How to write to e-ink P096

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

How to write to e-ink P096

#1 Post by Affinite » 12 Nov 2021, 16:02

I dont know if this is the right way to report back on TEST plugins but ...

I'm experimenting with the (Test) 2.13" e-ink display and I have the TEST e-ink plugin P096 running on an NodeMCU ESP8266
It works OK (after 2 or 3 screen flashes) on the basic text sub-commands <txt>,<txtfull> to write 1 line of text but

1) I cant see how to write a full display with several lines of text ?
2 ) I cant get the non-txt sub-commands to work eg <c>, <l> etc

Any ideas/guidance appreciated
Thanks

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

Re: How to write to e-ink P096

#2 Post by Ath » 12 Nov 2021, 16:32

This is the set of commands supported: (no documentation available yet, still in PR)

Code: Select all

| command | details | description |
|-----|-----|-----|
| epd | `EPD,<epd_subcommand>,....` | Draw line, rect, circle, triangle and text |
|epdcmd | `EPDCMD,<epdcmd_subcommand>` | Control the screen (on, off, clear,..) |

EPD Subcommands:

| EPD Subcommands | details | description |
|-----|-----|-----|
| txt | txt,<text> | Write simple text (use last position, color and size) |
| txp | txp,<X>,<Y> | Set text position (move the cursor) |
| txc | txc,<foreColor>,<backgroundColor> | Set text color (background is transparent if not provided |
| txz | txz,<X>,<Y>,<text> | Write text at position (move the cursor + print) |
| txs | txs,<SIZE> | Set text size |
| txtfull | txtfull,<row>,<col>,<size=1>,<foreColor=white>,<backColor=black>,<text> | Write text with all options |
| l | l,<x1>,<y1>,<2>,<y2>,<color> | Draw a simple line |
| lh | lh,<y>,<width>,<color> | Draw an horizontal line (width = Line width in pixels (positive = right of first point, negative = point of first corner). |
| lv | lv,<x>,<height>,<color> | Draw a vertical line (height= Line height in pixels (positive = below first point, negative = above first point).|
| r | r,<x>,<y>,<width>,<height>,<color> | Draw a rectangle |
| rf | rf,<x>,<y>,<width>,<height>,<bordercolor>,<innercolor> | Draw a filled rectangle |
| c | c,<x>,<y>,<radius>,<color> | Draw a circle |
| cf | cf,<x>,<y>,<radius>,<bordercolor>,<innercolor> | Draw a filled circle |
| t | t,<x1>,<y1>,<x2>,<y2>,<x3>,<y3>,<color>| Draw a triangle |
| tf | tf,<x1>,<y1>,<x2>,<y2>,<x3>,<y3>,<bordercolor>,<innercolor> | Draw a filled triangle |
| rr | rr,<x>,<y>,<width>,<height>,<corner_radius>,<color> | Draw a round rectangle |
| rrf | rrf,<x>,<y>,<width>,<height>,<corner_radius>,<bordercolor>,<innercolor> | Draw a filled round rectangle |
| px | px,<x>,<y>,<color> | Print a single pixel |
  
EPDCMD Subcommands:

| EPDCMD Subcommands | details | description |
|-----|-----|-----|
| clear | clear,<color> | Clear display |
| deepsleep | deepsleep | Make screen go to sleep |
| inv | inv,<value> | Invert the dispaly (value:0 normal display, 1 inverted display) |
| rot | rot,<value> | Rotate display (value from 0 to 3 inclusive) |

So f.e. the 'l' and 'r' commands need to be prefixed by 'epd' like: 'epd,l,0,0,250,122,black' should draw a black diagonal line from left-top to right-bottom. Only 'colors' supported are white and black.
If you want to clear the display, use 'epdcmd,clear'

Addressing text per line/column can either by using the 'epd,txp,(x),(y)' followed by 'epd,txt,(some text)' subcommands or 'epd,txz,(x),(y),(some text)' subcommand.
/Ton (PayPal.me)

Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

Re: How to write to e-ink P096

#3 Post by Affinite » 12 Nov 2021, 17:32

Ath
Thanks for (very) quick reply. (I had already printed off the readme for P096 from Github)
I mistakenly thought I could ignore the <color> parameter. Once I included it in the command line, it works fine but I still dont know how to do a multi-line display.
If I send <epd,txz,0,0,test> followed by <epd,txz,40,40,testagain>
The screen flashes and clears leaving just "testagain" at 40,40
How can I send commands to display "test" at 0,0 and "testagain" at 40,40 ?

Maybe I have connected up the e-ink display incorrectly so its doing a reset when data is sent?

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

Re: How to write to e-ink P096

#4 Post by Ath » 12 Nov 2021, 19:01

Hm, 2 separate command should still work as intended.
I've been working on that plugin during development of the ST77xx TFT plugin, and merged the command handling of the ILI9341, eInk and ST77xx into a generic component AdafruitGFX_Helper, but I don't remember if this was one of the bugs/issues I resolved. Currently you are using the unmodified plugin, so there may be bugs in there.
There are 2 undocumented subcommands 'seq_start' and 'seq_end' that will postpone screen updates to after the seq_end subcommand. You can try to use these before and after your multiple tx? commands, to see if that sovles your findings.
/Ton (PayPal.me)

Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

Re: How to write to e-ink P096

#5 Post by Affinite » 13 Nov 2021, 00:23

Ath
seq-start and seq-end seems to have done the job.
Still lots of screen flashing when doing a refresh but it works.
Thanks again - will keep an eye open for updates to the plugin

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

Re: How to write to e-ink P096

#6 Post by TD-er » 13 Nov 2021, 00:30

Hmm lots of refreshes are not good.
Those e-ink screens can literally wear out.
The contrasting ink on the rotating (floating) balls inside the screen can wear off, loosing their contrast.
Not saying there should not be any refreshing, but you must also prevent updating continously.
An update a second can wear out such a display in a few months.

Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

Re: How to write to e-ink P096

#7 Post by Affinite » 13 Nov 2021, 18:20

That's why I wonder if I've hooked up the display incorrectly or if that behaviour is "normal" for the display and plugin at this stage of development?
Once implemented my intention is to refresh the display once every hour so I dont think I'll wear it out :)

PS - I have another question re the plugin so hope Ath sees this ...
Is there a way to populate the rf<height> parameter using a Task#Value?
I want to use the eink display as a tank level display and would like to create a rectangle (to simulate a tank) using
epd,rf,20,12,[Task#Value],10,black,white
I tried inserting Task#value into my rules (see code) but it doesnt work
Thanks again

Code: Select all

On tanks.fuel#currentVolume Do
   epdcmd,seq_start
//write tank values
   epd,txs,1 // set text size
   epd,txz,20,0,([tanks.fuel#currentVolume]) ltr
   epd,txz,100,0,([tanks.freshWater#currentVolume]) ltr
   epd,txz,180,0,([tanks.blackWater#currentVolume]) ltr
//draw fuel tank
//Max tank volume value is 320 so need to express this as fraction of 80 (eink tank display size)
   epd,rf,20,12,50,80,black,black 
   epd,rf,20,12,(80-(([tanks.fuel#currentVolume]/320)*80)),10,black,white
//draw fresh water tank
   epd,rf,100,12,50,80,black,black
   epd,rf,100,12,50,60,black,white
//draw Black water tank
   epd,rf,180,12,50,80,black,black
   epd,rf,180,12,50,30,black,white
//write tank names
   epd,txs,2 // set text size
   epd,txz,20,95,Fuel
   epd,txz,100,95,Water
   epd,txz,180,95,Black
//write status box
   epd,l,0,113,250,113,black
   epd,txs,1 // set text size
   epd,txz,1,115,Time Read:%systime% UTC
   epdcmd,seq_end
   timerSet,1,10 // wait 10 seconds
EndOn

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

Re: How to write to e-ink P096

#8 Post by Ath » 13 Nov 2021, 20:54

The flashing of the display, when applying the new content, is exactly what I saw when testing with my displays (I've also implemented the UC8151D, same behavior), so that's probably typical for this type of display. Updates are applied rather slow it seems. (These are not of commercial e-reader quality, I guess)

It will probably work better if you first calculate the height into a variable, and then use the integer value as the level:

Code: Select all

let 80,(80-(([tanks.fuel#currentVolume]/320)*80))
epd,rf,20,12,[int#80],10,black,white
/Ton (PayPal.me)

Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

Re: How to write to e-ink P096

#9 Post by Affinite » 14 Nov 2021, 13:27

Ath
Your advice to use a variable worked fine. - Thanks
Nearly there but running out of GPIO pins on my ESP8266 so might need to take a deep breath and move to ESP32 :o

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

Re: How to write to e-ink P096

#10 Post by TD-er » 14 Nov 2021, 13:36

ESP32 is behaving quite OK these days, so don't be afraid :)
The platform does get a lot of dev-time, so when new issues are found they will be fixed.

Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

Re: How to write to e-ink P096

#11 Post by Affinite » 14 Nov 2021, 20:54

Me again :oops:
I'm stuck trying to get my rules to work correctly ..
I have 2 triggers that I want to use (in an OR configuration) to trigger my display
First is a simple press of a button - connected to GPIO-10 and the second is based on receipt of a Task#value
If I put in trigger 1 I can trigger the rule
If I replace trigger 1 with trigger 2 it also works
What I cant do is an OR of the two triggers
I have read the Rules tutorial but I cant get it to work so Id appreciate another helping hand
Thanks

Code: Select all

on System#Boot do
 Monitor GPIO,10
endon
//  on [GPIO#10]=0 do
  on tanks.fuel#currentVolume do
// prepare the page
   epcmd,clear
   epdcmd,seq_start
//calc white(empty) space at tank tops in pixels
   let 1,(((320-[tanks.fuel#currentVolume])/320)*80)
   let 2,(((450-[tanks.freshWater#currentVolume])/450)*80)
   let 3,(((100-[tanks.blackWater#currentVolume])/100)*80)
//write tank values
   epd,txs,1 // set text size
   epd,txz,20,0,[tanks.fuel#currentVolume]/320 ltr
   epd,txz,100,0,[tanks.freshWater#currentVolume]/450 ltr
   epd,txz,180,0,[tanks.blackWater#currentVolume]/100 ltr
//draw fuel tank
   epd,rf,20,12,60,80,black,black
   epd,rf,20,12,60,[int#1],black,white
//draw fresh water tank
   epd,rf,100,12,60,80,black,black
   epd,rf,100,12,60,[int#2],black,white
//draw Black water tank
   epd,rf,180,12,60,80,black,black
   epd,rf,180,12,60,[int#3],black,white
// tank names
   epd,txs,2 // set text size
   epd,txz,20,95,Fuel
   epd,txz,100,95,Fresh
   epd,txz,180,95,Black
// status bar
   epd,txs,1 // set text size
   epd,txz,1,115,Read:%systime% UTC
   epd,txz,150,115,IP:%ip%
//write the page
   epdcmd,seq_end
  endon

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

Re: How to write to e-ink P096

#12 Post by TD-er » 14 Nov 2021, 21:42

You can create your own events.
Let's assume you want to have an event called "updatedisplay"

N.B. You should not use the [] in the on ... do part as [] will replace whatever is inside the square brackets with its current representation.

Code: Select all

on System#Boot do
 Monitor GPIO,10
endon

  on GPIO#10 do
     if %eventvalue1% = 0
       asyncevent,updatedisplay
     endif  
  endon

  on tanks.fuel#currentVolume do
    asyncevent,updatedisplay  
  endon
  
  on updatedisplay do
    // prepare the page
    ....
    

Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

Re: How to write to e-ink P096

#13 Post by Affinite » 15 Nov 2021, 18:32

TD-er
I dont really understand what you did it but it worked just great. :D

Thanks a lot

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

Re: How to write to e-ink P096

#14 Post by TD-er » 15 Nov 2021, 23:19

Affinite wrote: 15 Nov 2021, 18:32 TD-er
I dont really understand what you did it but it worked just great. :D

Thanks a lot
Hmm that's not good..
You should understand what's happening here.

As people have been saying for centuries:
Teach a man to copy/paste and he keeps on asking.
Teach a man to write ESPEasy rules and he may end up helping others.
What I did was very simple:

Code: Select all

  on GPIO#10 do    // Don't use [] in the on....do part
     if %eventvalue1% = 0 
       asyncevent,updatedisplay  // We schedule a new event called "updatedisplay"
     endif  
  endon
The event that's being handled here is "GPIO#10=0"
But we're not matching that exact event, but only the beginning upto the = sign.
The value(s) given to an event can be used when handling the event through %eventvalue1% .. %eventvalue4%
In this event we only have 1 event value, but there may be others like "bme#All=20.0,71.2,1001.2" for a sensor called "bme" sending all measured values (temp, hum, pressure) in a single event.

So if the eventvalue matches, we schedule a new event called "updatedisplay", which will be dealt with later in the rules.
The reason I am using "asyncevent" instead of "event" is that it is easier on the resources of ESPEasy. It will schedule a new event and push it to the back of the event queue
If I was using "event" then this event would be executed immediately causing a completely new parsing of the rules. For 1 event it doesn't really matter, but what if eventA calls eventB, which calls .. well you get the idea.

Code: Select all

 on updatedisplay do
 ....
 endon
 
This is the block where our new event is being handled.

So you now have 2 kinds of events which will eventually (pun intended :) ) run the same rules block.

Affinite
Normal user
Posts: 57
Joined: 03 Apr 2018, 18:46

Re: How to write to e-ink P096

#15 Post by Affinite » 16 Nov 2021, 18:43

Teach a man to copy/paste and he keeps on asking.
Teach a man to write ESPEasy rules and he may end up helping others.
Point taken. :D ... workin on it

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests