diff --git a/include/bootscreen.h b/include/bootscreen.h new file mode 100644 index 00000000..16ce2cf0 --- /dev/null +++ b/include/bootscreen.h @@ -0,0 +1,45 @@ +// Images can be converted to XBM format by using the online converter here: +// https://www.online-utility.org/image/convert/to/XBM + +// The output must be pasted in a header file, renamed and adjusted to appear +// as as a const unsigned char array in PROGMEM (FLASH program memory). + +// The xbm format adds padding to pixel rows so they are a whole number of bytes +// In this example 50 pixel width means 56 bits = 7 bytes +// the 50 height then means array uses 50 x 7 = 350 bytes of FLASH +// The library ignores the padding bits when drawing the image on the display. + +// The NetWize logo uses the MaterialDesign icons font, released under the OFL license + +#include // PROGMEM support header + +#define logoWidth 148 +#define logoHeight 24 + +// Image is stored in this array +PROGMEM const unsigned char bootscreen[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0F, 0x0F, 0xC0, 0xFF, 0x03, 0xF8, 0x7F, 0x00, 0x0F, 0x00, 0x0F, 0x80, 0x7F, 0x00, 0xFE, 0x1F, 0x00, 0xFF, 0x0F, + 0x1F, 0x0F, 0xC0, 0xFF, 0x03, 0xF8, 0x7F, 0x00, 0x0F, 0x00, 0x0F, 0x80, 0x7F, 0x00, 0xFE, 0x1F, 0x00, 0xFF, 0x0F, + 0x1F, 0x0F, 0xC0, 0xFF, 0x03, 0xF8, 0x7F, 0x00, 0x0F, 0x0F, 0x0F, 0x80, 0x7F, 0x00, 0xFE, 0x1F, 0x00, 0xFF, 0x0F, + 0x1F, 0x0F, 0xC0, 0xFF, 0x03, 0xF8, 0x7F, 0x00, 0x0F, 0x0F, 0x0F, 0x80, 0x7F, 0x00, 0xFE, 0x1F, 0x00, 0xFF, 0x0F, + 0x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 0x78, 0x00, 0x00, 0x0F, 0x00, + 0xCF, 0x0F, 0xC0, 0x03, 0x00, 0x80, 0x07, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x1E, 0x00, 0x3C, 0x00, 0x00, 0x0F, 0x00, + 0xCF, 0x0F, 0xC0, 0x03, 0x00, 0x80, 0x07, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x1E, 0x00, 0x1E, 0x00, 0x00, 0x0F, 0x00, + 0x8F, 0x0F, 0xC0, 0xFF, 0x03, 0x80, 0x07, 0x00, 0xFF, 0xFF, 0x0F, 0x80, 0x7F, 0x00, 0xFE, 0x1F, 0x00, 0xFF, 0x0F, + 0x8F, 0x0F, 0xC0, 0xFF, 0x03, 0x80, 0x07, 0x00, 0xFF, 0xFF, 0x0F, 0x80, 0x7F, 0x00, 0xFE, 0x1F, 0x00, 0xFF, 0x0F, + 0x8F, 0x0F, 0xC0, 0xFF, 0x03, 0x80, 0x07, 0x00, 0xFE, 0xFF, 0x07, 0x80, 0x7F, 0x00, 0xFE, 0x1F, 0x00, 0xFF, 0x0F, + 0x0F, 0x0F, 0xC0, 0xFF, 0x03, 0x80, 0x07, 0x00, 0xFC, 0xFF, 0x03, 0x80, 0x7F, 0x00, 0xFE, 0x1F, 0x00, 0xFF, 0x0F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; diff --git a/lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp b/lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp index 9448fcbe..b18eca48 100644 --- a/lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp +++ b/lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp @@ -48,6 +48,8 @@ TFT_Class tft(io, controller, TFT_WIDTH, TFT_HEIGHT); #include // 240x320 #include "GxReadRegisters.h" +#include "bootscreen.h" // Sketch tab header for xbm images + /********************* * DEFINES *********************/ @@ -76,18 +78,35 @@ TFT_Class tft(io, controller, TFT_WIDTH, TFT_HEIGHT); **********************/ /** - * Initialize the R61581 display controller - * @return HW_RES_OK or any error from hw_res_t enum + * Initialize the ILI9341 display controller */ void fsmc_ili9341_init(uint8_t rotation) { tft.init(); tft.setRotation(rotation); - // tft.fillScreen(BLUE); + tft.setRotation(rotation); + tft.fillScreen(TFT_DARKCYAN); + int x = (tft.width() - logoWidth) / 2; + int y = (tft.height() - logoHeight) / 2; + // tft.drawBitmap(x, y, bootscreen, logoWidth, logoHeight, TFT_WHITE); + + io.startTransaction(); + int32_t i, j, byteWidth = (logoWidth + 7) / 8; + + for(j = 0; j < logoHeight; j++) { + for(i = 0; i < logoWidth; i++) { + if(pgm_read_byte(bootscreen + j * byteWidth + i / 8) & (1 << (i & 7))) { + tft.drawPixel(x + i, y + j, TFT_WHITE); + } + } + } + + io.endTransaction(); + delay(800); } /* GxTFT::pushColors only supports writing up to 255 at a time */ -/* This local function circumvents this artificial limit */ +/* This *local* function circumvents this artificial limititaion */ static inline void pushColors(uint16_t * data, uint32_t len) { io.startTransaction(); @@ -103,21 +122,9 @@ void fsmc_ili9341_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color tft.setWindow(x1, y1, x2, y2); size_t len = (x2 - x1 + 1) * (y2 - y1 + 1); /* Number of pixels */ -#if 1 +#if 1 // use local version instead pushColors((uint16_t *)color_p, len); #else - // tft.init(); - // Serial.print("flush "); - // Serial.print(x1); - // Serial.print(" "); - // Serial.print(y1); - // Serial.print(" "); - // Serial.print(x2); - // Serial.print(" "); - // Serial.print(y2); - // Serial.print(" "); - // Serial.println(len); - /* Update TFT */ while(len > 255) { tft.pushColors((uint16_t *)color_p, 255); diff --git a/lib/lv_drv_tft_espi/tft_espi_drv.cpp b/lib/lv_drv_tft_espi/tft_espi_drv.cpp index e87aed5c..cb435cba 100644 --- a/lib/lv_drv_tft_espi/tft_espi_drv.cpp +++ b/lib/lv_drv_tft_espi/tft_espi_drv.cpp @@ -16,6 +16,7 @@ #include LV_DRV_DISP_INCLUDE #include LV_DRV_DELAY_INCLUDE #include "../../../src/hasp_tft.h" +#include "bootscreen.h" // Sketch tab header for xbm images /********************* * DEFINES @@ -53,6 +54,9 @@ void tft_espi_init(uint8_t rotation) tft.setSwapBytes(true); /* set endianess */ tft.setRotation(rotation); tft.fillScreen(TFT_DARKCYAN); + int x = (tft.width() - logoWidth) / 2; + int y = (tft.height() - logoHeight) / 2; + tft.drawXBitmap(x, y, bootscreen, logoWidth, logoHeight, TFT_WHITE); #ifdef USE_DMA_TO_TFT // DMA - should work with STM32F2xx/F4xx/F7xx processors