Visuals - Custom Onroad UI - Road Name

Display the current road's name at the bottom of the screen. Sourced from OpenStreetMap.

Credit goes to Pfeiferj!

https: //github.com/pfeiferj
Co-Authored-By: Jacob Pfeifer <jacob@pfeifer.dev>
This commit is contained in:
FrogAi
2024-06-08 07:00:57 -07:00
parent 19b62e3bdc
commit b7224bb2b0
6 changed files with 24 additions and 4 deletions
+2 -1
View File
@@ -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;
+1
View File
@@ -41,6 +41,7 @@ protected:
Alert alert = {};
// FrogPilot variables
bool roadNameUI;
bool showAOLStatusBar;
bool showCEMStatusBar;
};
+18 -3
View File
@@ -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();
}
@@ -111,6 +111,7 @@ private:
bool mapOpen;
bool onroadDistanceButton;
bool reverseCruise;
bool roadNameUI;
bool showAlwaysOnLateralStatusBar;
bool showConditionalExperimentalStatusBar;
bool showSLCOffset;
+1
View File
@@ -320,6 +320,7 @@ void ui_update_frogpilot_params(UIState *s, Params &params) {
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");
+1
View File
@@ -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;