Skip to content

Commit 9cacc00

Browse files
committed
Merge branch 'develop'
2 parents 0105782 + 475b879 commit 9cacc00

File tree

16 files changed

+313
-98
lines changed

16 files changed

+313
-98
lines changed

.github/workflows/arduino-esp-v2-build-check.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ jobs:
8181
archi:
8282
- esp32
8383

84+
include:
85+
# Specific sketches for m5stack-core-esp32 only
86+
- sketch: SimpleDisplay
87+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
88+
platform: esp32
89+
archi: esp32
90+
platform-version: 2.0.17
91+
board: m5stack-core-esp32
92+
unit: UnitToF
93+
- sketch: SimpleDisplay
94+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
95+
platform: esp32
96+
archi: esp32
97+
platform-version: 2.0.17
98+
board: m5stack-core-esp32
99+
unit: UnitToF4M
100+
84101
steps:
85102
- name: Checkout
86103
uses: actions/checkout@v4

.github/workflows/arduino-esp-v3-build-check.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ jobs:
9797
archi:
9898
- esp32
9999

100+
include:
101+
# Specific sketches for m5stack-core-esp32 only
102+
- sketch: SimpleDisplay
103+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
104+
platform-version: 3.0.4
105+
platform: esp32
106+
archi: esp32
107+
board: m5stack_core
108+
unit: UnitToF
109+
- sketch: SimpleDisplay
110+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
111+
platform-version: 3.0.4
112+
platform: esp32
113+
archi: esp32
114+
board: m5stack_core
115+
unit: UnitToF4M
116+
117+
100118
steps:
101119
- name: Checkout
102120
uses: actions/checkout@v4

.github/workflows/arduino-m5-build-check.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ jobs:
9999
archi:
100100
- esp32
101101

102+
include:
103+
# Specific sketches for m5stack-core-esp32 only
104+
- sketch: SimpleDisplay
105+
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
106+
platform-version: 2.1.2
107+
platform: m5stack
108+
archi: esp32
109+
board: m5stack_core
110+
unit: UnitToF
111+
- sketch: SimpleDisplay
112+
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
113+
platform-version: 2.1.2
114+
platform: m5stack
115+
archi: esp32
116+
board: m5stack_core
117+
unit: UnitToF4M
118+
102119
steps:
103120
- name: Checkout
104121
uses: actions/checkout@v4

.github/workflows/platformio-build-check.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ jobs:
113113
# - board: Paper
114114
# espressif32: '4_4_0'
115115

116+
117+
include:
118+
# Specific sketches for m5stack-core-esp32 only
119+
- example: SimpleDisplay
120+
unit: UnitToF
121+
board: Core
122+
framework: Arduino
123+
espressif32: latest
124+
- example: SimpleDisplay
125+
unit: UnitToF4M
126+
board: Core
127+
framework: Arduino
128+
espressif32: latest
129+
116130
steps:
117131
- name: Checkout
118132
uses: actions/checkout@v4
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
/*
7+
Example using M5UnitUnified for UnitToF
8+
*/
9+
#include "main/SimpleDisplay.cpp"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
/*
7+
Example using M5UnitUnified for UnitToF
8+
*/
9+
#include <M5Unified.h>
10+
#include <M5UnitUnified.h>
11+
#include <M5UnitUnifiedTOF.h>
12+
#include <M5Utility.h>
13+
14+
namespace {
15+
auto& lcd = M5.Display;
16+
m5::unit::UnitUnified Units;
17+
m5::unit::UnitToF unit;
18+
int16_t lastRange{};
19+
} // namespace
20+
21+
void setup()
22+
{
23+
M5.begin();
24+
// The screen shall be in landscape mode if exists
25+
if (lcd.height() > lcd.width()) {
26+
lcd.setRotation(1);
27+
}
28+
29+
auto pin_num_sda = M5.getPin(m5::pin_name_t::port_a_sda);
30+
auto pin_num_scl = M5.getPin(m5::pin_name_t::port_a_scl);
31+
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
32+
33+
if (!Units.add(unit, Wire) || !Units.begin()) {
34+
M5_LOGE("Failed to begin");
35+
lcd.clear(TFT_RED);
36+
while (true) {
37+
m5::utility::delay(10000);
38+
}
39+
}
40+
41+
M5_LOGI("M5UnitUnified has been begun");
42+
M5_LOGI("%s", Units.debugInfo().c_str());
43+
44+
lcd.setTextColor(TFT_ORANGE);
45+
lcd.setFont(&fonts::Orbitron_Light_32);
46+
lcd.setTextDatum(middle_center);
47+
float scale = lcd.width() / (32 * 4.0f);
48+
lcd.setTextSize(scale, scale);
49+
50+
lcd.startWrite();
51+
lcd.clear();
52+
}
53+
54+
void loop()
55+
{
56+
M5.update();
57+
Units.update();
58+
59+
if (unit.updated()) {
60+
auto range = unit.range();
61+
if (range > 0 && range != lastRange) {
62+
lcd.fillRect(0, lcd.height() / 2 - lcd.fontHeight() / 2, lcd.width(), lcd.fontHeight(), TFT_BLACK);
63+
lcd.drawString(m5::utility::formatString("%d", range).c_str(), lcd.width() / 2, lcd.height() / 2);
64+
lastRange = range;
65+
}
66+
}
67+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
/*
7+
Example using M5UnitUnified for UnitToF4M
8+
*/
9+
#include "main/SimpleDisplay.cpp"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
/*
7+
Example using M5UnitUnified for UnitToF4M
8+
*/
9+
#include <M5Unified.h>
10+
#include <M5UnitUnified.h>
11+
#include <M5UnitUnifiedTOF.h>
12+
#include <M5Utility.h>
13+
14+
namespace {
15+
auto& lcd = M5.Display;
16+
m5::unit::UnitUnified Units;
17+
m5::unit::UnitToF4M unit;
18+
int16_t lastRange{};
19+
} // namespace
20+
21+
void setup()
22+
{
23+
M5.begin();
24+
// The screen shall be in landscape mode if exists
25+
if (lcd.height() > lcd.width()) {
26+
lcd.setRotation(1);
27+
}
28+
29+
auto pin_num_sda = M5.getPin(m5::pin_name_t::port_a_sda);
30+
auto pin_num_scl = M5.getPin(m5::pin_name_t::port_a_scl);
31+
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
32+
33+
if (!Units.add(unit, Wire) || !Units.begin()) {
34+
M5_LOGE("Failed to begin");
35+
lcd.clear(TFT_RED);
36+
while (true) {
37+
m5::utility::delay(10000);
38+
}
39+
}
40+
41+
M5_LOGI("M5UnitUnified has been begun");
42+
M5_LOGI("%s", Units.debugInfo().c_str());
43+
44+
lcd.setTextColor(TFT_ORANGE);
45+
lcd.setFont(&fonts::Orbitron_Light_32);
46+
lcd.setTextDatum(middle_center);
47+
float scale = lcd.width() / (32 * 4.0f);
48+
lcd.setTextSize(scale, scale);
49+
50+
lcd.startWrite();
51+
lcd.clear();
52+
}
53+
54+
void loop()
55+
{
56+
M5.update();
57+
Units.update();
58+
59+
if (unit.updated()) {
60+
auto range = unit.range();
61+
if (range > 0 && range != lastRange) {
62+
lcd.fillRect(0, lcd.height() / 2 - lcd.fontHeight() / 2, lcd.width(), lcd.fontHeight(), TFT_BLACK);
63+
lcd.drawString(m5::utility::formatString("%d", range).c_str(), lcd.width() / 2, lcd.height() / 2);
64+
lastRange = range;
65+
}
66+
}
67+
}

library.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"url": "https://github.com/m5stack/M5Unit-TOF.git"
1212
},
1313
"dependencies": {
14-
"M5UnitUnified": "https://github.com/m5stack/M5UnitUnified.git"
14+
"M5UnitUnified": "https://github.com/m5stack/M5UnitUnified.git@^0.0.5"
1515
},
16-
"version": "0.0.1",
16+
"version": "0.0.2",
1717
"frameworks": [
1818
"arduino"
1919
],
@@ -27,4 +27,4 @@
2727
"docs/html"
2828
]
2929
}
30-
}
30+
}

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=M5Unit-TOF
2-
version=0.0.1
2+
version=0.0.2
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=Library for M5Stack UNIT TOF using M5UnitUnified
@@ -8,4 +8,4 @@ category=Device Control
88
url=https://github.com/m5stack/M5Unit-TOF
99
architectures=esp32
1010
includes=M5UnitUnifiedTOF.h
11-
depends=M5UnitUnified,M5Utility,M5HAL
11+
depends=M5UnitUnified(>=0.0.5),M5Utility,M5HAL

0 commit comments

Comments
 (0)