Commit b4a7f4ac06c6560db8bba32bb035902755abe2e3
1 parent
6e35f0fb
Querying for pump informations
Showing
1 changed file
with
21 additions
and
2 deletions
Show diff stats
... | ... | @@ -27,10 +27,14 @@ |
27 | 27 | #define SET_HEAT_OFF 'G' |
28 | 28 | #define SET_PUMP_ON 'B' |
29 | 29 | #define SET_PUMP_OFF 'D' |
30 | +#define PUMP_STATE_HIGH 'I' | |
31 | +#define GET_PUMP 'F' | |
30 | 32 | |
31 | 33 | // Globals |
32 | 34 | int hvc_fd = -1; |
33 | 35 | bool hvcStop = false; |
36 | +int pumped = 0; | |
37 | +bool previousPumpState; | |
34 | 38 | bool sPump = false; |
35 | 39 | bool sHeat = false; |
36 | 40 | bool autoHeat = false; |
... | ... | @@ -47,6 +51,7 @@ int tempCons; |
47 | 51 | |
48 | 52 | void setPumpOn() |
49 | 53 | { |
54 | + pumped = 0; | |
50 | 55 | setPumpWantedState(true); |
51 | 56 | } |
52 | 57 | |
... | ... | @@ -120,13 +125,19 @@ bool initHVC() |
120 | 125 | return false; |
121 | 126 | } |
122 | 127 | |
128 | + sendData(&hvc_fd, GET_PUMP); | |
129 | + data = getData(&hvc_fd); | |
130 | + | |
131 | + previousPumpState = data == PUMP_STATE_HIGH; | |
132 | + | |
123 | 133 | return true; |
124 | 134 | } |
125 | 135 | |
126 | 136 | void* processHVC(void* we) |
127 | 137 | { |
128 | - uint8_t data; | |
129 | - float temp; | |
138 | + uint8_t data; | |
139 | + bool pumpState; | |
140 | + float temp; | |
130 | 141 | |
131 | 142 | while(!hvcStop) |
132 | 143 | { |
... | ... | @@ -175,6 +186,14 @@ void* processHVC(void* we) |
175 | 186 | tPumpStart = clock(); |
176 | 187 | } |
177 | 188 | |
189 | + // Querying pump state | |
190 | + sendData(&hvc_fd, GET_TEMP); | |
191 | + data = getData(&hvc_fd); | |
192 | + pumpState = data == PUMP_STATE_HIGH; | |
193 | + if(pumpState ^ previousPumpState) | |
194 | + pumped++; | |
195 | + previousPumpState = pumpState; | |
196 | + | |
178 | 197 | usleep(HVC_POLLING_TIME); |
179 | 198 | } |
180 | 199 | ... | ... |