diff options
author | JF <jf@codingfield.com> | 2019-12-07 19:15:33 +0100 |
---|---|---|
committer | JF <jf@codingfield.com> | 2019-12-07 19:15:33 +0100 |
commit | 528fc5661679feeef91e76d633c94c945bb0a3df (patch) | |
tree | dba56aaf213dfa7eba9692293e1915fccd344be7 /src/Components/Gfx/Gfx.cpp | |
parent | 6fbb6c8f70b2103fd88d8d9da3ce884a283b1bfd (diff) |
The font is now fixed width.
HUGE performance improvement of the display driver.
Diffstat (limited to 'src/Components/Gfx/Gfx.cpp')
-rw-r--r-- | src/Components/Gfx/Gfx.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/Components/Gfx/Gfx.cpp b/src/Components/Gfx/Gfx.cpp index e948c6c9..3621b055 100644 --- a/src/Components/Gfx/Gfx.cpp +++ b/src/Components/Gfx/Gfx.cpp @@ -8,7 +8,11 @@ Gfx::Gfx(Pinetime::Drivers::St7789 &lcd) : lcd{lcd} { } void Gfx::ClearScreen() { - lcd.FillRectangle(0, 0, width, height, 0xffff); + lcd.FillRectangle(0, 0, width, height, 0x0000); +} + +void Gfx::FillRectangle(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint16_t color) { + lcd.FillRectangle(x, y, width, height, color); } void Gfx::DrawString(uint8_t x, uint8_t y, uint16_t color, const char *text, const FONT_INFO *p_font, bool wrap) { @@ -55,17 +59,25 @@ void Gfx::DrawChar(const FONT_INFO *font, uint8_t c, uint8_t *x, uint8_t y, uint return; } + // TODO For now, LCD and SPI driver start a new transfer (cs pin + set address windows + write byte) FOR EACH PIXEL! + // This could be improved by setting CS pin, DC pin and address window ONLY ONCE for the whole character + + lcd.BeginDrawBuffer(*x, y, bytes_in_line*8, font->height); + uint16_t bg = 0x0000; for (uint16_t i = 0; i < font->height; i++) { for (uint16_t j = 0; j < bytes_in_line; j++) { for (uint8_t k = 0; k < 8; k++) { if ((1 << (7 - k)) & font->data[font->charInfo[char_idx].offset + i * bytes_in_line + j]) { - pixel_draw(*x + j * 8 + k, y + i, color); + lcd.NextDrawBuffer(reinterpret_cast<uint8_t *>(&color), 2); + } + else { + lcd.NextDrawBuffer(reinterpret_cast<uint8_t *>(&bg), 2); } } } } - + lcd.EndDrawBuffer(); *x += font->charInfo[char_idx].widthBits + font->spacePixels; } |