mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-03 03:16:30 +02:00
Merge branch 'develop' into hotfix/correct-ota-update-message-on-display
This commit is contained in:
@ -224,7 +224,7 @@ static void failedHandler(String msg) {
|
||||
static void executeCo2Calibration(void) {
|
||||
/** Count down for co2CalibCountdown secs */
|
||||
for (int i = 0; i < SENSOR_CO2_CALIB_COUNTDOWN_MAX; i++) {
|
||||
displayShowText("CO2 calib", "after",
|
||||
displayShowText("CO2 calib.", "after",
|
||||
String(SENSOR_CO2_CALIB_COUNTDOWN_MAX - i) + " sec");
|
||||
delay(1000);
|
||||
}
|
||||
@ -232,16 +232,16 @@ static void executeCo2Calibration(void) {
|
||||
if (ag.s8.setBaselineCalibration()) {
|
||||
displayShowText("Calib", "success", "");
|
||||
delay(1000);
|
||||
displayShowText("Wait for", "finish", "...");
|
||||
displayShowText("Wait to", "complete", "...");
|
||||
int count = 0;
|
||||
while (ag.s8.isBaseLineCalibrationDone() == false) {
|
||||
delay(1000);
|
||||
count++;
|
||||
}
|
||||
displayShowText("Finish", "after", String(count) + " sec");
|
||||
displayShowText("Finished", "after", String(count) + " sec");
|
||||
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
||||
} else {
|
||||
displayShowText("Calib", "failure!!!", "");
|
||||
displayShowText("Calibration", "failure", "");
|
||||
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
||||
}
|
||||
}
|
||||
|
@ -152,8 +152,6 @@ void setup() {
|
||||
}
|
||||
Serial.println("Detected " + ag->getBoardName());
|
||||
|
||||
/** Init sensor */
|
||||
boardInit();
|
||||
configuration.setAirGradient(ag);
|
||||
oledDisplay.setAirGradient(ag);
|
||||
stateMachine.setAirGradient(ag);
|
||||
@ -162,11 +160,13 @@ void setup() {
|
||||
openMetrics.setAirGradient(ag);
|
||||
localServer.setAirGraident(ag);
|
||||
|
||||
/** Init sensor */
|
||||
boardInit();
|
||||
|
||||
/** Connecting wifi */
|
||||
bool connectToWifi = false;
|
||||
if (ag->isOne()) {
|
||||
if (ledBarButtonTest) {
|
||||
stateMachine.executeLedBarPowerUpTest();
|
||||
if (ag->button.getState() == PushButton::BUTTON_PRESSED) {
|
||||
WiFi.begin("airgradient", "cleanair");
|
||||
Serial.println("WiFi Credential reset to factory defaults");
|
||||
@ -241,6 +241,9 @@ void setup() {
|
||||
} else {
|
||||
ledBarEnabledUpdate();
|
||||
}
|
||||
} else {
|
||||
oledDisplay.showRebooting();
|
||||
delay(2500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -465,9 +468,10 @@ static void ledBarEnabledUpdate(void) {
|
||||
if ((brightness == 0) || (configuration.getLedBarMode() == LedBarModeOff)) {
|
||||
ag->ledBar.setEnable(false);
|
||||
} else {
|
||||
ag->ledBar.setBrighness(brightness);
|
||||
ag->ledBar.setBrightness(brightness);
|
||||
ag->ledBar.setEnable(configuration.getLedBarMode() != LedBarModeOff);
|
||||
}
|
||||
ag->ledBar.show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,6 +647,23 @@ static void oneIndoorInit(void) {
|
||||
ag->button.begin();
|
||||
ag->watchdog.begin();
|
||||
|
||||
/** Run LED test on start up if button pressed */
|
||||
oledDisplay.setText("Press now for", "LED test", "");
|
||||
ledBarButtonTest = false;
|
||||
uint32_t stime = millis();
|
||||
while (true) {
|
||||
if (ag->button.getState() == ag->button.BUTTON_PRESSED) {
|
||||
ledBarButtonTest = true;
|
||||
stateMachine.executeLedBarPowerUpTest();
|
||||
break;
|
||||
}
|
||||
delay(1);
|
||||
uint32_t ms = (uint32_t)(millis() - stime);
|
||||
if (ms >= 3000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Init sensor SGP41 */
|
||||
if (sgp41Init() == false) {
|
||||
dispSensorNotFound("SGP41");
|
||||
@ -669,22 +690,6 @@ static void oneIndoorInit(void) {
|
||||
|
||||
dispSensorNotFound("PMS");
|
||||
}
|
||||
|
||||
/** Run LED test on start up */
|
||||
oledDisplay.setText("Press now for", "LED test", "");
|
||||
ledBarButtonTest = false;
|
||||
uint32_t stime = millis();
|
||||
while (true) {
|
||||
if (ag->button.getState() == ag->button.BUTTON_PRESSED) {
|
||||
ledBarButtonTest = true;
|
||||
break;
|
||||
}
|
||||
delay(1);
|
||||
uint32_t ms = (uint32_t)(millis() - stime);
|
||||
if (ms >= 3000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
static void openAirInit(void) {
|
||||
configuration.hasSensorSHT = false;
|
||||
@ -832,10 +837,6 @@ static void configUpdateHandle() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ag->isOne()) {
|
||||
ledBarEnabledUpdate();
|
||||
stateMachine.executeLedBarTest();
|
||||
}
|
||||
stateMachine.executeCo2Calibration();
|
||||
|
||||
String mqttUri = configuration.getMqttBrokerUri();
|
||||
@ -871,15 +872,36 @@ static void configUpdateHandle() {
|
||||
|
||||
if (ag->isOne()) {
|
||||
if (configuration.isLedBarBrightnessChanged()) {
|
||||
ag->ledBar.setBrighness(configuration.getLedBarBrightness());
|
||||
Serial.println("Set 'LedBarBrightness' brightness: " +
|
||||
String(configuration.getLedBarBrightness()));
|
||||
if (configuration.getLedBarBrightness() == 0) {
|
||||
ag->ledBar.setEnable(false);
|
||||
} else {
|
||||
if (configuration.getLedBarMode() != LedBarMode::LedBarModeOff) {
|
||||
ag->ledBar.setEnable(true);
|
||||
}
|
||||
ag->ledBar.setBrightness(configuration.getLedBarBrightness());
|
||||
}
|
||||
ag->ledBar.show();
|
||||
}
|
||||
|
||||
if (configuration.isLedBarModeChanged()) {
|
||||
if (configuration.getLedBarBrightness() == 0) {
|
||||
ag->ledBar.setEnable(false);
|
||||
} else {
|
||||
if(configuration.getLedBarMode() == LedBarMode::LedBarModeOff) {
|
||||
ag->ledBar.setEnable(false);
|
||||
} else {
|
||||
ag->ledBar.setEnable(true);
|
||||
ag->ledBar.setBrightness(configuration.getLedBarBrightness());
|
||||
}
|
||||
}
|
||||
ag->ledBar.show();
|
||||
}
|
||||
|
||||
if (configuration.isDisplayBrightnessChanged()) {
|
||||
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
||||
Serial.println("Set 'DisplayBrightness' brightness: " +
|
||||
String(configuration.getDisplayBrightness()));
|
||||
}
|
||||
|
||||
stateMachine.executeLedBarTest();
|
||||
}
|
||||
|
||||
fwNewVersion = configuration.newFirmwareVersion();
|
||||
|
@ -372,6 +372,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
||||
}
|
||||
}
|
||||
|
||||
_ledBarModeChanged = false;
|
||||
if (JSON.typeof_(root[jprop_ledBarMode]) == "string") {
|
||||
String mode = root[jprop_ledBarMode];
|
||||
if (mode == getLedBarModeName(LedBarMode::LedBarModeCO2) ||
|
||||
@ -380,6 +381,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
||||
String oldMode = jconfig[jprop_ledBarMode];
|
||||
if (mode != oldMode) {
|
||||
jconfig[jprop_ledBarMode] = mode;
|
||||
_ledBarModeChanged = true;
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
@ -559,6 +561,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
||||
}
|
||||
}
|
||||
|
||||
ledBarBrightnessChanged = false;
|
||||
if (JSON.typeof_(root[jprop_ledBarBrightness]) == "number") {
|
||||
int value = root[jprop_ledBarBrightness];
|
||||
int oldValue = jconfig[jprop_ledBarBrightness];
|
||||
@ -1147,6 +1150,12 @@ void Configuration::setOfflineModeWithoutSave(bool offline) {
|
||||
_offlineMode = offline;
|
||||
}
|
||||
|
||||
bool Configuration::isLedBarModeChanged(void) {
|
||||
bool changed = _ledBarModeChanged;
|
||||
_ledBarModeChanged = false;
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool Configuration::isDisplayBrightnessChanged(void) {
|
||||
bool changed = displayBrightnessChanged;
|
||||
displayBrightnessChanged = false;
|
||||
|
@ -18,6 +18,7 @@ private:
|
||||
bool displayBrightnessChanged = false;
|
||||
String otaNewFirmwareVersion;
|
||||
bool _offlineMode = false;
|
||||
bool _ledBarModeChanged = false;
|
||||
|
||||
AirGradient* ag;
|
||||
|
||||
@ -80,6 +81,7 @@ public:
|
||||
bool isOfflineMode(void);
|
||||
void setOfflineMode(bool offline);
|
||||
void setOfflineModeWithoutSave(bool offline);
|
||||
bool isLedBarModeChanged(void);
|
||||
};
|
||||
|
||||
#endif /** _AG_CONFIG_H_ */
|
||||
|
@ -410,3 +410,13 @@ void OledDisplay::showFirmwareUpdateUpToDate(void) {
|
||||
setCentralText(40, "up to date");
|
||||
} while (DISP()->nextPage());
|
||||
}
|
||||
|
||||
void OledDisplay::showRebooting(void) {
|
||||
DISP()->firstPage();
|
||||
do {
|
||||
DISP()->setFont(u8g2_font_t0_16_tf);
|
||||
// setCentralText(20, "Firmware Update");
|
||||
setCentralText(40, "Rebooting...");
|
||||
// setCentralText(60, String("Retry after 24h"));
|
||||
} while (DISP()->nextPage());
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
void showFirmwareUpdateFailed(void);
|
||||
void showFirmwareUpdateSkipped(void);
|
||||
void showFirmwareUpdateUpToDate(void);
|
||||
void showRebooting(void);
|
||||
};
|
||||
|
||||
#endif /** _AG_OLED_DISPLAY_H_ */
|
||||
|
@ -64,7 +64,7 @@ void LedBar::setColor(uint8_t red, uint8_t green, uint8_t blue, int ledNum) {
|
||||
*
|
||||
* @param brightness Brightness (0 - 100)%
|
||||
*/
|
||||
void LedBar::setBrighness(uint8_t brightness) {
|
||||
void LedBar::setBrightness(uint8_t brightness) {
|
||||
if (this->isBegin() == false) {
|
||||
return;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
void begin(void);
|
||||
void setColor(uint8_t red, uint8_t green, uint8_t blue, int ledNum);
|
||||
void setColor(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void setBrighness(uint8_t brightness);
|
||||
void setBrightness(uint8_t brightness);
|
||||
int getNumberOfLeds(void);
|
||||
void show(void);
|
||||
void clear(void);
|
||||
|
Reference in New Issue
Block a user