File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 33#include < cassert>
44#include < cmath>
55
6+ #include < QtConcurrent>
7+
68#include " common/transformations/orientation.hpp"
79#include " selfdrive/common/params.h"
810#include " selfdrive/common/swaglog.h"
@@ -290,9 +292,11 @@ void Device::updateBrightness(const UIState &s) {
290292 }
291293
292294 if (brightness != last_brightness) {
293- std::thread{Hardware::set_brightness, brightness}.detach ();
295+ if (!brightness_future.isRunning ()) {
296+ brightness_future = QtConcurrent::run (Hardware::set_brightness, brightness);
297+ last_brightness = brightness;
298+ }
294299 }
295- last_brightness = brightness;
296300}
297301
298302bool Device::motionTriggered (const UIState &s) {
Original file line number Diff line number Diff line change 77#include < QObject>
88#include < QTimer>
99#include < QColor>
10+ #include < QFuture>
1011#include < QTransform>
1112
1213#include " cereal/messaging/messaging.h"
@@ -162,6 +163,7 @@ class Device : public QObject {
162163 bool ignition_on = false ;
163164 int last_brightness = 0 ;
164165 FirstOrderFilter brightness_filter;
166+ QFuture<void > brightness_future;
165167
166168 void updateBrightness (const UIState &s);
167169 void updateWakefulness (const UIState &s);
You can’t perform that action at this time.
0 commit comments