mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-03 04:22:09 +08:00
set brightness, catch exceptions
old-commit-hash: 0d02e858735aa39137074704b6c9356632935852
This commit is contained in:
@@ -185,5 +185,8 @@ class Tici(HardwareBase):
|
||||
return ThermalConfig(cpu=((1, 2, 3, 4, 5, 6, 7, 8), 1000), gpu=((48,49), 1000), mem=(15, 1000), bat=(None, 1), ambient=(65, 1000))
|
||||
|
||||
def set_screen_brightness(self, percentage):
|
||||
with open("/sys/class/backlight/panel0-backlight/brightness", "w") as f:
|
||||
f.write(str(percentage * 10.23))
|
||||
try:
|
||||
with open("/sys/class/backlight/panel0-backlight/brightness", "w") as f:
|
||||
f.write(str(percentage * 10.23))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
+11
-5
@@ -2,6 +2,8 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <exception>
|
||||
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QHBoxLayout>
|
||||
@@ -164,7 +166,7 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) {
|
||||
Params().write_db_value("IsDriverViewEnabled", "0", 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
glWindow->wake();
|
||||
|
||||
// Settings button click
|
||||
@@ -191,10 +193,14 @@ static void handle_display_state(UIState* s, bool user_input) {
|
||||
}
|
||||
|
||||
static void set_backlight(int brightness) {
|
||||
std::ofstream brightness_control("/sys/class/backlight/panel0-backlight/brightness");
|
||||
if (brightness_control.is_open()) {
|
||||
brightness_control << brightness << "\n";
|
||||
brightness_control.close();
|
||||
try {
|
||||
std::ofstream brightness_control("/sys/class/backlight/panel0-backlight/brightness");
|
||||
if (brightness_control.is_open()) {
|
||||
brightness_control << brightness << "\n";
|
||||
brightness_control.close();
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
qDebug() << "Error setting brightness";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user