set brightness, catch exceptions

old-commit-hash: 0d02e85873
commatwo_master
Willem Melching 4 years ago
parent 9faffa817b
commit f0da92ba5c
  1. 7
      selfdrive/hardware/tici/hardware.py
  2. 16
      selfdrive/ui/qt/home.cc

@ -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)) 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): def set_screen_brightness(self, percentage):
with open("/sys/class/backlight/panel0-backlight/brightness", "w") as f: try:
f.write(str(percentage * 10.23)) with open("/sys/class/backlight/panel0-backlight/brightness", "w") as f:
f.write(str(percentage * 10.23))
except Exception:
pass

@ -2,6 +2,8 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <thread> #include <thread>
#include <exception>
#include <QDateTime> #include <QDateTime>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -164,7 +166,7 @@ void HomeWindow::mousePressEvent(QMouseEvent* e) {
Params().write_db_value("IsDriverViewEnabled", "0", 1); Params().write_db_value("IsDriverViewEnabled", "0", 1);
return; return;
} }
glWindow->wake(); glWindow->wake();
// Settings button click // Settings button click
@ -191,10 +193,14 @@ static void handle_display_state(UIState* s, bool user_input) {
} }
static void set_backlight(int brightness) { static void set_backlight(int brightness) {
std::ofstream brightness_control("/sys/class/backlight/panel0-backlight/brightness"); try {
if (brightness_control.is_open()) { std::ofstream brightness_control("/sys/class/backlight/panel0-backlight/brightness");
brightness_control << brightness << "\n"; if (brightness_control.is_open()) {
brightness_control.close(); brightness_control << brightness << "\n";
brightness_control.close();
}
} catch (std::exception& e) {
qDebug() << "Error setting brightness";
} }
} }

Loading…
Cancel
Save