From d9fc8ab131351eab75cb7d2d8b4f74593bf3e4c1 Mon Sep 17 00:00:00 2001 From: JoostDkr <79747798+JoostDkr@users.noreply.github.com> Date: Mon, 21 Mar 2022 08:14:51 +0100 Subject: [PATCH 1/5] Update _P208_Nokia_LCD_5110.ino --- _P208_Nokia_LCD_5110.ino | 75 ++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/_P208_Nokia_LCD_5110.ino b/_P208_Nokia_LCD_5110.ino index e5facfd..fe29d6a 100644 --- a/_P208_Nokia_LCD_5110.ino +++ b/_P208_Nokia_LCD_5110.ino @@ -5,7 +5,7 @@ #ifdef USES_P208 // Working: -// - support different digit-size's. +// - support different digit-size's // - Display Text via: // 1. ESPEasy-Webinterface (Line-1-Line-x) // 2. http-request: @@ -20,16 +20,16 @@ // RST - => LCD_pin_1 reset connected to Vcc with 10k resistor // CE GPIO-5 => LCD_pin_2 chip select // DC GPIO-32 => LCD_pin_3 Data/Command select -// DIN GPIO-23 => LCD_pin_4 Serial data -// CLK GPIO-18 => LCD_pin_5 Serial clock out -// In hardware tab; -// - enable SPI; -// - Select VSPI:CLK=GPIO-18, MISO=GPIO-19, MOSI=GPIO-23 +// DIN GPIO-23 => LCD_pin_4 Serial data (Hardware-tab: SPI interface, VSPI-MOSI) +// CLK GPIO-18 => LCD_pin_5 Serial clock out (Hardware-tab: SPI interface, VSPI-CLK) +// In hardware tab; +// - enable SPI; +// - Select VSPI:CLK=GPIO-18, MISO=GPIO-19, MOSI=GPIO-23 // (MISO not used) // // - Tested on // - Hardware ESP32 -// - ESPEasy-mega-20210223 +// - ESPEasy_ESP32_mega-20211224 // ToDo: // - different digit-size within a line.... @@ -37,7 +37,7 @@ // // Hardware note: // It's often seen that pins are connected via (10k) risistors. -// Sometimes a screen will not work with these risistors. In that case, connect the display without resistors. +// Sometimes a screen will not work with these risistors. In that case, connect the display without resistors. // That works well. However, I have no long-term experience with this. #define PLUGIN_208 @@ -98,7 +98,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ case PLUGIN_WEBFORM_LOAD:{ addFormNumericBox(F("Display Contrast(50-100):"), F("plugin_208_contrast"), PCONFIG(1)); - + int optionValues3[4] = { 0, 1, 2, 3 }; String options3[4] = { F("0"), F("90"), F("180"), F("270") }; addFormSelector(F("Display Rotation"), F("plugin_208_rotation"), 4, options3, optionValues3, PCONFIG(2)); @@ -109,9 +109,9 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ int optionValues5[3] = { 1,2,3 }; String options5[3] = { F("normal"), F("large"), F("x-large") }; - addFormSelector(F("Char.size line-1"), F("plugin_208_charsize_line_1"), 3, options5, optionValues5, PCONFIG(3)); - addFormSelector(F("Char.size line-2"), F("plugin_208_charsize_line_2"), 3, options5, optionValues5, PCONFIG(4)); - addFormSelector(F("Char.size line-3"), F("plugin_208_charsize_line_3"), 3, options5, optionValues5, PCONFIG(5)); + addFormSelector(F("Char.size line-1"), F("plugin_208_charsize_line_1"), 3, options5, optionValues5, PCONFIG(3)); + addFormSelector(F("Char.size line-2"), F("plugin_208_charsize_line_2"), 3, options5, optionValues5, PCONFIG(4)); + addFormSelector(F("Char.size line-3"), F("plugin_208_charsize_line_3"), 3, options5, optionValues5, PCONFIG(5)); char deviceTemplate [lcd_lines][Digits_per_template_line]; LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); @@ -169,7 +169,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ displayText(deviceTemplate, event); //displayText((byte**)&deviceTemplate, event); lcd3->display(); - setBacklight(event); + setBacklight(event); success = true; break; } @@ -193,21 +193,23 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ if (argIndex){ tmpString = tmpString.substring(0, argIndex); if (tmpString.equalsIgnoreCase(F("PCD8544"))){ - if (event->Par1 <= 6 ){ // event->Par1 = row. - success = true; + success = true; + if (event->Par1 <= 6 ){ // event->Par1 = row. argIndex = string.lastIndexOf(','); char deviceTemplate [lcd_lines][Digits_per_template_line]; LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); String linedefinition = deviceTemplate[event->Par1-1]; - if (!linedefinition.length()){ // only if value is not definde in plugin-webform + if (linedefinition.length()){ // only if value is not defined in plugin-webform + myLog ("Unable to display text. Line in use by form-definition!"); + }else{ line_content_ist = html_input[event->Par1-1]; line_content_soll = string.substring(argIndex + 1); if (line_content_soll.length() < line_content_ist.length() ) { for(int i=line_content_soll.length(); i < line_content_ist.length(); i++){ line_content_soll += " "; } - } - //addLog(LOG_LEVEL_INFO, "5:"+ line_content_soll); + } + //myLog(line_content_soll); strncpy(html_input[event->Par1-1], line_content_soll.c_str(), sizeof(deviceTemplate[event->Par1-1])); } } @@ -217,32 +219,43 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ argIndex = string.lastIndexOf(','); tmpString = string.substring(argIndex + 1); if (tmpString.equalsIgnoreCase(F("Clear"))){ - addLog(LOG_LEVEL_INFO, F("Clear Display")); + myLog("Clear Display"); lcd3->clearDisplay(); lcd3->display(); } if (tmpString.equalsIgnoreCase(F("blOn"))){ success = true; PCONFIG(0) = 1; - setBacklight(event); + setBacklight(event); } if (tmpString.equalsIgnoreCase(F("blOff"))){ success = true; PCONFIG(0) = 0; - setBacklight(event); + setBacklight(event); } - break; - } + break; + } } } } // switch (function) return success; } +//void myLog (String message) { +// addLog(LOG_LEVEL_INFO, "P208: " + message); +//} +void myLog(const String & message) { + String log; + log.reserve(message.length() + 6); + log += F("P208: "); + log += message; + addLog(LOG_LEVEL_INFO, log); +} + void setBacklight(struct EventStruct *event) { if (Settings.TaskDevicePin3[event->TaskIndex] != -1){ pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT); - digitalWrite(Settings.TaskDevicePin3[event->TaskIndex], PCONFIG(0)); + digitalWrite(Settings.TaskDevicePin3[event->TaskIndex], PCONFIG(0)); portStatusStruct newStatus; const uint32_t key = createKey(1, Settings.TaskDevicePin3[event->TaskIndex]); // WARNING: operator [] creates an entry in the map if key does not exist @@ -257,7 +270,7 @@ void setBacklight(struct EventStruct *event) { boolean displayText(char deviceTemplate[][48], struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" //boolean displayText( char &deviceTemplate, struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" String log = F("PCD8544: "); - String string ; + String logstring ; lcd3->clearDisplay(); lcd3->setTextColor(BLACK); lcd3->setCursor(0,0); @@ -265,7 +278,7 @@ boolean displayText(char deviceTemplate[][48], struct EventStruct *event ){ // 4 for (byte x = 0; x < lcd_lines; x++) { if (x <= 3){ - lcd3->setTextSize(PCONFIG(3+x)); + lcd3->setTextSize(PCONFIG(3+x)); }else{ lcd3->setTextSize(1); } @@ -275,7 +288,7 @@ boolean displayText(char deviceTemplate[][48], struct EventStruct *event ){ // 4 newString = parseTemplate(tmpString, false); }else{ // webformline is empty use html input - newString = html_input[x]; + newString = html_input[x]; // 1e time html_input[x] has trailing spaces to delete old digits from the previous html_input[x] displayed on de LCD // Remove trailing spaces in html_input[x] for the next time while (newString.endsWith(" ")) { @@ -287,10 +300,12 @@ boolean displayText(char deviceTemplate[][48], struct EventStruct *event ){ // 4 strncpy(html_input[x], newString.c_str(), len); } lcd3->println(newString); - string+=newString+"\\"; + logstring += newString; + logstring += F(" ; "); } - log += String(F("displayed text: \"")) + String(string) + String(F("\"")); - addLog(LOG_LEVEL_INFO, log); + log += F("displayed text: "); + log += logstring ; + myLog(log); lcd3->display(); return true; } From 5336383bbdee50be169ef69901ea736c8d6b374b Mon Sep 17 00:00:00 2001 From: JoostDkr <79747798+JoostDkr@users.noreply.github.com> Date: Sat, 2 Apr 2022 09:23:58 +0200 Subject: [PATCH 2/5] Update _P208_Nokia_LCD_5110.ino --- _P208_Nokia_LCD_5110.ino | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/_P208_Nokia_LCD_5110.ino b/_P208_Nokia_LCD_5110.ino index fe29d6a..7c85858 100644 --- a/_P208_Nokia_LCD_5110.ino +++ b/_P208_Nokia_LCD_5110.ino @@ -55,6 +55,7 @@ Adafruit_PCD8544 *lcd3 = nullptr; +bool sentlog ; // yes/no send info to espeasylog char html_input [lcd_lines][digits_per_display_line]; boolean Plugin_208(byte function, struct EventStruct *event, String& string){ @@ -120,6 +121,8 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_208_template")) + (varNr + 1), deviceTemplate[varNr], 80); } success = true; + addFormCheckBox(F("debuginfo to log"), F("plugin_208_debuglog"), PCONFIG(8)); + break; } @@ -132,7 +135,8 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ PCONFIG(5)= getFormItemInt(F("plugin_208_charsize_line_3")); PCONFIG(6)= getFormItemInt(F("plugin_208_GPIO_CE")); PCONFIG(7)= getFormItemInt(F("plugin_208_GPIO_DC")); - + PCONFIG(8)= isFormItemChecked(F("plugin_208_debuglog")) ? 1 : 0; + sentlog = PCONFIG(8) == 1; char deviceTemplate[lcd_lines][Digits_per_template_line]; for (byte varNr = 0; varNr < lcd_lines; varNr++) { @@ -157,6 +161,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ byte plugin1 = PCONFIG(2); // rotation byte plugin2 = PCONFIG(1); // contrast byte plugin4 = PCONFIG(0); // backlight_onoff + sentlog = PCONFIG(8) == 1; UserVar[event->BaseVarIndex+2]=plugin1; UserVar[event->BaseVarIndex+1]=plugin2; UserVar[event->BaseVarIndex]=! plugin4; @@ -246,10 +251,12 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ //} void myLog(const String & message) { String log; - log.reserve(message.length() + 6); - log += F("P208: "); - log += message; - addLog(LOG_LEVEL_INFO, log); + if (sentlog){ + log.reserve(message.length() + 6); + log += F("P208: "); + log += message; + addLog(LOG_LEVEL_INFO, log); + } } void setBacklight(struct EventStruct *event) { From 8e2ee524249e3d5813197e8b8955ed8b2a4a2de4 Mon Sep 17 00:00:00 2001 From: JoostDkr <79747798+JoostDkr@users.noreply.github.com> Date: Wed, 6 Apr 2022 21:52:58 +0200 Subject: [PATCH 3/5] Update _P208_Nokia_LCD_5110.ino changes made as a result of review comments --- _P208_Nokia_LCD_5110.ino | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/_P208_Nokia_LCD_5110.ino b/_P208_Nokia_LCD_5110.ino index 7c85858..1555c65 100644 --- a/_P208_Nokia_LCD_5110.ino +++ b/_P208_Nokia_LCD_5110.ino @@ -50,7 +50,7 @@ #include #include #define lcd_lines 6 -#define Digits_per_template_line 48 // This value must be used at the function "displayText" declaration! +#define Digits_per_template_line 48 // This value must be used at the function "P208_displayText" declaration! #define digits_per_display_line 14 Adafruit_PCD8544 *lcd3 = nullptr; @@ -121,7 +121,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_208_template")) + (varNr + 1), deviceTemplate[varNr], 80); } success = true; - addFormCheckBox(F("debuginfo to log"), F("plugin_208_debuglog"), PCONFIG(8)); + addFormCheckBox(F("debuginfo to log"), F("plugin_208_debuglog"), PCONFIG_LONG(0)); break; } @@ -135,8 +135,8 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ PCONFIG(5)= getFormItemInt(F("plugin_208_charsize_line_3")); PCONFIG(6)= getFormItemInt(F("plugin_208_GPIO_CE")); PCONFIG(7)= getFormItemInt(F("plugin_208_GPIO_DC")); - PCONFIG(8)= isFormItemChecked(F("plugin_208_debuglog")) ? 1 : 0; - sentlog = PCONFIG(8) == 1; + PCONFIG_LONG(0)= isFormItemChecked(F("plugin_208_debuglog")) ? 1 : 0; + sentlog = PCONFIG_LONG(0) == 1; char deviceTemplate[lcd_lines][Digits_per_template_line]; for (byte varNr = 0; varNr < lcd_lines; varNr++) { @@ -161,7 +161,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ byte plugin1 = PCONFIG(2); // rotation byte plugin2 = PCONFIG(1); // contrast byte plugin4 = PCONFIG(0); // backlight_onoff - sentlog = PCONFIG(8) == 1; + sentlog = PCONFIG_LONG(0) == 1; UserVar[event->BaseVarIndex+2]=plugin1; UserVar[event->BaseVarIndex+1]=plugin2; UserVar[event->BaseVarIndex]=! plugin4; @@ -171,8 +171,8 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ lcd3->setRotation(plugin1); char deviceTemplate[lcd_lines][Digits_per_template_line]; LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); - displayText(deviceTemplate, event); - //displayText((byte**)&deviceTemplate, event); + P208_displayText(deviceTemplate, event); + //P208_displayText((byte**)&deviceTemplate, event); lcd3->display(); setBacklight(event); success = true; @@ -182,8 +182,8 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ case PLUGIN_READ:{ char deviceTemplate[lcd_lines][Digits_per_template_line]; LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); - displayText(deviceTemplate, event); - //displayText((byte**)&deviceTemplate, event); + P208_displayText(deviceTemplate, event); + //P208_displayText((byte**)&deviceTemplate, event); success = false; break; } @@ -205,7 +205,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); String linedefinition = deviceTemplate[event->Par1-1]; if (linedefinition.length()){ // only if value is not defined in plugin-webform - myLog ("Unable to display text. Line in use by form-definition!"); + P208_log ("Unable to display text. Line in use by form-definition!"); }else{ line_content_ist = html_input[event->Par1-1]; line_content_soll = string.substring(argIndex + 1); @@ -214,7 +214,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ line_content_soll += " "; } } - //myLog(line_content_soll); + //P208_log(line_content_soll); strncpy(html_input[event->Par1-1], line_content_soll.c_str(), sizeof(deviceTemplate[event->Par1-1])); } } @@ -224,7 +224,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ argIndex = string.lastIndexOf(','); tmpString = string.substring(argIndex + 1); if (tmpString.equalsIgnoreCase(F("Clear"))){ - myLog("Clear Display"); + P208_log("Clear Display"); lcd3->clearDisplay(); lcd3->display(); } @@ -246,12 +246,12 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ return success; } -//void myLog (String message) { +//void P208_log (String message) { // addLog(LOG_LEVEL_INFO, "P208: " + message); //} -void myLog(const String & message) { +void P208_log(const String & message) { String log; - if (sentlog){ + if (sentlog ){ log.reserve(message.length() + 6); log += F("P208: "); log += message; @@ -274,8 +274,8 @@ void setBacklight(struct EventStruct *event) { } } -boolean displayText(char deviceTemplate[][48], struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" -//boolean displayText( char &deviceTemplate, struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" +boolean P208_displayText(char deviceTemplate[][48], struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" +//boolean P208_displayText( char &deviceTemplate, struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" String log = F("PCD8544: "); String logstring ; lcd3->clearDisplay(); @@ -312,7 +312,7 @@ boolean displayText(char deviceTemplate[][48], struct EventStruct *event ){ // 4 } log += F("displayed text: "); log += logstring ; - myLog(log); + P208_log(log); lcd3->display(); return true; } From 26d6d9a58fdef4f3504738c8108328e9996da0f9 Mon Sep 17 00:00:00 2001 From: JoostDkr <79747798+JoostDkr@users.noreply.github.com> Date: Wed, 27 Apr 2022 18:06:11 +0200 Subject: [PATCH 4/5] One html request can now contain multiple lines --- _P208_Nokia_LCD_5110.ino | 109 +++++++++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 38 deletions(-) diff --git a/_P208_Nokia_LCD_5110.ino b/_P208_Nokia_LCD_5110.ino index 1555c65..606ca32 100644 --- a/_P208_Nokia_LCD_5110.ino +++ b/_P208_Nokia_LCD_5110.ino @@ -2,6 +2,7 @@ //################################## Plugin 208: NOKIA 5110 lcd ######################################### //####################################################################################################### #include "_Plugin_Helper.h" +#include #ifdef USES_P208 // Working: @@ -12,7 +13,7 @@ // - BackLight on via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,blOn) // - BackLight off via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,blOff) // - Clear Display via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,clear) -// - Send Text via httpcmd (http://ESP-IP/control?cmd=pcd8544,1,Hello World!) // 1 : line# +// - Send Text via httpcmd (http://ESP-IP/control?cmd=pcd8544,1,Hello World!;2,this is line two;3, this is line three) // 1,2,3 are the linenumbers. Maximum linnumber is: "lcd_lines_max" // Send Text via http-request only works for the empty lines in ESPEasy-Webinterface! // - Pin connections: // SPI interface: @@ -49,14 +50,14 @@ #include #include -#define lcd_lines 6 -#define Digits_per_template_line 48 // This value must be used at the function "P208_displayText" declaration! +#define Digits_per_template_line 48 // This value must be also used at the function "P208_displayText" declaration! #define digits_per_display_line 14 +#define lcd_lines_max 6 Adafruit_PCD8544 *lcd3 = nullptr; bool sentlog ; // yes/no send info to espeasylog -char html_input [lcd_lines][digits_per_display_line]; +char html_input [lcd_lines_max][digits_per_display_line]; boolean Plugin_208(byte function, struct EventStruct *event, String& string){ boolean success = false; @@ -114,9 +115,9 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ addFormSelector(F("Char.size line-2"), F("plugin_208_charsize_line_2"), 3, options5, optionValues5, PCONFIG(4)); addFormSelector(F("Char.size line-3"), F("plugin_208_charsize_line_3"), 3, options5, optionValues5, PCONFIG(5)); - char deviceTemplate [lcd_lines][Digits_per_template_line]; + char deviceTemplate [lcd_lines_max][Digits_per_template_line]; LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); - for (byte varNr = 0; varNr < lcd_lines; varNr++) + for (byte varNr = 0; varNr < lcd_lines_max; varNr++) { addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_208_template")) + (varNr + 1), deviceTemplate[varNr], 80); } @@ -137,8 +138,8 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ PCONFIG(7)= getFormItemInt(F("plugin_208_GPIO_DC")); PCONFIG_LONG(0)= isFormItemChecked(F("plugin_208_debuglog")) ? 1 : 0; sentlog = PCONFIG_LONG(0) == 1; - char deviceTemplate[lcd_lines][Digits_per_template_line]; - for (byte varNr = 0; varNr < lcd_lines; varNr++) + char deviceTemplate[lcd_lines_max][Digits_per_template_line]; + for (byte varNr = 0; varNr < lcd_lines_max; varNr++) { char argc[25]; String arg = F("Plugin_208_template"); @@ -169,10 +170,7 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ lcd3->setContrast(30); lcd3->setContrast(plugin2); lcd3->setRotation(plugin1); - char deviceTemplate[lcd_lines][Digits_per_template_line]; - LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); - P208_displayText(deviceTemplate, event); - //P208_displayText((byte**)&deviceTemplate, event); + P208_displayText(event); lcd3->display(); setBacklight(event); success = true; @@ -180,49 +178,81 @@ boolean Plugin_208(byte function, struct EventStruct *event, String& string){ } case PLUGIN_READ:{ - char deviceTemplate[lcd_lines][Digits_per_template_line]; - LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); - P208_displayText(deviceTemplate, event); - //P208_displayText((byte**)&deviceTemplate, event); + P208_displayText(event); success = false; break; } case PLUGIN_WRITE:{ - String tmpString = string; + String tmpString = string; + String tmpstringAll = string; String StringToDisplay; String line_content_ist; String line_content_soll; + String log; + int semicolonpositionnext; + int semicolonposition =-1; + bool semicolonfound = true; + int commaposition; + int line_number_int; + String line_number_string; int argIndex = tmpString.indexOf(','); + //char htmlinput [lcd_lines_max] [1] [digits_per_display_line]; // max Aantal displayregels, rownumber, rowcontent soll + + P208_log("Html input1: "+tmpstringAll); if (argIndex){ - tmpString = tmpString.substring(0, argIndex); + //tmpstringAll = string; + tmpString = string.substring(0, argIndex); if (tmpString.equalsIgnoreCase(F("PCD8544"))){ success = true; - if (event->Par1 <= 6 ){ // event->Par1 = row. - argIndex = string.lastIndexOf(','); - char deviceTemplate [lcd_lines][Digits_per_template_line]; - LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); - String linedefinition = deviceTemplate[event->Par1-1]; - if (linedefinition.length()){ // only if value is not defined in plugin-webform - P208_log ("Unable to display text. Line in use by form-definition!"); - }else{ - line_content_ist = html_input[event->Par1-1]; - line_content_soll = string.substring(argIndex + 1); - if (line_content_soll.length() < line_content_ist.length() ) { - for(int i=line_content_soll.length(); i < line_content_ist.length(); i++){ + P208_log("Html input2: "+string); + do{ + tmpString = string.substring(argIndex+1,string.length()); + P208_log ("tmpString: "+ tmpString); + semicolonpositionnext = tmpString.indexOf(';',semicolonposition+1); // + P208_log ("Parameter: "+tmpString); + log = "semicolonpositionnext: "; + log += semicolonpositionnext; + P208_log (log); + if (semicolonpositionnext < 0){ // not found + semicolonpositionnext = tmpString.length(); + semicolonfound = false; + P208_log ("semicolonpositionnext < 0"); + } + line_number_string = tmpString.charAt(semicolonposition+1); + line_number_int = line_number_string.toInt(); // row + line_content_soll = tmpString.substring(semicolonposition+3,semicolonpositionnext); // contentsoll + + P208_log ("row/content: " + line_number_string + "/"+ line_content_soll); + + if (line_number_int <= lcd_lines_max ){ + char deviceTemplate [lcd_lines_max][Digits_per_template_line]; + LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); + String linedefinition = deviceTemplate[line_number_int-1]; + if (linedefinition.length()>0){ // only if value is not defined in plugin-webform + P208_log ("Unable to display text from html. Line in use by form-definition!"); + }else{ + // clear Old content thats not overwritten bij istcontent + line_content_ist = html_input[line_number_int-1]; + if (line_content_soll.length() < line_content_ist.length() ) { + for(int i=line_content_soll.length(); i < line_content_ist.length(); i++){ line_content_soll += " "; + } } - } - //P208_log(line_content_soll); - strncpy(html_input[event->Par1-1], line_content_soll.c_str(), sizeof(deviceTemplate[event->Par1-1])); + P208_log("Display: " + line_content_soll); + strncpy(html_input[line_number_int-1], line_content_soll.c_str(), sizeof(deviceTemplate[line_number_int-1])); + } } + semicolonposition = semicolonpositionnext; } + while (semicolonfound); } + if (tmpString.equalsIgnoreCase(F("PCD8544CMD"))){ success = true; - argIndex = string.lastIndexOf(','); - tmpString = string.substring(argIndex + 1); + commaposition = string.lastIndexOf(','); + tmpString = string.substring(commaposition + 1); if (tmpString.equalsIgnoreCase(F("Clear"))){ P208_log("Clear Display"); lcd3->clearDisplay(); @@ -274,15 +304,18 @@ void setBacklight(struct EventStruct *event) { } } -boolean P208_displayText(char deviceTemplate[][48], struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" -//boolean P208_displayText( char &deviceTemplate, struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" + +boolean P208_displayText(struct EventStruct *event ){ // 48 must be equal to "#define Digits_per_template_line" String log = F("PCD8544: "); String logstring ; lcd3->clearDisplay(); lcd3->setTextColor(BLACK); lcd3->setCursor(0,0); - for (byte x = 0; x < lcd_lines; x++) + char deviceTemplate[lcd_lines_max][Digits_per_template_line]; + LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); + + for (byte x = 0; x < lcd_lines_max; x++) { if (x <= 3){ lcd3->setTextSize(PCONFIG(3+x)); From 768bbc2195c237adffba8b84f8d004387e0f4fb8 Mon Sep 17 00:00:00 2001 From: JoostDkr <79747798+JoostDkr@users.noreply.github.com> Date: Thu, 28 Apr 2022 16:29:38 +0200 Subject: [PATCH 5/5] Update _P208_Nokia_LCD_5110.ino --- _P208_Nokia_LCD_5110.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_P208_Nokia_LCD_5110.ino b/_P208_Nokia_LCD_5110.ino index 606ca32..db420eb 100644 --- a/_P208_Nokia_LCD_5110.ino +++ b/_P208_Nokia_LCD_5110.ino @@ -2,13 +2,13 @@ //################################## Plugin 208: NOKIA 5110 lcd ######################################### //####################################################################################################### #include "_Plugin_Helper.h" -#include + #ifdef USES_P208 // Working: // - support different digit-size's // - Display Text via: -// 1. ESPEasy-Webinterface (Line-1-Line-x) +// 1. ESPEasy-Webinterface (Line-1...Line-x) // 2. http-request: // - BackLight on via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,blOn) // - BackLight off via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,blOff)