ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
pixoo.h
Go to the documentation of this file.
1#pragma once
2
8
9namespace esphome::pixoo {
10
11// The Pixoo's main board (where ESPHome runs) talks to a separate LED-driver board (a GD32/AT32
12// MCU) over SPI using Divoom's packet protocol:
13// 0xAA, len_lo, len_hi, cmd, <data...>, 0xBB
14// The image is sent as a DATA (0x00) packet carrying width*height*3 bytes of RGB888; brightness is
15// a separate LIGHT (0x01) command; the LED current is set once via SET_RGB_IOUT (0x22). Command
16// packets are padded out to the LED board's 240-byte DMA chunk with an UNUSED (0x21) packet.
17// The model selects the (square) panel side length.
18enum PixooModel : uint8_t {
20};
21
22class Pixoo : public display::Display,
23 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
24 spi::DATA_RATE_8MHZ> {
25 public:
26 explicit Pixoo(PixooModel model) : model_(model) {}
27
28 void setup() override;
29 void update() override;
30 void dump_config() override;
31 float get_setup_priority() const override;
32
33 // Brightness is controlled exclusively via the light platform: send a LIGHT command to the LED
34 // board (brightness 0..1 -> 0..100%).
35 void set_panel_brightness(float brightness);
36
38
39 void fill(Color color) override;
40 void draw_pixel_at(int x, int y, Color color) override;
41 void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order,
42 display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override;
43
44 protected:
45 int get_width_internal() override { return static_cast<int>(this->model_); }
46 int get_height_internal() override { return static_cast<int>(this->model_); }
47
48 void set_pixel_(uint32_t index, Color color);
49 void send_command_(uint8_t cmd, const uint8_t *data, uint16_t len);
50
51 // Size of the LED board's SPI DMA chunk; the command scratch buffer is one chunk.
52 static constexpr size_t DMA_CHUNK = 240;
53
55
56 size_t data_size_{0}; // RGB888 image bytes: model^2 * 3
57 size_t frame_size_{0}; // full SPI frame: DATA packet + trailing UNUSED packet
58
60 uint8_t *frame_buffer_{nullptr};
62};
63
64} // namespace esphome::pixoo
uint8_t h
Definition bl0906.h:2
uint8_t cmd_buffer_[DMA_CHUNK]
Definition pixoo.h:61
int get_width_internal() override
Definition pixoo.h:45
void send_command_(uint8_t cmd, const uint8_t *data, uint16_t len)
Definition pixoo.cpp:91
void fill(Color color) override
Definition pixoo.cpp:183
void setup() override
Definition pixoo.cpp:48
split_buffer::SplitBuffer buffer_
Definition pixoo.h:59
PixooModel model_
Definition pixoo.h:54
void set_panel_brightness(float brightness)
Definition pixoo.cpp:101
int get_height_internal() override
Definition pixoo.h:46
void set_pixel_(uint32_t index, Color color)
Definition pixoo.cpp:115
void draw_pixel_at(int x, int y, Color color) override
Definition pixoo.cpp:122
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
Definition pixoo.cpp:147
static constexpr size_t DMA_CHUNK
Definition pixoo.h:52
float get_setup_priority() const override
Definition pixoo.cpp:46
Pixoo(PixooModel model)
Definition pixoo.h:26
display::DisplayType get_display_type() override
Definition pixoo.h:37
uint8_t * frame_buffer_
Definition pixoo.h:60
void update() override
Definition pixoo.cpp:106
void dump_config() override
Definition pixoo.cpp:195
The SPIDevice is what components using the SPI will create.
Definition spi.h:429
A SplitBuffer allocates a large memory buffer potentially as multiple smaller buffers to facilitate a...
const void size_t len
Definition hal.h:64
static void uint32_t
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6