12 for (
const uint8_t
src : {first,
second}) {
13 for (uint8_t shift = 6;; shift -= 2) {
14 const uint8_t level = (
src >> shift) & 0x03;
15 out = (uint8_t) ((
out << 1) | (high_bit ? (level >> 1) : (level & 1)));
29 EPaperGray4(
const char *name, uint16_t width, uint16_t height,
const uint8_t *init_sequence,
30 size_t init_sequence_length)
34 if (this->get_clipping().is_set()) {
40 this->buffer_.fill((uint8_t) (level | (level << 2) | (level << 4) | (level << 6)));
41 this->mark_all_drawn_();
45 if (!this->rotate_coordinates_(
x,
y))
48 const size_t byte_position = (size_t)
y * this->row_width_ +
x / 4;
49 const uint8_t shift = (uint8_t) (6 - 2 * (
x % 4));
50 const uint8_t original = this->buffer_[byte_position];
51 this->buffer_[byte_position] = (uint8_t) ((original & ~(0x03 << shift)) | (level << shift));
57 const size_t src_row =
y * this->row_width_;
58 for (
size_t i = 0; i != this->mono_row_length_(); i++)
59 out[i] =
gray4_plane_byte(this->buffer_[src_row + 2 * i], this->buffer_[src_row + 2 * i + 1],
true);
Adds a framebuffer of four gray levels to a driver: 2 bits per pixel, 4 per byte, most significant pi...
EPaperGray4(const char *name, uint16_t width, uint16_t height, const uint8_t *init_sequence, size_t init_sequence_length)
void mono_row(size_t y, uint8_t *out) override
void fill(Color color) override
void HOT draw_pixel_at(int x, int y, Color color) override
std::vector< uint8_t > & out
uint8_t gray4_plane_byte(uint8_t first, uint8_t second, bool high_bit)
constexpr uint8_t color_to_gray4(Color color)
Map RGB color to one of 4 discrete gray levels (2 bits per pixel)