Screen brightness control
Added toggle to control the screen brightness.
This commit is contained in:
@@ -342,6 +342,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||||||
{"RoadNameUI", PERSISTENT},
|
{"RoadNameUI", PERSISTENT},
|
||||||
{"RotatingWheel", PERSISTENT},
|
{"RotatingWheel", PERSISTENT},
|
||||||
{"SchedulePending", PERSISTENT},
|
{"SchedulePending", PERSISTENT},
|
||||||
|
{"ScreenBrightness", PERSISTENT},
|
||||||
{"SearchInput", PERSISTENT},
|
{"SearchInput", PERSISTENT},
|
||||||
{"SilentMode", PERSISTENT},
|
{"SilentMode", PERSISTENT},
|
||||||
{"ShowCPU", PERSISTENT},
|
{"ShowCPU", PERSISTENT},
|
||||||
|
|||||||
BIN
selfdrive/frogpilot/assets/toggle_icons/icon_light.png
Normal file
BIN
selfdrive/frogpilot/assets/toggle_icons/icon_light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
@@ -51,6 +51,8 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
|
|||||||
{"DriveStats", "Drive Stats In Home Screen", "Display your device's drive stats in the home screen.", ""},
|
{"DriveStats", "Drive Stats In Home Screen", "Display your device's drive stats in the home screen.", ""},
|
||||||
{"FullMap", "Full Sized Map", "Maximize the size of the map in the onroad UI.", ""},
|
{"FullMap", "Full Sized Map", "Maximize the size of the map in the onroad UI.", ""},
|
||||||
{"HideSpeed", "Hide Speed", "Hide the speed indicator in the onroad UI. Additional toggle allows it to be hidden/shown via tapping the speed itself.", ""},
|
{"HideSpeed", "Hide Speed", "Hide the speed indicator in the onroad UI. Additional toggle allows it to be hidden/shown via tapping the speed itself.", ""},
|
||||||
|
|
||||||
|
{"ScreenBrightness", "Screen Brightness", "Customize your screen brightness.", "../frogpilot/assets/toggle_icons/icon_light.png"},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const auto &[param, title, desc, icon] : visualToggles) {
|
for (const auto &[param, title, desc, icon] : visualToggles) {
|
||||||
@@ -166,6 +168,13 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
|
|||||||
std::vector<QString> hideSpeedToggleNames{tr("Control Via UI")};
|
std::vector<QString> hideSpeedToggleNames{tr("Control Via UI")};
|
||||||
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, hideSpeedToggles, hideSpeedToggleNames);
|
toggle = new FrogPilotParamToggleControl(param, title, desc, icon, hideSpeedToggles, hideSpeedToggleNames);
|
||||||
|
|
||||||
|
} 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 {
|
} else {
|
||||||
toggle = new ParamControl(param, title, desc, icon, this);
|
toggle = new ParamControl(param, title, desc, icon, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,6 +352,7 @@ void ui_update_frogpilot_params(UIState *s) {
|
|||||||
scene.hide_speed_ui = scene.hide_speed && params.getBool("HideSpeedUI");
|
scene.hide_speed_ui = scene.hide_speed && params.getBool("HideSpeedUI");
|
||||||
|
|
||||||
scene.rotating_wheel = params.getBool("RotatingWheel");
|
scene.rotating_wheel = params.getBool("RotatingWheel");
|
||||||
|
scene.screen_brightness = params.getInt("ScreenBrightness");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIState::updateStatus() {
|
void UIState::updateStatus() {
|
||||||
@@ -493,6 +494,9 @@ void Device::updateBrightness(const UIState &s) {
|
|||||||
int brightness = brightness_filter.update(clipped_brightness);
|
int brightness = brightness_filter.update(clipped_brightness);
|
||||||
if (!awake) {
|
if (!awake) {
|
||||||
brightness = 0;
|
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) {
|
if (brightness != last_brightness) {
|
||||||
@@ -513,7 +517,11 @@ void Device::updateWakefulness(const UIState &s) {
|
|||||||
emit interactiveTimeout();
|
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() {
|
UIState *uiState() {
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ typedef struct UIScene {
|
|||||||
int desired_follow;
|
int desired_follow;
|
||||||
int obstacle_distance;
|
int obstacle_distance;
|
||||||
int obstacle_distance_stock;
|
int obstacle_distance_stock;
|
||||||
|
int screen_brightness;
|
||||||
int steering_angle_deg;
|
int steering_angle_deg;
|
||||||
int stopped_equivalence;
|
int stopped_equivalence;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user