Accelerate clear screen in st7789 driver
This commit is contained in:
parent
eecbba48d2
commit
e3f57f80df
@ -1,3 +1,4 @@
|
|||||||
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "st7789.h"
|
#include "st7789.h"
|
||||||
@ -115,17 +116,21 @@ void St7789::send_data(uint8_t data)
|
|||||||
|
|
||||||
void St7789::clear(uint16_t Color)
|
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);
|
set_windows(0, 0, 240, 240);
|
||||||
this->data_command.set();
|
this->data_command.set();
|
||||||
for(i = 0; i < 240; i++) {
|
for(unsigned int i = 0; i < 240 * 2; i++) {
|
||||||
for(j = 0; j < 240; j++){
|
this->spi.send(line.data(), line.size());
|
||||||
uint8_t c = (Color >> 8) & 0xff;
|
|
||||||
this->spi.send(&c, 1);
|
|
||||||
c = Color & 0xff;
|
|
||||||
this->spi.send(&c, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user