Driver camera view when in reverse

Added toggle to show the driver camera when in the reverse gear.
This commit is contained in:
FrogAi
2024-04-05 03:23:26 -07:00
parent 7b8bc36d3d
commit 464cb4620d
7 changed files with 22 additions and 5 deletions
+1
View File
@@ -256,6 +256,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"DisableOpenpilotLongitudinal", PERSISTENT},
{"DisengageVolume", PERSISTENT},
{"DragonPilotTune", PERSISTENT},
{"DriverCamera", PERSISTENT},
{"DynamicPathWidth", PERSISTENT},
{"EngageVolume", PERSISTENT},
{"FrogPilotTogglesUpdated", PERSISTENT},
@@ -38,6 +38,7 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
{"QOLVisuals", tr("Quality of Life"), tr("Miscellaneous quality of life changes to improve your overall openpilot experience."), "../frogpilot/assets/toggle_icons/quality_of_life.png"},
{"CameraView", tr("Camera View"), tr("Choose your preferred camera view for the onroad UI. This is purely a visual change and doesn't impact how openpilot drives."), ""},
{"DriverCamera", tr("Driver Camera On Reverse"), tr("Show the driver camera feed when in reverse."), ""},
};
for (const auto &[param, title, desc, icon] : visualToggles) {
@@ -28,7 +28,7 @@ private:
std::set<QString> customOnroadUIKeys = {"CustomPaths", "DeveloperUI", "LeadInfo"};
std::set<QString> customThemeKeys = {"CustomColors", "CustomIcons", "CustomSignals", "CustomSounds"};
std::set<QString> modelUIKeys = {"DynamicPathWidth", "HideLeadMarker", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"};
std::set<QString> qolKeys = {"CameraView"};
std::set<QString> qolKeys = {"CameraView", "DriverCamera"};
std::set<QString> screenKeys = {};
std::map<std::string, ParamControl*> toggles;
+12 -3
View File
@@ -66,6 +66,10 @@ void HomeWindow::updateState(const UIState &s) {
body->setEnabled(true);
slayout->setCurrentWidget(body);
}
if (s.scene.started) {
showDriverView(s.scene.driver_camera_timer >= 10, true);
}
}
void HomeWindow::offroadTransition(bool offroad) {
@@ -79,14 +83,19 @@ void HomeWindow::offroadTransition(bool offroad) {
}
}
void HomeWindow::showDriverView(bool show) {
void HomeWindow::showDriverView(bool show, bool started) {
if (show) {
emit closeSettings();
slayout->setCurrentWidget(driver_view);
sidebar->setVisible(show == false);
} else {
slayout->setCurrentWidget(home);
if (started) {
slayout->setCurrentWidget(onroad);
} else {
slayout->setCurrentWidget(home);
sidebar->setVisible(show == false);
}
}
sidebar->setVisible(show == false);
}
void HomeWindow::mousePressEvent(QMouseEvent* e) {
+1 -1
View File
@@ -56,7 +56,7 @@ signals:
public slots:
void offroadTransition(bool offroad);
void showDriverView(bool show);
void showDriverView(bool show, bool started=false);
void showSidebar(bool show);
void showMapPanel(bool show);
+3
View File
@@ -226,6 +226,7 @@ static void update_state(UIState *s) {
scene.acceleration = carState.getAEgo();
scene.blind_spot_left = carState.getLeftBlindspot();
scene.blind_spot_right = carState.getRightBlindspot();
scene.reverse = carState.getGearShifter() == cereal::CarState::GearShifter::REVERSE;
scene.turn_signal_left = carState.getLeftBlinker();
scene.turn_signal_right = carState.getRightBlinker();
}
@@ -329,6 +330,7 @@ void ui_update_frogpilot_params(UIState *s) {
bool quality_of_life_visuals = params.getBool("QOLVisuals");
scene.camera_view = quality_of_life_visuals ? params.getInt("CameraView") : 0;
scene.driver_camera = quality_of_life_visuals && params.getBool("DriverCamera");
}
void UIState::updateStatus() {
@@ -398,6 +400,7 @@ void UIState::update() {
// FrogPilot live variables that need to be constantly checked
scene.conditional_status = scene.conditional_experimental ? paramsMemory.getInt("CEStatus") : 0;
scene.driver_camera_timer = (scene.driver_camera && scene.reverse) ? scene.driver_camera_timer + 1 : 0;
}
void UIState::setPrimeType(PrimeType type) {
+3
View File
@@ -179,6 +179,7 @@ typedef struct UIScene {
bool blind_spot_path;
bool blind_spot_right;
bool conditional_experimental;
bool driver_camera;
bool dynamic_path_width;
bool enabled;
bool experimental_mode;
@@ -188,6 +189,7 @@ typedef struct UIScene {
bool live_valid;
bool map_open;
bool model_ui;
bool reverse;
bool right_hand_drive;
bool show_aol_status_bar;
bool show_cem_status_bar;
@@ -221,6 +223,7 @@ typedef struct UIScene {
int custom_icons;
int custom_signals;
int desired_follow;
int driver_camera_timer;
int obstacle_distance;
int obstacle_distance_stock;
int stopped_equivalence;