Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for M5StickC Plus2 #546

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
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
35 changes: 35 additions & 0 deletions boards/m5stick-c-plus2.json
Original file line number Diff line number Diff line change
@@ -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"
}
33 changes: 33 additions & 0 deletions boards/variants/m5stick_c_plus2/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

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 */
3 changes: 3 additions & 0 deletions lib/TFT_eSPI/User_Setup_Select.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@
#ifdef NERDMINER_S3_GEEK
#include <User_Setups/Setup303_WaveShare ESP32S3_GEEK.h> // Setup file for Waveshare Setup303_WaveShare ESP32S3_GEEK with ST7789 135*240 TFT
#endif
#ifdef M5STICK_C_PLUS2
#include <User_Setups/Setup304_M5StickCPlus2.h> // Setup file for ESP32 configured for ST7735 128 x 128 animated eyes
#endif
//#include <User_Setups/Setup301_BW16_ST7735.h> // Setup file for Bw16-based boards with ST7735 160 x 80 TFT

//#include <User_Setups/SetupX_Template.h> // Template file for a setup
Expand Down
65 changes: 65 additions & 0 deletions lib/TFT_eSPI/User_Setups/Setup304_M5StickCPlus2.h
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,37 @@ globallib_dir = lib

default_envs = NerdminerV2-T-HMI, wt32-sc01, wt32-sc01-plus, han_m5stack, M5Stick-C, esp32cam, ESP32-2432S028R, ESP32_2432S028_2USB, NerdminerV2, Lilygo-T-Embed, ESP32-devKitv1, NerdminerV2-S3-DONGLE, NerdminerV2-S3-GEEK, NerdminerV2-S3-AMOLED, NerdminerV2-S3-AMOLED-TOUCH, NerdminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R, M5-StampS3, ESP32-S3-devKitv1, ESP32-S3-mini-wemos, ESP32-S2-mini-wemos, ESP32-S3-mini-weact, ESP32-D0WD-V3-weact, ESP32-C3-devKitmv1, ESP32-C3-super-mini

[env:M5Stick-C-Plus2]
platform = [email protected]
board = m5stick-c-plus2
framework = arduino
monitor_filters =
esp32_exception_decoder
time
log2file
;board_build.arduino.memory_type = qio_opi
monitor_speed = 115200
upload_speed = 1500000
# 2 x 4.5MB app, 6.875MB SPIFFS
board_build.partitions = huge_app.csv
build_flags =
-D M5STICK_C_PLUS2=1
;-D DEBUG_MINING=1
lib_deps =
bblanchon/ArduinoJson@^6.21.5
https://github.com/tzapu/WiFiManager.git#v2.0.17
https://github.com/takkaO/OpenFontRender#v1.2
mathertel/OneButton@^2.5.0
arduino-libraries/NTPClient@^3.2.1
m5stack/M5StickCPlus2
lib_ignore =
SD
SD_MMC
rm67162
HANSOLOminerv2

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

[env:M5Stick-C]
platform = [email protected]
board = m5stick-c
Expand Down
10 changes: 10 additions & 0 deletions src/drivers/devices/M5Stick-C-Plus2.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/drivers/devices/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down