jonny_jr9 2fcf17feda Major Rework all files - Pass pointers to tasks, Remove gloabl variables
- All files:
  Modify almost all files to adjust functions and classes to
  work with pointers to objects passed at task creation
  instead of global variables from config.hpp

- Remove/clear config.hpp to get rid of all global variables

- main.cpp
    - Create pointer to all shared (used in multiple tasks) objects in main

- remove evaluatedSwitch button object,
  since joystick library is used to get switch events

- changes HTTP-mode
    - always init http-server (do not enable/disable at mode change)
    - pass url-handle function to init-htpp function
    - add lambda function to pass method of instance for thatMajor Rework all files - Remove global variables, pass pointers to tasks

- All files:
  Modify almost all files to adjust functions and classes to
  work with pointers to objects passed at task creation
  instead of global variables from config.hpp

- Remove/clear config.hpp to get rid of all global variables

- main.cpp
    - Create pointer to all shared (used in multiple tasks) objects in main

- remove evaluatedSwitch button object,
  since joystick library is used to get switch events

- changes HTTP-mode
    - always init http-server (do not enable/disable at mode change)
    - pass url-handle function to init-htpp function
    - add lambda function to pass method of instance for that

NOTES:  - tested on breakoutboard only
        - known issue that slow encoder events are not recognized
        (especially in menu) - slowing down motorctl helps
2024-02-18 10:00:34 +01:00

70 lines
2.0 KiB
C++

#pragma once
#include "gpio_evaluateSwitch.hpp"
#include "buzzer.hpp"
#include "control.hpp"
#include "motorctl.hpp"
#include "auto.hpp"
#include "config.hpp"
#include "joystick.hpp"
//===================================
//====== buttonCommands class =======
//===================================
//class which runs commands depending on the count a button was pressed
class buttonCommands {
public:
//--- constructor ---
buttonCommands(
controlledArmchair *control_f,
evaluatedJoystick *joystick_f,
QueueHandle_t encoderQueue_f,
controlledMotor * motorLeft_f,
controlledMotor *motorRight_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, bool lastPressLong);
//--- objects ---
controlledArmchair * control;
evaluatedJoystick* joystick;
controlledMotor * motorLeft;
controlledMotor * motorRight;
buzzer_t* buzzer;
QueueHandle_t encoderQueue;
//--- variables ---
uint8_t count = 0;
uint32_t timestamp_lastAction = 0;
enum class inputState_t {IDLE, WAIT_FOR_INPUT};
inputState_t state = inputState_t::IDLE;
};
//======================================
//============ button task =============
//======================================
// struct with variables passed to task from main
typedef struct task_button_parameters_t
{
controlledArmchair *control;
evaluatedJoystick *joystick;
QueueHandle_t encoderQueue;
controlledMotor *motorLeft;
controlledMotor *motorRight;
buzzer_t *buzzer;
} task_button_parameters_t;
//task that handles the button interface/commands
void task_button( void * task_button_parameters );