From 8057937239c1b6dc36433785bf4666670b9bb80b Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Tue, 11 Jun 2024 10:58:04 +0800 Subject: [PATCH] added display mode support --- common/params.cc | 3 +++ selfdrive/manager/manager.py | 3 +++ selfdrive/ui/ui.cc | 10 ++++++++++ selfdrive/ui/ui.h | 12 ++++++++++++ 4 files changed, 28 insertions(+) diff --git a/common/params.cc b/common/params.cc index 233016017..f337d721a 100644 --- a/common/params.cc +++ b/common/params.cc @@ -207,6 +207,9 @@ std::unordered_map keys = { {"UpdaterTargetBranch", CLEAR_ON_MANAGER_START}, {"UpdaterLastFetchTime", PERSISTENT}, {"Version", PERSISTENT}, + + // dp + {"dp_device_display_off_mode", PERSISTENT}, }; } // namespace diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index 512320a8d..af18867d6 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -40,6 +40,9 @@ def manager_init() -> None: ("LanguageSetting", "main_en"), ("OpenpilotEnabledToggle", "1"), ("LongitudinalPersonality", str(log.LongitudinalPersonality.standard)), + + # dp + ("dp_device_display_off_mode", "0"), ] if not PC: default_params.append(("LastUpdateTime", datetime.datetime.utcnow().isoformat().encode('utf8'))) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index e5309c969..33f66df6e 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -297,6 +297,12 @@ Device::Device(QObject *parent) : brightness_filter(BACKLIGHT_OFFROAD, BACKLIGHT resetInteractiveTimeout(); QObject::connect(uiState(), &UIState::uiUpdate, this, &Device::update); + #ifdef DP + display_mode_handler = new DisplayModeHandler; + QObject::connect(display_mode_handler, &DisplayModeHandler::reset_interactive_timeout, [=](bool timeout) { + resetInteractiveTimeout(timeout); + }); + #endif } void Device::update(const UIState &s) { @@ -359,7 +365,11 @@ void Device::updateWakefulness(const UIState &s) { emit interactiveTimeout(); } + #ifdef DP + setAwake(display_mode_handler->get_awake(s, interactive_timeout)); + #else setAwake(s.scene.ignition || interactive_timeout > 0); + #endif } UIState *uiState() { diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 7238159dd..512c09a1c 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -16,6 +16,11 @@ #include "common/timing.h" #include "system/hardware/hw.h" +#ifdef DP +#include "dp_priv/selfdrive/ui/ui.h" +class DisplayModeHandler; +#endif + const int UI_BORDER_SIZE = 30; const int UI_HEADER_HEIGHT = 420; @@ -128,6 +133,9 @@ public: QTransform car_space_transform; + // dp + QString gps_service = "gpsLocationExternal"; + signals: void uiUpdate(const UIState &s); void offroadTransition(bool offroad); @@ -170,6 +178,10 @@ private: void updateWakefulness(const UIState &s); void setAwake(bool on); + #ifdef DP + DisplayModeHandler *display_mode_handler; + #endif + signals: void displayPowerChanged(bool on); void interactiveTimeout();