Skip to content

Commit

Permalink
Merge pull request #46 from tobozo/M5CoreS3
Browse files Browse the repository at this point in the history
S3Box + M5Stack CoreS3 support
  • Loading branch information
tobozo authored May 24, 2023
2 parents 24f5c13 + 21c1d0b commit a2efdd4
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- esp32:esp32:m5stack-fire
- esp32:esp32:m5stack-core2
- esp32:esp32:odroid_esp32:PartitionScheme=min_spiffs
- esp32:esp32:esp32s3box

platform-url:
- https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
Expand All @@ -53,6 +54,9 @@ jobs:
- arduino-boards-fqbn: esp32:esp32:odroid_esp32:PartitionScheme=min_spiffs
fancy-name: OdroidGo
bin-name: OdroidGo-BLECollector.bin
- arduino-boards-fqbn: esp32:esp32:esp32s3box
fancy-name: S3Box
bin-name: S3Box-BLECollector.bin

fail-fast: false

Expand Down
10 changes: 10 additions & 0 deletions ESP32-BLECollector/BLE.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/

#pragma GCC diagnostic ignored "-Wunused-variable"

#define TICKS_TO_DELAY 1000

const char* processTemplateLong = "%s%d%s%d";
Expand Down Expand Up @@ -893,6 +895,7 @@ class BLEScanUtils
vTaskDelete(NULL);
}

#if defined USE_SCREENSHOTS
static void screenShotCB( void * param = NULL )
{
xTaskCreate(screenShotTask, "screenShotTask", 16000, NULL, 2, NULL);
Expand All @@ -904,6 +907,7 @@ class BLEScanUtils
log_w("Cold ScreenShot");
M5.ScreenShot->init(/* &M5.Lcd, BLE_FS */);
if( M5.ScreenShot->begin() ) {
log_w("ScreenShot Service loaded");
UI.ScreenShotLoaded = true;
UI.screenShot();
} else {
Expand All @@ -915,6 +919,7 @@ class BLEScanUtils
}
vTaskDelete(NULL);
}
#endif

static void setTimeZone( void * param = NULL )
{
Expand Down Expand Up @@ -1044,7 +1049,12 @@ class BLEScanUtils
{ "ls", o->listDirCB, "Show [dir] Content on the SD" },
{ "rm", o->rmFileCB, "Delete [file] from the SD" },
{ "restart", o->restartCB, "Restart BLECollector ('restart now' to skip replication)" },

#if defined USE_SCREENSHOTS
{ "screenshot", o->screenShotCB, "Make a screenshot and save it on the SD" },
#endif


{ "screenshow", o->screenShowCB, "Show screenshot" },
{ "toggle", o->toggleCB, "toggle a bool value" },
{ "resetDB", o->resetCB, "Hard Reset DB + forced restart" },
Expand Down
2 changes: 1 addition & 1 deletion ESP32-BLECollector/BLECache.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
*
\*/


#pragma GCC diagnostic ignored "-Wunused-variable"

struct BLEGATTService
{
Expand Down
1 change: 1 addition & 0 deletions ESP32-BLECollector/BLEFileSharing.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/

#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"


#define TICKS_TO_DELAY 1000
Expand Down
2 changes: 1 addition & 1 deletion ESP32-BLECollector/DB.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/


#pragma GCC diagnostic ignored "-Wunused-variable"


const char* data = 0; // for some reason sqlite3 db callback needs this
Expand Down
64 changes: 54 additions & 10 deletions ESP32-BLECollector/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#if defined ARDUINO_M5Stack_Core_ESP32 \
|| defined ARDUINO_M5STACK_Core2 \
|| defined ARDUINO_M5STACK_CORES3 \
|| defined ARDUINO_M5STACK_FIRE \
|| defined ARDUINO_ODROID_ESP32 \
|| defined ARDUINO_ESP32_DEV \
Expand All @@ -13,6 +14,7 @@
|| defined ARDUINO_TWATCH_2020_V1 \
|| defined ARDUINO_TWATCH_2020_V2 \
|| defined ARDUINO_LOLIN_D32_PRO \
|| defined ARDUINO_ESP32_S3_BOX \
// yay! platform is supported
#else
#error "NO SUPPORTED BOARD DETECTED !!"
Expand Down Expand Up @@ -51,7 +53,7 @@ static const int AMIGABALL_YPOS = 50;


// display profiles switcher
#if defined( ARDUINO_M5Stack_Core_ESP32 ) || defined( ARDUINO_M5STACK_FIRE ) || defined( ARDUINO_ODROID_ESP32 ) || defined( ARDUINO_M5STACK_Core2 ) || defined( ARDUINO_LOLIN_D32_PRO )
#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

#if defined ARDUINO_M5Stack_Core_ESP32
//#undef WITH_WIFI // M5Stack has a small partition, disable WiFi
Expand All @@ -70,7 +72,7 @@ static const int AMIGABALL_YPOS = 50;
#undef hasHID
#define hasHID() (bool)false

#elif defined( ARDUINO_ODROID_ESP32 ) // M5Core2
#elif defined( ARDUINO_ODROID_ESP32 ) // Odroid-Go

#undef WITH_WIFI // NTP is useless without a RTC module
#undef TIME_UPDATE_SOURCE // disable time update accordingly
Expand All @@ -79,7 +81,21 @@ static const int AMIGABALL_YPOS = 50;
#define tft_initOrientation() tft.setRotation(0)
#undef USE_SD_UPDATER // Odroid-Go prefers CrashOverride's Application Loader

#elif defined( ARDUINO_M5STACK_Core2 ) // M5Core2
#elif defined ARDUINO_M5STACK_CORES3 // M5CoreS3

#undef HAS_EXTERNAL_RTC
#define HAS_EXTERNAL_RTC false
#undef BASE_BRIGHTNESS
#define BASE_BRIGHTNESS 100

#elif defined ARDUINO_M5STACK_Core2 // M5Core2

#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 6)
// espressif bloated the WiFi core since 2.0.7, now throwing
// an "IRAM0 segment data does not fit" linking error when used with NimBLE
#undef WITH_WIFI
#endif

#undef HAS_EXTERNAL_RTC
#define HAS_EXTERNAL_RTC true
#undef RTC_SDA
Expand All @@ -105,6 +121,18 @@ static const int AMIGABALL_YPOS = 50;
//#undef HEAPGRAPH_CORE
//#define HEAPGRAPH_CORE 0


#elif defined ARDUINO_ESP32_S3_BOX

#undef WITH_WIFI // can't fit on partition
#undef HAS_EXTERNAL_RTC
#define HAS_EXTERNAL_RTC true
#undef RTC_SDA
#undef RTC_SCL
#define RTC_SDA 41 // pin number
#define RTC_SCL 40 // pin number


#else
// M5Stack Classic, Fire
#undef HAS_EXTERNAL_RTC
Expand Down Expand Up @@ -241,13 +269,17 @@ static const int AMIGABALL_YPOS = 50;

#endif


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


#if !defined ECC_VERSION_MAJOR || !defined ECC_VERSION_MAJOR || !defined ECC_VERSION_MAJOR
#error "This app only uses ESP32-Chimera-Core >= 1.2.3"
#else
#if ((ECC_VERSION_MAJOR << 16) | (ECC_VERSION_MINOR << 8) | (ECC_VERSION_PATCH)) >= ((1 << 16) | (2 << 8) | (3))
// yay, minimal version requirements are met !
#define TFT_eSprite LGFX_Sprite // satisfy namespace requirements, comment this out if your version of chimera-core is too old
#else
#error "This app needs ESP32-Chimera-Core >= 1.2.3"
#endif
Expand All @@ -265,11 +297,14 @@ static const int AMIGABALL_YPOS = 50;
#define tft M5.Lcd // syntax sugar
//#include "HID_XPad.h" // external HID

#pragma GCC diagnostic ignored "-Wunused-variable"

static TFT_eSprite gradientSprite( &tft ); // gradient background
static TFT_eSprite heapGraphSprite( &tft ); // activity graph
static TFT_eSprite hallOfMacSprite( &tft ); // mac address badge holder


void tft_hScrollTo(uint16_t vsp);
static bool isQuerying = false; // state maintained while SD is accessed, useful when SD is used instead of SD_MMC
// TODO: make this SD-driver dependant rather than platform dependant
static bool isInQuery()
Expand All @@ -285,7 +320,11 @@ static bool isInQuery()
void tft_begin()
{

M5.begin( true, true, false, false, false ); // don't start Serial
#ifdef __M5STACKUPDATER_H
M5.begin( true, false, false, false, false ); // don't start Serial and SD
#else
M5.begin( true, true, false, false, false ); // don't start Serial
#endif

#if HAS_EXTERNAL_RTC
Wire.begin(RTC_SDA, RTC_SCL);
Expand All @@ -294,16 +333,21 @@ void tft_begin()
#endif
delay( 100 );
#ifdef __M5STACKUPDATER_H

tft_hScrollTo(0); // reset scroll position

if( hasHID() ) {
// build has buttons => enable SD Updater at boot
// New SD Updater support, requires the latest version of https://github.com/tobozo/M5Stack-SD-Updater/
SDUCfg.display = &tft;

#if defined M5_SD_UPDATER_VERSION_INT
SDUCfg.setLabelMenu("<< Menu");
SDUCfg.setLabelSkip("Launch");
SDUCfg.setAppName( PLATFORM_NAME " BLE Collector" );
SDUCfg.setBinFileName( "/ESP32-BLECollector.bin" );
//SDUCfg.useRolllback( false );
checkSDUpdater( BLE_FS, MENU_BIN, 5000, TFCARD_CS_PIN ); // Filesystem, Launcher bin path, Wait delay, Sdcard CS pin
// SDUCfg.setLabelMenu("<< Menu");
// SDUCfg.setLabelSkip("Launch");
// SDUCfg.setAppName( PLATFORM_NAME " BLE Collector" );
// SDUCfg.setBinFileName( "/ESP32-BLECollector.bin" );
// SDUCfg.useRolllback( false );
checkSDUpdater( BLE_FS, MENU_BIN, 15000, TFCARD_CS_PIN ); // Filesystem, Launcher bin path, Wait delay, Sdcard CS pin
#else
checkSDUpdater();
#endif
Expand Down
2 changes: 2 additions & 0 deletions ESP32-BLECollector/NTP.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma GCC diagnostic ignored "-Wunused-variable"

/*\
* NTP Helpers
\*/
Expand Down
2 changes: 2 additions & 0 deletions ESP32-BLECollector/RTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
*/

#pragma GCC diagnostic ignored "-Wunused-variable"

#if defined( ARDUINO_M5STACK_Core2 ) // M5Core2 uses BM8563

//#define BM8563_ADDR 0x51 // M5Core2 RTC I2C address
Expand Down
3 changes: 3 additions & 0 deletions ESP32-BLECollector/SDUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* SD Helpers
\*/


#pragma GCC diagnostic ignored "-Wunused-variable"

static bool sd_mounted = false;


Expand Down
2 changes: 2 additions & 0 deletions ESP32-BLECollector/ScrollPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/

#pragma GCC diagnostic ignored "-Wunused-variable"

#define SPACE " "
static bool isScrolling = false;
static bool isInScroll()
Expand Down
2 changes: 2 additions & 0 deletions ESP32-BLECollector/TimeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/

#pragma GCC diagnostic ignored "-Wunused-variable"

static unsigned long forcedUptime = 0;

enum TimeUpdateSources
Expand Down
21 changes: 16 additions & 5 deletions ESP32-BLECollector/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/


#pragma GCC diagnostic ignored "-Wunused-variable"

char *macAddressToColorStr = new char[MAC_LEN+1];

Expand Down Expand Up @@ -413,7 +413,7 @@ class UIUtils
giveMuxSemaphore();
}


#if defined USE_SCREENSHOTS
static void screenShot()
{
takeMuxSemaphore();
Expand All @@ -427,7 +427,8 @@ class UIUtils

//M5.ScreenShot->snapBMP("BLECollector", false);
//M5.ScreenShot->snapJPG("BLECollector", false);
M5.ScreenShot->snap("BLECollector", false); // filename prefix, show image after capture
M5.ScreenShot->snapQOI("BLECollector", false);
//M5.ScreenShot->snap("BLECollector", false); // filename prefix, show image after capture

// restore scroll states
tft_scrollTo( yRef ); // restore software scroll
Expand All @@ -436,6 +437,7 @@ class UIUtils
isQuerying = false;
giveMuxSemaphore();
}
#endif

static void screenShow( void * fileName = NULL )
{
Expand All @@ -455,8 +457,7 @@ class UIUtils
giveMuxSemaphore();
vTaskDelay( 5000 );
}
}
if( String( (const char*)fileName ).endsWith(".bmp" ) ) {
} else if( String( (const char*)fileName ).endsWith(".bmp" ) ) {
if( !BLE_FS.exists( (const char*)fileName ) ) {
log_e("File %s does not exist\n", (const char*)fileName );
} else {
Expand All @@ -466,6 +467,16 @@ class UIUtils
giveMuxSemaphore();
vTaskDelay( 5000 );
}
} else if( String( (const char*)fileName ).endsWith(".qoi" ) ) {
if( !BLE_FS.exists( (const char*)fileName ) ) {
log_e("File %s does not exist\n", (const char*)fileName );
} else {
takeMuxSemaphore();
Out.scrollNextPage(); // reset scroll position to zero otherwise image will have offset
tft.drawQoiFile( BLE_FS, (const char*)fileName, 0, 0 );
giveMuxSemaphore();
vTaskDelay( 5000 );
}
}
isQuerying = false;
}
Expand Down
2 changes: 2 additions & 0 deletions ESP32-BLECollector/UI_Icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
\*/


#pragma GCC diagnostic ignored "-Wunused-variable"

#include "Assets.h" // bitmaps


Expand Down
Binary file added screenshots/capture-esp32-s3-box.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a2efdd4

Please sign in to comment.