ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
sh1122_spi.cpp
Go to the documentation of this file.
1#include "sh1122_spi.h"
2#include "esphome/core/log.h"
3
5
6ESPHOME_LOG_TAG(TAG, "sh1122_spi");
7
9 this->spi_setup();
10 this->dc_pin_->setup();
11
12 this->init_reset_();
13 delay(500); // NOLINT
14 SH1122::setup();
15}
17 LOG_DISPLAY("", "SPI SH1122", this);
18 ESP_LOGCONFIG(TAG,
19 " Model: %s\n"
20 " Initial Brightness: %.2f",
21 LOG_STR_ARG(this->model_str_()), this->brightness_);
22 LOG_PIN(" CS Pin: ", this->cs_);
23 LOG_PIN(" DC Pin: ", this->dc_pin_);
24 LOG_PIN(" Reset Pin: ", this->reset_pin_);
25 LOG_UPDATE_INTERVAL(this);
26}
27// enable() and disable() drive the CS pin. The D/C setup time is a few tens of nanoseconds, so the
28// GPIO write followed by the CS edge already satisfies it; no delay is needed.
29void SPISH1122::write_command(const uint8_t *bytes, size_t len) {
30 this->dc_pin_->digital_write(false);
31 this->enable();
32 this->write_array(bytes, len);
33 this->disable();
34}
36 this->dc_pin_->digital_write(true);
37 this->enable();
38 this->write_array(this->buffer_, this->get_buffer_length_());
39 this->disable();
40}
41
42} // namespace esphome::sh1122_spi
virtual void setup()=0
virtual void digital_write(bool value)=0
const LogString * model_str_()
void write_display_data() override
void write_command(const uint8_t *bytes, size_t len) override
ESPHOME_LOG_TAG(TAG, "sh1122_spi")
const void size_t len
Definition hal.h:68
void HOT delay(uint32_t ms)
Definition hal.cpp:85