ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
ssd1306_spi.cpp
Go to the documentation of this file.
1#include "ssd1306_spi.h"
2#include "esphome/core/log.h"
4
5namespace esphome {
6namespace ssd1306_spi {
7
8static const char *const TAG = "ssd1306_spi";
9
11 this->spi_setup();
12 this->dc_pin_->setup(); // OUTPUT
13
14 this->init_reset_();
15 SSD1306::setup();
16}
18 LOG_DISPLAY("", "SPI SSD1306", this);
19 ESP_LOGCONFIG(TAG, " Model: %s", this->model_str_());
20 LOG_PIN(" CS Pin: ", this->cs_);
21 LOG_PIN(" DC Pin: ", this->dc_pin_);
22 LOG_PIN(" Reset Pin: ", this->reset_pin_);
23 ESP_LOGCONFIG(TAG,
24 " External VCC: %s\n"
25 " Flip X: %s\n"
26 " Flip Y: %s\n"
27 " Offset X: %d\n"
28 " Offset Y: %d\n"
29 " Inverted Color: %s",
30 YESNO(this->external_vcc_), YESNO(this->flip_x_), YESNO(this->flip_y_), this->offset_x_,
31 this->offset_y_, YESNO(this->invert_));
32 LOG_UPDATE_INTERVAL(this);
33}
34void SPISSD1306::command(uint8_t value) {
35 this->dc_pin_->digital_write(false);
36 this->enable();
37 this->write_byte(value);
38 this->disable();
39}
41 if (this->is_sh1106_() || this->is_sh1107_()) {
42 for (uint8_t y = 0; y < (uint8_t) this->get_height_internal() / 8; y++) {
43 this->command(0xB0 + y);
44 if (this->is_sh1106_()) {
45 this->command(0x02);
46 } else {
47 this->command(0x00);
48 }
49 this->command(0x10);
50 this->dc_pin_->digital_write(true);
51 for (uint8_t x = 0; x < (uint8_t) this->get_width_internal(); x++) {
52 this->enable();
53 this->write_byte(this->buffer_[x + y * this->get_width_internal()]);
54 this->disable();
55 App.feed_wdt();
56 }
57 }
58 } else {
59 this->dc_pin_->digital_write(true);
60 this->enable();
61 this->write_array(this->buffer_, this->get_buffer_length_());
62 this->disable();
63 }
64}
65
66} // namespace ssd1306_spi
67} // namespace esphome
void feed_wdt(uint32_t time=0)
virtual void setup()=0
virtual void digital_write(bool value)=0
void command(uint8_t value) override
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
Application App
Global storage of Application pointer - only one Application can exist.
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6