ESPHome 2026.5.0b1
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
6
7static const char *const TAG = "ssd1306_spi";
8
10 this->spi_setup();
11 this->dc_pin_->setup(); // OUTPUT
12
13 this->init_reset_();
14 SSD1306::setup();
15}
17 LOG_DISPLAY("", "SPI SSD1306", this);
18 ESP_LOGCONFIG(TAG,
19 " Model: %s\n"
20 " External VCC: %s\n"
21 " Flip X: %s\n"
22 " Flip Y: %s\n"
23 " Offset X: %d\n"
24 " Offset Y: %d\n"
25 " Inverted Color: %s",
26 LOG_STR_ARG(this->model_str_()), YESNO(this->external_vcc_), YESNO(this->flip_x_), YESNO(this->flip_y_),
27 this->offset_x_, this->offset_y_, YESNO(this->invert_));
28 LOG_PIN(" CS Pin: ", this->cs_);
29 LOG_PIN(" DC Pin: ", this->dc_pin_);
30 LOG_PIN(" Reset Pin: ", this->reset_pin_);
31 LOG_UPDATE_INTERVAL(this);
32}
33void SPISSD1306::command(uint8_t value) {
34 this->dc_pin_->digital_write(false);
35 this->enable();
36 this->write_byte(value);
37 this->disable();
38}
40 if (this->is_sh1106_() || this->is_sh1107_()) {
41 for (uint8_t y = 0; y < (uint8_t) this->get_height_internal() / 8; y++) {
42 this->command(0xB0 + y);
43 if (this->is_sh1106_()) {
44 this->command(0x02);
45 } else {
46 this->command(0x00);
47 }
48 this->command(0x10);
49 this->dc_pin_->digital_write(true);
50 for (uint8_t x = 0; x < (uint8_t) this->get_width_internal(); x++) {
51 this->enable();
52 this->write_byte(this->buffer_[x + y * this->get_width_internal()]);
53 this->disable();
54 App.feed_wdt();
55 }
56 }
57 } else {
58 this->dc_pin_->digital_write(true);
59 this->enable();
60 this->write_array(this->buffer_, this->get_buffer_length_());
61 this->disable();
62 }
63}
64
65} // namespace esphome::ssd1306_spi
void feed_wdt()
Feed the task watchdog.
virtual void setup()=0
virtual void digital_write(bool value)=0
void command(uint8_t value) override
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