Skip to content

Commit d4173f7

Browse files
committed
init
1 parent f072c27 commit d4173f7

14 files changed

Lines changed: 1272 additions & 39 deletions

File tree

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ body:
7676
label: Issue checklist
7777
description: Please double-check that you have done each of the following things before submitting the issue.
7878
options:
79-
- label: I searched for previous reports in [the issue tracker](https://github.com/m5stack/M5Stack/issues?q=)
79+
- label: I searched for previous reports in [the issue tracker](https://github.com/m5stack/M5Module-QRCode/issues?q=)
8080
required: true
8181
- label: My report contains all necessary details
8282
required: true

README.md

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,15 @@
1-
# Product Name
1+
# Module-QRCode
22

33
## Overview
44

5-
### SKU:xxx
5+
### SKU:M145
66

7-
Description of the product
7+
**Module13.2 QRCode** is a 1D / 2D barcode scanning module in the M5Stack stackable module series. It integrates a 640 x 480 resolution CMOS barcode capture engine and supports three mainstream 2D barcode types and eight 1D barcode types on the market, enabling fast and accurate recognition of barcode information on media such as printouts and labels. By toggling the switch, you can switch between USB and UART communication interfaces for the QR module, allowing external devices to communicate with it. The USB interface can be configured as a USB virtual serial port, USB HID keyboard, or USB HID-POS. The module features a built-in buzzer for audio prompts, illumination and aiming LEDs, and provides rich secondary-development interfaces. It supports multiple scan trigger modes (such as auto mode, continuous mode, motion-sensing mode, pulse mode, etc.) for functional customization and integrated development. The module includes a DC power input port that supports DC 9 ~ 24V input. An internal DC-DC buck circuit supplies power to the entire device, making it suitable for logistics warehousing, retail POS, ticketing systems, production traceability, medical information collection, self-service terminals, and other scenarios.
88

99
## Related Link
1010

11-
- [Document & Datasheet](https://docs.m5stack.com/en/unit/product_Link)
12-
13-
## Required Libraries:
14-
15-
- [Adafruit_BMP280_Library](https://github.com/adafruit/Required_Libraries_Link)
16-
17-
## License
18-
19-
- [Product Name- MIT](LICENSE)
20-
21-
## Remaining steps(Editorial Staff Look,After following the steps, remember to delete all the content below)
22-
23-
1. Change [clang format check path](./.github/workflows/clang-format-check.yml#L42-L47).
24-
2. Add License content to [LICENSE](/LICENSE).
25-
3. Change link on line 78 of [bug-report.yml](./.github/ISSUE_TEMPLATE/bug-report.yml#L79).
26-
27-
```cpp
28-
Example
29-
# M5Unit-ENV
30-
31-
## Overview
32-
33-
### SKU:U001 & U001-B & U001-C
34-
35-
Contains M5Stack-**UNIT ENV** series related case programs.ENV is an environmental sensor with integrated SHT30 and QMP6988 internally to detect temperature, humidity, and atmospheric pressure data.
36-
37-
## Related Link
38-
39-
- [Document & Datasheet](https://docs.m5stack.com/en/unit/envIII)
40-
41-
## Required Libraries:
42-
43-
- [Adafruit_BMP280_Library](https://github.com/adafruit/Adafruit_BMP280_Library)
11+
- [Document & Datasheet](https://docs.m5stack.com/en/products/sku/M145)
4412

4513
## License
4614

47-
- [M5Unit-ENV - MIT](LICENSE)
48-
```
15+
- [Module-QRCode- MIT](LICENSE)

examples/AutoMode/AutoMode.ino

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
#include <Arduino.h>
7+
#include <M5Unified.h>
8+
#include <M5ModuleQRCode.h>
9+
10+
M5ModuleQRCode module_qrcode;
11+
12+
void setup()
13+
{
14+
M5.begin();
15+
M5.Display.setFont(&fonts::efontCN_16);
16+
M5.Display.setTextScroll(true);
17+
18+
/* Set module config */
19+
auto cfg = module_qrcode.getConfig();
20+
cfg.pin_tx = 17;
21+
cfg.pin_rx = 16;
22+
cfg.baudrate = 115200;
23+
cfg.serial = &Serial1;
24+
module_qrcode.setConfig(cfg);
25+
26+
/* Init module */
27+
while (!module_qrcode.begin()) {
28+
M5.Display.setTextColor(TFT_RED);
29+
M5.Display.println(">> Init module failed, retry...");
30+
delay(1000);
31+
}
32+
M5.Display.setTextColor(TFT_WHITE);
33+
M5.Display.println(">> Init module success");
34+
35+
/* Set trigger mode */
36+
M5.Display.println(">> Set trigger mode to auto");
37+
module_qrcode.setTriggerMode(QRCodeM14::TRIGGER_MODE_AUTO);
38+
39+
M5.Display.println(">> You can scan QR code now");
40+
}
41+
42+
void loop()
43+
{
44+
M5.update();
45+
46+
/* Update module */
47+
module_qrcode.update();
48+
49+
/* If scan result available */
50+
if (module_qrcode.available()) {
51+
auto result = module_qrcode.getScanResult();
52+
53+
/* Display result */
54+
M5.Display.setTextColor(TFT_WHITE);
55+
M5.Display.println(">> Get code:");
56+
M5.Display.setTextColor(TFT_YELLOW);
57+
M5.Display.println(result.c_str());
58+
}
59+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
#include <Arduino.h>
7+
#include <M5Unified.h>
8+
#include <M5ModuleQRCode.h>
9+
10+
M5ModuleQRCode module_qrcode;
11+
12+
void setup()
13+
{
14+
M5.begin();
15+
M5.Display.setFont(&fonts::efontCN_16);
16+
M5.Display.setTextScroll(true);
17+
18+
/* Set module config */
19+
auto cfg = module_qrcode.getConfig();
20+
cfg.pin_tx = 17;
21+
cfg.pin_rx = 16;
22+
cfg.baudrate = 115200;
23+
cfg.serial = &Serial1;
24+
module_qrcode.setConfig(cfg);
25+
26+
/* Init module */
27+
while (!module_qrcode.begin()) {
28+
M5.Display.setTextColor(TFT_RED);
29+
M5.Display.println(">> Init module failed, retry...");
30+
delay(1000);
31+
}
32+
M5.Display.setTextColor(TFT_WHITE);
33+
M5.Display.println(">> Init module success");
34+
35+
/* Set light mode */
36+
M5.Display.println(">> Set lights mode");
37+
module_qrcode.setFillLightMode(QRCodeM14::FILL_LIGHT_ON_DECODE);
38+
module_qrcode.setPosLightMode(QRCodeM14::POS_LIGHT_ON_DECODE);
39+
40+
/* Set trigger mode */
41+
M5.Display.println(">> Set trigger mode to continuous");
42+
module_qrcode.setTriggerMode(QRCodeM14::TRIGGER_MODE_CONTINUOUS);
43+
module_qrcode.stopDecode();
44+
45+
M5.Display.println(">> Click BtnA to toggle scanning");
46+
}
47+
48+
void loop()
49+
{
50+
M5.update();
51+
52+
static bool is_scanning = false;
53+
54+
/* If BtnA was clicked */
55+
if (M5.BtnA.wasClicked()) {
56+
is_scanning = !is_scanning;
57+
58+
if (is_scanning) {
59+
module_qrcode.startDecode();
60+
} else {
61+
module_qrcode.stopDecode();
62+
}
63+
64+
M5.Display.setTextColor(TFT_WHITE);
65+
M5.Display.println(is_scanning ? ">> Start scanning..." : ">> Stop scanning");
66+
}
67+
68+
/* Update module */
69+
module_qrcode.update();
70+
71+
/* If scan result available */
72+
if (module_qrcode.available()) {
73+
auto result = module_qrcode.getScanResult();
74+
75+
/* Display result */
76+
M5.Display.setTextColor(TFT_WHITE);
77+
M5.Display.println(">> Get code:");
78+
M5.Display.setTextColor(TFT_YELLOW);
79+
M5.Display.println(result.c_str());
80+
}
81+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
#include <Arduino.h>
7+
#include <M5Unified.h>
8+
#include <M5ModuleQRCode.h>
9+
10+
M5ModuleQRCode module_qrcode;
11+
12+
void setup()
13+
{
14+
M5.begin();
15+
M5.Display.setFont(&fonts::efontCN_16);
16+
M5.Display.setTextScroll(true);
17+
18+
/* Set module config */
19+
auto cfg = module_qrcode.getConfig();
20+
cfg.pin_tx = 17;
21+
cfg.pin_rx = 16;
22+
cfg.baudrate = 115200;
23+
cfg.serial = &Serial1;
24+
module_qrcode.setConfig(cfg);
25+
26+
/* Init module */
27+
while (!module_qrcode.begin()) {
28+
M5.Display.setTextColor(TFT_RED);
29+
M5.Display.println(">> Init module failed, retry...");
30+
delay(1000);
31+
}
32+
M5.Display.setTextColor(TFT_WHITE);
33+
M5.Display.println(">> Init module success");
34+
35+
/* Set trigger mode */
36+
M5.Display.println(">> Set trigger mode to motion sensing");
37+
module_qrcode.setTriggerMode(QRCodeM14::TRIGGER_MODE_MOTION_SENSING);
38+
module_qrcode.setMotionSensitivity(1);
39+
40+
/* Set light mode */
41+
M5.Display.println(">> Set lights mode");
42+
module_qrcode.setFillLightMode(QRCodeM14::FILL_LIGHT_ON_DECODE);
43+
module_qrcode.setPosLightMode(QRCodeM14::POS_LIGHT_FLASH_ON_DECODE);
44+
45+
M5.Display.println(">> You can scan QR code now");
46+
}
47+
48+
void loop()
49+
{
50+
M5.update();
51+
52+
/* Update module */
53+
module_qrcode.update();
54+
55+
/* If scan result available */
56+
if (module_qrcode.available()) {
57+
auto result = module_qrcode.getScanResult();
58+
59+
/* Display result */
60+
M5.Display.setTextColor(TFT_WHITE);
61+
M5.Display.println(">> Get code:");
62+
M5.Display.setTextColor(TFT_YELLOW);
63+
M5.Display.println(result.c_str());
64+
}
65+
}

examples/PulseMode/PulseMode.ino

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
#include <Arduino.h>
7+
#include <M5Unified.h>
8+
#include <M5ModuleQRCode.h>
9+
10+
M5ModuleQRCode module_qrcode;
11+
12+
void setup()
13+
{
14+
M5.begin();
15+
M5.Display.setFont(&fonts::efontCN_16);
16+
M5.Display.setTextScroll(true);
17+
18+
/* Set module config */
19+
auto cfg = module_qrcode.getConfig();
20+
cfg.pin_tx = 17;
21+
cfg.pin_rx = 16;
22+
cfg.baudrate = 115200;
23+
cfg.serial = &Serial1;
24+
module_qrcode.setConfig(cfg);
25+
26+
/* Init module */
27+
while (!module_qrcode.begin()) {
28+
M5.Display.setTextColor(TFT_RED);
29+
M5.Display.println(">> Init module failed, retry...");
30+
delay(1000);
31+
}
32+
M5.Display.setTextColor(TFT_WHITE);
33+
M5.Display.println(">> Init module success");
34+
35+
/* Set light mode */
36+
M5.Display.println(">> Set lights mode");
37+
module_qrcode.setFillLightMode(QRCodeM14::FILL_LIGHT_ON_DECODE);
38+
module_qrcode.setPosLightMode(QRCodeM14::POS_LIGHT_ON_DECODE);
39+
40+
/* Set trigger mode */
41+
M5.Display.println(">> Set trigger mode to pulse");
42+
module_qrcode.setTriggerMode(QRCodeM14::TRIGGER_MODE_PULSE);
43+
44+
M5.Display.println(">> Click BtnA to start a scan");
45+
}
46+
47+
void loop()
48+
{
49+
M5.update();
50+
51+
/* If BtnA was clicked */
52+
if (M5.BtnA.wasClicked()) {
53+
/* Trigger a scan */
54+
module_qrcode.setTriggerLevel(false);
55+
delay(20);
56+
module_qrcode.setTriggerLevel(true);
57+
58+
M5.Display.setTextColor(TFT_WHITE);
59+
M5.Display.println(">> Start scanning...");
60+
}
61+
62+
/* Update module */
63+
module_qrcode.update();
64+
65+
/* If scan result available */
66+
if (module_qrcode.available()) {
67+
auto result = module_qrcode.getScanResult();
68+
69+
/* Display result */
70+
M5.Display.setTextColor(TFT_WHITE);
71+
M5.Display.println(">> Get code:");
72+
M5.Display.setTextColor(TFT_YELLOW);
73+
M5.Display.println(result.c_str());
74+
}
75+
}

0 commit comments

Comments
 (0)