mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 13:27:14 +00:00
[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:
@@ -124,17 +124,17 @@ void HOT Pixoo::draw_pixel_at(int x, int y, Color color) {
|
|||||||
return;
|
return;
|
||||||
const int side = static_cast<int>(this->model_);
|
const int side = static_cast<int>(this->model_);
|
||||||
switch (this->rotation_) {
|
switch (this->rotation_) {
|
||||||
case DISPLAY_ROTATION_0_DEGREES:
|
case display::DISPLAY_ROTATION_0_DEGREES:
|
||||||
break;
|
break;
|
||||||
case DISPLAY_ROTATION_90_DEGREES:
|
case display::DISPLAY_ROTATION_90_DEGREES:
|
||||||
std::swap(x, y);
|
std::swap(x, y);
|
||||||
x = side - x - 1;
|
x = side - x - 1;
|
||||||
break;
|
break;
|
||||||
case DISPLAY_ROTATION_180_DEGREES:
|
case display::DISPLAY_ROTATION_180_DEGREES:
|
||||||
x = side - x - 1;
|
x = side - x - 1;
|
||||||
y = side - y - 1;
|
y = side - y - 1;
|
||||||
break;
|
break;
|
||||||
case DISPLAY_ROTATION_270_DEGREES:
|
case display::DISPLAY_ROTATION_270_DEGREES:
|
||||||
std::swap(x, y);
|
std::swap(x, y);
|
||||||
y = side - y - 1;
|
y = side - y - 1;
|
||||||
break;
|
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);
|
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,
|
void Pixoo::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order,
|
||||||
ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) {
|
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.
|
// 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
|
// 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.
|
// 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 ||
|
// NOTE: the stride/index math and 565->888 expansion below mirror Display::draw_pixels_at (the
|
||||||
this->is_clipping()) {
|
// source of truth) -- keep them in sync if the base ever changes its source layout or decoding.
|
||||||
Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
const int side = static_cast<int>(this->model_);
|
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) {
|
void Pixoo::fill(Color color) {
|
||||||
if (this->is_clipping()) {
|
if (this->is_clipping()) {
|
||||||
Display::fill(color);
|
display::Display::fill(color);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < this->data_size_; i += 3) {
|
for (size_t i = 0; i < this->data_size_; i += 3) {
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
namespace esphome::pixoo {
|
namespace esphome::pixoo {
|
||||||
|
|
||||||
using namespace display;
|
|
||||||
|
|
||||||
// The Pixoo's main board (where ESPHome runs) talks to a separate LED-driver board (a GD32/AT32
|
// 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:
|
// MCU) over SPI using Divoom's packet protocol:
|
||||||
// 0xAA, len_lo, len_hi, cmd, <data...>, 0xBB
|
// 0xAA, len_lo, len_hi, cmd, <data...>, 0xBB
|
||||||
@@ -21,7 +19,7 @@ enum PixooModel : uint8_t {
|
|||||||
PIXOO_64 = 64,
|
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,
|
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
|
||||||
spi::DATA_RATE_8MHZ> {
|
spi::DATA_RATE_8MHZ> {
|
||||||
public:
|
public:
|
||||||
@@ -36,12 +34,12 @@ class Pixoo : public Display,
|
|||||||
// board (brightness 0..1 -> 0..100%).
|
// board (brightness 0..1 -> 0..100%).
|
||||||
void set_panel_brightness(float brightness);
|
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 fill(Color color) override;
|
||||||
void draw_pixel_at(int x, int y, 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,
|
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order,
|
||||||
ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override;
|
display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int get_width_internal() override { return static_cast<int>(this->model_); }
|
int get_width_internal() override { return static_cast<int>(this->model_); }
|
||||||
|
|||||||
Reference in New Issue
Block a user