The font is now fixed width.

HUGE performance improvement of the display driver.
This commit is contained in:
JF
2019-12-07 19:15:33 +01:00
parent 6fbb6c8f70
commit 528fc56616
8 changed files with 4356 additions and 4279 deletions

View File

@@ -91,22 +91,17 @@ void St7789::DisplayOn() {
}
void St7789::FillRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) {
// rudimentary clipping (drawChar w/big text requires this)
if((x >= Width) || (y >= Height)) return;
if((x + width - 1) >= Width) width = Width - x;
if((y + height - 1) >= Height) height = Height - y;
BeginDrawBuffer(x, y, width, height);
SetAddrWindow(0+x, ST7789_ROW_OFFSET+y, x+width-1, y+height-1);
uint8_t hi = color >> 8, lo = color;
uint32_t c = color + (color << 16);
uint8_t w = width/2;
nrf_gpio_pin_set(pinDataCommand);
for(y=height+ST7789_ROW_OFFSET; y>ST7789_ROW_OFFSET; y--) {
for(x=width; x>0; x--) {
WriteSpi(reinterpret_cast<const uint8_t *>(&c), 4);
for(x=w; x>0; x--) {
NextDrawBuffer(reinterpret_cast<const uint8_t *>(&c), 4);
}
}
EndDrawBuffer();
}
void St7789::SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
@@ -147,3 +142,20 @@ void St7789::DrawPixel(uint16_t x, uint16_t y, uint32_t color) {
WriteSpi(reinterpret_cast<const uint8_t *>(&color), 2);
}
void St7789::BeginDrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height) {
if((x >= Width) || (y >= Height)) return;
if((x + width - 1) >= Width) width = Width - x;
if((y + height - 1) >= Height) height = Height - y;
SetAddrWindow(0+x, ST7789_ROW_OFFSET+y, x+width-1, y+height-1);
nrf_gpio_pin_set(pinDataCommand);
}
void St7789::EndDrawBuffer() {
}
void St7789::NextDrawBuffer(const uint8_t *data, size_t size) {
spi.Write(data, size);
}