Files
clearpilot/selfdrive/ui/qt/home.cc
Brian Hanson 578277ab9c session logging, build-only mode, park splash, boot logo spinner
- Per-process stderr logging to /data/log2/{session}/ with time-safe
  directory naming (boot-xxx renamed once GPS/NTP sets clock)
- Aggregate session.log with major events (start/stop, transitions)
- 30-day log rotation cleanup on manager startup
- build_only.sh: compile without starting manager, non-blocking error
  display, kills stale processes
- build.py: copies updated spinner binary after successful build
- Onroad park mode: show splash screen when car is on but in park,
  switch to camera view when shifted to drive, honor screen on/off
- Spinner: full-screen boot logo background from /usr/comma/bg.jpg
  with white progress bar overlay
- Boot logo: auto-regenerate when boot_logo.png changes, 140% scale
- launch_openpilot.sh: cd to /data/openpilot for reliable execution
- launch_chffrplus.sh: kill stale text error displays on startup
- spinner shell wrapper: prefer freshly built _spinner over prebuilt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 23:19:07 +00:00

196 lines
5.4 KiB
C++
Executable File

#include "selfdrive/ui/qt/home.h"
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QStackedWidget>
#include <QVBoxLayout>
#include "selfdrive/ui/qt/util.h"
// HomeWindow: the container for the offroad and onroad UIs
HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) {
// CLEARPILOT Sidebar set to invisible in drive view.
params.putBool("Sidebar", false);
QHBoxLayout *main_layout = new QHBoxLayout(this);
main_layout->setMargin(0);
main_layout->setSpacing(0);
sidebar = new Sidebar(this);
main_layout->addWidget(sidebar);
QObject::connect(sidebar, &Sidebar::openSettings, this, &HomeWindow::openSettings);
QObject::connect(sidebar, &Sidebar::openOnroad, this, &HomeWindow::showOnroad);
slayout = new QStackedLayout();
main_layout->addLayout(slayout);
home = new OffroadHome(this);
QObject::connect(home, &OffroadHome::openSettings, this, &HomeWindow::openSettings);
slayout->addWidget(home);
onroad = new OnroadWindow(this);
slayout->addWidget(onroad);
// CLEARPILOT
ready = new ReadyWindow(this);
slayout->addWidget(ready);
driver_view = new DriverViewWindow(this);
connect(driver_view, &DriverViewWindow::done, [=] {
showDriverView(false);
});
slayout->addWidget(driver_view);
setAttribute(Qt::WA_NoSystemBackground);
QObject::connect(uiState(), &UIState::uiUpdate, this, &HomeWindow::updateState);
QObject::connect(uiState(), &UIState::offroadTransition, this, &HomeWindow::offroadTransition);
QObject::connect(uiState(), &UIState::offroadTransition, sidebar, &Sidebar::offroadTransition);
}
// Debug function to activate onroad UI
void HomeWindow::showOnroad() {
sidebar->setVisible(false);
slayout->setCurrentWidget(onroad);
// sidebar->setVisible(params.getBool("Sidebar"));
}
void HomeWindow::showSidebar(bool show) {
sidebar->setVisible(show);
}
void HomeWindow::updateState(const UIState &s) {
if (s.scene.started) {
showDriverView(s.scene.driver_camera_timer >= 10, true);
// CLEARPILOT: show splash screen when onroad but in park
bool parked = s.scene.parked;
if (parked && !was_parked_onroad) {
// just shifted into park — show splash
slayout->setCurrentWidget(ready);
} else if (!parked && was_parked_onroad) {
// just shifted out of park — show onroad camera
slayout->setCurrentWidget(onroad);
}
was_parked_onroad = parked;
// CLEARPILOT: honor display on/off while showing splash in park
if (parked && ready->isVisible()) {
int screenMode = paramsMemory.getInt("ScreenDisaplayMode");
if (screenMode == 1) {
Hardware::set_display_power(false);
} else {
Hardware::set_display_power(true);
}
}
}
}
void HomeWindow::offroadTransition(bool offroad) {
sidebar->setVisible(false);
if (offroad) {
was_parked_onroad = false;
slayout->setCurrentWidget(ready);
} else {
// CLEARPILOT: start onroad in splash — updateState will switch to
// camera view once the car shifts out of park
was_parked_onroad = true;
slayout->setCurrentWidget(ready);
}
}
void HomeWindow::showDriverView(bool show, bool started) {
if (show) {
emit closeSettings();
slayout->setCurrentWidget(driver_view);
sidebar->setVisible(show == false);
} else {
if (started) {
slayout->setCurrentWidget(onroad);
sidebar->setVisible(params.getBool("Sidebar"));
} else {
slayout->setCurrentWidget(home);
sidebar->setVisible(show == false);
}
}
}
void HomeWindow::mousePressEvent(QMouseEvent* e) {
// CLEARPILOT todo - tap on main goes straight to settings
// Unless we click a debug widget.
// CLEARPILOT - click ready shows home (no sidebar)
if (!onroad->isVisible() && ready->isVisible()) {
sidebar->setVisible(false);
slayout->setCurrentWidget(home);
}
// Todo: widgets
if (onroad->isVisible()) {
emit openSettings();
}
}
void HomeWindow::mouseDoubleClickEvent(QMouseEvent* e) {
HomeWindow::mousePressEvent(e);
// const SubMaster &sm = *(uiState()->sm);
}
// CLEARPILOT: OffroadHome — clean grid launcher
OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
QVBoxLayout* main_layout = new QVBoxLayout(this);
main_layout->setContentsMargins(80, 80, 80, 80);
main_layout->setSpacing(0);
// grid of launcher buttons
QGridLayout *grid = new QGridLayout();
grid->setSpacing(40);
// Dashcam viewer button
QPushButton *dashcam_btn = new QPushButton("Dashcam");
dashcam_btn->setFixedSize(400, 300);
dashcam_btn->setStyleSheet(R"(
QPushButton {
background-color: #333333;
color: white;
border-radius: 20px;
font-size: 48px;
font-weight: 600;
}
QPushButton:pressed {
background-color: #555555;
}
)");
grid->addWidget(dashcam_btn, 0, 0);
// Settings button
QPushButton *settings_btn = new QPushButton("Settings");
settings_btn->setFixedSize(400, 300);
settings_btn->setStyleSheet(R"(
QPushButton {
background-color: #333333;
color: white;
border-radius: 20px;
font-size: 48px;
font-weight: 600;
}
QPushButton:pressed {
background-color: #555555;
}
)");
QObject::connect(settings_btn, &QPushButton::clicked, [=]() { emit openSettings(); });
grid->addWidget(settings_btn, 0, 1);
main_layout->addStretch();
main_layout->addLayout(grid);
main_layout->addStretch();
setStyleSheet(R"(
OffroadHome {
background-color: black;
}
)");
}