StateHandler: add functionality to control fan speed in Manual mode. Main: Modbus object + pressure display

This commit is contained in:
Evgenii Meshcheriakov
2022-10-18 15:21:34 +03:00
parent 67bc1589dd
commit 4a414ea70f
3 changed files with 25 additions and 6 deletions

View File

@@ -19,6 +19,8 @@
#include "DigitalIoPin.h"
#include "Event.h"
#include "LiquidCrystal.h"
#include "ModbusMaster.h"
#include "ModbusRegister.h"
/** Buttons enumeration
*
@@ -63,7 +65,7 @@ typedef void (StateHandler::*state_pointer) (const Event &);
class StateHandler
{
public:
StateHandler (LiquidCrystal *lcd);
StateHandler (LiquidCrystal *lcd, ModbusRegister *A01);
virtual ~StateHandler ();
/** Get currently set pressure
@@ -106,6 +108,7 @@ private:
int saved_set_value[2] = { 0, 0 };
int saved_curr_value[2] = { 0, 0 };
LiquidCrystal *_lcd;
ModbusRegister *A01;
/** Initialization state
*

View File

@@ -7,9 +7,10 @@
#include <StateHandler.h>
StateHandler::StateHandler (LiquidCrystal *lcd)
StateHandler::StateHandler (LiquidCrystal *lcd, ModbusRegister *A01)
{
this->_lcd = lcd;
this->A01 = A01;
current = &StateHandler::stateInit;
(this->*current) (Event (Event::eEnter));
current_mode = MANUAL;
@@ -143,9 +144,13 @@ StateHandler::handleControlButtons (uint8_t button)
{
case BUTTON_CONTROL_DOWN:
this->value[(current_mode) ? AUTO : MANUAL].dec ();
if(current_mode == MANUAL)
this->A01->write(value[(current_mode) ? AUTO : MANUAL].getCurrent() * 10);
break;
case BUTTON_CONTROL_UP:
this->value[(current_mode) ? AUTO : MANUAL].inc ();
if(current_mode == MANUAL)
this->A01->write(value[(current_mode) ? AUTO : MANUAL].getCurrent() * 10);
break;
case BUTTON_CONTROL_TOG_MODE:
current_mode = !current_mode;