[waveshare_epaper] Add color support for 7.5in

The 7.5in displays are available in a Red and yellow variant, but we
normally only have support for red, so this is the red support for
the 7.5in. If it has yellow, then everything painted red will be
shown in yellow.

Signed-off-by: Fabian Pflug <fabian.pflug@gumulka.eu>
This commit is contained in:
Fabian Pflug 2024-05-17 22:39:41 +02:00
parent 48fa549042
commit 55fbfbd9ae
No known key found for this signature in database
GPG key ID: C7AD3F0CBC38DF1D
2 changed files with 22 additions and 10 deletions

View file

@ -2567,19 +2567,31 @@ void HOT WaveshareEPaper7P5InBC::display() {
this->command(0x10); this->command(0x10);
this->start_data_(); this->start_data_();
for (size_t i = 0; i < this->get_buffer_length_(); i++) { const uint32_t buf_half_len = this->get_buffer_length_() / 2u;
for (size_t i = 0; i < buf_half_len; i++) {
// A line of eight source pixels (each a bit in this byte) // A line of eight source pixels (each a bit in this byte)
uint8_t eight_pixels = this->buffer_[i]; // logic for black is flipped.
uint8_t eight_black_pixels = ~(this->buffer_[i]);
uint8_t eight_red_pixels = this->buffer_[i + buf_half_len];
for (uint8_t j = 0; j < 8; j += 2) { for (uint8_t j = 0; j < 8; j += 2) {
/* For bichromatic displays, each byte represents two pixels. Each nibble encodes a pixel: 0=white, 3=black, /* For bichromatic displays, each byte represents two pixels. Each nibble encodes a pixel: 0=white, 3=black,
4=color. Therefore, e.g. 0x44 = two adjacent color pixels, 0x33 is two adjacent black pixels, etc. If you want 4=color. Therefore, e.g. 0x44 = two adjacent color pixels, 0x33 is two adjacent black pixels, etc. */
to draw using the color pixels, change '0x30' with '0x40' and '0x03' with '0x04' below. */ uint8_t data = 0x00;
uint8_t left_nibble = (eight_pixels & 0x80) ? 0x30 : 0x00; if (eight_red_pixels & 0x80) {
eight_pixels <<= 1; data |= 0x40;
uint8_t right_nibble = (eight_pixels & 0x80) ? 0x03 : 0x00; } else if (eight_black_pixels & 0x80) {
eight_pixels <<= 1; data |= 0x30;
this->write_byte(left_nibble | right_nibble); }
if (eight_red_pixels & 0x40) {
data |= 0x04;
} else if (eight_black_pixels & 0x40) {
data |= 0x03;
}
eight_black_pixels <<= 2;
eight_red_pixels <<= 2;
this->write_byte(data);
} }
App.feed_wdt(); App.feed_wdt();
} }

View file

@ -594,7 +594,7 @@ class WaveshareEPaper7P5InBV3 : public WaveshareEPaper {
void init_display_(); void init_display_();
}; };
class WaveshareEPaper7P5InBC : public WaveshareEPaper { class WaveshareEPaper7P5InBC : public WaveshareEPaperBWR {
public: public:
void initialize() override; void initialize() override;