From 69cf0bd7e823e87327ad7d04d9a5d73f7431deba Mon Sep 17 00:00:00 2001 From: Pirata Date: Wed, 27 Nov 2024 12:03:21 -0300 Subject: [PATCH] dev_mode --- src/display.cpp | 14 ++++++++++++++ src/display.h | 1 + src/globals.h | 1 + src/main.cpp | 9 ++++++--- src/settings.cpp | 6 ++++-- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 2f6f50e..37cf1a4 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -146,6 +146,20 @@ void initDisplay(bool doAll) { delay(50); } +/*************************************************************************************** +** Function name: initDisplayLoop +** Description: Start Display functions and display bootscreen +***************************************************************************************/ +void initDisplayLoop() { + tft.fillScreen(BGCOLOR); + initDisplay(true); + delay(250); + while(!checkAnyKeyPress()){ + initDisplay(); + delay(50); + } + returnToMenu=true; +} /*************************************************************************************** ** Function name: displayCurrentItem diff --git a/src/display.h b/src/display.h index 66b1912..d2648a1 100644 --- a/src/display.h +++ b/src/display.h @@ -22,6 +22,7 @@ void loopOptions(const std::vector> void loopVersions(); void loopFirmware(); void initDisplay(bool doAll = false); // Início da função e mostra bootscreen +void initDisplayLoop(); //Funções para economizar linhas nas outras funções void resetTftDisplay(int x = 0, int y = 0, uint16_t fc = FGCOLOR, int size = FONT_M, uint16_t bg = BGCOLOR, uint16_t screen = BGCOLOR); diff --git a/src/globals.h b/src/globals.h index f48a077..a4a4615 100644 --- a/src/globals.h +++ b/src/globals.h @@ -32,6 +32,7 @@ extern uint32_t MAX_FAT_sys; extern unsigned long previousMillis; extern bool isSleeping; extern bool isScreenOff; +extern bool dev_mode; extern int dimmerSet; extern int bright; diff --git a/src/main.cpp b/src/main.cpp index e2c3a8f..63bfb76 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,6 +40,7 @@ int dimmerSet=20; unsigned long previousMillis; bool isSleeping; bool isScreenOff; +bool dev_mode=false; int bright=100; bool dimmer=false; int prog_handler; // 0 - Flash, 1 - SPIFFS @@ -457,12 +458,14 @@ void loop() { #endif if(MAX_SPIFFS>0) options.push_back({"Save SPIFFS", [=]() { dumpPartition("spiffs", "/bkp/spiffs.bin"); }}); - //if(MAX_FAT_sys>0) options.push_back({"Bkp FAT sys", [=]() { dumpPartition("sys", "/bkp/FAT_sys.bin"); }}); //Test only - if(MAX_FAT_vfs>0) options.push_back({"Save FAT vfs", [=]() { dumpPartition("vfs", "/bkp/FAT_vfs.bin"); }}); + if(MAX_FAT_sys>0 && dev_mode) options.push_back({"Bkp FAT sys", [=]() { dumpPartition("sys", "/bkp/FAT_sys.bin"); }}); //Test only + if(MAX_FAT_vfs>0) options.push_back({"Bkp FAT vfs", [=]() { dumpPartition("vfs", "/bkp/FAT_vfs.bin"); }}); if(MAX_SPIFFS>0) options.push_back({ "Rest SPIFFS", [=]() { restorePartition("spiffs"); }}); - //if(MAX_FAT_sys>0) options.push_back({"Rest FAT Sys", [=]() { restorePartition("sys"); }}); //Test only + if(MAX_FAT_sys>0 && dev_mode) options.push_back({"Rest FAT Sys", [=]() { restorePartition("sys"); }}); //Test only if(MAX_FAT_vfs>0) options.push_back({"Rest FAT Vfs", [=]() { restorePartition("vfs"); }}); + if(dev_mode) options.push_back({"Boot Animation", [=]() { initDisplayLoop(); }}); + options.push_back({"Restart", [=]() { ESP.restart(); }}); #if defined(STICK_C_PLUS2) || defined(T_EMBED) || defined(STICK_C_PLUS) diff --git a/src/settings.cpp b/src/settings.cpp index 49f30e4..9ad4e6b 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -272,9 +272,9 @@ bool config_exists() { File conf = SDM.open(CONFIG_FILE, FILE_WRITE); if (conf) { #if ROTATION > 1 - conf.print("[{\"rot\":3,\"dimmerSet\":10,\"onlyBins\":1,\"bright\":100,\"askSpiffs\":1,\"wui_usr\":\"admin\",\"wui_pwd\":\"launcher\",\"dwn_path\":\"/downloads/\",\"FGCOLOR\":2016,\"BGCOLOR\":0,\"ALCOLOR\":63488,\"even\":13029,\"odd\":12485,\"wifi\":[{\"ssid\":\"myNetSSID\",\"pwd\":\"myNetPassword\"}]}]"); + conf.print("[{\"rot\":3,\"dimmerSet\":10,\"onlyBins\":1,\"bright\":100,\"askSpiffs\":1,\"wui_usr\":\"admin\",\"wui_pwd\":\"launcher\",\"dwn_path\":\"/downloads/\",\"FGCOLOR\":2016,\"BGCOLOR\":0,\"ALCOLOR\":63488,\"even\":13029,\"odd\":12485,\",\"dev\":0,\"wifi\":[{\"ssid\":\"myNetSSID\",\"pwd\":\"myNetPassword\"}]}]"); #else - conf.print("[{\"rot\":1,\"dimmerSet\":10,\"onlyBins\":1,\"bright\":100,\"askSpiffs\":1,\"wui_usr\":\"admin\",\"wui_pwd\":\"launcher\",\"dwn_path\":\"/downloads/\",\"FGCOLOR\":2016,\"BGCOLOR\":0,\"ALCOLOR\":63488,\"even\":13029,\"odd\":12485,\"wifi\":[{\"ssid\":\"myNetSSID\",\"pwd\":\"myNetPassword\"}]}]"); + conf.print("[{\"rot\":1,\"dimmerSet\":10,\"onlyBins\":1,\"bright\":100,\"askSpiffs\":1,\"wui_usr\":\"admin\",\"wui_pwd\":\"launcher\",\"dwn_path\":\"/downloads/\",\"FGCOLOR\":2016,\"BGCOLOR\":0,\"ALCOLOR\":63488,\"even\":13029,\"odd\":12485,\",\"dev\":0,\"wifi\":[{\"ssid\":\"myNetSSID\",\"pwd\":\"myNetPassword\"}]}]"); #endif } conf.close(); @@ -318,6 +318,7 @@ void getConfigs() { if(setting["ALCOLOR"].is()) { ALCOLOR = setting["ALCOLOR"].as(); } else { count++; log_i("Fail"); } if(setting["odd"].is()) { odd_color = setting["odd"].as(); } else { count++; log_i("Fail"); } if(setting["even"].is()) { even_color= setting["even"].as(); } else { count++; log_i("Fail"); } + if(setting["dev"].is()) { dev_mode = setting["dev"].as(); } else { count++; log_i("Fail"); } if(setting["wui_usr"].is()) { wui_usr = setting["wui_usr"].as(); } else { count++; log_i("Fail"); } if(setting["wui_pwd"].is()) { wui_pwd = setting["wui_pwd"].as(); } else { count++; log_i("Fail"); } if(setting["dwn_path"].is()) { dwn_path = setting["dwn_path"].as(); } else { count++; log_i("Fail"); } @@ -388,6 +389,7 @@ void saveConfigs() { setting["ALCOLOR"] = ALCOLOR; setting["odd"] = odd_color; setting["even"] = even_color; + setting["dev"] = dev_mode; setting["wui_usr"] = wui_usr; setting["wui_pwd"] = wui_pwd; setting["dwn_path"] = dwn_path;