15static constexpr uint8_t PACKET_HEAD = 0xAA;
16static constexpr uint8_t PACKET_TAIL = 0xBB;
17static constexpr uint8_t CMD_DATA = 0x00;
18static constexpr uint8_t CMD_LIGHT = 0x01;
19static constexpr uint8_t CMD_UNUSED = 0x21;
20static constexpr uint8_t CMD_SET_RGB_IOUT = 0x22;
21static constexpr size_t PACKET_HEADER_LEN = 4;
22static constexpr size_t PACKET_STATIC_LEN = 5;
23static constexpr uint8_t DEFAULT_IOUT = 75;
26static inline size_t build_packet(uint8_t *buf, uint8_t cmd,
const uint8_t *data, uint16_t
len) {
28 buf[1] =
static_cast<uint8_t
>(
len & 0xFF);
29 buf[2] =
static_cast<uint8_t
>((
len >> 8) & 0xFF);
31 if (data !=
nullptr &&
len > 0)
32 std::memcpy(buf + PACKET_HEADER_LEN, data,
len);
33 buf[PACKET_HEADER_LEN +
len] = PACKET_TAIL;
34 return len + PACKET_STATIC_LEN;
38static inline void pad_unused(uint8_t *buf,
size_t total) {
39 const uint16_t
len =
static_cast<uint16_t
>(total - PACKET_STATIC_LEN);
41 buf[1] =
static_cast<uint8_t
>(
len & 0xFF);
42 buf[2] =
static_cast<uint8_t
>((
len >> 8) & 0xFF);
44 buf[total - 1] = PACKET_TAIL;
57 this->
mark_failed(LOG_STR(
"Failed to allocate draw buffer"));
66 this->
mark_failed(LOG_STR(
"Failed to allocate frame buffer"));
83 const uint8_t iout[3] = {DEFAULT_IOUT, DEFAULT_IOUT, DEFAULT_IOUT};
94 const size_t used = build_packet(this->
cmd_buffer_, cmd, data,
len);
95 if (
DMA_CHUNK - used >= PACKET_STATIC_LEN)
103 const uint8_t pct =
static_cast<uint8_t
>(lroundf(clamp(brightness, 0.0f, 1.0f) * 100.0f));
117 const size_t off =
static_cast<size_t>(index) * 3;
126 const int side =
static_cast<int>(this->
model_);
151 bool big_endian,
int x_offset,
int y_offset,
int x_pad) {
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++) {
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)
184 for (
size_t i = 0; i < this->
data_size_; i += 3) {
192 LOG_DISPLAY(
"",
"Divoom Pixoo",
this);
193 ESP_LOGCONFIG(TAG,
" Model: %ux%u", (
unsigned) this->
model_, (
unsigned) this->model_);
194 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.
static Color to_color(uint32_t colorcode, ColorBitness color_bitness=ColorBitness::COLOR_BITNESS_888, bool right_bit_aligned=true)
Unpacks a color of the given bitness, red in the most significant bits.
static ESPHOME_ALWAYS_INLINE uint32_t read_packed(const uint8_t *ptr, size_t index, bool big_endian)
Reads one packed pixel of the given bitness from a source buffer into the value to_color() takes.
int int int const uint8_t ColorOrder ColorBitness bitness
int int int const uint8_t ColorOrder ColorBitness bool int int y_offset
virtual void fill(Color color)
Fill the entire screen with the given color.
int int int const uint8_t ColorOrder ColorBitness bool int int int x_pad
int int int const uint8_t * ptr
bool ESPHOME_ALWAYS_INLINE is_point_clipped(int x, int y) const
Whether (x, y) falls outside the active clipping rectangle.
int int int const uint8_t ColorOrder ColorBitness bool big_endian
int int int const uint8_t ColorOrder ColorBitness bool int x_offset
DisplayRotation rotation_
virtual void draw_pixels_internal(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad)
Draws a block for draw_pixels_at(); the parameters are the same.
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
static constexpr size_t DMA_CHUNK
float get_setup_priority() const override
void draw_pixels_internal(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) 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, size_t max_buffer_size=SIZE_MAX)
void fill(uint8_t value) const
Fill the entire buffer with a single byte value.
struct @66::@67 __attribute__
Wake the main loop task from an ISR. ISR-safe.
@ DISPLAY_ROTATION_0_DEGREES
@ DISPLAY_ROTATION_270_DEGREES
@ DISPLAY_ROTATION_180_DEGREES
@ DISPLAY_ROTATION_90_DEGREES
ESPHOME_LOG_TAG(TAG, "pixoo")
constexpr float PROCESSOR
For components that use data from sensors like displays.