11static const char *
const TAG =
"pixoo";
14static constexpr uint8_t PACKET_HEAD = 0xAA;
15static constexpr uint8_t PACKET_TAIL = 0xBB;
16static constexpr uint8_t CMD_DATA = 0x00;
17static constexpr uint8_t CMD_LIGHT = 0x01;
18static constexpr uint8_t CMD_UNUSED = 0x21;
19static constexpr uint8_t CMD_SET_RGB_IOUT = 0x22;
20static constexpr size_t PACKET_HEADER_LEN = 4;
21static constexpr size_t PACKET_STATIC_LEN = 5;
22static constexpr uint8_t DEFAULT_IOUT = 75;
25static inline size_t build_packet(uint8_t *buf, uint8_t cmd,
const uint8_t *data, uint16_t
len) {
27 buf[1] =
static_cast<uint8_t
>(
len & 0xFF);
28 buf[2] =
static_cast<uint8_t
>((
len >> 8) & 0xFF);
30 if (data !=
nullptr &&
len > 0)
31 std::memcpy(buf + PACKET_HEADER_LEN, data,
len);
32 buf[PACKET_HEADER_LEN +
len] = PACKET_TAIL;
33 return len + PACKET_STATIC_LEN;
37static inline void pad_unused(uint8_t *buf,
size_t total) {
38 const uint16_t
len =
static_cast<uint16_t
>(total - PACKET_STATIC_LEN);
40 buf[1] =
static_cast<uint8_t
>(
len & 0xFF);
41 buf[2] =
static_cast<uint8_t
>((
len >> 8) & 0xFF);
43 buf[total - 1] = PACKET_TAIL;
56 this->
mark_failed(LOG_STR(
"Failed to allocate draw buffer"));
65 this->
mark_failed(LOG_STR(
"Failed to allocate frame buffer"));
82 const uint8_t iout[3] = {DEFAULT_IOUT, DEFAULT_IOUT, DEFAULT_IOUT};
93 const size_t used = build_packet(this->
cmd_buffer_, cmd, data,
len);
94 if (
DMA_CHUNK - used >= PACKET_STATIC_LEN)
102 const uint8_t pct =
static_cast<uint8_t
>(lroundf(clamp(brightness, 0.0f, 1.0f) * 100.0f));
116 const size_t off =
static_cast<size_t>(index) * 3;
125 const int side =
static_cast<int>(this->
model_);
156 display::Display::draw_pixels_at(x_start, y_start, w,
h, ptr, order, bitness, big_endian, x_offset, y_offset,
160 const int side =
static_cast<int>(this->
model_);
161 const size_t line_stride =
static_cast<size_t>(x_offset) + w + x_pad;
162 for (
int y = 0;
y !=
h;
y++) {
163 const int dst_y = y_start +
y;
164 if (dst_y < 0 || dst_y >= side)
166 size_t source_idx = (
static_cast<size_t>(y_offset) +
y) * line_stride + x_offset;
167 for (
int x = 0;
x != w;
x++, source_idx++) {
168 const int dst_x = x_start +
x;
169 if (dst_x < 0 || dst_x >= side)
171 const size_t byte_idx = source_idx * 2;
172 const uint16_t rgb565 =
173 big_endian ? (ptr[byte_idx] << 8) | ptr[byte_idx + 1] : ptr[byte_idx] | (ptr[byte_idx + 1] << 8);
174 const uint8_t r5 = (rgb565 >> 11) & 0x1F;
175 const uint8_t g6 = (rgb565 >> 5) & 0x3F;
176 const uint8_t b5 = rgb565 & 0x1F;
178 Color((r5 << 3) | (r5 >> 2), (g6 << 2) | (g6 >> 4), (b5 << 3) | (b5 >> 2)));
188 for (
size_t i = 0; i < this->
data_size_; i += 3) {
196 LOG_DISPLAY(
"",
"Divoom Pixoo",
this);
197 ESP_LOGCONFIG(TAG,
" Model: %ux%u", (
unsigned) this->
model_, (
unsigned) this->model_);
198 LOG_UPDATE_INTERVAL(
this);
void mark_failed()
Mark this component as failed.
void disable_loop()
Disable this component's loop.
An STL allocator that uses SPI or internal RAM.
virtual void fill(Color color)
Fill the entire screen with the given color.
Rect get_clipping() const
Get the current the clipping rectangle.
DisplayRotation rotation_
virtual 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)
Given an array of pixels encoded in the nominated format, draw these into the display's buffer.
uint8_t cmd_buffer_[DMA_CHUNK]
void send_command_(uint8_t cmd, const uint8_t *data, uint16_t len)
void fill(Color color) override
split_buffer::SplitBuffer buffer_
void set_panel_brightness(float brightness)
void set_pixel_(uint32_t index, Color color)
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, display::ColorOrder order, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
static constexpr size_t DMA_CHUNK
float get_setup_priority() const override
void dump_config() override
void spi_setup() override
void write_array(const uint8_t *data, size_t length)
bool init(size_t total_length)
void fill(uint8_t value) const
Fill the entire buffer with a single byte value.
@ DISPLAY_ROTATION_0_DEGREES
@ DISPLAY_ROTATION_270_DEGREES
@ DISPLAY_ROTATION_180_DEGREES
@ DISPLAY_ROTATION_90_DEGREES
constexpr float PROCESSOR
For components that use data from sensors like displays.