diff --git a/selfdrive/ui/qt/onroad/alerts.cc b/selfdrive/ui/qt/onroad/alerts.cc index e68d86e48..1c3447d3b 100644 --- a/selfdrive/ui/qt/onroad/alerts.cc +++ b/selfdrive/ui/qt/onroad/alerts.cc @@ -15,6 +15,7 @@ void OnroadAlerts::updateState(const UIState &s) { // FrogPilot variables const UIScene &scene = s.scene; + roadNameUI = scene.road_name_ui; showAOLStatusBar = scene.show_aol_status_bar; showCEMStatusBar = scene.show_cem_status_bar; } @@ -73,7 +74,7 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) { int margin = 40; int radius = 30; - int offset = showAOLStatusBar || showCEMStatusBar ? 25 : 0; + int offset = roadNameUI || showAOLStatusBar || showCEMStatusBar ? 25 : 0; if (alert.size == cereal::ControlsState::AlertSize::FULL) { margin = 0; radius = 0; diff --git a/selfdrive/ui/qt/onroad/alerts.h b/selfdrive/ui/qt/onroad/alerts.h index a518b9782..8efac918d 100644 --- a/selfdrive/ui/qt/onroad/alerts.h +++ b/selfdrive/ui/qt/onroad/alerts.h @@ -41,6 +41,7 @@ protected: Alert alert = {}; // FrogPilot variables + bool roadNameUI; bool showAOLStatusBar; bool showCEMStatusBar; }; diff --git a/selfdrive/ui/qt/onroad/annotated_camera.cc b/selfdrive/ui/qt/onroad/annotated_camera.cc index 32f44b86e..06fef937d 100644 --- a/selfdrive/ui/qt/onroad/annotated_camera.cc +++ b/selfdrive/ui/qt/onroad/annotated_camera.cc @@ -394,7 +394,7 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s) } else if (onroadDistanceButton) { x += 250; } - offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar ? 25 : 0; + offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar || roadNameUI ? 25 : 0; int y = height() - offset; float opacity = dmActive ? 0.65 : 0.2; drawIcon(painter, QPoint(x, y), dm_img, blackColor(70), opacity); @@ -610,7 +610,7 @@ void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &painter, const UISce alwaysOnLateralActive = scene.always_on_lateral_active; showAlwaysOnLateralStatusBar = scene.show_aol_status_bar; - if (showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar) { + if (showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar || roadNameUI) { drawStatusBar(painter); } @@ -663,6 +663,8 @@ void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &painter, const UISce reverseCruise = scene.reverse_cruise; + roadNameUI = scene.road_name_ui; + speedLimitController = scene.speed_limit_controller; showSLCOffset = speedLimitController && scene.show_slc_offset; slcOverridden = speedLimitController && scene.speed_limit_overridden; @@ -865,6 +867,7 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) { constexpr qreal fadeDuration = 1500.0; constexpr qreal textDuration = 5000.0; + static qreal roadNameOpacity = 0.0; static qreal statusTextOpacity = 0.0; QString newStatus; @@ -916,7 +919,10 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) { } } - if (newStatus != lastShownStatus) { + QString roadName = QString::fromStdString(paramsMemory.get("RoadName")); + roadName = (!roadNameUI || roadName.isEmpty() || roadName == "null") ? "" : roadName; + + if (newStatus != lastShownStatus || roadName.isEmpty()) { lastShownStatus = newStatus; displayStatusText = true; timer.restart(); @@ -926,7 +932,9 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) { if (displayStatusText) { statusTextOpacity = qBound(0.0, 1.0 - (timer.elapsed() - textDuration) / fadeDuration, 1.0); + roadNameOpacity = 1.0 - statusTextOpacity; } else { + roadNameOpacity = qBound(0.0, timer.elapsed() / fadeDuration, 1.0); statusTextOpacity = 0.0; } @@ -939,5 +947,12 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) { textRect.moveBottom(statusBarRect.bottom() - 50); p.drawText(textRect, Qt::AlignCenter | Qt::TextWordWrap, newStatus); + if (!roadName.isEmpty()) { + p.setOpacity(roadNameOpacity); + textRect = p.fontMetrics().boundingRect(statusBarRect, Qt::AlignCenter | Qt::TextWordWrap, roadName); + textRect.moveBottom(statusBarRect.bottom() - 50); + p.drawText(textRect, Qt::AlignCenter | Qt::TextWordWrap, roadName); + } + p.restore(); } diff --git a/selfdrive/ui/qt/onroad/annotated_camera.h b/selfdrive/ui/qt/onroad/annotated_camera.h index d36789a61..685e5b4cf 100644 --- a/selfdrive/ui/qt/onroad/annotated_camera.h +++ b/selfdrive/ui/qt/onroad/annotated_camera.h @@ -111,6 +111,7 @@ private: bool mapOpen; bool onroadDistanceButton; bool reverseCruise; + bool roadNameUI; bool showAlwaysOnLateralStatusBar; bool showConditionalExperimentalStatusBar; bool showSLCOffset; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index d9e9a11c5..1590b3a0a 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -320,6 +320,7 @@ void ui_update_frogpilot_params(UIState *s, Params ¶ms) { scene.pedals_on_ui = custom_onroad_ui && params.getBool("PedalsOnUI"); scene.dynamic_pedals_on_ui = scene.pedals_on_ui && params.getBool("DynamicPedalsOnUI"); scene.static_pedals_on_ui = scene.pedals_on_ui && params.getBool("StaticPedalsOnUI"); + scene.road_name_ui = custom_onroad_ui && params.getBool("RoadNameUI"); scene.disable_smoothing_mtsc = params.getBool("MTSCEnabled") && params.getBool("DisableMTSCSmoothing"); scene.disable_smoothing_vtsc = params.getBool("VisionTurnControl") && params.getBool("DisableVTSCSmoothing"); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 778f49305..9c40991c4 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -149,6 +149,7 @@ typedef struct UIScene { bool reverse_cruise; bool reverse_cruise_ui; bool right_hand_drive; + bool road_name_ui; bool show_aol_status_bar; bool show_cem_status_bar; bool show_slc_offset;