[pixoo] Qualify display:: namespace and note fast-path sync

Drop the header-level using namespace display (and the cpp-local one),
fully qualifying display types, and note that the draw_pixels_at fast
path mirrors Display::draw_pixels_at and must stay in sync.
This commit is contained in:
Jesse Hills
2026-06-16 10:22:49 +12:00
parent 962b65a46d
commit bba9ee5d9c
2 changed files with 17 additions and 16 deletions

View File

@@ -124,17 +124,17 @@ void HOT Pixoo::draw_pixel_at(int x, int y, Color color) {
return;
const int side = static_cast<int>(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<uint32_t>(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<int>(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) {

View File

@@ -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, <data...>, 0xBB
@@ -21,7 +19,7 @@ enum PixooModel : uint8_t {
PIXOO_64 = 64,
};
class Pixoo : public Display,
class Pixoo : public display::Display,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
spi::DATA_RATE_8MHZ> {
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<int>(this->model_); }