esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

Waveshare 7.5in V2 e-paper dim and grainy when using lines or rectangles #2216

Closed TheStork239 closed 1 year ago

TheStork239 commented 3 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

Hass.io

ESP (ESP32/ESP8266, Board/Sonoff):

ESP32 Waveshare Driver Board

ESPHome version (latest production, beta, dev branch)

1.19.4

Affected component:

Waveshare e-paper display https://esphome.io/components/display/waveshare_epaper.html

Description of problem:

All items on a Waveshare 7.5in V2 e-paper display (black & white) go dim and grainy if the items to be displayed include horizontal lines, rectangles or filled rectangles. The wider the line or rectangle, the more marked the effect is. Other shapes or text do not cause the issue.

Below is example code that has the issue. If I comment out the "it.filled_rectangle" lines in the code, then the text on screen becomes crisp and clear, but if the rectangles are included, when the screen refreshes, for a split second on refresh it is clear but the black 'ink' dims out instantly. The issue is exactly the same if I use "it.line" or "it.rectangle" of similar dimensions.

If I only use very short horizontal lines or rectangles then the issue is less noticeable, but for long horizontal lines and rectangles the entire display goes dim. IMG_1899

Problem-relevant YAML-configuration entries:

esphome:
  name: cabin-epaper
  platform: ESP32
  board: esp32dev
  on_boot:
    priority: -10
    then:
      - delay: 10s
      - component.update: epaperdisplay

wifi:
  networks:
  - ssid: [removed]
    password: [removed]

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: [removed]

font:
  - file: 'fonts/Roboto-Regular.ttf'
    id: footer_font
    size: 15
    glyphs:
      ['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
       '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
       'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
       'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
       'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
       'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³']

  - file: 'fonts/Roboto-Regular.ttf'
    id: main_sensor_unit
    size: 20
    glyphs:
      ['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
       '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
       'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
       'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
       'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
       'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³']

  - file: 'fonts/Roboto-Bold.ttf'
    id: main_sensor_font
    size: 54
    glyphs:
      ['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
       '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
       'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
       'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
       'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
       'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³']

  - file: 'fonts/materialdesignicons-webfont.ttf'
    id:  mdi_wifi
    size: 20
    glyphs: [
      # Wifi
      '󰤫', # mdi-wifi-strength-alert-outline
      '󰤟', # mdi-wifi-strength-1
      '󰤢', # mdi-wifi-strength-2
      '󰤥', # mdi-wifi-strength-3
      '󰤨'  # mdi-wifi-strength-4
      ]

time:
  - platform: homeassistant
    id: homeassistant_time

sensor:
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    id: wifisignal
    update_interval: 60s

spi:
  clk_pin: 13   #SCK
  mosi_pin: 14  #DIN

display:
  - platform: waveshare_epaper
    id: epaperdisplay
    cs_pin: 15
    dc_pin: 27
    busy_pin: 25
    reset_pin: 26
    update_interval: 600s
    model: 7.50inV2
    lambda: |-

      static const char* TAG = "epaperdisplay";
      ESP_LOGD(TAG, "Writing to e-ink display");

      it.print(775, 17, id(main_sensor_unit), TextAlign::BASELINE_RIGHT, "E-Paper is awesome!");
      it.print(0, 460, id(main_sensor_unit), "E-Paper is awesome!");

      /* TOP */
      it.print(10, 10, id(main_sensor_unit), "TOP");
      it.filled_rectangle(98, 21, 400, 3);
      it.print(15, 60, id(main_sensor_font), "Test 1");

      /* MIDDLE */
      int offsetY = 200;
      it.print(10, 10 + offsetY, id(main_sensor_unit), "MIDDLE");
      it.filled_rectangle(98, 21 + offsetY, 500, 3);
      it.print(400, 80 + offsetY, id(main_sensor_font), TextAlign::BASELINE_CENTER, "Test 2");

      /* BOTTOM */
      int offsetYb = 360;
      it.print(10, 10 + offsetYb, id(main_sensor_unit), "BOTTOM");
      it.filled_rectangle(98, 21 + offsetYb, 600, 3);
      it.print(775, 80 + offsetYb, id(main_sensor_font), TextAlign::BASELINE_RIGHT, "Test 3");

      /* FOOTERT */
      it.strftime(755, 475 , id(footer_font), TextAlign::BASELINE_RIGHT , "Updated at %d/%b/%Y %H:%M", id(homeassistant_time).now());

      /* WiFi Signal Strenght */
      if(id(wifisignal).has_state()) {
        int x = 775;
        int y = 475;
        if (id(wifisignal).state >= -50) {
            //Excellent
            it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤨");
            ESP_LOGI("WiFi", "Exellent");
        } else if (id(wifisignal).state  >= -60) {
            //Good
            it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤥");
            ESP_LOGI("WiFi", "Good");
        } else if (id(wifisignal).state  >= -75) {
            //Fair
            it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤢");
            ESP_LOGI("WiFi", "Fair");
        } else if (id(wifisignal).state  >= -100) {
            //Weak
            it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤟");
            ESP_LOGI("WiFi", "Weak");
        } else {
            //Unlikely working signal
            it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤫");
            ESP_LOGI("WiFi", "Unlikely");
        }
      }

Logs (if applicable):

The logs do not display any errors.

Additional information and things you've tried: I have tried this with two separate Waveshare 7.5in V2 e-paper displays, and two separate ESP32 driver boards, and get the same results for each combination, so it does not seem to be a faulty hardware issue.

EagleStClair commented 1 year ago

@prapador fix seems to work here as well, hopefully it will not gradually faint with time as have been my main issue with other configurations.

prapador commented 1 year ago

Just mentioning that all credits go to @Egglestron changes are not mine :)

napalmz commented 1 year ago

I made some test, basically leaving it on for 20h straight.

This is after 10h of refresh (one every 5 min): IMG_6259

This is after 20h (same 5m refresh): IMG_6261

Detail: IMG_6260

Far better than before but not "perfect".

prapador commented 1 year ago

I haven't experienced any degradation issues during this past week, and in my case, the contrast is excellent. I believe we should submit a pull request to the ESPhome repository if no one has detected any problems. What do you think?

Draexl commented 1 year ago

I can't install... That is the Log Output: INFO Generating C++ source... Traceback (most recent call last): File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/bin/esphome", line 8, in sys.exit(main()) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 965, in main return run_esphome(sys.argv) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 952, in run_esphome rc = POST_CONFIG_ACTIONS[args.command](args, config) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 397, in command_run exit_code = write_cpp(config) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 178, in write_cpp generate_cpp_contents(config) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 190, in generate_cpp_contents CORE.flush_tasks() File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/core/init.py", line 622, in flush_tasks self.event_loop.flush_tasks() File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/coroutine.py", line 246, in flush_tasks next(task.iterator) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 170, in wrapped await coro(conf) File "/opt/iobroker/iobroker-data/esphome.0/.esphome/external_components/fc00875a/esphome/components/waveshare_epaper/display.py", line 156, in to_code config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void AttributeError: module 'esphome.components.display' has no attribute 'DisplayRef'

I used this:

external_components:

prapador commented 1 year ago

I can't install... That is the Log Output: INFO Generating C++ source... Traceback (most recent call last): File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/bin/esphome", line 8, in sys.exit(main()) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 965, in main return run_esphome(sys.argv) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 952, in run_esphome rc = POST_CONFIG_ACTIONS[args.command](args, config) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 397, in command_run exit_code = write_cpp(config) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 178, in write_cpp generate_cpp_contents(config) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 190, in generate_cpp_contents CORE.flush_tasks() File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/core/init.py", line 622, in flush_tasks self.event_loop.flush_tasks() File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/coroutine.py", line 246, in flush_tasks next(task.iterator) File "/opt/iobroker/node_modules/iobroker.esphome/python_modules/lib/python3.9/site-packages/esphome/main.py", line 170, in wrapped await coro(conf) File "/opt/iobroker/iobroker-data/esphome.0/.esphome/external_components/fc00875a/esphome/components/waveshare_epaper/display.py", line 156, in to_code config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void AttributeError: module 'esphome.components.display' has no attribute 'DisplayRef'

I used this:

external_components:

Make sure that you have at least version 2023.6.5.

Draexl commented 1 year ago

Perfect, that was the problem. THX :-)

Egglestron commented 1 year ago

I'm currently making a pull request with my latest changes. I'll keep you posted!

requiemmg commented 1 year ago

Here also no problems. Tried both changes, didnt make a difference fie me, all good.