mirror of
https://github.com/esphome/esphome.git
synced 2026-09-24 13:34:07 +00:00
[epaper_spi] Add support for Waveshare 2.13" V4 series B (R/B/W) (#16828)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#include "epaper_waveshare_b.h"
|
||||
|
||||
namespace esphome::epaper_spi {
|
||||
|
||||
bool EpaperWaveshareB::reset() {
|
||||
if (EPaperBase::reset()) {
|
||||
this->command(0x12);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace esphome::epaper_spi
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "epaper_weact_3c.h"
|
||||
|
||||
namespace esphome::epaper_spi {
|
||||
|
||||
/**
|
||||
* Waveshare (B) series BWR e-paper displays using SSD1680-compatible controllers.
|
||||
* Waveshare uses 0=red, 1=no-red, the inverse of EPaperWeAct3C
|
||||
*/
|
||||
class EpaperWaveshareB : public EPaperWeAct3C {
|
||||
public:
|
||||
using EPaperWeAct3C::EPaperWeAct3C;
|
||||
|
||||
protected:
|
||||
bool reset() override;
|
||||
uint8_t transform_red_byte(uint8_t byte) const override { return static_cast<uint8_t>(~byte); }
|
||||
};
|
||||
|
||||
} // namespace esphome::epaper_spi
|
||||
@@ -144,7 +144,7 @@ bool HOT EPaperWeAct3C::transfer_data() {
|
||||
size_t bytes_to_copy = std::min(MAX_TRANSFER_SIZE, half_buffer - this->current_data_index_);
|
||||
|
||||
for (size_t i = 0; i < bytes_to_copy; i++) {
|
||||
bytes_to_send[i] = this->buffer_[red_offset + this->current_data_index_ + i];
|
||||
bytes_to_send[i] = this->transform_red_byte(this->buffer_[red_offset + this->current_data_index_ + i]);
|
||||
}
|
||||
|
||||
this->write_array(bytes_to_send, bytes_to_copy);
|
||||
|
||||
@@ -34,6 +34,9 @@ class EPaperWeAct3C : public EPaperBase {
|
||||
void draw_pixel_at(int x, int y, Color color) override;
|
||||
|
||||
bool transfer_data() override;
|
||||
|
||||
// Hook for subclasses to transform red plane bytes before they go on the wire.
|
||||
virtual uint8_t transform_red_byte(uint8_t byte) const { return byte; }
|
||||
};
|
||||
|
||||
} // namespace esphome::epaper_spi
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from . import EpaperModel
|
||||
|
||||
|
||||
class WaveshareB(EpaperModel):
|
||||
def __init__(self, name, **defaults):
|
||||
super().__init__(name, "EpaperWaveshareB", **defaults)
|
||||
|
||||
def get_init_sequence(self, config):
|
||||
_, height = self.get_dimensions(config)
|
||||
h = height - 1
|
||||
return (
|
||||
(0x01, h & 0xFF, h >> 8, 0x00), # Driver output control
|
||||
(0x11, 0x03), # Data entry mode
|
||||
(0x3C, 0x05), # Border waveform
|
||||
(0x18, 0x80), # Internal temperature sensor
|
||||
(0x21, 0x80, 0x80), # Display update control
|
||||
)
|
||||
|
||||
|
||||
WaveshareB(
|
||||
"waveshare-2.13in-bv4",
|
||||
width=122,
|
||||
height=250,
|
||||
data_rate="10MHz",
|
||||
minimum_update_interval="1s",
|
||||
)
|
||||
@@ -162,6 +162,27 @@ display:
|
||||
allow_other_uses: true
|
||||
number: GPIO4
|
||||
|
||||
# Waveshare 2.13" V4 B series 3-color e-paper (122x250, BWR, SSD1680)
|
||||
- platform: epaper_spi
|
||||
spi_id: spi_bus
|
||||
model: waveshare-2.13in-bv4
|
||||
cs_pin:
|
||||
allow_other_uses: true
|
||||
number: GPIO5
|
||||
dc_pin:
|
||||
allow_other_uses: true
|
||||
number: GPIO17
|
||||
reset_pin:
|
||||
allow_other_uses: true
|
||||
number: GPIO16
|
||||
busy_pin:
|
||||
allow_other_uses: true
|
||||
number: GPIO4
|
||||
lambda: |-
|
||||
it.filled_rectangle(0, 0, it.get_width(), it.get_height(), Color::WHITE);
|
||||
it.circle(it.get_width() / 2, it.get_height() / 2, 20, Color::BLACK);
|
||||
it.circle(it.get_width() / 2, it.get_height() / 2, 15, Color(255, 0, 0));
|
||||
|
||||
# Soldered Inkplate 2 3-color e-paper (104x212, BWR)
|
||||
- platform: epaper_spi
|
||||
spi_id: spi_bus
|
||||
|
||||
Reference in New Issue
Block a user