Mercurial > ~darius > hgwebdir.cgi > avr
diff tempctrl.c @ 42:97ae82023d5b
Actually keep track of when the heater & cooler go on/off..
author | darius@inchoate.localdomain |
---|---|
date | Sun, 06 Jul 2008 22:28:21 +0930 |
parents | 5898fba6593c |
children | 51e7458d2e76 |
line wrap: on
line diff
--- a/tempctrl.c Sun Jul 06 22:19:53 2008 +0930 +++ b/tempctrl.c Sun Jul 06 22:28:21 2008 +0930 @@ -38,10 +38,6 @@ #include "1wire.h" #include "tempctrl.h" -/* Helpers for our number system */ -#define GETWHOLE(x) ((x) / 100) -#define GETFRAC(x) ((x) - (GETWHOLE(x) * 100)) - typedef struct { int32_t sec; int32_t usec; @@ -280,6 +276,27 @@ else if (settings.mode == TC_MODE_COOL) nextstate = 'c'; + // Keep track of when we last turned things on or off + switch (nextstate) { + case 'c': + if (currstate == 'h') + lastheatoff = t; + lastcoolon = t; + break; + + case 'h': + if (currstate == 'c') + lastcooloff = t; + lastheaton = t; + break; + + default: + if (currstate == 'c') + lastcooloff = t; + if (currstate == 'h') + lastheatoff = t; + } + if (nextstate != '-') currstate = nextstate;