esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
292 stars 36 forks source link

Waveshare ePaper 2.9" Rev2.1 - flickering screen refreshing problem. #2334

Open dougle03 opened 3 years ago

dougle03 commented 3 years ago

The problem

Following the example within the ESPHome.io page https://next.esphome.io/components/display/waveshare_epaper.html I've paired up a Waveshare ePaper 2.92 board version 2.1 to a Wemos D1 Mini and loaded the code. I get the basic itprint text on boot up, but on next refresh the screen shows noise, then flashes the correct display then fades to nearly nothing until the next refresh where the cycle repeats. image

Which version of ESPHome has the issue?

2021.9.0-dev

What type of installation are you using?

Docker

Which version of Home Assistant has the issue?

Not applicable

What platform are you using?

ESP8266

Board

Wemos D1 (Clone)

Component causing the issue

Waveshare ePaper 2.9" rev2.1

Example YAML snippet

yaml below.

spi:
  clk_pin: D0
  mosi_pin: D1
  #miso_pin: D7 #not connected
display:
  - platform: waveshare_epaper
    cs_pin: D2
    dc_pin: D3
    busy_pin: D4
    reset_pin: D5
    model: 2.90inv2
    #id: mydisplay
    update_interval: 30s
    full_update_every: 180
    rotation: 90°
    #brightness: 100%
    lambda: |-
      //Header
      it.strftime(0, 0, id(font4), TextAlign::TOP_LEFT, "%a %H:%M", id(esptime).now());
      it.print(0, 50, id(font3), "TESTING");

### Anything in the logs that might be useful for us?

```txt
Nothing in the logs of note.

Additional information

https://user-images.githubusercontent.com/59865048/130116613-ad30d677-3dce-4061-958c-a3fba39d5742.mp4

dougle03 commented 3 years ago

Note: powered by a lab bench power supply to the USB of the D1. Ground and 3.3v from the D1's pins.

ephirial commented 3 years ago

Hey, I can confirm this behaviour. I have tested the same display with a Wemos D1 and I have the same issue. I have tested a bunch of different pin configurations, all with the same result. I have also tested it on a ESP32, also with the same issue.

dougle03 commented 3 years ago

Seems like it's an actual bug then. It's a shame as I have plans for this display.

swifty99 commented 3 years ago

Hi, same here on a 1.54 display with ESP32.

To mitigate the problem I use:

on_boot: priority: 700

code formatting is somewhat broken, CR go missing, sorry

dougle03 commented 3 years ago

Thanks, I'll give that a go when I get home ;)

dougle03 commented 3 years ago

Just need to get home now to try it! image

dkagedal commented 3 years ago

I have this problem as well. I'm not sure how the code above was meant to help, other than to try to update the display "enough times". Anyway it didn't help to me.

Looking at the code, and at the specs and examples from Waveshare, I'm wondering about the code at https://github.com/esphome/esphome/blob/8f3a739da77e06b5ef18115248ee469ed0caa95f/esphome/components/waveshare_epaper/waveshare_epaper.cpp#L375

Should't there be a call to this->wait_until_idle_() after the Master Activation command?

And what is the 0xFF command? I didn't find that in the specs.

dkagedal commented 3 years ago

Tried adding that, and it didn't help. But I don't really know what I'm doing here.

dougle03 commented 3 years ago

It does look like there is a bug in the module that's presumably messing up the refresh process. People have these displays working fine using Arduino IDE and the libs available; but the ESPHome implementation does not work properly with v2.1 screens. I've tried to buy a v2 screen but can't find them anywhere on sale. Perhaps the original dev would take a look at some point? Anyone know who the dev was? blambov and jesserockz

balloob commented 3 years ago

Please do not tag random people to get attention to your issue.

dkagedal commented 3 years ago

It seems to get it right when redrawing it initially after boot, but later refreshes are corrupted. So I tried

    full_update_every: 1

And that solved the issue!

dougle03 commented 3 years ago

Please do not tag random people to get attention to your issue. Sorry, did not mean to tag you, was attempting to tag the original dev for the mod. Apologies again.

dougle03 commented 3 years ago

It seems to get it right when redrawing it initially after boot, but later refreshes are corrupted. So I tried

    full_update_every: 1

And that solved the issue!

Excellent, will give that a try later this evening. Thanks

dougle03 commented 3 years ago

full_update_every: 1

That did it. Now it's stable. Thanks very much. I'll close this issue now, but I suspect a change is needed to the ESPHome docs page.

dkagedal commented 3 years ago

This is really just a workaround. The problem remains that partial updates are broken, so i think we can keep this issue open

dougle03 commented 3 years ago

Yes, I agree. I only closed because it solved my immediate problem, but yes, having it flicker in the corner of my eye every 15 seconds is pretty annoying... Looks like there is a PR going through (not by me) to update the documentation to 1 rather than fixing the underlying problem...

LukasK13 commented 3 years ago

Please reopen this issue. The problem is not only the text being blurry but also the flickering during the partial update which should not occur. Definitely not resolved.

dougle03 commented 3 years ago

Reopened to resolve the issues

LukasK13 commented 3 years ago

@K-r-i-s-t-i-a-n you implemented esphome/esphome#1538. Did this work with v2?

Dianoga commented 3 years ago

I'm seeing this exact same issue. Same screen hooked up to a D1 mini 32 clone exhibiting the same effect. I also tried switching to a Heltec Wifi kit 32 to see if it was board specific but the same issue is still happening.

dougle03 commented 3 years ago

If you change full_update_every: 1 then the issue resolves, but it's annoying having the whole screen do a full refresh every update.

Dianoga commented 3 years ago

Partial update is the entire reason I'm using this screen. Currently I'm looking at the differences between the code generated by esphome and the sample code provided by waveshare as the sample code is properly working with the partial refresh.

Dianoga commented 3 years ago

I don't have it working and have in fact made everything worse (full updates don't work either) but as best as I can tell right now these changes should match the behavior of the example code from waveshare.

https://github.com/Dianoga/esphome/commit/696d319d4baca2884c576eb48be57edd31d5eea8

dougle03 commented 3 years ago

My yaml that now works, although a full refresh is done every 15 seconds (Which is a bit rubbish).

spi:
  clk_pin: D0
  mosi_pin: D1 #DIN
  #miso_pin: D7 #not connected
display:
  - platform: waveshare_epaper
    cs_pin: D2
    dc_pin: D6
    busy_pin: D7
    reset_pin: D5
    model: 2.90inv2
    id: mydisplay
    update_interval: 15s
    full_update_every: 1
    rotation: 90
    lambda: |-
LukasK13 commented 3 years ago

I had a look at the example code here and the (incomplete) manual here and implemented a hacky fix for the artial update. Unfortunately, a partial update has to be done 2 s after each full update in order to make the first partial update work. Therefore I had to include a 2 s delay in the code which is rather unprofessional. You can find my fix here.

Dianoga commented 2 years ago

How do we get a fix merged into esphome? I don't have enough C knowledge to put together a PR that I would have any faith in. @LukasK13 are you able to submit a PR with your changes? Even if it's not a perfect fix it would be better then the broken we have now.

joekeslar commented 2 years ago

Is there a status on the merged fix?

Tookir commented 2 years ago

Hi,

Same problem here, I just bought it for a project, it annoys me a little since it is not marked that it does not work in v2.1. Anyone have a solution, other than a total refresh?

emdekext commented 2 years ago

I agree, please fix this asap, thanks. There's also another open issue, it seems exactly the same problem link issue #2459

Kaibob2 commented 2 years ago

I just bought a 2.9" Waveshare E-Ink Panel V2 and seeing the exact same behaviour as pictured in the start post. Reducing full_update_every: to 1 fixes the grainy display, but a full update is not what the display is intended for.

stephenjamieson commented 2 years ago

Just wanted to say, I merged the above locally and the issue is fixed on my v2.1 screen

Kaibob2 commented 2 years ago

Meanwhile I also added the above as local external_component and this fixed the issue almost perfectly. The mentioned 2 seconds delay (in the original thread) in the partial update code make buttons pretty unresponsive when a lot of display updates occur while pressing them, but that's not a real problem.

Tookir commented 2 years ago

Can you share you esp code for exemple Kaibob2 ? I try to add id by external_component github link but it's not working. (errors at compilation). Thanks for your help.

Kaibob2 commented 2 years ago

This is what you can use:

external_components:
  - source:
      type: git
      url: https://github.com/velaar/esphome
      ref: dev
    components: [ waveshare_epaper]

When you have ESPhome 2022.6.0 or newer installed you will need display also additional as external component as there was a breaking change from that version onwards. Add display_type property to DisplayBuffer https://github.com/esphome/esphome/pull/3430 by [@guillempages](https://github.com/guillempages) (breaking-change) In that case it would be like this then:

external_components:
  - source:
      type: git
      url: https://github.com/velaar/esphome
      ref: dev
    components: [ waveshare_epaper, display]
Kaibob2 commented 2 years ago

Another option would be to download the git repository and copy the display and waveshare folder into a folder of your choice in the esphome directory. In my case it's named my_components. All components in this directory will then be used instead of the default ones during compilation. This method makes the source code a little more independent from changes in a repository of someone else. If you decide to do so it will be like that:

external_components:
  - source:
      type: local
      path: /config/esphome/my_components
joekeslar commented 2 years ago

Thanks @Kaibob2. I copied the waveshare_epaper folder from the repo into my local as you suggested. Didn't previously know about the external_components feature, so happy to learn that today. The update has also solved the problem for me. I set my variables as follows:

reset_duration: 2ms
update_interval: 1s
full_update_every: 3600

Everything seems to be working as expected now. In my case, 1s update interval hasn't caused any delay with my buttons or any other functionality, although I also don't have much info changing on the display in a single refresh either.

Not sure why this hasn't been merged, but happy to have a fix at the moment.

Kaibob2 commented 2 years ago

Glad I could help. I'm very thankful for this fix, too. Most of the info on my display is not time critical either, the few info which is I perform a manual update with component.update as soon as a new value arrives. My standard values are:

reset_duration: 200ms
update_interval: 30s
full_update_every: 200
Tookir commented 2 years ago

Thanks a lot @Kaibob2 and @joekeslar , all is working fine now with your exemple code. I think my mistake was not include Display lib ( i'm in 2022.06.XX ).

Have a nice day !

remyderuysscher commented 1 year ago

This is what you can use:

external_components:
  - source:
      type: git
      url: https://github.com/velaar/esphome
      ref: dev
    components: [ waveshare_epaper]

When you have ESPhome 2022.6.0 or newer installed you will need display also additional as external component as there was a breaking change from that version onwards. Add display_type property to DisplayBuffer https://github.com/esphome/esphome/pull/3430 by [@guillempages](https://github.com/guillempages) (breaking-change) In that case it would be like this then:

external_components:
  - source:
      type: git
      url: https://github.com/velaar/esphome
      ref: dev
    components: [ waveshare_epaper, display]

Excellent, spend many hours to debug this screen. This solves it. Should be merged in ESPHome someday.

ExZylan commented 1 year ago

This is what you can use:

external_components:
  - source:
      type: git
      url: https://github.com/velaar/esphome
      ref: dev
    components: [ waveshare_epaper]

When you have ESPhome 2022.6.0 or newer installed you will need display also additional as external component as there was a breaking change from that version onwards. Add display_type property to DisplayBuffer https://github.com/esphome/esphome/pull/3430 by [@guillempages](https://github.com/guillempages) (breaking-change) In that case it would be like this then:

external_components:
  - source:
      type: git
      url: https://github.com/velaar/esphome
      ref: dev
    components: [ waveshare_epaper, display]

Excellent, spend many hours to debug this screen. This solves it. Should be merged in ESPHome someday.

With the latest version of esphome 2023.6.0, this external package no longer works. Any solution?

Compiling the program without the external package still produces errors in the fast screen refresh of my Waveshare 2.9".

I had to revert to an earlier version of esphome to be able to compile the program with the external package.

Kaibob2 commented 1 year ago

Same here.

Kaibob2 commented 1 year ago

The fix is pretty simple if you finally find the breaking change related to this issue: https://github.com/esphome/esphome/pull/4926 So, if you're already using the external component from https://github.com/velaar/esphome and have waveshare_epaper and display integrated like this:

external_components:
  - source:
      type: local
      path: /config/esphome/my_components

then just navigate with a file editor to your my_components folder and change time::ESPTime time to ESPTime time in line 371, 377, 380 and 383 in file display_buffer.cpp

Afterwards do the same in line 241, 253, 265 and 276 in file display_buffer.h

Save both files, click on clean build files in the ESPhome Dashboard for the specific node which won't compile and install like usual.

beyondgrave commented 1 year ago

This almost worked for me. I can now get past the time::ESPTime time error, but now get an error about set_transparency. Are you using any images on your epaper display??

Kaibob2 commented 1 year ago

No, only Icons, lines and Text . Sorry.

beyondgrave commented 1 year ago

Weird. I can't even get icons to work... I guess I'll keep fighting with it

Kaibob2 commented 1 year ago

For the icons i added this

font:
  - file: 'materialdesignicons-webfont.ttf'
    id: icon_font_24
    size: 24
    glyphs: [
      "\U000F1974",  #car-clock
      "\U000F0298",  #gas-station
      "\U000F1077",  #face-woman
      "\U000F0643",  #face-man
      "\U000F050F",  #thermometer
      "\U000F058E",  #water-percent
      "\U000F11DC",  #window-open-variant
      "\U000F06E8",  #lightbulb-on
      "\U000F01AD",  #currency-eur
      "\U000F0D8E",  #mailbox-up-outline
      "\U000F1886"   #mdi-flower-pollen-outline  
      ]

and then use the icons like this:

    pages:
      - id: mainscreen
        lambda: |-
          if (id(online).state){

            //Temperatur Garten
            it.printf(2, 36, id(icon_font_24), "\U000F050F");          
            if (id(t_garten).has_state())
            {              
              it.printf(24, 41, id(arial18), "%.1f°", id(t_garten).state);
            }
          }

Only for example, the whole mainscreen code is huuuge.

beyondgrave commented 1 year ago

Ah, I see. I was using still using the Image function in ESPhome and referring to the mdi-icons. Seems like the custom components don't have support for the new/changed Image features (transparency stuff). Using the Font function as a workaround is very clever. I'll have to try that, but I'll have to do a lot of re-coding

Kaibob2 commented 1 year ago

This whole custom component solution is quite flaky and I guess it will be a constant struggle to keep it working with ongoing changes in the main ESPhome features. I hope that there will be a better supported e-ink display soon. Maybe there is already one available and I just don't know. Good luck and happy re-coding :)

stephenjamieson commented 1 year ago

@jesserockz, apologies for the direct ping, but is there any chance that this will get merged? Or does it need work?

velaar commented 1 year ago

time::ESPTime time

Fixed this in my github version. This manual fix is no longer needed.