Fix crash in ADJUST_CHAIR mode, Fix Rest not stopping

While testing the ADJUST_CHAIR mode on actual hardware fixed the
following issues:

- main.cpp: Uninitialized pointer for leg/back-rest were passed to
  control task thus as when a method was called the controller crashed

- chairAdjust.cpp: the state was never reset to REST_OFF when below
  stick threshold
This commit is contained in:
jonny_l480
2024-02-20 09:34:33 +01:00
parent 26761f4a80
commit 8de4dbbe27
3 changed files with 15 additions and 10 deletions

View File

@@ -134,12 +134,12 @@ void createObjects()
//sabertoothDriver = new sabertooth2x60a(sabertoothConfig);
// create controlled motor instances (motorctl.hpp)
// with configurations above
// with configurations from config.cpp
motorLeft = new controlledMotor(setLeftFunc, configMotorControlLeft);
motorRight = new controlledMotor(setRightFunc, configMotorControlRight);
// create speedsensor instances
// with configurations above
// with configurations from config.cpp
speedLeft = new speedSensor(speedLeft_config);
speedRight = new speedSensor(speedRight_config);
@@ -153,17 +153,18 @@ void createObjects()
// create buzzer object on pin 12 with gap between queued events of 100ms
buzzer = new buzzer_t(GPIO_NUM_12, 100);
// create objects for controlling the chair position
// gpio_up, gpio_down, name
legRest = new cControlledRest(GPIO_NUM_4, GPIO_NUM_16, "legRest");
backRest = new cControlledRest(GPIO_NUM_2, GPIO_NUM_15, "backRest");
// create control object (control.hpp)
// with configuration above
// with configuration from config.cpp
control = new controlledArmchair(configControl, buzzer, motorLeft, motorRight, joystick, httpJoystickMain, automatedArmchair, legRest, backRest);
// create automatedArmchair_c object (for auto-mode) (auto.hpp)
automatedArmchair = new automatedArmchair_c(motorLeft, motorRight);
// create objects for controlling the chair position
// gpio_up, gpio_down, name
legRest = new cControlledRest(GPIO_NUM_4, GPIO_NUM_16, "legRest");
backRest = new cControlledRest(GPIO_NUM_2, GPIO_NUM_15, "backRest");
}