From 4102e735a3d9a1012a350dce0a93aa50b98d416a Mon Sep 17 00:00:00 2001 From: TheMiner203 Date: Fri, 20 Dec 2024 21:18:21 +0800 Subject: [PATCH] M5StickC Plus2 Support --- boards/m5stick-c-plus2.json | 35 ++++++++++ .../variants/m5stick_c_plus2/pins_arduino.h | 33 ++++++++++ lib/TFT_eSPI/User_Setup_Select.h | 3 + .../User_Setups/Setup304_M5StickCPlus2.h | 65 +++++++++++++++++++ src/drivers/devices/M5Stick-C-Plus2.h | 10 +++ src/drivers/devices/device.h | 2 + 6 files changed, 148 insertions(+) create mode 100644 boards/m5stick-c-plus2.json create mode 100644 boards/variants/m5stick_c_plus2/pins_arduino.h create mode 100644 lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h create mode 100644 src/drivers/devices/M5Stick-C-Plus2.h diff --git a/boards/m5stick-c-plus2.json b/boards/m5stick-c-plus2.json new file mode 100644 index 0000000..a0065d8 --- /dev/null +++ b/boards/m5stick-c-plus2.json @@ -0,0 +1,35 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": "-DARDUINO_M5Stick_C_Plus2", + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variants_dir": "boards/variants", + "variant": "m5stick_c_plus2" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "M5Stick-ะก-Plus2", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 2095104, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 1500000 + }, + "url": "https://docs.m5stack.com/en/core/M5StickC%20PLUS2", + "vendor": "M5Stack" +} diff --git a/boards/variants/m5stick_c_plus2/pins_arduino.h b/boards/variants/m5stick_c_plus2/pins_arduino.h new file mode 100644 index 0000000..1948afc --- /dev/null +++ b/boards/variants/m5stick_c_plus2/pins_arduino.h @@ -0,0 +1,33 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 32; +static const uint8_t SCL = 33; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 15; +static const uint8_t MISO = 36; +static const uint8_t SCK = 13; + +static const uint8_t G9 = 9; +static const uint8_t G10 = 10; +static const uint8_t G37 = 37; +static const uint8_t G39 = 39; +static const uint8_t G32 = 32; +static const uint8_t G33 = 33; +static const uint8_t G26 = 26; +static const uint8_t G36 = 36; +static const uint8_t G0 = 0; + +static const uint8_t DAC1 = 25; +static const uint8_t DAC2 = 26; + +static const uint8_t ADC1 = 35; +static const uint8_t ADC2 = 36; + +#endif /* Pins_Arduino_h */ diff --git a/lib/TFT_eSPI/User_Setup_Select.h b/lib/TFT_eSPI/User_Setup_Select.h index 0955318..6f9a082 100644 --- a/lib/TFT_eSPI/User_Setup_Select.h +++ b/lib/TFT_eSPI/User_Setup_Select.h @@ -158,6 +158,9 @@ #ifdef NERDMINER_S3_GEEK #include // Setup file for Waveshare Setup303_WaveShare ESP32S3_GEEK with ST7789 135*240 TFT #endif +#ifdef M5STICK_C_PLUS2 +#include // Setup file for ESP32 configured for ST7735 128 x 128 animated eyes +#endif //#include // Setup file for Bw16-based boards with ST7735 160 x 80 TFT //#include // Template file for a setup diff --git a/lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h b/lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h new file mode 100644 index 0000000..f4a1dd5 --- /dev/null +++ b/lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h @@ -0,0 +1,65 @@ +// ST7789 135 x 240 display + +#define USER_SETUP_ID 304 + +// #define DISABLE_ALL_LIBRARY_WARNINGS + +#define ST7789_DRIVER + +#define TFT_WIDTH 135 +#define TFT_HEIGHT 240 + +#define TFT_BL 27 +#define TFT_BACKLIGHT_ON HIGH +#define TFT_MISO -1 +#define TFT_MOSI 15 +#define TFT_SCLK 13 +#define TFT_CS 5 +#define TFT_DC 14 +#define TFT_RST 12 + + +#define CGRAM_OFFSET // Library will add offsets required + +//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue +//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red + +//#define TFT_INVERSION_ON +//#define TFT_INVERSION_OFF + +// DSTIKE stepup +//#define TFT_DC 23 +//#define TFT_RST 32 +//#define TFT_MOSI 26 +//#define TFT_SCLK 27 + +// Generic ESP32 setup +//#define TFT_MISO 19 +//#define TFT_MOSI 23 +//#define TFT_SCLK 18 +//#define TFT_CS -1 // Not connected +//#define TFT_DC 2 +//#define TFT_RST 4 // Connect reset to ensure display initialises + +// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation + +#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH +#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters +#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters +#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm +#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. +#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. +//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT +#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts + +#define SMOOTH_FONT + + +// #define SPI_FREQUENCY 27000000 +#define SPI_FREQUENCY 40000000 + +#define SPI_READ_FREQUENCY 20000000 + +#define SPI_TOUCH_FREQUENCY 2500000 + +// #define SUPPORT_TRANSACTIONS \ No newline at end of file diff --git a/src/drivers/devices/M5Stick-C-Plus2.h b/src/drivers/devices/M5Stick-C-Plus2.h new file mode 100644 index 0000000..6f27f1f --- /dev/null +++ b/src/drivers/devices/M5Stick-C-Plus2.h @@ -0,0 +1,10 @@ +#ifndef _M5_STICK_C_PLUS2_H +#define _M5_STICK_C_PLUS2_H + +#define PIN_BUTTON_1 37 +#define PIN_BUTTON_2 39 +#define LED_PIN 19 + +#define V1_DISPLAY + +#endif \ No newline at end of file diff --git a/src/drivers/devices/device.h b/src/drivers/devices/device.h index 9f72dde..6739663 100644 --- a/src/drivers/devices/device.h +++ b/src/drivers/devices/device.h @@ -5,6 +5,8 @@ #include "nerdMinerV2.h" #elif defined(M5STICK_C) #include "M5Stick-C.h" +#elif defined(M5STICK_C_PLUS2) +#include "M5Stick-C-Plus2.h" #elif defined(DEVKITV1) #include "esp32DevKit.h" #elif defined(TDISPLAY)