mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 00:05:59 +08:00
tici: limit brightness with display uptime (#22918)
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
+23
-13
@@ -12,7 +12,7 @@
|
||||
|
||||
#define BACKLIGHT_DT 0.05
|
||||
#define BACKLIGHT_TS 10.00
|
||||
#define BACKLIGHT_OFFROAD 75
|
||||
#define BACKLIGHT_OFFROAD 50
|
||||
|
||||
|
||||
// Projects a point in car to space to the corresponding point in full frame
|
||||
@@ -105,6 +105,7 @@ static void update_sockets(UIState *s) {
|
||||
static void update_state(UIState *s) {
|
||||
SubMaster &sm = *(s->sm);
|
||||
UIScene &scene = s->scene;
|
||||
s->running_time = 1e-9 * (nanos_since_boot() - sm["deviceState"].getDeviceState().getStartedMonoTime());
|
||||
|
||||
// update engageability and DM icons at 2Hz
|
||||
if (sm.frame % (UI_FREQ / 2) == 0) {
|
||||
@@ -278,21 +279,30 @@ void Device::setAwake(bool on, bool reset) {
|
||||
}
|
||||
|
||||
void Device::updateBrightness(const UIState &s) {
|
||||
// Scale to 0% to 100%
|
||||
float clipped_brightness = 100.0 * s.scene.light_sensor;
|
||||
float clipped_brightness = BACKLIGHT_OFFROAD;
|
||||
if (s.scene.started) {
|
||||
// Scale to 0% to 100%
|
||||
clipped_brightness = 100.0 * s.scene.light_sensor;
|
||||
|
||||
// CIE 1931 - https://www.photonstophotos.net/GeneralTopics/Exposure/Psychometric_Lightness_and_Gamma.htm
|
||||
if (clipped_brightness <= 8) {
|
||||
clipped_brightness = (clipped_brightness / 903.3);
|
||||
} else {
|
||||
clipped_brightness = std::pow((clipped_brightness + 16.0) / 116.0, 3.0);
|
||||
}
|
||||
// CIE 1931 - https://www.photonstophotos.net/GeneralTopics/Exposure/Psychometric_Lightness_and_Gamma.htm
|
||||
if (clipped_brightness <= 8) {
|
||||
clipped_brightness = (clipped_brightness / 903.3);
|
||||
} else {
|
||||
clipped_brightness = std::pow((clipped_brightness + 16.0) / 116.0, 3.0);
|
||||
}
|
||||
|
||||
// Scale back to 10% to 100%
|
||||
clipped_brightness = std::clamp(100.0f * clipped_brightness, 10.0f, 100.0f);
|
||||
// Scale back to 10% to 100%
|
||||
clipped_brightness = std::clamp(100.0f * clipped_brightness, 10.0f, 100.0f);
|
||||
|
||||
if (!s.scene.started) {
|
||||
clipped_brightness = BACKLIGHT_OFFROAD;
|
||||
// Limit brightness if running for too long
|
||||
if (Hardware::TICI()) {
|
||||
const float MAX_BRIGHTNESS_HOURS = 4;
|
||||
const float HOURLY_BRIGHTNESS_DECREASE = 5;
|
||||
float ui_running_hours = s.running_time / (60*60);
|
||||
float anti_burnin_max_percent = std::clamp(100.0f - HOURLY_BRIGHTNESS_DECREASE * (ui_running_hours - MAX_BRIGHTNESS_HOURS),
|
||||
30.0f, 100.0f);
|
||||
clipped_brightness = std::min(clipped_brightness, anti_burnin_max_percent);
|
||||
}
|
||||
}
|
||||
|
||||
int brightness = brightness_filter.update(clipped_brightness);
|
||||
|
||||
+2
-1
@@ -31,7 +31,6 @@ const int header_h = 420;
|
||||
const int footer_h = 280;
|
||||
|
||||
const int UI_FREQ = 20; // Hz
|
||||
|
||||
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert;
|
||||
|
||||
// TODO: this is also hardcoded in common/transformations/camera.py
|
||||
@@ -149,6 +148,8 @@ typedef struct UIState {
|
||||
|
||||
float car_space_transform[6];
|
||||
bool wide_camera;
|
||||
|
||||
float running_time;
|
||||
} UIState;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user