From 20bc0dfe7d19d2554f53b457f2e931668a37b826 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Wed, 15 May 2024 20:37:18 -0700 Subject: [PATCH] Visuals - Developer UI - Border Metrics - Blind Spot Display blind spot metrics in onroad UI border. --- selfdrive/ui/qt/onroad.cc | 33 ++++++++++++++++++++++++++++++++- selfdrive/ui/ui.cc | 4 ++++ selfdrive/ui/ui.h | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 18dd64d..2610e34 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -220,7 +220,38 @@ void OnroadWindow::paintEvent(QPaintEvent *event) { SubMaster &sm = *(s->sm); QPainter p(this); - p.fillRect(rect(), QColor(bg.red(), bg.green(), bg.blue(), 255)); + QRect rect = this->rect(); + p.fillRect(rect, QColor(bg.red(), bg.green(), bg.blue(), 255)); + + if (scene.show_blind_spot) { + auto getBlindspotColor = [&](bool turn_signal, int &frames) { + if (turn_signal) { + if (sm.frame % 10 == 0) { + frames = 5; + } + return (frames-- > 0) ? bg_colors[STATUS_TRAFFIC_MODE_ACTIVE] : bg; + } + return bg_colors[STATUS_TRAFFIC_MODE_ACTIVE]; + }; + + static int blindspot_frames_left = 0; + static int blindspot_frames_right = 0; + + if (scene.blind_spot_left || scene.blind_spot_right) { + if (scene.blind_spot_left) { + QRect leftHalf(rect.x(), rect.y(), rect.width() / 2, rect.height()); + QColor color = getBlindspotColor(scene.turn_signal_left, blindspot_frames_left); + p.fillRect(leftHalf, QColor(color.red(), color.green(), color.blue(), 255)); + } + if (scene.blind_spot_right) { + QRect rightHalf(rect.x() + rect.width() / 2, rect.y(), rect.width() / 2, rect.height()); + QColor color = getBlindspotColor(scene.turn_signal_right, blindspot_frames_right); + p.fillRect(rightHalf, QColor(color.red(), color.green(), color.blue(), 255)); + } + } else { + blindspot_frames_left = blindspot_frames_right = 0; + } + } } // ***** onroad widgets ***** diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 47c8dc3..3945230 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -323,6 +323,10 @@ void ui_update_frogpilot_params(UIState *s) { scene.holiday_themes = custom_theme && params.getBool("HolidayThemes"); scene.random_events = custom_theme && params.getBool("RandomEvents"); + bool developer_ui = params.getBool("DeveloperUI"); + bool border_metrics = developer_ui && params.getBool("BorderMetrics"); + scene.show_blind_spot = border_metrics && params.getBool("BlindSpotMetrics"); + 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 8e5dd61..a651f63 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -215,6 +215,7 @@ typedef struct UIScene { bool road_name_ui; bool rotating_wheel; bool show_aol_status_bar; + bool show_blind_spot; bool show_cem_status_bar; bool show_slc_offset; bool show_slc_offset_ui;