New formatter, who dis

This commit is contained in:
aderusha 2022-05-02 11:08:19 -04:00
parent ad4a0bf57a
commit 69efb4709b
7 changed files with 50 additions and 43 deletions

View File

@ -658,7 +658,7 @@ void mqttProcessInput(String &strTopic, String &strPayload)
debugSerialEnabled = true; debugSerialEnabled = true;
configSave(); configSave();
} }
else if(strPayload.equalsIgnoreCase("false")) else if (strPayload.equalsIgnoreCase("false"))
{ {
debugSerialEnabled = false; debugSerialEnabled = false;
configSave(); configSave();
@ -671,7 +671,7 @@ void mqttProcessInput(String &strTopic, String &strPayload)
debugTelnetEnabled = true; debugTelnetEnabled = true;
configSave(); configSave();
} }
else if(strPayload.equalsIgnoreCase("false")) else if (strPayload.equalsIgnoreCase("false"))
{ {
debugTelnetEnabled = false; debugTelnetEnabled = false;
configSave(); configSave();
@ -684,7 +684,7 @@ void mqttProcessInput(String &strTopic, String &strPayload)
mdnsEnabled = true; mdnsEnabled = true;
configSave(); configSave();
} }
else if(strPayload.equalsIgnoreCase("false")) else if (strPayload.equalsIgnoreCase("false"))
{ {
mdnsEnabled = false; mdnsEnabled = false;
configSave(); configSave();
@ -697,7 +697,7 @@ void mqttProcessInput(String &strTopic, String &strPayload)
beepEnabled = true; beepEnabled = true;
configSave(); configSave();
} }
else if(strPayload.equalsIgnoreCase("false")) else if (strPayload.equalsIgnoreCase("false"))
{ {
beepEnabled = false; beepEnabled = false;
configSave(); configSave();
@ -710,7 +710,7 @@ void mqttProcessInput(String &strTopic, String &strPayload)
ignoreTouchWhenOff = true; ignoreTouchWhenOff = true;
configSave(); configSave();
} }
else if(strPayload.equalsIgnoreCase("false")) else if (strPayload.equalsIgnoreCase("false"))
{ {
ignoreTouchWhenOff = false; ignoreTouchWhenOff = false;
configSave(); configSave();
@ -1624,8 +1624,6 @@ void nextionParseJson(const String &strPayload)
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void nextionOtaStartDownload(const String &lcdOtaUrl) void nextionOtaStartDownload(const String &lcdOtaUrl)
{ // Upload firmware to the Nextion LCD via HTTP download { // Upload firmware to the Nextion LCD via HTTP download
// based in large part on code posted by indev2 here:
// http://support.iteadstudio.com/support/discussions/topics/11000007686/page/2
uint32_t lcdOtaFileSize = 0; uint32_t lcdOtaFileSize = 0;
String lcdOtaNextionCmd; String lcdOtaNextionCmd;
@ -1967,11 +1965,13 @@ void espWifiConnect()
nextionSendCmd("page 0"); nextionSendCmd("page 0");
} }
WiFi.mode(WIFI_STA); // Set the radio to Station WiFi.persistent(false);
enableWiFiAtBootTime();
WiFi.macAddress(espMac); // Read our MAC address and save it to espMac WiFi.macAddress(espMac); // Read our MAC address and save it to espMac
WiFi.hostname(haspNode); // Assign our hostname before connecting to WiFi WiFi.hostname(haspNode); // Assign our hostname before connecting to WiFi
WiFi.setAutoReconnect(true); // Tell WiFi to autoreconnect if connection has dropped WiFi.setAutoReconnect(true); // Tell WiFi to autoreconnect if connection has dropped
WiFi.setSleepMode(WIFI_NONE_SLEEP); // Disable WiFi sleep modes to prevent occasional disconnects WiFi.setSleepMode(WIFI_NONE_SLEEP); // Disable WiFi sleep modes to prevent occasional disconnects
WiFi.mode(WIFI_STA); // Set the radio to Station
if (String(wifiSSID) == "") if (String(wifiSSID) == "")
{ // If the sketch has no hard-coded wifiSSID, attempt to use saved creds or use WiFiManager to collect required information from the user. { // If the sketch has no hard-coded wifiSSID, attempt to use saved creds or use WiFiManager to collect required information from the user.
@ -1981,7 +1981,9 @@ void espWifiConnect()
{ {
nextionSetAttr("p[0].b[1].txt", "\"WiFi Connecting...\\r " + String(WiFi.SSID()) + "\""); nextionSetAttr("p[0].b[1].txt", "\"WiFi Connecting...\\r " + String(WiFi.SSID()) + "\"");
unsigned long connectTimer = millis() + 10000; unsigned long connectTimer = millis() + 10000;
debugPrintln(String(F("WIFI: Connecting to previously-saved SSID: ")) + String(WiFi.SSID())); debugPrintln(String(F("WIFI: Connecting to previously-saved SSID: ")) + String(WiFi.SSID()));
WiFi.begin(); WiFi.begin();
while ((WiFi.status() != WL_CONNECTED) && (millis() < connectTimer)) while ((WiFi.status() != WL_CONNECTED) && (millis() < connectTimer))
{ {
@ -2004,13 +2006,19 @@ void espWifiConnect()
{ {
yield(); yield();
} }
if (WiFi.localIP().toString() == "(IP unset)")
{ // Check if we have our IP yet
debugPrintln(F("WIFI: Failed to lease address from DHCP, disconnecting and trying again"));
WiFi.disconnect();
}
} }
} }
if (WiFi.status() != WL_CONNECTED) if (WiFi.status() != WL_CONNECTED)
{ // We gave it a shot, still couldn't connect, so let WiFiManager run to make one last { // We gave it a shot, still couldn't connect, so let WiFiManager run to make one last
// connection attempt and then flip to AP mode to collect credentials from the user. // connection attempt and then flip to AP mode to collect credentials from the user.
WiFi.persistent(true);
WiFiManagerParameter custom_haspNodeHeader("<br/><b>HASPone Node</b>"); WiFiManagerParameter custom_haspNodeHeader("<br/><b>HASPone Node</b>");
WiFiManagerParameter custom_haspNode("haspNode", "<br/>Node Name <small>(required: lowercase letters, numbers, and _ only)</small>", haspNode, 15, " maxlength=15 required pattern='[a-z0-9_]*'"); WiFiManagerParameter custom_haspNode("haspNode", "<br/>Node Name <small>(required: lowercase letters, numbers, and _ only)</small>", haspNode, 15, " maxlength=15 required pattern='[a-z0-9_]*'");
WiFiManagerParameter custom_groupName("groupName", "Group Name <small>(required)</small>", groupName, 15, " maxlength=15 required"); WiFiManagerParameter custom_groupName("groupName", "Group Name <small>(required)</small>", groupName, 15, " maxlength=15 required");
@ -2170,16 +2178,14 @@ void espSetupOta()
debugPrintln(F("ESP OTA: update start")); debugPrintln(F("ESP OTA: update start"));
nextionSetAttr("p[0].b[1].txt", "\"\\rHASPone update:\\r\\r\\r \""); nextionSetAttr("p[0].b[1].txt", "\"\\rHASPone update:\\r\\r\\r \"");
nextionSendCmd("page 0"); nextionSendCmd("page 0");
nextionSendCmd("vis 4,1"); nextionSendCmd("vis 4,1"); });
});
ArduinoOTA.onEnd([]() ArduinoOTA.onEnd([]()
{ {
debugPrintln(F("ESP OTA: update complete")); debugPrintln(F("ESP OTA: update complete"));
nextionSetAttr("p[0].b[1].txt", "\"\\rHASPone update:\\r\\r Complete!\\rRestarting.\""); nextionSetAttr("p[0].b[1].txt", "\"\\rHASPone update:\\r\\r Complete!\\rRestarting.\"");
nextionSendCmd("vis 4,1"); nextionSendCmd("vis 4,1");
delay(1000); delay(1000);
espReset(); espReset(); });
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) ArduinoOTA.onProgress([](unsigned int progress, unsigned int total)
{ nextionUpdateProgress(progress, total); }); { nextionUpdateProgress(progress, total); });
ArduinoOTA.onError([](ota_error_t error) ArduinoOTA.onError([](ota_error_t error)
@ -2198,8 +2204,7 @@ void espSetupOta()
nextionSendCmd("vis 4,0"); nextionSendCmd("vis 4,0");
nextionSetAttr("p[0].b[1].txt", "\"HASPone update:\\r FAILED\\rerror: " + String(error) + "\""); nextionSetAttr("p[0].b[1].txt", "\"HASPone update:\\r FAILED\\rerror: " + String(error) + "\"");
delay(1000); delay(1000);
nextionSendCmd("page " + String(nextionActivePage)); nextionSendCmd("page " + String(nextionActivePage)); });
});
ArduinoOTA.begin(); ArduinoOTA.begin();
debugPrintln(F("ESP OTA: Over the Air firmware update ready")); debugPrintln(F("ESP OTA: Over the Air firmware update ready"));
} }
@ -2579,7 +2584,7 @@ void webHandleNotFound()
void webHandleRoot() void webHandleRoot()
{ // http://plate01/ { // http://plate01/
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -2832,7 +2837,7 @@ void webHandleRoot()
void webHandleSaveConfig() void webHandleSaveConfig()
{ // http://plate01/saveConfig { // http://plate01/saveConfig
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3028,7 +3033,7 @@ void webHandleSaveConfig()
void webHandleResetConfig() void webHandleResetConfig()
{ // http://plate01/resetConfig { // http://plate01/resetConfig
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3070,7 +3075,7 @@ void webHandleResetConfig()
void webHandleResetBacklight() void webHandleResetBacklight()
{ // http://plate01/resetBacklight { // http://plate01/resetBacklight
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3101,7 +3106,7 @@ void webHandleResetBacklight()
void webHandleFirmware() void webHandleFirmware()
{ // http://plate01/firmware { // http://plate01/firmware
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3174,7 +3179,7 @@ void webHandleFirmware()
void webHandleEspFirmware() void webHandleEspFirmware()
{ // http://plate01/espfirmware { // http://plate01/espfirmware
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3209,7 +3214,7 @@ void webHandleLcdUpload()
// Upload firmware to the Nextion LCD via HTTP upload // Upload firmware to the Nextion LCD via HTTP upload
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3443,7 +3448,7 @@ void webHandleLcdUpload()
void webHandleLcdUpdateSuccess() void webHandleLcdUpdateSuccess()
{ // http://plate01/lcdOtaSuccess { // http://plate01/lcdOtaSuccess
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3471,7 +3476,7 @@ void webHandleLcdUpdateSuccess()
void webHandleLcdUpdateFailure() void webHandleLcdUpdateFailure()
{ // http://plate01/lcdOtaFailure { // http://plate01/lcdOtaFailure
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3499,7 +3504,7 @@ void webHandleLcdUpdateFailure()
void webHandleLcdDownload() void webHandleLcdDownload()
{ // http://plate01/lcddownload { // http://plate01/lcddownload
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3528,7 +3533,7 @@ void webHandleLcdDownload()
void webHandleTftFileSize() void webHandleTftFileSize()
{ // http://plate01/tftFileSize { // http://plate01/tftFileSize
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();
@ -3548,7 +3553,7 @@ void webHandleTftFileSize()
void webHandleReboot() void webHandleReboot()
{ // http://plate01/reboot { // http://plate01/reboot
if (configPassword[0] != '\0') if (configPassword[0] != '\0')
{ //Request HTTP auth if configPassword is set { // Request HTTP auth if configPassword is set
if (!webServer.authenticate(configUser, configPassword)) if (!webServer.authenticate(configUser, configPassword))
{ {
return webServer.requestAuthentication(); return webServer.requestAuthentication();

View File

@ -18,8 +18,8 @@ build_flags =
-D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191122 -D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191122
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
lib_deps = lib_deps =
bblanchon/ArduinoJson @ ^6.19.4
256dpi/MQTT @ ^2.5.0 256dpi/MQTT @ ^2.5.0
dancol90/ESP8266Ping @ ^1.0 dancol90/ESP8266Ping @ ^1.0
bblanchon/ArduinoJson @ ^6.19.4
krzychb/EspSaveCrash @ ^1.3.0 krzychb/EspSaveCrash @ ^1.3.0
https://github.com/tzapu/WiFiManager.git#91826229cb8e80c24d49ee32a243220c77f55c08 https://github.com/tzapu/WiFiManager.git#14cf6b81d44252a58823e8e766bfad613ad7a061 ; 2.0.9-beta, confirmed working

Binary file not shown.

View File

@ -10,7 +10,9 @@ Please [check the Nextion HMI documentation](../Documentation/02_Nextion_HMI.md)
* **[HASwitchPlate.hmi](HASwitchPlate.hmi)** This is the "source" file which you can modify in the [Nextion editor](https://nextion.itead.cc/resource/download/nextion-editor/). If you want to make your own Nextion HMI, I'd recommend starting with this file, keeping Page 0 (`p0`), then start your own design on pages 1+. * **[HASwitchPlate.hmi](HASwitchPlate.hmi)** This is the "source" file which you can modify in the [Nextion editor](https://nextion.itead.cc/resource/download/nextion-editor/). If you want to make your own Nextion HMI, I'd recommend starting with this file, keeping Page 0 (`p0`), then start your own design on pages 1+.
* **[HASwitchPlate.tft](HASwitchPlate.tft)** This is the compiled Nextion firmware for the HASPone usable on a Basic series Nextion 2.4" LCD, model `NX3224T024_011R` * **[HASwitchPlate.tft](HASwitchPlate.tft)** This is the compiled Nextion firmware for the HASPone usable on a Basic series Nextion 2.4" LCD, model `NX3224T024_011R`
* **[HASwitchPlate-Inverted.tft](HASwitchPlate-Inverted.tft)** Basic series firmware but inverted, usable if the viewing angle on your display works better when mounted upside-down.
* **[HASwitchPlate-Discovery.tft](HASwitchPlate-Discovery.tft)** This is the compiled Nextion firmware for the HASPone usable on a Discovery series Nextion 2.4" LCD, model `NX3224F024_011R`. This is a drop-in replacement for the Basic series, might be cheaper or more readily available than the Basic, and is fully supported by the HASPone project. * **[HASwitchPlate-Discovery.tft](HASwitchPlate-Discovery.tft)** This is the compiled Nextion firmware for the HASPone usable on a Discovery series Nextion 2.4" LCD, model `NX3224F024_011R`. This is a drop-in replacement for the Basic series, might be cheaper or more readily available than the Basic, and is fully supported by the HASPone project.
* **[HASwitchPlate-Discovery-Inverted.tft](HASwitchPlate-Discovery-Inverted.tft)** Discovery series firmware but inverted, usable if the viewing angle on your display works better when mounted upside-down.
* **[HASwitchPlate-Enhanced.tft](HASwitchPlate-Enhanced.tft)** This is the compiled Nextion firmware for the HASPone usable on an enhanced Nextion 2.4" LCD, model `NX4024K032_011R`. This panel will not fit in the provided 3D printed enclosure and no enhanced features are used in this project. **Don't buy this panel**, but if you did (*and you shouldn't*), you can use this firmware. * **[HASwitchPlate-Enhanced.tft](HASwitchPlate-Enhanced.tft)** This is the compiled Nextion firmware for the HASPone usable on an enhanced Nextion 2.4" LCD, model `NX4024K032_011R`. This panel will not fit in the provided 3D printed enclosure and no enhanced features are used in this project. **Don't buy this panel**, but if you did (*and you shouldn't*), you can use this firmware.
* **[HASwitchPlate-TJC.hmi](HASwitchPlate-TJC.hmi)** This is the "source" file for the Chinese-market TJC LCD model `TJC3224T024_011`. This file cannot be used with the english language editor. If you purchase this panel, you will need to use the Chinese-language "USART HMI" editor to modify this file. **Don't buy this panel**. * **[HASwitchPlate-TJC.hmi](HASwitchPlate-TJC.hmi)** This is the "source" file for the Chinese-market TJC LCD model `TJC3224T024_011`. This file cannot be used with the english language editor. If you purchase this panel, you will need to use the Chinese-language "USART HMI" editor to modify this file. **Don't buy this panel**.
* **[HASwitchPlate-TJC.tft](HASwitchPlate-TJC.tft)** This is the compiled Nextion firmware for the HASPone usable on a Chinese market TJC 2.4" LCD, model `TJC3224T024_011`. * **[HASwitchPlate-TJC.tft](HASwitchPlate-TJC.tft)** This is the compiled Nextion firmware for the HASPone usable on a Chinese market TJC 2.4" LCD, model `TJC3224T024_011`.

View File

@ -1,6 +1,6 @@
{ {
"d1_mini": { "d1_mini": {
"version": "1.05", "version": "1.06",
"firmware": "https://raw.githubusercontent.com/HASwitchPlate/HASPone/main/Arduino_Sketch/HASwitchPlate.ino.d1_mini.bin" "firmware": "https://raw.githubusercontent.com/HASwitchPlate/HASPone/main/Arduino_Sketch/HASwitchPlate.ino.d1_mini.bin"
}, },
"NX3224T024_011R": { "NX3224T024_011R": {