Skip to content

Commit b402122

Browse files
authored
Merge pull request #260 from Tinyu-Zhao/master
Add some examples
2 parents 3dd0200 + 0465519 commit b402122

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1985
-4426
lines changed

examples/Advanced/WIFI/WiFiSetting/WiFiSetting.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void setup() {
5757
void loop() {
5858
if (settingMode) {
5959
}
60-
webServer.handleClient(); //检查有没有设备通过网络向M5Stack网络服务器发送请求
60+
webServer.handleClient(); //Check that there is no facility to send requests to the M5StickC Web server over the network. 检查有没有设备通过网络向M5Stack网络服务器发送请求
6161
}
6262

6363
boolean restoreConfig() { /* Check whether there is wifi configuration information storage, if there is 1 return, if no return 0.

examples/Modules/AC-SOCKET/AC-SOCKET.ino

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
/*
2-
Description:Click button B to turn on the power. Click button A to turn off the power.
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/products
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/products
8+
*
9+
* describe: AC Socket.
10+
* date:2021/9/1
11+
*******************************************************************************
12+
Click button B to turn on the power. Click button A to turn off the power.
13+
单击按钮 B 打开电源。 单击按钮 A 关闭电源。
314
*/
415
#include <Arduino.h>
516
#include <M5Stack.h>

examples/Modules/COM_GPS/COM_GPS.ino

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
/*
2-
Description: Use COM.GPS Module to get the coordinate data and time of the current location.
3-
Please install library before compiling:
4-
TinyGPSPlus: file in M5stack lib examples -> modules -> GPS -> TinyGPSPlus-1.0.2.zip (unzip the lib zip file to the Arduino Lib path)
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core2示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/module/comx_gps
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/module/comx_gps
8+
*
9+
* describe: comx_gps.
10+
* date:2021/9/2
11+
*******************************************************************************
12+
Use COM.GPS Module to get the coordinate data and time of the current location.
13+
使用 COM.GPS 模块获取当前位置的坐标数据和时间。
514
*/
615

716
#include <M5Stack.h>

examples/Modules/COM_GSM/COM_GSM.ino

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
/*
2-
Description: screen will display the signal strength and network access status
3-
Note: Set the DIP switch to 5 and 13.
4-
*/
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core2 sample source code
5+
* 配套 M5Core2 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/module/comx_gsm
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/module/comx_gsm
8+
*
9+
* describe: comx_gsm.
10+
* date:2021/9/2
11+
*******************************************************************************
12+
Set the DIP switch to 5 and 13
13+
and the screen will display the signal strength and network access status
14+
将 DIP 开关设置为 5 和 13
15+
并且屏幕会显示信号强度和网络访问状态
16+
*/
517

618
#include <M5Stack.h>
719
#include <stdint.h>

examples/Modules/COM_LTE-DATA/COM_LTE-DATA.ino

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
/*
2-
Description: screen will display the signal strength and network access status
3-
Note: Set the DIP switch to 5 and 13.
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/module/comx_lte-data
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/module/comx_lte-data
8+
*
9+
* describe: comx_lte-data.
10+
* date:2021/9/2
11+
*******************************************************************************
12+
Set the DIP switch to 5 and 13 and the screen will display the signal strength and network access status
13+
press buttonA to dial phonenumber, ATD00000000000 is phone number, you can change
14+
将 DIP 开关设置为 5 和 13 并且屏幕会显示信号强度和网络访问状态
15+
按按钮A拨打电话号码,ATD00000000000 是电话号码,您可以更改
416
*/
5-
617
#include <M5Stack.h>
718
#include <stdint.h>
819
#include <vector>

examples/Modules/COM_LTE/COM_LTE.ino

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
/*
2-
Description: screen will display the signal strength and network access status
3-
press buttonA to dial phonenumber.
4-
ATD13800088888 is phone number, you can change
5-
Note: Set the DIP switch to 5 and 13.
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/module/comx_lte
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/module/comx_lte
8+
*
9+
* describe: comx_lte.
10+
* date:2021/9/2
11+
*******************************************************************************
12+
Set the DIP switch to 5 and 13 and the screen will display the signal strength and network access status
13+
press buttonA to dial phonenumber, ATD00000000000 is phone number, you can change
14+
将 DIP 开关设置为 5 和 13 并且屏幕会显示信号强度和网络访问状态
15+
按按钮A拨打电话号码,ATD00000000000 是电话号码,您可以更改
616
*/
717

8-
918
#include <M5Stack.h>
1019
#include <stdint.h>
1120
#include <vector>

examples/Modules/GRBL13.2/multi_control/multi_control.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ void setup() {
1919
// put your setup code here, to run once:
2020
M5.begin();
2121
M5.Power.begin();
22-
_GRBL_A.Init();
23-
_GRBL_B.Init();
22+
Wire.begin(21, 22);
23+
_GRBL_A.Init(&Wire);
24+
_GRBL_B.Init(&Wire);
2425
Serial.begin(115200);
2526
m5.Lcd.setTextColor(WHITE, BLACK);
2627
m5.Lcd.setTextSize(3);

examples/Modules/GRBL13.2/xyz_control/xyz_control.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ void setup() {
1818
// put your setup code here, to run once:
1919
M5.begin();
2020
M5.Power.begin();
21-
_GRBL.Init();
21+
Wire.begin(21, 22);
22+
_GRBL.Init(&Wire);
2223
Serial.begin(115200);
2324
m5.Lcd.setTextColor(WHITE, BLACK);
2425
m5.Lcd.setTextSize(3);

examples/Modules/LORA868_SX1276/LoRa868Duplex/LoRa868Duplex.ino

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,61 @@
11
/*
2-
Description: LoRa868 Duplex communication.Send messages regularly "HeLoRa World!"
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/module/comx_lorawan
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/module/comx_lorawan
8+
*
9+
* describe: comx_lorawan.
10+
* date:2021/9/2
11+
*******************************************************************************
12+
LoRa868 Duplex communication.Send messages regularly "HeLoRa World!"
13+
LoRa868 双工通讯。定期发送消息“HeLoRa World!”
14+
315
*/
416
#include <M5Stack.h>
517
#include <M5LoRa.h>
618

7-
String outgoing; // outgoing message
19+
String outgoing; // outgoing message. 传出讯息
820

9-
byte msgCount = 0; // count of outgoing messages
10-
byte localAddress = 0xFF; // address of this device
11-
byte destination = 0xBB; // destination to send to
21+
byte msgCount = 0; // count of outgoing messages. 传出消息的计数
22+
byte localAddress = 0xFF; // address of this device. 此设备的地址
23+
byte destination = 0xBB; // destination to send to. 发送目的地
1224

13-
long lastSendTime = 0; // last send time
14-
int interval = 1000; // interval between sends
25+
long lastSendTime = 0; // last send time. 上次发送时间
26+
int interval = 1000; // interval between sends. 发送间隔
1527

1628
void setup() {
1729
M5.begin();
1830
M5.Power.begin();
31+
1932
while (!Serial);
2033

2134
Serial.println("LoRa Duplex B");
2235

23-
// override the default CS, reset, and IRQ pins (optional)
24-
LoRa.setPins();// set CS, reset, IRQ pin
36+
// override the default CS, reset, and IRQ pins (optional). 覆盖默认的 CS、复位和 IRQ 引脚(可选)
37+
LoRa.setPins();// set CS, reset, IRQ pin. 设置 CS、复位、IRQ 引脚
2538

26-
if (!LoRa.begin(868E6)) { // initialize ratio at 868 MHz
39+
if (!LoRa.begin(868E6)) { // initialize ratio at 868 MHz. 868 MHz 时的初始化比率
2740
Serial.println("LoRa init failed. Check your connections.");
28-
while (true); // if failed, do nothing
41+
while (true); // if failed, do nothing. 如果失败,什么都不做
2942
}
3043

3144
Serial.println("LoRa init succeeded.");
3245
}
3346

3447
void loop() {
3548
if (millis() - lastSendTime > interval) {
36-
String message = "HeLoRa World!"; // send a message
49+
String message = "HeLoRa World!"; // send a message. 发送消息
3750
sendMessage(message);
3851
Serial.println("Sending " + message);
3952
M5.Lcd.setTextColor(BLUE);
4053
M5.Lcd.println("Sending " + message);
41-
lastSendTime = millis(); // timestamp the message
54+
lastSendTime = millis(); // timestamp the message. 给消息加时间戳
4255
interval = random(1000) + 500;
4356
}
4457

45-
// parse for a packet, and call onReceive with the result:
58+
// parse for a packet, and call onReceive with the result:. 解析数据包,并使用结果调用 onReceive:
4659
onReceive(LoRa.parsePacket());
4760

4861
if(M5.BtnA.wasPressed()){
@@ -60,58 +73,58 @@ void loop() {
6073
void reinit(){
6174
Serial.println("LoRa Duplex Reinitialization");
6275

63-
// override the default CS, reset, and IRQ pins (optional)
64-
LoRa.setPins();// set CS, reset, IRQ pin
76+
// override the default CS, reset, and IRQ pins (optional). 覆盖默认的 CS、复位和 IRQ 引脚(可选)
77+
LoRa.setPins();// set CS, reset, IRQ pin. 设置 CS、复位、IRQ 引脚
6578

66-
if (!LoRa.begin(868E6)) { // initialize ratio at 868 MHz
79+
if (!LoRa.begin(868E6)) { // initialize ratio at 868 MHz. 868 MHz 时的初始化比率
6780
Serial.println("LoRa init failed. Check your connections.");
6881
M5.Lcd.setCursor(0, 0);
6982
M5.Lcd.setTextColor(RED);
7083
M5.Lcd.println("Init failed!!!");
71-
while (true); // if failed, do nothing
84+
while (true); // if failed, do nothing. 如果失败,什么都不做
7285
}
7386

7487
Serial.println("LoRa init succeeded.");
7588
}
7689

7790
void sendMessage(String outgoing) {
78-
LoRa.beginPacket(); // start packet
79-
LoRa.write(destination); // add destination address
80-
LoRa.write(localAddress); // add sender address
81-
LoRa.write(msgCount); // add message ID
82-
LoRa.write(outgoing.length()); // add payload length
83-
LoRa.print(outgoing); // add payload
84-
LoRa.endPacket(); // finish packet and send it
85-
msgCount++; // increment message ID
91+
LoRa.beginPacket(); // start packet. 开始包
92+
LoRa.write(destination); // add destination address. 添加目标地址
93+
LoRa.write(localAddress); // add sender address. 添加发件人地址
94+
LoRa.write(msgCount); // add message ID. 添加消息标识
95+
LoRa.write(outgoing.length()); // add payload length. 添加有效载荷长度
96+
LoRa.print(outgoing); // add payload. 添加有效载荷
97+
LoRa.endPacket(); // finish packet and send it. 完成数据包并发送
98+
msgCount++; // increment message ID. 增加消息 ID
8699
}
87100

88101
void onReceive(int packetSize) {
89-
if (packetSize == 0) return; // if there's no packet, return
102+
if (packetSize == 0) return; // if there's no packet, return. 如果没有包,返回。
90103

91104
// read packet header bytes:
92-
int recipient = LoRa.read(); // recipient address
93-
byte sender = LoRa.read(); // sender address
94-
byte incomingMsgId = LoRa.read(); // incoming msg ID
95-
byte incomingLength = LoRa.read(); // incoming msg length
105+
int recipient = LoRa.read(); // recipient address. 收件人地址。
106+
byte sender = LoRa.read(); // sender address. 发件人地址。
107+
byte incomingMsgId = LoRa.read(); // incoming msg ID. 传入的消息 ID。
108+
byte incomingLength = LoRa.read(); // incoming msg length. 传入消息长度。
96109

97110
String incoming = "";
98111

99112
while (LoRa.available()) {
100113
incoming += (char)LoRa.read();
101114
}
102115

103-
if (incomingLength != incoming.length()) { // check length for error
116+
if (incomingLength != incoming.length()) { // check length for error. 检查错误长度
104117
Serial.println("error: message length does not match length");
105-
return; // skip rest of function
118+
return; // skip rest of function. 跳过其余功能
106119
}
107120

108-
// if the recipient isn't this device or broadcast,
121+
// if the recipient isn't this device or broadcast,. 如果收件人不是此设备或广播,
109122
if (recipient != localAddress && recipient != 0xFF) {
110123
Serial.println("This message is not for me.");
111-
return; // skip rest of function
124+
return; // skip rest of function. 跳过其余功能
112125
}
113126

114-
// if message is for this device, or broadcast, print details:
127+
// if message is for this device, or broadcast, print details:. 如果消息是针对此设备或广播的,则打印详细信息:
115128
Serial.println("Received from: 0x" + String(sender, HEX));
116129
Serial.println("Sent to: 0x" + String(recipient, HEX));
117130
Serial.println("Message ID: " + String(incomingMsgId));

examples/Modules/NB-IoT_M5311LV/NB-IoT_M5311LV.ino

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
/*
2-
Description: Use NB-IoT Module to send data to MQTT server.
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/module/nb-iot
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/module/nb-iot
8+
*
9+
* describe: NB-IoT.
10+
* date:2021/9/1
11+
*******************************************************************************
12+
Use NB-IoT Module to send data to MQTT server.
13+
使用 NB-IoT 模块将数据发送到 MQTT 服务器。
314
*/
15+
416
#include <M5Stack.h>
517
#include <stdint.h>
618
#include <vector>

examples/Modules/PLUS/PLUS.ino

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
/*
2-
Description: This exmpale can display the encoder gear reading of the PLUS Module and the state of the keys.
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/en/module/plus
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/module/plus
8+
*
9+
* describe: PLUS.
10+
* date:2021/9/2
11+
*******************************************************************************
12+
This exmpale can display the encoder gear reading of the PLUS Module and the state of the keys.
13+
本例可以显示PLUS模块的编码器齿轮读数和按键状态。
314
*/
415
#include <Arduino.h>
516
#include <M5Stack.h>

0 commit comments

Comments
 (0)