Remove dependency from StateMachine

This commit is contained in:
Phat Nguyen
2024-05-03 17:27:05 +07:00
parent d2723de0f8
commit 8eb8d4a1ec
4 changed files with 68 additions and 72 deletions

View File

@ -759,47 +759,3 @@ void StateMachine::executeCo2Calibration(void) {
void StateMachine::executeLedBarTest(void) {
handleLeds(AgStateMachineLedBarTest);
}
void StateMachine::executeOTA(StateMachine::OtaState state, String msg,
int processing) {
switch (state) {
case OtaState::OTA_STATE_BEGIN: {
if (ag->isOne()) {
disp.showNewFirmwareVersion(msg);
} else {
logInfo("New firmware: " + msg);
}
delay(2500);
break;
}
case OtaState::OTA_STATE_FAIL: {
if (ag->isOne()) {
disp.showNewFirmwareFailed();
} else {
logError("Firmware update: failed");
}
delay(2500);
break;
}
case OtaState::OTA_STATE_PROCESSING: {
if (ag->isOne()) {
disp.showNewFirmwareUpdating(String(processing));
} else {
logInfo("Firmware update: " + String(processing) + String("%"));
}
break;
}
case OtaState::OTA_STATE_SUCCESS: {
if (ag->isOne()) {
disp.showNewFirmwareSuccess(String(processing));
} else {
logInfo("Rebooting... " + String(processing));
}
break;
}
default:
break;
}
}

View File

@ -49,14 +49,6 @@ public:
AgStateMachineState getLedState(void);
void executeCo2Calibration(void);
void executeLedBarTest(void);
enum OtaState {
OTA_STATE_BEGIN,
OTA_STATE_FAIL,
OTA_STATE_PROCESSING,
OTA_STATE_SUCCESS
};
void executeOTA(OtaState state, String msg, int processing);
};
#endif /** _AG_STATE_MACHINE_H_ */