- Move all separately declared functions in control.hpp to a new class 'controlledArmchair' - now passing other objects only one time with constructor instead of accessing them globally - Create control instance in config.hpp, and passing objects in config.cpp - Add functions to new control class - toggleIdle(): toggle between last mode and idle - toggleModes(mode1, mode2): toggle between two modes - Add commands to button.cpp - 2x button press: call toggleIdle() - 6x button press: toggleModes MASSAGE -> JOYSTICK - Define control task in main.cpp - Adjust button files and main.cpp to use the new command object instead of the previus functions
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "gpio_evaluateSwitch.hpp"
|
|
#include "buzzer.hpp"
|
|
#include "control.hpp"
|
|
|
|
|
|
|
|
//===================================
|
|
//====== buttonCommands class =======
|
|
//===================================
|
|
//class which runs commands depending on the count a button was pressed
|
|
class buttonCommands {
|
|
public:
|
|
//--- constructor ---
|
|
buttonCommands (
|
|
gpio_evaluatedSwitch * button_f,
|
|
controlledArmchair * control_f,
|
|
buzzer_t * buzzer_f
|
|
);
|
|
|
|
//--- functions ---
|
|
//the following function has to be started once in a separate task.
|
|
//repeatedly evaluates and processes button events then takes the corresponding action
|
|
void startHandleLoop();
|
|
|
|
private:
|
|
//--- functions ---
|
|
void action(uint8_t count);
|
|
|
|
//--- objects ---
|
|
gpio_evaluatedSwitch* button;
|
|
controlledArmchair * control;
|
|
buzzer_t* buzzer;
|
|
|
|
//--- variables ---
|
|
uint8_t count = 0;
|
|
uint32_t timestamp_lastAction = 0;
|
|
enum class inputState_t {IDLE, WAIT_FOR_INPUT};
|
|
inputState_t state = inputState_t::IDLE;
|
|
|
|
};
|
|
|