[go: up one dir, main page]

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 · 167 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 · 167 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

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

@asmfreak
Copy link
Author
asmfreak commented Oct 5, 2024

To anyone with ESP8266 driver module, willing to use it with 7.5in 3-color epaper. Here is a new rendering engine, which can run on resource-constrained ESP8266. It uses dithered colors by default.

Warning

This rendering algorithm right now is EXTREMELY slow.
It can take a LOT of time (minutes) to render a screen with lots of grafical elements.
It, though, pales in comparison with display update time (2 minutes).

5190587652640989765

esphome:
  name: epaper
  friendly_name: epaper
  on_boot: 
    then:
      - wait_until:
          wifi.connected:
      - lambda: |-
          ESP_LOGW("main", "on boot");
          id(colDisp).set_ready_for_updates();
          id(colDisp).update();

external_components:
  - source: 
      path: ./components
      type: local

esp8266:
  board: esp12e

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: #KEY

ota:
  - platform: esphome
    password: #KEY

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Epaper Fallback Hotspot"
    password: #PASSWORD

captive_portal:
   
spi:
  - id: spi0
    mosi_pin: GPIO13
    clk_pin: GPIO14

font:
    # gfonts://family[@weight]
  - file: "gfonts://Roboto"
    id: roboto_20
    size: 30

  - file: "gfonts://Material+Symbols+Outlined"
    id: icons_50
    size: 50
    glyphs: ["\U0000e425"] # mdi-timer

image:
  - file: mdi:alert-outline
    id: alert
    resize: 80x80

display:
  - platform: epaper
    id: colDisp
    spi_id: spi0
    dc_pin: GPIO4
    cs_pin: GPIO15
    reset_pin: GPIO2
    busy_pin: GPIO5
    lambda: |
      using namespace esphome::waveshare_epaper::elements;
      using namespace esphome::display;
      it.fill(COLOR_OFF);

      // Turn a single pixel off at [50,60]
      it.elements.draw_pixel_at(50, 60, COLOR_OFF);

      it.elements.append_element<LinearGradient>(Rect2D{Point2D{0,0}, Point2D{it.static_width_() ,it.static_height_()}}, 
        Color3{0,0,0}, Color3{255,255,255}
      );
      
      it.print(
          30, it.static_height_()/2+30, roboto_20, COLOR_OFF,
          TextAlign::TOP_LEFT, "hello world", COLOR_ON);
      
      it.print(30, it.static_height_()/2+70, icons_50, COLOR_ON, "\356\220\245");
      
      it.strftime(
          320, 100, roboto_20, "%Y_%m_%dT%H_%M_%S", esphome::ESPTime::from_epoch_local(1728075180));
      
      // it.printf(
      //     300, 100, roboto_20, "%lld ms", it.s);
      // Draw a line from [0,0] to [100,50]
      it.line(0, 0, 100, 50);
      // Draw the outline of a rectangle with the top left at [5,20], a width of 30 and a height of 42
      it.rectangle(5, 20, 30, 42);
      // Draw the same rectangle a few pixels apart, but this time filled
      it.filled_rectangle(40, 40, 30, 42);
      
      // Circles! Let's draw one with the center at [20,40] and a radius of 10
      it.circle(20, 40, 10);
      // ... and the same thing filled again
      it.filled_circle(20, 75, 10);
      
      // Triangles... Let's draw the outline of a triangle from the [x,y] coordinates of its three points
      // [25,5], [100,5], [80,25]
      it.triangle(25, 5, 100, 5, 80, 25);
      // and a filled triangle !
      it.filled_triangle(115, 5, 95, 25, 125, 70);
      
      // Regular Polygons? Let's draw a filled, pointy-topped hexagon inscribed in a circle
      // centered on [170,45] with a radius of 20
      it.filled_regular_polygon(170, 45, 20, EDGES_HEXAGON);
      // and the outline of flat-topped octagon around it!
      it.regular_polygon(170, 45, 40, EDGES_OCTAGON, VARIATION_FLAT_TOP);
      // Need to rotate the polygon, or retrieve the coordinates of its vertices? Check the API!
      
      
      auto black = esphome::Color{0, 0, 0, 0};
      auto red = esphome::Color{255, 0, 0, 0};
      auto green = esphome::Color{0, 255, 0, 0};
      auto blue = esphome::Color{0, 0, 255, 0};
      auto white = esphome::Color{255, 255, 255, 0};
      it.filled_circle(20, 120, 15, black);
      it.filled_circle(40, 120, 15, red);
      it.filled_circle(60, 120, 15, green);
      it.filled_circle(80, 120, 15, blue);
      it.filled_circle(100, 120, 15, white);
      
      it.image(320, 0, alert);

https://github.com/asmfreak/esphome-waveshare-7.5in-epaper-dynamic-render

@Joshyakadamien
Copy link

To anyone with ESP8266 driver module, willing to use it with 7.5in 3-color epaper. Here is a new rendering engine, which can run on resource-constrained ESP8266. It uses dithered colors by default.

Warning

This rendering algorithm right now is EXTREMELY slow. It can take a LOT of time (minutes) to render a screen with lots of grafical elements. It, though, pales in comparison with display update time (2 minutes).

5190587652640989765

esphome:
  name: epaper
  friendly_name: epaper
  on_boot: 
    then:
      - wait_until:
          wifi.connected:
      - lambda: |-
          ESP_LOGW("main", "on boot");
          id(colDisp).set_ready_for_updates();
          id(colDisp).update();

external_components:
  - source: 
      path: ./components
      type: local

esp8266:
  board: esp12e

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: #KEY

ota:
  - platform: esphome
    password: #KEY

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Epaper Fallback Hotspot"
    password: #PASSWORD

captive_portal:
   
spi:
  - id: spi0
    mosi_pin: GPIO13
    clk_pin: GPIO14

font:
    # gfonts://family[@weight]
  - file: "gfonts://Roboto"
    id: roboto_20
    size: 30

  - file: "gfonts://Material+Symbols+Outlined"
    id: icons_50
    size: 50
    glyphs: ["\U0000e425"] # mdi-timer

image:
  - file: mdi:alert-outline
    id: alert
    resize: 80x80

display:
  - platform: epaper
    id: colDisp
    spi_id: spi0
    dc_pin: GPIO4
    cs_pin: GPIO15
    reset_pin: GPIO2
    busy_pin: GPIO5
    lambda: |
      using namespace esphome::waveshare_epaper::elements;
      using namespace esphome::display;
      it.fill(COLOR_OFF);

      // Turn a single pixel off at [50,60]
      it.elements.draw_pixel_at(50, 60, COLOR_OFF);

      it.elements.append_element<LinearGradient>(Rect2D{Point2D{0,0}, Point2D{it.static_width_() ,it.static_height_()}}, 
        Color3{0,0,0}, Color3{255,255,255}
      );
      
      it.print(
          30, it.static_height_()/2+30, roboto_20, COLOR_OFF,
          TextAlign::TOP_LEFT, "hello world", COLOR_ON);
      
      it.print(30, it.static_height_()/2+70, icons_50, COLOR_ON, "\356\220\245");
      
      it.strftime(
          320, 100, roboto_20, "%Y_%m_%dT%H_%M_%S", esphome::ESPTime::from_epoch_local(1728075180));
      
      // it.printf(
      //     300, 100, roboto_20, "%lld ms", it.s);
      // Draw a line from [0,0] to [100,50]
      it.line(0, 0, 100, 50);
      // Draw the outline of a rectangle with the top left at [5,20], a width of 30 and a height of 42
      it.rectangle(5, 20, 30, 42);
      // Draw the same rectangle a few pixels apart, but this time filled
      it.filled_rectangle(40, 40, 30, 42);
      
      // Circles! Let's draw one with the center at [20,40] and a radius of 10
      it.circle(20, 40, 10);
      // ... and the same thing filled again
      it.filled_circle(20, 75, 10);
      
      // Triangles... Let's draw the outline of a triangle from the [x,y] coordinates of its three points
      // [25,5], [100,5], [80,25]
      it.triangle(25, 5, 100, 5, 80, 25);
      // and a filled triangle !
      it.filled_triangle(115, 5, 95, 25, 125, 70);
      
      // Regular Polygons? Let's draw a filled, pointy-topped hexagon inscribed in a circle
      // centered on [170,45] with a radius of 20
      it.filled_regular_polygon(170, 45, 20, EDGES_HEXAGON);
      // and the outline of flat-topped octagon around it!
      it.regular_polygon(170, 45, 40, EDGES_OCTAGON, VARIATION_FLAT_TOP);
      // Need to rotate the polygon, or retrieve the coordinates of its vertices? Check the API!
      
      
      auto black = esphome::Color{0, 0, 0, 0};
      auto red = esphome::Color{255, 0, 0, 0};
      auto green = esphome::Color{0, 255, 0, 0};
      auto blue = esphome::Color{0, 0, 255, 0};
      auto white = esphome::Color{255, 255, 255, 0};
      it.filled_circle(20, 120, 15, black);
      it.filled_circle(40, 120, 15, red);
      it.filled_circle(60, 120, 15, green);
      it.filled_circle(80, 120, 15, blue);
      it.filled_circle(100, 120, 15, white);
      
      it.image(320, 0, alert);

https://github.com/asmfreak/esphome-waveshare-7.5in-epaper-dynamic-render

Cool stuff, thank you for sharing. :)
Do you know please if there is anything similar for the 3 inch "G" (R,B,Y,W)modules perhaps?

@asmfreak
Copy link
Author

@Joshyakadamien Can you please specify (with links to waveshare site), which ESP module and epaper display do you use?

@Joshyakadamien
Copy link

@Joshyakadamien Can you please specify (with links to waveshare site), which ESP module and epaper display do you use?

Sure Sir, this one:
I tried to look into custom components, but i'm fairly new to C and it seems a big bite for a newbie so far.

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.

@asmfreak
Copy link
Author

@Joshyakadamien Your module is ESP-independent (as it includes the driver IC onboard). You can use any ESP board with SPI interface (ESP8266 or ESP32). I'm not sure, but I think your device's screen buffer should fit in even in ESP8266 memory (in my case with 7.5inch screen it does not). For you, the screen buffer will consume 400*168/4=16800 bytes of memory, whereas ESP8266 has 80K of RAM. In vanilla ESPHome EPD implementation, you wont (AFAIK) get dithering of colors. I'm not sure, if this display is supported. It should, though, be pretty simple to implement.

@Joshyakadamien
Copy link
Joshyakadamien commented Oct 23, 2024

@Joshyakadamien Your module is ESP-independent (as it includes the driver IC onboard). You can use any ESP board with SPI interface (ESP8266 or ESP32). I'm not sure, but I think your device's screen buffer should fit in even in ESP8266 memory (in my case with 7.5inch screen it does not). For you, the screen buffer will consume 400*168/4=16800 bytes of memory, whereas ESP8266 has 80K of RAM. In vanilla ESPHome EPD implementation, you wont (AFAIK) get dithering of colors. I'm not sure, if this display is supported. It should, though, be pretty simple to implement.

Thank you for the info and explanation.
I did not knew the technical details but i got it running with the example code on esp32.
On 8266 as i have d1 mini and it would require modding the disp from 4 line spi which i do not want to.
Unfortunately it is not supported in vanilla esphome
which sent me down google's path to find custom components developed for some models, (but not the 3 inch model g)
and this thread with same manufacturer, color capabilities but different resolutions.

Basically i tried dissect the examples given by manufacturer to create my own custom comp.
But that much i do not understand the code, and i cannot begin reverse engineering the driver.

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