diff --git a/common/params.cc b/common/params.cc index 6275d79..8d8a54a 100644 --- a/common/params.cc +++ b/common/params.cc @@ -251,6 +251,7 @@ std::unordered_map keys = { {"RelaxedFollow", PERSISTENT}, {"RelaxedJerk", PERSISTENT}, {"RoadEdgesWidth", PERSISTENT}, + {"ScreenBrightness", PERSISTENT}, {"ShowCPU", PERSISTENT}, {"ShowFPS", PERSISTENT}, {"ShowGPU", PERSISTENT}, diff --git a/selfdrive/frogpilot/assets/toggle_icons/icon_light.png b/selfdrive/frogpilot/assets/toggle_icons/icon_light.png new file mode 100644 index 0000000..2a3369c Binary files /dev/null and b/selfdrive/frogpilot/assets/toggle_icons/icon_light.png differ diff --git a/selfdrive/frogpilot/ui/visual_settings.cc b/selfdrive/frogpilot/ui/visual_settings.cc index cf453b4..8c215f2 100644 --- a/selfdrive/frogpilot/ui/visual_settings.cc +++ b/selfdrive/frogpilot/ui/visual_settings.cc @@ -18,6 +18,8 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot {"PathWidth", "Path Width", "Customize the width of the driving path shown on your UI.\n\nDefault matches the width of a 2019 Lexus ES 350.", ""}, {"RoadEdgesWidth", "Road Edges", "Adjust the visual thickness of road edges on your display.\n\nDefault is 1/2 of the MUTCD average lane line width of 4 inches.", ""}, {"UnlimitedLength", "'Unlimited' Road UI Length", "Extend the display of the path, lane lines, and road edges as far as the system can detect, providing a more expansive view of the road ahead.", ""}, + + {"ScreenBrightness", "Screen Brightness", "Customize your screen brightness.", "../frogpilot/assets/toggle_icons/icon_light.png"}, }; for (const auto &[param, title, desc, icon] : visualToggles) { @@ -58,6 +60,13 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot } else if (param == "PathWidth") { toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map(), this, false, " feet", 10); + } else if (param == "ScreenBrightness") { + std::map brightnessLabels; + for (int i = 0; i <= 101; ++i) { + brightnessLabels[i] = i == 0 ? "Screen Off" : i == 101 ? "Auto" : QString::number(i) + "%"; + } + toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 101, brightnessLabels, this, false); + } else { toggle = new ParamControl(param, title, desc, icon, this); } diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 44880fe..b6b9f1d 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -292,6 +292,8 @@ void ui_update_params(UIState *s) { scene.path_width = params.getInt("PathWidth") / 10.0 * (scene.is_metric ? 1 : FOOT_TO_METER) / 2; scene.road_edge_width = params.getInt("RoadEdgesWidth") * (scene.is_metric ? 1 : INCH_TO_CM) / 200; scene.unlimited_road_ui_length = scene.model_ui && params.getBool("UnlimitedLength"); + + scene.screen_brightness = params.getInt("ScreenBrightness"); } void UIState::updateStatus() { @@ -339,6 +341,8 @@ UIState::UIState(QObject *parent) : QObject(parent) { QObject::connect(timer, &QTimer::timeout, this, &UIState::update); timer->start(1000 / UI_FREQ); + scene.screen_brightness = params.getInt("ScreenBrightness"); + setDefaultParams(); } @@ -427,6 +431,9 @@ void Device::updateBrightness(const UIState &s) { int brightness = brightness_filter.update(clipped_brightness); if (!awake) { brightness = 0; + } else if (s.scene.screen_brightness <= 100) { + // Bring the screen brightness up to 5% upon screen tap + brightness = fmax(5, s.scene.screen_brightness); } if (brightness != last_brightness) { @@ -447,7 +454,11 @@ void Device::updateWakefulness(const UIState &s) { emit interactiveTimeout(); } - setAwake(s.scene.ignition || interactive_timeout > 0); + if (s.scene.screen_brightness != 0) { + setAwake(s.scene.ignition || interactive_timeout > 0); + } else { + setAwake(interactive_timeout > 0); + } } UIState *uiState() { diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 7834982..9ec8e2d 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -198,6 +198,7 @@ typedef struct UIScene { int desired_follow; int obstacle_distance; int obstacle_distance_stock; + int screen_brightness; int stopped_equivalence; QPolygonF track_adjacent_vertices[6]; QPolygonF track_edge_vertices;