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

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