StateHandler: add functionality to control fan speed in Manual mode. Main: Modbus object + pressure display
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user