Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,8 +1538,12 @@ static void cmd_runtime_tune(Data *d, unsigned char *cfg, int len) {

split(cfg[7], &h1, &h2);
d->float_conf.atr_angle_limit = h1 + 5;
d->float_conf.atr_on_speed = (h2 & 0x3) + 3;
d->float_conf.atr_off_speed = (h2 >> 2) + 2;
if (h2 > 0) {
// kept for compatibility reasons
// wider ranges can be set with byte[18]
d->float_conf.atr_on_speed = (h2 & 0x3) + 3;
d->float_conf.atr_off_speed = (h2 >> 2) + 2;
}

split(cfg[8], &h1, &h2);
d->float_conf.atr_response_boost = ((float) h1) / 10 + 1;
Expand Down Expand Up @@ -1576,7 +1580,7 @@ static void cmd_runtime_tune(Data *d, unsigned char *cfg, int len) {
split(cfg[15], &h1, &h2);
float onspd = h1;
float offspd = h2;
d->float_conf.torquetilt_on_speed = onspd / 2;
d->float_conf.torquetilt_on_speed = onspd + 3;
d->float_conf.torquetilt_off_speed = offspd + 3;
}
if (len >= 17) {
Expand All @@ -1585,6 +1589,20 @@ static void cmd_runtime_tune(Data *d, unsigned char *cfg, int len) {
d->float_conf.kp2_brake = ((float) h2) / 10;
beep_alert(d, 1, 1);
}
if (len >= 18) {
split(cfg[17], &h1, &h2);
if (h1 > 0) {
d->float_conf.mahony_kp_roll = ((float) h1) / 10 + 1.0;
}
if (h2 > 0) {
d->float_conf.turntilt_start_angle = h2;
}
split(cfg[18], &h1, &h2);
if ((h1 > 0) && (h2 > 0)) {
d->float_conf.atr_on_speed = h1 * 2;
d->float_conf.atr_off_speed = h2 * 2;
}
}

reconfigure(d);
}
Expand Down Expand Up @@ -1662,6 +1680,9 @@ static void cmd_runtime_tune_tilt(Data *d, unsigned char *cfg, int len) {
d->float_conf.tiltback_duty = (float) cfg[2] / 100.0;
d->float_conf.tiltback_duty_angle = (float) cfg[3] / 10.0;
d->float_conf.tiltback_duty_speed = (float) cfg[4] / 10.0;
if (len >= 6) {
d->float_conf.tiltback_speed = (float) cfg[5];
}

beep_alert(d, 3, 0);
}
Expand Down Expand Up @@ -1709,7 +1730,12 @@ static void cmd_runtime_tune_other(Data *d, unsigned char *cfg, int len) {
if (tiltspeed > 0) {
d->float_conf.noseangling_speed = tiltspeed / 10;
}
d->float_conf.tiltback_variable = tiltvarrate / 100;
if (tiltvarrate > 100) {
// numbers above 100 are negative
d->float_conf.tiltback_variable = (tiltvarrate - 100) / (-100);
} else {
d->float_conf.tiltback_variable = tiltvarrate / 100;
}
d->float_conf.tiltback_variable_max = tiltvarmax / 10;
d->float_conf.tiltback_variable_erpm = cfg[11] * 100;
}
Expand All @@ -1725,6 +1751,18 @@ static void cmd_runtime_tune_other(Data *d, unsigned char *cfg, int len) {
}
}

if (len >= 15) {
int flags2 = cfg[14];
// bits 0 & 1:
d->float_conf.fault_moving_fault_disabled = ((flags2 & 0x1) == 0x1);
d->float_conf.is_footbeep_enabled = ((flags2 & 0x2) == 0x2);
d->switch_warn_beep_erpm = d->float_conf.is_footbeep_enabled ? 2000 : 100000;
// bits 2 & 3:
int pbmode = (flags2 >> 2) & 0x3;
d->motor_control.parking_brake_mode = pbmode;
d->float_conf.parking_brake_mode = pbmode;
}

reconfigure(d);
}

Expand Down