esphome / issues

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

SH1106 On SPI Bus First Page Overwriting Last #5333

Open blauvster opened 9 months ago

blauvster commented 9 months ago

The problem

My display required a few weird things to get it looking correct. First was setting the offset to -24 on the Y. Probably has to do with how the chip is connected to the display. Not an ESPHome issue.

The next issue I ran into is the first page (8 sequential rows) of memory written is displayed in the last modified pages area. Not sure what is going on there but adding another write for the first 8 rows fixes it...

ssd1306_spi.cpp:

void HOT SPISSD1306::write_display_data() {
  if (this->is_sh1106_()) {
    for (uint8_t y = 0; y < (uint8_t) this->get_height_internal() / 8; y++) {
      this->command(0xB0 + y);
      this->command(0x02);
      this->command(0x10);
      this->dc_pin_->digital_write(true);
      for (uint8_t x = 0; x < (uint8_t) this->get_width_internal(); x++) {
        this->enable();
        this->write_byte(this->buffer_[x + y * this->get_width_internal()]);
        this->disable();
        App.feed_wdt();
      }
    }
    // Write the first page again... not sure why.
    this->command(0xB0);
    this->command(0x02);
    this->command(0x10);
    this->dc_pin_->digital_write(true);
    for (uint8_t x = 0; x < (uint8_t) this->get_width_internal(); x++) {
      this->enable();
      this->write_byte(this->buffer_[x]);
      this->disable();
      App.feed_wdt();
    }
  } else {
    this->dc_pin_->digital_write(true);
    this->enable();
    this->write_array(this->buffer_, this->get_buffer_length_());
    this->disable();
  }
}

Which version of ESPHome has the issue?

2023.11.6

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP8266

Board

ESP12F

Component causing the issue

SH1106

Example YAML snippet

display:
  - platform: ssd1306_spi
    id: oled
    model: "SH1106 128x64"
    offset_y: -24
    cs_pin: GPIO2
    dc_pin: GPIO4
    lambda: |-
        it.line(0, 0, 6, 0);
        it.line(7, 1, 13, 1);
        it.line(14, 2, 20, 2);
        it.line(21, 3, 27, 3);
        it.line(28, 4, 34, 4);
        it.line(35, 5, 41, 5);
        it.line(42, 6, 48, 6);
        it.line(49, 7, 62, 7);
        it.line(63, 63, 127, 63);
      }

Anything in the logs that might be useful for us?

I do not think so.

Additional information

No response

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.