UI: better logic for Stand Still Timer (#28)

This commit is contained in:
Jason Wen
2023-02-09 10:40:20 -05:00
committed by GitHub
parent 37e07b8362
commit c19c38309e
2 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -333,6 +333,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
setProperty("brakeLights", car_state.getBrakeLights() && s.scene.visual_brake_lights);
setProperty("standStillTimer", s.scene.stand_still_timer);
setProperty("standStill", car_state.getStandstill());
setProperty("standstillElapsedTime", sm["lateralPlan"].getLateralPlan().getStandstillElapsed());
// update engageability/experimental mode button
@@ -501,7 +502,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
}
// Stand Still Timer
if (standStillTimer && standstillElapsedTime != 0.0) {
if (standStillTimer && standStill) {
drawStandstillTimer(p, rect().right() - 650, 30 + 160 + 250);
}
p.restore();
@@ -571,7 +572,7 @@ void AnnotatedCameraWidget::drawStandstillTimer(QPainter &p, int x, int y) {
int minute = (int)(standstillElapsedTime / 60);
int second = (int)((standstillElapsedTime) - (minute * 60));
if (standstillElapsedTime != 0) {
if (standStill) {
snprintf(lab_str, sizeof(lab_str), "STOP");
snprintf(val_str, sizeof(val_str), "%01d:%02d", minute, second);
}
+2
View File
@@ -78,6 +78,7 @@ class AnnotatedCameraWidget : public CameraWidget {
Q_PROPERTY(bool brakeLights MEMBER brakeLights);
Q_PROPERTY(bool standStillTimer MEMBER standStillTimer);
Q_PROPERTY(bool standStill MEMBER standStill);
Q_PROPERTY(float standstillElapsedTime MEMBER standstillElapsedTime);
public:
@@ -127,6 +128,7 @@ private:
bool brakeLights;
bool standStillTimer;
bool standStill;
float standstillElapsedTime;
protected: