ESPHome  2024.12.2
ssd1351_spi.cpp
Go to the documentation of this file.
1 #include "ssd1351_spi.h"
2 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace ssd1351_spi {
7 
8 static const char *const TAG = "ssd1351_spi";
9 
11  ESP_LOGCONFIG(TAG, "Setting up SPI SSD1351...");
12  this->spi_setup();
13  this->dc_pin_->setup(); // OUTPUT
14  if (this->cs_)
15  this->cs_->setup(); // OUTPUT
16 
17  this->init_reset_();
18  delay(500); // NOLINT
20 }
22  LOG_DISPLAY("", "SPI SSD1351", this);
23  ESP_LOGCONFIG(TAG, " Model: %s", this->model_str_());
24  LOG_PIN(" CS Pin: ", this->cs_);
25  LOG_PIN(" DC Pin: ", this->dc_pin_);
26  LOG_PIN(" Reset Pin: ", this->reset_pin_);
27  ESP_LOGCONFIG(TAG, " Initial Brightness: %.2f", this->brightness_);
28  LOG_UPDATE_INTERVAL(this);
29 }
30 void SPISSD1351::command(uint8_t value) {
31  if (this->cs_)
32  this->cs_->digital_write(true);
33  this->dc_pin_->digital_write(false);
34  delay(1);
35  this->enable();
36  if (this->cs_)
37  this->cs_->digital_write(false);
38  this->write_byte(value);
39  if (this->cs_)
40  this->cs_->digital_write(true);
41  this->disable();
42 }
43 void SPISSD1351::data(uint8_t value) {
44  if (this->cs_)
45  this->cs_->digital_write(true);
46  this->dc_pin_->digital_write(true);
47  delay(1);
48  this->enable();
49  if (this->cs_)
50  this->cs_->digital_write(false);
51  this->write_byte(value);
52  if (this->cs_)
53  this->cs_->digital_write(true);
54  this->disable();
55 }
57  if (this->cs_)
58  this->cs_->digital_write(true);
59  this->dc_pin_->digital_write(true);
60  if (this->cs_)
61  this->cs_->digital_write(false);
62  delay(1);
63  this->enable();
64  this->write_array(this->buffer_, this->get_buffer_length_());
65  if (this->cs_)
66  this->cs_->digital_write(true);
67  this->disable();
68 }
69 
70 } // namespace ssd1351_spi
71 } // namespace esphome
void setup()
virtual void digital_write(bool value)=0
GPIOPin * cs_
Definition: spi.h:378
virtual void setup()=0
void data(uint8_t value) override
Definition: ssd1351_spi.cpp:43
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void command(uint8_t value) override
Definition: ssd1351_spi.cpp:30
void IRAM_ATTR HOT delay(uint32_t ms)
Definition: core.cpp:26