generated from m5stack/M5Template-C-CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,066 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
/* | ||
Example using M5UnitUnified for UnitADC | ||
*/ | ||
#include "main/PlotToSerial.cpp" |
64 changes: 64 additions & 0 deletions
64
examples/UnitUnified/UnitADC/PlotToSerial/main/PlotToSerial.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
/* | ||
Example using M5UnitUnified for UnitADC | ||
*/ | ||
#include <M5Unified.h> | ||
#include <M5UnitUnified.h> | ||
#include <M5UnitUnifiedANADIG.h> | ||
#include <M5Utility.h> | ||
|
||
namespace { | ||
auto& lcd = M5.Display; | ||
m5::unit::UnitUnified Units; | ||
m5::unit::UnitADC11 unit; | ||
} // namespace | ||
|
||
using namespace m5::unit::ads1110; | ||
|
||
void setup() | ||
{ | ||
M5.begin(); | ||
|
||
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); | ||
M5_LOGI("getPin: SDA:%u SCL:%u", pin_num_sda, pin_num_scl); | ||
Wire.begin(pin_num_sda, pin_num_scl, 100 * 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.clear(TFT_DARKGREEN); | ||
} | ||
|
||
void loop() | ||
{ | ||
M5.update(); | ||
auto touch = M5.Touch.getDetail(); | ||
|
||
// Periodic | ||
Units.update(); | ||
if (unit.updated()) { | ||
M5_LOGI("\n>Diff:%d\n>DiffMV:%f", unit.differentialValue(), unit.differentialVoltage()); | ||
} | ||
|
||
// Single | ||
if (M5.BtnA.wasClicked() || touch.wasClicked()) { | ||
unit.stopPeriodicMeasurement(); | ||
Data d{}; | ||
if (unit.measureSingleshot(d)) { | ||
M5_LOGI("Single: %d/%f", d.differentialValue(), d.differentialVoltage()); | ||
} | ||
unit.startPeriodicMeasurement(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,6 +181,92 @@ lib_deps = google/[email protected] | |
; -------------------------------- | ||
; UnitTest | ||
; -------------------------------- | ||
; ADC | ||
[env:test_UnitADC_Core] | ||
extends=Core, option_release, arduino_latest | ||
lib_deps = ${Core.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_Core2] | ||
extends=Core2, option_release, arduino_latest | ||
lib_deps = ${Core2.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_CoreS3] | ||
extends=CoreS3, option_release, arduino_latest | ||
lib_deps = ${CoreS3.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_Fire] | ||
extends=Fire, option_release, arduino_latest | ||
lib_deps = ${Fire.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_StampS3] | ||
extends=StampS3, option_release, arduino_latest | ||
lib_deps = ${StampS3.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_Dial] | ||
extends=Dial, option_release, arduino_latest | ||
lib_deps = ${Dial.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_AtomMatrix] | ||
extends=AtomMatrix, option_release, arduino_latest | ||
lib_deps = ${AtomMatrix.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_AtomS3] | ||
extends=AtomS3, option_release, arduino_latest | ||
lib_deps = ${AtomS3.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_AtomS3R] | ||
extends=AtomS3R, option_release, arduino_latest | ||
lib_deps = ${AtomS3R.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_NanoC6] | ||
extends=NanoC6, option_release, arduino_latest | ||
lib_deps = ${NanoC6.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_StickCPlus] | ||
extends=StickCPlus, option_release, arduino_latest | ||
lib_deps = ${StickCPlus.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_StickCPlus2] | ||
extends=StickCPlus2, option_release, arduino_latest | ||
lib_deps = ${StickCPlus2.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_Paper] | ||
extends=Paper, option_release, arduino_latest | ||
lib_deps = ${Paper.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
[env:test_UnitADC_CoreInk] | ||
extends=CoreInk, option_release, arduino_latest | ||
lib_deps = ${CoreInk.lib_deps} | ||
${test_fw.lib_deps} | ||
test_filter= embedded/test_ads1110 | ||
|
||
; DAC | ||
[env:test_UnitDAC_Core] | ||
extends=Core, option_release, arduino_latest | ||
lib_deps = ${Core.lib_deps} | ||
|
@@ -265,7 +351,7 @@ lib_deps = ${CoreInk.lib_deps} | |
${test_fw.lib_deps} | ||
test_filter= embedded/test_mcp4725 | ||
|
||
|
||
; DAC2 | ||
[env:test_UnitDAC2_Core] | ||
extends=Core, option_release, arduino_latest | ||
lib_deps = ${Core.lib_deps} | ||
|
@@ -354,6 +440,87 @@ test_filter= embedded/test_gp8413 | |
; -------------------------------- | ||
; Examples by M5UnitUnified | ||
; -------------------------------- | ||
; ADC | ||
[env:UnitADC_PlotToSerial_Core_Arduino_latest] | ||
extends=Core, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Core_Arduino_5_4_0] | ||
extends=Core, option_release, arduino_5_4_0 | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Core_Arduino_4_4_0] | ||
extends=Core, option_release, arduino_4_4_0 | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Core2_Arduino_latest] | ||
extends=Core2, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Core2_Arduino_5_4_0] | ||
extends=Core2, option_release, arduino_5_4_0 | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Core2_Arduino_4_4_0] | ||
extends=Core2, option_release, arduino_4_4_0 | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_CoreS3_Arduino_latest] | ||
extends=CoreS3, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_StampS3_Arduino_latest] | ||
extends=StampS3, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_AtomMatrix_Arduino_latest] | ||
extends=AtomMatrix, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_AtomS3_Arduino_latest] | ||
extends=AtomS3, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_AtomS3R_Arduino_latest] | ||
extends=AtomS3R, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Dial_Arduino_latest] | ||
extends=Dial, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_NanoC6_Arduino_latest] | ||
extends=NanoC6, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_StickCPlus_Arduino_latest] | ||
extends=StickCPlus, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_StickCPlus2_Arduino_latest] | ||
extends=StickCPlus2, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Paper_Arduino_latest] | ||
extends=Paper, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_CoreInk_Arduino_latest] | ||
extends=CoreInk, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Fire_Arduino_latest] | ||
extends=Fire, option_release, arduino_latest | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Fire_Arduino_5_4_0] | ||
extends=Fire, option_release, arduino_5_4_0 | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
[env:UnitADC_PlotToSerial_Fire_Arduino_4_4_0] | ||
extends=Fire, option_release, arduino_4_4_0 | ||
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitADC/PlotToSerial> | ||
|
||
;DAC | ||
[env:UnitDAC_Output_Core_Arduino_latest] | ||
extends=Core, option_release, arduino_latest | ||
|
Oops, something went wrong.