11static uint8_t plane_byte(uint8_t first, uint8_t
second,
bool high_bit) {
13 for (
const uint8_t
src : {first,
second}) {
14 for (uint8_t shift = 6;; shift -= 2) {
15 const uint8_t level = (
src >> shift) & 0x03;
16 out = (uint8_t) ((
out << 1) | (high_bit ? (level >> 1) : (level & 1)));
31 this->
buffer_.
fill((uint8_t) (level | (level << 2) | (level << 4) | (level << 6)));
42 const size_t byte_position = (size_t)
y * this->
row_width_ + x / 4;
43 const uint8_t shift = (uint8_t) (6 - 2 * (
x % 4));
44 const uint8_t original = this->
buffer_[byte_position];
45 this->
buffer_[byte_position] = (uint8_t) ((original & ~(0x03 << shift)) | (level << shift));
52 out[i] = plane_byte(this->
buffer_[src_row + 2 * i], this->
buffer_[src_row + 2 * i + 1],
true);
61 auto start_time =
millis();
73 this->
command(first_pass ? 0x24 : 0x26);
76 const size_t plane_row_length = (this->
x_high_ - this->
x_low_) / 8;
80 uint8_t *bytes_to_send = bytes_to_send_alloc.
get();
81 ESP_LOGV(TAG,
"Writing %u bytes at line %zu at %ums", plane_row_length, this->
current_data_index_,
86 for (
size_t i = 0; i != plane_row_length; i++) {
87 const uint8_t plane = plane_byte(this->
buffer_[src_row + 2 * i], this->
buffer_[src_row + 2 * i + 1], first_pass);
89 bytes_to_send[i] = (uint8_t) ~plane;
96 if (
millis() - start_time > MAX_TRANSFER_TIME) {
115 ESP_LOGV(TAG,
"Black-and-white partial refresh");
123 ESP_LOGV(TAG,
"Four-level refresh");
Helper class for efficient buffer allocation - uses stack for small sizes, heap for large This is use...
Rect get_clipping() const
Get the current the clipping rectangle.
void command(uint8_t value)
void fill(Color color) override
bool rotate_coordinates_(int &x, int &y)
Check and rotate coordinates based on the transform flags.
virtual void refresh_screen(bool partial)=0
Refresh the screen after data transfer.
split_buffer::SplitBuffer buffer_
void cmd_data(uint8_t command, const uint8_t *ptr, size_t length)
size_t current_data_index_
virtual void set_window()
bool transfer_data() override
void refresh_screen(bool partial) override
bool is_partial_push_() const
void plane_row(size_t y, uint8_t *out) override
void draw_pixel_at(int x, int y, Color color) override
void fill(Color color) override
split_buffer::SplitBuffer sent_
bool transfer_data() override
size_t plane_row_length_() const
void write_array(const uint8_t *data, size_t length)
void fill(uint8_t value) const
Fill the entire buffer with a single byte value.
std::vector< uint8_t > & out
ESPHOME_LOG_TAG(TAG, "display")
constexpr uint8_t color_to_gray4(Color color)
Map RGB color to one of 4 discrete gray levels (2 bits per pixel)
uint32_t IRAM_ATTR HOT millis()