From 5144cb05384fe6787d4bf82d191306e36a5f277a Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 31 Aug 2024 17:24:50 -0700 Subject: [PATCH] ui: gc experiments old-commit-hash: 42f8875901de9d9ca64765e758e8564b79afeeb2 --- selfdrive/ui/SConscript | 3 -- selfdrive/ui/mui.cc | 50 -------------------------- selfdrive/ui/ui.py | 77 ----------------------------------------- 3 files changed, 130 deletions(-) delete mode 100644 selfdrive/ui/mui.cc delete mode 100755 selfdrive/ui/ui.py diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index 2ee8a9dbac..cfdaf87b7d 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -83,9 +83,6 @@ if GetOption('extras') and arch != "Darwin": # build updater UI qt_env.Program("qt/setup/updater", ["qt/setup/updater.cc", asset_obj], LIBS=qt_libs) - # build mui - qt_env.Program("mui", ["mui.cc"], LIBS=qt_libs) - # build installers senv = qt_env.Clone() senv['LINKFLAGS'].append('-Wl,-strip-debug') diff --git a/selfdrive/ui/mui.cc b/selfdrive/ui/mui.cc deleted file mode 100644 index 98029ee311..0000000000 --- a/selfdrive/ui/mui.cc +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include - -#include "cereal/messaging/messaging.h" -#include "selfdrive/ui/ui.h" -#include "selfdrive/ui/qt/qt_window.h" - -int main(int argc, char *argv[]) { - QApplication a(argc, argv); - QWidget w; - setMainWindow(&w); - - w.setStyleSheet("background-color: black;"); - - // our beautiful UI - QVBoxLayout *layout = new QVBoxLayout(&w); - QLabel *label = new QLabel("〇"); - layout->addWidget(label, 0, Qt::AlignCenter); - - QTimer timer; - QObject::connect(&timer, &QTimer::timeout, [=]() { - static SubMaster sm({"deviceState", "controlsState"}); - - bool onroad_prev = sm.allAliveAndValid({"deviceState"}) && - sm["deviceState"].getDeviceState().getStarted(); - sm.update(0); - - bool onroad = sm.allAliveAndValid({"deviceState"}) && - sm["deviceState"].getDeviceState().getStarted(); - - if (onroad) { - label->setText("〇"); - auto cs = sm["controlsState"].getControlsState(); - UIStatus status = cs.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED; - label->setStyleSheet(QString("color: %1; font-size: 250px;").arg(bg_colors[status].name())); - } else { - label->setText("offroad"); - label->setStyleSheet("color: grey; font-size: 40px;"); - } - - if ((onroad != onroad_prev) || sm.frame < 2) { - Hardware::set_brightness(50); - Hardware::set_display_power(onroad); - } - }); - timer.start(50); - - return a.exec(); -} diff --git a/selfdrive/ui/ui.py b/selfdrive/ui/ui.py deleted file mode 100755 index 660495b1de..0000000000 --- a/selfdrive/ui/ui.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python3 -import os -import signal - -signal.signal(signal.SIGINT, signal.SIG_DFL) - -import cereal.messaging as messaging -from openpilot.system.hardware import HARDWARE - -from PyQt5.QtCore import Qt, QTimer -from PyQt5.QtWidgets import QLabel, QWidget, QVBoxLayout, QStackedLayout, QApplication -from openpilot.selfdrive.ui.qt.python_helpers import set_main_window - - -if __name__ == "__main__": - app = QApplication([]) - win = QWidget() - set_main_window(win) - - bg = QLabel("", alignment=Qt.AlignCenter) - - alert1 = QLabel() - alert2 = QLabel() - vlayout = QVBoxLayout() - vlayout.addWidget(alert1, alignment=Qt.AlignCenter) - vlayout.addWidget(alert2, alignment=Qt.AlignCenter) - - tmp = QWidget() - tmp.setLayout(vlayout) - - stack = QStackedLayout(win) - stack.addWidget(tmp) - stack.addWidget(bg) - stack.setStackingMode(QStackedLayout.StackAll) - - win.setObjectName("win") - win.setStyleSheet(""" - #win { - background-color: black; - } - QLabel { - color: white; - font-size: 40px; - } - """) - - sm = messaging.SubMaster(['deviceState', 'controlsState']) - - def update(): - sm.update(0) - - onroad = sm.all_checks(['deviceState']) and sm['deviceState'].started - if onroad: - cs = sm['controlsState'] - color = ("grey" if str(cs.state) in ("overriding", "preEnabled") else "green") if cs.enabled else "blue" - bg.setText("\U0001F44D" if cs.engageable else "\U0001F6D1") - bg.setStyleSheet(f"font-size: 100px; background-color: {color};") - bg.show() - - alert1.setText(cs.alertText1) - alert2.setText(cs.alertText2) - - if not sm.alive['controlsState']: - alert1.setText("waiting for controls...") - else: - bg.hide() - alert1.setText("") - alert2.setText("offroad") - - HARDWARE.set_screen_brightness(100 if onroad else 40) - os.system("echo 0 > /sys/class/backlight/panel0-backlight/bl_power") - - timer = QTimer() - timer.timeout.connect(update) - timer.start(50) - - app.exec_()