feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Support for Waveshare Three-color E-Ink Displays

Open asmfreak opened this issue 6 years ago • 167 comments

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 avatar May 21 '19 11:05 asmfreak

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.

asmfreak avatar May 26 '19 09:05 asmfreak

@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.

OttoWinter avatar May 27 '19 09:05 OttoWinter

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.

sbussinger avatar Jun 19 '19 15:06 sbussinger

@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.

asmfreak avatar Jul 07 '19 00:07 asmfreak

@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.

tommy-hartmann avatar Jul 23 '19 06:07 tommy-hartmann

@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 !!!

minsuke avatar Oct 26 '19 07:10 minsuke

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

Cabbo avatar Aug 23 '20 17:08 Cabbo

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

shacal avatar Nov 08 '20 21:11 shacal

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!

lbonherbe avatar Jan 19 '21 12:01 lbonherbe

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).

brettp avatar Mar 13 '21 22:03 brettp

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

xaxix avatar Mar 27 '21 15:03 xaxix

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

martin3000 avatar Jul 24 '21 14:07 martin3000

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.

oscaropenness avatar Jul 28 '21 07:07 oscaropenness

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

martin3000 avatar Jul 28 '21 07:07 martin3000

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.

henriklied avatar Nov 30 '21 10:11 henriklied

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

parats15 avatar Dec 14 '21 01:12 parats15

https://github.com/esphome/feature-requests/issues/239#issuecomment-888087235 Morever your epaper sceen is an 800 x 480 px https://www.waveshare.com/wiki/Pico-ePaper-7.5-B

parats15 avatar Dec 14 '21 10:12 parats15

https://github.com/esphome/feature-requests/issues/239#issuecomment-993076104 @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 avatar Dec 17 '21 14:12 TheFitzZZ

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?

TheFitzZZ avatar Dec 17 '21 14:12 TheFitzZZ

@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

parats15 avatar Dec 18 '21 09:12 parats15

@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 :-)

TheFitzZZ avatar Dec 18 '21 10:12 TheFitzZZ

Yes think I found my mistake, I pushed fix

I updated my bio on my github page, Thank

parats15 avatar Dec 18 '21 11:12 parats15

I just pushed another little fix ^^

parats15 avatar Dec 18 '21 11:12 parats15

Brilliant! Sent a little "thank you" via PayPal :-) image

TheFitzZZ avatar Dec 18 '21 12:12 TheFitzZZ

So I'm guessing their 7 color displays are out of the question for the moment?

Adrian-at-CrimsonAzure avatar Jan 06 '22 00:01 Adrian-at-CrimsonAzure

Love to see support for the LOLIN 2.13 3-color model. Created feature request already.

Tokn59 avatar Jan 07 '22 08:01 Tokn59

I have implemented red color support for the 4.20in version 1 model. I did a pull request against your version @parats15. Are you considering to do a pull request against the main version? grafik

patman15 avatar Jan 10 '22 13:01 patman15

@patman15 Thank you for adding this screen. It's ok I merged your PR.

parats15 avatar Jan 11 '22 00:01 parats15

@Adrian-at-CrimsonAuzre Yes it's possible to add 7 color control on your screen. Your screen is 600 × 448 × 3bits color => 806400bits in ram. Technically it should work with an ESP32 WROOM 32 board.

Just I need to work in my branch to manage your screen and more than 3 color.

parats15 avatar Jan 11 '22 00:01 parats15

@patman15 Thank you for adding this screen. It's ok I merged your PR.

@parats15 When implementing I noticed a few things:

  1. COLOR_ON is used for drawing on the e-paper which appears black. On the other hand it is defined as const Color COLOR_ON(255, 255, 255, 255); actually meaning the color white. I looked at the implementation for Inkplate6 which uses COLOR_OFF (which seems logic to me as the display draws in black). For me it makes issues when moving code from one display to the other as the behavior is exactly opposite. Also I think it could start making issues when rendering pictures for displays with more colors. Easy to change, not sure what you think.
  2. I had to do a separate class for the B/W/R display although it is practically identically to the B/W display except that it uses the second memory page for the red color. I would have needed a function to query which (not how many) colors exist to just merge it to the class that already does the B/W display. Probably this is an issue more towards the upstream?
  3. The code currently uses a color identity comparison for rendering. I looked at the waveshare documentation on page 7 you can find hints on mappings that would make it a more generic implementation (independent of the supported colors and levels). Nevertheless, it would need a map of colors that a specific display supports.

Let me know if you want me to support you with any of these topics in case you see it the same way. We could also ask the upstream maintainer on how it is intended.

patman15 avatar Jan 11 '22 08:01 patman15