Mercurial > ~darius > hgwebdir.cgi > stm32temp
comparison tempctrl.c @ 43:b4440f9f6d47
Fix 'none' mode.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 01 Apr 2013 23:38:34 +1030 |
parents | 56b32b0c9a40 |
children | adc9b1555f9d |
comparison
equal
deleted
inserted
replaced
42:56b32b0c9a40 | 43:b4440f9f6d47 |
---|---|
173 checktime = t + settings.check_interval; | 173 checktime = t + settings.check_interval; |
174 | 174 |
175 /* Don't do any logging, just force idle and leave */ | 175 /* Don't do any logging, just force idle and leave */ |
176 if (settings.mode == TC_MODE_NOTHING) { | 176 if (settings.mode == TC_MODE_NOTHING) { |
177 nextstate = 'i'; | 177 nextstate = 'i'; |
178 goto setstate; | 178 goto skip; |
179 } | 179 } |
180 | 180 |
181 /* Update our temperatures | 181 /* Update our temperatures |
182 * Can take a while (800ms each!) | 182 * Can take a while (800ms each!) |
183 */ | 183 */ |
206 diff = fermenter_temp - settings.target_temp; | 206 diff = fermenter_temp - settings.target_temp; |
207 | 207 |
208 switch (currstate) { | 208 switch (currstate) { |
209 case 'i': | 209 case 'i': |
210 /* If we're idle then only heat or cool if the temperate difference is out of the | 210 /* If we're idle then only heat or cool if the temperate difference is out of the |
211 * hysteresis band | 211 * hysteresis band and the heater/cooler have been off long enough |
212 */ | 212 */ |
213 if (abs(diff) > settings.hysteresis) { | 213 if (abs(diff) > settings.hysteresis) { |
214 if (diff < 0 && settings.minheatofftime + lastheatoff < t) | 214 if (diff < 0 && settings.minheatofftime + lastheatoff < t) |
215 nextstate = 'h'; | 215 nextstate = 'h'; |
216 else if (diff > 0 && settings.mincoolofftime + lastcooloff < t) | 216 else if (diff > 0 && settings.mincoolofftime + lastcooloff < t) |
252 else if (settings.mode == TC_MODE_HEAT) | 252 else if (settings.mode == TC_MODE_HEAT) |
253 nextstate = 'h'; | 253 nextstate = 'h'; |
254 else if (settings.mode == TC_MODE_COOL) | 254 else if (settings.mode == TC_MODE_COOL) |
255 nextstate = 'c'; | 255 nextstate = 'c'; |
256 | 256 |
257 // Keep track of when we last turned things on or off | 257 /* Keep track of when we last turned things on or off */ |
258 skip: | |
258 switch (nextstate) { | 259 switch (nextstate) { |
259 case 'c': | 260 case 'c': |
260 if (currstate == 'h') | 261 if (currstate == 'h') |
261 lastheatoff = t; | 262 lastheatoff = t; |
262 lastcoolon = t; | 263 lastcoolon = t; |
277 | 278 |
278 if (nextstate != '-') | 279 if (nextstate != '-') |
279 currstate = nextstate; | 280 currstate = nextstate; |
280 | 281 |
281 | 282 |
282 localtime_r(&t, &tm); | 283 if (settings.mode != TC_MODE_NOTHING) { |
283 assert(strftime(buf, sizeof(buf) - 1, "%Y/%m/%d %H:%M:%S: ", &tm) != 0); | 284 localtime_r(&t, &tm); |
284 fputs(buf, stdout); | 285 assert(strftime(buf, sizeof(buf) - 1, "%Y/%m/%d %H:%M:%S: ", &tm) != 0); |
285 printtemp("Tr", settings.target_temp, ", "); | 286 fputs(buf, stdout); |
286 printtemp("Fm", tempt, ", "); // Use actual value from sensor | 287 printtemp("Tr", settings.target_temp, ", "); |
287 printtemp("Fr", fridge_temp, ", "); | 288 printtemp("Fm", tempt, ", "); // Use actual value from sensor |
288 printtemp("Am", ambient_temp, ", "); | 289 printtemp("Fr", fridge_temp, ", "); |
289 printf("St: %s, Fl: %s%s\r\n", state2long(currstate), | 290 printtemp("Am", ambient_temp, ", "); |
290 forced ? "F" : "", | 291 printf("St: %s, Fl: %s%s\r\n", state2long(currstate), |
291 stale ? "S" : ""); | 292 forced ? "F" : "", |
292 | 293 stale ? "S" : ""); |
293 setstate: | 294 } |
295 | |
294 setstate(currstate); | 296 setstate(currstate); |
295 } | 297 } |
296 | 298 |
297 /* | 299 /* |
298 * Print out temperature (or short error code) with specified trailer | 300 * Print out temperature (or short error code) with specified trailer |