17constexpr uint8_t expand_channel(uint16_t value, uint16_t max) {
return static_cast<uint8_t
>(value * 255 / max); }
19constexpr uint16_t RED_MAX = 0x1F;
20constexpr uint16_t GREEN_MAX = 0x3F;
21constexpr uint16_t BLUE_MAX = 0x1F;
28 this->
mark_failed(LOG_STR(
"Could not allocate display buffer"));
37 this->
pixels_()[y * this->
width_ +
x] = display::ColorUtil::color_to_565(color);
56 for (
int y = 0;
y !=
h;
y++) {
57 memcpy(&this->
pixels_()[(y_start +
y) * this->
width_ + x_start],
src +
y * stride * 2,
w * 2);
63 ESP_LOGE(TAG,
"Snapshot requested but there is no buffer to read");
68 uint8_t *
out = dest +
y * row_stride;
70 const uint16_t pixel = *
src++;
71 *
out++ = expand_channel(pixel & BLUE_MAX, BLUE_MAX);
72 *
out++ = expand_channel((pixel >> 5) & GREEN_MAX, GREEN_MAX);
73 *
out++ = expand_channel(pixel >> 11, RED_MAX);
void mark_failed()
Mark this component as failed.
void init_internal_(uint32_t buffer_length)
int int int const uint8_t ColorOrder ColorBitness bitness
int int int const uint8_t ColorOrder ColorBitness bool int int y_offset
int int int const uint8_t ColorOrder ColorBitness bool int int int x_pad
int int int const uint8_t * ptr
int int int const uint8_t ColorOrder ColorBitness bool big_endian
int int int const uint8_t ColorOrder ColorBitness bool int x_offset
DisplayRotation rotation_
bool capture_bgr(uint8_t *dest, size_t row_stride) override
void dump_config() override
uint16_t * pixels_()
The picture, one 16 bit RGB565 value per pixel, topmost row first.
void draw_pixels_internal(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
void draw_absolute_pixel_internal(int x, int y, Color color) override
std::vector< uint8_t > & out
@ DISPLAY_ROTATION_0_DEGREES
ESPHOME_LOG_TAG(TAG, "snapshot.display")