From b89393a5a214a24fe45f49630029749598996562 Mon Sep 17 00:00:00 2001 From: Nayan Date: Sun, 12 Oct 2025 00:34:15 -0400 Subject: [PATCH] UI: Blinker Size & State Fix (#1363) Blinker Size & State Fix Co-authored-by: Jason Wen --- selfdrive/ui/sunnypilot/qt/onroad/hud.cc | 22 ++++++++++++++++++---- selfdrive/ui/sunnypilot/qt/onroad/hud.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/sunnypilot/qt/onroad/hud.cc b/selfdrive/ui/sunnypilot/qt/onroad/hud.cc index c00be966a3..718bfb514b 100644 --- a/selfdrive/ui/sunnypilot/qt/onroad/hud.cc +++ b/selfdrive/ui/sunnypilot/qt/onroad/hud.cc @@ -776,19 +776,33 @@ void HudRendererSP::drawCurrentSpeedSP(QPainter &p, const QRect &surface_rect) { } void HudRendererSP::drawBlinker(QPainter &p, const QRect &surface_rect) { + const bool hazard = leftBlinkerOn && rightBlinkerOn; + int blinkerStatus = hazard ? 2 : (leftBlinkerOn or rightBlinkerOn) ? 1 : 0; + if (!leftBlinkerOn && !rightBlinkerOn) { blinkerFrameCounter = 0; + lastBlinkerStatus = 0; return; } + + if (blinkerStatus != lastBlinkerStatus) { + blinkerFrameCounter = 0; + lastBlinkerStatus = blinkerStatus; + } + ++blinkerFrameCounter; - const int circleRadius = 44; - const int arrowLength = 44; - const int x_gap = 180; + const int BLINKER_COOLDOWN_FRAMES = UI_FREQ / 10; + if (blinkerFrameCounter < BLINKER_COOLDOWN_FRAMES) { + return; + } + + const int circleRadius = 60; + const int arrowLength = 60; + const int x_gap = 160; const int y_offset = 272; const int centerX = surface_rect.center().x(); - const bool hazard = leftBlinkerOn && rightBlinkerOn; const QPen bgBorder(Qt::white, 5); const QPen arrowPen(Qt::NoPen); diff --git a/selfdrive/ui/sunnypilot/qt/onroad/hud.h b/selfdrive/ui/sunnypilot/qt/onroad/hud.h index 4a3f90827d..554c9c5d0d 100644 --- a/selfdrive/ui/sunnypilot/qt/onroad/hud.h +++ b/selfdrive/ui/sunnypilot/qt/onroad/hud.h @@ -114,6 +114,7 @@ private: bool leftBlindspot; bool rightBlindspot; int blinkerFrameCounter; + int lastBlinkerStatus; bool showTurnSignals; bool carControlEnabled;