Skip to content

Commit 52f7e8a

Browse files
committed
Resolve conflict
2 parents 1570029 + aeeb897 commit 52f7e8a

File tree

12 files changed

+1389
-39
lines changed

12 files changed

+1389
-39
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ Unit PaHub v2.1 is an I2C multiplexer unit that uses the PCA9548AP chip solution
1818
The module is equipped with an onboard DIP switch to easily adjust the I2C address of Unit PaHub v2.1, supporting multi-unit cascading to connect more I2C devices.
1919

2020

21+
### SKU:U041-B
22+
Unit Pbhub v1.1 is an I2C-controlled 6-channel PORT.B expander. Each Port B interface can achieve GPIO, PWM, Servo control, ADC sampling, RGB light control, and more. It is internally controlled by an STM32F030 microcontroller.
23+
24+
Note : Not all Units with a black interface (PortB) support expansion through PbHUB. PbHUB can only be applied to basic single-bus communication, through the I2C protocol (built-in MEGA328) to achieve basic digital read and write, analog Read and write. But for units such as Weight (built-in HX711) that not only need to read analog, but also depend on the timing of the Unit, PbHUB cannot be expanded.
25+
26+
2127
## Related Link
2228
See also examples using conventional methods here.
2329

2430
- [Unit PaHub v2.0 - Document & Datasheet](https://docs.m5stack.com/en/unit/pahub2)
2531
- [Unit PaHub v2.1 - Document & Datasheet](https://docs.m5stack.com/en/unit/Unit-PaHub%20v2.1)
26-
32+
- [Unit PbHub v1.1 - Document & Datasheet](https://docs.m5stack.com/ja/unit/pbhub_1.1)
2733

2834
## Required Libraries:
2935

examples/UnitUnified/UnitPaHub/DaisyChain/DaisyChain.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
* SPDX-License-Identifier: MIT
55
*/
66
/*
7-
Example: Daisy chaining Unit-PaHub
7+
Example: Daisy chaining UnitPaHub
88
*/
99
/*
1010
*********************************************************************************************
1111
Note for ArduinoIDE
1212
Install the necessary unit libraries according to the units used in example.
13-
(Initially, M5Unit-VMETER is required)
13+
(This example requires the M5Unit-METER library)
1414
See alse main/DaisyChain.cpp
1515
*********************************************************************************************
1616
*/

examples/UnitUnified/UnitPaHub/DaisyChain/main/DaisyChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
/*
77
Example: Example of daisy chaining Unit-PaHub
8-
Device => PaHub2 ch:0 => PaHub2 ch:5 => UnitVmeter (*1)
8+
Device ---> PaHub2 ch:0 ---> PaHub2 ch:5 ---> UnitVmeter (*1)
99
*/
1010
#include <M5Unified.h>
1111
#include <M5UnitUnified.h>

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"m5stack/M5UnitUnified": ">=0.1.0"
1515
},
16-
"version": "0.1.0",
16+
"version": "0.2.0",
1717
"frameworks": [
1818
"arduino"
1919
],

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=M5Unit-HUB
2-
version=0.1.0
2+
version=0.2.0
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=Library for M5Stack UNIT HUB using M5UnitUnified

platformio.ini

Lines changed: 108 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -270,133 +270,218 @@ lib_deps = ${CoreInk.lib_deps}
270270
${test_fw.lib_deps}
271271
test_filter= embedded/test_pca9548ap
272272

273+
; UnitPbHub
274+
[env:test_UnitPbHub_Core]
275+
extends=Core, option_release, arduino_latest
276+
lib_deps = ${Core.lib_deps}
277+
${test_fw.lib_deps}
278+
test_filter= embedded/test_pbhub
279+
280+
[env:test_UnitPbHub_Core2]
281+
extends=Core2, option_release, arduino_latest
282+
lib_deps = ${Core2.lib_deps}
283+
${test_fw.lib_deps}
284+
test_filter= embedded/test_pbhub
285+
286+
[env:test_UnitPbHub_CoreS3]
287+
extends=CoreS3, option_release, arduino_latest
288+
lib_deps = ${CoreS3.lib_deps}
289+
${test_fw.lib_deps}
290+
test_filter= embedded/test_pbhub
291+
292+
[env:test_UnitPbHub_Fire]
293+
extends=Fire, option_release, arduino_latest
294+
lib_deps = ${Fire.lib_deps}
295+
${test_fw.lib_deps}
296+
test_filter= embedded/test_pbhub
297+
298+
[env:test_UnitPbHub_StampS3]
299+
extends=StampS3, option_release, arduino_latest
300+
lib_deps = ${StampS3.lib_deps}
301+
${test_fw.lib_deps}
302+
test_filter= embedded/test_pbhub
303+
304+
[env:test_UnitPbHub_Dial]
305+
extends=Dial, option_release, arduino_latest
306+
lib_deps = ${StampS3.lib_deps}
307+
${test_fw.lib_deps}
308+
test_filter= embedded/test_pbhub
309+
310+
[env:test_UnitPbHub_AtomMatrix]
311+
extends=AtomMatrix, option_release, arduino_latest
312+
lib_deps = ${AtomMatrix.lib_deps}
313+
${test_fw.lib_deps}
314+
test_filter= embedded/test_pbhub
315+
316+
[env:test_UnitPbHub_AtomS3]
317+
extends=AtomS3, option_release, arduino_latest
318+
lib_deps = ${AtomS3.lib_deps}
319+
${test_fw.lib_deps}
320+
test_filter= embedded/test_pbhub
321+
322+
[env:test_UnitPbHub_AtomS3R]
323+
extends=AtomS3R, option_release, arduino_latest
324+
lib_deps = ${AtomS3R.lib_deps}
325+
${test_fw.lib_deps}
326+
test_filter= embedded/test_pbhub
327+
328+
[env:test_UnitPbHub_NanoC6]
329+
extends=NanoC6, option_release, arduino_latest
330+
lib_deps = ${NanoC6.lib_deps}
331+
${test_fw.lib_deps}
332+
test_filter= embedded/test_pbhub
333+
334+
[env:test_UnitPbHub_StickCPlus]
335+
extends=StickCPlus, option_release, arduino_latest
336+
lib_deps = ${StickCPlus.lib_deps}
337+
${test_fw.lib_deps}
338+
test_filter= embedded/test_pbhub
339+
340+
[env:test_UnitPbHub_StickCPlus2]
341+
extends=StickCPlus2, option_release, arduino_latest
342+
lib_deps = ${StickCPlus2.lib_deps}
343+
${test_fw.lib_deps}
344+
test_filter= embedded/test_pbhub
345+
346+
[env:test_UnitPbHub_Paper]
347+
extends=Paper, option_release, arduino_latest
348+
lib_deps = ${Paper.lib_deps}
349+
${test_fw.lib_deps}
350+
test_filter= embedded/test_pbhub
351+
352+
[env:test_UnitPbHub_CoreInk]
353+
extends=CoreInk, option_release, arduino_latest
354+
lib_deps = ${CoreInk.lib_deps}
355+
${test_fw.lib_deps}
356+
test_filter= embedded/test_pbhub
357+
358+
273359
; --------------------------------
274360
; Examples
275361
; --------------------------------
276-
; DaisyChain
277-
362+
; PaHub DaisyChain
278363
; Change as appropriate for the units used in examples
279364
; See also examples/UnitUnified/UnitPaHub/DaisyChain/main/DaisyChain.cpp
280-
[unit]
365+
[unit_for_pa]
281366
lib_deps = m5stack/M5Unit-METER
282367

283368
[env:UnitPaHub_DaisyChain_Core_Arduino_latest]
284369
extends=Core, option_release, arduino_latest
285370
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
286371
lib_deps = ${Core.lib_deps}
287-
${unit.lib_deps}
372+
${unit_for_pa.lib_deps}
288373

289374
[env:UnitPaHub_DaisyChain_Core_Arduino_5_4_0]
290375
extends=Core, option_release, arduino_5_4_0
291376
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
292377
lib_deps = ${Core.lib_deps}
293-
${unit.lib_deps}
378+
${unit_for_pa.lib_deps}
294379

295380
[env:UnitPaHub_DaisyChain_Core_Arduino_4_4_0]
296381
extends=Core, option_release, arduino_4_4_0
297382
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
298383
lib_deps = ${Core.lib_deps}
299-
${unit.lib_deps}
384+
${unit_for_pa.lib_deps}
300385

301386
[env:UnitPaHub_DaisyChain_Core2_Arduino_latest]
302387
extends=Core2, option_release, arduino_latest
303388
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
304389
lib_deps = ${Core2.lib_deps}
305-
${unit.lib_deps}
390+
${unit_for_pa.lib_deps}
306391

307392
[env:UnitPaHub_DaisyChain_Core2_Arduino_5_4_0]
308393
extends=Core2, option_release, arduino_5_4_0
309394
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
310395
lib_deps = ${Core2.lib_deps}
311-
${unit.lib_deps}
396+
${unit_for_pa.lib_deps}
312397

313398
[env:UnitPaHub_DaisyChain_Core2_Arduino_4_4_0]
314399
extends=Core2, option_release, arduino_4_4_0
315400
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
316401
lib_deps = ${Core2.lib_deps}
317-
${unit.lib_deps}
402+
${unit_for_pa.lib_deps}
318403

319404
[env:UnitPaHub_DaisyChain_CoreS3_Arduino_latest]
320405
extends=CoreS3, option_release, arduino_latest
321406
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
322407
lib_deps = ${CoreS3.lib_deps}
323-
${unit.lib_deps}
408+
${unit_for_pa.lib_deps}
324409

325410
[env:UnitPaHub_DaisyChain_StampS3_Arduino_latest]
326411
extends=StampS3, option_release, arduino_latest
327412
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
328413
lib_deps = ${StampS3.lib_deps}
329-
${unit.lib_deps}
414+
${unit_for_pa.lib_deps}
330415

331416
[env:UnitPaHub_DaisyChain_AtomMatrix_Arduino_latest]
332417
extends=AtomMatrix, option_release, arduino_latest
333418
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
334419
lib_deps = ${AtomMatrix.lib_deps}
335-
${unit.lib_deps}
420+
${unit_for_pa.lib_deps}
336421

337422
[env:UnitPaHub_DaisyChain_AtomS3_Arduino_latest]
338423
extends=AtomS3, option_release, arduino_latest
339424
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
340425
lib_deps = ${AtomS3.lib_deps}
341-
${unit.lib_deps}
426+
${unit_for_pa.lib_deps}
342427

343428
[env:UnitPaHub_DaisyChain_AtomS3R_Arduino_latest]
344429
extends=AtomS3R, option_release, arduino_latest
345430
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
346431
lib_deps = ${AtomS3R.lib_deps}
347-
${unit.lib_deps}
432+
${unit_for_pa.lib_deps}
348433

349434
[env:UnitPaHub_DaisyChain_Dial_Arduino_latest]
350435
extends=Dial, option_release, arduino_latest
351436
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
352437
lib_deps = ${Dial.lib_deps}
353-
${unit.lib_deps}
438+
${unit_for_pa.lib_deps}
354439

355440
[env:UnitPaHub_DaisyChain_NanoC6_Arduino_latest]
356441
extends=NanoC6, option_release, arduino_latest
357442
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
358443
lib_deps = ${NanoC6.lib_deps}
359-
${unit.lib_deps}
444+
${unit_for_pa.lib_deps}
360445

361446
[env:UnitPaHub_DaisyChain_StickCPlus_Arduino_latest]
362447
extends=StickCPlus, option_release, arduino_latest
363448
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
364449
lib_deps = ${StickCPlus.lib_deps}
365-
${unit.lib_deps}
450+
${unit_for_pa.lib_deps}
366451

367452
[env:UnitPaHub_DaisyChain_StickCPlus2_Arduino_latest]
368453
extends=StickCPlus2, option_release, arduino_latest
369454
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
370455
lib_deps = ${StickCPlus2.lib_deps}
371-
${unit.lib_deps}
456+
${unit_for_pa.lib_deps}
372457

373458
[env:UnitPaHub_DaisyChain_Paper_Arduino_latest]
374459
extends=Paper, option_release, arduino_latest
375460
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
376461
lib_deps = ${Paper.lib_deps}
377-
${unit.lib_deps}
462+
${unit_for_pa.lib_deps}
378463

379464
[env:UnitPaHub_DaisyChain_CoreInk_Arduino_latest]
380465
extends=CoreInk, option_release, arduino_latest
381466
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
382467
lib_deps = ${CoreInk.lib_deps}
383-
${unit.lib_deps}
468+
${unit_for_pa.lib_deps}
384469

385470
[env:UnitPaHub_DaisyChain_Fire_Arduino_latest]
386471
extends=Fire, option_release, arduino_latest
387472
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
388473
lib_deps = ${Fire.lib_deps}
389-
${unit.lib_deps}
474+
${unit_for_pa.lib_deps}
390475

391476
[env:UnitPaHub_DaisyChain_Fire_Arduino_5_4_0]
392477
extends=Fire, option_release, arduino_5_4_0
393478
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
394479
lib_deps = ${Fire.lib_deps}
395-
${unit.lib_deps}
480+
${unit_for_pa.lib_deps}
396481

397482
[env:UnitPaHub_DaisyChain_Fire_Arduino_4_4_0]
398483
extends=Fire, option_release, arduino_4_4_0
399484
build_src_filter = +<*> -<.git/> -<.svn/> +<../examples/UnitUnified/UnitPaHub/DaisyChain>
400485
lib_deps = ${Fire.lib_deps}
401-
${unit.lib_deps}
486+
${unit_for_pa.lib_deps}
402487

src/M5UnitUnifiedHUB.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define M5_UNIT_UNIFIED_HUB_HPP
1515

1616
#include "unit/unit_PCA9548AP.hpp"
17+
#include "unit/unit_PbHub.hpp"
1718

1819
/*!
1920
@namespace m5

src/unit/unit_PCA9548AP.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ std::shared_ptr<Adapter> UnitPCA9548AP::ensure_adapter(const uint8_t ch)
5555
m5::hal::error::error_t UnitPCA9548AP::select_channel(const uint8_t ch)
5656
{
5757
// M5_LIB_LOGV("Try current to %u => %u", _current, ch);
58-
if (ch != _current && ch < MAX_CHANNEL) {
59-
_current = 0;
60-
uint8_t buf[1] = {static_cast<uint8_t>((1U << ch) & 0xFF)};
61-
auto ret = writeWithTransaction(buf, 1);
62-
if (ret == m5::hal::error::error_t::OK) {
63-
_current = ch;
58+
if (ch < MAX_CHANNEL) {
59+
m5::hal::error::error_t ret{m5::hal::error::error_t::OK};
60+
if (ch != _current) {
61+
uint8_t buf = (1U << ch);
62+
ret = writeWithTransaction(&buf, 1);
63+
if (ret == m5::hal::error::error_t::OK) {
64+
_current = ch;
65+
}
6466
}
6567
return ret;
6668
}

src/unit/unit_PCA9548AP.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace m5 {
1717
namespace unit {
1818

1919
/*!
20-
@class UnitPCA9548AP
20+
@class m5::unit::UnitPCA9548AP
2121
@brief PCA9548AP unit
2222
*/
2323
class UnitPCA9548AP : public Component {
@@ -30,7 +30,7 @@ class UnitPCA9548AP : public Component {
3030
virtual ~UnitPCA9548AP() = default;
3131

3232
/*!
33-
Get current channel
33+
@brief Get current channel
3434
@return Channel no(0...)
3535
*/
3636
uint8_t currentChannel() const
@@ -46,8 +46,8 @@ class UnitPCA9548AP : public Component {
4646
bool readChannel(uint8_t& bits);
4747

4848
protected:
49-
virtual m5::hal::error::error_t select_channel(const uint8_t ch = 8) override;
50-
virtual std::shared_ptr<Adapter> ensure_adapter(const uint8_t /*ch*/) override;
49+
virtual m5::hal::error::error_t select_channel(const uint8_t ch) override;
50+
virtual std::shared_ptr<Adapter> ensure_adapter(const uint8_t ch) override;
5151

5252
protected:
5353
uint8_t _current{0xFF}; // current channel 0 ~ MAX_CHANNEL

0 commit comments

Comments
 (0)