16static constexpr uint8_t PACKET_HEAD = 0xAA;
17static constexpr uint8_t PACKET_TAIL = 0xBB;
18static constexpr uint8_t CMD_DATA = 0x00;
19static constexpr uint8_t CMD_LIGHT = 0x01;
20static constexpr uint8_t CMD_UNUSED = 0x21;
21static constexpr uint8_t CMD_SET_RGB_IOUT = 0x22;
22static constexpr size_t PACKET_HEADER_LEN = 4;
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) {
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) {
39 put_le16(buf + 1, total - PACKET_STATIC_LEN);
41 buf[total - 1] = PACKET_TAIL;
55 this->
frame_buffer_[PACKET_HEADER_LEN + image_bytes] = PACKET_TAIL;
63 const uint8_t iout[3] = {DEFAULT_IOUT, DEFAULT_IOUT, DEFAULT_IOUT};
74 const size_t used = build_packet(this->
cmd_buffer_, cmd, data,
len);
75 if (
DMA_CHUNK - used >= PACKET_STATIC_LEN)
83 const uint8_t pct =
static_cast<uint8_t
>(lroundf(clamp(brightness, 0.0f, 1.0f) * 100.0f));
90 for (
size_t i = 0; i < image_bytes; i++)
98 const size_t off =
static_cast<size_t>(index) * 3;
107 const int side =
static_cast<int>(this->
model_);
132 int y_offset,
int x_pad) {
141 const int side =
static_cast<int>(this->
model_);
142 const size_t line_stride =
static_cast<size_t>(
x_offset) +
w +
x_pad;
143 for (
int y = 0;
y !=
h;
y++) {
145 if (dst_y < 0 || dst_y >= side)
147 size_t source_idx = (
static_cast<size_t>(
y_offset) +
y) * line_stride +
x_offset;
148 for (
int x = 0;
x !=
w;
x++, source_idx++) {
149 const int dst_x = x_start +
x;
150 if (dst_x < 0 || dst_x >= side)
166 for (
size_t i = 0; i < image_bytes; i += 3) {
174 LOG_DISPLAY(
"",
"Divoom Pixoo",
this);
175 ESP_LOGCONFIG(TAG,
" Model: %ux%u", (
unsigned) this->
model_, (
unsigned) this->model_);
176 LOG_UPDATE_INTERVAL(
this);
bool ESPHOME_ALWAYS_INLINE setup_check(bool ok)
Marks the component failed with message (default "Communication failed") unless ok; returns ok.
void disable_loop()
Disable this component's loop.
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
static constexpr size_t frame_size(PixooModel model)
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
static constexpr size_t data_size(PixooModel model)
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 @67::@68 __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.
constexpr uint8_t * put_le16(uint8_t *dst, uint16_t value)