set brightness, catch exceptions

old-commit-hash: 0d02e85873
commatwo_master
Willem Melching 4 years ago
parent 9faffa817b
commit f0da92ba5c
  1. 3
      selfdrive/hardware/tici/hardware.py
  2. 6
      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))
def set_screen_brightness(self, percentage):
try:
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 <iostream>
#include <thread>
#include <exception>
#include <QDateTime>
#include <QHBoxLayout>
@ -191,11 +193,15 @@ static void handle_display_state(UIState* s, bool user_input) {
}
static void set_backlight(int brightness) {
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";
}
}
GLWindow::GLWindow(QWidget* parent) : QOpenGLWidget(parent) {

Loading…
Cancel
Save