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:
@@ -48,6 +48,7 @@ void cControlledRest::init()
|
||||
// both relays off initially
|
||||
gpio_set_level(gpio_down, 0);
|
||||
gpio_set_level(gpio_up, 0);
|
||||
state = REST_OFF;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +106,10 @@ void controlChairAdjustment(joystickData_t data, cControlledRest * legRest, cCon
|
||||
//leg rest (x-axis)
|
||||
if (data.x > stickThreshold) legRest->setState(REST_UP);
|
||||
else if (data.x < -stickThreshold) legRest->setState(REST_DOWN);
|
||||
else legRest->setState(REST_OFF);
|
||||
|
||||
//back rest (y-axis)
|
||||
if (data.y > stickThreshold) backRest->setState(REST_UP);
|
||||
else if (data.y < -stickThreshold) backRest->setState(REST_DOWN);
|
||||
else backRest->setState(REST_OFF);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ extern const char* restStateStr[];
|
||||
//class that controls 2 relays powering a motor that moves a rest of the armchair up or down
|
||||
//2 instances will be created one for back and one for leg rest
|
||||
class cControlledRest {
|
||||
public:
|
||||
cControlledRest(gpio_num_t gpio_up, gpio_num_t gpio_down, const char * name);
|
||||
public:
|
||||
cControlledRest(gpio_num_t gpio_up, gpio_num_t gpio_down, const char *name);
|
||||
void setState(restState_t targetState);
|
||||
void stop();
|
||||
|
||||
private:
|
||||
private:
|
||||
void init();
|
||||
|
||||
char name[32];
|
||||
|
||||
Reference in New Issue
Block a user