Onroad Screen Off Brightness + Timer + Global Brightness (#19)

* Onroad Screen Off Brightness + Timer + Global Brightness

* need to add the object

* missed this
This commit is contained in:
Jason Wen
2023-02-05 23:55:14 -05:00
committed by GitHub
parent 1fb8a891fc
commit 7b22a2b4ad
3 changed files with 37 additions and 0 deletions
+5
View File
@@ -83,6 +83,11 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) {
if ((onroad->isVisible() || body->isVisible()) && (!sidebar->isVisible() || e->x() > sidebar->width())) {
sidebar->setVisible(!sidebar->isVisible() && !onroad->isMapVisible());
}
if (uiState()->scene.started && uiState()->scene.onroadScreenOff != -2) {
uiState()->scene.touched2 = true;
QTimer::singleShot(500, []() { uiState()->scene.touched2 = false; });
}
}
void HomeWindow::mouseDoubleClickEvent(QMouseEvent* e) {
+26
View File
@@ -179,6 +179,19 @@ void ui_update_params(UIState *s) {
s->scene.map_on_left = params.getBool("NavSettingLeftSide");
s->scene.dynamic_lane_profile_toggle = params.getBool("DynamicLaneProfileToggle");
s->scene.visual_brake_lights = params.getBool("BrakeLights");
s->scene.onroadScreenOff = std::atoi(params.get("OnroadScreenOff").c_str());
s->scene.onroadScreenOffBrightness = std::atoi(params.get("OnroadScreenOffBrightness").c_str());
s->scene.brightness = std::atoi(params.get("BrightnessControl").c_str());
if (s->scene.onroadScreenOff > 0) {
s->scene.osoTimer = s->scene.onroadScreenOff * 60 * UI_FREQ;
} else if (s->scene.onroadScreenOff == 0) {
s->scene.osoTimer = 30 * UI_FREQ;
} else if (s->scene.onroadScreenOff == -1) {
s->scene.osoTimer = 15 * UI_FREQ;
} else {
s->scene.osoTimer = -1;
}
}
void UIState::updateStatus() {
@@ -290,11 +303,24 @@ void Device::updateBrightness(const UIState &s) {
// Scale back to 10% to 100%
clipped_brightness = std::clamp(100.0f * clipped_brightness, 10.0f, 100.0f);
if (s.scene.onroadScreenOff != -2 && s.scene.touched2) {
sleep_time = s.scene.osoTimer;
} else if (s.scene.controlsState.getAlertSize() != cereal::ControlsState::AlertSize::NONE && s.scene.onroadScreenOff != -2) {
sleep_time = s.scene.osoTimer;
} else if (sleep_time > 0 && s.scene.onroadScreenOff != -2) {
sleep_time--;
} else if (s.scene.started && sleep_time == -1 && s.scene.onroadScreenOff != -2) {
sleep_time = s.scene.osoTimer;
}
}
int brightness = brightness_filter.update(clipped_brightness);
if (!awake) {
brightness = 0;
} else if (s.scene.started && sleep_time == 0 && s.scene.onroadScreenOff != -2) {
brightness = s.scene.onroadScreenOffBrightness * 0.01 * brightness;
} else if (s.scene.brightness) {
brightness = s.scene.brightness * 0.99;
}
if (brightness != last_brightness) {
+6
View File
@@ -94,6 +94,7 @@ typedef struct UIScene {
mat3 view_from_calib = DEFAULT_CALIBRATION;
mat3 view_from_wide_calib = DEFAULT_CALIBRATION;
cereal::PandaState::PandaType pandaType;
cereal::ControlsState::Reader controlsState;
// modelV2
float lane_line_probs[4];
@@ -113,6 +114,9 @@ typedef struct UIScene {
bool dynamic_lane_profile_status, dynamic_lane_profile_toggle;
bool visual_brake_lights;
int onroadScreenOff, osoTimer, brightness, onroadScreenOffBrightness, awake;
bool touched2 = false;
} UIScene;
class UIState : public QObject {
@@ -178,6 +182,8 @@ private:
bool motionTriggered(const UIState &s);
void setAwake(bool on);
int sleep_time = -1;
signals:
void displayPowerChanged(bool on);
void interactiveTimout();