1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-01 00:08:15 +00:00
This commit is contained in:
Neil 2024-03-27 20:42:22 +01:00 committed by NeilSCGH
parent e6dc8f9910
commit db2abab361
2 changed files with 33 additions and 19 deletions

View File

@ -198,23 +198,37 @@ void WaveshareEPaper7C::init_internal_(uint32_t buffer_length) {
} }
uint8_t WaveshareEPaper7C::color_to_hex(Color color) { uint8_t WaveshareEPaper7C::color_to_hex(Color color) {
uint8_t hex_code; uint8_t hex_code;
if (((color.red < 127) && (color.green < 127) && (color.blue < 127))) {
hex_code = 0x0; // Black if (color.red > 127) {
} else if (((color.red > 127) && (color.green > 127) && (color.blue > 127))) { if (color.blue > 127) {
hex_code = 0x1; // White if (color.green > 127) {
} else if (((color.red < 127) && (color.green > 127) && (color.blue < 127))) { hex_code = 0x1; // White
hex_code = 0x2; // Green } else {
} else if (((color.red < 127) && (color.green < 127) && (color.blue > 127))) { hex_code = 0x5; // Yellow
hex_code = 0x3; // Blue }
} else if (((color.red > 127) && (color.green < 127) && (color.blue < 127))) { } else {
hex_code = 0x4; // Red if (color.green > 85 && color.green < 170 ) {
} else if (((color.red > 127) && (color.green > 127) && (color.blue < 127))) { hex_code = 0x6; // Orange
hex_code = 0x5; // Yellow } else {
} else if (((color.red > 127) && (color.green > 64) && (color.green < 191) && (color.blue < 127))) { hex_code = 0x4; // Red
hex_code = 0x6; // Orange }
}
} else { } else {
hex_code = 0x1; // White if (color.green > 127) {
if (color.blue > 127) {
hex_code = 0x3; // Blue
} else {
hex_code = 0x2; // Green
}
} else {
if (color.blue > 127) {
hex_code = 0x3; // Blue
} else {
hex_code = 0x0; // Black
}
}
} }
return hex_code; return hex_code;
} }
void WaveshareEPaper7C::fill(Color color) { void WaveshareEPaper7C::fill(Color color) {
@ -225,7 +239,7 @@ void WaveshareEPaper7C::fill(Color color) {
pixel_color = 0x1; pixel_color = 0x1;
} }
if (this->buffers_ == nullptr) { if (this->buffers_[0] == nullptr) {
ESP_LOGE(TAG, "Buffer unavailable!"); ESP_LOGE(TAG, "Buffer unavailable!");
} else { } else {
uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS; uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS;
@ -2496,7 +2510,7 @@ void WaveshareEPaper7P5In::dump_config() {
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }
void WaveshareEPaper7P3InF::initialize() { void WaveshareEPaper7P3InF::initialize() {
if (this->buffers_ == nullptr) { if (this->buffers_[0] == nullptr) {
ESP_LOGE(TAG, "Buffer unavailable!"); ESP_LOGE(TAG, "Buffer unavailable!");
return; return;
} }
@ -2599,11 +2613,10 @@ void WaveshareEPaper7P3InF::initialize() {
ESP_LOGI(TAG, "Display initialized successfully"); ESP_LOGI(TAG, "Display initialized successfully");
} }
void HOT WaveshareEPaper7P3InF::display() { void HOT WaveshareEPaper7P3InF::display() {
if (this->buffers_ == nullptr) { if (this->buffers_[0] == nullptr) {
ESP_LOGE(TAG, "Buffer unavailable!"); ESP_LOGE(TAG, "Buffer unavailable!");
return; return;
} }
uint32_t buf_len = this->get_buffer_length_();
// INITIALIZATION // INITIALIZATION
ESP_LOGI(TAG, "Initialise the display"); ESP_LOGI(TAG, "Initialise the display");

View File

@ -289,6 +289,7 @@ class GDEW0154M09 : public WaveshareEPaper {
void display() override; void display() override;
void dump_config() override; void dump_config() override;
void deep_sleep() override; void deep_sleep() override;
using WaveshareEPaper::init_internal_;
protected: protected:
int get_width_internal() override; int get_width_internal() override;