From 348631fedc93969c2e07a68b66809b7a72d7d256 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Fri, 17 Jul 2020 17:00:57 +0200 Subject: [PATCH] Only store valid sensor values --- AdaptiveBrightness/main_window.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AdaptiveBrightness/main_window.cpp b/AdaptiveBrightness/main_window.cpp index 93d33e4..8a88d37 100644 --- a/AdaptiveBrightness/main_window.cpp +++ b/AdaptiveBrightness/main_window.cpp @@ -298,7 +298,9 @@ void MainWindow::updateState() bool errorOccurred = false; for(auto& monitor: m_monitors) { - monitor.brightness = monitor.manualOverride ? monitor.brightness : brightness; + if(!std::isnan(brightness) && !monitor.manualOverride) { + monitor.brightness = brightness; + } if(!monitor.driver.setBrightness(monitor.brightness)) { errorOccurred = true; } @@ -306,7 +308,7 @@ void MainWindow::updateState() return !errorOccurred; }; - auto brightness = 0.5f; + auto brightness = NAN; if(!getAverageSensorValue(brightness)) { enumSensors();