@@ -1678,7 +1678,9 @@ static void cmd_tune_defaults(Data *d) {
16781678 * cmd_runtime_tune_tilt: Extract settings from 20byte message but don't write to EEPROM!
16791679 */
16801680static void cmd_runtime_tune_tilt (Data * d , unsigned char * cfg , int len ) {
1681- unused (len );
1681+ if (len < 5 ) {
1682+ return ;
1683+ }
16821684 unsigned int flags = cfg [0 ];
16831685 bool duty_beep = flags & 0x1 ;
16841686 d -> float_conf .is_dutybeep_enabled = duty_beep ;
@@ -1689,16 +1691,23 @@ static void cmd_runtime_tune_tilt(Data *d, unsigned char *cfg, int len) {
16891691 d -> float_conf .tiltback_return_speed = retspeed / 10 ;
16901692 d -> tiltback_return_step_size = d -> float_conf .tiltback_return_speed / d -> float_conf .hertz ;
16911693 }
1692- d -> float_conf .tiltback_duty = (float ) cfg [2 ] / 100.0 ;
1693- d -> float_conf .tiltback_duty_angle = (float ) cfg [3 ] / 10.0 ;
1694- d -> float_conf .tiltback_duty_speed = (float ) cfg [4 ] / 10.0 ;
1694+ d -> float_conf .tiltback_duty = fmaxf (0.3 , (float ) cfg [2 ] / 100.0 );
1695+ d -> float_conf .tiltback_duty_angle = fminf (10 , (float ) cfg [3 ] / 10.0 );
1696+ d -> float_conf .tiltback_duty_speed = fminf (10 , (float ) cfg [4 ] / 10.0 );
1697+ d -> tiltback_duty_step_size = d -> float_conf .tiltback_duty_speed / d -> float_conf .hertz ;
1698+
1699+ if (len >= 6 ) {
1700+ d -> float_conf .tiltback_speed = cfg [5 ];
1701+ }
16951702}
16961703
16971704/**
16981705 * cmd_runtime_tune_haptic: Extract settings from 20byte message but don't write to EEPROM!
16991706 */
17001707static void cmd_runtime_tune_haptic (Data * d , unsigned char * cfg , int len ) {
1701- unused (len );
1708+ if (len < 11 ) {
1709+ return ;
1710+ }
17021711 // using one byte, frequencies can be 350..605Hz
17031712 d -> float_conf .haptic .duty .frequency = cfg [0 ] + 350 ;
17041713 d -> float_conf .haptic .duty .strength = ((float ) cfg [1 ]) / 10 ;
@@ -1712,13 +1721,18 @@ static void cmd_runtime_tune_haptic(Data *d, unsigned char *cfg, int len) {
17121721 d -> float_conf .haptic .min_strength = ((float ) cfg [8 ]) / 100 ;
17131722 d -> float_conf .haptic .strength_curvature = ((float ) cfg [9 ]) / 100 ;
17141723 d -> float_conf .haptic .max_strength_speed = ((float ) cfg [10 ]);
1724+
1725+ haptic_feedback_configure (& d -> haptic_feedback , & d -> float_conf );
17151726}
17161727
17171728/**
17181729 * cmd_runtime_tune_other Extract settings from 20byte message but don't write to
17191730 * EEPROM!
17201731 */
17211732static void cmd_runtime_tune_other (Data * d , unsigned char * cfg , int len ) {
1733+ if (len < 12 ) {
1734+ return ;
1735+ }
17221736 unsigned int flags = cfg [0 ];
17231737 d -> beeper_enabled = ((flags & 0x2 ) == 2 );
17241738 d -> float_conf .fault_reversestop_enabled = ((flags & 0x4 ) == 4 );
0 commit comments