ESPHome  2024.11.1
ssd1331_spi.cpp
Go to the documentation of this file.
1 #include "ssd1331_spi.h"
2 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace ssd1331_spi {
7 
8 static const char *const TAG = "ssd1331_spi";
9 
11  ESP_LOGCONFIG(TAG, "Setting up SPI SSD1331...");
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 SSD1331", this);
23  LOG_PIN(" CS Pin: ", this->cs_);
24  LOG_PIN(" DC Pin: ", this->dc_pin_);
25  LOG_PIN(" Reset Pin: ", this->reset_pin_);
26  ESP_LOGCONFIG(TAG, " Initial Brightness: %.2f", this->brightness_);
27  LOG_UPDATE_INTERVAL(this);
28 }
29 void SPISSD1331::command(uint8_t value) {
30  if (this->cs_)
31  this->cs_->digital_write(true);
32  this->dc_pin_->digital_write(false);
33  delay(1);
34  this->enable();
35  if (this->cs_)
36  this->cs_->digital_write(false);
37  this->write_byte(value);
38  if (this->cs_)
39  this->cs_->digital_write(true);
40  this->disable();
41 }
43  if (this->cs_)
44  this->cs_->digital_write(true);
45  this->dc_pin_->digital_write(true);
46  if (this->cs_)
47  this->cs_->digital_write(false);
48  delay(1);
49  this->enable();
50  this->write_array(this->buffer_, this->get_buffer_length_());
51  if (this->cs_)
52  this->cs_->digital_write(true);
53  this->disable();
54 }
55 
56 } // namespace ssd1331_spi
57 } // namespace esphome
void setup()
virtual void digital_write(bool value)=0
void command(uint8_t value) override
Definition: ssd1331_spi.cpp:29
GPIOPin * cs_
Definition: spi.h:378
virtual void setup()=0
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void IRAM_ATTR HOT delay(uint32_t ms)
Definition: core.cpp:26