mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-03 22:53:44 +08:00
36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
#include "frogpilot/ui/frogpilot_ui.h"
|
|
|
|
static void update_state(FrogPilotUIState *fs) {
|
|
FrogPilotUIScene &frogpilot_scene = fs->frogpilot_scene;
|
|
|
|
SubMaster &fpsm = *(fs->sm);
|
|
fpsm.update(0);
|
|
|
|
if (fpsm.updated("deviceState")) {
|
|
const cereal::DeviceState::Reader &deviceState = fpsm["deviceState"].getDeviceState();
|
|
}
|
|
if (fpsm.updated("selfdriveState")) {
|
|
const cereal::SelfdriveState::Reader &selfdriveState = fpsm["selfdriveState"].getSelfdriveState();
|
|
frogpilot_scene.enabled = selfdriveState.getEnabled();
|
|
}
|
|
}
|
|
|
|
FrogPilotUIState::FrogPilotUIState(QObject *parent) : QObject(parent) {
|
|
sm = std::make_unique<SubMaster, const std::initializer_list<const char *>>({
|
|
"carControl", "deviceState",
|
|
"liveDelay",
|
|
"liveParameters", "liveTorqueParameters", "liveTracks", "selfdriveState"
|
|
});
|
|
|
|
wifi = new WifiManager(this);
|
|
}
|
|
|
|
FrogPilotUIState *frogpilotUIState() {
|
|
static FrogPilotUIState frogpilot_ui_state;
|
|
return &frogpilot_ui_state;
|
|
}
|
|
|
|
void FrogPilotUIState::update() {
|
|
update_state(this);
|
|
}
|