Skip to content

Commit

Permalink
Merge pull request #165 from tobozo/1.1.7
Browse files Browse the repository at this point in the history
1.1.7
  • Loading branch information
tobozo authored Dec 9, 2021
2 parents c984795 + 2869dee commit 6a630f6
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 150 deletions.
21 changes: 15 additions & 6 deletions examples/LGFX-SDLoader-Snippet/LGFX-SDLoader-Snippet.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ 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 );
#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 {
Expand Down Expand Up @@ -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 );

}


Expand All @@ -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 !");
}

}
26 changes: 8 additions & 18 deletions examples/M5Stack-SD-Menu/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -845,4 +836,3 @@ const unsigned char bluefork_jpg[] PROGMEM /* 10x14 */ = {
0xff, 0xd9
};
const unsigned int bluefork_jpg_len = 1022;

2 changes: 1 addition & 1 deletion examples/M5Stack-SD-Menu/downloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions examples/M5Stack-SD-Menu/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -28,6 +25,7 @@ void loop() {

}


#if !defined ARDUINO
extern "C" {
void loopTask(void*)
Expand All @@ -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 );
}

}
Expand Down
6 changes: 3 additions & 3 deletions examples/M5Stack-SD-Menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 !!
Expand All @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions examples/M5Stack-SD-Menu/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ default_envs = m5stack-core-esp32
;platform = [email protected]
;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
Expand Down
3 changes: 2 additions & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=M5Stack-SD-Updater
version=1.1.6
version=1.1.7
author=tobozo
maintainer[email protected]
sentence=SD Card Loader for M5 Stack
Expand Down
37 changes: 26 additions & 11 deletions src/M5StackUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
#endif


void SDUpdater::_error( const char **errMsgs, uint8_t msgCount, unsigned long waitdelay )
{
for( int i=0; i<msgCount; i++ ) {
_error( String(errMsgs[i]), i<msgCount-1?0:waitdelay );
}
//_error( "", waitdelay );
}


void SDUpdater::_error( const String& errMsg, unsigned long waitdelay )
{
Serial.print("[ERROR] ");
Expand Down Expand Up @@ -175,7 +184,8 @@ bool SDUpdater::saveSketchToFS( fs::FS &fs, const char* binfilename, bool skipIf
{
// no rollback possible, start filesystem
if( !_fsBegin( fs ) ) {
_error( "Unloadable filesystem, aborting" );
const char *msg[] = {"No Filesystem mounted.","Can't check firmware."};
_error( msg, 2 );
return false;
}

Expand All @@ -197,7 +207,7 @@ bool SDUpdater::saveSketchToFS( fs::FS &fs, const char* binfilename, bool skipIf

if (copyFsPartition( &dst, running, sksize)) {
if( cfg->onProgress ) cfg->onProgress( 75, 100 );
_message( String("\nDone ") + String(binfilename) );
_message( String("Done ") + String(binfilename) );
vTaskDelay(1000);
ret = true;
} else {
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
}

Expand Down Expand Up @@ -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 );
Expand All @@ -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;
}

Expand All @@ -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 );
}
}

Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 6a630f6

Please sign in to comment.