Skip to content

Commit f7a43b2

Browse files
committed
update lib depend and add dlight example
2 parents ac1dea3 + ba372f3 commit f7a43b2

File tree

6 files changed

+153
-8
lines changed

6 files changed

+153
-8
lines changed

examples/Advanced/Display/Display_Unicode/Display_Unicode.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
-----PLEASE SEE THE README----
1414
------请在使用前看README文件----*/
15+
#define USE_M5_FONT_CREATOR
1516
#include <M5Stack.h>
1617
#include "CUF_24px.h"
1718

examples/Modules/LORA868_SX1276/LoRa868Duplex/LoRa868Duplex.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* Copyright (c) 2021 by M5Stack
44
* Equipped with M5Core sample source code
55
* 配套 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
6+
* Visit the website for more information:https://docs.m5stack.com/en/module/lora868
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/module/lora868
88
*
9-
* describe: comx_lorawan.
10-
* date:2021/9/2
9+
* describe: Module LoRa868.
10+
* date:2021/12/26
1111
*******************************************************************************
1212
LoRa868 Duplex communication.Send messages regularly "HeLoRa World!"
1313
LoRa868 双工通讯。定期发送消息“HeLoRa World!”
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more
7+
information:https://docs.m5stack.com/en/unit/nbiot_global
8+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/unit/nbiot_global
9+
*
10+
* describe:NBIoT UNIT.
11+
* date:2022/01/04
12+
* Dependent library download:
13+
* TinyGSM:
14+
https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/lib/TinyGSM.zip
15+
*******************************************************************************
16+
Connect NBIoT UNIT to PORT C port (G16/17), connect to MQTT server for data
17+
sending and receiving test. Before compiling, please install and visit the link
18+
above to download the TinyGSM dependency library. 将NBIoT UNIT连接到PORT
19+
C端口(G16/17),
20+
连接MQTT服务器进行数据收发测试。编译前,请安装访问上方链接,下载TinyGSM依赖库。
21+
*/
22+
23+
#include "M5Stack.h"
24+
#include "M5GFX.h"
25+
26+
27+
#define TINY_GSM_MODEM_SIM7020
28+
29+
#include <PubSubClient.h>
30+
#include <TinyGsmClient.h>
31+
#include <sys/time.h>
32+
#include <time.h>
33+
34+
35+
#define SerialAT Serial1
36+
#define SIM7020_BAUDRATE 115200
37+
38+
#define UNIT_SIM7020_TX 17
39+
#define UNIT_SIM7020_RX 16
40+
41+
#define MQTT_BROKER "mqtt.m5stack.com"
42+
#define MQTT_PORT 1883
43+
#define MQTT_USERNAME "UNIT_NBIoT_USER_NAME"
44+
#define MQTT_PASSWORD "UNIT_NBIoT_PASSWORD"
45+
#define MQTT_SYNC_TIME_D_TOPIC "UNIT_NBIoT/D"
46+
#define MQTT_SYNC_TIME_U_TOPIC "UNIT_NBIoT/U"
47+
48+
#define UPLOAD_INTERVAL 10000
49+
50+
TinyGsm modem(SerialAT, -1);
51+
52+
TinyGsmClient tcpClient(modem);
53+
PubSubClient mqttClient(MQTT_BROKER, MQTT_PORT, tcpClient);
54+
55+
void mqttCallback(char *topic, byte *payload, unsigned int len);
56+
void mqttConnect(void);
57+
void nbConnect(void);
58+
59+
struct tm now;
60+
char s_time[50];
61+
62+
M5GFX display;
63+
M5Canvas canvas(&display);
64+
65+
void log(String info) {
66+
canvas.println(info);
67+
canvas.pushSprite(0, 0);
68+
Serial.println(info);
69+
}
70+
71+
void setup() {
72+
M5.begin();
73+
display.begin();
74+
canvas.setColorDepth(1); // mono color
75+
canvas.setFont(&fonts::efontCN_14);
76+
canvas.createSprite(display.width(), display.height());
77+
canvas.setTextSize(2);
78+
canvas.setPaletteColor(1, GREEN);
79+
canvas.setTextScroll(true);
80+
canvas.println(">>UNIT NBIoT");
81+
canvas.println(">>MQTT TEST");
82+
canvas.pushSprite(0, 0);
83+
SerialAT.begin(SIM7020_BAUDRATE, SERIAL_8N1, UNIT_SIM7020_RX,
84+
UNIT_SIM7020_TX);
85+
nbConnect();
86+
mqttClient.setBufferSize(4096);
87+
mqttClient.setCallback(mqttCallback);
88+
mqttClient.setKeepAlive(300);
89+
}
90+
91+
void loop() {
92+
static unsigned long timer = 0;
93+
94+
if (!mqttClient.connected()) {
95+
if (!modem.isNetworkConnected()) {
96+
nbConnect();
97+
}
98+
log(">>MQTT NOT CONNECTED");
99+
mqttConnect();
100+
}
101+
102+
if (millis() >= timer) {
103+
timer = millis() + UPLOAD_INTERVAL;
104+
mqttClient.publish(MQTT_SYNC_TIME_U_TOPIC, "hello"); // 发送数据
105+
}
106+
107+
mqttClient.loop();
108+
}
109+
110+
void mqttCallback(char *topic, byte *payload, unsigned int len) {
111+
log("Message arrived [" + String(topic) + "]: ");
112+
String payload_str = String((char *)payload);
113+
log(payload_str);
114+
}
115+
116+
void mqttConnect(void) {
117+
log("Connecting to " + String(MQTT_BROKER) + "...");
118+
119+
// Connect to MQTT Broker
120+
String mqttid = ("MQTTID_" + String(random(65536)));
121+
while (!mqttClient.connect(mqttid.c_str(), MQTT_USERNAME, MQTT_PASSWORD)) {
122+
log(" fail");
123+
}
124+
log(" success");
125+
mqttClient.subscribe(MQTT_SYNC_TIME_D_TOPIC);
126+
while (!mqttClient.publish(MQTT_SYNC_TIME_U_TOPIC, "Device Online")) {
127+
delay(1000);
128+
}
129+
}
130+
131+
void nbConnect(void) {
132+
unsigned long start = millis();
133+
log("Initializing modem...");
134+
while (!modem.init()) {
135+
log("waiting...." + String((millis() - start) / 1000) + "s");
136+
};
137+
138+
start = millis();
139+
log("Waiting for network...");
140+
while (!modem.waitForNetwork()) {
141+
log("waiting...." + String((millis() - start) / 1000) + "s");
142+
}
143+
log("success");
144+
}

library.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"url": "https://github.com/m5stack/m5stack.git"
1212
},
1313
"version": "0.3.9",
14-
"framework": "arduino",
15-
"platforms": "espressif32"
14+
"frameworks": "arduino",
15+
"platforms": "espressif32",
16+
"headers": "M5Stack.h"
1617
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ category=Device Control
88
url=https://github.com/m5stack/m5stack
99
architectures=esp32
1010
includes=M5Stack.h
11-
depends=M5GFX,ESP32CAN,UNIT_ENV,UNIT_4RELAY,ADXL345,FastLED,MODULE_GRBL13.2,Adafruit MCP4725,Adafruit TCS34725,Adafruit NeoPixel,MAX30100lib,MFRC522_I2C,M5_BM8563,M5_ADS1100,M5_ADS1115,M5_FPC1020A,HX711 Arduino Library,PCA9554,TinyGPSPlus,Adafruit SGP30 Sensor,FFT,TFTTerminal,ClosedCube TCA9548A,M5GFX,ArduinoJson,M5_EzData,PubSubClient,UNIT_SONIC,PoE_CAM,M5_BH1750FVI
11+
depends=M5GFX,ESP32CAN,UNIT_ENV,UNIT_4RELAY,ADXL345,FastLED,MODULE_GRBL13.2,Adafruit MCP4725,Adafruit TCS34725,Adafruit NeoPixel,MAX30100lib,MFRC522_I2C,M5_BM8563,M5_ADS1100,M5_ADS1115,M5_FPC1020A,HX711 Arduino Library,PCA9554,TinyGPSPlus,Adafruit SGP30 Sensor,FFT,TFTTerminal,ClosedCube TCA9548A,M5GFX,ArduinoJson,M5_EzData,PubSubClient,UNIT_SONIC,PoE_CAM,M5_RoverC,UNIT_UHF_RFID,M5_JoyC,M5_BH1750FVI
1212

src/utility/In_eSPI.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4304,7 +4304,6 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y)
43044304
}
43054305

43064306
// Any UTF-8 decoding must be done before calling drawChar()
4307-
static uint32_t char_count = 0;
43084307
int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font)
43094308
{
43104309
if (!uniCode) return 0;

0 commit comments

Comments
 (0)