state-handler: simplify displaySet()
Simplify the function with a switch
This commit is contained in:
parent
cd06e2b3ba
commit
566d1d2659
@ -60,12 +60,7 @@ enum _bars
|
||||
enum _mode
|
||||
{
|
||||
MANUAL,
|
||||
AUTO
|
||||
};
|
||||
|
||||
enum _display
|
||||
{
|
||||
MODES,
|
||||
AUTO,
|
||||
SENSORS
|
||||
};
|
||||
|
||||
@ -105,9 +100,9 @@ public:
|
||||
*
|
||||
* AUTO MODE: P. SET: XXPa P. CURR: XXPa
|
||||
*
|
||||
* @param sensors the current printing mode
|
||||
* @param mode the current printing mode
|
||||
*/
|
||||
void displaySet (bool sensors);
|
||||
void displaySet (size_t mode);
|
||||
|
||||
/** Handle the given event of the current state
|
||||
*
|
||||
|
||||
@ -26,29 +26,31 @@ StateHandler::~StateHandler ()
|
||||
}
|
||||
|
||||
void
|
||||
StateHandler::displaySet (bool sensors)
|
||||
StateHandler::displaySet (size_t mode)
|
||||
{
|
||||
char line_up[16] = { 0 };
|
||||
char line_down[16] = { 0 };
|
||||
|
||||
if (sensors)
|
||||
switch (mode)
|
||||
{
|
||||
case MANUAL:
|
||||
snprintf (line_up, 16, "SPEED: %02d%", saved_set_value[current_mode]);
|
||||
snprintf (line_down, 16, "PRESSURE: %02dPa",
|
||||
saved_curr_value[current_mode]);
|
||||
break;
|
||||
case AUTO:
|
||||
snprintf (line_up, 16, "P. SET: %02dPa", saved_set_value[current_mode]);
|
||||
snprintf (line_down, 16, "P. CURR: %02dPa",
|
||||
saved_curr_value[current_mode]);
|
||||
break;
|
||||
case SENSORS:
|
||||
snprintf (line_up, 16, "PRE:%02d TEM:%02d", sensors_data[PRESSUREDAT],
|
||||
sensors_data[TEMPERATURE]);
|
||||
snprintf (line_down, 16, "HUM:%02d CO2:%02d", sensors_data[HUMIDITY],
|
||||
sensors_data[CO2]);
|
||||
}
|
||||
else if (current_mode == MANUAL)
|
||||
{
|
||||
snprintf (line_up, 16, "SPEED: %02d%", saved_set_value[current_mode]);
|
||||
snprintf (line_down, 16, "PRESSURE: %02dPa",
|
||||
saved_curr_value[current_mode]);
|
||||
}
|
||||
else if (current_mode == AUTO)
|
||||
{
|
||||
snprintf (line_up, 16, "P. SET: %02dPa", saved_set_value[current_mode]);
|
||||
snprintf (line_down, 16, "P. CURR: %02dPa",
|
||||
saved_curr_value[current_mode]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_lcd->clear ();
|
||||
@ -247,7 +249,7 @@ StateHandler::save (int eventValue, size_t mode)
|
||||
{
|
||||
saved_curr_value[mode] = eventValue;
|
||||
saved_set_value[mode] = counterValue;
|
||||
displaySet (MODES);
|
||||
displaySet ((current_mode) ? AUTO : MANUAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user