diff --git a/esp-vent-main/inc/StateHandler/StateHandler.h b/esp-vent-main/inc/StateHandler/StateHandler.h index 5673839..12c085a 100644 --- a/esp-vent-main/inc/StateHandler/StateHandler.h +++ b/esp-vent-main/inc/StateHandler/StateHandler.h @@ -116,6 +116,7 @@ private: int saved_set_value[2] = { 0, 0 }; int saved_curr_value[2] = { 0, 0 }; int sensors_data[4] = { 0 }; + int sensor_timer = 0; LiquidCrystal *_lcd; Fan *_propeller; PressureWrapper *_pressure; diff --git a/esp-vent-main/inc/common_control_values.h b/esp-vent-main/inc/common_control_values.h index c23ef7b..25605a7 100644 --- a/esp-vent-main/inc/common_control_values.h +++ b/esp-vent-main/inc/common_control_values.h @@ -19,7 +19,7 @@ enum _global_values { LCD_SIZE = 16, TIMER_GLOBAL_TIMEOUT = 120000, - TIMER_SENSORS_TIMEOUT = 5000, + TIMER_SENSORS_TIMEOUT = 5, TIMER_PRESSURE_TIMEOUT = 150, TIMER_ERROR_VALUE = -255, }; diff --git a/esp-vent-main/src/StateHandler/StateHandler.cpp b/esp-vent-main/src/StateHandler/StateHandler.cpp index 6125c36..028410e 100644 --- a/esp-vent-main/src/StateHandler/StateHandler.cpp +++ b/esp-vent-main/src/StateHandler/StateHandler.cpp @@ -217,14 +217,16 @@ StateHandler::handleControlButtons (uint8_t button) void StateHandler::handleTickValue (int value) { - if (value % TIMER_SENSORS_TIMEOUT == 0) + if (sensor_timer > TIMER_SENSORS_TIMEOUT) { updateSensorValues (); - // displaySet (SENSORS); + displaySet (SENSORS); + sensor_timer = 0; } if (value > TIMER_PRESSURE_TIMEOUT) { SetState (&StateHandler::stateGetPressure); + ++sensor_timer; state_timer->resetCounter (); } if (value == TIMER_ERROR_VALUE)