ESPHome 2025.5.0
Loading...
Searching...
No Matches
ssd1327_i2c.cpp
Go to the documentation of this file.
1#include "ssd1327_i2c.h"
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace ssd1327_i2c {
6
7static 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
20 SSD1327::setup();
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}
33void 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
virtual void mark_failed()
Mark this component as failed.
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)
Definition i2c.h:252
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:190
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
Definition i2c.h:266
void command(uint8_t value) override
@ ERROR_OK
No error found during execution of method.
Definition i2c_bus.h:13
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7