# HG changeset patch # User Daniel O'Connor # Date 1364821714 -37800 # Node ID b4440f9f6d4709737fac757a4b81d7a1010e6b6d # Parent 56b32b0c9a4089d23d8591d898c44dabad8ee199 Fix 'none' mode. diff -r 56b32b0c9a40 -r b4440f9f6d47 tempctrl.c --- a/tempctrl.c Mon Apr 01 21:12:57 2013 +1030 +++ b/tempctrl.c Mon Apr 01 23:38:34 2013 +1030 @@ -175,7 +175,7 @@ /* Don't do any logging, just force idle and leave */ if (settings.mode == TC_MODE_NOTHING) { nextstate = 'i'; - goto setstate; + goto skip; } /* Update our temperatures @@ -208,7 +208,7 @@ switch (currstate) { case 'i': /* If we're idle then only heat or cool if the temperate difference is out of the - * hysteresis band + * hysteresis band and the heater/cooler have been off long enough */ if (abs(diff) > settings.hysteresis) { if (diff < 0 && settings.minheatofftime + lastheatoff < t) @@ -254,7 +254,8 @@ else if (settings.mode == TC_MODE_COOL) nextstate = 'c'; - // Keep track of when we last turned things on or off + /* Keep track of when we last turned things on or off */ + skip: switch (nextstate) { case 'c': if (currstate == 'h') @@ -279,18 +280,19 @@ currstate = nextstate; - localtime_r(&t, &tm); - assert(strftime(buf, sizeof(buf) - 1, "%Y/%m/%d %H:%M:%S: ", &tm) != 0); - fputs(buf, stdout); - printtemp("Tr", settings.target_temp, ", "); - printtemp("Fm", tempt, ", "); // Use actual value from sensor - printtemp("Fr", fridge_temp, ", "); - printtemp("Am", ambient_temp, ", "); - printf("St: %s, Fl: %s%s\r\n", state2long(currstate), - forced ? "F" : "", - stale ? "S" : ""); + if (settings.mode != TC_MODE_NOTHING) { + localtime_r(&t, &tm); + assert(strftime(buf, sizeof(buf) - 1, "%Y/%m/%d %H:%M:%S: ", &tm) != 0); + fputs(buf, stdout); + printtemp("Tr", settings.target_temp, ", "); + printtemp("Fm", tempt, ", "); // Use actual value from sensor + printtemp("Fr", fridge_temp, ", "); + printtemp("Am", ambient_temp, ", "); + printf("St: %s, Fl: %s%s\r\n", state2long(currstate), + forced ? "F" : "", + stale ? "S" : ""); + } - setstate: setstate(currstate); }