Custom screen brightness

Added toggle to customize the screen brightness.
This commit is contained in:
FrogAi
2024-01-12 22:39:30 -07:00
parent d6e17df710
commit 62e60535e6
5 changed files with 23 additions and 1 deletions

View File

@@ -251,6 +251,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"RelaxedFollow", PERSISTENT},
{"RelaxedJerk", PERSISTENT},
{"RoadEdgesWidth", PERSISTENT},
{"ScreenBrightness", PERSISTENT},
{"ShowCPU", PERSISTENT},
{"ShowFPS", PERSISTENT},
{"ShowGPU", PERSISTENT},

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@@ -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<int, QString>(), this, false, " feet", 10);
} else if (param == "ScreenBrightness") {
std::map<int, QString> 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);
}

View File

@@ -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() {

View File

@@ -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;