From 9330070bb5b4afd424841cd97c3c9bf5cb8d33fb Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Thu, 17 Sep 2020 15:50:09 +0200 Subject: [PATCH] tici: offroad ui powersave (#2191) * ui powersaving * Lower brightness even more --- selfdrive/ui/qt/window.cc | 16 ++++++++++++++++ selfdrive/ui/qt/window.hpp | 1 + 2 files changed, 17 insertions(+) diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 462380dd42..408f5f6709 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -95,6 +96,21 @@ void GLWindow::initializeGL() { void GLWindow::timerUpdate(){ ui_update(ui_state); + +#ifdef QCOM2 + if (ui_state->started != onroad){ + onroad = ui_state->started; + timer->setInterval(onroad ? 50 : 1000); + + int brightness = onroad ? 1023 : 0; + std::ofstream brightness_control("/sys/class/backlight/panel0-backlight/brightness"); + if (brightness_control.is_open()){ + brightness_control << int(brightness) << "\n"; + brightness_control.close(); + } + } +#endif + update(); if (label != NULL){ diff --git a/selfdrive/ui/qt/window.hpp b/selfdrive/ui/qt/window.hpp index d73acfe04f..fce9d70cf4 100644 --- a/selfdrive/ui/qt/window.hpp +++ b/selfdrive/ui/qt/window.hpp @@ -55,6 +55,7 @@ private: UIState * ui_state; QtSound sound; QLabel * label = NULL; + bool onroad = true; public slots: void timerUpdate();