mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-22 17:43:52 +08:00
UI: run set_brightness in QtConcurrent (#23326)
* use QFuture * update at 10 hz * don't change frequency
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
#include <QtConcurrent>
|
||||
|
||||
#include "common/transformations/orientation.hpp"
|
||||
#include "selfdrive/common/params.h"
|
||||
#include "selfdrive/common/swaglog.h"
|
||||
@@ -290,9 +292,11 @@ void Device::updateBrightness(const UIState &s) {
|
||||
}
|
||||
|
||||
if (brightness != last_brightness) {
|
||||
std::thread{Hardware::set_brightness, brightness}.detach();
|
||||
if (!brightness_future.isRunning()) {
|
||||
brightness_future = QtConcurrent::run(Hardware::set_brightness, brightness);
|
||||
last_brightness = brightness;
|
||||
}
|
||||
}
|
||||
last_brightness = brightness;
|
||||
}
|
||||
|
||||
bool Device::motionTriggered(const UIState &s) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QColor>
|
||||
#include <QFuture>
|
||||
#include <QTransform>
|
||||
|
||||
#include "cereal/messaging/messaging.h"
|
||||
@@ -162,6 +163,7 @@ private:
|
||||
bool ignition_on = false;
|
||||
int last_brightness = 0;
|
||||
FirstOrderFilter brightness_filter;
|
||||
QFuture<void> brightness_future;
|
||||
|
||||
void updateBrightness(const UIState &s);
|
||||
void updateWakefulness(const UIState &s);
|
||||
|
||||
Reference in New Issue
Block a user