Files
Nayan fa4c3a80b6 device: customizable wake-up behavior (start offroad) (#861)
* allow always offroad at boot

* update description

* move buttons down again

* device boot mode

* update description

* offroad on sleep

* update name & description

* cleanup

* update signal name

* Update selfdrive/ui/sunnypilot/qt/offroad/settings/device_panel.cc

---------

Co-authored-by: DevTekVE <devtekve@gmail.com>
Co-authored-by: Kumar <36933347+rav4kumar@users.noreply.github.com>
Co-authored-by: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com>
2025-06-07 14:41:39 +02:00

73 lines
2.1 KiB
C++

/**
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
*
* This file is part of sunnypilot and is licensed under the MIT License.
* See the LICENSE.md file in the root directory for more details.
*/
#include "selfdrive/ui/sunnypilot/ui.h"
#include "common/watchdog.h"
void UIStateSP::updateStatus() {
UIState::updateStatus();
}
UIStateSP::UIStateSP(QObject *parent) : UIState(parent) {
sm = std::make_unique<SubMaster>(std::vector<const char*>{
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState",
"pandaStates", "carParams", "driverMonitoringState", "carState", "driverStateV2",
"wideRoadCameraState", "managerState", "selfdriveState", "longitudinalPlan",
"modelManagerSP", "selfdriveStateSP", "longitudinalPlanSP", "backupManagerSP"
});
// update timer
timer = new QTimer(this);
QObject::connect(timer, &QTimer::timeout, this, &UIStateSP::update);
timer->start(1000 / UI_FREQ);
}
// This method overrides completely the update method from the parent class intentionally.
void UIStateSP::update() {
update_sockets(this);
update_state(this);
updateStatus();
if (sm->frame % UI_FREQ == 0) {
watchdog_kick(nanos_since_boot());
}
emit uiUpdate(*this);
}
DeviceSP::DeviceSP(QObject *parent) : Device(parent) {
QObject::connect(uiStateSP(), &UIStateSP::uiUpdate, this, &DeviceSP::update);
QObject::connect(this, &Device::displayPowerChanged, this, &DeviceSP::handleDisplayPowerChanged);
}
UIStateSP *uiStateSP() {
static UIStateSP ui_state;
return &ui_state;
}
void UIStateSP::setSunnylinkRoles(const std::vector<RoleModel>& roles) {
sunnylinkRoles = roles;
emit sunnylinkRolesChanged(roles);
}
void UIStateSP::setSunnylinkDeviceUsers(const std::vector<UserModel>& users) {
sunnylinkUsers = users;
emit sunnylinkDeviceUsersChanged(users);
}
DeviceSP *deviceSP() {
static DeviceSP _device;
return &_device;
}
void DeviceSP::handleDisplayPowerChanged(bool on) {
// if enabled, trigger offroad mode when device goes to sleep
if (params.get("DeviceBootMode") == "1" && not on) {
params.putBool("OffroadMode", true);
}
}