add slow acceleration in slower modes

This commit is contained in:
interfisch 2024-07-14 11:12:08 +02:00
parent 2e557af21f
commit a8d43211e9
2 changed files with 5 additions and 2 deletions

View File

@ -95,7 +95,7 @@ bool error_sdfile_unavailable=false;
#define NORMAL_MAX_ACCELERATION_RATE 10000 #define NORMAL_MAX_ACCELERATION_RATE 10000
#define SLOW_MAX_ACCELERATION_RATE 500 #define SLOW_MAX_ACCELERATION_RATE 250
int16_t max_acceleration_rate=NORMAL_MAX_ACCELERATION_RATE; //maximum cmd send increase per second int16_t max_acceleration_rate=NORMAL_MAX_ACCELERATION_RATE; //maximum cmd send increase per second

View File

@ -520,7 +520,7 @@ void calculateSetSpeed(unsigned long timediff){
} }
//acceleration //acceleration
cmd_send += constrain(adjusted_throttle_pos-cmd_send,0,(int16_t)(max_acceleration_rate*(timediff/1000.0)) ); //if throttle higher than last applied value, apply throttle directly cmd_send += constrain(adjusted_throttle_pos-cmd_send,0,(int16_t)(max_acceleration_rate*(timediff/1000.0)) ); //if throttle higher than last applied value, apply throttle directly with rate limit
cmd_send=constrain(cmd_send,0,throttle_max); cmd_send=constrain(cmd_send,0,throttle_max);
@ -603,12 +603,15 @@ void readButtons() {
if (control_buttonA) { //button A is held down during start button press if (control_buttonA) { //button A is held down during start button press
throttle_max=1000; throttle_max=1000;
reverse_speed=0.25; reverse_speed=0.25;
max_acceleration_rate=NORMAL_MAX_ACCELERATION_RATE;
}else if (control_buttonB) { //button B is held down during start button press }else if (control_buttonB) { //button B is held down during start button press
throttle_max=750; throttle_max=750;
reverse_speed=0.25; reverse_speed=0.25;
max_acceleration_rate=SLOW_MAX_ACCELERATION_RATE;
}else { //no control button pressed during start }else { //no control button pressed during start
throttle_max=250; throttle_max=250;
reverse_speed=0.15; reverse_speed=0.15;
max_acceleration_rate=SLOW_MAX_ACCELERATION_RATE;
} }
}else{ }else{