From e8d2bc223b034107c02461e9abfe0167f3e7793a Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Sat, 8 Jun 2024 13:30:34 -0700 Subject: [PATCH] Controls - Quality of Life - Reverse Cruise Increase Reverses the 'long press' functionality logic to increase the max set speed by 5 instead of 1. Useful to increase the max speed quickly. --- selfdrive/car/toyota/toyotacan.py | 2 +- selfdrive/ui/qt/onroad/annotated_camera.cc | 4 ++++ selfdrive/ui/qt/onroad/annotated_camera.h | 2 ++ selfdrive/ui/qt/onroad/onroad_home.cc | 9 +++++++++ selfdrive/ui/ui.cc | 4 ++++ selfdrive/ui/ui.h | 2 ++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/toyota/toyotacan.py b/selfdrive/car/toyota/toyotacan.py index 0c2f936b2..7d9c12a2f 100644 --- a/selfdrive/car/toyota/toyotacan.py +++ b/selfdrive/car/toyota/toyotacan.py @@ -43,7 +43,7 @@ def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead, acc_ty "PERMIT_BRAKING": 1, "RELEASE_STANDSTILL": not standstill_req, "CANCEL_REQ": pcm_cancel, - "ALLOW_LONG_PRESS": 1, + "ALLOW_LONG_PRESS": 2 if frogpilot_toggles.reverse_cruise_increase else 1, "ACC_CUT_IN": fcw_alert, # only shown when ACC enabled } return packer.make_can_msg("ACC_CONTROL", 0, values) diff --git a/selfdrive/ui/qt/onroad/annotated_camera.cc b/selfdrive/ui/qt/onroad/annotated_camera.cc index ee8df985d..ec50f8c31 100644 --- a/selfdrive/ui/qt/onroad/annotated_camera.cc +++ b/selfdrive/ui/qt/onroad/annotated_camera.cc @@ -123,6 +123,8 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) { ), 10)); } else if (trafficModeActive) { p.setPen(QPen(redColor(), 10)); + } else if (reverseCruise) { + p.setPen(QPen(blueColor(), 6)); } else { p.setPen(QPen(whiteColor(75), 6)); } @@ -545,6 +547,8 @@ void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &painter, const UISce bottom_layout->setAlignment(distance_btn, (rightHandDM ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignBottom); } + reverseCruise = scene.reverse_cruise; + trafficModeActive = scene.traffic_mode_active; } diff --git a/selfdrive/ui/qt/onroad/annotated_camera.h b/selfdrive/ui/qt/onroad/annotated_camera.h index 094561093..00a7aa4c4 100644 --- a/selfdrive/ui/qt/onroad/annotated_camera.h +++ b/selfdrive/ui/qt/onroad/annotated_camera.h @@ -58,6 +58,7 @@ private: bool experimentalMode; bool mapOpen; bool onroadDistanceButton; + bool reverseCruise; bool showAlwaysOnLateralStatusBar; bool showConditionalExperimentalStatusBar; bool trafficModeActive; @@ -76,6 +77,7 @@ private: QString leadDistanceUnit; QString leadSpeedUnit; + inline QColor blueColor(int alpha = 255) { return QColor(0, 150, 255, alpha); } inline QColor greenColor(int alpha = 242) { return QColor(23, 134, 68, alpha); } protected: diff --git a/selfdrive/ui/qt/onroad/onroad_home.cc b/selfdrive/ui/qt/onroad/onroad_home.cc index 829e8cec6..413bb8324 100644 --- a/selfdrive/ui/qt/onroad/onroad_home.cc +++ b/selfdrive/ui/qt/onroad/onroad_home.cc @@ -97,6 +97,15 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) { // FrogPilot clickable widgets QPoint pos = e->pos(); + QRect maxSpeedRect(7, 25, 225, 225); + + if (maxSpeedRect.contains(pos) && scene.reverse_cruise_ui) { + scene.reverse_cruise = !scene.reverse_cruise; + params.putBoolNonBlocking("ReverseCruise", scene.reverse_cruise); + updateFrogPilotToggles(); + return; + } + if (scene.experimental_mode_via_screen && pos != timeoutPoint) { if (clickTimer.isActive()) { clickTimer.stop(); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index aa17531dd..ee745bd29 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -302,6 +302,10 @@ void ui_update_frogpilot_params(UIState *s, Params ¶ms) { bool model_manager = params.getBool("ModelManagement"); scene.model_randomizer = model_manager && params.getBool("ModelRandomizer"); + bool quality_of_life_controls = params.getBool("QOLControls"); + scene.reverse_cruise = quality_of_life_controls && params.getBool("ReverseCruise"); + scene.reverse_cruise_ui = params.getBool("ReverseCruiseUI"); + scene.tethering_config = params.getInt("TetheringEnabled"); if (scene.tethering_config == 2) { WifiManager(s).setTetheringEnabled(true); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 43aec27ea..694707512 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -134,6 +134,8 @@ typedef struct UIScene { bool online; bool onroad_distance_button; bool parked; + bool reverse_cruise; + bool reverse_cruise_ui; bool right_hand_drive; bool show_aol_status_bar; bool show_cem_status_bar;