fix led bar button test not work on power up

This commit is contained in:
Phat Nguyen
2024-05-01 21:02:57 +07:00
parent d40b1d37a8
commit 221730160b
4 changed files with 26 additions and 13 deletions

View File

@ -162,7 +162,7 @@ void setup() {
bool connectToWifi = false; bool connectToWifi = false;
if (ag->isOne()) { if (ag->isOne()) {
if (ledBarButtonTest) { if (ledBarButtonTest) {
stateMachine.executeLedBarTest(); stateMachine.executeLedBarPowerUpTest();
} else { } else {
ledBarEnabledUpdate(); ledBarEnabledUpdate();
connectToWifi = true; connectToWifi = true;

View File

@ -302,20 +302,24 @@ void StateMachine::co2Calibration(void) {
void StateMachine::ledBarTest(void) { void StateMachine::ledBarTest(void) {
if (config.isLedBarTestRequested()) { if (config.isLedBarTestRequested()) {
if (config.getCountry() == "TH") { ledBarPowerUpTest();
uint32_t tstart = millis(); }
logInfo("Start run LED test for 2 min"); }
while (1) {
ledBarRunTest(); void StateMachine::ledBarPowerUpTest(void) {
uint32_t ms = (uint32_t)(millis() - tstart); if (config.getCountry() == "TH") {
if (ms >= (60 * 1000 * 2)) { uint32_t tstart = millis();
logInfo("LED test after 2 min finish"); logInfo("Start run LED test for 2 min");
break; while (1) {
}
}
} else {
ledBarRunTest(); ledBarRunTest();
uint32_t ms = (uint32_t)(millis() - tstart);
if (ms >= (60 * 1000 * 2)) {
logInfo("LED test after 2 min finish");
break;
}
} }
} else {
ledBarRunTest();
} }
} }
@ -706,6 +710,8 @@ void StateMachine::handleLeds(AgStateMachineState state) {
case AgStateMachineLedBarTest: case AgStateMachineLedBarTest:
ledBarTest(); ledBarTest();
break; break;
case AgStateMachineLedBarPowerUpTest:
ledBarPowerUpTest();
default: default:
break; break;
} }
@ -759,3 +765,7 @@ void StateMachine::executeCo2Calibration(void) {
void StateMachine::executeLedBarTest(void) { void StateMachine::executeLedBarTest(void) {
handleLeds(AgStateMachineLedBarTest); handleLeds(AgStateMachineLedBarTest);
} }
void StateMachine::executeLedBarPowerUpTest(void) {
handleLeds(AgStateMachineLedBarPowerUpTest);
}

View File

@ -28,6 +28,7 @@ private:
void pm25handleLeds(void); void pm25handleLeds(void);
void co2Calibration(void); void co2Calibration(void);
void ledBarTest(void); void ledBarTest(void);
void ledBarPowerUpTest(void);
void ledBarRunTest(void); void ledBarRunTest(void);
void runLedTest(char color); void runLedTest(char color);
@ -49,6 +50,7 @@ public:
AgStateMachineState getLedState(void); AgStateMachineState getLedState(void);
void executeCo2Calibration(void); void executeCo2Calibration(void);
void executeLedBarTest(void); void executeLedBarTest(void);
void executeLedBarPowerUpTest(void);
}; };
#endif /** _AG_STATE_MACHINE_H_ */ #endif /** _AG_STATE_MACHINE_H_ */

View File

@ -59,6 +59,7 @@ enum AgStateMachineState {
/* LED bar testing */ /* LED bar testing */
AgStateMachineLedBarTest, AgStateMachineLedBarTest,
AgStateMachineLedBarPowerUpTest,
/** LED: Show working state. /** LED: Show working state.
* Display: Show dashboard */ * Display: Show dashboard */