diff options
| author | JF <jf@codingfield.com> | 2019-12-07 18:15:33 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2019-12-07 18:15:33 (GMT) |
| commit | 528fc5661679feeef91e76d633c94c945bb0a3df (patch) | |
| tree | dba56aaf213dfa7eba9692293e1915fccd344be7 /src/drivers/St7789.cpp | |
| parent | 6fbb6c8f70b2103fd88d8d9da3ce884a283b1bfd (diff) | |
The font is now fixed width.
HUGE performance improvement of the display driver.
Diffstat (limited to 'src/drivers/St7789.cpp')
| -rw-r--r-- | src/drivers/St7789.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/drivers/St7789.cpp b/src/drivers/St7789.cpp index dcc32fe..0c18a61 100644 --- a/src/drivers/St7789.cpp +++ b/src/drivers/St7789.cpp @@ -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; - - SetAddrWindow(0+x, ST7789_ROW_OFFSET+y, x+width-1, y+height-1); + BeginDrawBuffer(x, y, width, height); - 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); +} + + |
