Pass joystick object to button class

the joystick object is now available in the button class/task
thus can be used to trigger commands with certain combinations of
joystick and button
- not used yet -
This commit is contained in:
jonny_l480 2022-08-11 13:32:16 +02:00
parent fb9e9ede25
commit 0148f69fab
3 changed files with 9 additions and 2 deletions

View File

@ -19,9 +19,10 @@ static const char * TAG = "button";
//-----------------------------
//-------- constructor --------
//-----------------------------
buttonCommands::buttonCommands(gpio_evaluatedSwitch * button_f, controlledArmchair * control_f, buzzer_t * buzzer_f, controlledMotor * motorLeft_f, controlledMotor * motorRight_f){
buttonCommands::buttonCommands(gpio_evaluatedSwitch * button_f, evaluatedJoystick * joystick_f, controlledArmchair * control_f, buzzer_t * buzzer_f, controlledMotor * motorLeft_f, controlledMotor * motorRight_f){
//copy object pointers
button = button_f;
joystick = joystick_f;
control = control_f;
buzzer = buzzer_f;
motorLeft = motorLeft_f;
@ -40,6 +41,9 @@ void buttonCommands::action (uint8_t count){
bool decelEnabled; //for different beeping when toggling
commandSimple_t cmds[8]; //array for commands for automatedArmchair
//--- get joystick position ---
//joystickData_t stickData = joystick->getData();
//--- actions based on count ---
switch (count){
//no such command

View File

@ -6,6 +6,7 @@
#include "motorctl.hpp"
#include "auto.hpp"
#include "config.hpp"
#include "joystick.hpp"
@ -18,6 +19,7 @@ class buttonCommands {
//--- constructor ---
buttonCommands (
gpio_evaluatedSwitch * button_f,
evaluatedJoystick * joystick_f,
controlledArmchair * control_f,
buzzer_t * buzzer_f,
controlledMotor * motorLeft_f,
@ -35,6 +37,7 @@ class buttonCommands {
//--- objects ---
gpio_evaluatedSwitch* button;
evaluatedJoystick* joystick;
controlledArmchair * control;
buzzer_t* buzzer;
controlledMotor * motorLeft;

View File

@ -75,7 +75,7 @@ void task_control( void * pvParameters ){
void task_button( void * pvParameters ){
ESP_LOGI(TAG, "Initializing command-button and starting handle loop");
//create button instance
buttonCommands commandButton(&buttonJoystick, &control, &buzzer, &motorLeft, &motorRight);
buttonCommands commandButton(&buttonJoystick, &joystick, &control, &buzzer, &motorLeft, &motorRight);
//start handle loop
commandButton.startHandleLoop();
}