Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
GOB52 committed Jan 6, 2025
2 parents 97a559d + d6c9464 commit 4011769
Show file tree
Hide file tree
Showing 14 changed files with 1,066 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/arduino-esp-v2-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ jobs:
- https://espressif.github.io/arduino-esp32/package_esp32_index.json

sketch:
- PlotToSerial
- Output

unit:
- UnitADC
- UnitDAC
- UnitDAC2

Expand All @@ -81,6 +83,14 @@ jobs:
archi:
- esp32

exclude:
- sketch: Output
unit: UnitADC
- sketch: PlotToSerial
unit: UnitDAC
- sketch: PlotToSerial
unit: UnitDAC2

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

sketch:
- Output
- PlotToSerial

unit:
- UnitADC
- UnitDAC
- UnitDAC2

Expand Down Expand Up @@ -97,6 +99,14 @@ jobs:
archi:
- esp32

exclude:
- sketch: Output
unit: UnitADC
- sketch: PlotToSerial
unit: UnitDAC
- sketch: PlotToSerial
unit: UnitDAC2

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

sketch:
- Output
- PlotToSerial

unit:
- UnitADC
- UnitDAC
- UnitDAC2

Expand Down Expand Up @@ -99,6 +101,14 @@ jobs:
archi:
- esp32

exclude:
- sketch: Output
unit: UnitADC
- sketch: PlotToSerial
unit: UnitDAC
- sketch: PlotToSerial
unit: UnitDAC2

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/platformio-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ jobs:
matrix:
example:
- Output
- PlotToSerial

unit:
- UnitADC
- UnitDAC
- UnitDAC2

Expand Down Expand Up @@ -113,6 +115,14 @@ jobs:
# - board: Paper
# espressif32: '4_4_0'

exclude:
- example: Output
unit: UnitADC
- example: PlotToSerial
unit: UnitDAC
- example: PlotToSerial
unit: UnitDAC2

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ DAC, is a unit with the ability to convert digital signal to analog signal (volt
### SKU:U012-B
DAC2 Unit is an I2C digital-to-analog signal conversion unit. It utilizes the GP8413 solution, which provides high precision and accuracy in its performance. This chip can linearly convert a 15-bit digital value into two independent analog voltages of 0-5V or 0-10V. The output voltage error is only 0.2%, and it achieves linearity of up to 0.01%.

### SKU:U013-V11
ADC V1.1 Unit is an A/D conversion module that utilizes the ADS1110 chip, a 16-bit self-calibrating analog-to-digital converter. It is designed with an I2C interface, offering convenient connectivity. The module offers conversion speeds of 8, 16, 32, and 128 samples per second (SPS), providing varying levels of accuracy at 16, 15, 14, and 12 bits of resolution respectively.


## Related Link
See also examples using conventional methods here.

- [Unit DAC & Datasheet](https://docs.m5stack.com/en/unit/dac)
- [Unit DAC2 & Datasheet](https://docs.m5stack.com/en/unit/Unit-DAC2)
- [Unit ADC v1.1 & Datasheet](https://docs.m5stack.com/en/unit/Unit-ADC_V1.1)


### Required Libraries:
Expand Down
9 changes: 9 additions & 0 deletions examples/UnitUnified/UnitADC/PlotToSerial/PlotToSerial.ino
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 examples/UnitUnified/UnitADC/PlotToSerial/main/PlotToSerial.cpp
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();
}
}
169 changes: 168 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 4011769

Please sign in to comment.