timers: create proper timeouts
This commit is contained in:
parent
6cf950cc98
commit
dc43afd441
@ -117,6 +117,7 @@ private:
|
||||
int saved_curr_value[2] = { 0, 0 };
|
||||
int sensors_data[4] = { 0 };
|
||||
int sensor_timer = 0;
|
||||
int error_timer = 0;
|
||||
LiquidCrystal *_lcd;
|
||||
Fan *_propeller;
|
||||
PressureWrapper *_pressure;
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
enum _global_values
|
||||
{
|
||||
LCD_SIZE = 16,
|
||||
TIMER_GLOBAL_TIMEOUT = 120000,
|
||||
TIMER_SENSORS_TIMEOUT = 5,
|
||||
TIMER_GLOBAL_TIMEOUT = 10000,
|
||||
TIMER_SENSORS_TIMEOUT = 5000,
|
||||
TIMER_PRESSURE_TIMEOUT = 150,
|
||||
TIMER_ERROR_VALUE = -255,
|
||||
};
|
||||
|
||||
@ -226,15 +226,20 @@ StateHandler::handleTickValue (int value)
|
||||
if (value > TIMER_PRESSURE_TIMEOUT)
|
||||
{
|
||||
SetState (&StateHandler::stateGetPressure);
|
||||
++sensor_timer;
|
||||
sensor_timer += value;
|
||||
error_timer += value;
|
||||
state_timer->resetCounter ();
|
||||
}
|
||||
if (value == TIMER_ERROR_VALUE)
|
||||
if (error_timer > TIMER_GLOBAL_TIMEOUT)
|
||||
{
|
||||
displaySet (ERROR_TIMEOUT);
|
||||
this->fan_speed.setInit (0);
|
||||
this->value[(current_mode)].setInit (0);
|
||||
saveSetAndDisplay(AUTO);
|
||||
displaySet (ERROR_TIMEOUT);
|
||||
SetState (&StateHandler::stateInit);
|
||||
state_timer->Sleep(2000);
|
||||
state_timer->resetCounter();
|
||||
error_timer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -87,11 +87,6 @@ main (void)
|
||||
i1 = DWT->CYCCNT;
|
||||
|
||||
getcounterValue = glob_time.getCounter ();
|
||||
if (getcounterValue > TIMER_GLOBAL_TIMEOUT)
|
||||
{
|
||||
glob_time.resetCounter ();
|
||||
ventMachine.HandleState (Event (Event::eTick, TIMER_ERROR_VALUE));
|
||||
}
|
||||
sw_up.listen ();
|
||||
sw_down.listen ();
|
||||
sw_toggle.listen ();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user