From ac8c3dd31355d442ad35e343f0e94916b77c821c Mon Sep 17 00:00:00 2001 From: david-robson Date: Mon, 27 Mar 2017 00:47:42 +0200 Subject: [PATCH] Update GfxUi.cpp The display of the bmp images was not working (nothing displayed, everything else working ok). The pixels were being calculated and written OK. I guess the "setAddrWindow" is not working as expected. I changed to use the "writePixel" instruction instead. --- GfxUi.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/GfxUi.cpp b/GfxUi.cpp index 86819b4..6c0bc5e 100644 --- a/GfxUi.cpp +++ b/GfxUi.cpp @@ -145,8 +145,8 @@ void GfxUi::drawBmp(String filename, uint8_t x, uint16_t y) { if((x+w-1) >= _tft->width()) w = _tft->width() - x; if((y+h-1) >= _tft->height()) h = _tft->height() - y; - // Set TFT address window to clipped image bounds - _tft->setAddrWindow(x, y, x+w-1, y+h-1); + // Open write access to the tft + _tft->startWrite(); for (row=0; row= sizeof(sdbuffer)) { // Indeed bmpFile.read(sdbuffer, sizeof(sdbuffer)); @@ -176,10 +177,15 @@ void GfxUi::drawBmp(String filename, uint8_t x, uint16_t y) { b = sdbuffer[buffidx++]; g = sdbuffer[buffidx++]; r = sdbuffer[buffidx++]; - _tft->pushColor(_tft->color565(r,g,b)); + + _tft->writePixel(x+col,y+row,_tft->color565(r,g,b)); + yield(); } // end pixel } // end scanline + + _tft->endWrite(); + Serial.print(F("Loaded in ")); Serial.print(millis() - startTime); Serial.println(" ms"); @@ -210,4 +216,3 @@ uint32_t GfxUi::read32(File &f) { ((uint8_t *)&result)[3] = f.read(); // MSB return result; } -