mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-05 21:42:05 +08:00
43 lines
1.5 KiB
C++
43 lines
1.5 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();
|
|
frogpilot_scene.online = deviceState.getNetworkType() != cereal::DeviceState::NetworkType::NONE;
|
|
}
|
|
if (fpsm.updated("frogpilotCarState")) {
|
|
const cereal::FrogPilotCarState::Reader &frogpilotCarState = fpsm["frogpilotCarState"].getFrogpilotCarState();
|
|
}
|
|
if (fpsm.updated("frogpilotPlan")) {
|
|
const cereal::FrogPilotPlan::Reader &frogpilotPlan = fpsm["frogpilotPlan"].getFrogpilotPlan();
|
|
}
|
|
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", "frogpilotCarState", "frogpilotDeviceState",
|
|
"frogpilotPlan", "frogpilotRadarState", "frogpilotSelfdriveState", "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);
|
|
}
|