mirror of
https://github.com/m5stack/esphome.git
synced 2026-05-20 11:52:52 -07:00
[mipi_rgb] Fix byte order and dirty bounds in fill() (#14537)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
035f985693
commit
d8deb2255d
@@ -288,9 +288,7 @@ void MipiRgb::draw_pixel_at(int x, int y, Color color) {
|
||||
if (!this->check_buffer_())
|
||||
return;
|
||||
size_t pos = (y * this->width_) + x;
|
||||
uint8_t hi_byte = static_cast<uint8_t>(color.r & 0xF8) | (color.g >> 5);
|
||||
uint8_t lo_byte = static_cast<uint8_t>((color.g & 0x1C) << 3) | (color.b >> 3);
|
||||
uint16_t new_color = hi_byte | (lo_byte << 8); // big endian
|
||||
uint16_t new_color = convert_big_endian(display::ColorUtil::color_to_565(color));
|
||||
if (this->buffer_[pos] == new_color)
|
||||
return;
|
||||
this->buffer_[pos] = new_color;
|
||||
@@ -315,10 +313,12 @@ void MipiRgb::fill(Color color) {
|
||||
}
|
||||
|
||||
auto *ptr_16 = reinterpret_cast<uint16_t *>(this->buffer_);
|
||||
uint8_t hi_byte = static_cast<uint8_t>(color.r & 0xF8) | (color.g >> 5);
|
||||
uint8_t lo_byte = static_cast<uint8_t>((color.g & 0x1C) << 3) | (color.b >> 3);
|
||||
uint16_t new_color = lo_byte | (hi_byte << 8); // little endian
|
||||
uint16_t new_color = convert_big_endian(display::ColorUtil::color_to_565(color));
|
||||
std::fill_n(ptr_16, this->width_ * this->height_, new_color);
|
||||
this->x_low_ = 0;
|
||||
this->y_low_ = 0;
|
||||
this->x_high_ = this->width_ - 1;
|
||||
this->y_high_ = this->height_ - 1;
|
||||
}
|
||||
|
||||
int MipiRgb::get_width() {
|
||||
|
||||
Reference in New Issue
Block a user