state-handler: replace EVENT_HANDL struct with enum

This is done due to passing the values to the key event of the state
This commit is contained in:
Vasily Davydov 2022-10-05 11:10:29 +03:00
parent f77fd5040d
commit b231d6e9db
2 changed files with 21 additions and 17 deletions

View File

@ -18,29 +18,35 @@
#include "DigitalIoPin.h" #include "DigitalIoPin.h"
#include "Counter.h" #include "Counter.h"
/** A structure to hold button pointers /** Buttons enumeration
*
* Main four buttons that operate the
* whole program. The structure should be
* initialized in main with correct values and
* passed to main EvenHandler object constructor.
* *
* Current switch state is being passed
* from main to StateHandler through
* a keyEvent. Enumeration determines the state
* of the particular button.
* */ * */
typedef struct _EVENT_HANDL{
DigitalIoPin * _button_control_up; enum _buttons {
DigitalIoPin * _button_control_down; /** Raises the bar up */
DigitalIoPin * _button_control_toggle_mode; BUTTON_CONTROL_UP,
DigitalIoPin * _button_control_toggle_active; /** Raises the bar down */
} EVENT_HANDL; BUTTON_CONTROL_DOWN,
/** Toggles the mode between auto and
* manual, which changes the state */
BUTTON_CONTROL_TOG_MODE,
/** Optional button to toggle the
* activation of the current setting.
* Not compulsory to be used. */
BUTTON_CONTROL_TOG_ACTIVE
};
class StateHandler { class StateHandler {
public: public:
StateHandler(EVENT_HANDL btns); StateHandler();
virtual ~StateHandler(); virtual ~StateHandler();
int getSetPresuure(); // Get currently set pressure 0-100% int getSetPresuure(); // Get currently set pressure 0-100%
int getSetSpeed(); //Get currently set FanSpeed 0-100% int getSetSpeed(); //Get currently set FanSpeed 0-100%
private: private:
EVENT_HANDL internal = {0,0,0,0};
bool mode; bool mode;
Counter * bar_pressure; Counter * bar_pressure;
Counter * bar_speed; Counter * bar_speed;

View File

@ -7,8 +7,6 @@
#include "Counter.h" #include "Counter.h"
#include "Counter.h"
void Counter::inc() { void Counter::inc() {
if(init >= up_lim){ if(init >= up_lim){
init = 0; init = 0;