Skip to content

Commit

Permalink
ui: only show overriding set speed states when gas pressed (commaai#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyhaibin authored Mar 27, 2023
1 parent 9c3bceb commit 989b8b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
setProperty("status", s.status);

setProperty("steerOverride", car_state.getSteeringPressed());
setProperty("gasOverride", car_state.getGasPressed());
setProperty("latActive", car_control.getLatActive());
setProperty("madsEnabled", car_state.getMadsEnabled());

Expand Down Expand Up @@ -598,7 +599,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
if (is_cruise_set) {
if (status == STATUS_DISENGAGED) {
p.setPen(whiteColor());
} else if (status == STATUS_OVERRIDE) {
} else if (status == STATUS_OVERRIDE && gasOverride) {
p.setPen(QColor(0x91, 0x9b, 0x95, 0xff));
} else if (speedLimitSLC > 0) {
p.setPen(interpColor(
Expand Down Expand Up @@ -626,13 +627,13 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {

// Draw set speed
if (is_cruise_set) {
if (speedLimitSLC > 0 && status != STATUS_DISENGAGED && status != STATUS_OVERRIDE) {
if (speedLimitSLC > 0 && status != STATUS_DISENGAGED && (status != STATUS_OVERRIDE || !gasOverride)) {
p.setPen(interpColor(
setSpeed,
{speedLimitSLC + 5, speedLimitSLC + 15, speedLimitSLC + 25},
{whiteColor(), QColor(0xff, 0x95, 0x00, 0xff), QColor(0xff, 0x00, 0x00, 0xff)}
));
} else if (speedLimit > 0 && status != STATUS_DISENGAGED && status != STATUS_OVERRIDE) {
} else if (speedLimit > 0 && status != STATUS_DISENGAGED && (status != STATUS_OVERRIDE || !gasOverride)) {
p.setPen(interpColor(
setSpeed,
{speedLimit + 5, speedLimit + 15, speedLimit + 25},
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/onroad.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class AnnotatedCameraWidget : public CameraWidget {
Q_PROPERTY(int status MEMBER status);

Q_PROPERTY(bool steerOverride MEMBER steerOverride);
Q_PROPERTY(bool gasOverride MEMBER gasOverride);
Q_PROPERTY(bool latActive MEMBER latActive);
Q_PROPERTY(bool madsEnabled MEMBER madsEnabled);

Expand Down Expand Up @@ -194,6 +195,7 @@ class AnnotatedCameraWidget : public CameraWidget {
bool wide_cam_requested = false;

bool steerOverride = false;
bool gasOverride = false;
bool latActive = false;
bool madsEnabled = false;

Expand Down

0 comments on commit 989b8b2

Please sign in to comment.