ESPHome  2024.10.2
ssd1327_i2c.cpp
Go to the documentation of this file.
1 #include "ssd1327_i2c.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace ssd1327_i2c {
6 
7 static const char *const TAG = "ssd1327_i2c";
8 
10  ESP_LOGCONFIG(TAG, "Setting up I2C SSD1327...");
11  this->init_reset_();
12 
13  auto err = this->write(nullptr, 0);
14  if (err != i2c::ERROR_OK) {
15  this->error_code_ = COMMUNICATION_FAILED;
16  this->mark_failed();
17  return;
18  }
19 
21 }
23  LOG_DISPLAY("", "I2C SSD1327", this);
24  LOG_I2C_DEVICE(this);
25  ESP_LOGCONFIG(TAG, " Model: %s", this->model_str_());
26  LOG_PIN(" Reset Pin: ", this->reset_pin_);
27  LOG_UPDATE_INTERVAL(this);
28 
29  if (this->error_code_ == COMMUNICATION_FAILED) {
30  ESP_LOGE(TAG, "Communication with SSD1327 failed!");
31  }
32 }
33 void I2CSSD1327::command(uint8_t value) { this->write_byte(0x00, value); }
35  for (uint32_t i = 0; i < this->get_buffer_length_();) {
36  uint8_t data[16];
37  for (uint8_t &j : data)
38  j = this->buffer_[i++];
39  this->write_bytes(0x40, data, sizeof(data));
40  }
41 }
42 
43 } // namespace ssd1327_i2c
44 } // namespace esphome
void setup()
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
Definition: i2c.h:186
No error found during execution of method.
Definition: i2c_bus.h:13
void command(uint8_t value) override
Definition: ssd1327_i2c.cpp:33
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
Definition: i2c.h:262
virtual void mark_failed()
Mark this component as failed.
Definition: component.cpp:118
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)
Definition: i2c.h:248