[WebUI] Final Changes Pre Release (#1613)

Description:
1 - Fix nextDisplayPage/nextWebUIPage sync with SSD1306
2 - Discovery message name is SS1306
3 - Stack size tuning - ARDUINO_LOOP_STACK_SIZE=9600

With this change, in your personal ESP32 platformio environments you need to change ${com-esp.build_flags} to ${com-esp32.build_flags} and ${com-esp.lib_deps} to ${com-esp32.lib_deps}
4 - On information page, fix module display
5 - Set OTA URL to String systemUrl = RELEASE_LINK + latestVersion + "/" + ENV_NAME + "-firmware.bin";
6 - Allow back level espressif32 framework support
This commit is contained in:
Northern Man authored and GitHub committed 2023-04-24 07:46:30 -05:00
1 parent 57651334dc
commit 8d5c2c4d58
7 files changed
+154 -166

No files matched your search

+2 -1
View File
@@ -93,12 +93,13 @@ void loopSSD1306() {
long enough since the last message and display not being used and a queue message waiting
*/
if (jsonDisplay && displayState) {
if (uptime() >= nextDisplayPage && uxSemaphoreGetCount(semaphoreOLEDOperation) && currentWebUIMessage) {
if (uptime() >= nextDisplayPage && uxSemaphoreGetCount(semaphoreOLEDOperation) && currentWebUIMessage && newSSD1306Message) {
if (!Oled.displayPage(currentWebUIMessage)) {
Log.warning(F("[ssd1306] displayPage failed: %s" CR), currentWebUIMessage->title);
}
nextDisplayPage = uptime() + DISPLAY_PAGE_INTERVAL;
logoDisplayed = false;
newSSD1306Message = false;
}
}
/*
+2 -2
View File
@@ -478,7 +478,7 @@ void pubMqttDiscovery() {
# ifdef ZdisplaySSD1306
createDiscovery("switch", //set Type
subjectSSD1306toMQTT, "SS1306: Control", (char*)getUniqueId("onstate", "").c_str(), //set state_topic,name,uniqueId
subjectSSD1306toMQTT, "SSD1306: Control", (char*)getUniqueId("onstate", "").c_str(), //set state_topic,name,uniqueId
will_Topic, "", "{{ value_json.onstate }}", //set availability_topic,device_class,value_template,
"{\"onstate\":true,\"save\":true}", "{\"onstate\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
@@ -488,7 +488,7 @@ void pubMqttDiscovery() {
"false", "true" //state_off, state_on
);
createDiscovery("switch", //set Type
subjectSSD1306toMQTT, "SS1306: Display metric", (char*)getUniqueId("displaymetric", "").c_str(), //set state_topic,name,uniqueId
subjectSSD1306toMQTT, "SSD1306: Display metric", (char*)getUniqueId("displaymetric", "").c_str(), //set state_topic,name,uniqueId
will_Topic, "", "{{ value_json.displaymetric }}", //set availability_topic,device_class,value_template,
"{\"displaymetric\":true,\"save\":true}", "{\"displaymetric\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
+21 -13
View File
@@ -984,7 +984,7 @@ void handleIN() {
informationDisplay += stateWebUIStatus();
// stateBTMeasures causes a Stack canary watchpoint triggered (loopTask)
// WEBUI_TRACE_LOG(F("[WebUI] informationDisplay before %s" CR), informationDisplay.c_str());
// WEBUI_TRACE_LOG(F("[WebUI] informationDisplay before %s" CR), informationDisplay.c_str());
// TODO: need to fix display of modules array within SYStoMQTT
@@ -994,7 +994,7 @@ void handleIN() {
informationDisplay.replace("{\"", "");
informationDisplay.replace("\"", "\\\"");
// WEBUI_TRACE_LOG(F("[WebUI] informationDisplay after %s" CR), informationDisplay.c_str());
// WEBUI_TRACE_LOG(F("[WebUI] informationDisplay after %s" CR), informationDisplay.c_str());
if (informationDisplay.length() > WEB_TEMPLATE_BUFFER_MAX_SIZE) {
Log.warning(F("[WebUI] informationDisplay content length ( %d ) greater than WEB_TEMPLATE_BUFFER_MAX_SIZE. Display truncated" CR), informationDisplay.length());
@@ -1077,7 +1077,8 @@ void handleUP() {
String response = String(buffer);
response += String(script);
response += String(style);
snprintf(buffer, WEB_TEMPLATE_BUFFER_MAX_SIZE, upgrade_body, jsonChar, gateway_name, "https://github.com/1technophile/OpenMQTTGateway/releases/");
String systemUrl = RELEASE_LINK + latestVersion + "/" + ENV_NAME + "-firmware.bin";
snprintf(buffer, WEB_TEMPLATE_BUFFER_MAX_SIZE, upgrade_body, jsonChar, gateway_name, systemUrl.c_str());
response += String(buffer);
snprintf(buffer, WEB_TEMPLATE_BUFFER_MAX_SIZE, footer, OMG_VERSION);
response += String(buffer);
@@ -1141,7 +1142,9 @@ void handleCS() {
if (cflg) {
message += "\n";
}
message += String(line, len - 1);
for (int x = 0; x < len - 1; x++) {
message += line[x];
}
cflg = true;
}
message += "}1";
@@ -1152,7 +1155,7 @@ void handleCS() {
char buffer[WEB_TEMPLATE_BUFFER_MAX_SIZE];
snprintf(buffer, WEB_TEMPLATE_BUFFER_MAX_SIZE, header_html, (String(gateway_name) + " - Configuration").c_str());
snprintf(buffer, WEB_TEMPLATE_BUFFER_MAX_SIZE, header_html, (String(gateway_name) + " - Console").c_str());
String response = String(buffer);
response += String(console_script);
response += String(script);
@@ -1235,20 +1238,21 @@ void WebUISetup() {
Log.notice(F("ZwebUI setup done" CR));
}
unsigned long nextWebUIPage = uptime() + DISPLAY_WEBUI_INTERVAL;
unsigned long nextWebUIMessage = uptime() + DISPLAY_WEBUI_INTERVAL;
void WebUILoop() {
server.handleClient();
if (uptime() >= nextWebUIPage && uxQueueMessagesWaiting(webUIQueue)) {
if (uptime() >= nextWebUIMessage && uxQueueMessagesWaiting(webUIQueue)) {
webUIQueueMessage* message = nullptr;
xQueueReceive(webUIQueue, &message, portMAX_DELAY);
newSSD1306Message = true;
if (currentWebUIMessage) {
free(currentWebUIMessage);
}
currentWebUIMessage = message;
nextWebUIPage = uptime() + DISPLAY_WEBUI_INTERVAL;
nextWebUIMessage = uptime() + DISPLAY_WEBUI_INTERVAL;
}
}
@@ -1424,7 +1428,7 @@ void webUIPubPrint(const char* topicori, JsonObject& data) {
# ifdef ZgatewayRTL_433
case webUIHash("RTL_433toMQTT"): {
if (strncmp(data["model"], "status", 6)) { // Does not contain "status"
if (data["model"] && strncmp(data["model"], "status", 6)) { // Does not contain "status"
// {"model":"Acurite-Tower","id":2043,"channel":"B","battery_ok":1,"temperature_C":5.3,"humidity":81,"mic":"CHECKSUM","protocol":"Acurite 592TXR Temp/Humidity, 5n1 Weather Station, 6045 Lightning, 3N1, Atlas","rssi":-81,"duration":121060}
// Line 1
@@ -1433,13 +1437,17 @@ void webUIPubPrint(const char* topicori, JsonObject& data) {
// Line 2
if (data["id"] || data["channel"]) {
String line2 = "";
if (data["id"]) {
String id = data["id"];
String channel = data["channel"];
String line2 = "id: " + id + " channel: " + channel;
line2.toCharArray(message->line2, WEBUI_TEXT_WIDTH);
line2 += "id: " + id + " ";
}
if (data["channel"]) {
String channel = data["channel"];
line2 += "channel: " + channel;
}
line2.toCharArray(message->line2, WEBUI_TEXT_WIDTH);
// Line 3
String line3 = "";
+2
View File
@@ -26,6 +26,7 @@
#ifndef config_WebUI_h
#define config_WebUI_h
#include <ArduinoJson.h>
#include <Wire.h>
#define WEBUI_TEXT_WIDTH 128
@@ -91,6 +92,7 @@ void MQTTtoWebUI(char*, JsonObject&);
String stateWebUIStatus();
webUIQueueMessage* currentWebUIMessage;
bool newSSD1306Message = false; // Flag to indicate new message to display
/*------------------- End of Global Functions ----------------------*/
+14 -2
View File
@@ -1964,11 +1964,23 @@ String stateMeasures() {
}
# endif
SYSdata["modules"] = modules;
String output;
serializeJson(SYSdata, output);
pub(subjectSYStoMQTT, SYSdata);
pubOled(subjectSYStoMQTT, SYSdata);
char jsonChar[100];
serializeJson(modules, jsonChar, 99);
String _modules = jsonChar;
_modules.replace(",", ", ");
_modules.replace("[", "");
_modules.replace("]", "");
_modules.replace("\"", "'");
SYSdata["modules"] = _modules.c_str();
String output;
serializeJson(SYSdata, output);
return output;
}
#endif