From 3909b6a397a1304cbcef16d01314ea76b1bd3940 Mon Sep 17 00:00:00 2001 From: tobozo Date: Fri, 19 Nov 2021 15:11:01 +0100 Subject: [PATCH 1/7] pio tweak + SPIFFS fix --- examples/M5Stack-SD-Menu/platformio.ini | 4 ++-- library.json | 3 ++- library.properties | 2 +- src/M5StackUpdater.h | 2 +- src/gitTagVersion.h | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/M5Stack-SD-Menu/platformio.ini b/examples/M5Stack-SD-Menu/platformio.ini index 2435db75..e1f6113d 100644 --- a/examples/M5Stack-SD-Menu/platformio.ini +++ b/examples/M5Stack-SD-Menu/platformio.ini @@ -9,8 +9,8 @@ default_envs = m5stack-core-esp32 ;platform = espressif32@3.3.2 ;platform = espressif32 ;platform = https://github.com/platformio/platform-espressif32.git -platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream -platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.0 +platform = https://github.com/platformio/platform-espressif32.git +platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1 framework = arduino upload_speed = 921600 monitor_speed = 115200 diff --git a/library.json b/library.json index e7c91aea..08506ae9 100644 --- a/library.json +++ b/library.json @@ -10,7 +10,8 @@ "type": "git", "url": "https://github.com/tobozo/M5Stack-SD-Updater.git" }, - "version": "1.1.6", + "version": "1.1.7", "framework": "arduino", + "headers": "M5StackUpdater.h", "platforms": "espressif32" } diff --git a/library.properties b/library.properties index 97a06305..9ea114f9 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=M5Stack-SD-Updater -version=1.1.6 +version=1.1.7 author=tobozo maintainer=tobozo@noreply.github.com sentence=SD Card Loader for M5 Stack diff --git a/src/M5StackUpdater.h b/src/M5StackUpdater.h index 201dd47f..ced31ec8 100644 --- a/src/M5StackUpdater.h +++ b/src/M5StackUpdater.h @@ -178,7 +178,7 @@ class SDUpdater { bool mounted = false; size_t tried = 0; - #if __has_include() || defined _SPIFFS_H_ + #if defined _SPIFFS_H_ log_i("Checking for SPIFFS Support"); if( &fs == &SPIFFS ) { if( !SPIFFS.begin() ){ diff --git a/src/gitTagVersion.h b/src/gitTagVersion.h index bf87fe67..0e8057fa 100644 --- a/src/gitTagVersion.h +++ b/src/gitTagVersion.h @@ -1,6 +1,6 @@ #define SDU_VERSION_MAJOR 1 #define SDU_VERSION_MINOR 1 -#define SDU_VERSION_PATCH 6 +#define SDU_VERSION_PATCH 7 #define _SDU_STR(x) #x #define SDU_STR(x) _SDU_STR(x) // Macro to convert library version number into an integer From 7b8e506f8846477ae2826886ce26976701040010 Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 9 Dec 2021 13:52:26 +0100 Subject: [PATCH 2/7] Added SDU_APP_AUTHOR for lobby screen --- src/M5StackUpdaterConfig.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/M5StackUpdaterConfig.h b/src/M5StackUpdaterConfig.h index b6b9b814..9463c9a1 100644 --- a/src/M5StackUpdaterConfig.h +++ b/src/M5StackUpdaterConfig.h @@ -27,7 +27,7 @@ * OTHER DEALINGS IN THE SOFTWARE. * */ - +#pragma once #define ROLLBACK_LABEL "Rollback" // reload app from the "other" OTA partition #define LAUNCHER_LABEL "Launcher" // load Launcher (typically menu.bin) @@ -43,6 +43,9 @@ #if !defined SDU_APP_NAME #define SDU_APP_NAME nullptr #endif +#if !defined SDU_APP_AUTHOR + #define SDU_APP_AUTHOR nullptr +#endif // callback signatures typedef void (*onProgressCb)( int state, int size ); @@ -51,7 +54,7 @@ typedef void (*onErrorCb)( const String& message, unsigned long delay ); typedef void (*onBeforeCb)(); typedef void (*onAfterCb)(); typedef void (*onSplashPageCb)( const char* msg ); -typedef void (*onButtonDrawCb)( const char* label, uint8_t position, uint16_t outlinecolor, uint16_t fillcolor, uint16_t textcolor ); +typedef void (*onButtonDrawCb)( const char* label, uint8_t position, uint16_t outlinecolor, uint16_t fillcolor, uint16_t textcolor, uint16_t shadowcolor ); typedef int (*onWaitForActionCb)( char* labelLoad, char* labelSkip, char* labelSave, unsigned long waitdelay ); typedef void (*onConfigLoad)(); @@ -68,6 +71,7 @@ struct config_sdu_t const char* labelSave = SAVE_LABEL; const char* binFileName = SDU_APP_PATH; const char* appName = SDU_APP_NAME; + const char* authorName = SDU_APP_AUTHOR; onProgressCb onProgress = nullptr; onMessageCb onMessage = nullptr; @@ -94,6 +98,7 @@ struct config_sdu_t void setLabelRollback( const char* label ) { labelRollback = label; } void setLabelSave( const char* label ) { labelSave = label; } void setAppName( const char* name ) { appName = name; } + void setAuthorName( const char* name ) { authorName = name; } void setBinFileName( const char* name ) { binFileName = name; } void useRolllback( bool use ) { use_rollback = use; } From ee438992899cae3e84765ea9d8ae4e8c53e6b134 Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 9 Dec 2021 13:54:17 +0100 Subject: [PATCH 3/7] Lobby screen improvements --- src/M5StackUpdater.cpp | 37 +++++--- src/M5StackUpdater.h | 46 +++++----- src/M5StackUpdaterUI.h | 169 +++++++++++++++++++++--------------- src/M5StackUpdaterUITouch.h | 10 +-- src/assets.h | 6 +- 5 files changed, 160 insertions(+), 108 deletions(-) diff --git a/src/M5StackUpdater.cpp b/src/M5StackUpdater.cpp index 158bad16..dd9399f2 100644 --- a/src/M5StackUpdater.cpp +++ b/src/M5StackUpdater.cpp @@ -54,6 +54,15 @@ #endif +void SDUpdater::_error( const char **errMsgs, uint8_t msgCount, unsigned long waitdelay ) +{ + for( int i=0; ionProgress ) cfg->onProgress( 75, 100 ); - _message( String("\nDone ") + String(binfilename) ); + _message( String("Done ") + String(binfilename) ); vTaskDelay(1000); ret = true; } else { @@ -234,7 +244,7 @@ void SDUpdater::updateNVS() void SDUpdater::performUpdate( Stream &updateSource, size_t updateSize, String fileName ) { _message( "LOADING " + fileName ); - log_i( "Binary size: %d bytes", updateSize ); + log_d( "Binary size: %d bytes", updateSize ); if( cfg->onProgress ) Update.onProgress( cfg->onProgress ); if (Update.begin( updateSize )) { size_t written = Update.writeStream( updateSource ); @@ -281,10 +291,11 @@ void SDUpdater::doRollBack( const String& message ) if( cfg->onProgress ) cfg->onProgress( i, 100 ); vTaskDelay(10); } - _message( "\nRollback done, restarting" ); + _message( "Rollback done, restarting" ); ESP.restart(); } else { - _error( "Cannot rollback: the other OTA partition doesn't seem to be populated or valid" ); + const char *msg[] = {"Cannot rollback", "The other OTA", "partition doesn't", "seem to be", "populated or valid"}; + _error( msg, 5 ); } } @@ -373,7 +384,8 @@ void SDUpdater::checkSDUpdaterUI( fs::FS &fs, String fileName, unsigned long wai void SDUpdater::updateFromFS( const String& fileName ) { if( cfg->fs == nullptr ) { - _error("No valid filesystem selected!"); + const char *msg[] = {"No valid filesystem", "selected!"}; + _error( msg, 2 ); return; } Serial.printf( "[" SD_PLATFORM_NAME "-SD-Updater] SD Updater version: %s\n", (char*)M5_SD_UPDATER_VERSION ); @@ -389,13 +401,14 @@ void SDUpdater::updateFromFS( const String& fileName ) tryRollback( fileName ); log_e("Rollback failed, will try from filesystem"); } else { - log_w("Skipping rollback per config"); + log_d("Skipping rollback per config"); } } // no rollback possible, start filesystem if( !_fsBegin() ) { - _error( "Unloadable filesystem, aborting" ); + const char* msg[] = {"No filesystem mounted.", "Can't load firmware."}; + _error( msg, 2 ); return; } @@ -410,14 +423,15 @@ void SDUpdater::updateFromFS( const String& fileName ) size_t updateSize = updateBin.size(); - log_i("File %s exists (%d bytes)", fileName.c_str(), updateSize ); + //log_d("File %s exists (%d bytes)", fileName.c_str(), updateSize ); updateFromStream( updateBin, updateSize, fileName ); updateBin.close(); } else { - _error( "Could not load " + fileName + " binary from sd root" ); + const char* msg[] = {"Could not reach", fileName.c_str(), "Can't load firmware."}; + _error( msg, 3 ); } } @@ -452,7 +466,8 @@ void SDUpdater::checkSDUpdaterHeadless( String fileName, unsigned long waitdelay void SDUpdater::checkSDUpdaterUI( String fileName, unsigned long waitdelay ) { if( cfg->fs == nullptr ) { - _error("No valid filesystem selected!"); + const char* msg[] = {"No valid filesystem", "selected!", "Cannot load", fileName.c_str()}; + _error( msg, 4 ); return; } bool draw = SDUHasTouch; diff --git a/src/M5StackUpdater.h b/src/M5StackUpdater.h index ced31ec8..58154129 100644 --- a/src/M5StackUpdater.h +++ b/src/M5StackUpdater.h @@ -1,4 +1,4 @@ -#ifndef __M5STACKUPDATER_H +#pragma once #define __M5STACKUPDATER_H /* * @@ -122,7 +122,7 @@ class SDUpdater }; // legacy constructor SDUpdater( const int TFCardCsPin_ = TFCARD_CS_PIN ) { - log_d("SDUpdate base mode on CS pin(%d)", TFCardCsPin_ ); + //log_d("SDUpdater base mode on CS pin(%d)", TFCardCsPin_ ); //SDUCfg.setSDU( this ); // attach this to SDUCfg.sdUpdater SDUCfg.setCSPin( TFCardCsPin_ ); cfg = &SDUCfg; @@ -162,6 +162,7 @@ class SDUpdater void performUpdate( Stream &updateSource, size_t updateSize, String fileName ); void tryRollback( String fileName ); void _error( const String& errMsg, unsigned long waitdelay = 2000 ); + void _error( const char **errMsgs, uint8_t msgCount=1, unsigned long waitdelay=2000 ); void _message( const String& label ); #if defined _M5Core2_H_ // enable additional touch button support const bool SDUHasTouch = true; @@ -171,60 +172,66 @@ class SDUpdater bool _fsBegin() { if( cfg->fs != nullptr ) return _fsBegin( *cfg->fs ); - _error("No filesystem selected"); + _error( "No filesystem selected" ); return false; } bool _fsBegin( fs::FS &fs ) { bool mounted = false; size_t tried = 0; + const char* msg[] = {nullptr, "ABORTING"}; #if defined _SPIFFS_H_ - log_i("Checking for SPIFFS Support"); + log_d("Checking for SPIFFS Support"); if( &fs == &SPIFFS ) { if( !SPIFFS.begin() ){ - _error( "SPIFFS MOUNT FAILED, ABORTING!!" ); + msg[0] = "SPIFFS MOUNT FAILED"; + _error( msg, 2 ); return false; - } else log_i("SPIFFS Successfully mounted"); + } else log_d("SPIFFS Successfully mounted"); mounted = true; } #endif #if defined (_LITTLEFS_H_) - log_i("Checking for LittleFS Support"); + log_d("Checking for LittleFS Support"); if( &fs == &LittleFS ) { if( !LittleFS.begin() ){ - _error( "LittleFS MOUNT FAILED, ABORTING!!" ); + msg[0] = "LittleFS MOUNT FAILED"; + _error( msg, 2 ); return false; - } else log_i("LittleFS Successfully mounted"); + } else log_d("LittleFS Successfully mounted"); mounted = true; } #endif #if defined (_SD_H_) - log_i(" Checking for SD Support (pin #%d)", cfg->TFCardCsPin ); + log_d(" Checking for SD Support (pin #%d)", cfg->TFCardCsPin ); if( &fs == &SD ) { if( !SD.begin( cfg->TFCardCsPin ) ) { - _error( "SD MOUNT FAILED (pin #" + String(cfg->TFCardCsPin) + "), ABORTING!!" ); + msg[0] = String("SD MOUNT FAILED (pin #" + String(cfg->TFCardCsPin) + ")").c_str(); + _error( msg, 2 ); return false; - } else log_i( "SD Successfully mounted (pin #%d)", cfg->TFCardCsPin ); + } else log_d( "SD Successfully mounted (pin #%d)", cfg->TFCardCsPin ); mounted = true; } #endif #if defined (_SDMMC_H_) - log_i(" Checking for SD_MMC Support"); + log_d(" Checking for SD_MMC Support"); if( &fs == &SD_MMC ) { if( !SD_MMC.begin() ){ - _error( "SD_MMC MOUNT FAILED, ABORTING!!" ); + msg[0] = "SD_MMC FAILED"; + _error( msg, 2 ); return false; - } else log_i( "SD_MMC Successfully mounted"); + } else log_d( "SD_MMC Successfully mounted"); mounted = true; } #endif #if __has_include() || defined _PSRAMFS_H_ - log_i(" Checking for PSRamFS Support"); + log_d(" Checking for PSRamFS Support"); if( &fs == &PSRamFS ) { if( !PSRamFS.begin() ){ - _error( "PSRamFS MOUNT FAILED, ABORTING!!" ); + msg[0] = "PSRamFS FAILED"; + _error( msg, 2 ); return false; - } else log_i( "PSRamFS Successfully mounted"); + } else log_d( "PSRamFS Successfully mounted"); mounted = true; } #endif @@ -300,6 +307,3 @@ __attribute__((unused)) static void checkSDUpdater( fs::FS &fs, String fileName sdUpdater.checkSDUpdaterHeadless( fileName, waitdelay ); #endif } - - -#endif diff --git a/src/M5StackUpdaterUI.h b/src/M5StackUpdaterUI.h index b686782e..3d67cd9b 100644 --- a/src/M5StackUpdaterUI.h +++ b/src/M5StackUpdaterUI.h @@ -27,7 +27,7 @@ * OTHER DEALINGS IN THE SOFTWARE. * */ -#ifndef _M5UPDATER_UI_ +#pragma once #define _M5UPDATER_UI_ @@ -125,11 +125,11 @@ static void SDMenuProgressHeadless( int state, int size ) 0, 0, 0, 0 }; #else // assuming landscape mode /w 320x240 display - #define BUTTON_WIDTH 60 + #define BUTTON_WIDTH 68 #define BUTTON_HWIDTH BUTTON_WIDTH/2 // button half width #define BUTTON_HEIGHT 28 static int16_t SDUButtonsXOffset[3] = { - 31, 126, 221 + 31, 125, 219 }; static int16_t SDUButtonsYOffset[3] = { 0, 0, 0 @@ -166,6 +166,7 @@ static void SDMenuProgressHeadless( int state, int size ) uint16_t BorderColor; uint16_t FillColor; uint16_t TextColor; + uint16_t ShadowColor; }; struct SDUTextStyle_T // somehow redundant with LGFX's textstyle_t @@ -179,9 +180,10 @@ static void SDMenuProgressHeadless( int state, int size ) struct BtnStyles { - BtnStyle Load = { TFT_ORANGE, SDU_GFX.color565( 0xaa, 0x00, 0x00), SDU_GFX.color565( 0xdd, 0xdd, 0xdd) }; - BtnStyle Skip = { SDU_GFX.color565( 0x11, 0x11, 0x11), SDU_GFX.color565( 0x33, 0x88, 0x33), SDU_GFX.color565( 0xee, 0xee, 0xee) }; - BtnStyle Save = { TFT_ORANGE, TFT_BLACK, TFT_WHITE }; + // Border Fill Text Shadow + BtnStyle Load = { SDU_GFX.color565( 0x75, 0x75, 0x75 ), SDU_GFX.color565( 0x60, 0x60, 0x60 ), TFT_WHITE, TFT_BLACK }; + BtnStyle Skip = { SDU_GFX.color565( 0x75, 0x75, 0x75 ), SDU_GFX.color565( 0x40, 0x40, 0x40 ), TFT_WHITE, TFT_BLACK }; + BtnStyle Save = { SDU_GFX.color565( 0x75, 0x75, 0x75 ), SDU_GFX.color565( 0x20, 0x20, 0x20 ), TFT_WHITE, TFT_BLACK }; uint16_t height = BUTTON_HEIGHT; uint16_t width = BUTTON_WIDTH; uint16_t hwidth = BUTTON_HWIDTH; @@ -193,9 +195,10 @@ static void SDMenuProgressHeadless( int state, int size ) static BtnStyles DefaultBtnStyle; static BtnStyles *userBtnStyle = nullptr; - static SplashPageElementStyle SplashTitleStyle = { TFT_BLACK, TFT_WHITE, 2, MC_DATUM, TFT_LIGHTGREY, TFT_DARKGREY }; - static SplashPageElementStyle SplashAppNameStyle = { TFT_LIGHTGREY, TFT_BLACK, 2, BC_DATUM, 0, 0 }; - static SplashPageElementStyle SplashAppPathStyle = { TFT_DARKGREY, TFT_BLACK, 1, TC_DATUM, 0, 0 }; + static SplashPageElementStyle SplashTitleStyle = { TFT_BLACK, TFT_WHITE, 2, MC_DATUM, TFT_LIGHTGREY, TFT_DARKGREY }; + static SplashPageElementStyle SplashAppNameStyle = { TFT_LIGHTGREY, TFT_BLACK, 2, BC_DATUM, 0, 0 }; + static SplashPageElementStyle SplashAuthorNameStyle = { TFT_LIGHTGREY, TFT_BLACK, 2, BC_DATUM, 0, 0 }; + static SplashPageElementStyle SplashAppPathStyle = { TFT_DARKGREY, TFT_BLACK, 1, BC_DATUM, 0, 0 }; static ProgressBarStyle ProgressStyle = { 200, // width @@ -251,13 +254,24 @@ static void SDMenuProgressHeadless( int state, int size ) SDUTextStyle.frozen = false; } + static void drawTextShadow( const char* text, int32_t x, int32_t y, uint16_t textcolor, uint16_t shadowcolor ) + { + if( textcolor != shadowcolor ) { + SDU_GFX.setTextColor( shadowcolor ); + SDU_GFX.drawString( text, x+1, y+1 ); + } + SDU_GFX.setTextColor( textcolor ); + SDU_GFX.drawString( text, x, y ); + } + + + __attribute__((unused)) static void drawSDUSplashElement( const char* msg, int32_t x, int32_t y, SplashPageElementStyle *style ) { SDU_GFX.setTextSize( style->fontSize ); SDU_GFX.setTextDatum( style->textDatum ); uint8_t lineHeight = SDU_GFX.fontHeight()*1.8; - #if defined HAS_LGFX if( style->colorStart == style->colorEnd ) { SDU_GFX.fillRect( 0, y, SDU_GFX.width(), lineHeight, style->bgColor ); @@ -269,51 +283,48 @@ static void SDMenuProgressHeadless( int state, int size ) #else SDU_GFX.fillRect( 0, y, SDU_GFX.width(), lineHeight, style->bgColor ); #endif - - if( style->textColor != TFT_DARKGREY ) { - // drop shadow first - SDU_GFX.setTextColor( TFT_DARKGREY ); - SDU_GFX.drawString( msg, x+1, 1+y+lineHeight/2 ); - } - // now draw text - SDU_GFX.setTextColor( style->textColor ); - SDU_GFX.drawString( msg, x, y+lineHeight/2 ); + drawTextShadow( msg, x, y+lineHeight/2, style->textColor, TFT_DARKGREY ); } __attribute__((unused)) static void drawSDUSplashPage( const char* msg ) { - int32_t centerX = SDU_GFX.width()/2; + int32_t centerX = SDU_GFX.width() >> 1; + SDU_GFX.setTextSize( 2 ); + uint8_t lineHeightBig = SDU_GFX.fontHeight(); SDU_GFX.setTextFont( 1 ); + uint8_t lineHeightSmall = SDU_GFX.fontHeight(); + uint8_t appNamePosy = lineHeightBig*1.8+lineHeightSmall; + uint8_t authorNamePosY = appNamePosy + lineHeightBig*1.8; + uint8_t binFileNamePosY = authorNamePosY+lineHeightSmall*1.8; + SDU_GFX.clear(); drawSDUSplashElement( msg, centerX, 0, &SplashTitleStyle ); if( SDUCfg.appName != nullptr ) { - drawSDUSplashElement( SDUCfg.appName, centerX, SDU_GFX.height()/4, &SplashAppNameStyle ); + drawSDUSplashElement( SDUCfg.appName, centerX, appNamePosy, &SplashAppNameStyle ); + } + if( SDUCfg.authorName != nullptr ) { + drawSDUSplashElement( String( "By " + String(SDUCfg.authorName) ).c_str(), centerX, authorNamePosY, &SplashAuthorNameStyle ); } if( SDUCfg.binFileName != nullptr ) { - int32_t posY = (SDU_GFX.height() >> 1)-( ProgressStyle.height+2+SDU_GFX.fontHeight() ); - drawSDUSplashElement( String("File name: " + String(&SDUCfg.binFileName[1])).c_str(), centerX, posY, &SplashAppPathStyle ); + drawSDUSplashElement( String("File name: " + String(&SDUCfg.binFileName[1])).c_str(), centerX, binFileNamePosY, &SplashAppPathStyle ); } //SDU_GFX.drawJpg( sdUpdaterIcon32x40_jpg, sdUpdaterIcon32x40_jpg_len, (centerX)-16, (SDU_GFX.height()/2)-20, 32, 40 ); } __attribute__((unused)) - static void drawSDUPushButton( const char* label, uint8_t position, uint16_t outlinecolor, uint16_t fillcolor, uint16_t textcolor ) + static void drawSDUPushButton( const char* label, uint8_t position, uint16_t outlinecolor, uint16_t fillcolor, uint16_t textcolor, uint16_t shadowcolor ) { BtnStyles *bs = ( userBtnStyle == nullptr ) ? &DefaultBtnStyle : userBtnStyle; - SDU_GFX.setTextColor( textcolor, fillcolor ); - SDU_GFX.setTextSize( bs->FontSize ); - uint32_t bx = SDUButtonsXOffset[position]; uint32_t by = SDU_GFX.height() - bs->height - 2 - SDUButtonsYOffset[position]; - SDU_GFX.fillRoundRect( bx, by, bs->width, bs->height, 3, fillcolor ); SDU_GFX.drawRoundRect( bx, by, bs->width, bs->height, 3, outlinecolor ); - + SDU_GFX.setTextSize( bs->FontSize ); SDU_GFX.setTextDatum( MC_DATUM ); SDU_GFX.setTextFont( 2 ); - SDU_GFX.drawString( label, bx+bs->width/2, by+bs->height/2 ); + drawTextShadow( label, bx+bs->width/2, by+bs->height/2, textcolor, shadowcolor ); } @@ -332,10 +343,10 @@ static void SDMenuProgressHeadless( int state, int size ) SDUCfg.onBefore(); SDUCfg.onSplashPage( BTN_HINT_MSG ); BtnStyles btns; - SDUCfg.onButtonDraw( labelLoad, 0, btns.Load.BorderColor, btns.Load.FillColor, btns.Load.TextColor ); - SDUCfg.onButtonDraw( labelSkip, 1, btns.Skip.BorderColor, btns.Skip.FillColor, btns.Skip.TextColor ); + SDUCfg.onButtonDraw( labelLoad, 0, btns.Load.BorderColor, btns.Load.FillColor, btns.Load.TextColor, btns.Load.ShadowColor ); + SDUCfg.onButtonDraw( labelSkip, 1, btns.Skip.BorderColor, btns.Skip.FillColor, btns.Skip.TextColor, btns.Skip.ShadowColor ); if( SDUCfg.binFileName != nullptr ) { - SDUCfg.onButtonDraw( labelSave, 2, btns.Save.BorderColor, btns.Save.FillColor, btns.Save.TextColor ); + SDUCfg.onButtonDraw( labelSave, 2, btns.Save.BorderColor, btns.Save.FillColor, btns.Save.TextColor, btns.Save.ShadowColor ); } } auto msec = millis(); @@ -343,22 +354,29 @@ static void SDMenuProgressHeadless( int state, int size ) uint32_t progress = 0, progressOld = 1; if( SDUCfg.onProgress ) SDUCfg.onProgress( 100, 100 ); - SDUSprite *sprite = new SDUSprite( &SDU_GFX ); - sprite->createSprite( 32, 32 ); + #if defined HAS_LGFX + SDUSprite *sprite = new SDUSprite( &SDU_GFX ); + sprite->createSprite( 32, 32 ); + #endif - float angle = 0; int ret = -1; + + Button *ButtonA = &M5.BtnA; // Load Launcher + Button *ButtonB = &M5.BtnB; // Skip Lobby + #if defined _M5STICKC_H_ + Button *ButtonC = nullptr; + #else + Button *ButtonC = SDUCfg.binFileName != nullptr ? &M5.BtnC : nullptr; // Save Sketch to SD + #endif + + // order matters !! + Button *buttons[3] = { ButtonB, ButtonA, ButtonC }; + do { M5.update(); - if( M5.BtnA.isPressed() ) { ret = 1; break; } - if( M5.BtnB.isPressed() ) { ret = 0; break; } - if( SDUCfg.binFileName != nullptr ) { - // copy binary to SD - #ifndef _M5STICKC_H_ // M5StickC has not BtnC - if( M5.BtnC.isPressed() ) { ret = 2; break; }// Force copy bin - #endif + for( int i=0; i<3; i++ ) { + if( buttons[i] && buttons[i]->isPressed() ) { ret = i; goto _endAssert; } } - if( SDUCfg.onProgress ) { float barprogress = float(millis() - msec) / float(waitdelay); progress = 100- (100 * barprogress); @@ -367,16 +385,27 @@ static void SDMenuProgressHeadless( int state, int size ) SDUCfg.onProgress( (uint8_t)progress, 100 ); } } - #if defined HAS_LGFX - angle = sin( float(millis())/500.0 )*180.0; // 1/2 round per second + #if defined HAS_LGFX // this effect needs pushImageRotateZoom support + float angle = sin( float(millis())/500.0 )*180.0; // 1/2 round per second sprite->clear(); sprite->pushImageRotateZoom(sprite->width()/2, sprite->height()/2, 7.5, 8, angle, 1, 1, 15, 16, sdUpdaterIcon15x16_raw); sprite->pushSprite( SDU_GFX.width()/2-sprite->width()/2, SDU_GFX.height()*.75-sprite->height() ); lastdraw = millis(); #endif } while (millis() - msec < waitdelay); + + _endAssert: + if( SDUCfg.onProgress ) SDUCfg.onProgress( 0, 100 ); - sprite->deleteSprite(); + #if defined HAS_LGFX + sprite->deleteSprite(); + #endif + if( ret > -1 ) { // wait for button release + while( buttons[ret]->isPressed() ) { + M5.update(); + vTaskDelay(10); + } + } return ret; } #endif @@ -462,13 +491,20 @@ static void SDMenuProgressHeadless( int state, int size ) static void DisplayErrorUI( const String& msg, unsigned long wait ) { - SDU_GFX.fillScreen( TFT_BLACK ); - SDU_GFX.setTextColor( TFT_RED, TFT_BLACK ); - SDU_GFX.setTextFont( 0 ); + static uint8_t msgposy = 0; SDU_GFX.setTextSize( 2 ); - SDU_GFX.setTextDatum( ML_DATUM ); - SDU_GFX.setCursor( 10, 10 ); - SDU_GFX.print( msg ); + SDU_GFX.setTextFont( 0 ); + uint8_t headerHeight = SDU_GFX.fontHeight()*1.8; // = 28px + log_d("Header height: %d", headerHeight ); + if( msgposy == 0 ) { + SDU_GFX.fillRect( 0, headerHeight+1, SDU_GFX.width(), SDU_GFX.height()-headerHeight, TFT_BLACK ); + } + SDU_GFX.setTextColor( TFT_RED, TFT_BLACK ); + SDU_GFX.setTextDatum( MC_DATUM ); + SDU_GFX.drawString( msg.c_str(), SDU_GFX.width()/2, msgposy+headerHeight*2 ); + msgposy += headerHeight; + //SDU_GFX.setCursor( SDU_GFX.width()/2, headerHeight*2 ); + //SDU_GFX.print( msg ); delay(wait); } @@ -477,18 +513,18 @@ static void SDMenuProgressHeadless( int state, int size ) { if( SDUCfg.load_defaults ) { - if( !SDUCfg.onProgress ) SDUCfg.setProgressCb( SDMenuProgressUI ); log_d("Attaching onProgress"); - if( !SDUCfg.onMessage ) SDUCfg.setMessageCb( DisplayUpdateUI ); log_d("Attaching onMessage"); - if( !SDUCfg.onError ) SDUCfg.setErrorCb( DisplayErrorUI ); log_d("Attaching onError"); - if( !SDUCfg.onBefore ) SDUCfg.setBeforeCb( freezeTextStyle ); log_d("Attaching onBefore"); - if( !SDUCfg.onAfter ) SDUCfg.setAfterCb( thawTextStyle ); log_d("Attaching onAfter"); - if( !SDUCfg.onSplashPage ) SDUCfg.setSplashPageCb( drawSDUSplashPage ); log_d("Attaching onSplashPage"); - if( !SDUCfg.onButtonDraw ) SDUCfg.setButtonDrawCb( drawSDUPushButton ); log_d("Attaching onButtonDraw"); + if( !SDUCfg.onProgress ) { SDUCfg.setProgressCb( SDMenuProgressUI ); log_v("Attached onProgress"); } + if( !SDUCfg.onMessage ) { SDUCfg.setMessageCb( DisplayUpdateUI ); log_v("Attached onMessage"); } + if( !SDUCfg.onError ) { SDUCfg.setErrorCb( DisplayErrorUI ); log_v("Attached onError"); } + if( !SDUCfg.onBefore ) { SDUCfg.setBeforeCb( freezeTextStyle ); log_v("Attached onBefore"); } + if( !SDUCfg.onAfter ) { SDUCfg.setAfterCb( thawTextStyle ); log_v("Attached onAfter"); } + if( !SDUCfg.onSplashPage ) { SDUCfg.setSplashPageCb( drawSDUSplashPage ); log_v("Attached onSplashPage"); } + if( !SDUCfg.onButtonDraw ) { SDUCfg.setButtonDrawCb( drawSDUPushButton ); log_v("Attached onButtonDraw"); } #if defined SDU_HAS_TOUCH // default touch button support - if ( !SDUCfg.onWaitForAction) SDUCfg.setWaitForActionCb( assertStartUpdateFromTouchButton ); log_d("Attaching onWaitForAction (touch)"); + if ( !SDUCfg.onWaitForAction) { SDUCfg.setWaitForActionCb( assertStartUpdateFromTouchButton ); log_v("Attached onWaitForAction (touch)"); } #else // default momentary button support - if ( !SDUCfg.onWaitForAction) SDUCfg.setWaitForActionCb( assertStartUpdateFromPushButton ); log_d("Attaching onWaitForAction (button)"); + if ( !SDUCfg.onWaitForAction) { SDUCfg.setWaitForActionCb( assertStartUpdateFromPushButton ); log_v("Attached onWaitForAction (button)"); } #endif } #if defined LGFX_ONLY @@ -508,13 +544,10 @@ static void SDMenuProgressHeadless( int state, int size ) static void SetupSDMenuConfig() { if( SDUCfg.load_defaults ) { - if( !SDUCfg.onProgress ) { SDUCfg.setProgressCb( SDMenuProgressHeadless ); log_d("Attaching onProgress"); } - if( !SDUCfg.onMessage ) { SDUCfg.setMessageCb( DisplayUpdateHeadless ); log_d("Attaching onMessage"); } - if( !SDUCfg.onWaitForAction ) { SDUCfg.setWaitForActionCb( assertStartUpdateFromSerial ); log_d("Attaching onWaitForAction (serial)"); } + if( !SDUCfg.onProgress ) { SDUCfg.setProgressCb( SDMenuProgressHeadless ); log_v("Attached onProgress"); } + if( !SDUCfg.onMessage ) { SDUCfg.setMessageCb( DisplayUpdateHeadless ); log_v("Attached onMessage"); } + if( !SDUCfg.onWaitForAction ) { SDUCfg.setWaitForActionCb( assertStartUpdateFromSerial ); log_v("Attached onWaitForAction (serial)"); } } } #endif //#ifdef USE_DISPLAY - - -#endif // _M5UPDATER_UI_ diff --git a/src/M5StackUpdaterUITouch.h b/src/M5StackUpdaterUITouch.h index cb0d01ae..fe01e3ba 100644 --- a/src/M5StackUpdaterUITouch.h +++ b/src/M5StackUpdaterUITouch.h @@ -71,11 +71,11 @@ void handlePressed( SDU_TouchButton *btn, bool pressed, uint16_t x, uint16_t y) { if (pressed && btn->contains(x, y)) { - log_d("Press at [%d:%d]", x, y ); + log_v("Press at [%d:%d]", x, y ); btn->press(true); // tell the button it is pressed } else { if( pressed ) { - log_d("Outside Press at [%d:%d]", x, y ); + log_v("Outside Press at [%d:%d]", x, y ); } btn->press(false); // tell the button it is NOT pressed } @@ -202,18 +202,18 @@ if( tbWrapper.justReleased( LoadBtn, ispressed, labelLoad ) ) { retval = 1; - log_n("LoadBTN Pressed at [%d:%d]!", t_x, t_y); + log_v("LoadBTN Pressed at [%d:%d]!", t_x, t_y); break; } if( tbWrapper.justReleased( SkipBtn, ispressed, labelSkip ) ) { retval = 0; - log_n("SkipBTN Pressed at [%d:%d]!", t_x, t_y); + log_v("SkipBTN Pressed at [%d:%d]!", t_x, t_y); break; } if( SDUCfg.binFileName != nullptr ) { if( tbWrapper.justReleased( SaveBtn, ispressed, labelSave ) ) { retval = 2; - log_n("SaveBtn Pressed at [%d:%d]!", t_x, t_y); + log_v("SaveBtn Pressed at [%d:%d]!", t_x, t_y); break; } } diff --git a/src/assets.h b/src/assets.h index 8945d5db..f9183238 100644 --- a/src/assets.h +++ b/src/assets.h @@ -1,3 +1,4 @@ +#pragma once #if defined USE_DISPLAY const uint16_t sdUpdaterIcon15x16_raw[] = { @@ -18,8 +19,7 @@ const uint16_t sdUpdaterIcon15x16_raw[] = { 0xffff, 0x0000, 0xef7b, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xfff7, 0xffff, 0xfde7, 0xfde7, 0xfdef, 0xfef7, 0xffff, 0xffff }; - -const unsigned char sdUpdaterIcon15x16_jpg[] PROGMEM = { +const unsigned char sdUpdaterIcon15x16_jpg[] = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, @@ -118,7 +118,7 @@ const unsigned char sdUpdaterIcon15x16_jpg[] PROGMEM = { }; const unsigned int sdUpdaterIcon15x16_jpg_len = 1133; -const unsigned char sdUpdaterIcon32x40_jpg[] PROGMEM = { +const unsigned char sdUpdaterIcon32x40_jpg[] = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x01, 0x2c, 0x01, 0x2c, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, From f5040c3c25cd32bd79b49fda55240f9d81c2fe11 Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 9 Dec 2021 14:05:28 +0100 Subject: [PATCH 4/7] Reflecting upcoming changes for M5.Screenshot --- examples/M5Stack-SD-Menu/assets.h | 26 ++++++++------------------ examples/M5Stack-SD-Menu/downloader.h | 2 +- examples/M5Stack-SD-Menu/main/main.cpp | 10 ++++------ examples/M5Stack-SD-Menu/menu.h | 6 +++--- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/examples/M5Stack-SD-Menu/assets.h b/examples/M5Stack-SD-Menu/assets.h index f05bbb07..0c78a1d3 100644 --- a/examples/M5Stack-SD-Menu/assets.h +++ b/examples/M5Stack-SD-Menu/assets.h @@ -13,7 +13,7 @@ * */ -const unsigned PROGMEM char disk00_jpg[1775] = { +const unsigned char disk00_jpg[1775] = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, @@ -164,7 +164,7 @@ const unsigned PROGMEM char disk00_jpg[1775] = { 0x50, 0xbb, 0x02, 0x22, 0x00, 0x49, 0x52, 0xce, 0x01, 0xff, 0xd9 }; -const unsigned char disk01_jpg[1486] PROGMEM = { +const unsigned char disk01_jpg[1486] = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, @@ -291,8 +291,7 @@ const unsigned char disk01_jpg[1486] PROGMEM = { 0xc0, 0x88, 0x80, 0x12, 0x54, 0xb3, 0x80, 0x7f, 0xff, 0xd9 }; -// 32x32 jpg icon -const unsigned char joyicon_jpeg[1070] PROGMEM = { +const unsigned char joyicon_jpeg[1070] = /* 32 x 32 */{ 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05, 0x04, 0x04, 0x04, 0x05, @@ -385,7 +384,7 @@ const unsigned char joyicon_jpeg[1070] PROGMEM = { 0xff, 0xd9 }; -const unsigned char caution_jpg[] PROGMEM /* 64x46 */ = { +const unsigned char caution_jpg[] /* 64x46 */ = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x14, 0x0e, 0x0f, 0x12, 0x0f, 0x0d, 0x14, 0x12, 0x10, 0x12, 0x17, @@ -519,11 +518,7 @@ const unsigned char caution_jpg[] PROGMEM /* 64x46 */ = { }; const unsigned int caution_jpg_len = 1557; - - - - -const unsigned char checksum_jpg[] PROGMEM /* 22 x32 */ = { +const unsigned char checksum_jpg[] /* 22 x32 */ = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x14, 0x0e, 0x0f, 0x12, 0x0f, 0x0d, 0x14, 0x12, 0x10, 0x12, 0x17, @@ -601,8 +596,7 @@ const unsigned char checksum_jpg[] PROGMEM /* 22 x32 */ = { }; const unsigned int checksum_jpg_len = 882; - -const /* 26 x 32 */ unsigned char download_jpg[] PROGMEM = { +const unsigned char download_jpg[] = /* 26 x 32 */ { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x14, 0x0e, 0x0f, 0x12, 0x0f, 0x0d, 0x14, 0x12, 0x10, 0x12, 0x17, @@ -679,9 +673,7 @@ const /* 26 x 32 */ unsigned char download_jpg[] PROGMEM = { }; const unsigned int download_jpg_len = 868; - - -const unsigned char ntp_jpeg[] PROGMEM /* 32x32 */= { +const unsigned char ntp_jpeg[] /* 32x32 */= { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x14, 0x0e, 0x0f, 0x12, 0x0f, 0x0d, 0x14, 0x12, 0x10, 0x12, 0x17, @@ -755,8 +747,7 @@ const unsigned char ntp_jpeg[] PROGMEM /* 32x32 */= { }; const unsigned int ntp_jpeg_len = 835; - -const unsigned char bluefork_jpg[] PROGMEM /* 10x14 */ = { +const unsigned char bluefork_jpg[] /* 10x14 */ = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, @@ -845,4 +836,3 @@ const unsigned char bluefork_jpg[] PROGMEM /* 10x14 */ = { 0xff, 0xd9 }; const unsigned int bluefork_jpg_len = 1022; - diff --git a/examples/M5Stack-SD-Menu/downloader.h b/examples/M5Stack-SD-Menu/downloader.h index a17d4780..f00e8878 100644 --- a/examples/M5Stack-SD-Menu/downloader.h +++ b/examples/M5Stack-SD-Menu/downloader.h @@ -442,7 +442,7 @@ int modalConfirm( const char* modalName, const char* question, const char* title hidState = getControls(); #ifdef _CHIMERA_CORE_ if( hidState == HID_SCREENSHOT ) { - M5.ScreenShot.snap( modalName ); + M5.ScreenShot->snap( modalName ); hidState = HID_INERT; } #endif diff --git a/examples/M5Stack-SD-Menu/main/main.cpp b/examples/M5Stack-SD-Menu/main/main.cpp index ec8d5061..6a42c276 100644 --- a/examples/M5Stack-SD-Menu/main/main.cpp +++ b/examples/M5Stack-SD-Menu/main/main.cpp @@ -2,11 +2,8 @@ void setup() { - #if defined(_CHIMERA_CORE_) - M5.begin(true, false, true, false, false); // bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEnable, bool ScreenShotEnable - #else - M5.begin(); // bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEnable, bool ScreenShotEnable - #endif + + M5.begin(); // bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEnable, bool ScreenShotEnable SDUCfg.setFS( &M5_FS ); SDUCfg.setCSPin( TFCARD_CS_PIN ); @@ -28,6 +25,7 @@ void loop() { } + #if !defined ARDUINO extern "C" { void loopTask(void*) @@ -39,7 +37,7 @@ extern "C" { } void app_main() { - xTaskCreatePinnedToCore( loopTask, "loopTask", 8192, NULL, 1, NULL, 1 ); + xTaskCreatePinnedToCore( loopTask, "loopTask", 16384, NULL, 1, NULL, 1 ); } } diff --git a/examples/M5Stack-SD-Menu/menu.h b/examples/M5Stack-SD-Menu/menu.h index 0c05791d..a05d58e4 100644 --- a/examples/M5Stack-SD-Menu/menu.h +++ b/examples/M5Stack-SD-Menu/menu.h @@ -32,7 +32,7 @@ #pragma once -// TODO: moved USE_DOWNLOADER features to "Downloader.ino" +// TODO: moved USE_DOWNLOADER features to "AppStore.ino" // auto-select board #if defined( ARDUINO_M5STACK_Core2 ) #warning M5STACK Core2 DETECTED !! @@ -43,7 +43,7 @@ #warning M5STACK CLASSIC DETECTED !! #define PLATFORM_NAME "M5Stack" #define DEFAULT_REGISTRY_BOARD "m5stack" - #define USE_DOWNLOADER + //#define USE_DOWNLOADER // moved to AppStore.ino #elif defined( ARDUINO_M5STACK_FIRE ) #warning M5STACK FIRE DETECTED !! #define PLATFORM_NAME "M5Fire" @@ -914,7 +914,7 @@ void HIDMenuObserve() { switch( hidState ) { #ifdef _CHIMERA_CORE_ case HID_SCREENSHOT: - M5.ScreenShot.snap( "screenshot" ); + M5.ScreenShot->snap( "screenshot" ); break; #endif case HID_DOWN: From 495ceb2fb5cd2cd151b9bbc0ba7a47394616e85e Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 9 Dec 2021 15:38:21 +0100 Subject: [PATCH 5/7] new onButtonDraw signature --- examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino b/examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino index 0af1124b..48ffa5d8 100644 --- a/examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino +++ b/examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino @@ -32,9 +32,9 @@ static int myActionTrigger( char* labelLoad, char* labelSkip, char* labelSave, u //SDUCfg.onBefore(); SDUCfg.onSplashPage( "SD Updater Options" ); BtnStyles btns; // use default theme from library - SDUCfg.onButtonDraw( labelLoad, 0, btns.Load.BorderColor, btns.Load.FillColor, btns.Load.TextColor ); - SDUCfg.onButtonDraw( labelSkip, 1, btns.Skip.BorderColor, btns.Skip.FillColor, btns.Skip.TextColor ); - SDUCfg.onButtonDraw( labelSave, 1, btns.Save.BorderColor, btns.Save.FillColor, btns.Save.TextColor ); + SDUCfg.onButtonDraw( labelLoad, 0, btns.Load.BorderColor, btns.Load.FillColor, btns.Load.TextColor, btns.Load.ShadowColor ); + SDUCfg.onButtonDraw( labelSkip, 1, btns.Skip.BorderColor, btns.Skip.FillColor, btns.Skip.TextColor, btns.Skip.ShadowColor ); + SDUCfg.onButtonDraw( labelSave, 1, btns.Save.BorderColor, btns.Save.FillColor, btns.Save.TextColor, btns.Save.ShadowColor ); } auto msec = millis(); do { From c67f2b4925101110215a053e479458ca83c51b27 Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 9 Dec 2021 15:46:39 +0100 Subject: [PATCH 6/7] new onButtonDraw signature --- .../LGFX-SDLoader-Snippet.ino | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino b/examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino index 48ffa5d8..806e127d 100644 --- a/examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino +++ b/examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino @@ -34,7 +34,11 @@ static int myActionTrigger( char* labelLoad, char* labelSkip, char* labelSave, u BtnStyles btns; // use default theme from library SDUCfg.onButtonDraw( labelLoad, 0, btns.Load.BorderColor, btns.Load.FillColor, btns.Load.TextColor, btns.Load.ShadowColor ); SDUCfg.onButtonDraw( labelSkip, 1, btns.Skip.BorderColor, btns.Skip.FillColor, btns.Skip.TextColor, btns.Skip.ShadowColor ); - SDUCfg.onButtonDraw( labelSave, 1, btns.Save.BorderColor, btns.Save.FillColor, btns.Save.TextColor, btns.Save.ShadowColor ); + #if defined SDU_APP_PATH + if( SDU_APP_PATH!=nullptr ) { + SDUCfg.onButtonDraw( labelSave, 1, btns.Save.BorderColor, btns.Save.FillColor, btns.Save.TextColor, btns.Save.ShadowColor ); + } + #endif } auto msec = millis(); do { @@ -74,6 +78,11 @@ void setup() 2000, // wait delay, (default=0, will be forced to 2000 upon ESP.restart() ) TFCARD_CS_PIN // (usually default=4 but your mileage may vary) ); + + + tft.setTextSize(2); + tft.println( SDU_APP_NAME ); + } @@ -83,13 +92,13 @@ void loop() ButtonUpdate(); if( BtnA->wasPressed() ) { - Serial.println("BtnA pressed !"); + tft.println("BtnA pressed !"); } if( BtnB->wasPressed() ) { - Serial.println("BtnB pressed !"); + tft.println("BtnB pressed !"); } if( BtnC->wasPressed() ) { - Serial.println("BtnC pressed !"); + tft.println("BtnC pressed !"); } } From 2869deeffe7ed78baf3ef017f1eac59eb984bebf Mon Sep 17 00:00:00 2001 From: tobozo Date: Thu, 9 Dec 2021 15:53:15 +0100 Subject: [PATCH 7/7] M5StickC does not have tft.clear() --- src/M5StackUpdaterUI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/M5StackUpdaterUI.h b/src/M5StackUpdaterUI.h index 3d67cd9b..78f137e2 100644 --- a/src/M5StackUpdaterUI.h +++ b/src/M5StackUpdaterUI.h @@ -298,7 +298,7 @@ static void SDMenuProgressHeadless( int state, int size ) uint8_t authorNamePosY = appNamePosy + lineHeightBig*1.8; uint8_t binFileNamePosY = authorNamePosY+lineHeightSmall*1.8; - SDU_GFX.clear(); + SDU_GFX.fillScreen(TFT_BLACK); // M5StickC does not have tft.clear() drawSDUSplashElement( msg, centerX, 0, &SplashTitleStyle ); if( SDUCfg.appName != nullptr ) {