mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
[ili9xxx] Improve fill operation performance (#4702)
Co-authored-by: Your Name <you@example.com>
This commit is contained in:
parent
b5dac00dcb
commit
8c32941428
1 changed files with 12 additions and 3 deletions
|
@ -84,9 +84,18 @@ void ILI9XXXDisplay::fill(Color color) {
|
|||
break;
|
||||
case BITS_16:
|
||||
new_color = display::ColorUtil::color_to_565(color);
|
||||
for (uint32_t i = 0; i < this->get_buffer_length_() * 2; i = i + 2) {
|
||||
this->buffer_[i] = (uint8_t) (new_color >> 8);
|
||||
this->buffer_[i + 1] = (uint8_t) new_color;
|
||||
{
|
||||
const uint32_t buffer_length_16_bits = this->get_buffer_length_() * 2;
|
||||
if (((uint8_t) (new_color >> 8)) == ((uint8_t) new_color)) {
|
||||
// Upper and lower is equal can use quicker memset operation. Takes ~20ms.
|
||||
memset(this->buffer_, (uint8_t) new_color, buffer_length_16_bits);
|
||||
} else {
|
||||
// Slower set of both buffers. Takes ~30ms.
|
||||
for (uint32_t i = 0; i < buffer_length_16_bits; i = i + 2) {
|
||||
this->buffer_[i] = (uint8_t) (new_color >> 8);
|
||||
this->buffer_[i + 1] = (uint8_t) new_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue