error-handler: pending task
This commit is contained in:
parent
dc43afd441
commit
857e50a62b
@ -122,6 +122,8 @@ private:
|
||||
Fan *_propeller;
|
||||
PressureWrapper *_pressure;
|
||||
bool pressure_status;
|
||||
bool task_is_pending;
|
||||
uint8_t pressure_achieved;
|
||||
Timer *state_timer;
|
||||
/* CO2 sensor object */
|
||||
GMP252 co2;
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
enum _global_values
|
||||
{
|
||||
LCD_SIZE = 16,
|
||||
TIMER_GLOBAL_TIMEOUT = 10000,
|
||||
TIMER_GLOBAL_TIMEOUT = 120000,
|
||||
TIMER_SENSORS_TIMEOUT = 5000,
|
||||
TIMER_PRESSURE_TIMEOUT = 150,
|
||||
TIMER_ERROR_VALUE = -255,
|
||||
|
||||
@ -17,6 +17,7 @@ StateHandler::StateHandler (LiquidCrystal *lcd, Fan *propeller,
|
||||
current = &StateHandler::stateInit;
|
||||
(this->*current) (Event (Event::eEnter));
|
||||
current_mode = MANUAL;
|
||||
pressure_achieved = 0;
|
||||
}
|
||||
|
||||
StateHandler::~StateHandler ()
|
||||
@ -149,8 +150,19 @@ StateHandler::stateAuto (const Event &event)
|
||||
break;
|
||||
case Event::eTick:
|
||||
handleTickValue (event.value);
|
||||
if(saved_set_value[AUTO]){
|
||||
pid ();
|
||||
this->_propeller->spin (fan_speed.getCurrent ());
|
||||
}
|
||||
if (saved_curr_value[AUTO] == saved_set_value[AUTO])
|
||||
{
|
||||
++pressure_achieved;
|
||||
}
|
||||
if (pressure_achieved > 5)
|
||||
{
|
||||
pressure_achieved = 0;
|
||||
task_is_pending = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -185,6 +197,8 @@ StateHandler::stateGetPressure (const Event &event)
|
||||
void
|
||||
StateHandler::handleControlButtons (uint8_t button)
|
||||
{
|
||||
task_is_pending = true;
|
||||
error_timer = 0;
|
||||
switch (button)
|
||||
{
|
||||
case BUTTON_CONTROL_DOWN:
|
||||
@ -220,7 +234,7 @@ StateHandler::handleTickValue (int value)
|
||||
if (sensor_timer > TIMER_SENSORS_TIMEOUT)
|
||||
{
|
||||
updateSensorValues ();
|
||||
displaySet (SENSORS);
|
||||
//displaySet (SENSORS);
|
||||
sensor_timer = 0;
|
||||
}
|
||||
if (value > TIMER_PRESSURE_TIMEOUT)
|
||||
@ -230,16 +244,17 @@ StateHandler::handleTickValue (int value)
|
||||
error_timer += value;
|
||||
state_timer->resetCounter ();
|
||||
}
|
||||
if (error_timer > TIMER_GLOBAL_TIMEOUT)
|
||||
if (error_timer > TIMER_GLOBAL_TIMEOUT && task_is_pending)
|
||||
{
|
||||
this->fan_speed.setInit (0);
|
||||
this->_propeller->spin (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;
|
||||
SetState (&StateHandler::stateInit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user