mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-09-30 19:33:42 +08:00
fix v long_press + // - == 5 kph
This commit is contained in:
@@ -69,7 +69,7 @@ def update_v_cruise(v_cruise_kph, buttonEvents, button_timers, enabled, metric):
|
||||
long_press = False
|
||||
button_type = None
|
||||
|
||||
v_cruise_delta = 1 if metric else 1.6
|
||||
v_cruise_delta = 1 if metric else 1.609344
|
||||
|
||||
for b in buttonEvents:
|
||||
if b.type.raw in button_timers and not b.pressed:
|
||||
@@ -85,9 +85,14 @@ def update_v_cruise(v_cruise_kph, buttonEvents, button_timers, enabled, metric):
|
||||
break
|
||||
|
||||
if button_type:
|
||||
v_cruise_kph = math.floor(v_cruise_kph)
|
||||
v_cruise_delta = v_cruise_delta * (5 if long_press else 1)
|
||||
if long_press and v_cruise_kph % v_cruise_delta != 0: # partial interval
|
||||
v_cruise_kph = CRUISE_NEAREST_FUNC[button_type](v_cruise_kph / v_cruise_delta) * v_cruise_delta
|
||||
if long_press:
|
||||
remainder = v_cruise_kph % v_cruise_delta
|
||||
if remainder > 0:
|
||||
v_cruise_kph += (v_cruise_delta - remainder) * CRUISE_INTERVAL_SIGN[button_type]
|
||||
else:
|
||||
v_cruise_kph += v_cruise_delta * CRUISE_INTERVAL_SIGN[button_type]
|
||||
else:
|
||||
v_cruise_kph += v_cruise_delta * CRUISE_INTERVAL_SIGN[button_type]
|
||||
v_cruise_kph = clip(round(v_cruise_kph, 1), V_CRUISE_MIN, V_CRUISE_MAX)
|
||||
|
||||
Reference in New Issue
Block a user