Skip to content

Commit

Permalink
Merge pull request commaai#369 from arne182/priusblinker
Browse files Browse the repository at this point in the history
Priusblinker confrimed working by @pratik
  • Loading branch information
arne182 committed Jun 13, 2019
2 parents 500ca6f + 899b2aa commit 410c1a5
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def __init__(self, CP):
self.CP = CP
self.can_define = CANDefine(DBC[CP.carFingerprint]['pt'])
self.shifter_values = self.can_define.dv["GEAR_PACKET"]['GEAR']

self.left_blinker_on = 0
self.right_blinker_on = 0
self.lkas_barriers = 0
Expand All @@ -268,6 +269,9 @@ def __init__(self, CP):

#BB variable for custom buttons
self.cstm_btns = UIButtons(self,"Toyota","toyota")
if self.CP.carFingerprint == CAR.PRIUS:
self.alcaMode = 3
self.cstm_btns.set_button_status("alca", 0)

#BB pid holder for ALCA
self.pid = None
Expand All @@ -291,7 +295,7 @@ def __init__(self, CP):
def init_ui_buttons(self):
btns = []
btns.append(UIButton("sound", "SND", 0, "", 0))
btns.append(UIButton("alca", "ALC", 1, self.alcaLabels[self.alcaMode], 1))
btns.append(UIButton("alca", "ALC", 0, self.alcaLabels[self.alcaMode], 1))
btns.append(UIButton("slow", "SLO", self.sloMode, self.sloLabels[self.sloMode], 2))
btns.append(UIButton("lka", "LKA", 1, "", 3))
btns.append(UIButton("tr", "TR", 0, "", 4))
Expand All @@ -304,12 +308,20 @@ def update_ui_buttons(self,id,btn_status):
if (id == 1) and (btn_status == 0) and self.cstm_btns.btns[id].btn_name=="alca":
if self.cstm_btns.btns[id].btn_label2 == self.alcaLabels[self.alcaMode]:
self.alcaMode = (self.alcaMode + 1 ) % 4
if self.CP.carFingerprint == CAR.PRIUS:
self.alcaMode = 3
self.cstm_btns.set_button_status("alca", 0)
kegman.save({'lastALCAMode': int(self.alcaMode)}) # write last ALCAMode setting to file
else:
self.alcaMode = 0
if self.CP.carFingerprint == CAR.PRIUS:
self.alcaMode = 3
self.cstm_btns.set_button_status("alca", 0)
kegman.save({'lastALCAMode': int(self.alcaMode)}) # write last ALCAMode setting to file
self.cstm_btns.btns[id].btn_label2 = self.alcaLabels[self.alcaMode]
self.cstm_btns.hasChanges = True
if self.CP.carFingerprint == CAR.PRIUS:
self.alcaMode = 3
if self.alcaMode == 3:
self.cstm_btns.set_button_status("alca", 0)
elif (id == 2) and (btn_status == 0) and self.cstm_btns.btns[id].btn_name=="slow":
Expand Down Expand Up @@ -368,7 +380,9 @@ def update(self, cp, cp_cam):
self.lastspeedlimitvalid = True
else:
self.lastspeedlimitvalid = False


if self.CP.carFingerprint == CAR.PRIUS:
self.alcaMode = 3

if msg is not None:
gps_pkt = msg.gpsLocationExternal
Expand Down Expand Up @@ -434,12 +448,10 @@ def update(self, cp, cp_cam):
elif self.gasMode == 2:
self.econ_on = 1
self.gear_shifter = parse_gear_shifter(can_gear, self.shifter_values)
if self.CP.carFingerprint != CAR.PRIUS:
self.left_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1
self.right_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 2
else:
self.left_blinker_on = False
self.right_blinker_on = False

self.left_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 1
self.right_blinker_on = cp.vl["STEERING_LEVERS"]['TURN_SIGNALS'] == 2

#self.lkas_barriers = cp_cam.vl["LKAS_HUD"]['BARRIERS']
#self.left_line = cp_cam.vl["LKAS_HUD"]['LEFT_LINE']
#self.right_line = cp_cam.vl["LKAS_HUD"]['RIGHT_LINE']
Expand Down

0 comments on commit 410c1a5

Please sign in to comment.