PCD8544 - Nokia 5110/3310 LCD - beta plugin

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#51 Post by joost d » 24 Dec 2020, 18:05

It looks like, this plugin is not working any more on ESPEasy_ESP32_mega-20201130.
Does somebody knows how to solve this compiling error: I'v treid to sole this problem for many hours....
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:99:39: error: expected primary-expression before '.' token
String tmpString = WebServer.arg(argc);
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:127:20: warning: unused variable 'setTextWrap' [-Wunused-variable]
boolean setTextWrap = false;
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:149:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
^
C:/Users/xx/Documents/PlatformIO/Projects/ESPEasy3_P208/src/_P208_LCD_PCD8544.ino:154:138: error: 'setPinState' was not declared in this scope
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
^
^
*** [.pio\build\custom_ESP32_4M316k\src\ESPEasy.ino.cpp.o] Error 1

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#52 Post by TD-er » 24 Dec 2020, 19:27

There are probably more things to change, but for starters, change WebServer into web_server.

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#53 Post by Ath » 24 Dec 2020, 21:59

I have done some initial work on this plugin, but didn't get it to display any text yet :shock: , I've shelved it for a while already, and probably give it a retry in the new year
/Ton (PayPal.me)

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#54 Post by joost d » 25 Dec 2020, 11:28

Great, changing WebServer into web_server works.

Now i'm struggling with these two errors. Does anyone have any advice?

_P208_LCD_PCD8544.ino:149:35: error: 'displayText' was not declared in this scope
displayText(deviceTemplate);
_P208_LCD_PCD8544.ino:154:138: error: 'setPinState' was not declared in this scope
setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#55 Post by TD-er » 25 Dec 2020, 15:02

I guess adding this as the first line of your .ino file will fix a lot of (future) compile errors:

Code: Select all

#include "_Plugin_Helper.h"
But setPinState is no longer implemented in the code, so you will need to make a lot more changes which makes it very hard to tell you what you should change.
This means I probably have to look at the code myself to see what else is missing or needs to be changed.

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#56 Post by joost d » 26 Dec 2020, 08:30

I had already included the line "#include "_Plugin_Helper.h".....

Stephan2204
New user
Posts: 8
Joined: 06 Feb 2021, 20:25

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#57 Post by Stephan2204 » 06 Feb 2021, 20:33

Hi Everybody,

i have successfully connected the LCD with the precompiled Image.
On thing won't work. Sending of display text via http cmd won't work.
As i understand the plugin code the behaviour should be compatible to the lcd2004 plugin:

http://192.168.1.242/control?cmd=pcd854 ... TTODISPLAY


But nothing appears. No Logging. But no message "wrong or unknown command". Thats appearing if you use cmd=whatever.

Code: Select all

 case PLUGIN_WRITE:
      {
        String tmpString  = string;
        int argIndex = tmpString.indexOf(',');
        if (argIndex)
          tmpString = tmpString.substring(0, argIndex);
        if (tmpString.equalsIgnoreCase(F("PCD8544")))
        {
          success = true;
          argIndex = string.lastIndexOf(',');
          tmpString = string.substring(argIndex + 1);
          lcd2->setCursor(event->Par2 - 1, event->Par1 - 1);
          lcd2->println(tmpString.c_str());
        }
        if (tmpString.equalsIgnoreCase(F("PCD8544CMD")))
        {
          success = true;
          argIndex = string.lastIndexOf(',');
          tmpString = string.substring(argIndex + 1);
          if (tmpString.equalsIgnoreCase(F("Clear")))
            lcd2->clearDisplay();
        }
        break;
      }

It's a pity, that the code isn'T working with the actual ESPEasy Source.

Any Idea, or what i'm doing wrong?

BR
Stephan

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#58 Post by TD-er » 07 Feb 2021, 00:37

What exact build did you use?
Asking this because lots of users still install old builds linked from some blog post for example.

Stephan2204
New user
Posts: 8
Joined: 06 Feb 2021, 20:25

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#59 Post by Stephan2204 » 07 Feb 2021, 04:35

Hi,

I don't have tried to compile it by myself.
I have downloaded the binary from Post #23:
viewtopic.php?p=32154#p32154
And i have read the draft for the plugin. And read within this thread, that the plugin is only usable with sources around 2018.

So the next step for me is:
try to update the plugin to compile with actual releases, and / or use a release from ~2018.
Then it's possible to (re)check, if the http command will work.

In the precompiled version only the following informations are found on the info page:

Code: Select all

Build	20102 - Mega
Libraries	ESP82xx Core 2_4_2, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.0.3
GIT version	
Plugins	73 [Normal] [Testing]
Build Md5	4d44355f4d44355f4d44355f4d44355f
Md5 check	fail !
Build time	Sep 22 2018 19:29:53
Binary filename	ThisIsTheDummyPlaceHolderForTheBinaryFilename64ByteLongFilenames 
Update:
Setting up platformio with visual studio code and compiling a unchanged repository successfully.
Now i have made the first advises to create a updated plugin.

Change for setPinState (might be the right way, after study of other plugins)

Code: Select all

 
          pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT);
          digitalWrite(Settings.TaskDevicePin3[event->TaskIndex],Settings.TaskDevicePluginConfig[event->TaskIndex][0]);        
          // setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
          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
          newStatus         = globalMapPortStatus[key];
          newStatus.command = 1;
          newStatus.mode    = PIN_MODE_OUTPUT;
          newStatus.state   = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
          savePortStatus(key, newStatus);}
 


Compiling done and image is working. Display is showing the configured lines.

Next step: verify http command....

BR
Stephan

Stephan2204
New user
Posts: 8
Joined: 06 Feb 2021, 20:25

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#60 Post by Stephan2204 » 07 Feb 2021, 21:28

One step forward.

Find here the code for the PCD8544 Display compatible to ESP_Easy_mega_20210207.
Something might be buggy. The ESP was sometime not directly reachable. But i don't find any reason or logging about.
Feel free to optimize the code, but give here some feedback.

// Working:
// - Display Text & Var via ESPEasy Webinterface (Line1-LineX)
// - Clear Display via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,clear)
// - Send Text via httpcmd (but don't clear the line :-( ) (http://ESP-IP/control?cmd=pcd8544,1,1,Hello%20World!)
//
// Mixed Mode (Display Data from ESP Easy and HTTP-request) is not easy to handle. Some problems are known from P012 LCD2004 Plugin
// Set Interval to 0 seconds for only using the http requests. Otherwise display clear will occur every cycle.
//
//
// ToDo:
// - If no Data via Webinterface (Line 1-x) exists. don't clear the display or no update!
// - How to "overwrite" via Webcmd the actual line. -> No garbage character
// (introduce clear line command? depending on orientation write n spaces. then write the new text?)



Code: Select all

#ifdef USES_P208
//#######################################################################################################
//################################## Plugin 208: NOKIA lcd2 ###############################################
//#######################################################################################################

// Working:
// - Display Text & Var via ESPEasy Webinterface (Line1-Linex)
// - Clear Display via httpcmd (http://ESP-IP/control?cmd=pcd8544cmd,clear)
// - Send Text via httpcmd (but don't clear the line :-( ) (http://ESP-IP/control?cmd=pcd8544,1,1,Hello%20World!)
//
// Mixed Mode (Display Data from ESP Easy and HTTP-request) is not easy to handle. Some problems are known from P012 LCD2004 Plugin
// Set Interval to 0 seconds for only using the http requests
//
// ToDo:
// - If no Data via Webinterface (Line 1-x) exists. don't clear the display or no update!
// - How to "overwrite" via Webcmd the actual line. -> No garbage character
//


#define PLUGIN_208
#define PLUGIN_ID_208 208
#define PLUGIN_NAME_208 "Display - LCD PCD8544 [TESTING]"
#define PLUGIN_VALUENAME1_208 "Backlight"
#define PLUGIN_VALUENAME2_208 "Contrast"
#define PLUGIN_VALUENAME3_208 "Rotation"

#include "_Plugin_Helper.h"
//#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

Adafruit_PCD8544 *lcd2;
byte lines = 6;

boolean Plugin_208(byte function, struct EventStruct *event, String& string)
{
  boolean success = false;

  switch (function)
  {

    case PLUGIN_DEVICE_ADD:
      {
        Device[++deviceCount].Number = PLUGIN_ID_208 ;
        Device[deviceCount].Type = DEVICE_TYPE_SINGLE;
        Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_SINGLE;
        Device[deviceCount].Ports = 0;
        Device[deviceCount].PullUpOption = false;
        Device[deviceCount].InverseLogicOption = false;
        Device[deviceCount].FormulaOption = false;
        Device[deviceCount].ValueCount = 3;
        Device[deviceCount].SendDataOption = false;
        Device[deviceCount].TimerOption = true;
        Device[deviceCount].TimerOptional = true;
        break;
      }


    case PLUGIN_GET_DEVICENAME:
      {
        string = F(PLUGIN_NAME_208);
        break;
      }

    case PLUGIN_GET_DEVICEVALUENAMES:
      {
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_208));
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_208));
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_208));
        break;
      }


    case PLUGIN_WEBFORM_LOAD:
      {
        addFormNumericBox(F("Display Contrast(50-100):"), F("plugin_208_contrast"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);

        addFormPinSelect(F("Backlight PIN"), F("taskdevicepin3"), Settings.TaskDevicePin3[event->TaskIndex]);

        byte choice3 = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
        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, choice3);

        byte choice4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
        String options4[2] = { F("ON"), F("OFF") };
        int optionValues4[2] = { 0, 1 };
        addFormSelector(F("Backlight"), F("plugin_208_backlight"), 2, options4, optionValues4, choice4);

        char deviceTemplate [lines][48];
        LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        for (byte varNr = 0; varNr < lines; varNr++)
        {
          addFormTextBox(String(F("Line ")) + (varNr + 1), String(F("Plugin_208_template")) + (varNr + 1), deviceTemplate[varNr], 80);
        }

        success = true;
        break;
      }

    case PLUGIN_WEBFORM_SAVE:
      {
        Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_208_backlight"));
        Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_208_contrast"));
        Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_208_rotation"));

        char deviceTemplate[lines][48];
        for (byte varNr = 0; varNr < lines; varNr++)
        {
          char argc[25];
          String arg = F("Plugin_208_template");
          arg += varNr + 1;
          arg.toCharArray(argc, 25);
          String tmpString = web_server.arg(argc);
          strncpy(deviceTemplate[varNr], tmpString.c_str(), sizeof(deviceTemplate[varNr]));
        }

      //  Settings.TaskDeviceID[event->TaskIndex] = 1; // temp fix, needs a dummy value

        SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        success = true;
        break;
      }

    case PLUGIN_INIT:
      {
        if (!lcd2)
        {
          // pin 14 - Serial clock out (SCLK)
          // pin 13 - Serial data out (DIN)
          // pin 12 - Data/Command select (D/C)
          // pin 5 - LCD chip select (CS)
          // pin 4 - LCD reset (RST)
          //lcd2 = new Adafruit_PCD8544(14, 13, 12, 5, 4);
          #if defined(ESP8266)
              lcd2 = new Adafruit_PCD8544(15, 2, -1); // D/C (need to be connected) GPIO2 , CS(CEN) GPIO15 , RESET not connected
          #endif
          #if defined(ESP32)
              lcd2 = new Adafruit_PCD8544(16, 17, -1); // D/C (need to be connected) GPIO16 , CS(CEN) GPIO17 , RESET not connected
          #endif

          boolean setTextWrap = false;
        }
        // Setup lcd2 display
        byte plugin1 = Settings.TaskDevicePluginConfig[event->TaskIndex][2]; // rotation
        byte plugin2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1]; // contrast
        byte plugin4 = Settings.TaskDevicePluginConfig[event->TaskIndex][0]; // backlight_onoff
        UserVar[event->BaseVarIndex+2]=plugin1;
        UserVar[event->BaseVarIndex+1]=plugin2;
        UserVar[event->BaseVarIndex]=!plugin4;
        if (plugin1==0 || plugin1==2)
        {
          lines=6;
        }
        else{
          lines=10;
        }
        lcd2->begin();                     // initialize the lcd2
        lcd2->setContrast(plugin2);
        lcd2->setRotation(plugin1);
        lcd2->clearDisplay();
        char deviceTemplate[lines][48];
        LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        displayText(deviceTemplate);
        lcd2->display();
        if (Settings.TaskDevicePin3[event->TaskIndex] != -1){
          pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT);
          digitalWrite(Settings.TaskDevicePin3[event->TaskIndex],Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
 
          // setPinState(1, Settings.TaskDevicePin3[event->TaskIndex], PIN_MODE_OUTPUT, Settings.TaskDevicePluginConfig[event->TaskIndex][3]);}
 
          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
          newStatus         = globalMapPortStatus[key];
          newStatus.command = 1;
          newStatus.mode    = PIN_MODE_OUTPUT;
          newStatus.state   = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
          savePortStatus(key, newStatus);}
 
        success = true;
        break;
      }

    case PLUGIN_READ:
      {
        char deviceTemplate[lines][48];
        LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        displayText(deviceTemplate);
        success = false;
        break;
      }

    case PLUGIN_WRITE:
      {
        String tmpString  = string;
        int argIndex = tmpString.indexOf(',');
        if (argIndex)
          tmpString = tmpString.substring(0, argIndex);
        if (tmpString.equalsIgnoreCase(F("PCD8544")))
        {
          success = true;
          argIndex = string.lastIndexOf(',');
          tmpString = string.substring(argIndex + 1);
          lcd2->setTextSize(1);
          int colPos  = event->Par2 - 1;
          int rowPos  = event->Par1 - 1;
          lcd2->setCursor(colPos, rowPos*8); // 8 Pixel
          //addLog(LOG_LEVEL_INFO, F("Position set"));

          lcd2->println(tmpString.c_str());
          lcd2->display();
        }
        if (tmpString.equalsIgnoreCase(F("PCD8544CMD")))
        {
          success = true;
          argIndex = string.lastIndexOf(',');
          tmpString = string.substring(argIndex + 1);
          if (tmpString.equalsIgnoreCase(F("Clear")))
            // addLog(LOG_LEVEL_INFO, F("Clear Display"));
            // Works! 
            lcd2->clearDisplay();
            lcd2->display();
        }
        break;
      }

  }
  return success;
}

boolean displayText(char deviceTemplate[][48]){
        String log = F("PCD8544: ");
        String string = F("");
        lcd2->clearDisplay();
        lcd2->setTextSize(1);
        lcd2->setTextColor(BLACK);
        lcd2->setCursor(0,0);
        for (byte x = 0; x < lines; x++)
        {
          String tmpString = deviceTemplate[x];
          if (tmpString.length())
          {
            String newString = parseTemplate(tmpString, 48);
            lcd2->setCursor(0,x*8);
            lcd2->print(newString);
            string+=newString+"\\";
          }
        }
        log += String(F("displayed text: \"")) + String(string) + String(F("\""));
        addLog(LOG_LEVEL_INFO, log);
        lcd2->display();
        return true;
  }
#endif // USES_P208


svasiliou
Normal user
Posts: 13
Joined: 04 May 2019, 20:46

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#61 Post by svasiliou » 21 Feb 2021, 20:32

Does anyone has compiled firmware newer than post 23?
Could uploaded here?
Is there any compiled firmware in nightly builds?

Thanks.

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#62 Post by joost d » 22 Feb 2021, 15:08

Hello Stephan2204,

I'v compile'd you code without errors. That's fine. But i have a question. I like to wire the 5110 directly to the ESP32. (5110-pins: CLK, DIN, DC, CE, RST). In your code, at PLUGIN_INIT, you only define pin D/C and CS.

#if defined(ESP32)
lcd2 = new Adafruit_PCD8544(16, 17, -1); // D/C (need to be connected) GPIO16 , CS(CEN) GPIO17 , RESET not connected
#endif

What about the other pins...?

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#63 Post by Ath » 22 Feb 2021, 16:56

The display is connected through SPI, so you'll have to enable SPI on the Hardware tab, en there it also shows the pins used.
/Ton (PayPal.me)

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#64 Post by joost d » 22 Feb 2021, 22:07

Ok, that was great information. Now the 5110 works. But:
1/ I had to connect 5110-pin-1 (RST) to Vcc (5V with 10k resistor!).
2/ I had to disable\comment the 1e and last line ("//#ifdef USES_P208" and "//#endif // USES_P208").
So what is the proper way\place to define USES_P208 ?

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#65 Post by joost d » 24 Feb 2021, 10:40

I like to display the current time. I used the ESPeasy-variable %systime%.
The displayed value on the screen is "10%3a37%3a53" meaning 10:37 and 53 sec.
Does somebody know why "%3a" is displayed?

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#66 Post by TD-er » 24 Feb 2021, 11:50

Looks like the values are "URL encoded"

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#67 Post by Ath » 24 Feb 2021, 13:07

This code:

Code: Select all

String newString = parseTemplate(tmpString, 48);
should be changed to:

Code: Select all

String newString = parseTemplate_padded(tmpString, 48);
parseTemplate() with a second argument defines a bool to use url encoding, and that 48 fits within a byte, then acting as a bool that's != 0...
/Ton (PayPal.me)

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#68 Post by joost d » 24 Feb 2021, 16:56

Thanks, Great, now the Plugin works fine for me. But...... Better is to replace
String newString = parseTemplate_padded(tmpString, 48); // 2e parameter is a bool!
in
String newString = parseTemplate_padded(tmpString, false);

Is there somebody who can answer my queston in post #64 at bullit "2/".

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#69 Post by Ath » 24 Feb 2021, 18:20

joost d wrote: 24 Feb 2021, 16:56 Is there somebody who can answer my queston in post #64 at bullit "2/".
You can use a custom build and create a Custom.h file from the sample provided with all stuff you need enabled, the add there #define USES_P208, or add that define to a set (normal does have enough flash space) in define_plugin_sets.h and run that build from the pio list in VSCode/Atom
/Ton (PayPal.me)

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#70 Post by joost d » 26 Feb 2021, 15:12

Thanks, I used the "define_plugin_sets.h" way. The _P208 is now compile and works OK.
But... The code after "#ifdef USES_P208" in _P208 is grey-out as shown in attachment. Can somebody tell me how to change that?
Attachments
Knipsel.JPG
Knipsel.JPG (90.54 KiB) Viewed 13910 times

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#71 Post by joost d » 08 Mar 2021, 16:41

I have futher developed this code, removed some bugs and added some extra functions. I think is is now free of bugs.

/ - support different digit-size's
// - Display Text via
// 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)
// - 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 http-request only works for the empty lines in ESPEasy-Webinterface!
// 3. See "PLUGIN_INIT:" for pin connections.

The code is placed in my fork of ESPeasy and I have made a pullrequest.

Example shows:
CO2 ppm
temp humidity
date time
Attachments
Knipsel.JPG
Knipsel.JPG (42.27 KiB) Viewed 13588 times
Last edited by joost d on 09 Mar 2021, 07:40, edited 1 time in total.

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#72 Post by Ath » 08 Mar 2021, 20:29

joost d wrote: 08 Mar 2021, 16:41 The code is placed in my fork of ESPeasy and I have made a pullrequest.
Have you set https://github.com/letscontrolit/ESPEasy as the upstream repository from your fork? As it currently isn't visible on the ESPEasy repo :shock:

You only have to do this once, when using VSCode you can type this from the terminal window when at the root directory of your forked repo.

Code: Select all

git remote add upstream https://github.com/letscontrolit/ESPEasy
After that, when pushing your commit initially to your repo, just push it to origin/... , and the PR will be visible when you open the ESPEasy github url in your browser.
/Ton (PayPal.me)

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#73 Post by joost d » 08 Mar 2021, 20:48

I can see my pullrequest in https://github.com/letscontrolit/ESPEas ... ound/pulls. But other people don't.
I think it has to do with a message display om my github:

Your account has been flagged.
Because of that, your profile is hidden from the public. If you believe this is a mistake, contact support to have your account status reviewed.

I'v reported this at GitHub-support.

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#74 Post by Ath » 08 Mar 2021, 21:54

Possibly your email address is abused by spammers? That's nasty, and hard to resolve I guess. But a new Google email address is cheap ;)
/Ton (PayPal.me)

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#75 Post by joost d » 10 Mar 2021, 18:28

OK, my account on GitHub is not "flaged" anymore. So You can see my pullrequest of "_P208 NOKIA 5110 LCD plugin".

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#76 Post by TD-er » 10 Mar 2021, 21:51

joost d wrote: 10 Mar 2021, 18:28 OK, my account on GitHub is not "flaged" anymore. So You can see my pullrequest of "_P208 NOKIA 5110 LCD plugin".
Yep, and replied to it :)

Stephan2204
New user
Posts: 8
Joined: 06 Feb 2021, 20:25

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#77 Post by Stephan2204 » 08 Apr 2021, 09:41

Great Job!

I just want to integrate the last changes into my build.
But i've got some errors.

I've just replaced the P208.ino from me with your file from github (ESPEasyPluginPlayground).
No difference with 20210223 or 20210114.

VSC report this lines:

Code: Select all

C:/Users/Stephan/Downloads/ESPEASY Nokia Display/source/src/_P208_Nokia_LCD_5110.ino: In function 'boolean Plugin_208(byte, EventStruct*, String&)':
C:/Users/Stephan/Downloads/ESPEASY Nokia Display/source/src/_P208_Nokia_LCD_5110.ino:200:85: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   for(int i=line_content_soll.length(); i < line_content_ist.length(); i++){
                                                                                     ^
In file included from C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Arduino.h:243:0,
                 from C:\Users\Stephan\AppData\Local\Temp\tmp1omtbdm5:1:
C:/Users/Stephan/Downloads/ESPEASY Nokia Display/source/src/_P208_Nokia_LCD_5110.ino: In function 'boolean displayText3(char (*)[48], EventStruct*)':
C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtensa-lx106-elf\include/sys/pgmspace.h:44:239: error: initializer fails to determine size of '__c'
     #define PSTRN(s,n) (__extension__({static const char __c[] __attribute__((__aligned__(n))) __attribute__((section( "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "."  __STRINGIZE(__COUNTER__) "\", \"aSM\", @progbits, 1 #"))) = (s); &__c[0];}))

                                                            ^
C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/WString.h:38:76: note: in definition of macro 'FPSTR'
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                                                                            ^
C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtensa-lx106-elf\include/sys/pgmspace.h:48:19: note: in expansion of macro 'PSTRN'
   #define PSTR(s) PSTRN(s,PSTR_ALIGN)
                   ^
C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/WString.h:39:34: note: in expansion of macro 'PSTR'
 #define F(string_literal) (FPSTR(PSTR(string_literal)))
                                  ^
C:/Users/Stephan/Downloads/ESPEASY Nokia Display/source/src/_P208_Nokia_LCD_5110.ino:265:30: note: in expansion of macro 'F'
           String tmpString = F(deviceTemplate[x]);
                              ^
C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtensa-lx106-elf\include/sys/pgmspace.h:44:239: error: array must be initialized with a brace-enclosed initializer
     #define PSTRN(s,n) (__extension__({static const char __c[] __attribute__((__aligned__(n))) __attribute__((section( "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "."  __STRINGIZE(__COUNTER__) "\", \"aSM\", @progbits, 1 #"))) = (s); &__c[0];}))

                                                            ^
C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/WString.h:38:76: note: in definition of macro 'FPSTR'
 #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
                                                                            ^
C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtensa-lx106-elf\include/sys/pgmspace.h:48:19: note: in expansion of macro 'PSTRN'
   #define PSTR(s) PSTRN(s,PSTR_ALIGN)
                   ^
C:\Users\Stephan\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/WString.h:39:34: note: in expansion of macro 'PSTR'
 #define F(string_literal) (FPSTR(PSTR(string_literal)))
                                  ^
C:/Users/Stephan/Downloads/ESPEASY Nokia Display/source/src/_P208_Nokia_LCD_5110.ino:265:30: note: in expansion of macro 'F'
           String tmpString = F(deviceTemplate[x]);
                              ^
The first line points to this part of the file:

Code: Select all

              
              if (!linedefinition.length()){  // only if value is not definde in plugin-webform
                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 += " ";
                  }
                }
But it looks fine for me.

For my github knowhow:
The PluginPlayground is only a collection of plugins. Theres no possibility to download/clone and compile espeasy?

BR
Stephan

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#78 Post by TD-er » 08 Apr 2021, 10:23

The F() macro can only be used on static strings which are known at compile time.

Code: Select all

// deviceTemplate[x] is not a static string, but a structure holding arrays of char.
// This will not work
String tmpString = F(deviceTemplate[x]);
 
 // This is constructing a new String object from an array of char, which is valid.
String tmpString = deviceTemplate[x];

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#79 Post by Ath » 08 Apr 2021, 11:28

Stephan2204 wrote: 08 Apr 2021, 09:41

Code: Select all

C:/Users/Stephan/Downloads/ESPEASY Nokia Display/source/src/_P208_Nokia_LCD_5110.ino: In function 'boolean Plugin_208(byte, EventStruct*, String&)':
C:/Users/Stephan/Downloads/ESPEASY Nokia Display/source/src/_P208_Nokia_LCD_5110.ino:200:85: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   for(int i=line_content_soll.length(); i < line_content_ist.length(); i++){
The message is in fact saying it (though not too obvious), so it should be something like:

Code: Select all

                   for(unsigned int i=line_content_soll.length(); i < line_content_ist.length(); i++){
/Ton (PayPal.me)

Stephan2204
New user
Posts: 8
Joined: 06 Feb 2021, 20:25

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#80 Post by Stephan2204 » 08 Apr 2021, 21:03

Thanks a lot.

The unsigned error was clear for me. The F() macro is a higher level story :-o ;-).

I'm wondering, because the pulled version was working for joost d.
Seems that the uploaded code might be different to the working code from joost.

@joost d: It is possible to verify your P208 file?

brachiate through the error messages shows the next issue.
Might be easier to doublecheck with joost.

Code: Select all

C:/ESPEasy_ESP82xx_mega-20210223/source/src/_P208_Nokia_LCD_5110.ino: In function 'boolean displayText3(char (*)[48], EventStruct*)':        
C:\.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtensa-lx106-elf\include/sys/pgmspace.h:44:239: error: initializer fails to determine size of '__c'

Code: Select all

boolean displayText3(char deviceTemplate[][48], struct EventStruct *event ){ 
        // 48 must be equal to "#define Digits_per_template_line"
        // OLD F Macro String log = F("PCD8544: ");
        // OLD F Macro String string =F("");
        String log = "PCD8544: ";
        String string ="";

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#81 Post by TD-er » 08 Apr 2021, 21:14

Code: Select all

boolean displayText3(char deviceTemplate[][48], struct EventStruct *event ){ 

This is rather tricky at best, to have such a specific parameter.
Why not simply call it like this:

Code: Select all

boolean displayText3(const char* text, struct EventStruct *event ){ 
Also String objects don't have to be constructed with an empty string.

Code: Select all

        String string ="";
can be simply this:

Code: Select all

        String string;
And this should be marked with the F() macro:

Code: Select all

        String log = F("PCD8544: ");

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#82 Post by joost d » 08 Apr 2021, 21:32

I compared my source with the playgroned (https://github.com/letscontrolit/ESPEas ... D_5110.ino).
The are exactly the same.

Stephan2204
New user
Posts: 8
Joined: 06 Feb 2021, 20:25

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#83 Post by Stephan2204 » 08 Apr 2021, 21:49

Very suspicious...

What i have done:
- downloading new ESPEasy Sources (old one same behaviour)
- adding the P208 file vom github
- creating new project (using VSC)
- enable P208 plugin
- adding adafruit Lib (PCD8544)

-> And the issues occurs...

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#84 Post by joost d » 08 Apr 2021, 22:48

I'm Using:
1/ PlatformIO and
2/ building with the "Default" environment.
In platfomio.ini :
default_envs =
normal_ESP32_4M316k
3/ ESPeasy: https://github.com/letscontrolit/ESPEas ... a-20210223

Stephan2204
New user
Posts: 8
Joined: 06 Feb 2021, 20:25

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#85 Post by Stephan2204 » 09 Apr 2021, 08:58

joost d wrote: 08 Apr 2021, 22:48 In platfomio.ini :
default_envs =
normal_ESP32_4M316k
Found.... We are using different HW. I'm using ESP8266_4M_1M.

Build might run. Adafruit and P208 will be compiled without errors. The bin can't be created. But this should be another issue.
Easier to order some ESP32 Shields for the future...

Code: Select all

Generating factory bin for genuine esp units
*** [.pio\build\normal_ESP32_4M316k\ESP_Easy_mega_20210409_normal_ESP32_4M316k.bin] ValueError : too many values to unpack (expected 2)

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#86 Post by TD-er » 09 Apr 2021, 09:50

You probably have a space in your path where you try to build the firmware.

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#87 Post by joost d » 09 Apr 2021, 10:45

@td'r:
You suggested "boolean displayText3(const char* text, struct EventStruct *event ){"
But I can't make that working correct. Ofcourse, it should be nice to pass the parameter "char deviceTemplate[][48]" by reference, but I can't make that working correct.
I will soon make a pullrequest with some other small optimizations.

Stephan2204
New user
Posts: 8
Joined: 06 Feb 2021, 20:25

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#88 Post by Stephan2204 » 09 Apr 2021, 11:16

TD-er wrote: 09 Apr 2021, 09:50 You probably have a space in your path where you try to build the firmware.
You're right! It was a copy of the folder with some spaces in its name.
Without spaces the compile for ESP32 works fine: normal_ESP32_4M316k SUCCESS

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCD8544 - Nokia 5110/3310 LCD - beta plugin

#89 Post by TD-er » 09 Apr 2021, 14:40

joost d wrote: 09 Apr 2021, 10:45 @td'r:
You suggested "boolean displayText3(const char* text, struct EventStruct *event ){"
But I can't make that working correct. Ofcourse, it should be nice to pass the parameter "char deviceTemplate[][48]" by reference, but I can't make that working correct.
I will soon make a pullrequest with some other small optimizations.
char arrays will always be handed over like a char pointer (char*) and an array of arrays like char**, but how you do it now, it will only accept objects that match exactly this definition. (can be to make sure you can make assumptions about the sizes, so isn't always a bad idea)
So you could make it slightly more readable by making it a typedef, so you only have the "48" defined once.

At least it won't be copied, as it is a pointer anyway.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 32 guests