Skip to content

Commit cd12f67

Browse files
committed
init
1 parent 57bbda9 commit cd12f67

59 files changed

Lines changed: 6241 additions & 10 deletions

Some content is hidden

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

.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/StackChan-BSP/issues?q=)
8080
required: true
8181
- label: My report contains all necessary details
8282
required: true

.github/workflows/clang-format-check.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ jobs:
3939
strategy:
4040
matrix:
4141
path:
42-
- check: './' # path to include
43-
exclude: '' # path to exclude
44-
#- check: 'src'
45-
# exclude: '(Fonts)' # Exclude file paths containing "Fonts"
46-
#- check: 'examples'
47-
# exclude: ''
42+
# - check: './' # path to include
43+
# exclude: '' # path to exclude
44+
- check: 'src'
45+
exclude: 'src/(utils|drivers)'
46+
- check: 'examples'
47+
exclude: ''
4848

4949
steps:
5050
- name: Checkout

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Product Name
1+
# StackChan
22

33
## Overview
44

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

77
Description of the product
88

@@ -12,7 +12,9 @@ Description of the product
1212

1313
## Required Libraries:
1414

15-
- [Adafruit_BMP280_Library](https://github.com/adafruit/Required_Libraries_Link)
15+
- [M5Unified](https://github.com/m5stack/M5Unified)
16+
- [IRremoteESP8266](https://github.com/crankyoldgit/irremoteesp8266)
17+
- [M5Unit-NFC](https://github.com/m5stack/M5Unit-NFC)
1618

1719
## License
1820

examples/INA226/INA226.ino

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
#include <Arduino.h>
7+
#include <M5StackChan.h>
8+
9+
void setup()
10+
{
11+
/* Init StackChan */
12+
M5StackChan.begin();
13+
14+
/* Setup display */
15+
M5StackChan.Display().setTextSize(2);
16+
M5StackChan.Display().setTextColor(TFT_GREENYELLOW);
17+
M5StackChan.Display().setTextScroll(true);
18+
}
19+
20+
void loop()
21+
{
22+
/* Get battery info from INA226 */
23+
float voltage = M5StackChan.getBatteryVoltage();
24+
float current = M5StackChan.getBatteryCurrent() * 1000;
25+
26+
M5StackChan.Display().printf("> Bat: %0.2fV %0.2fmA\n", voltage, current);
27+
28+
delay(1000);
29+
}

examples/IR/Receive/Receive.ino

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
// More examples on: https://github.com/crankyoldgit/IRremoteESP8266/tree/master/examples
7+
#include <Arduino.h>
8+
#include <M5StackChan.h>
9+
#include <assert.h>
10+
#include <IRrecv.h>
11+
#include <IRremoteESP8266.h>
12+
#include <IRac.h>
13+
#include <IRtext.h>
14+
#include <IRutils.h>
15+
16+
const uint16_t kRecvPin = 10; // IR rx pin
17+
18+
const uint16_t kCaptureBufferSize = 1024;
19+
20+
#if DECODE_AC
21+
// Some A/C units have gaps in their protocols of ~40ms. e.g. Kelvinator
22+
// A value this large may swallow repeats of some protocols
23+
const uint8_t kTimeout = 50;
24+
#else // DECODE_AC
25+
// Suits most messages, while not swallowing many repeats.
26+
const uint8_t kTimeout = 15;
27+
#endif // DECODE_AC
28+
29+
const uint16_t kMinUnknownSize = 12;
30+
const uint8_t kTolerancePercentage = kTolerance; // kTolerance is normally 25%
31+
32+
IRrecv irrecv(kRecvPin, kCaptureBufferSize, kTimeout, true);
33+
decode_results results;
34+
35+
void setup()
36+
{
37+
M5StackChan.begin();
38+
USBSerial.begin(115200);
39+
40+
// Perform a low level sanity checks that the compiler performs bit field
41+
// packing as we expect and Endianness is as we expect.
42+
assert(irutils::lowLevelSanityCheck() == 0);
43+
44+
#if DECODE_HASH
45+
// Ignore messages with less than minimum on or off pulses.
46+
irrecv.setUnknownThreshold(kMinUnknownSize);
47+
#endif // DECODE_HASH
48+
irrecv.setTolerance(kTolerancePercentage); // Override the default tolerance.
49+
irrecv.enableIRIn(); // Start the receiver
50+
}
51+
52+
void loop()
53+
{
54+
// Check if the IR code has been received.
55+
if (irrecv.decode(&results)) {
56+
// Display a crude timestamp.
57+
uint32_t now = millis();
58+
USBSerial.printf(D_STR_TIMESTAMP " : %06u.%03u\n", now / 1000, now % 1000);
59+
// Check if we got an IR message that was to big for our capture buffer.
60+
if (results.overflow) USBSerial.printf(D_WARN_BUFFERFULL "\n", kCaptureBufferSize);
61+
// Display the library version the message was captured with.
62+
USBSerial.println(D_STR_LIBRARY " : v" _IRREMOTEESP8266_VERSION_STR "\n");
63+
// Display the tolerance percentage if it has been change from the default.
64+
if (kTolerancePercentage != kTolerance) USBSerial.printf(D_STR_TOLERANCE " : %d%%\n", kTolerancePercentage);
65+
// Display the basic output of what we found.
66+
USBSerial.print(resultToHumanReadableBasic(&results));
67+
// Display any extra A/C info if we have it.
68+
String description = IRAcUtils::resultAcToString(&results);
69+
if (description.length()) USBSerial.println(D_STR_MESGDESC ": " + description);
70+
yield(); // Feed the WDT as the text output can take a while to print.
71+
// Output the results as source code
72+
USBSerial.println(resultToSourceCode(&results));
73+
USBSerial.println(); // Blank line between entries
74+
yield(); // Feed the WDT (again)
75+
}
76+
delay(50);
77+
}

examples/IR/Send/Send.ino

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
// More examples on: https://github.com/crankyoldgit/IRremoteESP8266/tree/master/examples
7+
#include <Arduino.h>
8+
#include <M5StackChan.h>
9+
#include <IRremoteESP8266.h>
10+
#include <IRsend.h>
11+
12+
const uint16_t kIrLed = 5; // IR tx pin
13+
14+
IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message.
15+
16+
// Example of data captured by IRrecvDumpV2.ino
17+
uint16_t rawData[67] = {9000, 4500, 650, 550, 650, 1650, 600, 550, 650, 550, 600, 1650, 650, 550,
18+
600, 1650, 650, 1650, 650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 550,
19+
600, 1650, 650, 1650, 650, 550, 650, 550, 650, 1650, 650, 550, 650, 550,
20+
650, 550, 600, 550, 650, 550, 650, 550, 650, 1650, 600, 550, 650, 1650,
21+
650, 1650, 650, 1650, 650, 1650, 650, 1650, 650, 1650, 600};
22+
// Example Samsung A/C state captured from IRrecvDumpV2.ino
23+
uint8_t samsungState[kSamsungAcStateLength] = {0x02, 0x92, 0x0F, 0x00, 0x00, 0x00, 0xF0,
24+
0x01, 0xE2, 0xFE, 0x71, 0x40, 0x11, 0xF0};
25+
26+
void setup()
27+
{
28+
M5StackChan.begin();
29+
USBSerial.begin(115200);
30+
irsend.begin();
31+
}
32+
33+
void loop()
34+
{
35+
USBSerial.println("NEC");
36+
irsend.sendNEC(0x00FFE01FUL);
37+
delay(2000);
38+
USBSerial.println("Sony");
39+
irsend.sendSony(0xa90, 12, 2); // 12 bits & 2 repeats
40+
delay(2000);
41+
USBSerial.println("a rawData capture from IRrecvDumpV2");
42+
irsend.sendRaw(rawData, 67, 38); // Send a raw data capture at 38kHz.
43+
delay(2000);
44+
USBSerial.println("a Samsung A/C state from IRrecvDumpV2");
45+
irsend.sendSamsungAC(samsungState);
46+
delay(2000);
47+
}

examples/NFC/Detect/Detect.ino

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
// More examples on: https://github.com/m5stack/M5Unit-NFC/tree/main/examples
7+
#include <Arduino.h>
8+
#include <M5StackChan.h>
9+
#include <M5UnitUnified.h>
10+
#include <M5UnitUnifiedNFC.h>
11+
#include <M5Utility.h>
12+
#include <vector>
13+
14+
using namespace m5::nfc::a;
15+
16+
namespace {
17+
auto& lcd = M5.Display;
18+
m5::unit::UnitUnified Units;
19+
m5::unit::UnitNFC unit{}; // I2C
20+
m5::nfc::NFCLayerA nfc_a{unit};
21+
} // namespace
22+
23+
void setup()
24+
{
25+
M5StackChan.begin();
26+
27+
if (!Units.add(unit, M5.In_I2C) || !Units.begin()) {
28+
M5_LOGE("Failed to begin");
29+
lcd.clear(TFT_RED);
30+
while (true) {
31+
m5::utility::delay(10000);
32+
}
33+
}
34+
M5_LOGI("M5UnitUnified has been begun");
35+
M5_LOGI("%s", Units.debugInfo().c_str());
36+
37+
if (lcd.width() < lcd.height()) {
38+
lcd.setRotation(1);
39+
}
40+
lcd.setFont(&fonts::Font0);
41+
lcd.fillScreen(0);
42+
lcd.setCursor(0, 0);
43+
}
44+
45+
void loop()
46+
{
47+
M5StackChan.update();
48+
Units.update();
49+
50+
std::vector<PICC> piccs;
51+
if (nfc_a.detect(piccs)) {
52+
lcd.fillScreen(0);
53+
lcd.setCursor(0, 0);
54+
uint16_t idx{};
55+
for (auto&& u : piccs) {
56+
M5.Speaker.tone(6000, 5);
57+
// detect only performs a provisional classification based on sak, so further identification is required
58+
if (nfc_a.identify(u)) {
59+
M5.Log.printf("PICC:%s %s %04X/%02X %u/%u\n", u.uidAsString().c_str(), u.typeAsString().c_str(), u.atqa,
60+
u.sak, u.userAreaSize(), u.totalSize());
61+
lcd.printf("[%2u]:PICC:<%s> %s\n", idx, u.uidAsString().c_str(), u.typeAsString().c_str());
62+
++idx;
63+
} else {
64+
M5_LOGW("Failed to identify %s %s %04X/%02X %u/%u", u.uidAsString().c_str(), u.typeAsString().c_str(),
65+
u.atqa, u.sak, u.userAreaSize(), u.totalSize());
66+
}
67+
}
68+
if (idx) {
69+
M5.Speaker.tone(3000, 10);
70+
lcd.printf("==> %u PICC\n", idx);
71+
M5.Log.printf("==> %u PICC\n", idx);
72+
}
73+
nfc_a.deactivate();
74+
}
75+
}

0 commit comments

Comments
 (0)