diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 9cc7a113cb..c294c48dfe 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -94,6 +94,7 @@ std::unordered_map keys = { {"CompletedTrainingVersion", PERSISTENT}, {"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"CurrentRoute", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, + {"DisableLogging", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"DisablePowerDown", PERSISTENT}, {"DisableRadar_Allow", PERSISTENT}, {"DisableRadar", PERSISTENT}, // WARNING: THIS DISABLES AEB @@ -103,7 +104,6 @@ std::unordered_map keys = { {"DoReboot", CLEAR_ON_MANAGER_START}, {"DoShutdown", CLEAR_ON_MANAGER_START}, {"DoUninstall", CLEAR_ON_MANAGER_START}, - {"EnableLogging", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"EnableWideCamera", CLEAR_ON_MANAGER_START}, {"EndToEndToggle", PERSISTENT}, {"ForcePowerDown", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/manager/process_config.py b/selfdrive/manager/process_config.py index 34b120efaf..8fa0454011 100644 --- a/selfdrive/manager/process_config.py +++ b/selfdrive/manager/process_config.py @@ -14,7 +14,7 @@ def notcar(started: bool, params: Params, CP: car.CarParams) -> bool: return CP.notCar def logging(started, params, CP: car.CarParams) -> bool: - run = (not CP.notCar) or params.get_bool("EnableLogging") + run = (not CP.notCar) or not params.get_bool("DisableLogging") return started and run procs = [ diff --git a/selfdrive/ui/qt/body.cc b/selfdrive/ui/qt/body.cc index 01b91571a4..7ca064a6cf 100644 --- a/selfdrive/ui/qt/body.cc +++ b/selfdrive/ui/qt/body.cc @@ -7,11 +7,16 @@ #include #include "selfdrive/common/params.h" +#include "selfdrive/common/timing.h" RecordButton::RecordButton(QWidget *parent) : QPushButton(parent) { setCheckable(true); setChecked(false); setFixedSize(148, 148); + + QObject::connect(this, &QPushButton::toggled, [=]() { + setEnabled(false); + }); } void RecordButton::paintEvent(QPaintEvent *event) { @@ -20,8 +25,13 @@ void RecordButton::paintEvent(QPaintEvent *event) { QPoint center(width() / 2, height() / 2); - QColor bg(isChecked() ? "#FFFFFF" : "#404040"); + QColor bg(isChecked() ? "#FFFFFF" : "#737373"); QColor accent(isChecked() ? "#FF0000" : "#FFFFFF"); + if (!isEnabled()) { + bg = QColor("#404040"); + accent = QColor("#FFFFFF"); + } + if (isDown()) { accent.setAlphaF(0.7); } @@ -62,7 +72,9 @@ BodyWindow::BodyWindow(QWidget *parent) : fuel_filter(1.0, 5., 1. / UI_FREQ), QW btn = new RecordButton(this); vlayout->addWidget(btn, 0, Qt::AlignBottom | Qt::AlignRight); QObject::connect(btn, &QPushButton::clicked, [=](bool checked) { - Params().putBool("EnableLogging", checked); + btn->setEnabled(false); + Params().putBool("DisableLogging", !checked); + last_button = nanos_since_boot(); }); w->raise(); @@ -70,8 +82,6 @@ BodyWindow::BodyWindow(QWidget *parent) : fuel_filter(1.0, 5., 1. / UI_FREQ), QW } void BodyWindow::paintEvent(QPaintEvent *event) { - //QLabel::paintEvent(event); - QPainter p(this); p.setRenderHint(QPainter::Antialiasing); @@ -112,6 +122,11 @@ void BodyWindow::paintEvent(QPaintEvent *event) { } } +void BodyWindow::offroadTransition(bool offroad) { + btn->setChecked(true); + btn->setEnabled(true); + fuel_filter.reset(1.0); +} void BodyWindow::updateState(const UIState &s) { if (!isVisible()) { @@ -132,5 +147,15 @@ void BodyWindow::updateState(const UIState &s) { face->movie()->start(); } + // update record button state + if (sm.updated("managerState") && (sm.rcv_time("managerState") - last_button)*1e-9 > 0.5) { + for (auto proc : sm["managerState"].getManagerState().getProcesses()) { + if (proc.getName() == "loggerd") { + btn->setEnabled(true); + btn->setChecked(proc.getRunning()); + } + } + } + update(); } diff --git a/selfdrive/ui/qt/body.h b/selfdrive/ui/qt/body.h index b49192a2bf..6555487bf1 100644 --- a/selfdrive/ui/qt/body.h +++ b/selfdrive/ui/qt/body.h @@ -25,6 +25,7 @@ public: private: bool charging = false; + uint64_t last_button = 0; FirstOrderFilter fuel_filter; QLabel *face; QMovie *awake, *sleep; @@ -33,4 +34,5 @@ private: private slots: void updateState(const UIState &s); + void offroadTransition(bool onroad); }; diff --git a/selfdrive/ui/qt/home.cc b/selfdrive/ui/qt/home.cc index 0b64900770..fbd458cc02 100644 --- a/selfdrive/ui/qt/home.cc +++ b/selfdrive/ui/qt/home.cc @@ -32,7 +32,6 @@ HomeWindow::HomeWindow(QWidget* parent) : QWidget(parent) { body = new BodyWindow(this); slayout->addWidget(body); - body->setEnabled(false); driver_view = new DriverViewWindow(this); connect(driver_view, &DriverViewWindow::done, [=] { @@ -59,6 +58,7 @@ void HomeWindow::updateState(const UIState &s) { } void HomeWindow::offroadTransition(bool offroad) { + body->setEnabled(false); sidebar->setVisible(offroad); if (offroad) { slayout->setCurrentWidget(home); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 0debb5ba04..ab99b8fc24 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -233,7 +233,7 @@ UIState::UIState(QObject *parent) : QObject(parent) { sm = std::make_unique>({ "modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", "roadCameraState", "pandaStates", "carParams", "driverMonitoringState", "sensorEvents", "carState", "liveLocationKalman", - "wideRoadCameraState", + "wideRoadCameraState", "managerState", }); Params params;