From b74144ece3767cdcef0fcb24bf71f13c86b19cb4 Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Fri, 14 Jun 2024 16:46:23 +0800 Subject: [PATCH] map panel for free --- common/params.cc | 1 + dp_ext | 2 +- dp_priv | 2 +- selfdrive/ui/SConscript | 3 ++- selfdrive/ui/qt/maps/map.cc | 7 +++++++ selfdrive/ui/qt/onroad/onroad_home.cc | 12 +++++++++--- selfdrive/ui/qt/onroad/onroad_home.h | 1 + selfdrive/ui/ui.cc | 3 +++ selfdrive/ui/ui.h | 3 +++ system/manager/manager.py | 1 + 10 files changed, 29 insertions(+), 6 deletions(-) diff --git a/common/params.cc b/common/params.cc index 56d97e038..71b237371 100644 --- a/common/params.cc +++ b/common/params.cc @@ -221,6 +221,7 @@ std::unordered_map keys = { {"dp_vag_sng", PERSISTENT}, {"dp_vehicle_list", PERSISTENT}, {"dp_vehicle_assigned", PERSISTENT}, + {"dp_ui_map_panel", PERSISTENT}, }; } // namespace diff --git a/dp_ext b/dp_ext index 22edb00ad..33c4c75b3 160000 --- a/dp_ext +++ b/dp_ext @@ -1 +1 @@ -Subproject commit 22edb00adc9231241c575b0fd1ba0ee479a2fd52 +Subproject commit 33c4c75b326b121e9bb786b92e29fa2129b65057 diff --git a/dp_priv b/dp_priv index ef6eac980..586b0725b 160000 --- a/dp_priv +++ b/dp_priv @@ -1 +1 @@ -Subproject commit ef6eac98056b8a7861b336db2c2328bd1d41b6d1 +Subproject commit 586b0725b1978570a82efa039b4860d01040dccf diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index 7e1bb72f9..30fce52c5 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -37,7 +37,8 @@ if maps: base_libs += ['QMapLibre'] widgets_src += ["qt/maps/map_helpers.cc", "qt/maps/map_settings.cc", "qt/maps/map.cc", "qt/maps/map_panel.cc", "qt/maps/map_eta.cc", "qt/maps/map_instructions.cc"] -# if dp_priv: + if dp_priv: + widgets_src = insert_src(widgets_src, "qt/maps/map_helpers.cc", ["#dp_priv/selfdrive/ui/qt/maps/map_helpers.cc"]) # widgets_src = insert_src(widgets_src, "qt/maps/map_settings.cc", ["#dp_priv/selfdrive/ui/qt/maps/map_settings.cc"]) qt_env['CPPDEFINES'] += ["ENABLE_MAPS"] diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 298454927..82d78a7e5 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -10,6 +10,7 @@ #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/ui.h" +#include "dp_priv/selfdrive/ui/qt/maps/map_helpers.h" const int INTERACTION_TIMEOUT = 100; @@ -262,6 +263,12 @@ void MapWindow::initializeGL() { m_map->setPitch(MIN_PITCH); m_map->setStyleUrl("mapbox://styles/commaai/clkqztk0f00ou01qyhsa5bzpj"); + #ifdef DP + if (uiState()->scene.dp_ui_map_panel) { + ReconfigureMapPanel(m_map); + } + #endif + QObject::connect(m_map.data(), &QMapLibre::Map::mapChanged, [=](QMapLibre::Map::MapChange change) { // set global animation duration to 0 ms so visibility changes are instant if (change == QMapLibre::Map::MapChange::MapChangeDidFinishLoadingStyle) { diff --git a/selfdrive/ui/qt/onroad/onroad_home.cc b/selfdrive/ui/qt/onroad/onroad_home.cc index defa02190..dbdd42ff4 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.cc +++ b/selfdrive/ui/qt/onroad/onroad_home.cc @@ -54,6 +54,7 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { #endif // rick - read full screen param dp_nav_full_screen = Params().getBool("dp_nav_full_screen"); + dp_ui_map_panel = Params().getBool("dp_ui_map_panel"); } void OnroadWindow::updateState(const UIState &s) { @@ -114,13 +115,18 @@ void OnroadWindow::createMapWidget() { split->insertWidget(0, m); // hidden by default, made visible when navRoute is published m->setVisible(false); + + if (dp_ui_map_panel) { + nvg->map_settings_btn->setEnabled(false); + nvg->map_settings_btn->setVisible(false); + } #endif } void OnroadWindow::offroadTransition(bool offroad) { #ifdef ENABLE_MAPS if (!offroad) { - if (map == nullptr && (uiState()->hasPrime() || !MAPBOX_TOKEN.isEmpty())) { + if (map == nullptr && (dp_ui_map_panel || uiState()->hasPrime() || !MAPBOX_TOKEN.isEmpty())) { createMapWidget(); } } @@ -130,12 +136,12 @@ void OnroadWindow::offroadTransition(bool offroad) { void OnroadWindow::primeChanged(bool prime) { #ifdef ENABLE_MAPS - if (map && (!prime && MAPBOX_TOKEN.isEmpty())) { + if (map && (!dp_ui_map_panel && !prime && MAPBOX_TOKEN.isEmpty())) { nvg->map_settings_btn->setEnabled(false); nvg->map_settings_btn->setVisible(false); map->deleteLater(); map = nullptr; - } else if (!map && (prime || !MAPBOX_TOKEN.isEmpty())) { + } else if (!map && (dp_ui_map_panel || prime || !MAPBOX_TOKEN.isEmpty())) { createMapWidget(); } #endif diff --git a/selfdrive/ui/qt/onroad/onroad_home.h b/selfdrive/ui/qt/onroad/onroad_home.h index 5bdd348ae..2b295ca49 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.h +++ b/selfdrive/ui/qt/onroad/onroad_home.h @@ -30,6 +30,7 @@ private: // dp bool dp_nav_full_screen = false; + bool dp_ui_map_panel = false; #ifdef DP BorderIndicator *border_indicator; #endif diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index cb9eaa723..82becc607 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -215,6 +215,9 @@ void ui_update_params(UIState *s) { auto params = Params(); s->scene.is_metric = params.getBool("IsMetric"); s->scene.map_on_left = params.getBool("NavSettingLeftSide"); + + // dp + s->scene.dp_ui_map_panel = params.getBool("dp_ui_map_panel"); } void UIState::updateStatus() { diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 2ccb70edb..d2c704e3c 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -108,6 +108,9 @@ typedef struct UIScene { bool started, ignition, is_metric, map_on_left, longitudinal_control; bool world_objects_visible = false; uint64_t started_frame; + + // dp + bool dp_ui_map_panel; } UIScene; class UIState : public QObject { diff --git a/system/manager/manager.py b/system/manager/manager.py index 0f3b3937d..36fd177cd 100755 --- a/system/manager/manager.py +++ b/system/manager/manager.py @@ -53,6 +53,7 @@ def manager_init() -> None: ("dp_vag_sng", "0"), ("dp_vehicle_list", ""), ("dp_vehicle_assigned", ""), + ("dp_ui_map_panel", "0"), ] if not PC: default_params.append(("LastUpdateTime", datetime.datetime.now(datetime.UTC).replace(tzinfo=None).isoformat().encode('utf8')))