Mercurial > ~darius > hgwebdir.cgi > tempctrl
comparison tempctrl.c @ 82:93388163e037 default tip
Fix 'none' mode.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 01 Apr 2013 23:39:25 +1030 |
parents | 781071a115be |
children |
comparison
equal
deleted
inserted
replaced
81:781071a115be | 82:93388163e037 |
---|---|
220 checktime = t + settings.check_interval; | 220 checktime = t + settings.check_interval; |
221 | 221 |
222 /* Don't do any logging, just force idle and leave */ | 222 /* Don't do any logging, just force idle and leave */ |
223 if (settings.mode == TC_MODE_NOTHING) { | 223 if (settings.mode == TC_MODE_NOTHING) { |
224 nextstate = 'i'; | 224 nextstate = 'i'; |
225 goto setstate; | 225 goto skip; |
226 } | 226 } |
227 | 227 |
228 /* Update our temperatures | 228 /* Update our temperatures |
229 * Can take a while (800ms each!) so reset the WDT | 229 * Can take a while (800ms each!) so reset the WDT |
230 */ | 230 */ |
257 diff = fermenter_temp - settings.target_temp; | 257 diff = fermenter_temp - settings.target_temp; |
258 | 258 |
259 switch (currstate) { | 259 switch (currstate) { |
260 case 'i': | 260 case 'i': |
261 /* If we're idle then only heat or cool if the temperate difference is out of the | 261 /* If we're idle then only heat or cool if the temperate difference is out of the |
262 * hysteresis band | 262 * hysteresis band and the heater/cooler have been off long enough |
263 */ | 263 */ |
264 if (abs(diff) > settings.hysteresis) { | 264 if (abs(diff) > settings.hysteresis) { |
265 if (diff < 0 && settings.minheatofftime + lastheatoff < t) | 265 if (diff < 0 && settings.minheatofftime + lastheatoff < t) |
266 nextstate = 'h'; | 266 nextstate = 'h'; |
267 else if (diff > 0 && settings.mincoolofftime + lastcooloff < t) | 267 else if (diff > 0 && settings.mincoolofftime + lastcooloff < t) |
309 else if (settings.mode == TC_MODE_HEAT) | 309 else if (settings.mode == TC_MODE_HEAT) |
310 nextstate = 'h'; | 310 nextstate = 'h'; |
311 else if (settings.mode == TC_MODE_COOL) | 311 else if (settings.mode == TC_MODE_COOL) |
312 nextstate = 'c'; | 312 nextstate = 'c'; |
313 | 313 |
314 // Keep track of when we last turned things on or off | 314 /* Keep track of when we last turned things on or off */ |
315 skip: | |
315 switch (nextstate) { | 316 switch (nextstate) { |
316 case 'c': | 317 case 'c': |
317 if (currstate == 'h') | 318 if (currstate == 'h') |
318 lastheatoff = t; | 319 lastheatoff = t; |
319 lastcoolon = t; | 320 lastcoolon = t; |
332 lastheatoff = t; | 333 lastheatoff = t; |
333 } | 334 } |
334 | 335 |
335 if (nextstate != '-') | 336 if (nextstate != '-') |
336 currstate = nextstate; | 337 currstate = nextstate; |
337 | 338 if (settings.mode != TC_MODE_NOTHING) { |
338 #if 0 | 339 #if 0 |
339 printf_P(PSTR("T: %10ld, "), t); | 340 printf_P(PSTR("T: %10ld, "), t); |
340 #else | 341 #else |
341 ds1307_printtime(PSTR(""), PSTR(": ")); | 342 ds1307_printtime(PSTR(""), PSTR(": ")); |
342 #endif | 343 #endif |
343 printtemp(PSTR("Tr"), settings.target_temp, PSTR(", ")); | 344 printtemp(PSTR("Tr"), settings.target_temp, PSTR(", ")); |
344 printtemp(PSTR("Fm"), tempt, PSTR(", ")); // Use actual value from sensor | 345 printtemp(PSTR("Fm"), tempt, PSTR(", ")); // Use actual value from sensor |
345 printtemp(PSTR("Fr"), fridge_temp, PSTR(", ")); | 346 printtemp(PSTR("Fr"), fridge_temp, PSTR(", ")); |
346 printtemp(PSTR("Am"), ambient_temp, PSTR(", ")); | 347 printtemp(PSTR("Am"), ambient_temp, PSTR(", ")); |
347 printf_P(PSTR("St: %S, Fl: %S%S\r\n"), state2long(currstate), | 348 printf_P(PSTR("St: %S, Fl: %S%S\r\n"), state2long(currstate), |
348 forced ? PSTR("F") : PSTR(""), | 349 forced ? PSTR("F") : PSTR(""), |
349 stale ? PSTR("S") : PSTR("")); | 350 stale ? PSTR("S") : PSTR("")); |
350 | 351 } |
351 setstate: | 352 |
352 setstate(currstate); | 353 setstate(currstate); |
353 } | 354 } |
354 | 355 |
355 /* Return 'time of day' (really uptime) */ | 356 /* Return 'time of day' (really uptime) */ |
356 int32_t | 357 int32_t |