|
|
@ -12,7 +12,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#define BACKLIGHT_DT 0.05 |
|
|
|
#define BACKLIGHT_DT 0.05 |
|
|
|
#define BACKLIGHT_TS 10.00 |
|
|
|
#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
|
|
|
|
// 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) { |
|
|
|
static void update_state(UIState *s) { |
|
|
|
SubMaster &sm = *(s->sm); |
|
|
|
SubMaster &sm = *(s->sm); |
|
|
|
UIScene &scene = s->scene; |
|
|
|
UIScene &scene = s->scene; |
|
|
|
|
|
|
|
s->running_time = 1e-9 * (nanos_since_boot() - sm["deviceState"].getDeviceState().getStartedMonoTime()); |
|
|
|
|
|
|
|
|
|
|
|
// update engageability and DM icons at 2Hz
|
|
|
|
// update engageability and DM icons at 2Hz
|
|
|
|
if (sm.frame % (UI_FREQ / 2) == 0) { |
|
|
|
if (sm.frame % (UI_FREQ / 2) == 0) { |
|
|
@ -278,8 +279,10 @@ void Device::setAwake(bool on, bool reset) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Device::updateBrightness(const UIState &s) { |
|
|
|
void Device::updateBrightness(const UIState &s) { |
|
|
|
|
|
|
|
float clipped_brightness = BACKLIGHT_OFFROAD; |
|
|
|
|
|
|
|
if (s.scene.started) { |
|
|
|
// Scale to 0% to 100%
|
|
|
|
// 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
|
|
|
|
// CIE 1931 - https://www.photonstophotos.net/GeneralTopics/Exposure/Psychometric_Lightness_and_Gamma.htm
|
|
|
|
if (clipped_brightness <= 8) { |
|
|
|
if (clipped_brightness <= 8) { |
|
|
@ -291,8 +294,15 @@ void Device::updateBrightness(const UIState &s) { |
|
|
|
// Scale back to 10% to 100%
|
|
|
|
// Scale back to 10% to 100%
|
|
|
|
clipped_brightness = std::clamp(100.0f * clipped_brightness, 10.0f, 100.0f); |
|
|
|
clipped_brightness = std::clamp(100.0f * clipped_brightness, 10.0f, 100.0f); |
|
|
|
|
|
|
|
|
|
|
|
if (!s.scene.started) { |
|
|
|
// Limit brightness if running for too long
|
|
|
|
clipped_brightness = BACKLIGHT_OFFROAD; |
|
|
|
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); |
|
|
|
int brightness = brightness_filter.update(clipped_brightness); |
|
|
|