handle ledBarTestRequested on OpenAir

This commit is contained in:
Phat Nguyen
2024-09-01 20:19:18 +07:00
parent 663836e277
commit d3534cda52
4 changed files with 56 additions and 26 deletions

View File

@ -939,6 +939,9 @@ static void configUpdateHandle() {
stateMachine.executeLedBarTest();
}
else if(ag->isOpenAir()) {
stateMachine.executeLedBarTest();
}
appDispHandler();
appLedHandler();

View File

@ -1,5 +1,6 @@
#include "AgStateMachine.h"
#define LED_TEST_BLINK_DELAY 50 /** ms */
#define LED_FAST_BLINK_DELAY 250 /** ms */
#define LED_SLOW_BLINK_DELAY 1000 /** ms */
#define LED_SHORT_BLINK_DELAY 500 /** ms */
@ -305,6 +306,7 @@ void StateMachine::co2Calibration(void) {
void StateMachine::ledBarTest(void) {
if (config.isLedBarTestRequested()) {
if (ag->isOne()) {
if (config.getCountry() == "TH") {
uint32_t tstart = millis();
logInfo("Start run LED test for 2 min");
@ -320,11 +322,16 @@ void StateMachine::ledBarTest(void) {
ledBarRunTest();
}
}
else if(ag->isOpenAir()) {
ledBarRunTest();
}
}
}
void StateMachine::ledBarPowerUpTest(void) { ledBarRunTest(); }
void StateMachine::ledBarRunTest(void) {
if (ag->isOne()) {
disp.setText("LED Test", "running", ".....");
runLedTest('r');
ag->ledBar.show();
@ -341,6 +348,14 @@ void StateMachine::ledBarRunTest(void) {
runLedTest('n');
ag->ledBar.show();
delay(1000);
} else if (ag->isOpenAir()) {
for (int i = 0; i < 100; i++) {
ag->statusLed.setOn();
delay(LED_TEST_BLINK_DELAY);
ag->statusLed.setOff();
delay(LED_TEST_BLINK_DELAY);
}
}
}
void StateMachine::runLedTest(char color) {

View File

@ -65,6 +65,10 @@ bool AirGradient::isOne(void) {
return boardType == BoardType::ONE_INDOOR;
}
bool AirGradient::isOpenAir(void) {
return boardType == BoardType::OPEN_AIR_OUTDOOR;
}
bool AirGradient::isPro4_2(void) {
return boardType == BoardType::DIY_PRO_INDOOR_V4_2;
}

View File

@ -135,6 +135,14 @@ public:
*/
bool isOne(void);
/**
* @brief Check that Airgradient object is OPEN_AIR
*
* @return true
* @return false
*/
bool isOpenAir(void);
/**
* @brief Check that Airgradient object is DIY_PRO 4.2 indoor
*