Skip to content

Commit d26e4fe

Browse files
committed
Merge branch 'develop'
2 parents f196fcd + 3456186 commit d26e4fe

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"m5stack/M5Utility": "*",
1515
"m5stack/M5HAL": "*"
1616
},
17-
"version": "0.1.0",
17+
"version": "0.1.1",
1818
"frameworks": [
1919
"arduino"
2020
],

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=M5UnitUnified
2-
version=0.1.0
2+
version=0.1.1
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=M5UnitUnified is a library for unified handling of various M5 units products. (Alpha version)

pio_project/test/unit_unified_test.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
#include <M5UnitUnifiedANADIG.h>
2323
#include <M5UnitUnifiedCOLOR.h>
2424
#include <M5UnitUnifiedTHERMO.h>
25-
26-
#include <M5UnitUnifiedRFID.h>
2725
#include <M5UnitUnifiedDISTANCE.h>
2826
#include <M5UnitUnifiedEXTIO.h>
29-
#include <M5UnitUnifiedKEYBOARD.h>
3027
#include <M5UnitUnifiedINFRARED.h>
3128
#include <M5UnitUnifiedCRYPTO.h>
3229

30+
#include <M5UnitUnifiedRFID.h>
31+
#include <M5UnitUnifiedKEYBOARD.h>
32+
3333
#include <algorithm>
3434
#include <utility>
3535

@@ -104,6 +104,7 @@ TEST(UnitUnified, EachUnit)
104104
each_unit_test<m5::unit::UnitAmeter>();
105105
each_unit_test<m5::unit::UnitVmeter>();
106106
each_unit_test<m5::unit::UnitKmeterISO>();
107+
each_unit_test<m5::unit::UnitDualKmeter>();
107108

108109
// HUB
109110
each_unit_test<m5::unit::UnitPCA9548AP>();
@@ -138,29 +139,29 @@ TEST(UnitUnified, EachUnit)
138139
each_unit_test<m5::unit::UnitMLX90614BAA>();
139140
each_unit_test<m5::unit::UnitNCIR2>();
140141

141-
// RFID
142-
each_unit_test<m5::unit::UnitMFRC522>();
143-
each_unit_test<m5::unit::UnitWS1850S>();
144-
145142
// DISTANCE
146143
each_unit_test<m5::unit::UnitRCWL9620>();
147144

148145
// EXTIO
149146
each_unit_test<m5::unit::UnitExtIO2>();
150147

151-
// KEYBOARD
152-
each_unit_test<m5::unit::UnitKeyboard>();
153-
each_unit_test<m5::unit::UnitKeyboardBitwise>();
154-
each_unit_test<m5::unit::UnitCardKB>();
155-
each_unit_test<m5::unit::UnitFacesQWERTY>();
156-
157148
// INFRARED
158149
each_unit_test<m5::unit::UnitSTHS34PF80>();
159150

160151
// CRYPTO
161152
each_unit_test<m5::unit::UnitATECC608B>();
162153
each_unit_test<m5::unit::UnitATECC608B_TNGTLS>();
163154

155+
// RFID
156+
each_unit_test<m5::unit::UnitMFRC522>();
157+
each_unit_test<m5::unit::UnitWS1850S>();
158+
159+
// KEYBOARD
160+
each_unit_test<m5::unit::UnitKeyboard>();
161+
each_unit_test<m5::unit::UnitKeyboardBitwise>();
162+
each_unit_test<m5::unit::UnitCardKB>();
163+
each_unit_test<m5::unit::UnitFacesQWERTY>();
164+
164165
for (auto&& e : vec) {
165166
delete e;
166167
}

src/m5_unit_component/adapter_gpio.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,27 @@
1111
#include "adapter_gpio.hpp"
1212
#include <driver/gpio.h>
1313
#include <driver/adc.h>
14+
1415
#if defined(SOC_DAC_SUPPORTED) && SOC_DAC_SUPPORTED
16+
#pragma message "DAC supported"
17+
18+
#if __has_include(<driver/dac_common.h>)
1519
#include <driver/dac_common.h>
20+
#define USING_RMT_CHANNNE_T
21+
#endif
22+
23+
#endif
24+
25+
#if !defined(USING_RMT_CHANNNE_T) && defined(ARDUINO)
26+
#include <esp32-hal-dac.h>
1627
#endif
28+
29+
#if SOC_ADC_SUPPORTED
30+
#pragma message "ADC supported"
31+
#else
32+
#pragma message "ADC Not supported"
33+
#endif
34+
1735
#include <esp_timer.h>
1836

1937
namespace {
@@ -244,10 +262,10 @@ constexpr int8_t gpio_to_adc_table[] = {
244262
int8_t gpio_to_adc_channel(const int8_t pin)
245263
{
246264
if (pin < 0 || pin >= m5::stl::size(gpio_to_adc_table)) {
247-
return static_cast<adc_channel_t>(-1);
265+
return -1;
248266
}
249267
auto v = gpio_to_adc_table[pin];
250-
return static_cast<adc_channel_t>(v < 10 ? v : v - 10);
268+
return (v < 10) ? v : v - 10;
251269
}
252270

253271
#if 0
@@ -318,17 +336,19 @@ m5::hal::error::error_t AdapterGPIOBase::GPIOImpl::read_digital(const gpio_num_t
318336

319337
m5::hal::error::error_t AdapterGPIOBase::GPIOImpl::write_analog(const gpio_num_t pin, const uint16_t value)
320338
{
321-
#if defined(SOC_DAC_SUPPORTED) && SOC_DAC_SUPPORTED
322339
if (pin != 25 && pin != 26) {
323340
// DAC output can 25 or 26
324341
return m5::hal::error::error_t::INVALID_ARGUMENT;
325342
}
343+
#if defined(USING_RMT_CHANNNE_T)
326344
dac_channel_t ch = (pin == 25) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
327345
dac_output_enable(ch);
328346
dac_output_voltage(ch, static_cast<uint8_t>(value & 0xFF)); // 0〜255
329347
return m5::hal::error::error_t::OK;
330348
#else
331-
return m5::hal::error::error_t::NOT_IMPLEMENTED;
349+
analogWrite(pin, value & 0xFF);
350+
;
351+
// return m5::hal::error::error_t::NOT_IMPLEMENTED;
332352
#endif
333353
}
334354

0 commit comments

Comments
 (0)