Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/TFT_eSPI/User_Setup_Select.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@
#ifdef LILYGO_S3_T_EMBED
#include <User_Setups/Setup210_LilyGo_T_Embed_S3.h> // For the LilyGo T-Embed S3 based ESP32S3 with ST7789 170 x 320 TFT
#endif
#ifdef M5_STICKS3
#include <User_Setups/Setup216_M5_StickS3.h> // M5Stack StickS3 (ESP32-S3-PICO) with ST7789P3 135 x 240 TFT
#ifdef M5_CARDPUTER_ADV
#include <User_Setups/Setup215_M5_Cardputer_Adv.h> // M5Stack Cardputer Adv (ESP32-S3) with ST7789V2 240 x 135 TFT
#endif
Expand Down
31 changes: 31 additions & 0 deletions lib/TFT_eSPI/User_Setups/Setup216_M5_StickS3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// ST7789P3 135 x 240 display - M5Stack StickS3 (ESP32-S3-PICO)
#define USER_SETUP_ID 216

#define ST7789_DRIVER

#define TFT_WIDTH 135
#define TFT_HEIGHT 240

#define TFT_INVERSION_ON
#define TFT_BACKLIGHT_ON 1

#define TFT_MISO -1
#define TFT_MOSI 39
#define TFT_SCLK 40
#define TFT_CS 41
#define TFT_DC 45
#define TFT_RST 21
#define TFT_BL 38

#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8
#define LOAD_GFXFF

#define SMOOTH_FONT

#define SPI_FREQUENCY 40000000
#define SPI_READ_FREQUENCY 20000000
40 changes: 36 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ framework = arduino
extra_scripts =
pre:auto_firmware_version.py
post:post_build_merge.py
monitor_filters =
monitor_filters =
esp32_exception_decoder
time
log2file
Expand All @@ -107,17 +107,17 @@ monitor_speed = 115200
upload_speed = 1500000
# 2 x 4.5MB app, 6.875MB SPIFFS
board_build.partitions = huge_app.csv
build_flags =
build_flags =
-D M5STICK_CPLUS=1
;-D DEBUG_MINING=1
lib_deps =
lib_deps =
https://github.com/takkaO/OpenFontRender#v1.2
bblanchon/ArduinoJson@^6.21.5
https://github.com/tzapu/WiFiManager.git#v2.0.17
mathertel/OneButton@^2.5.0
arduino-libraries/NTPClient@^3.2.1
m5stack/M5StickCPlus@^0.1.0
lib_ignore =
lib_ignore =
TFT_eSPI
SD
SD_MMC
Expand All @@ -126,6 +126,38 @@ lib_ignore =

;--------------------------------------------------------------------

[env:M5-StickS3]
platform = espressif32@6.6.0
board = esp32-s3-devkitc-1
framework = arduino
extra_scripts =
pre:auto_firmware_version.py
post:post_build_merge.py
monitor_filters =
esp32_exception_decoder
time
log2file
board_build.arduino.memory_type = qio_opi
monitor_speed = 115200
upload_speed = 921600
board_build.partitions = huge_app.csv
build_flags =
-D BOARD_HAS_PSRAM
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D M5_STICKS3=1
;-D DEBUG_MINING=1
lib_deps =
https://github.com/takkaO/OpenFontRender#v1.2
bblanchon/ArduinoJson@^6.21.5
https://github.com/tzapu/WiFiManager.git#v2.0.17
mathertel/oneButton@^2.6.1
arduino-libraries/NTPClient@^3.2.1
lib_ignore =
HANSOLOminerv2

;--------------------------------------------------------------------

[env:wt32-sc01]
platform = espressif32@6.6.0
board = esp-wrover-kit
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/devices/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "lilygoS3Dongle.h"
#elif defined(LILYGO_S3_T_EMBED)
#include "lilygoS3TEmbed.h"
#elif defined(M5_STICKS3)
#include "m5StickS3.h"
#elif defined(M5_CARDPUTER_ADV)
#include "m5CardputerAdv.h"
#elif defined(ESP32_2432S028R)
Expand Down
9 changes: 9 additions & 0 deletions src/drivers/devices/m5StickS3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _M5_STICKS3_H
#define _M5_STICKS3_H

#define PIN_BUTTON_1 11
#define PIN_BUTTON_2 12

#define V1_DISPLAY

#endif
5 changes: 4 additions & 1 deletion src/drivers/displays/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ DisplayDriver *currentDisplayDriver = &esp32_2432S028RDriver;
DisplayDriver *currentDisplayDriver = &t_qtDisplayDriver;
#endif

#ifdef V1_DISPLAY
#if defined(M5_STICKS3)
DisplayDriver *currentDisplayDriver = &m5StickS3Driver;
#elif defined(V1_DISPLAY)
DisplayDriver *currentDisplayDriver = &tDisplayV1Driver;
#endif

Expand All @@ -69,6 +71,7 @@ DisplayDriver *currentDisplayDriver = &ssd1306DisplayDriver;
#endif



// Initialize the display
void initDisplay()
{
Expand Down
1 change: 1 addition & 0 deletions src/drivers/displays/displayDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extern DisplayDriver m5stickCDriver;
extern DisplayDriver m5stickCPlusDriver;
extern DisplayDriver t_hmiDisplayDriver;
extern DisplayDriver sp_kcDisplayDriver;
extern DisplayDriver m5StickS3Driver;
extern DisplayDriver ssd1306DisplayDriver;

#define SCREENS_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
Expand Down
77 changes: 77 additions & 0 deletions src/drivers/displays/m5StickS3Driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "displayDriver.h"

#ifdef M5_STICKS3

#include <Arduino.h>
#include <Wire.h>

// Reusing functions from tDisplayV1Driver.cpp, only the display
// initialization differs

extern void tDisplay_Init(void);
extern void tDisplay_AlternateScreenState(void);
extern void tDisplay_AlternateRotation(void);
extern void tDisplay_LoadingScreen(void);
extern void tDisplay_SetupScreen(void);
extern void tDisplay_AnimateCurrentScreen(unsigned long);
extern void tDisplay_DoLedStuff(unsigned long);
extern void tDisplay_MinerScreen(unsigned long);
extern void tDisplay_ClockScreen(unsigned long);
extern void tDisplay_GlobalHashScreen(unsigned long);
extern void tDisplay_BTCprice(unsigned long);

// M5PM1 PMIC (I2C 0x6E, SDA=47, SCL=48) gates the LCD power rail via PM1_G2.
// Without this sequence the ST7789P3 has no VCC and the screen stays black

static void m5pm1_rmw(uint8_t reg, uint8_t setBits, uint8_t clearBits)
{
const uint8_t addr = 0x6E;
Wire.beginTransmission(addr);
Wire.write(reg);
if (Wire.endTransmission(false) != 0) return;
if (Wire.requestFrom(addr, (uint8_t)1) != 1) return;
uint8_t v = Wire.read();
v = (v & ~clearBits) | setBits;
Wire.beginTransmission(addr);
Wire.write(reg);
Wire.write(v);
Wire.endTransmission();
}

static void m5StickS3_enableLcdPower(void)
{
Wire.begin(47, 48);
const uint8_t G2 = 1 << 2;
m5pm1_rmw(0x16, 0, G2); // FUNC0: PM1_G2 -> GPIO function
m5pm1_rmw(0x10, G2, 0); // MODE: PM1_G2 -> output
m5pm1_rmw(0x13, 0, G2); // DRV: PM1_G2 -> push-pull
m5pm1_rmw(0x11, G2, 0); // OUT: PM1_G2 -> high (LCD power on)
}

static void m5StickS3_Init(void)
{
m5StickS3_enableLcdPower();
tDisplay_Init();
}

static CyclicScreenFunction m5StickS3CyclicScreens[] = {
tDisplay_MinerScreen,
tDisplay_ClockScreen,
tDisplay_GlobalHashScreen,
tDisplay_BTCprice};

DisplayDriver m5StickS3Driver = {
m5StickS3_Init,
tDisplay_AlternateScreenState,
tDisplay_AlternateRotation,
tDisplay_LoadingScreen,
tDisplay_SetupScreen,
m5StickS3CyclicScreens,
tDisplay_AnimateCurrentScreen,
tDisplay_DoLedStuff,
SCREENS_ARRAY_SIZE(m5StickS3CyclicScreens),
0,
240,
135};

#endif
Loading