From 71e7d02b970d08a900f2dfed2cc14a21ed97b413 Mon Sep 17 00:00:00 2001 From: Pirata Date: Sun, 5 Jan 2025 17:07:30 -0300 Subject: [PATCH] Never gonna say goodbye --- boards/CYD-2432S028/platformio.ini | 1 - boards/_New-Device-Model/platformio.ini | 1 - boards/lilygo-t-deck/platformio.ini | 1 - boards/lilygo-t-display-s3-pro/platformio.ini | 1 - .../lilygo-t-display-s3-touch/platformio.ini | 1 - boards/lilygo-t-embed-cc1101/platformio.ini | 2 - boards/m5stack-cardputer/platformio.ini | 1 - boards/m5stack-core/platformio.ini | 1 - boards/m5stack-core2/platformio.ini | 1 - boards/m5stack-cores3/platformio.ini | 3 - boards/m5stack-cplus1_1/platformio.ini | 2 - boards/m5stack-cplus2.json | 4 +- boards/m5stack-cplus2/platformio.ini | 4 - boards/marauder-mini/platformio.ini | 1 - boards/marauder-v4og/platformio.ini | 1 - boards/pinouts/m5stack-cores3.h | 19 ++- include/pre_compiler.h | 4 - src/display.cpp | 126 +++++++++++------- src/main.cpp | 8 +- src/onlineLauncher.cpp | 12 +- src/partitioner.cpp | 7 +- src/powerSave.cpp | 4 - src/sd_functions.cpp | 15 +-- src/settings.cpp | 8 +- src/webInterface.cpp | 2 - 25 files changed, 105 insertions(+), 125 deletions(-) diff --git a/boards/CYD-2432S028/platformio.ini b/boards/CYD-2432S028/platformio.ini index 6866879..a7b10fd 100644 --- a/boards/CYD-2432S028/platformio.ini +++ b/boards/CYD-2432S028/platformio.ini @@ -22,7 +22,6 @@ build_flags = -Os -DCYD=1 - -DREDRAW_DELAY=200 -DPART_04MB=1 ;-DPART_08MB =0 diff --git a/boards/_New-Device-Model/platformio.ini b/boards/_New-Device-Model/platformio.ini index 8b0b9c9..2e09dfd 100644 --- a/boards/_New-Device-Model/platformio.ini +++ b/boards/_New-Device-Model/platformio.ini @@ -20,7 +20,6 @@ build_flags = -mfix-esp32-psram-cache-strategy=memw -DSTICK_C_PLUS2=1 - -DREDRAW_DELAY=200 ;-DPART_04MB=1 -DPART_08MB=1 diff --git a/boards/lilygo-t-deck/platformio.ini b/boards/lilygo-t-deck/platformio.ini index bd0f625..f4bd350 100644 --- a/boards/lilygo-t-deck/platformio.ini +++ b/boards/lilygo-t-deck/platformio.ini @@ -21,7 +21,6 @@ build_flags = -DT_DECK=1 -DPIN_POWER_ON=10 - -DREDRAW_DELAY=250 -DBK_BTN=6 ;-DPART_04MB =0 diff --git a/boards/lilygo-t-display-s3-pro/platformio.ini b/boards/lilygo-t-display-s3-pro/platformio.ini index e2db04e..6c1ceb1 100644 --- a/boards/lilygo-t-display-s3-pro/platformio.ini +++ b/boards/lilygo-t-display-s3-pro/platformio.ini @@ -23,7 +23,6 @@ build_flags = -DT_DISPLAY_S3=1 -DT_DISPLAY_S3_PRO=1 - -DREDRAW_DELAY=200 ;-DPART_04MB =0 ;-DPART_08MB =0 diff --git a/boards/lilygo-t-display-s3-touch/platformio.ini b/boards/lilygo-t-display-s3-touch/platformio.ini index 7fd295e..7525a19 100644 --- a/boards/lilygo-t-display-s3-touch/platformio.ini +++ b/boards/lilygo-t-display-s3-touch/platformio.ini @@ -22,7 +22,6 @@ build_flags = -DT_DISPLAY_S3=1 -DT_DISPLAY_S3_TOUCH=1 - -DREDRAW_DELAY=200 ;-DPART_04MB =0 ;-DPART_08MB =0 diff --git a/boards/lilygo-t-embed-cc1101/platformio.ini b/boards/lilygo-t-embed-cc1101/platformio.ini index 6e533fd..8505169 100644 --- a/boards/lilygo-t-embed-cc1101/platformio.ini +++ b/boards/lilygo-t-embed-cc1101/platformio.ini @@ -25,7 +25,6 @@ build_flags = -DT_EMBED=1 -DPIN_POWER_ON=46 - -DREDRAW_DELAY=1 -DBK_BTN=6 ;-DPART_04MB =0 @@ -110,7 +109,6 @@ build_flags = -DT_EMBED=1 -DT_EMBED_1101=1 -DPIN_POWER_ON=15 - -DREDRAW_DELAY=0 -DBK_BTN=6 ;-DPART_04MB =0 diff --git a/boards/m5stack-cardputer/platformio.ini b/boards/m5stack-cardputer/platformio.ini index 4501c62..101841b 100644 --- a/boards/m5stack-cardputer/platformio.ini +++ b/boards/m5stack-cardputer/platformio.ini @@ -19,7 +19,6 @@ build_flags = -DCORE_DEBUG_LEVEL=5 -DARDUINO_USB_CDC_ON_BOOT=1 -DCARDPUTER=1 - -DREDRAW_DELAY=200 ;-DPART_04MB =0 -DPART_08MB=1 diff --git a/boards/m5stack-core/platformio.ini b/boards/m5stack-core/platformio.ini index 4b0cc86..41eb797 100644 --- a/boards/m5stack-core/platformio.ini +++ b/boards/m5stack-core/platformio.ini @@ -22,7 +22,6 @@ build_flags = -mfix-esp32-psram-cache-strategy=memw -DCORE=1 - -DREDRAW_DELAY=200 ;-DPART_04MB =0 ;-DPART_08MB =0 diff --git a/boards/m5stack-core2/platformio.ini b/boards/m5stack-core2/platformio.ini index 9d1dc6d..05ad9ed 100644 --- a/boards/m5stack-core2/platformio.ini +++ b/boards/m5stack-core2/platformio.ini @@ -22,7 +22,6 @@ build_flags = -mfix-esp32-psram-cache-strategy=memw -DCORE2=1 - -DREDRAW_DELAY=200 ;-DPART_04MB =0 ;-DPART_08MB =0 diff --git a/boards/m5stack-cores3/platformio.ini b/boards/m5stack-cores3/platformio.ini index 5322f3b..2a8b657 100644 --- a/boards/m5stack-cores3/platformio.ini +++ b/boards/m5stack-cores3/platformio.ini @@ -17,11 +17,8 @@ build_flags = ${env.build_flags} -Iboards/m5stack-cores3 ;-DCORE_DEBUG_LEVEL=5 - -DBOARD_HAS_PSRAM - -DARDUINO_USB_CDC_ON_BOOT=1 -DCORE3=1 - -DREDRAW_DELAY=200 ;-DPART_04MB =0 ;-DPART_08MB =0 diff --git a/boards/m5stack-cplus1_1/platformio.ini b/boards/m5stack-cplus1_1/platformio.ini index beacd98..7e947d4 100644 --- a/boards/m5stack-cplus1_1/platformio.ini +++ b/boards/m5stack-cplus1_1/platformio.ini @@ -20,7 +20,6 @@ build_flags = -DCONFIG_ESP32_JTAG_SUPPORT_DISABLE=1 -Wl,--gc-sections -DSTICK_C_PLUS=1 - -DREDRAW_DELAY=200 -DPART_04MB=1 ;-DPART_08MB =0 @@ -84,7 +83,6 @@ build_flags = -Os -DSTICK_C=1 -DSTICK_C_PLUS=1 - -DREDRAW_DELAY=200 -DPART_04MB=1 ;-DPART_08MB =0 diff --git a/boards/m5stack-cplus2.json b/boards/m5stack-cplus2.json index 5b7e23b..700bd3d 100644 --- a/boards/m5stack-cplus2.json +++ b/boards/m5stack-cplus2.json @@ -30,9 +30,9 @@ ], "name": "M5Stick CPlus2", "upload": { - "flash_size": "4MB", + "flash_size": "8MB", "maximum_ram_size": 327680, - "maximum_size": 4194304, + "maximum_size": 8388608, "require_upload_port": true, "speed": 1500000 }, diff --git a/boards/m5stack-cplus2/platformio.ini b/boards/m5stack-cplus2/platformio.ini index 77bb8f1..4c74cbd 100644 --- a/boards/m5stack-cplus2/platformio.ini +++ b/boards/m5stack-cplus2/platformio.ini @@ -17,12 +17,8 @@ build_flags = ${env.build_flags} -Iboards/m5stack-cplus2 ;-DCORE_DEBUG_LEVEL=5 - -DBOARD_HAS_PSRAM - -mfix-esp32-psram-cache-issue - -mfix-esp32-psram-cache-strategy=memw -DSTICK_C_PLUS2=1 - -DREDRAW_DELAY=200 ;-DPART_04MB=1 -DPART_08MB=1 diff --git a/boards/marauder-mini/platformio.ini b/boards/marauder-mini/platformio.ini index c930eaa..8c60d40 100644 --- a/boards/marauder-mini/platformio.ini +++ b/boards/marauder-mini/platformio.ini @@ -22,7 +22,6 @@ build_flags = -Os -DMARAUDERMINI=1 - -DREDRAW_DELAY=200 -DPART_04MB=1 ;-DPART_08MB =0 diff --git a/boards/marauder-v4og/platformio.ini b/boards/marauder-v4og/platformio.ini index ac74f4c..7b3690e 100644 --- a/boards/marauder-v4og/platformio.ini +++ b/boards/marauder-v4og/platformio.ini @@ -22,7 +22,6 @@ build_flags = -Os -DMARAUDERV4=1 - -DREDRAW_DELAY=200 -DPART_04MB=1 ;-DPART_08MB =0 diff --git a/boards/pinouts/m5stack-cores3.h b/boards/pinouts/m5stack-cores3.h index 1cab33b..a8d8952 100644 --- a/boards/pinouts/m5stack-cores3.h +++ b/boards/pinouts/m5stack-cores3.h @@ -60,7 +60,6 @@ static const uint8_t G46 = 46; static const uint8_t ADC = 10; - #define HAS_RTC #define USB_as_HID @@ -89,11 +88,11 @@ static const uint8_t ADC = 10; #define M5STACK #define TFT_HEIGHT 320 #define TFT_WIDTH 240 -#define TFT_MOSI MOSI -#define TFT_MISO MISO -#define TFT_SCLK SCK -#define TFT_CS G3 -#define TFT_DC G35 +#define TFT_MOSI 37 +#define TFT_MISO 35 +#define TFT_SCLK 36 +#define TFT_CS 3 +#define TFT_DC 35 #define TFT_RST -1 #define TFT_BL -1 #define TOUCH_CS -1 @@ -108,10 +107,10 @@ static const uint8_t ADC = 10; #define BTN_ACT LOW // SD Card Setup pins -#define SDCARD_CS G4 -#define SDCARD_SCK SCK -#define SDCARD_MISO MISO -#define SDCARD_MOSI MOSI +#define SDCARD_CS 4 +#define SDCARD_SCK 36 +#define SDCARD_MISO 35 +#define SDCARD_MOSI 37 // Default I2C port #define GROVE_SDA 32 diff --git a/include/pre_compiler.h b/include/pre_compiler.h index 2afe596..d523c38 100644 --- a/include/pre_compiler.h +++ b/include/pre_compiler.h @@ -1,7 +1,3 @@ -#ifndef REDRAW_DELAY -#define REDRAW_DELAY 250 -#endif - #if !defined(PART_04MB) && !defined(PART_08MB) && !defined(PART_16MB) && !defined(HEADLESS) #define PART_04MB 1 #endif diff --git a/src/display.cpp b/src/display.cpp index 120d485..3f32bec 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -598,7 +598,6 @@ void loopOptions(const std::vector> setBrightness(100*(numOpt-index)/numOpt,false); } redraw=false; - delay(REDRAW_DELAY); } String txt=options[index].first.c_str(); displayScrollingText(txt, coord); @@ -624,7 +623,6 @@ void loopOptions(const std::vector> } if(millis()-longPrevTmp>200) tft.drawArc(tftWidth/2, tftHeight/2, 25,15,0,360*(millis()-(longPrevTmp+200))/500,FGCOLOR-0x1111,BGCOLOR,true); if(millis()-longPrevTmp>700) { // longpress detected to exit - delay(200); break; } else goto WAITING; @@ -649,7 +647,6 @@ void loopOptions(const std::vector> if(check(EscPress)) break; #endif } - delay(200); } /********************************************************************* @@ -665,6 +662,8 @@ void loopVersions() { JsonArray versions = item["versions"]; bool redraw = true; + bool longPrevPress = false; + long longPrevTmp=millis(); while(1) { if(returnToMenu) break; // Stops the loop to get back to Main menu @@ -687,46 +686,60 @@ void loopVersions() { displayCurrentVersion(String(name), String(author), String(version), String(published_at), versionIndex, versions); redraw = false; - delay(REDRAW_DELAY); } /* DW Btn to next item */ if(check(NextPress)) { versionIndex++; if(versionIndex>versions.size()-1) versionIndex = 0; redraw = true; - delay(REDRAW_DELAY); } /* UP Btn go back to FW menu and ´<´ go to previous version item */ - #ifdef ESC_LOGIC + #if defined(T_EMBED) || defined(HAS_TOUCH) || defined(HAS_KEYBOARD) /* UP Btn go to previous item */ if(check(PrevPress)) { versionIndex--; if(versionIndex<0) versionIndex = versions.size()-1; redraw = true; - delay(200); } - if(checkEscPress()) { - delay(200); + if(check(EscPress)) { goto SAIR; } #else // Esc logic is holding previous btn fot 1 second +- - - if(check(PrevPress)) { - long _tmp=millis(); - while(check(PrevPress)) { if(millis()-_tmp>200) tft.drawArc(tftWidth/2, tftHeight/2, 25,15,0,360*(millis()-(_tmp+200))/500,FGCOLOR-0x1111,BGCOLOR,true); } - if(millis()-_tmp>700) { // longpress detected to exit - delay(200); - goto SAIR; + if(longPrevPress || PrevPress) { + if(!longPrevPress) { + longPrevPress = true; + longPrevTmp = millis(); } - else { - if(versionIndex==0) versionIndex = versions.size() - 1; - else if(versionIndex>0) versionIndex--; - redraw = true; + if(longPrevPress && millis()-longPrevTmp<800) { + WAITING: + vTaskDelay(10/portTICK_PERIOD_MS); + if(!PrevPress && millis()-longPrevTmp<200) { + AnyKeyPress=false; + if(versionIndex==0) versionIndex = versions.size() - 1; + else if(versionIndex>0) versionIndex--; + longPrevPress=false; + redraw = true; + } + if(!PrevPress && millis()-longPrevTmp>200) { + check(PrevPress); + redraw=true; + longPrevPress=false; + goto EXIT_CHECK; + } + if(millis()-longPrevTmp>200) tft.drawArc(tftWidth/2, tftHeight/2, 25,15,0,360*(millis()-(longPrevTmp+200))/500,FGCOLOR-0x1111,BGCOLOR,true); + if(millis()-longPrevTmp>700) { // longpress detected to exit + returnToMenu=true; + check(PrevPress); + goto SAIR; + } else goto WAITING; } + EXIT_CHECK: + yield(); } + #endif /* Select to install */ @@ -738,8 +751,6 @@ void loopVersions() { {"Download->SD", [=]() { downloadFirmware(String(file), String(name) + "." + String(version).substring(0,10), dwn_path); }}, {"Back to List", [=]() { returnToMenu=true; }}, }; - delay(200); - loopOptions(options); // On fail installing will run the following line redraw = true; @@ -761,57 +772,75 @@ void loopVersions() { ** Where you choose which Firmware to see more data **********************************************************************/ void loopFirmware(){ + bool longSelPress = false; + long longSelTmp=millis(); currentIndex=0; - delay(200); //debounce from previous btn press displayCurrentItem(doc, currentIndex); while(1){ - if(returnToMenu) break; // break the loop and gets back to Main Menu - if (WiFi.status() == WL_CONNECTED) { /* UP Btn go to previous item */ if(check(PrevPress)) { if(currentIndex==0) currentIndex = doc.size() - 1; else if(currentIndex>0) currentIndex--; displayCurrentItem(doc, currentIndex); - delay(REDRAW_DELAY); - } /* DW Btn to next item */ if(check(NextPress)) { currentIndex++; if((currentIndex+1)>doc.size()) currentIndex = 0; displayCurrentItem(doc, currentIndex); - delay(REDRAW_DELAY); } - /* Select to install */ - if(check(SelPress)) { - + //Checks for long press to get back to Main Menu, only for StickCs.. Cardputer uses Esc btn - #ifndef ESC_LOGIC - int time = millis(); // Saves the moment when the btn was pressed - while(check(SelPress)) { - - if((millis()-time)>150) tft.drawArc(tftWidth/2,tftHeight/2,25,15,0,360*(millis()-time)/1000,ALCOLOR,BGCOLOR,false); - } // while pressed the btn, hold the code to count the time - if((millis()-time)>1000) break;// check how many ms it was kept held on and stop the loop if more than 250ms - else { + #if defined(T_EMBED) || defined(HAS_TOUCH) || defined(HAS_KEYBOARD) + /* Select to install */ + if(check(SelPress)) { + loopVersions(); + delay(200); + returnToMenu=false; + } + #else + if(longSelPress || SelPress) { + if(!longSelPress) { + longSelPress = true; + longSelTmp = millis(); + } + if(longSelPress && millis()-longSelTmp<250) goto WAITING; + longSelPress=false; + if(check(SelPress)) { + bool exit=false; + options = { + {"View version",[=](){ loopVersions(); }}, + {"Main Menu", [&](){ exit=true;}} + }; + loopOptions(options); + returnToMenu=false; + if(exit) { + returnToMenu=true; + goto END; + } + displayCurrentItem(doc, currentIndex); + delay(200); + } else { + check(SelPress); loopVersions(); // goes to the Version information + displayCurrentItem(doc, currentIndex); + delay(200); returnToMenu=false; } - #else - loopVersions(); - returnToMenu=false; + } + WAITING: + yield(); + #endif - #endif + #if defined(T_EMBED) || defined(HAS_TOUCH) || defined(HAS_KEYBOARD) + if(check(EscPress)) break; // Esc btn to get back to Main Menu. + #endif - delay(200); - } + if(returnToMenu) break; // break the loop and gets back to Main Menu - #ifdef ESC_LOGIC - if(checkEscPress()) break; // Esc btn to get back to Main Menu. - #endif } else { displayRedStripe("WiFi: Disconnected"); @@ -819,6 +848,7 @@ void loopFirmware(){ break; } } + END: WiFi.disconnect(true,true); WiFi.mode(WIFI_OFF); doc.clear(); diff --git a/src/main.cpp b/src/main.cpp index 67111c0..4efe020 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -185,7 +185,7 @@ void get_partition_sizes() { if(__size==0x1000000) { partitionSetter(def_part16, sizeof(def_part16)); } while(1) { Serial.println("Turn Off and On again to apply partition changes."); - delay(2000); + delay(2500); } } @@ -388,9 +388,6 @@ void setup() { Launcher: tft.fillScreen(BGCOLOR); - #if REDRAW_DELAY<50 // Encoder devices need delay to not open the firt option in the menu - delay(200); - #endif #if LED>0 && defined(HEADLESS) digitalWrite(LED, LED_ON?LOW:HIGH); // turn off the LED #endif @@ -416,7 +413,6 @@ void loop() { #endif redraw = false; returnToMenu = false; - delay(REDRAW_DELAY); } if(check(PrevPress)) { @@ -459,7 +455,6 @@ void loop() { } options.push_back({"Hidden SSID", [=]() { String __ssid=keyboard("", 32, "Your SSID"); wifiConnect(__ssid.c_str(),8); }}); options.push_back({"Main Menu", [=]() { returnToMenu=true; }}); - delay(200); loopOptions(options); if (WiFi.status() == WL_CONNECTED) { if(GetJsonFromM5()) loopFirmware(); @@ -523,7 +518,6 @@ void loop() { options.push_back({"Turn-off", [=]() { powerOff(); }}); #endif options.push_back({"Main Menu", [=]() { returnToMenu=true; }}); - delay(200); loopOptions(options); tft.fillScreen(BGCOLOR); tft.fillScreen(BGCOLOR); diff --git a/src/onlineLauncher.cpp b/src/onlineLauncher.cpp index a9aadf3..1dffaa0 100644 --- a/src/onlineLauncher.cpp +++ b/src/onlineLauncher.cpp @@ -64,7 +64,6 @@ void wifiConnect(String ssid, int encryptation, bool isAP) { Retry: if (!found || wrongPass) { - delay(200); if (encryptation > 0) pwd = keyboard(pwd, 63, "Network Password:"); EEPROM.begin(EEPROMSIZE); @@ -112,7 +111,6 @@ void wifiConnect(String ssid, int encryptation, bool isAP) { {"Main Menu", [&](){ returnToMenu=true;}}, }; loopOptions(options); - delay(200); if(!returnToMenu) goto Retry; else goto END; } @@ -127,7 +125,7 @@ void wifiConnect(String ssid, int encryptation, bool isAP) { Serial.println(WiFi.softAPIP()); } END: - delay(200); + delay(0); } /*************************************************************************************** ** Function name: replaceChars @@ -206,13 +204,13 @@ void downloadFirmware(String file_str, String fileName, String folder) { prog_handler = 2; if(!setupSdCard()) { displayRedStripe("SDCard Not Found"); - delay(2000); + delay(2500); return; } tft.fillRect(7, 40, tftWidth - 14, 88, BGCOLOR); // Erase the information below the firmware name displayRedStripe("Connecting FW"); - + doc.clear(); // Clear Json Memory, m5burner is getting too big!!! WiFiClientSecure *client = new WiFiClientSecure; client->setCACert(root_ca3); retry: @@ -291,6 +289,7 @@ void downloadFirmware(String file_str, String fileName, String folder) { } else { displayRedStripe("Couldn't Connect"); } wakeUpScreen(); + GetJsonFromM5(); } /*************************************************************************************** @@ -306,7 +305,6 @@ void installFirmware(String file, uint32_t app_size, bool spiffs, uint32_t spiff {"SPIFFS No", [&](){ spiffs = false; }}, {"SPIFFS Yes", [&](){ spiffs = true; }}, }; - delay(200); loopOptions(options); } @@ -324,6 +322,7 @@ void installFirmware(String file, uint32_t app_size, bool spiffs, uint32_t spiff tft.fillRect(7, 40, tftWidth - 14, 88, BGCOLOR); // Erase the information below the firmware name displayRedStripe("Connecting FW"); + doc.clear(); WiFiClientSecure *client = new WiFiClientSecure; fileAddr = "https://m5burner-cdn.m5stack.com/firmware/" + file; client->setCACert(root_ca3); @@ -401,6 +400,7 @@ void installFirmware(String file, uint32_t app_size, bool spiffs, uint32_t spiff // Só chega aqui se der errado SAIR: delay(5000); + GetJsonFromM5(); } diff --git a/src/partitioner.cpp b/src/partitioner.cpp index 6a7d958..158c72b 100644 --- a/src/partitioner.cpp +++ b/src/partitioner.cpp @@ -188,7 +188,6 @@ void partitioner() { {"UiFlow1", [&](){ partition = 1; }}, #endif }; - delay(200); loopOptions(options); if(partition==100) goto Exit; @@ -212,7 +211,7 @@ void partitioner() { #elif defined(PART_16MB) case 1: data = uiFlow1; displayRedStripe("Experimental"); - delay(2000); + delay(2500); data_size = sizeof(uiFlow1); break; #endif @@ -315,7 +314,7 @@ void dumpPartition(const char* partitionLabel, const char* outputPath) { } outputFile.close(); displayRedStripe(" Complete! "); - delay(2000); + delay(2500); Serial.printf("Dump da partição %s para o arquivo %s concluído\n", partitionLabel, outputPath); } @@ -351,7 +350,7 @@ void restorePartition(const char* partitionLabel) { } delay(100); displayRedStripe(" Restored! "); - delay(2000); + delay(2500); } diff --git a/src/powerSave.cpp b/src/powerSave.cpp index 234c458..fcb6a0d 100644 --- a/src/powerSave.cpp +++ b/src/powerSave.cpp @@ -13,12 +13,10 @@ bool wakeUpScreen(){ isScreenOff = false; dimmer = false; getBrightness(); - delay(200); return true; }else if(dimmer){ dimmer = false; getBrightness(); - delay(200); return true; } return false; @@ -45,7 +43,6 @@ void sleepModeOn(){ disableCore0WDT(); disableCore1WDT(); disableLoopWDT(); - delay(200); } /* Wake up device */ @@ -57,5 +54,4 @@ void sleepModeOff(){ enableLoopWDT(); feedLoopWDT(); getBrightness(); - delay(200); } diff --git a/src/sd_functions.cpp b/src/sd_functions.cpp index 8cd8f41..4f3b6fb 100644 --- a/src/sd_functions.cpp +++ b/src/sd_functions.cpp @@ -311,14 +311,14 @@ void readFs(String folder, String result[][3]) { if (!setupSdCard()) { //Serial.println("Falha ao iniciar o cartão SD"); displayRedStripe("SD not found or not formatted in FAT32"); - delay(2000); + delay(2500); return; // Retornar imediatamente em caso de falha } File root = SDM.open(folder); if (!root || !root.isDirectory()) { displayRedStripe("Fail open root"); - delay(2000); + delay(2500); return; // Retornar imediatamente se não for possível abrir o diretório } @@ -412,8 +412,6 @@ String loopSD(bool filePicker) { tft.fillSmoothRoundRect(6,6,tftWidth-12,tftHeight-12,5,BGCOLOR); } coord=listFiles(index, fileList); - - delay(REDRAW_DELAY); redraw = false; } @@ -451,7 +449,6 @@ String loopSD(bool filePicker) { {"Delete", [=]() { deleteFromSd(fileList[index][1]); }}, {"Main Menu", [=]() { returnToMenu=true; }}, }; - delay(200); loopOptions(options); tft.drawRoundRect(5,5,tftWidth-10,tftHeight-10,5,FGCOLOR); reload = true; @@ -464,7 +461,6 @@ String loopSD(bool filePicker) { }; if(fileToCopy!="") options.push_back({"Paste", [=]() { pasteFile(Folder); }}); options.push_back({"Main Menu", [=]() { returnToMenu=true; }}); - delay(200); loopOptions(options); reload = true; redraw = true; @@ -484,7 +480,6 @@ String loopSD(bool filePicker) { if(fileToCopy!="") options.push_back({"Paste", [=]() { pasteFile(Folder); }}); options.push_back({"Delete", [=]() { deleteFromSd(fileList[index][1]); }}); options.push_back({"Main Menu", [=]() { returnToMenu=true; }}); - delay(200); if(!filePicker) loopOptions(options); else { @@ -562,7 +557,7 @@ void performUpdate(Stream &updateSource, size_t updateSize, int command) { { uint8_t error = Update.getError(); displayRedStripe("E:" + String(error) + "-Wrong Partition Scheme"); - delay(2000); + delay(2500); } } @@ -653,7 +648,7 @@ void updateFromSD(String path) { {"SPIFFS No", [&](){ spiffs = false; }}, {"SPIFFS Yes", [&](){ spiffs = true; }}, }; - delay(200); + loopOptions(options); tft.fillSmoothRoundRect(6, 6, tftWidth - 12, tftHeight - 12, 5, BGCOLOR); } @@ -694,7 +689,7 @@ void updateFromSD(String path) { } Exit: displayRedStripe("Update Error."); - delay(2000); + delay(2500); } diff --git a/src/settings.cpp b/src/settings.cpp index 98246d7..00572b9 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -205,9 +205,7 @@ void setBrightnessMenu() { {"25 %", [=]() { setBrightness(25); }}, {" 0 %", [=]() { setBrightness(1); }}, }; - delay(200); loopOptions(options, true); - delay(200); } /********************************************************************* ** Function: setUiColor @@ -223,7 +221,6 @@ void setUiColor() { {"White", [&]() { FGCOLOR=0xFFFF; BGCOLOR=0x0000; ALCOLOR=0x6b6d; odd_color=0x630C; even_color=0x8410; }}, {"Black", [&]() { FGCOLOR=0x0000; BGCOLOR=0xFFFF; ALCOLOR=0x6b6d; odd_color=0x8c71; even_color=0xb596; }}, }; - delay(200); loopOptions(options); displayRedStripe("Saving..."); EEPROM.begin(EEPROMSIZE); @@ -246,7 +243,6 @@ void setUiColor() { EEPROM.commit(); // Store data to EEPROM EEPROM.end(); - delay(200); } /********************************************************************* ** Function: setdimmerSet @@ -262,14 +258,13 @@ void setdimmerSet() { {"60s", [&]() { time=60; }}, }; - delay(200); + loopOptions(options); dimmerSet=time; EEPROM.begin(EEPROMSIZE); EEPROM.write(EEPROMSIZE-14, dimmerSet); // 20s Dimm time EEPROM.commit(); EEPROM.end(); - delay(200); } /********************************************************************* @@ -290,7 +285,6 @@ void chargeMode() { } setCpuFrequencyMhz(240); setBrightness(bright,false); - delay(200); } diff --git a/src/webInterface.cpp b/src/webInterface.cpp index c643b80..f99f8ab 100644 --- a/src/webInterface.cpp +++ b/src/webInterface.cpp @@ -50,7 +50,6 @@ void webUIMyNet() { } options.push_back({"Hidden SSID", [=]() { String __ssid=keyboard("", 32, "Your SSID"); wifiConnect(__ssid.c_str(),8); }}); options.push_back({"Main Menu", [=]() { returnToMenu=true; }}); - delay(200); loopOptions(options); } else { @@ -72,7 +71,6 @@ void loopOptionsWebUi() { {"AP mode", [=]() { startWebUi("Launcher", 0, true); }}, {"Main Menu", [=]() { returnToMenu=true; }}, }; - delay(200); loopOptions(options); // On fail installing will run the following line