state-hander: timer for sensors

This commit is contained in:
Evgenii Meshcheriakov 2022-10-27 17:43:16 +03:00
parent 8212890897
commit 6cf950cc98
3 changed files with 6 additions and 3 deletions

View File

@ -116,6 +116,7 @@ private:
int saved_set_value[2] = { 0, 0 }; int saved_set_value[2] = { 0, 0 };
int saved_curr_value[2] = { 0, 0 }; int saved_curr_value[2] = { 0, 0 };
int sensors_data[4] = { 0 }; int sensors_data[4] = { 0 };
int sensor_timer = 0;
LiquidCrystal *_lcd; LiquidCrystal *_lcd;
Fan *_propeller; Fan *_propeller;
PressureWrapper *_pressure; PressureWrapper *_pressure;

View File

@ -19,7 +19,7 @@ enum _global_values
{ {
LCD_SIZE = 16, LCD_SIZE = 16,
TIMER_GLOBAL_TIMEOUT = 120000, TIMER_GLOBAL_TIMEOUT = 120000,
TIMER_SENSORS_TIMEOUT = 5000, TIMER_SENSORS_TIMEOUT = 5,
TIMER_PRESSURE_TIMEOUT = 150, TIMER_PRESSURE_TIMEOUT = 150,
TIMER_ERROR_VALUE = -255, TIMER_ERROR_VALUE = -255,
}; };

View File

@ -217,14 +217,16 @@ StateHandler::handleControlButtons (uint8_t button)
void void
StateHandler::handleTickValue (int value) StateHandler::handleTickValue (int value)
{ {
if (value % TIMER_SENSORS_TIMEOUT == 0) if (sensor_timer > TIMER_SENSORS_TIMEOUT)
{ {
updateSensorValues (); updateSensorValues ();
// displaySet (SENSORS); displaySet (SENSORS);
sensor_timer = 0;
} }
if (value > TIMER_PRESSURE_TIMEOUT) if (value > TIMER_PRESSURE_TIMEOUT)
{ {
SetState (&StateHandler::stateGetPressure); SetState (&StateHandler::stateGetPressure);
++sensor_timer;
state_timer->resetCounter (); state_timer->resetCounter ();
} }
if (value == TIMER_ERROR_VALUE) if (value == TIMER_ERROR_VALUE)