tici: limit brightness with display uptime (#22918)

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: c9218a55f3
commatwo_master
HaraldSchafer 3 years ago committed by GitHub
parent 5247da772d
commit 95d63ee981
  1. 18
      selfdrive/ui/ui.cc
  2. 3
      selfdrive/ui/ui.h

@ -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,8 +279,10 @@ void Device::setAwake(bool on, bool reset) {
}
void Device::updateBrightness(const UIState &s) {
float clipped_brightness = BACKLIGHT_OFFROAD;
if (s.scene.started) {
// Scale to 0% to 100%
float clipped_brightness = 100.0 * s.scene.light_sensor;
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) {
@ -291,8 +294,15 @@ 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.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);

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

Loading…
Cancel
Save