Skip to content

Commit

Permalink
CoreS3 port and AsyncTCP new solution
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorcelli committed Aug 10, 2024
1 parent ca9d23c commit 334e44c
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 44 deletions.
16 changes: 0 additions & 16 deletions .vscode/settings.json

This file was deleted.

Binary file modified Launcher/Launcher_2.0_C.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_CYD-2-USB.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_CYD-2432S028.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_Cardputer.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_CoreS3.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_Marauder-Mini.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_Marauder-v4-OG.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_T-Display-S3-Touchscreen.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_core2.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_core_16Mb.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_cplus1_1.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_cplus2.bin
Binary file not shown.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Sourcecode will be released in the future..
* UiFlow 1 doesn´t work with M5Launcher.. it uses an old MicroPython distro, that uses an old ESP-IDF distro with lots os secrets that I couldn´t figure out.

## Changelog
* 2.2.4:
* [x] Finally ported to CoreS3 and CoreS3-SE
* [x] Added reset to watchdog on WebUI and check for free memory when loading files to WebUI, to avoid crashes.
* 2.2.3:
* [x] StickC, Plus and Plus2: removed power btn from skip logic at start.
* [x] Changed EEPROM Addresses to avoid problems with the new Bruce and other firmwares..
Expand Down
8 changes: 7 additions & 1 deletion lib/M5GFX/src/lgfx/v1/LGFXBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ namespace lgfx
public:
LGFXBase(void) = default;
virtual ~LGFXBase(void) = default;

LGFX_INLINE static constexpr uint16_t tftwidth = WIDTH;
LGFX_INLINE static constexpr uint16_t tftheight = HEIGHT;
LGFX_INLINE static constexpr uint16_t textsize = 2;
LGFX_INLINE static constexpr uint16_t textcolor = TFT_GREEN;
LGFX_INLINE static constexpr uint16_t textbgcolor = TFT_BLACK;
/// @brief Converts RGB information to 8-bit color code.
/// @param r red
/// @param g green
Expand Down Expand Up @@ -217,6 +221,7 @@ namespace lgfx
/// @param h Height in pixels
/// @note Draws in the color specified by setColor().
void drawRect ( int32_t x, int32_t y, int32_t w, int32_t h);
LGFX_INLINE_T void drawRoundRect ( int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, const T& color, uint16_t _nada) { setColor(color); drawRoundRect(x, y, w, h, r); }
LGFX_INLINE_T void drawRoundRect ( int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, const T& color) { setColor(color); drawRoundRect(x, y, w, h, r); }
void drawRoundRect ( int32_t x, int32_t y, int32_t w, int32_t h, int32_t r);
LGFX_INLINE_T void fillRoundRect ( int32_t x, int32_t y, int32_t w, int32_t h, int32_t r, const T& color) { setColor(color); fillRoundRect(x, y, w, h, r); }
Expand All @@ -243,6 +248,7 @@ namespace lgfx
void drawEllipseArc ( int32_t x, int32_t y, int32_t r0x, int32_t r1x, int32_t r0y, int32_t r1y, float angle0, float angle1);
LGFX_INLINE_T void fillEllipseArc ( int32_t x, int32_t y, int32_t r0x, int32_t r1x, int32_t r0y, int32_t r1y, float angle0, float angle1, const T& color) { setColor(color); fillEllipseArc( x, y, r0x, r1x, r0y, r1y, angle0, angle1); }
void fillEllipseArc ( int32_t x, int32_t y, int32_t r0x, int32_t r1x, int32_t r0y, int32_t r1y, float angle0, float angle1);
LGFX_INLINE_T void drawArc ( int32_t x, int32_t y, int32_t r0, int32_t r1, float angle0, float angle1, const T& color, uint16_t __x, bool __s) { setColor(color); drawEllipseArc( x, y, r0, r1, r0, r1, angle0, angle1); }
LGFX_INLINE_T void drawArc ( int32_t x, int32_t y, int32_t r0, int32_t r1, float angle0, float angle1, const T& color) { setColor(color); drawEllipseArc( x, y, r0, r1, r0, r1, angle0, angle1); }
void drawArc ( int32_t x, int32_t y, int32_t r0, int32_t r1, float angle0, float angle1) { drawEllipseArc( x, y, r0, r1, r0, r1, angle0, angle1); }
LGFX_INLINE_T void fillArc ( int32_t x, int32_t y, int32_t r0, int32_t r1, float angle0, float angle1, const T& color) { setColor(color); fillEllipseArc( x, y, r0, r1, r0, r1, angle0, angle1); }
Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ default_envs =

[common]
build_flags =
-DLAUNCHER='"2.2.3"'
-DLAUNCHER='"2.2.4"'
-DMAXFILES=256
-DEEPROMSIZE=128
-DLH=8
Expand Down Expand Up @@ -451,7 +451,7 @@ build_flags =
-DMAX_ITEMS=10

-DUSER_SETUP_LOADED=1
-DILI9341_DRIVER=1
-DILI9342_DRIVER=1
-DTFT_INVERSION_ON=1
-DTFT_BACKLIGHT_ON=1
-DM5STACK=1
Expand Down
13 changes: 9 additions & 4 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
#include "sd_functions.h"
#include "settings.h"

#if defined(M5STACK) && defined(CORE3)
#define tft M5.Lcd
#else
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
#endif


/***************************************************************************************
** Function name: resetTftDisplay
Expand Down Expand Up @@ -89,7 +94,7 @@ void TdisplayS3Footer2(uint16_t color) {
** Description: Start Display functions and display bootscreen
***************************************************************************************/
void initDisplay(bool doAll) {
tft.drawSmoothRoundRect(5,5,5,5,WIDTH-10,HEIGHT-10,FGCOLOR,BGCOLOR);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,FGCOLOR);
tft.setTextSize(FONT_P);
tft.setCursor(10,10);
int cor = 0;
Expand Down Expand Up @@ -146,8 +151,8 @@ void displayCurrentItem(JsonDocument doc, int currentIndex) {

//tft.fillScreen(BGCOLOR);
tft.fillRect(0,HEIGHT-5,WIDTH,5,BGCOLOR);
tft.drawSmoothRoundRect(5,5,5,5,WIDTH-10,HEIGHT-10,FGCOLOR,BGCOLOR);
tft.fillSmoothRoundRect(6,6,WIDTH-12,HEIGHT-12,5,BGCOLOR);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,FGCOLOR);
tft.fillRoundRect(6,6,WIDTH-12,HEIGHT-12,5,BGCOLOR);

setTftDisplay(10, 10, FGCOLOR,FONT_P);
tft.print("Firmware: ");
Expand Down Expand Up @@ -205,7 +210,7 @@ void displayCurrentItem(JsonDocument doc, int currentIndex) {
void displayCurrentVersion(String name, String author, String version, String published_at, int versionIndex, JsonArray versions) {
//tft.fillScreen(BGCOLOR);
tft.fillRect(0,HEIGHT-5,WIDTH,5,BGCOLOR);
tft.drawSmoothRoundRect(5,5,5,5,WIDTH-10,HEIGHT-10,ALCOLOR,BGCOLOR);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,FGCOLOR);
tft.fillSmoothRoundRect(6,6,WIDTH-12,HEIGHT-12,5,BGCOLOR);

setTftDisplay(10, 10, ~BGCOLOR,FONT_M,BGCOLOR);
Expand Down
6 changes: 4 additions & 2 deletions src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
#include <vector>
#include "globals.h"
// Declaração dos objetos TFT

#if defined(M5STACK) && defined(CORE3)
#define tft M5.Lcd
#else
extern TFT_eSPI tft;

#endif
void loopOptions(const std::vector<std::pair<std::string, std::function<void()>>>& options, bool bright = false);
void loopVersions();
void loopFirmware();
Expand Down
14 changes: 7 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ void setup() {
axp192.begin();
pinMode(SEL_BTN, INPUT);
pinMode(DW_BTN, INPUT);
#elif defined(M5STACK)
//M5.begin(); // Begin after TFT, for SDCard to work
#elif defined(M5STACK) && defined(CORE3)
M5.begin(); // Begin after TFT, for SDCard to work
#elif defined(CARDPUTER)
Keyboard.begin();
pinMode(10, INPUT);
Expand All @@ -141,7 +141,6 @@ void setup() {
if (!touch.init()) {
Serial.println("Touch IC not found");
}

#elif defined(CYD)
pinMode(XPT2046_CS, OUTPUT);
//touchSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
Expand All @@ -150,7 +149,7 @@ void setup() {
log_i("Touch IC not Started");
} else log_i("Touch IC Started");
digitalWrite(XPT2046_CS, LOW);
#elif defined(HAS_BTN)
#elif HAS_BTN>0
#if UP_BTN >= 0
pinMode(UP_BTN, INPUT);
#endif
Expand All @@ -161,7 +160,6 @@ void setup() {
pinMode(DW_BTN, INPUT);
#endif
#endif

#if defined(BACKLIGHT)
pinMode(BACKLIGHT, OUTPUT);
#endif
Expand Down Expand Up @@ -227,8 +225,11 @@ void setup() {
String fileToCopy;

//Init Display
#if !defined(M5STACK)
tft.setAttribute(PSRAM_ENABLE,true);
tft.init();
#endif
//log_i("Passou init %d", (int)count); count++;
tft.setRotation(rotation);
tft.fillScreen(BGCOLOR);
setBrightness(bright,false);
Expand All @@ -253,7 +254,7 @@ uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield from
#endif


#if defined(M5STACK)
#if defined(M5STACK) && !defined(CORE3)
M5.begin(); // Begin after TFT, for SDCard to work
#endif
// Performs the verification when Launcher is installed through OTA
Expand All @@ -262,7 +263,6 @@ uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield from
const esp_partition_t* ota_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL);
uint8_t firstByte;
esp_partition_read(ota_partition,0,&firstByte,1);

//Gets the config.conf from SD Card and fill out the settings JSON
getConfigs();
#if defined(M5STACK)
Expand Down
11 changes: 2 additions & 9 deletions src/onlineLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void wifiConnect(String ssid, int encryptation, bool isAP) {
resetTftDisplay(10, 10, FGCOLOR, FONT_P);
tft.fillScreen(BGCOLOR);
tftprint("Connecting to: " + ssid + ".", 10);
tft.drawSmoothRoundRect(5,5,5,5,WIDTH-10,HEIGHT-10,FGCOLOR,BGCOLOR);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,FGCOLOR);
// Simulação da função de desenho no display TFT
int count = 0;
while (WiFi.status() != WL_CONNECTED) {
Expand Down Expand Up @@ -161,7 +161,7 @@ bool GetJsonFromM5() {
int httpResponseCode=-1;
resetTftDisplay(WIDTH/2 - 6*String("Getting info from").length(),32);
tft.fillSmoothRoundRect(6,6,WIDTH-12,HEIGHT-12,5,BGCOLOR);
tft.drawSmoothRoundRect(5,5,5,5,WIDTH-10,HEIGHT-10,FGCOLOR,BGCOLOR);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,FGCOLOR);
tft.drawCentreString("Getting info from", WIDTH/2, HEIGHT/3,1);
tft.drawCentreString("M5Burner repo", WIDTH/2, HEIGHT/3+FONT_M*9,1);

Expand Down Expand Up @@ -335,13 +335,6 @@ void installFirmware(String file, uint32_t app_size, bool spiffs, uint32_t spiff
//eraseFAT();
#endif

#ifndef STICK_C
tft.drawRect(18, HEIGHT - 47, 204, 17, FGCOLOR);
if (spiffs) tft.drawRect(18, HEIGHT - 28, 204, 17, ALCOLOR);
#else
tft.drawRect(28, HEIGHT - 47, 104, 17, FGCOLOR);
if (spiffs) tft.drawRect(28, HEIGHT - 28, 104, 17, ALCOLOR);
#endif
if(nb) app_offset = 0;
if(!httpUpdate.updateFromOffset(*client, fileAddr, app_offset, app_size)) {
displayRedStripe("Instalation Failed");
Expand Down
15 changes: 12 additions & 3 deletions src/webInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "display.h"
#include "mykeyboard.h"
#include "settings.h"
#include "esp_task_wdt.h"

struct Config {
String httpuser;
Expand Down Expand Up @@ -100,8 +101,11 @@ String listFiles(String folder) {

if (folder=="/") folder = "";
while (foundfile) {
if(foundfile.isDirectory()) returnText+="Fo:" + String(foundfile.name()) + ":0\n";
if(esp_get_free_heap_size()>(String("Fo:" + String(foundfile.name()) + ":0\n").length())+1024) {
if(foundfile.isDirectory()) returnText+="Fo:" + String(foundfile.name()) + ":0\n";
} else break;
foundfile = root.openNextFile();
esp_task_wdt_reset();
}
root.close();
foundfile.close();
Expand All @@ -110,8 +114,11 @@ String listFiles(String folder) {
root = SDM.open(folder);
foundfile = root.openNextFile();
while (foundfile) {
if(!(foundfile.isDirectory())) returnText+="Fi:" + String(foundfile.name()) + ":" + humanReadableSize(foundfile.size()) + "\n";
if(esp_get_free_heap_size()>(String("Fo:" + String(foundfile.name()) + ":0\n").length())+1024) {
if(!(foundfile.isDirectory())) returnText+="Fi:" + String(foundfile.name()) + ":" + humanReadableSize(foundfile.size()) + "\n";
} else break;
foundfile = root.openNextFile();
esp_task_wdt_reset();
}
root.close();
foundfile.close();
Expand Down Expand Up @@ -171,8 +178,10 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index,
// stream the incoming chunk to the opened file
if(!update) {
request->_tempFile.write(data, len);
esp_task_wdt_reset();
} else {
if(!Update.write(data,len)) displayRedStripe("FAIL 172");
esp_task_wdt_reset();
}
}

Expand Down Expand Up @@ -411,7 +420,7 @@ void startWebUi(String ssid, int encryptation, bool mode_ap) {
disableCore1WDT(); // disable WDT
disableLoopWDT(); // disable WDT

tft.drawSmoothRoundRect(5,5,5,5,WIDTH-10,HEIGHT-10,ALCOLOR,BGCOLOR);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,ALCOLOR);
tft.fillSmoothRoundRect(6,6,WIDTH-12,HEIGHT-12,5,BGCOLOR);
setTftDisplay(7,7,ALCOLOR,FONT_P,BGCOLOR);
tft.drawCentreString("-= M5Launcher WebUI =-",WIDTH/2,0,8);
Expand Down

0 comments on commit 334e44c

Please sign in to comment.