diff --git a/esphome/components/pixoo/pixoo.cpp b/esphome/components/pixoo/pixoo.cpp index 81962ced03..4436b1fb17 100644 --- a/esphome/components/pixoo/pixoo.cpp +++ b/esphome/components/pixoo/pixoo.cpp @@ -124,17 +124,17 @@ void HOT Pixoo::draw_pixel_at(int x, int y, Color color) { return; const int side = static_cast(this->model_); switch (this->rotation_) { - case DISPLAY_ROTATION_0_DEGREES: + case display::DISPLAY_ROTATION_0_DEGREES: break; - case DISPLAY_ROTATION_90_DEGREES: + case display::DISPLAY_ROTATION_90_DEGREES: std::swap(x, y); x = side - x - 1; break; - case DISPLAY_ROTATION_180_DEGREES: + case display::DISPLAY_ROTATION_180_DEGREES: x = side - x - 1; y = side - y - 1; break; - case DISPLAY_ROTATION_270_DEGREES: + case display::DISPLAY_ROTATION_270_DEGREES: std::swap(x, y); y = side - y - 1; break; @@ -144,14 +144,17 @@ void HOT Pixoo::draw_pixel_at(int x, int y, Color color) { this->set_pixel_(static_cast(y) * side + x, color); } -void Pixoo::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorOrder order, - ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) { +void Pixoo::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, + display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) { // Fast path for the common LVGL/image blit: RGB565, RGB order, no rotation, no active clipping. // Anything else defers to the base implementation, which decodes per pixel and routes through // draw_pixel_at() so rotation, clipping and other color formats stay correct. - if (bitness != COLOR_BITNESS_565 || order != COLOR_ORDER_RGB || this->rotation_ != DISPLAY_ROTATION_0_DEGREES || - this->is_clipping()) { - Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad); + // NOTE: the stride/index math and 565->888 expansion below mirror Display::draw_pixels_at (the + // source of truth) -- keep them in sync if the base ever changes its source layout or decoding. + if (bitness != display::COLOR_BITNESS_565 || order != display::COLOR_ORDER_RGB || + this->rotation_ != display::DISPLAY_ROTATION_0_DEGREES || this->is_clipping()) { + display::Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, + x_pad); return; } const int side = static_cast(this->model_); @@ -179,7 +182,7 @@ void Pixoo::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t void Pixoo::fill(Color color) { if (this->is_clipping()) { - Display::fill(color); + display::Display::fill(color); return; } for (size_t i = 0; i < this->data_size_; i += 3) { diff --git a/esphome/components/pixoo/pixoo.h b/esphome/components/pixoo/pixoo.h index 01256cc34f..4913ef85db 100644 --- a/esphome/components/pixoo/pixoo.h +++ b/esphome/components/pixoo/pixoo.h @@ -8,8 +8,6 @@ namespace esphome::pixoo { -using namespace display; - // The Pixoo's main board (where ESPHome runs) talks to a separate LED-driver board (a GD32/AT32 // MCU) over SPI using Divoom's packet protocol: // 0xAA, len_lo, len_hi, cmd, , 0xBB @@ -21,7 +19,7 @@ enum PixooModel : uint8_t { PIXOO_64 = 64, }; -class Pixoo : public Display, +class Pixoo : public display::Display, public spi::SPIDevice { public: @@ -36,12 +34,12 @@ class Pixoo : public Display, // board (brightness 0..1 -> 0..100%). void set_panel_brightness(float brightness); - DisplayType get_display_type() override { return DISPLAY_TYPE_COLOR; } + display::DisplayType get_display_type() override { return display::DISPLAY_TYPE_COLOR; } void fill(Color color) override; void draw_pixel_at(int x, int y, Color color) override; - void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorOrder order, - ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override; + void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, + display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override; protected: int get_width_internal() override { return static_cast(this->model_); }