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