Skip to content

Commit

Permalink
GM: Ignore resume button until first engaged with set
Browse files Browse the repository at this point in the history
  • Loading branch information
vntarasov committed Sep 26, 2018
1 parent 3fd41ad commit a551df3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def __init__(self, CP, sendcan=None):
self.can_invalid_count = 0
self.acc_active_prev = 0

# First engagement must be done with "set/-",
# ignore "res/+" until then.
self.allow_resume = False

# *** init the major players ***
canbus = CanBus()
self.CS = CarState(CP, canbus)
Expand Down Expand Up @@ -197,6 +201,7 @@ def update(self, c):

# cruise state
ret.cruiseState.available = bool(self.CS.main_on)
self.allow_resume &= ret.cruiseState.available
cruiseEnabled = self.CS.pcm_acc_status in [AccState.ACTIVE, AccState.STANDSTILL]
ret.cruiseState.enabled = cruiseEnabled
ret.cruiseState.standstill = False
Expand Down Expand Up @@ -232,10 +237,12 @@ def update(self, c):
be.pressed = False
but = self.CS.prev_cruise_buttons
if but == CruiseButtons.RES_ACCEL:
if not (cruiseEnabled and self.CS.standstill):
be.type = 'accelCruise' # Suppress resume button if we're resuming from stop so we don't adjust speed.
# Suppress resume button if we're resuming from stop so we don't adjust speed.
if self.allow_resume and not (cruiseEnabled and self.CS.standstill):
be.type = 'accelCruise'
elif but == CruiseButtons.DECEL_SET:
be.type = 'decelCruise'
self.allow_resume = True
elif but == CruiseButtons.CANCEL:
be.type = 'cancel'
elif but == CruiseButtons.MAIN:
Expand Down

0 comments on commit a551df3

Please sign in to comment.