mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Add bootscreen
This commit is contained in:
parent
11309df661
commit
97248e67fc
45
include/bootscreen.h
Normal file
45
include/bootscreen.h
Normal file
@ -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 <pgmspace.h> // 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, 0x0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0x00, 0x00, 0xFF, 0x0F,
|
||||
0xEF, 0x0F, 0xC0, 0x03, 0x00, 0x80, 0x07, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x1E, 0x00, 0x78, 0x00, 0x00, 0x0F, 0x00,
|
||||
0xEF, 0x0F, 0xC0, 0x03, 0x00, 0x80, 0x07, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x1E, 0x00, 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,
|
||||
};
|
@ -48,6 +48,8 @@ TFT_Class tft(io, controller, TFT_WIDTH, TFT_HEIGHT);
|
||||
#include <GxCTRL/GxCTRL_ILI9341/GxCTRL_ILI9341.h> // 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);
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user