Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/arduino-esp-v2-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ jobs:
archi:
- esp32

include:
# Specific sketches for m5stack-core-esp32 only
- sketch: SimpleDisplay
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
platform: esp32
archi: esp32
platform-version: 2.0.17
board: m5stack-core-esp32
unit: UnitToF
- sketch: SimpleDisplay
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
platform: esp32
archi: esp32
platform-version: 2.0.17
board: m5stack-core-esp32
unit: UnitToF4M

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/arduino-esp-v3-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ jobs:
archi:
- esp32

include:
# Specific sketches for m5stack-core-esp32 only
- sketch: SimpleDisplay
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
platform-version: 3.0.4
platform: esp32
archi: esp32
board: m5stack_core
unit: UnitToF
- sketch: SimpleDisplay
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
platform-version: 3.0.4
platform: esp32
archi: esp32
board: m5stack_core
unit: UnitToF4M


steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/arduino-m5-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ jobs:
archi:
- esp32

include:
# Specific sketches for m5stack-core-esp32 only
- sketch: SimpleDisplay
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
platform-version: 2.1.2
platform: m5stack
archi: esp32
board: m5stack_core
unit: UnitToF
- sketch: SimpleDisplay
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
platform-version: 2.1.2
platform: m5stack
archi: esp32
board: m5stack_core
unit: UnitToF4M

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/platformio-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ jobs:
# - board: Paper
# espressif32: '4_4_0'


include:
# Specific sketches for m5stack-core-esp32 only
- example: SimpleDisplay
unit: UnitToF
board: Core
framework: Arduino
espressif32: latest
- example: SimpleDisplay
unit: UnitToF4M
board: Core
framework: Arduino
espressif32: latest

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
9 changes: 9 additions & 0 deletions examples/UnitUnified/UnitToF/SimpleDisplay/SimpleDisplay.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
*
* SPDX-License-Identifier: MIT
*/
/*
Example using M5UnitUnified for UnitToF
*/
#include "main/SimpleDisplay.cpp"
67 changes: 67 additions & 0 deletions examples/UnitUnified/UnitToF/SimpleDisplay/main/SimpleDisplay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
*
* SPDX-License-Identifier: MIT
*/
/*
Example using M5UnitUnified for UnitToF
*/
#include <M5Unified.h>
#include <M5UnitUnified.h>
#include <M5UnitUnifiedTOF.h>
#include <M5Utility.h>

namespace {
auto& lcd = M5.Display;
m5::unit::UnitUnified Units;
m5::unit::UnitToF unit;
int16_t lastRange{};
} // namespace

void setup()
{
M5.begin();
// The screen shall be in landscape mode if exists
if (lcd.height() > lcd.width()) {
lcd.setRotation(1);
}

auto pin_num_sda = M5.getPin(m5::pin_name_t::port_a_sda);
auto pin_num_scl = M5.getPin(m5::pin_name_t::port_a_scl);
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);

if (!Units.add(unit, Wire) || !Units.begin()) {
M5_LOGE("Failed to begin");
lcd.clear(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}

M5_LOGI("M5UnitUnified has been begun");
M5_LOGI("%s", Units.debugInfo().c_str());

lcd.setTextColor(TFT_ORANGE);
lcd.setFont(&fonts::Orbitron_Light_32);
lcd.setTextDatum(middle_center);
float scale = lcd.width() / (32 * 4.0f);
lcd.setTextSize(scale, scale);

lcd.startWrite();
lcd.clear();
}

void loop()
{
M5.update();
Units.update();

if (unit.updated()) {
auto range = unit.range();
if (range > 0 && range != lastRange) {
lcd.fillRect(0, lcd.height() / 2 - lcd.fontHeight() / 2, lcd.width(), lcd.fontHeight(), TFT_BLACK);
lcd.drawString(m5::utility::formatString("%d", range).c_str(), lcd.width() / 2, lcd.height() / 2);
lastRange = range;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
*
* SPDX-License-Identifier: MIT
*/
/*
Example using M5UnitUnified for UnitToF4M
*/
#include "main/SimpleDisplay.cpp"
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
*
* SPDX-License-Identifier: MIT
*/
/*
Example using M5UnitUnified for UnitToF4M
*/
#include <M5Unified.h>
#include <M5UnitUnified.h>
#include <M5UnitUnifiedTOF.h>
#include <M5Utility.h>

namespace {
auto& lcd = M5.Display;
m5::unit::UnitUnified Units;
m5::unit::UnitToF4M unit;
int16_t lastRange{};
} // namespace

void setup()
{
M5.begin();
// The screen shall be in landscape mode if exists
if (lcd.height() > lcd.width()) {
lcd.setRotation(1);
}

auto pin_num_sda = M5.getPin(m5::pin_name_t::port_a_sda);
auto pin_num_scl = M5.getPin(m5::pin_name_t::port_a_scl);
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);

if (!Units.add(unit, Wire) || !Units.begin()) {
M5_LOGE("Failed to begin");
lcd.clear(TFT_RED);
while (true) {
m5::utility::delay(10000);
}
}

M5_LOGI("M5UnitUnified has been begun");
M5_LOGI("%s", Units.debugInfo().c_str());

lcd.setTextColor(TFT_ORANGE);
lcd.setFont(&fonts::Orbitron_Light_32);
lcd.setTextDatum(middle_center);
float scale = lcd.width() / (32 * 4.0f);
lcd.setTextSize(scale, scale);

lcd.startWrite();
lcd.clear();
}

void loop()
{
M5.update();
Units.update();

if (unit.updated()) {
auto range = unit.range();
if (range > 0 && range != lastRange) {
lcd.fillRect(0, lcd.height() / 2 - lcd.fontHeight() / 2, lcd.width(), lcd.fontHeight(), TFT_BLACK);
lcd.drawString(m5::utility::formatString("%d", range).c_str(), lcd.width() / 2, lcd.height() / 2);
lastRange = range;
}
}
}
14 changes: 14 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,17 @@ build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitToF/Plot
[env:UnitToF_PlotToSerial_CoreInk_Arduino_latest]
extends=CoreInk, option_release, arduino_latest
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitToF/PlotToSerial>

;
; For the following samples, please refer to PlotToSerial to create env for your own environment
; 以下のサンプルは、PlotToSerial を参考にして、自分の環境にあった env を作成してください
;
;SimpleDisplay (ToF)
[env:UnitToF_SimpleDisplay_Core_Arduino_latest]
extends=Core, option_release, arduino_latest
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitToF/SimpleDisplay>

;SimpleDisplay (ToF4M)
[env:UnitToF4M_SimpleDisplay_Core_Arduino_latest]
extends=Core, option_release, arduino_latest
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitToF4M/SimpleDisplay>
Loading