mirror of
https://github.com/infiniteCable2/opendbc.git
synced 2026-06-08 10:54:51 +08:00
* fix * clearer * cleanup * more fix * hkg dbc * typo! * Add Custom MIT License (#26) * missed * better * more fixes * try this out * inherit in carcontroller properly * hyundai: main button handling * always disable * add main check for pcm cruise * revert * sunnyParams * Move car-specific changes to opendbc * no need * more fixes * more! * final? * static analysis * use new cereal * rename to lkas_button * rename * mads base for cars * add lkas for ford * enabled <-> active * MUST REMOVE test process replay * Revert "MUST REMOVE test process replay" This reverts commit 6dde2c8435b0e09158ab455aa215a573f5212c11. * subaru * ruff * more subaru * toyota * add them * mypy * fix * update name * FCA * assign directly * init directly * missing * not yet * missed * no longer needed * missed hd * fix * move to generator * more nissan * Apply suggestions from code review * no need * Revert "no need" This reverts commit 6156c62113d9abb626014947a9066b5580f6460a. * hyundai: move main logic out of main carstate * move around * move lkas and lfa icon logic to mads base * Parse more flags from alt exp, more tests, hyundai main cruise allowed * license * add code spell ignore * fix icon * remove toyota lta status for lkas, causes weird behaviors * parse signals inside mads methods * more codes in mads childs * Update opendbc/sunnypilot/car/hyundai/escc.py * revert * type hint * test type hint * more type hint * no * needs to be in carstate * in another PR --------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
75 lines
1.9 KiB
Python
75 lines
1.9 KiB
Python
from opendbc.car import structs
|
|
from opendbc.car.chrysler.values import RAM_CARS
|
|
|
|
GearShifter = structs.CarState.GearShifter
|
|
VisualAlert = structs.CarControl.HUDControl.VisualAlert
|
|
|
|
def create_lkas_hud(packer, CP, lkas_active, hud_alert, hud_count, car_model, auto_high_beam, mads):
|
|
# LKAS_HUD - Controls what lane-keeping icon is displayed
|
|
|
|
# == Color ==
|
|
# 0 hidden?
|
|
# 1 white
|
|
# 2 green
|
|
# 3 ldw
|
|
|
|
# == Lines ==
|
|
# 03 white Lines
|
|
# 04 grey lines
|
|
# 09 left lane close
|
|
# 0A right lane close
|
|
# 0B left Lane very close
|
|
# 0C right Lane very close
|
|
# 0D left cross cross
|
|
# 0E right lane cross
|
|
|
|
# == Alerts ==
|
|
# 7 Normal
|
|
# 6 lane departure place hands on wheel
|
|
|
|
if mads.enable_mads:
|
|
color = 2 if lkas_active else 1 if mads.paused else 0
|
|
else:
|
|
color = 2 if lkas_active else 1
|
|
lines = 3 if lkas_active else 0
|
|
alerts = 7 if lkas_active else 0
|
|
|
|
if hud_count < (1 * 4): # first 3 seconds, 4Hz
|
|
alerts = 1
|
|
|
|
if hud_alert in (VisualAlert.ldw, VisualAlert.steerRequired):
|
|
color = 4
|
|
lines = 0
|
|
alerts = 6
|
|
|
|
values = {
|
|
"LKAS_ICON_COLOR": color,
|
|
"CAR_MODEL": car_model,
|
|
"LKAS_LANE_LINES": lines,
|
|
"LKAS_ALERTS": alerts,
|
|
}
|
|
|
|
if CP.carFingerprint in RAM_CARS:
|
|
values['AUTO_HIGH_BEAM_ON'] = auto_high_beam
|
|
|
|
return packer.make_can_msg("DAS_6", 0, values)
|
|
|
|
|
|
def create_lkas_command(packer, CP, apply_steer, lkas_control_bit):
|
|
# LKAS_COMMAND Lane-keeping signal to turn the wheel
|
|
enabled_val = 2 if CP.carFingerprint in RAM_CARS else 1
|
|
values = {
|
|
"STEERING_TORQUE": apply_steer,
|
|
"LKAS_CONTROL_BIT": enabled_val if lkas_control_bit else 0,
|
|
}
|
|
return packer.make_can_msg("LKAS_COMMAND", 0, values)
|
|
|
|
|
|
def create_cruise_buttons(packer, frame, bus, cancel=False, resume=False):
|
|
values = {
|
|
"ACC_Cancel": cancel,
|
|
"ACC_Resume": resume,
|
|
"COUNTER": frame % 0x10,
|
|
}
|
|
return packer.make_can_msg("CRUISE_BUTTONS", bus, values)
|