P012 plugin - LCD display

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

P012 plugin - LCD display

#1 Post by mackowiakp » 07 Mar 2023, 01:41

As I can see in the sources, it is possible to define Polish characters in the LCD display.

Code: Select all

[maciek@Piotr src]$ grep -R USES_P012_POLISH *
src/PluginStructs/P012_data_struct.cpp:# ifdef USES_P012_POLISH_CHARS
src/PluginStructs/P012_data_struct.cpp:# endif // USES_P012_POLISH_CHARS
src/PluginStructs/P012_data_struct.cpp:# ifdef USES_P012_POLISH_CHARS
src/PluginStructs/P012_data_struct.cpp:# endif // ifdef USES_P012_POLISH_CHARS
src/PluginStructs_tmp/__tmpfile.cpp:# ifdef USES_P012_POLISH_CHARS
src/PluginStructs_tmp/__tmpfile.cpp:# endif // USES_P012_POLISH_CHARS
src/PluginStructs_tmp/__tmpfile.cpp:# ifdef USES_P012_POLISH_CHARS
src/PluginStructs_tmp/__tmpfile.cpp:# endif // ifdef USES_P012_POLISH_CHARS
What and where to add to the plugin source to be able to compile FW with this function?

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

Re: P012 plugin - LCD display

#2 Post by TD-er » 07 Mar 2023, 08:14

Where you also define what plugin to use (e.g. USES_P012), you also define the USES_P012_POLISH_CHARS

Code: Select all

#define USES_P012
#define USES_P012_POLISH_CHARS
Or if you're using the Python files to define your custom build:

Code: Select all

"-DUSES_P012",
"-DUSES_P012_POLISH_CHARS",

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#3 Post by mackowiakp » 07 Mar 2023, 08:52

OK, THX, Will try later and rapport results.

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#4 Post by mackowiakp » 07 Mar 2023, 10:35

Polish letters are display properly both on 2x16 and 4x20 display.
But there is another problem.
So far I used FW compiled 3 or more years ago, with Polish letter feature made on my own. It works properly.
Now there is in logs such command:

Code: Select all

LCD,1,1,10:26 Wt. 7/03/23
or
LCD,4,1,Wewn. 20.3° VOC 299
The command above are created by rules:

Code: Select all

LCD,1,1,%systm_hm% Wt. %sysday%/%sysmonth_0%/%sysyears%
and
LCD,4,1,Wewn. [Temp-Higro#Temperatura-Piotr#D1.1]{D} VOC [VOC-Piotr#VOC-Piotr]
But only "10:26" and "Wewn." is shown on display.
Looks like something wrong with spaces interpretation.
How can I fix it?

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

Re: P012 plugin - LCD display

#5 Post by Ath » 07 Mar 2023, 10:38

You need to add quotes around the part that is supposed to be displayed, that can either be double quotes, single quotes or back-ticks. Just use one that's not used in the content. See: https://github.com/letscontrolit/ESPEasy/issues/2724

Code: Select all

LCD,1,1,"%systm_hm% Wt. %sysday%/%sysmonth_0%/%sysyears%"
and
LCD,4,1,"Wewn. [Temp-Higro#Temperatura-Piotr#D1.1]{D} VOC [VOC-Piotr#VOC-Piotr]"
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#6 Post by mackowiakp » 07 Mar 2023, 10:45

Yep, now is a lot of better :D
THX for quick feedback !

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#7 Post by mackowiakp » 07 Mar 2023, 13:13

Another problem.
When I try to send LCD command to unit with 4x20 display, using such command from bash scipt on Rpi:

Code: Select all

#!/bin/bash
....
....
wget -q -O - http://$display/control?cmd=LCD,2,1,"Wilg.garaż:     $higro_garaz%"
...
it display only text-> Wilg.garaż: without content of variable.
I try for test change variable to fixed string but result was the same.

An next issue. Sending string (from bash too) with leading spaces causes that text is display without leading spaces.
Below the command

Code: Select all

nazwa="     Wyłączone"
wget -q -O - http://$display/control?cmd=LCD,2,1,"$nazwa"

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

Re: P012 plugin - LCD display

#8 Post by TD-er » 07 Mar 2023, 13:30

What happens when you try to send the same command from the tools page from that command line there?
After submitting, the URL in the browser will be updated with the exact formatting needed in the URL.

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

Re: P012 plugin - LCD display

#9 Post by TD-er » 07 Mar 2023, 13:31

About the leading spaces.... why not set the position (the 2nd argument)?
Or does it then not clear the previous text on those positions?

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#10 Post by mackowiakp » 07 Mar 2023, 13:45

About the leading spaces.... why not set the position (the 2nd argument)?
Or does it then not clear the previous text on those positions?
Because I have to clear beginning of line (not whole display)
What happens when you try to send the same command from the tools page from that command line there?
After submitting, the URL in the browser will be updated with the exact formatting needed in the URL.
Its display properly but please take into account that I want to pass variable to bash command line.
I try syntax like this:

Code: Select all

wget -q -O - http://$display/control?cmd='LCD,2,1,"Wilg.zewnątrz:  $higro%"'
and
wget -q -O - http://$display/control?cmd=LCD,2,1,'"Wilg.zewnątrz:  $higro%"'
with additional quota char ' but reuslt was in both cases that it display-> Wilg.zewnątrz: $higr

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

Re: P012 plugin - LCD display

#11 Post by Ath » 07 Mar 2023, 14:07

Bash doesn't expand variables wrapped in single quotes, AFAIR, this SO question has a quite usable explanation on that
/Ton (PayPal.me)

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

Re: P012 plugin - LCD display

#12 Post by TD-er » 07 Mar 2023, 14:15

It isn't that hard to find out where in this part of the URL you need to replace stuff for your variables, right?

Code: Select all

Command: LCD,2,1,"Wilg.zewnątrz:  $higro%"
URL: /tools?cmd=LCD%2C2%2C1%2C"Wilg.zewnątrz%3A++%24higro%25"
Edit:
Ah now I get it, you need to replace it in the bash string.

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#13 Post by mackowiakp » 07 Mar 2023, 14:20

Hmmm... I changed order of quota charactrs in bash command from ` and " to " and `just like below

Code: Select all

wget -q -O - http://$display/control?cmd=LCD,2,1,"'Wilg.zewnątrz:  $higro%'"
and it works properly.
But the issue of leading spaces still exist

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

Re: P012 plugin - LCD display

#14 Post by Ath » 07 Mar 2023, 14:56

Parsing the arguments does by default a trim on the value. For the content part that should probably be changed (there's an extra argument that has to be set to false). I'll start a PR to change that soon (unless someone beats me to it :lol:)
Same goes for other Display-related plugins, I guess, I'll check that too.
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#15 Post by mackowiakp » 07 Mar 2023, 15:13

OK, but can I change this argument (which one?) to "false" by myself and compile new FW?

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

Re: P012 plugin - LCD display

#16 Post by Ath » 07 Mar 2023, 16:00

mackowiakp wrote: 07 Mar 2023, 15:13 OK, but can I change this argument (which one?) to "false" by myself and compile new FW?
File _P012_LCD.ino, line 258:

Code: Select all

          String text = parseStringKeepCase(string, 4, ',', false);
/Ton (PayPal.me)

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

Re: P012 plugin - LCD display

#17 Post by Ath » 07 Mar 2023, 22:02

I've created pull request #4536 that will correct this issue for this and other Display plugins that had the same behavior (P012, P023, P036, P104).
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#18 Post by mackowiakp » 08 Mar 2023, 00:11

THX

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: P012 plugin - LCD display

#19 Post by mackowiakp » 08 Mar 2023, 06:49

New source code for P012 taken from request #4536 works properly on LCD display 4x20 and 2x16.
THX for quick correction!

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

Re: P012 plugin - LCD display

#20 Post by Ath » 08 Mar 2023, 07:26

Thanks for the feedback ;)
/Ton (PayPal.me)

ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Re: P012 plugin - LCD display

#21 Post by ewaldharmsen » 14 Jul 2023, 14:27

I am using this plugin today for the first time.

Thanks for the hard work

Its working fine except the brightness of the text.

I need to put the contrast all the way to one side to even see the text but its barely visible.

Anything I can do?

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

Re: P012 plugin - LCD display

#22 Post by TD-er » 14 Jul 2023, 15:05

Sounds like you might want to add a potentiometer to the contrast pin.
See: http://wiki.sunfounder.cc/index.php?tit ... 004_Module

Edit:
Apparently on the I2C to parallel add-on PCB is a potentiometer to set the contrast.
See: https://randomnerdtutorials.com/esp32-e ... duino-ide/

ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Re: P012 plugin - LCD display

#23 Post by ewaldharmsen » 14 Jul 2023, 19:53

Yes I have the potentiometer. If I turn it all the way I see something but not clearly.

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

Re: P012 plugin - LCD display

#24 Post by TD-er » 14 Jul 2023, 22:40

How is the display powered?
3V3 or 5V?

It looks like it needs 5V.
However, be aware that the SDA and SCL might be pulled up to the Vcc pin.
This means the SDA and SCL levels might be higher than 3V3.
The ESP may be able to handle this, but other sensors connected to this I2C bus might not be 5V tolerant.

Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests