diff --git a/esp-vent-main/inc/StateHandler/StateHandler.h b/esp-vent-main/inc/StateHandler/StateHandler.h index 12c085a..8229e59 100644 --- a/esp-vent-main/inc/StateHandler/StateHandler.h +++ b/esp-vent-main/inc/StateHandler/StateHandler.h @@ -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; diff --git a/esp-vent-main/inc/common_control_values.h b/esp-vent-main/inc/common_control_values.h index 25605a7..b9846d6 100644 --- a/esp-vent-main/inc/common_control_values.h +++ b/esp-vent-main/inc/common_control_values.h @@ -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, }; diff --git a/esp-vent-main/src/StateHandler/StateHandler.cpp b/esp-vent-main/src/StateHandler/StateHandler.cpp index 028410e..ad599c6 100644 --- a/esp-vent-main/src/StateHandler/StateHandler.cpp +++ b/esp-vent-main/src/StateHandler/StateHandler.cpp @@ -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; } } diff --git a/esp-vent-main/src/esp-vent-main.cpp b/esp-vent-main/src/esp-vent-main.cpp index 3559acb..41b65aa 100644 --- a/esp-vent-main/src/esp-vent-main.cpp +++ b/esp-vent-main/src/esp-vent-main.cpp @@ -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 ();