diff --git a/src/core/display.cpp b/src/core/display.cpp index 30eea3c6c..9cc03ffda 100644 --- a/src/core/display.cpp +++ b/src/core/display.cpp @@ -792,7 +792,7 @@ void jpegRender(int xpos, int ypos) { } -bool showJpeg(FS fs, String filename, int x, int y) { +bool showJpeg(FS fs, String filename, int x, int y, bool center) { File picture; if(fs.exists(filename)) picture = fs.open(filename, FILE_READ); @@ -848,6 +848,10 @@ bool showJpeg(FS fs, String filename, int x, int y) { } if (decoded) { + if(center) { + x=(WIDTH-JpegDec.width)/2; + y=(HEIGHT-JpegDec.height)/2; + } jpegRender(x, y); } @@ -1044,8 +1048,8 @@ int32_t GIFSeekFile(GIFFILE *pFile, int32_t iPosition) } bool showGIF(FS fs, String filename, int x, int y) { -//#if defined(CONFIG_IDF_TARGET_ESP32S3) -#if defined(CARDPUTER) +#if defined(CONFIG_IDF_TARGET_ESP32S3) +//#if defined(CARDPUTER) if(!fs.exists(filename)) return false; static AnimatedGIF gif; // MEMO: triggers stack canary if not static diff --git a/src/core/display.h b/src/core/display.h index 6f5a0653e..a1e6857a4 100644 --- a/src/core/display.h +++ b/src/core/display.h @@ -21,7 +21,7 @@ struct Opt_Coord { void displayScrollingText(const String& text, Opt_Coord& coord); bool showGIF(FS fs,String filename, int x=0, int y=0); -bool showJpeg(FS fs,String filename, int x=0, int y=0); +bool showJpeg(FS fs,String filename, int x=0, int y=0, bool center = false); uint16_t getComplementaryColor(uint16_t color); uint16_t getColorVariation(uint16_t color, int delta = 10, int direction = 0); diff --git a/src/core/sd_functions.cpp b/src/core/sd_functions.cpp index d7b4f37c3..862f449fa 100644 --- a/src/core/sd_functions.cpp +++ b/src/core/sd_functions.cpp @@ -633,7 +633,7 @@ String loopSD(FS &fs, bool filePicker, String allowed_ext) { // custom file formats commands added in front if(filepath.endsWith(".jpg")) options.insert(options.begin(), {"View Image", [&]() { - showJpeg(fs, filepath); + showJpeg(fs, filepath,0,0,true); delay(750); while(!checkAnyKeyPress()) yield(); }}); diff --git a/src/main.cpp b/src/main.cpp index 823822565..db430aefe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -157,24 +157,25 @@ void boot_screen_anim() { boot_screen(); int i = millis(); // checks for boot.jpg in SD and LittleFS for customization - bool boot_img=false; - if(SD.exists("/boot.jpg")) boot_img = true; - else if(LittleFS.exists("/boot.jpg")) boot_img = true; - else if(SD.exists("/boot.gif")) boot_img = true; - else if(LittleFS.exists("/boot.gif")) boot_img = true; + int boot_img=0; + bool drawn=false; + if(SD.exists("/boot.jpg")) boot_img = 1; + else if(LittleFS.exists("/boot.jpg")) boot_img = 2; + else if(SD.exists("/boot.gif")) boot_img = 3; + else if(LittleFS.exists("/boot.gif")) boot_img = 4; // Start image loop while(millis()2000) && (millis()-i)<2200){ + if((millis()-i>2000) && !drawn) { tft.fillRect(0,45,WIDTH,HEIGHT-45,bruceConfig.bgColor); - if(boot_img && !drawn) { - if(showJpeg(SD,"/boot.jpg") && (millis()-i>2000) && (millis()-i<2200)) { boot_img=true; Serial.println("Image from SD"); } - else if (showJpeg(LittleFS,"/boot.jpg") && (millis()-i>2000) && (millis()-i<2100)) { boot_img=true; Serial.println("Image from LittleFS"); } - else if (showGIF(SD,"/boot.gif") && (millis()-i>2000) && (millis()-i<2200)) { boot_img=true; Serial.println("Image from SD"); } - else if (showGIF(LittleFS,"/boot.gif") && (millis()-i>2000) && (millis()-i<2100)) { boot_img=true; Serial.println("Image from LittleFS"); } - drawn=true; + if(boot_img > 0 && !drawn) { + tft.fillScreen(bruceConfig.bgColor); + if(boot_img==1) { showJpeg(SD,"/boot.jpg",0,0,true); Serial.println("Image from SD"); } + else if (boot_img==2) { showJpeg(LittleFS,"/boot.jpg",0,0,true); Serial.println("Image from LittleFS"); } + else if (boot_img==3) { showGIF(SD,"/boot.gif"); Serial.println("Image from SD"); } + else if (boot_img==4) { showGIF(LittleFS,"/boot.gif"); Serial.println("Image from LittleFS"); } } + drawn=true; } if(!boot_img && (millis()-i>2200) && (millis()-i)<2700) tft.drawRect(2*WIDTH/3,HEIGHT/2,2,2,bruceConfig.priColor); if(!boot_img && (millis()-i>2700) && (millis()-i)<2900) tft.fillRect(0,45,WIDTH,HEIGHT-45,bruceConfig.bgColor); @@ -336,7 +337,7 @@ void loop() { } if (redraw) { - mainMenu.draw(); + mainMenu.draw(float((float)HEIGHT/(float)135)); clock_update=0; // forces clock drawing redraw = false; delay(REDRAW_DELAY);