Skip to content

Commit

Permalink
Boot img and Menu drawings size
Browse files Browse the repository at this point in the history
Fixed gif message on boot screen for non Cardputer devices
Allowed ESP32-S3 devices to see GIFs (couldn't find a file that works though)
  • Loading branch information
bmorcelli committed Dec 9, 2024
1 parent 89624fb commit 1482ab3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
10 changes: 7 additions & 3 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/core/sd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}});
Expand Down
29 changes: 15 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()<i+7000) { // boot image lasts for 5 secs
#if !defined(LITE_VERSION)
bool drawn=false;
if((millis()-i>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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1482ab3

Please sign in to comment.