Accelerate clear screen in st7789 driver

This commit is contained in:
Thomas Klaehn 2020-04-17 07:35:36 +02:00
parent eecbba48d2
commit e3f57f80df

View File

@ -1,3 +1,4 @@
#include <array>
#include <cstdint>
#include "st7789.h"
@ -115,17 +116,21 @@ void St7789::send_data(uint8_t data)
void St7789::clear(uint16_t Color)
{
unsigned int i,j;
unsigned int odd = 0;
std::array<uint8_t, 240> line;
for(auto it = line.begin(); it != line.end(); ++it) {
if(odd % 2 == 0) {
*it = static_cast<uint8_t>((Color >> 8) & 0xff);
} else {
*it = static_cast<uint8_t>(Color & 0xff);
}
odd++;
}
set_windows(0, 0, 240, 240);
this->data_command.set();
for(i = 0; i < 240; i++) {
for(j = 0; j < 240; j++){
uint8_t c = (Color >> 8) & 0xff;
this->spi.send(&c, 1);
c = Color & 0xff;
this->spi.send(&c, 1);
}
for(unsigned int i = 0; i < 240 * 2; i++) {
this->spi.send(line.data(), line.size());
}
}