From 79c8fb0236a1468cf1f7396a8a120ccd4fb10f40 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Mon, 13 May 2024 13:27:05 -0700 Subject: [PATCH] ui: fix brightness when there's no camera (#32413) --- selfdrive/ui/ui.cc | 4 +++- selfdrive/ui/ui.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 9afd22f13..e5309c969 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -205,6 +205,8 @@ static void update_state(UIState *s) { auto cam_state = sm["wideRoadCameraState"].getWideRoadCameraState(); float scale = (cam_state.getSensor() == cereal::FrameData::ImageSensor::AR0231) ? 6.0f : 1.0f; scene.light_sensor = std::max(100.0f - scale * cam_state.getExposureValPercent(), 0.0f); + } else if (!sm.allAliveAndValid({"wideRoadCameraState"})) { + scene.light_sensor = -1; } scene.started = sm["deviceState"].getDeviceState().getStarted() && scene.ignition; @@ -320,7 +322,7 @@ void Device::resetInteractiveTimeout(int timeout) { void Device::updateBrightness(const UIState &s) { float clipped_brightness = offroad_brightness; - if (s.scene.started) { + if (s.scene.started && s.scene.light_sensor > 0) { clipped_brightness = s.scene.light_sensor; // CIE 1931 - https://www.photonstophotos.net/GeneralTopics/Exposure/Psychometric_Lightness_and_Gamma.htm diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index f5028a280..7238159dd 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -97,7 +97,7 @@ typedef struct UIScene { cereal::LongitudinalPersonality personality; - float light_sensor; + float light_sensor = -1; bool started, ignition, is_metric, map_on_left, longitudinal_control; bool world_objects_visible = false; uint64_t started_frame;