Skip to content

Commit 1fe1718

Browse files
authored
Add board M5Stickc Plus (1technophile#828)
1 parent bf94aee commit 1fe1718

File tree

7 files changed

+54
-19
lines changed

7 files changed

+54
-19
lines changed

docs/use/boards.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
So as to erase the flash memory on ESP boards you may do a long press to TRIGGER_GPIO button or connect the pin TRIGGER_GPIO to the ground during several seconds.
88

99
On M5Stack boards you may do a long press to these buttons:
10-
* Button B on M5StickC (GPIO 37)
10+
* Button B on M5StickC and M5StickC Plus (GPIO 37)
1111
* Button C on M5Stack (GPIO 37)
1212
* Button lateral on M5stick (GPIO 35)
1313

@@ -31,15 +31,15 @@ When coming back from mode 2 to mode 0 you may publish the command with a retain
3131
If you change the default low power mode in config_BT.h to 2 and your credential are not set or not correct, the ESP32 will not connect to the broker and the only way to change the low power mode will be a new erase/upload.
3232
:::
3333

34-
## M5Stick C or M5Stack
34+
## M5StickC, M5StickC Plus or M5Stack
3535

3636
### Behaviour
3737

3838
If the connexion of the board to WIFI and MQTT is successfull you will see the logo with text like below:
3939

4040
![boards](../img/OpenMQTTgateway_M5_Stack_Board_Display_Text.png)
4141

42-
The same behaviour apply to M5 Stick C
42+
The same behaviour apply to M5StickC and M5StickC Plus
4343

4444
![boards](../img/OpenMQTTgateway_M5_StickC_Board_Display_Text.png)
4545

@@ -66,8 +66,8 @@ OpenMQTTGateway support a low power mode for ESP32, this mode can be set by MQTT
6666

6767
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoBT/config" -m '{"low_power_mode":1}'`
6868

69-
* Low Power mode, screen OFF, LED ON when processing on M5StickC
69+
* Low Power mode, screen OFF, LED ON when processing on M5StickC or M5stickC Plus
7070

7171
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoBT/config" -m '{"low_power_mode":2}'`
7272

73-
The low power mode can be changed also with a push to button B when the board is processing (top button on M5stickC and middle button of M5stack).
73+
The low power mode can be changed also with a push to button B when the board is processing (top button on M5stickC, M5stickC Plus and middle button of M5stack).

main/User_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ uint8_t wifiProtocol = 0; // default mode, automatic selection
229229
//#define ZmqttDiscovery "HADiscovery"//ESP8266, Arduino, ESP32, Sonoff RF Bridge
230230
//#define ZactuatorFASTLED "FASTLED" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
231231
//#define ZboardM5STICKC "M5StickC"
232+
//#define ZboardM5STICKCP "M5StickCP"
232233
//#define ZboardM5STACK "ZboardM5STACK"
233234
//#define ZradioCC1101 "CC1101" //ESP8266, ESP32
234235
//#define ZactuatorPWM "PWM" //ESP8266, ESP32

main/ZboardM5.ino

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@
2828
*/
2929
#include "User_config.h"
3030

31-
#if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
31+
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
3232
# ifdef ZboardM5STICKC
3333
# include <M5StickC.h>
3434
# endif
35+
# ifdef ZboardM5STICKCP
36+
# include <M5StickCPlus.h>
37+
# endif
3538
# ifdef ZboardM5STACK
3639
# include <M5Stack.h>
3740
# endif
@@ -43,7 +46,7 @@ void setBrightness(int brightness) {
4346
# ifdef ZboardM5STACK
4447
M5.Lcd.setBrightness(brightness * 2);
4548
# endif
46-
# ifdef ZboardM5STICKC
49+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP)
4750
(!brightness) ? M5.Axp.ScreenBreath(0) : M5.Axp.ScreenBreath(7 + (int)brightness * 0.08);
4851
# endif
4952
}
@@ -84,7 +87,7 @@ void sleepScreen() {
8487
# ifdef ZboardM5STACK
8588
M5.begin(false, false, false); // M5.lcd.sleep() provokes a reset of the ESP
8689
# endif
87-
# ifdef ZboardM5STICKC
90+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP)
8891
M5.Axp.ScreenBreath(0);
8992
M5.Axp.SetLDO2(false);
9093
# endif

main/ZgatewayBT.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ void changelow_power_mode(int newLowPowerMode) {
654654
# ifdef ZboardM5STACK
655655
M5.Lcd.wakeup();
656656
# endif
657-
# ifdef ZboardM5STICKC
657+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP)
658658
M5.Axp.SetLDO2(true);
659659
M5.Lcd.begin();
660660
# endif

main/config_M5.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#ifdef ZboardM5STICKC
3030
# include <M5StickC.h>
3131
#endif
32+
#ifdef ZboardM5STICKCP
33+
# include <M5StickCPlus.h>
34+
#endif
3235
#ifdef ZboardM5STACK
3336
# include <M5Stack.h>
3437
#endif

main/main.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ JsonArray& modules = modulesBuffer.createArray();
132132
#ifdef ZactuatorPWM
133133
# include "config_PWM.h"
134134
#endif
135-
#if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
135+
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
136136
# include "config_M5.h"
137137
#endif
138138
#if defined(ZgatewayRS232)
@@ -466,7 +466,7 @@ void connectMQTT() {
466466
strcat(topic, will_Topic);
467467
client.setBufferSize(mqtt_max_packet_size);
468468
if (client.connect(gateway_name, mqtt_user, mqtt_pass, topic, will_QoS, will_Retain, will_Message)) {
469-
#if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
469+
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
470470
if (low_power_mode < 2)
471471
M5Display("MQTT connected", "", "");
472472
#endif
@@ -547,7 +547,7 @@ void setup() {
547547
preferences.begin(Gateway_Short_Name, false);
548548
low_power_mode = preferences.getUInt("low_power_mode", DEFAULT_LOW_POWER_MODE);
549549
preferences.end();
550-
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
550+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
551551
setupM5();
552552
# endif
553553
# endif
@@ -807,7 +807,7 @@ void setOTA() {
807807
# if defined(ZgatewayBT) && defined(ESP32)
808808
stopProcessing();
809809
# endif
810-
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
810+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
811811
M5Display("OTA in progress", "", "");
812812
# endif
813813
});
@@ -816,7 +816,7 @@ void setOTA() {
816816
# if defined(ZgatewayBT) && defined(ESP32)
817817
startProcessing();
818818
# endif
819-
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
819+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
820820
M5Display("OTA done", "", "");
821821
# endif
822822
});
@@ -1046,7 +1046,7 @@ void setup_wifimanager(bool reset_settings) {
10461046
{
10471047
# ifdef ESP32
10481048
if (low_power_mode < 2) {
1049-
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
1049+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
10501050
M5Display("Connect your phone to WIFI AP:", WifiManager_ssid, WifiManager_password);
10511051
# endif
10521052
} else { // in case of low power mode we put the ESP to sleep again if we didn't get connected (typical in case the wifi is down)
@@ -1073,7 +1073,7 @@ void setup_wifimanager(bool reset_settings) {
10731073
}
10741074
}
10751075

1076-
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
1076+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
10771077
if (low_power_mode < 2)
10781078
M5Display("Wifi connected", "", "");
10791079
# endif
@@ -1346,7 +1346,7 @@ void loop() {
13461346
#endif
13471347
}
13481348
// Function that doesn't need an active connection
1349-
#if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
1349+
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
13501350
loopM5();
13511351
#endif
13521352
}
@@ -1392,7 +1392,7 @@ void stateMeasures() {
13921392
SYSdata["m5-is-charging"] = (bool)M5.Power.isCharging();
13931393
SYSdata["m5-is-chargefull"] = (bool)M5.Power.isChargeFull();
13941394
# endif
1395-
# ifdef ZboardM5STICKC
1395+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP)
13961396
M5.Axp.EnableCoulombcounter();
13971397
SYSdata["m5-bat-voltage"] = (float)M5.Axp.GetBatVoltage();
13981398
SYSdata["m5-bat-current"] = (float)M5.Axp.GetBatCurrent();
@@ -1514,7 +1514,7 @@ void receivingMQTT(char* topicOri, char* datacallback) {
15141514
# ifdef ZactuatorPWM
15151515
MQTTtoPWM(topicOri, jsondata);
15161516
# endif
1517-
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
1517+
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
15181518
MQTTtoM5(topicOri, jsondata);
15191519
# endif
15201520
# ifdef ZactuatorONOFF // outside the jsonpublishing macro due to the fact that we need to use simplepublishing with HA discovery

platformio.ini

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extra_configs =
4444
;default_envs = esp32-m5stick-ble
4545
;default_envs = esp32-m5stack-ble
4646
;default_envs = esp32-m5stick-c-ble
47+
;default_envs = esp32-m5stick-cp-ble
4748
;default_envs = esp32-m5atom
4849
;default_envs = ttgo-lora32-v1
4950
;default_envs = nodemcuv2-rf
@@ -104,6 +105,7 @@ fastled = FastLED@3.3.2
104105
onewire = OneWire
105106
dallastemperature = DallasTemperature
106107
m5stickc = M5StickC@0.2.0
108+
m5stickcp = https://github.com/m5stack/M5StickC-Plus.git
107109
m5stack = M5Stack@0.3.0
108110
smartrc-cc1101-driver-lib = SmartRC-CC1101-Driver-Lib@2.3.5
109111
stl = https://github.com/mike-matera/ArduinoSTL.git#7411816
@@ -405,6 +407,32 @@ build_flags =
405407
'-DGateway_Name="OpenMQTTGateway_ESP32_M5STICK_C_BLE_IR"'
406408
board_upload.speed = 1500000
407409

410+
[env:esp32-m5stick-cp-ble]
411+
platform = ${com.esp32_platform}
412+
board = pico32
413+
board_build.partitions = min_spiffs.csv
414+
lib_deps =
415+
${com-esp.lib_deps}
416+
${libraries.ble}
417+
${libraries.m5stickcp}
418+
${libraries.irremoteesp}
419+
build_flags =
420+
${com-esp.build_flags}
421+
'-DZgatewayBT="BT"'
422+
'-DZgatewayIR="IR"'
423+
'-DZsensorGPIOInput="GPIOInput"'
424+
'-DZboardM5STICKCP="M5StickCP"'
425+
'-DACTUATOR_ONOFF_GPIO=10'
426+
'-DINPUT_GPIO=37'
427+
'-DLED_RECEIVE=10'
428+
'-DLED_RECEIVE_ON=0'
429+
'-DSLEEP_BUTTON=39'
430+
'-DTRIGGER_GPIO=39'
431+
'-DIR_EMITTER_INVERTED=true'
432+
'-DIR_EMITTER_GPIO=9'
433+
'-DGateway_Name="OpenMQTTGateway_ESP32_M5STICK_CP_BLE_IR"'
434+
board_upload.speed = 1500000
435+
408436
[env:esp32-m5atom]
409437
platform = ${com.esp32_platform}
410438
board = pico32

0 commit comments

Comments
 (0)