Skip to content

Commit 210ebc8

Browse files
committed
M5Stack CoreS3 support
1 parent 0fd3385 commit 210ebc8

File tree

4 files changed

+63
-15
lines changed

4 files changed

+63
-15
lines changed

ESP32-BLECollector/BLE.h

+8
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ class BLEScanUtils
895895
vTaskDelete(NULL);
896896
}
897897

898+
#if defined USE_SCREENSHOTS
898899
static void screenShotCB( void * param = NULL )
899900
{
900901
xTaskCreate(screenShotTask, "screenShotTask", 16000, NULL, 2, NULL);
@@ -906,6 +907,7 @@ class BLEScanUtils
906907
log_w("Cold ScreenShot");
907908
M5.ScreenShot->init(/* &M5.Lcd, BLE_FS */);
908909
if( M5.ScreenShot->begin() ) {
910+
log_w("ScreenShot Service loaded");
909911
UI.ScreenShotLoaded = true;
910912
UI.screenShot();
911913
} else {
@@ -917,6 +919,7 @@ class BLEScanUtils
917919
}
918920
vTaskDelete(NULL);
919921
}
922+
#endif
920923

921924
static void setTimeZone( void * param = NULL )
922925
{
@@ -1046,7 +1049,12 @@ class BLEScanUtils
10461049
{ "ls", o->listDirCB, "Show [dir] Content on the SD" },
10471050
{ "rm", o->rmFileCB, "Delete [file] from the SD" },
10481051
{ "restart", o->restartCB, "Restart BLECollector ('restart now' to skip replication)" },
1052+
1053+
#if defined USE_SCREENSHOTS
10491054
{ "screenshot", o->screenShotCB, "Make a screenshot and save it on the SD" },
1055+
#endif
1056+
1057+
10501058
{ "screenshow", o->screenShowCB, "Show screenshot" },
10511059
{ "toggle", o->toggleCB, "toggle a bool value" },
10521060
{ "resetDB", o->resetCB, "Hard Reset DB + forced restart" },

ESP32-BLECollector/Display.h

+40-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#if defined ARDUINO_M5Stack_Core_ESP32 \
44
|| defined ARDUINO_M5STACK_Core2 \
5+
|| defined ARDUINO_M5STACK_CORES3 \
56
|| defined ARDUINO_M5STACK_FIRE \
67
|| defined ARDUINO_ODROID_ESP32 \
78
|| defined ARDUINO_ESP32_DEV \
@@ -52,7 +53,7 @@ static const int AMIGABALL_YPOS = 50;
5253

5354

5455
// display profiles switcher
55-
#if defined( ARDUINO_M5Stack_Core_ESP32 ) || defined( ARDUINO_M5STACK_FIRE ) || defined( ARDUINO_ODROID_ESP32 ) || defined( ARDUINO_M5STACK_Core2 ) || defined( ARDUINO_LOLIN_D32_PRO ) || defined ARDUINO_ESP32_S3_BOX
56+
#if defined( ARDUINO_M5Stack_Core_ESP32 ) || defined( ARDUINO_M5STACK_FIRE ) || defined( ARDUINO_ODROID_ESP32 ) || defined( ARDUINO_M5STACK_Core2 ) || defined( ARDUINO_LOLIN_D32_PRO ) || defined ARDUINO_ESP32_S3_BOX || defined ARDUINO_M5STACK_CORES3
5657

5758
#if defined ARDUINO_M5Stack_Core_ESP32
5859
//#undef WITH_WIFI // M5Stack has a small partition, disable WiFi
@@ -80,7 +81,14 @@ static const int AMIGABALL_YPOS = 50;
8081
#define tft_initOrientation() tft.setRotation(0)
8182
#undef USE_SD_UPDATER // Odroid-Go prefers CrashOverride's Application Loader
8283

83-
#elif defined( ARDUINO_M5STACK_Core2 ) // M5Core2
84+
#elif defined ARDUINO_M5STACK_CORES3 // M5CoreS3
85+
86+
#undef HAS_EXTERNAL_RTC
87+
#define HAS_EXTERNAL_RTC false
88+
#undef BASE_BRIGHTNESS
89+
#define BASE_BRIGHTNESS 100
90+
91+
#elif defined ARDUINO_M5STACK_Core2 // M5Core2
8492
#undef HAS_EXTERNAL_RTC
8593
#define HAS_EXTERNAL_RTC true
8694
#undef RTC_SDA
@@ -109,7 +117,14 @@ static const int AMIGABALL_YPOS = 50;
109117

110118
#elif defined ARDUINO_ESP32_S3_BOX
111119

112-
#undef WITH_WIFI // NTP is useless without a RTC module
120+
#undef WITH_WIFI // can't fit on partition
121+
#undef HAS_EXTERNAL_RTC
122+
#define HAS_EXTERNAL_RTC true
123+
#undef RTC_SDA
124+
#undef RTC_SCL
125+
#define RTC_SDA 41 // pin number
126+
#define RTC_SCL 40 // pin number
127+
113128

114129
#else
115130
// M5Stack Classic, Fire
@@ -247,13 +262,17 @@ static const int AMIGABALL_YPOS = 50;
247262

248263
#endif
249264

265+
266+
#define USE_SCREENSHOTS // load tft->snap() functions
250267
#include <ESP32-Chimera-Core.h> // https://github.com/tobozo/ESP32-Chimera-Core
251268

269+
252270
#if !defined ECC_VERSION_MAJOR || !defined ECC_VERSION_MAJOR || !defined ECC_VERSION_MAJOR
253271
#error "This app only uses ESP32-Chimera-Core >= 1.2.3"
254272
#else
255273
#if ((ECC_VERSION_MAJOR << 16) | (ECC_VERSION_MINOR << 8) | (ECC_VERSION_PATCH)) >= ((1 << 16) | (2 << 8) | (3))
256274
// yay, minimal version requirements are met !
275+
#define TFT_eSprite LGFX_Sprite // satisfy namespace requirements, comment this out if your version of chimera-core is too old
257276
#else
258277
#error "This app needs ESP32-Chimera-Core >= 1.2.3"
259278
#endif
@@ -273,11 +292,12 @@ static const int AMIGABALL_YPOS = 50;
273292

274293
#pragma GCC diagnostic ignored "-Wunused-variable"
275294

276-
277295
static TFT_eSprite gradientSprite( &tft ); // gradient background
278296
static TFT_eSprite heapGraphSprite( &tft ); // activity graph
279297
static TFT_eSprite hallOfMacSprite( &tft ); // mac address badge holder
280298

299+
300+
void tft_hScrollTo(uint16_t vsp);
281301
static bool isQuerying = false; // state maintained while SD is accessed, useful when SD is used instead of SD_MMC
282302
// TODO: make this SD-driver dependant rather than platform dependant
283303
static bool isInQuery()
@@ -293,7 +313,11 @@ static bool isInQuery()
293313
void tft_begin()
294314
{
295315

296-
M5.begin( true, true, false, false, false ); // don't start Serial
316+
#ifdef __M5STACKUPDATER_H
317+
M5.begin( true, false, false, false, false ); // don't start Serial and SD
318+
#else
319+
M5.begin( true, true, false, false, false ); // don't start Serial
320+
#endif
297321

298322
#if HAS_EXTERNAL_RTC
299323
Wire.begin(RTC_SDA, RTC_SCL);
@@ -302,16 +326,21 @@ void tft_begin()
302326
#endif
303327
delay( 100 );
304328
#ifdef __M5STACKUPDATER_H
329+
330+
tft_hScrollTo(0); // reset scroll position
331+
305332
if( hasHID() ) {
306333
// build has buttons => enable SD Updater at boot
307334
// New SD Updater support, requires the latest version of https://github.com/tobozo/M5Stack-SD-Updater/
335+
SDUCfg.display = &tft;
336+
308337
#if defined M5_SD_UPDATER_VERSION_INT
309-
SDUCfg.setLabelMenu("<< Menu");
310-
SDUCfg.setLabelSkip("Launch");
311-
SDUCfg.setAppName( PLATFORM_NAME " BLE Collector" );
312-
SDUCfg.setBinFileName( "/ESP32-BLECollector.bin" );
313-
//SDUCfg.useRolllback( false );
314-
checkSDUpdater( BLE_FS, MENU_BIN, 5000, TFCARD_CS_PIN ); // Filesystem, Launcher bin path, Wait delay, Sdcard CS pin
338+
// SDUCfg.setLabelMenu("<< Menu");
339+
// SDUCfg.setLabelSkip("Launch");
340+
// SDUCfg.setAppName( PLATFORM_NAME " BLE Collector" );
341+
// SDUCfg.setBinFileName( "/ESP32-BLECollector.bin" );
342+
// SDUCfg.useRolllback( false );
343+
checkSDUpdater( BLE_FS, MENU_BIN, 15000, TFCARD_CS_PIN ); // Filesystem, Launcher bin path, Wait delay, Sdcard CS pin
315344
#else
316345
checkSDUpdater();
317346
#endif

ESP32-BLECollector/UI.h

+15-4
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ class UIUtils
413413
giveMuxSemaphore();
414414
}
415415

416-
416+
#if defined USE_SCREENSHOTS
417417
static void screenShot()
418418
{
419419
takeMuxSemaphore();
@@ -427,7 +427,8 @@ class UIUtils
427427

428428
//M5.ScreenShot->snapBMP("BLECollector", false);
429429
//M5.ScreenShot->snapJPG("BLECollector", false);
430-
M5.ScreenShot->snap("BLECollector", false); // filename prefix, show image after capture
430+
M5.ScreenShot->snapQOI("BLECollector", false);
431+
//M5.ScreenShot->snap("BLECollector", false); // filename prefix, show image after capture
431432

432433
// restore scroll states
433434
tft_scrollTo( yRef ); // restore software scroll
@@ -436,6 +437,7 @@ class UIUtils
436437
isQuerying = false;
437438
giveMuxSemaphore();
438439
}
440+
#endif
439441

440442
static void screenShow( void * fileName = NULL )
441443
{
@@ -455,8 +457,7 @@ class UIUtils
455457
giveMuxSemaphore();
456458
vTaskDelay( 5000 );
457459
}
458-
}
459-
if( String( (const char*)fileName ).endsWith(".bmp" ) ) {
460+
} else if( String( (const char*)fileName ).endsWith(".bmp" ) ) {
460461
if( !BLE_FS.exists( (const char*)fileName ) ) {
461462
log_e("File %s does not exist\n", (const char*)fileName );
462463
} else {
@@ -466,6 +467,16 @@ class UIUtils
466467
giveMuxSemaphore();
467468
vTaskDelay( 5000 );
468469
}
470+
} else if( String( (const char*)fileName ).endsWith(".qoi" ) ) {
471+
if( !BLE_FS.exists( (const char*)fileName ) ) {
472+
log_e("File %s does not exist\n", (const char*)fileName );
473+
} else {
474+
takeMuxSemaphore();
475+
Out.scrollNextPage(); // reset scroll position to zero otherwise image will have offset
476+
tft.drawQoiFile( BLE_FS, (const char*)fileName, 0, 0 );
477+
giveMuxSemaphore();
478+
vTaskDelay( 5000 );
479+
}
469480
}
470481
isQuerying = false;
471482
}

screenshots/capture-esp32-s3-box.jpg

121 KB
Loading

0 commit comments

Comments
 (0)