Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Waveshare Three-color E-Ink Displays #239

Open
asmfreak opened this issue May 21, 2019 · 161 comments · May be fixed by esphome/esphome#5886
Open

Support for Waveshare Three-color E-Ink Displays #239

asmfreak opened this issue May 21, 2019 · 161 comments · May be fixed by esphome/esphome#5886

Comments

@asmfreak
Copy link

asmfreak commented May 21, 2019

Describe the problem you have/What new integration you would like

References #77.
I've got Waveshare's 3-color e-ink display and it would be nice to have some support for them.

7.50in B-type (red-black-white)
7.50in C-type (yellow-black-white)

Please describe your use case for this integration and alternatives you've tried:

Additional context

@asmfreak
Copy link
Author

asmfreak commented May 26, 2019

After some fiddling around, I can report that implementing color in 7.50 modules is quite hard due to memory.
Consider this (numbers in braces are reported by PIO):

  • The ESP I use have around 80K(81920) of RAM.
  • ESPHOME in minimal configuration consumes around 30K(31300) of RAM.
  • Waveshare Display in BW mode consumes \dfrac{640 \cdot 384}{8} = 30720, totaling in 81920 - (31300 + 30720) = 19900 ~\text{bytes} of free space after buffer allocation
  • A naive color implementation (2bits) needs a buffer of \dfrac{640 \cdot 384}{4} = 61440 ~\text{bytes}, resulting in buffer allocation fail - 81920 - (31300 + 61440) = -10820 ~\text{bytes}.

I'll try to use flash memory for this. This result will also affect our ability to implement color LCD displays.

@OttoWinter
Copy link
Member

@asmfreak Hmm yeah that's true.

Of course the ESPHome memory usage could be optimized a bit (though most of that number probably comes from the SDK wifi system etc), but that would not solve the problem for longer.

At least on ESP32s this will be a much smaller problem (I think they had like 6 times as much RAM, but don't quote me on that). So if it turns out that it can't run on ESP8266s let's just make it ESP32-only.

@sbussinger
Copy link

I'd also like support for WaveShare's 3 color e-ink displays, but I'm interested in the smaller displays (1.5" 200x200). So let's not make it ESP32 only since the smaller buffer required should fit on an ESP8266.

@asmfreak
Copy link
Author

asmfreak commented Jul 7, 2019

@sbussinger I've written and tested the code for 7.5in color display. I could extend it for all color displays, but I need someone to test the code.

@tommy-hartmann
Copy link

tommy-hartmann commented Jul 23, 2019

@sbussinger I've written and tested the code for 7.5in color display. I could extend it for all color displays, but I need someone to test the code.

I have a waveshare 4.20in BWR Display and i'd like to test your code.

@minsuke
Copy link

minsuke commented Oct 26, 2019

@sbussinger I've written and tested the code for 7.5in color display. I could extend it for all color displays, but I need someone to test the code.

you developed 3 color? If I can use 3 color I'll buy it, I wich you can share the code with esphome library. you great !!!

@Cabbo
Copy link

Cabbo commented Aug 23, 2020

What about implementing the smaller color ones as b/w? I could test 1.54in-c

@shacal
Copy link

shacal commented Nov 8, 2020

Any update on this, I have hardware to test this out.

@lbonherbe
Copy link

Hello all!

Since then Waveshare has released a flurry of epaper screens - the list is long but a lot of good ones, with partial refresh, almost instant refreshes etc. We can see the list here for example: https://www.waveshare.com/product/displays/e-paper/epaper-2/3.7inch-e-paper.htm
It would be good to add those in ESPHome as they seem to be changing the game of epaper display!

@brettp
Copy link

brettp commented Mar 13, 2021

Is there a ticket to track color support for these three-color displays?

I can only find a few old references about specific displays (#892, a reference in a PR to another PR, and possibly the referenced PR itself).

@xaxix
Copy link

xaxix commented Mar 27, 2021

i will love the support of the 3 color 4.2 display!

@martin3000
Copy link

Is there a way to use the colored version without using the red color? just to make it work with b&w?

@oscaropenness
Copy link

Is there a way to use the colored version without using the red color? just to make it work with b&w?

The displays are working in b&w there is just no option yet to make use of the color.

@martin3000
Copy link

martin3000 commented Jul 28, 2021

image
So you think this should look ok? The problem is not the color version of the panel?

@henriklied
Copy link

image
So you think this should look ok? The problem is not the color version of the panel?

Same issue here. Hoping that there's a way to address this.

@AntoineOnnillon
Copy link

AntoineOnnillon commented Dec 14, 2021

Hello,
I just finish to create a new waveshare epaper screen with red color management
On you yaml file you add:

external_components:
  - source:
      type: git
      url: https://github.com/parats15/esphome.git
      ref: waveshare-color
    components: [ waveshare_epaper ]

color:
  - id: COLOR_RED
    red: 100%
    green: 0%
    blue: 0%
    white: 0%`

display:
  - platform: waveshare_epaper
    model: 7.50inv2b
    [....]

For the colors:

  • Black : COLOR_ON
  • White : COLOR_OFF
  • Red : COLOR_RED

@AntoineOnnillon
Copy link

AntoineOnnillon commented Dec 14, 2021

#239 (comment)
Morever your epaper sceen is an 800 x 480 px
https://www.waveshare.com/wiki/Pico-ePaper-7.5-B

@TheFitzZZ
Copy link

#239 (comment) @parats15
First of all thank you for adding the color support!

I got my 7.5" screen working with model: 7.50in, but with model: 7.50inv2b it can't update anymore: [E][waveshare_epaper:107]: Timeout while displaying image!

Is the model just wrong in my case and for mine it's not supported yet?

I got this one (driven by a ESP32 driver board):
image

@TheFitzZZ
Copy link

Ah, I got the v1 - which is the lower version. Would you be able to provide the color support for that one as well by any chance @parats15?

@AntoineOnnillon
Copy link

@TheFitzZZ
I updated my branch, now you can use the red color on model: 7.50in
But I haven't this screen so I don't know if this work correctly.
Keep me posted

Also if you have recently adding the external component, add refresh: 1min in external_components:
https://esphome.io/components/external_components.html

@TheFitzZZ
Copy link

@parats15 thanks for the swift response (and refresh hint)!

The red does work, yet now I have vertical "interlacing" lines:
image

Any chance to fix that? Also please drop me your paypal or so, that I can buy you a drink :-)

@AntoineOnnillon
Copy link

Yes think I found my mistake,
I pushed fix

I updated my bio on my github page, Thank

@EDelsman
Copy link

EDelsman commented May 13, 2024

I did not mean to suggest it merely left out red refresh, but I'm pretty sure it did. Leaving red refresh out means you cannot have the same short refresh time with red support.

Also, the specs say the screen needs 26sec for a full refresh, and it does not support partial refresh. The waveshare demo also takes long to refresh. So Waveshare says a longer refresh is needed.

Of course the driver is on control of refresh. So I do not doubt you can shorten the refresh by altering the driver. I experienced the v3 implementation did. But Waveshare would not exaggerate display refresh time. If they say 26sec, and no partial refresh, they have a reason for it. So doing less comes at a cost. Most likely loss of contrast, which I also experienced really soon.

The TL/DR version: hoping for a display implementation with as short a refresh time and red support is unlikely, and if you do it will not be implemented the way Waveshare thinks the display should be used. It is hard to tell what the long term effects will be.

@NOTORIOUSVR
Copy link

2024.5.0 just broke this AGAIN

@EDelsman
Copy link

EDelsman commented May 15, 2024

Thanks for the heads up. Which repository are you using?

@NOTORIOUSVR
Copy link

Using Atomic Mikes here:

  url: https://github.com/atomicmike/esphome.git
  ref: waveshare-color-2023.12
components: [ waveshare_epaper ]

@atomicmike
Copy link

@NOTORIOUSVR What issue are you seeing? I'm on 2024.5.0 and it's working fine for me so far.

@NOTORIOUSVR
Copy link

@NOTORIOUSVR What issue are you seeing? I'm on 2024.5.0 and it's working fine for me so far.

@atomicmike I wouldn't compile with an error - however I just noticed that I actually was pointing to 2023.10 instead of 2023.12 which does work!

Thanks and sorry!

@atomicmike
Copy link

Glad it was an easy fix! :)

@Fiiti
Copy link

Fiiti commented May 20, 2024

Am I right, that other Diplays, e. g. the waveshare black/white/yellow 4.2in is not working with this solution?

I tried:

`
...
external_components:

color:

  • id: COLOR_YELLOW
    red: 100%
    green: 100%
    blue: 0%
    white: 0%
    ...

    it.print(10, 114, id(main_sensor_unit), TextAlign::BASELINE_LEFT, "some text", COLOR_YELLOW);
    ...

But I get compilererror

`


HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
    Dependency Graph
    |-- AsyncTCP-esphome @ 2.1.3
    |-- WiFi @ 2.0.0
    |-- FS @ 2.0.0
    |-- Update @ 2.0.0
    |-- ESPAsyncWebServer-esphome @ 3.1.0
    |-- DNSServer @ 2.0.0
    |-- ESPmDNS @ 2.0.0
    |-- SPI @ 2.0.0
    Compiling .pioenvs/terrasse-e-paper/src/esphome/components/waveshare_epaper/waveshare_epaper.cpp.o
    Compiling .pioenvs/terrasse-e-paper/src/main.cpp.o
    src/main.cpp: In function 'void setup()':
    src/main.cpp:4050:62: error: invalid new-expression of abstract class type 'esphome::waveshare_epaper::WaveshareEPaper4P2In'
    epaperdisplay = new waveshare_epaper::WaveshareEPaper4P2In();
    ^
    In file included from src/esphome.h:48,
    from src/main.cpp:3:
    src/esphome/components/waveshare_epaper/waveshare_epaper.h:165:7: note: because the following virtual functions are pure within 'esphome::waveshare_epaper::WaveshareEPaper4P2In':
    class WaveshareEPaper4P2In : public WaveshareEPaper {
    ^~~~~~~~~~~~~~~~~~~~
    In file included from src/esphome.h:17,
    from src/main.cpp:3:
    src/esphome/components/display/display.h:585:23: note: 'virtual esphome::display::DisplayType esphome::display::Display::get_display_type()'
    virtual DisplayType get_display_type() = 0;
    ^~~~~~~~~~~~~~~~
    *** [.pioenvs/terrasse-e-paper/src/main.cpp.o] Error 1
    ========================= [FAILED] Took 12.67 seconds =========================`

    `

@trip5
Copy link

trip5 commented May 25, 2024

Figured I'd link to my projects here if anyone is thinking about what these things can actually be used for. The WeatherBoard was mostly for wife-approval factor and the TasksBoard is right next to it.

https://github.com/trip5/ESPHome-eInk-Boards

@ceddimag
Copy link

ceddimag commented Jun 9, 2024

Am I right, that other Diplays, e. g. the waveshare black/white/yellow 4.2in is not working with this solution?

I tried:

` ... external_components:

* source:
  type: git
  url: https://github.com/atomicmike/esphome.git
  ref: waveshare-color-2023.12
  components: [ waveshare_epaper ]

color:

* id: COLOR_YELLOW
  red: 100%
  green: 100%
  blue: 0%
  white: 0%
  ...
  it.print(10, 114, id(main_sensor_unit), TextAlign::BASELINE_LEFT, "some text", COLOR_YELLOW);
  ...

But I get compilererror

`

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

* toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
  Dependency Graph
  |-- AsyncTCP-esphome @ 2.1.3
  |-- WiFi @ 2.0.0
  |-- FS @ 2.0.0
  |-- Update @ 2.0.0
  |-- ESPAsyncWebServer-esphome @ 3.1.0
  |-- DNSServer @ 2.0.0
  |-- ESPmDNS @ 2.0.0
  |-- SPI @ 2.0.0
  Compiling .pioenvs/terrasse-e-paper/src/esphome/components/waveshare_epaper/waveshare_epaper.cpp.o
  Compiling .pioenvs/terrasse-e-paper/src/main.cpp.o
  src/main.cpp: In function 'void setup()':
  src/main.cpp:4050:62: error: invalid new-expression of abstract class type 'esphome::waveshare_epaper::WaveshareEPaper4P2In'
  epaperdisplay = new waveshare_epaper::WaveshareEPaper4P2In();
  ^
  In file included from src/esphome.h:48,
  from src/main.cpp:3:
  src/esphome/components/waveshare_epaper/waveshare_epaper.h:165:7: note:   because the following virtual functions are pure within 'esphome::waveshare_epaper::WaveshareEPaper4P2In':
  class WaveshareEPaper4P2In : public WaveshareEPaper {
  ^~~~~~~~~~~~~~~~~~~~
  In file included from src/esphome.h:17,
  from src/main.cpp:3:
  src/esphome/components/display/display.h:585:23: note: 	'virtual esphome::display::DisplayType esphome::display::Display::get_display_type()'
  virtual DisplayType get_display_type() = 0;
  ^~~~~~~~~~~~~~~~
  *** [.pioenvs/terrasse-e-paper/src/main.cpp.o] Error 1
  ========================= [FAILED] Took 12.67 seconds =========================`
  `

Hello,
I have the same type 4.2 V2 model B, B/W/R and unfortunately i think this size is not supported.
I have an error with , 4.20in-bV2 / 4.20inv2b / 4.20inV2 / etc...

@wolfinabox
Copy link

Anyone have a solution now for good red support on the 7.50in-bV3? Tried twisterss' repo and while it does support red (if I use 7.50in-bV2-rb as the model instead), but flickers like crazy for a good few seconds when refreshing.

@trip5
Copy link

trip5 commented Jul 2, 2024

but flickers like crazy for a good few seconds when refreshing.

It's supposed to be this way. The red requires a 20-ish second refresh by the manufacturer's spec. I think that info is upward in this thread. If it's not, you know now. If you want a faster refresh, you can use the non-tri-color ESPHome driver and it can refresh in 2s.

There are some good videos on color eInk and why it is this way. My bet is that there are no red pixels but rather the pixels themselves are tricolor.

The fast refresh color eInk screens have CMY pixels similar to how monitors have RGB pixels.

@tvdhorst
Copy link

tvdhorst commented Jul 2, 2024

I'm not sure these are the same things you are referring to @trip5? I understand the refresh time is longer, but the flickering is consistent between the code with AND without implementation of the red color. This seems to be more of a result of a slight mismatch of the code with the way the v3 hardware version works (the code is for v2).

7.50in-bV3: no flickering
7.50inv2b: heavy flickering
7.50inv2b with Red color: heavy flickering

@ThomDietrich
Copy link

ThomDietrich commented Jul 2, 2024

Hey @ceddimag and @Fiiti, did you make any progress with this? I have the 4.2 V2 model B as well and didn't get it to work with what was presented here so far. I was always hoping that any of the geniuses here working on e.g. the 7.5in-v2 would eventually also have some tips for us. Did you try re-implementing the changes for the 4.2 model?

@trip5
Copy link

trip5 commented Jul 2, 2024

@tvdhorst Not sure if you're mixing up a bit here. The 7.50inv2b is in atomicmike's repo while twisterss uses 7.50in-bv2-rb - unless something has changed?

Actually I can't be sure of twisterss fork since I've been using atomicmike's. His seems to have a bit of a better result than twisterss. I admit I have a V2 but I played with it a lot and the different drivers. I'm still not sure what you mean by flickering as the refresh itself does tend to flicker anyways...? It's not a bad idea to post a video link (youtube or whatever) here and get other folks to take a look and see what exactly you mean.

BTW here's my 2 variations of my YAMLs for you to compare with yours. Please note the difference in model names and reset duration. About a year ago, I did fiddle with the reset duration a bit, going as low as 1ms and high as 10ms. It can't hurt the display by trying to raise the value by 1ms. But I do remember too high or too low had side-effects.

# use atomicmike's repo:
external_components:
  - source:
      type: git
      url: https://github.com/atomicmike/esphome.git
      ref: waveshare-color-2023.12
    components: [ waveshare_epaper ]

display:
  - platform: waveshare_epaper
    id: eink_display
    cs_pin:
      number: GPIO15
      ignore_strapping_warning: true
    dc_pin: GPIO27
    busy_pin:
      number: GPIO25
      inverted: "true"
    model: 7.50inv2b
    reset_duration: 3ms
# use twisterss' repo:
  - source:
      type: git
      url:  https://github.com/twisterss/esphome-dev.git
      ref: waveshare-red-black
    components: [ waveshare_epaper ]

display:
  - platform: waveshare_epaper
    id: eink_display
    cs_pin:
      number: GPIO15
      ignore_strapping_warning: true
    dc_pin: GPIO27
    busy_pin:
      number: GPIO25
      inverted: "true"
    model: 7.50in-bv2-rb
    reset_duration: 2ms

In the end, you may be right. There be a code-implementation mismatch between V2 and V3. Likely timing, I'd think. Try both forks and see if one of them works for you.

@wolfinabox
Copy link

Here's an example video showing the "flicker" when refreshing using twisterss' fork.
Using 7.50in-bv2-rb for the model, but I have a 7.50in-bV3 display (and the waveshare universal epaper driver board).

Once it fully refreshes it looks pretty excellent, it just takes about 22-23s to finish. Not sure if this is what's expected.

@trip5
Copy link

trip5 commented Jul 2, 2024

That looks normal to me. Mine all do that initial reverso-black stuff too. I'm curious what other people say, too but I suspect this is normal behavior... at least in ESPHome. A search around Youtube reveals that this type of refresh: https://www.youtube.com/watch?v=_QKtgPaasXA is what Waveshare uses for their demo...

Almost the same but in slow motion (about 30s, so 30-40% slower)... and with a third of the "flashes." The flashes are also responsible for that beautiful contrast (which is lacking in some of the ESPHome drivers).

So, yeah it looks like the drivers that twisterss and atomicmike have added in may not be optimal but... they work, they look great and BTW atomicmike's code might be a bit closer to Waveshare and ESPHome spec than twisterss... I can't remember where I read that he kept up with some spec talk and worked a few tweaks into his code. Not sure what the difference is and can't judge it with eyes alone. Just a gut feeling.

@EDelsman
Copy link

EDelsman commented Jul 2, 2024

The refresh flickering is in line with the time Waveshare says a refresh should take on the three color display. It is a normal looking refresh cycle for this technology.

As for the difference between atomicmike and twistterss: I have a pretty full display, so the display method takes a long time. twisterss implemented a different approach that allows for the display method taking a long time. atomicmike has an implementation really close to the original implementation. For me that experiences timeouts with the display function too long, that I do not have with twisterss.

Why I think this makes a difference to me: with the original implementation, and that of atomicmike, I experience signs of the display not turning off power while idle. Regarless of the inverted pin setting. My educated guess (not proven) is that when the display method takes too long, the code to turn off power to the display isn't called. With twisterss, it is. With that I have no deterioration signs whatsoever, so I'm sure it turns off the power for me. The twisterss implementation also improved over time a display that deteriorated due to the power not turning off.

So, while I think atomicmike did correctly implement power off, it does not work for me because the display method takes too long. Due to the large display, I think that it is hard to avoid that it takes a long time. That is why a stick with the twisterss one. But ymmv, and as i said, I'm not sure if my analysis is correct.

@tvdhorst
Copy link

tvdhorst commented Jul 3, 2024

Thanks for linking to those vids @wolfinabox and @trip5. That gets us on the same page about what we're actually seeing :) This is the exact behaviour that I have. With both atomicmike and twisterss forks and current release version of the 7.50inv2b implementation.

I currently use the release implementation of 7.50in-bV3 with my V3 screen. See gif for how that refreshes. It's much cleaner, less flickering.

trim C5652505-0A33-4036-9870-8437677CF37D

That's why I assumed that all the flickering caused on V3 screens by both 7.50inv2b and 7.50in-bv2-rb implementations, incl. forks that support red, was unexpected and caused by slight mismatch in hardware definitions. Resulting in me beleving a cleaner implementation incl red might be possible :)

@trip5
Copy link

trip5 commented Jul 3, 2024

Well, again, I have 3 V2s and my refresh looks the same as wolfinabox's video. The faster refresh is only possible with BW because the black and white inside a pixel "flip" while the red remains floating. To get a clear red, more weirdness is required.

If you want the visual version, check out Linus explaining how color can work here: https://youtu.be/aVUxxn53mBE?si=9qiIBjIE6xyNTCal&t=85 - this is almost surely how the tricolor displays work and why they take so long to work.

@EDelsman
Copy link

EDelsman commented Jul 3, 2024

The gif above of release implementation of 7.50in-bV3 may flicker less, but in terms of contrast it is very very pale compared to what Twisterss version gives:
image

@peaechan
Copy link

Just found this post. I have this display: https://www.waveshare.com/product/5.79inch-e-paper-module-b.htm Anyone using this? Is this one supported?

Same here! Hope 5.79in B can use with esphome. So painful using Arduino IDE for coding with HA now...

@fusionstream
Copy link

The display is slowly being destroyed regardless of that inverted pin on my display. Anyone else experiencing the same issue?

@EDelsman
Copy link

EDelsman commented Aug 29, 2024

Yes, I had the same, look a few posts up:
#239 (comment)
With twisterss' fork mentioned above the effect is gone, and my very deteriorated display even improved to quite acceptable again after some weeks lying around disconnected and then using twisterss' fork on it. (I do not think the lying around changed much). The replacement display I bought stayed perfect for months now. Why it works better for me is pure speculation, but I stick with what works for me.

@fusionstream
Copy link

Yes, I had the same, look a few posts up: #239 (comment) With twisterss' fork mentioned above the effect is gone, and my very deteriorated display even improved to quite acceptable again after some weeks lying around disconnected and then using twisterss' fork on it. (I do not think the lying around changed much). The replacement display I bought stayed perfect for months now. Why it works better for me is pure speculation, but I stick with what works for me.

Cheers mate. I'll give this a go. Your's is with inverted: true right?

@EDelsman
Copy link

Yes, I have it set to inverted.

@Misiu
Copy link

Misiu commented Sep 13, 2024

@trip5
Copy link

trip5 commented Sep 13, 2024

That's kind of interesting as the SSD1683 is in ESPHome for OLED Screens, is it not? You wouldn't need any external components at all if that's true. I imagine you could just draw to the screen what you need and then send the ESP into sleep mode... So, that's pretty cool.

I just ordered an ESP32 Terminal CrowPanel and I've been playing with it with OpenHASP and it's fantastic. The acrylic around it makes it look wall-worthy. It already has the wife-approval factor even when I haven't finished setting it up (problem being how/where to mount it). They both seem to have an acrylic frame in common and a bit of break-out with buttons and a few GPIOs already exposed... and at a very reasonable price. It's not on their official Aliexpress store yet so it must be pretty new.

@Misiu
Copy link

Misiu commented Sep 13, 2024

That's kind of interesting as the SSD1683 is in ESPHome for OLED Screens, is it not?

SSD1306 is used for OLED - https://esphome.io/components/display/ssd1306.html, but didn't find anything about SSD1683, so I think those are different chips.

I'm waiting for their 5.0 Display - https://www.elecrow.com/esp32-display-5-inch-hmi-display-rgb-tft-lcd-touch-screen-support-lvgl.html, but found the E-paper displays on their website and before I get one I'd like to know if ESPHome supports it.

@Joshyakadamien
Copy link

Joshyakadamien commented Sep 27, 2024

Hi Good People,

Does anyone knows if this might be the right place, or is there anything related to the 3 inch tri-color e-papers maybe?
3inch-e-Paper-Module-G-details-1
https://www.waveshare.com/3inch-e-paper-module-g.htm
MagicMike's does not support this model either unfortunately,
and i find nothing else even remotely similar about the topic...

Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment