mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-29 16:37:17 +02:00
Merge pull request #119 from airgradienthq/hotfix/fix-issue-before-release-new-version
Hotfix: Fix some issue before release new version
This commit is contained in:
@ -239,6 +239,9 @@ void setup() {
|
||||
if (ag->isOne()) {
|
||||
oledDisplay.setText("Warming Up", "Serial Number:", ag->deviceId().c_str());
|
||||
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
||||
|
||||
Serial.println("Display brightness: " + String(configuration.getDisplayBrightness()));
|
||||
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
||||
}
|
||||
|
||||
appLedHandler();
|
||||
@ -399,9 +402,8 @@ static void factoryConfigReset(void) {
|
||||
mqttTask = NULL;
|
||||
}
|
||||
|
||||
/** Disconnect WIFI */
|
||||
wifiConnector.disconnect();
|
||||
wifiConnector.reset();
|
||||
/** Reset WIFI */
|
||||
WiFi.disconnect(true, true);
|
||||
|
||||
/** Reset local config */
|
||||
configuration.reset();
|
||||
@ -437,14 +439,20 @@ static void factoryConfigReset(void) {
|
||||
static void wdgFeedUpdate(void) {
|
||||
ag->watchdog.reset();
|
||||
Serial.println();
|
||||
Serial.println("External watchdog feed");
|
||||
Serial.println("Offline mode or isPostToAirGradient = false: watchdog reset");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
static void ledBarEnabledUpdate(void) {
|
||||
if (ag->isOne()) {
|
||||
ag->ledBar.setBrighness(configuration.getLedBarBrightness());
|
||||
ag->ledBar.setEnable(configuration.getLedBarMode() != LedBarModeOff);
|
||||
int brightness = configuration.getLedBarBrightness();
|
||||
Serial.println("LED bar brightness: " + String(brightness));
|
||||
if ((brightness == 0) || (configuration.getLedBarMode() == LedBarModeOff)) {
|
||||
ag->ledBar.setEnable(false);
|
||||
} else {
|
||||
ag->ledBar.setBrighness(brightness);
|
||||
ag->ledBar.setEnable(configuration.getLedBarMode() != LedBarModeOff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,11 +583,6 @@ static void sendDataToAg() {
|
||||
stateMachine.handleLeds(AgStateMachineNormal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Must reset each 5min to avoid ESP32 reset
|
||||
*/
|
||||
static void resetWatchdog() { ag->watchdog.reset(); }
|
||||
|
||||
void dispSensorNotFound(String ss) {
|
||||
ss = ss + " not found";
|
||||
oledDisplay.setText("Sensor init", "Error:", ss.c_str());
|
||||
@ -871,14 +874,17 @@ static void appLedHandler(void) {
|
||||
static void appDispHandler(void) {
|
||||
if (ag->isOne()) {
|
||||
AgStateMachineState state = AgStateMachineNormal;
|
||||
if (wifiConnector.isConnected() == false) {
|
||||
state = AgStateMachineWiFiLost;
|
||||
} else if (apiClient.isFetchConfigureFailed()) {
|
||||
state = AgStateMachineSensorConfigFailed;
|
||||
} else if (apiClient.isPostToServerFailed()) {
|
||||
state = AgStateMachineServerLost;
|
||||
}
|
||||
|
||||
/** Only show display status on online mode. */
|
||||
if (configuration.isOfflineMode() == false) {
|
||||
if (wifiConnector.isConnected() == false) {
|
||||
state = AgStateMachineWiFiLost;
|
||||
} else if (apiClient.isFetchConfigureFailed()) {
|
||||
state = AgStateMachineSensorConfigFailed;
|
||||
} else if (apiClient.isPostToServerFailed()) {
|
||||
state = AgStateMachineServerLost;
|
||||
}
|
||||
}
|
||||
stateMachine.displayHandle(state);
|
||||
}
|
||||
}
|
||||
@ -1092,10 +1098,19 @@ static void updatePm(void) {
|
||||
}
|
||||
|
||||
static void sendDataToServer(void) {
|
||||
/** Ignore send data to server if postToAirGradient disabled */
|
||||
if (configuration.isPostDataToAirGradient() == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI(),
|
||||
ag, &configuration);
|
||||
if (apiClient.postToServer(syncData)) {
|
||||
resetWatchdog();
|
||||
ag->watchdog.reset();
|
||||
Serial.println();
|
||||
Serial.println(
|
||||
"Online mode and isPostToAirGradient = true: watchdog reset");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
measurements.bootCount++;
|
||||
|
@ -103,7 +103,12 @@ bool OledDisplay::begin(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setBrightness(config.getDisplayBrightness());
|
||||
/** Show low brightness on startup. then it's completely turn off on main
|
||||
* application */
|
||||
int brightness = config.getDisplayBrightness();
|
||||
if(brightness == 0) {
|
||||
setBrightness(1);
|
||||
}
|
||||
|
||||
isBegin = true;
|
||||
logInfo("begin");
|
||||
@ -148,6 +153,10 @@ void OledDisplay::setText(String &line1, String &line2, String &line3) {
|
||||
*/
|
||||
void OledDisplay::setText(const char *line1, const char *line2,
|
||||
const char *line3) {
|
||||
if (isDisplayOff) {
|
||||
return;
|
||||
}
|
||||
|
||||
DISP()->firstPage();
|
||||
do {
|
||||
DISP()->setFont(u8g2_font_t0_16_tf);
|
||||
@ -180,6 +189,10 @@ void OledDisplay::setText(String &line1, String &line2, String &line3,
|
||||
*/
|
||||
void OledDisplay::setText(const char *line1, const char *line2,
|
||||
const char *line3, const char *line4) {
|
||||
if (isDisplayOff) {
|
||||
return;
|
||||
}
|
||||
|
||||
DISP()->firstPage();
|
||||
do {
|
||||
DISP()->setFont(u8g2_font_t0_16_tf);
|
||||
@ -201,6 +214,10 @@ void OledDisplay::showDashboard(void) { showDashboard(NULL); }
|
||||
*
|
||||
*/
|
||||
void OledDisplay::showDashboard(const char *status) {
|
||||
if (isDisplayOff) {
|
||||
return;
|
||||
}
|
||||
|
||||
char strBuf[10];
|
||||
|
||||
DISP()->firstPage();
|
||||
@ -299,10 +316,25 @@ void OledDisplay::showDashboard(const char *status) {
|
||||
}
|
||||
|
||||
void OledDisplay::setBrightness(int percent) {
|
||||
DISP()->setContrast((127 * percent) / 100);
|
||||
if (percent == 0) {
|
||||
isDisplayOff = true;
|
||||
|
||||
// Clear display.
|
||||
DISP()->firstPage();
|
||||
do {
|
||||
} while (DISP()->nextPage());
|
||||
|
||||
} else {
|
||||
isDisplayOff = false;
|
||||
DISP()->setContrast((127 * percent) / 100);
|
||||
}
|
||||
}
|
||||
|
||||
void OledDisplay::showNewFirmwareVersion(String version) {
|
||||
if (isDisplayOff) {
|
||||
return;
|
||||
}
|
||||
|
||||
DISP()->firstPage();
|
||||
do {
|
||||
DISP()->setFont(u8g2_font_t0_16_tf);
|
||||
@ -313,6 +345,10 @@ void OledDisplay::showNewFirmwareVersion(String version) {
|
||||
}
|
||||
|
||||
void OledDisplay::showNewFirmwareUpdating(String percent) {
|
||||
if (isDisplayOff) {
|
||||
return;
|
||||
}
|
||||
|
||||
DISP()->firstPage();
|
||||
do {
|
||||
DISP()->setFont(u8g2_font_t0_16_tf);
|
||||
@ -322,6 +358,10 @@ void OledDisplay::showNewFirmwareUpdating(String percent) {
|
||||
}
|
||||
|
||||
void OledDisplay::showNewFirmwareSuccess(String count) {
|
||||
if (isDisplayOff) {
|
||||
return;
|
||||
}
|
||||
|
||||
DISP()->firstPage();
|
||||
do {
|
||||
DISP()->setFont(u8g2_font_t0_16_tf);
|
||||
@ -332,6 +372,10 @@ void OledDisplay::showNewFirmwareSuccess(String count) {
|
||||
}
|
||||
|
||||
void OledDisplay::showNewFirmwareFailed(void) {
|
||||
if (isDisplayOff) {
|
||||
return;
|
||||
}
|
||||
|
||||
DISP()->firstPage();
|
||||
do {
|
||||
DISP()->setFont(u8g2_font_t0_16_tf);
|
||||
|
@ -14,6 +14,7 @@ private:
|
||||
bool isBegin = false;
|
||||
void *u8g2 = NULL;
|
||||
Measurements &value;
|
||||
bool isDisplayOff = false;
|
||||
|
||||
void showTempHum(bool hasStatus);
|
||||
void setCentralText(int y, String text);
|
||||
|
Reference in New Issue
Block a user