main/co2meter.c

changeset 8
c6bbd1380f22
parent 7
6eafc4c2bf3d
child 9
a85995941d0d
equal deleted inserted replaced
7:6eafc4c2bf3d 8:c6bbd1380f22
277 u8g2_SetFont(&u8g2, u8g2_font_t0_18b_tf); 277 u8g2_SetFont(&u8g2, u8g2_font_t0_18b_tf);
278 278
279 /* Copy measured data and calculate results */ 279 /* Copy measured data and calculate results */
280 if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) { 280 if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) {
281 for (int i = 0; i < 3; i++) { 281 for (int i = 0; i < 3; i++) {
282 if (i == 0)
283 units[i].mode = 1;
282 units[i].temperature = temp; 284 units[i].temperature = temp;
283 units[i].temperature_state = state; 285 units[i].temperature_state = state;
286 units[i].alarm = 0;
287 if (state)
288 units[i].alarm |= ALARM_SYS_TEMPERATURE & ALARM_UNIT_TEMPERATURE;
284 strncpy(units[i].temperature_rom_code, rom_code, 17); 289 strncpy(units[i].temperature_rom_code, rom_code, 17);
285 if (xSemaphoreTake(xSemaphoreADC, 10) == pdTRUE) { 290 if (xSemaphoreTake(xSemaphoreADC, 10) == pdTRUE) {
286 units[i].pressure_state = adc_state->Pressure[i].error; 291 units[i].pressure_state = adc_state->Pressure[i].error;
287 units[i].pressure_channel = adc_state->Pressure[i].channel; 292 units[i].pressure_channel = adc_state->Pressure[i].channel;
288 units[i].pressure_voltage = adc_state->Pressure[i].voltage; 293 units[i].pressure_voltage = adc_state->Pressure[i].voltage;
289 units[i].pressure_zero = 110; 294 units[i].pressure_zero = 110;
295 if (units[i].pressure_state || units[i].pressure_voltage < 80)
296 units[i].alarm |= ALARM_UNIT_PRESSURE;
290 int P = (units[i].pressure_voltage / (adc_state->Batt_voltage / 1000) - units[i].pressure_zero) * 14; // in bar 297 int P = (units[i].pressure_voltage / (adc_state->Batt_voltage / 1000) - units[i].pressure_zero) * 14; // in bar
291 if (P < 0) 298 if (P < 0)
292 P = 0; 299 P = 0;
293 units[i].pressure = P; 300 units[i].pressure = P;
294 sprintf(buf, "%.1f", P / 1000.0); 301 sprintf(buf, "%.1f", P / 1000.0);

mercurial