ESPHome  2022.6.3
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  if (this->cs_)
25  LOG_PIN(" CS Pin: ", this->cs_);
26  LOG_PIN(" DC Pin: ", this->dc_pin_);
27  LOG_PIN(" Reset Pin: ", this->reset_pin_);
28  ESP_LOGCONFIG(TAG, " Initial Brightness: %.2f", this->brightness_);
29  LOG_UPDATE_INTERVAL(this);
30 }
31 void SPISSD1351::command(uint8_t value) {
32  if (this->cs_)
33  this->cs_->digital_write(true);
34  this->dc_pin_->digital_write(false);
35  delay(1);
36  this->enable();
37  if (this->cs_)
38  this->cs_->digital_write(false);
39  this->write_byte(value);
40  if (this->cs_)
41  this->cs_->digital_write(true);
42  this->disable();
43 }
44 void SPISSD1351::data(uint8_t value) {
45  if (this->cs_)
46  this->cs_->digital_write(true);
47  this->dc_pin_->digital_write(true);
48  delay(1);
49  this->enable();
50  if (this->cs_)
51  this->cs_->digital_write(false);
52  this->write_byte(value);
53  if (this->cs_)
54  this->cs_->digital_write(true);
55  this->disable();
56 }
58  if (this->cs_)
59  this->cs_->digital_write(true);
60  this->dc_pin_->digital_write(true);
61  if (this->cs_)
62  this->cs_->digital_write(false);
63  delay(1);
64  this->enable();
65  this->write_array(this->buffer_, this->get_buffer_length_());
66  if (this->cs_)
67  this->cs_->digital_write(true);
68  this->disable();
69 }
70 
71 } // namespace ssd1351_spi
72 } // namespace esphome
void setup()
virtual void digital_write(bool value)=0
virtual void setup()=0
void data(uint8_t value) override
Definition: ssd1351_spi.cpp:44
Definition: a4988.cpp:4
void command(uint8_t value) override
Definition: ssd1351_spi.cpp:31
void IRAM_ATTR HOT delay(uint32_t ms)
Definition: core.cpp:27