From b6f046f1fdcb867511493c3366afd5aa2b473fda Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Mon, 17 Mar 2025 10:08:19 +0800 Subject: [PATCH 1/2] display mode --- common/params.cc | 1 + selfdrive/manager/manager.py | 1 + selfdrive/ui/qt/offroad/settings_dp.cc | 8 ++++++ selfdrive/ui/ui.cc | 38 +++++++++++++++++++++++++- selfdrive/ui/ui.h | 1 + 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/common/params.cc b/common/params.cc index e15c8c598..ba71d6afa 100644 --- a/common/params.cc +++ b/common/params.cc @@ -228,6 +228,7 @@ std::unordered_map keys = { {"dp_toyota_enhanced_bsm", PERSISTENT}, {"dp_toyota_auto_lock", PERSISTENT}, {"dp_toyota_auto_unlock", PERSISTENT}, + {"dp_device_display_off_mode", PERSISTENT}, {"dp_device_audible_alert_mode", PERSISTENT}, {"dp_device_disable_temp_check", PERSISTENT}, {"dp_car_dashcam_mode_removal", PERSISTENT}, diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index 4b7605bd2..06923a9ec 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -64,6 +64,7 @@ def manager_init() -> None: ("dp_toyota_enhanced_bsm", "0"), ("dp_toyota_auto_lock", "0"), ("dp_toyota_auto_unlock", "0"), + ("dp_device_display_off_mode", "0"), ("dp_device_audible_alert_mode", "0"), ("dp_device_disable_temp_check", "0"), ("dp_car_dashcam_mode_removal", "0"), diff --git a/selfdrive/ui/qt/offroad/settings_dp.cc b/selfdrive/ui/qt/offroad/settings_dp.cc index f2cba618d..ebce7923e 100644 --- a/selfdrive/ui/qt/offroad/settings_dp.cc +++ b/selfdrive/ui/qt/offroad/settings_dp.cc @@ -202,6 +202,12 @@ void DPCtrlPanel::add_device_toggles() { }, }; + std::vector display_off_mode_texts{tr("Standard"), tr("On-Road"), tr("MAIN"), tr("OP"), tr("Off")}; + ButtonParamControl* display_off_mode_setting = new ButtonParamControl("dp_device_display_off_mode", tr("Display Mode"), + tr("Standard - Standard behaviour.\nOn-Road - When driving, the display will be off (excl. warning).\nMAIN - When ACC MAIN is on, the display will be off (excl. warning).\nOP - When OP is enabled, the display will be off (excl. warning).\nOff - the display will be off completely (incl. warning).\nReboot required."), + "", + display_off_mode_texts); + std::vector audible_alert_mode_texts{tr("Standard"), tr("Warning"), tr("Off")}; ButtonParamControl* audible_alert_mode_setting = new ButtonParamControl("dp_device_audible_alert_mode", tr("Audible Alert Mode"), tr("Standard - Standard behaviour.\nWarning - Only emits sound when there is a warning.\nOff - Does not emit any sound at all."), @@ -230,6 +236,8 @@ void DPCtrlPanel::add_device_toggles() { }); auto_shutdown_timer_toggle->setVisible(false); addItem(auto_shutdown_timer_toggle); + // display off mode + addItem(display_off_mode_setting); // audible alert mode addItem(audible_alert_mode_setting); } diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 50fd5e981..fb121f284 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -311,6 +311,8 @@ UIState::UIState(QObject *parent) : QObject(parent) { prime_type = std::atoi(params.get("PrimeType").c_str()); language = QString::fromStdString(params.get("LanguageSetting")); + dp_device_display_off_mode = std::atoi(params.get("dp_device_display_off_mode").c_str()); + // update timer timer = new QTimer(this); QObject::connect(timer, &QTimer::timeout, this, &UIState::update); @@ -421,7 +423,41 @@ void Device::updateWakefulness(const UIState &s) { emit interactiveTimeout(); } - setAwake(s.scene.ignition || interactive_timeout > 0); + // rick - display mode + // tr("Disabled"), tr("On-Road") tr("MAIN"), tr("OP"), tr("Off")} + if (s.scene.ignition && s.dp_device_display_off_mode > 0) { + // Off - the display will be off completely (incl. warning). + if (s.dp_device_display_off_mode == 4) { + interactive_timeout = 0; + } else { + const SubMaster &sm = *(s.sm); + auto cs = sm["carState"].getCarState().getCruiseState(); + Alert alert = Alert::get(*(s.sm), s.scene.started_frame); + // if there is a warning, always show screen + if (alert.status == cereal::ControlsState::AlertStatus::USER_PROMPT || alert.status == cereal::ControlsState::AlertStatus::CRITICAL) { + resetInteractiveTimeout(); + // op - When OP is enabled, the display will be off + } else if (s.dp_device_display_off_mode == 3) { + if (!cs.getEnabled()) { + resetInteractiveTimeout(); + } + // main - When ACC MAIN is on, the display will be off + } else if (s.dp_device_display_off_mode == 2) { + if (!cs.getAvailable()) { + resetInteractiveTimeout(); + } + // on-road - When driving, the display will be off + } else if (s.dp_device_display_off_mode == 1) { + if (!s.scene.ignition) { + resetInteractiveTimeout(); + } + } + } + setAwake(interactive_timeout > 0); + } else { + setAwake(s.scene.ignition || interactive_timeout > 0); + } +// setAwake(s.scene.ignition || interactive_timeout > 0); } UIState *uiState() { diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 9d7429a33..7b8141eb0 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -195,6 +195,7 @@ class UIState : public QObject { UIScene scene = {}; QString language; + int dp_device_display_off_mode = 0; QTransform car_space_transform; From 7b5fe113e857283f4aefaa5a67b3f143eb3a96ab Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Mon, 17 Mar 2025 17:23:29 +0800 Subject: [PATCH 2/2] remove off --- selfdrive/ui/qt/offroad/settings_dp.cc | 4 +-- selfdrive/ui/ui.cc | 43 ++++++++++++-------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/selfdrive/ui/qt/offroad/settings_dp.cc b/selfdrive/ui/qt/offroad/settings_dp.cc index ebce7923e..e0b84333d 100644 --- a/selfdrive/ui/qt/offroad/settings_dp.cc +++ b/selfdrive/ui/qt/offroad/settings_dp.cc @@ -202,9 +202,9 @@ void DPCtrlPanel::add_device_toggles() { }, }; - std::vector display_off_mode_texts{tr("Standard"), tr("On-Road"), tr("MAIN"), tr("OP"), tr("Off")}; + std::vector display_off_mode_texts{tr("Standard"), tr("On-Road"), tr("MAIN"), tr("OP")}; ButtonParamControl* display_off_mode_setting = new ButtonParamControl("dp_device_display_off_mode", tr("Display Mode"), - tr("Standard - Standard behaviour.\nOn-Road - When driving, the display will be off (excl. warning).\nMAIN - When ACC MAIN is on, the display will be off (excl. warning).\nOP - When OP is enabled, the display will be off (excl. warning).\nOff - the display will be off completely (incl. warning).\nReboot required."), + tr("Standard - Standard behaviour.\nOn-Road - When driving, the display will be off (excl. warning).\nMAIN - When ACC MAIN is on, the display will be off (excl. warning).\nOP - When OP is enabled, the display will be off (excl. warning).\nReboot required."), "", display_off_mode_texts); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index fb121f284..ddee89d3b 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -427,30 +427,27 @@ void Device::updateWakefulness(const UIState &s) { // tr("Disabled"), tr("On-Road") tr("MAIN"), tr("OP"), tr("Off")} if (s.scene.ignition && s.dp_device_display_off_mode > 0) { // Off - the display will be off completely (incl. warning). - if (s.dp_device_display_off_mode == 4) { - interactive_timeout = 0; - } else { - const SubMaster &sm = *(s.sm); - auto cs = sm["carState"].getCarState().getCruiseState(); - Alert alert = Alert::get(*(s.sm), s.scene.started_frame); - // if there is a warning, always show screen - if (alert.status == cereal::ControlsState::AlertStatus::USER_PROMPT || alert.status == cereal::ControlsState::AlertStatus::CRITICAL) { + + const SubMaster &sm = *(s.sm); + auto cs = sm["carState"].getCarState().getCruiseState(); + Alert alert = Alert::get(*(s.sm), s.scene.started_frame); + // if there is a warning, always show screen + if (alert.status == cereal::ControlsState::AlertStatus::USER_PROMPT || alert.status == cereal::ControlsState::AlertStatus::CRITICAL) { + resetInteractiveTimeout(); + // op - When OP is enabled, the display will be off + } else if (s.dp_device_display_off_mode == 3) { + if (!cs.getEnabled()) { + resetInteractiveTimeout(); + } + // main - When ACC MAIN is on, the display will be off + } else if (s.dp_device_display_off_mode == 2) { + if (!cs.getAvailable()) { + resetInteractiveTimeout(); + } + // on-road - When driving, the display will be off + } else if (s.dp_device_display_off_mode == 1) { + if (!s.scene.ignition) { resetInteractiveTimeout(); - // op - When OP is enabled, the display will be off - } else if (s.dp_device_display_off_mode == 3) { - if (!cs.getEnabled()) { - resetInteractiveTimeout(); - } - // main - When ACC MAIN is on, the display will be off - } else if (s.dp_device_display_off_mode == 2) { - if (!cs.getAvailable()) { - resetInteractiveTimeout(); - } - // on-road - When driving, the display will be off - } else if (s.dp_device_display_off_mode == 1) { - if (!s.scene.ignition) { - resetInteractiveTimeout(); - } } } setAwake(interactive_timeout > 0);