diff --git a/selfdrive/ui/qt/onroad/onroad_home.cc b/selfdrive/ui/qt/onroad/onroad_home.cc index cc5368c2a..73663a476 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.cc +++ b/selfdrive/ui/qt/onroad/onroad_home.cc @@ -87,11 +87,14 @@ void OnroadWindow::updateState(const UIState &s) { blindSpotLeft = scene.blind_spot_left; blindSpotRight = scene.blind_spot_right; showBlindspot = scene.show_blind_spot && (blindSpotLeft || blindSpotRight); + showSignal = scene.show_signal && (turnSignalLeft || turnSignalRight); showSteering = scene.show_steering; steer = scene.steer; steeringAngleDeg = scene.steering_angle_deg; + turnSignalLeft = scene.turn_signal_left; + turnSignalRight = scene.turn_signal_right; - if (showBlindspot || showSteering) { + if (showBlindspot || showSignal || showSteering) { shouldUpdate = true; } @@ -270,4 +273,54 @@ void OnroadWindow::paintEvent(QPaintEvent *event) { p.fillRect(blindspotRectLeft, blindspotColorLeft); p.fillRect(blindspotRectRight, blindspotColorRight); } + + if (showSignal) { + static int signalFramesLeft = 0; + static int signalFramesRight = 0; + + bool blindSpotActive = (blindSpotLeft && turnSignalLeft) || (blindSpotRight && turnSignalRight); + bool turnSignalActive = (turnSignalLeft && signalFramesLeft > 0) || (turnSignalRight && signalFramesRight > 0); + + QColor signalBorderColorLeft = bg; + QColor signalBorderColorRight = bg; + + if (blindSpotLeft) { + signalBorderColorLeft = bg_colors[STATUS_TRAFFIC_MODE_ACTIVE]; + } + + if (blindSpotRight) { + signalBorderColorRight = bg_colors[STATUS_TRAFFIC_MODE_ACTIVE]; + } + + if (sm.frame % 20 == 0 || blindSpotActive || turnSignalActive) { + QColor activeColor = bg_colors[STATUS_CONDITIONAL_OVERRIDDEN]; + + if (turnSignalLeft) { + signalFramesLeft = sm.frame % 10 == 0 && blindSpotActive ? 5 : sm.frame % 20 == 0 ? 10 : signalFramesLeft - 1; + if (signalFramesLeft > 0) { + signalBorderColorLeft = activeColor; + } + } + + if (turnSignalRight) { + signalFramesRight = sm.frame % 10 == 0 && blindSpotActive ? 5 : sm.frame % 20 == 0 ? 10 : signalFramesRight - 1; + if (signalFramesRight > 0) { + signalBorderColorRight = activeColor; + } + } + } + + int xLeft = rect.x(); + int xRight = rect.x() + rect.width() / 2; + QRect signalRectLeft(xLeft, rect.y(), rect.width() / 2, rect.height()); + QRect signalRectRight(xRight, rect.y(), rect.width() / 2, rect.height()); + + if (turnSignalLeft) { + p.fillRect(signalRectLeft, signalBorderColorLeft); + } + + if (turnSignalRight) { + p.fillRect(signalRectRight, signalBorderColorRight); + } + } } diff --git a/selfdrive/ui/qt/onroad/onroad_home.h b/selfdrive/ui/qt/onroad/onroad_home.h index 47647a04b..0a8225ad3 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.h +++ b/selfdrive/ui/qt/onroad/onroad_home.h @@ -28,7 +28,10 @@ private: bool blindSpotLeft; bool blindSpotRight; bool showBlindspot; + bool showSignal; bool showSteering; + bool turnSignalLeft; + bool turnSignalRight; float steer; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index f41ae3162..64a4c25e6 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -342,6 +342,7 @@ void ui_update_frogpilot_params(UIState *s, Params ¶ms) { bool developer_ui = params.getBool("DeveloperUI"); bool border_metrics = developer_ui && params.getBool("BorderMetrics"); scene.show_blind_spot = border_metrics && params.getBool("BlindSpotMetrics"); + scene.show_signal = border_metrics && params.getBool("SignalMetrics"); scene.show_steering = border_metrics && params.getBool("ShowSteering"); scene.disable_smoothing_mtsc = params.getBool("MTSCEnabled") && params.getBool("DisableMTSCSmoothing"); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index cf77740d8..213fa2c15 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -157,6 +157,7 @@ typedef struct UIScene { bool show_aol_status_bar; bool show_blind_spot; bool show_cem_status_bar; + bool show_signal; bool show_slc_offset; bool show_slc_offset_ui; bool show_steering;