comparison tempctrl.c @ 62:e955aa7047ed

Don't update the temperature we make decisions if it is invalid.
author darius@Inchoate
date Thu, 30 Oct 2008 20:09:02 +1030
parents 50fca9562310
children 1ef17cd8af7a
comparison
equal deleted inserted replaced
61:0910ab6f0095 62:e955aa7047ed
214 static char currstate = 'i'; // Current state 214 static char currstate = 'i'; // Current state
215 /* We init to times to INT32_MIN so that things function properly when 215 /* We init to times to INT32_MIN so that things function properly when
216 * now < settings.minheat/cool/on/offtime */ 216 * now < settings.minheat/cool/on/offtime */
217 217
218 /* Temporary variables */ 218 /* Temporary variables */
219 int32_t t; 219 int32_t t, tempt;
220 int16_t diff; 220 int16_t diff;
221 char nextstate; 221 char nextstate;
222 int forced; 222 int forced;
223 int stale; 223 int stale;
224 224
234 nextstate = 'i'; 234 nextstate = 'i';
235 goto setstate; 235 goto setstate;
236 } 236 }
237 237
238 /* Update our temperatures */ 238 /* Update our temperatures */
239 fermenter_temp = OWGetTemp(settings.fermenter_ROM); 239 tempt = OWGetTemp(settings.fermenter_ROM);
240 fridge_temp = OWGetTemp(settings.fridge_ROM); 240 fridge_temp = OWGetTemp(settings.fridge_ROM);
241 ambient_temp = OWGetTemp(settings.ambient_ROM); 241 ambient_temp = OWGetTemp(settings.ambient_ROM);
242 242
243 if (fermenter_temp > OW_TEMP_BADVAL) 243 /* We only care about this one, only update the value we decide on
244 * only if it is valid
245 */
246 if (fermenter_temp > OW_TEMP_BADVAL) {
247 fermenter_temp = tempt;
244 lastdata = t; 248 lastdata = t;
245 249 }
250
246 /* Check for stale data */ 251 /* Check for stale data */
247 if (lastdata + (settings.check_interval * settings.stale_factor) < t) 252 if (lastdata + (settings.check_interval * settings.stale_factor) < t)
248 stale = 1; 253 stale = 1;
249 else 254 else
250 stale = 0; 255 stale = 0;
340 printf_P(PSTR("Time: %10ld, "), t); 345 printf_P(PSTR("Time: %10ld, "), t);
341 #else 346 #else
342 ds1307_printtime(PSTR(""), PSTR(": ")); 347 ds1307_printtime(PSTR(""), PSTR(": "));
343 #endif 348 #endif
344 printtemp(PSTR("Target"), settings.target_temp, PSTR(", ")); 349 printtemp(PSTR("Target"), settings.target_temp, PSTR(", "));
345 printtemp(PSTR("Fermenter"), fermenter_temp, PSTR(", ")); 350 printtemp(PSTR("Fermenter"), tempt, PSTR(", ")); // Use actual value from sensor
346 printtemp(PSTR("Fridge"), fridge_temp, PSTR(", ")); 351 printtemp(PSTR("Fridge"), fridge_temp, PSTR(", "));
347 printtemp(PSTR("Ambient"), ambient_temp, PSTR(", ")); 352 printtemp(PSTR("Ambient"), ambient_temp, PSTR(", "));
348 printf_P(PSTR("State: %S, Flags: %S%S\r\n"), state2long(currstate), 353 printf_P(PSTR("State: %S, Flags: %S%S\r\n"), state2long(currstate),
349 forced ? PSTR("F") : PSTR(""), 354 forced ? PSTR("F") : PSTR(""),
350 stale ? PSTR("S") : PSTR("")); 355 stale ? PSTR("S") : PSTR(""));