added display mode support

This commit is contained in:
Rick Lan
2024-06-11 10:58:04 +08:00
parent 68e326b238
commit 8057937239
4 changed files with 28 additions and 0 deletions
+3
View File
@@ -207,6 +207,9 @@ std::unordered_map<std::string, uint32_t> keys = {
{"UpdaterTargetBranch", CLEAR_ON_MANAGER_START},
{"UpdaterLastFetchTime", PERSISTENT},
{"Version", PERSISTENT},
// dp
{"dp_device_display_off_mode", PERSISTENT},
};
} // namespace
+3
View File
@@ -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')))
+10
View File
@@ -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() {
+12
View File
@@ -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();