ui: fix brightness when there's no camera (#32413)

old-commit-hash: 79c8fb0236
pull/32199/head
Adeeb Shihadeh 12 months ago committed by GitHub
parent 4a0b3c8b64
commit f641d7e851
  1. 4
      selfdrive/ui/ui.cc
  2. 2
      selfdrive/ui/ui.h

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

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

Loading…
Cancel
Save