1- /*
2- *******************************************************************************
3- * Copyright (c) 2023 by M5Stack
4- * Equipped with M5Core sample source code
5- * 配套 M5Core 示例源代码
6- * Visit for more information: https://docs.m5stack.com/en/unit/pahub
7- * 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/pahub
8- *
9- * Describe: PaHUB.
10- * Date: 2021/8/31
11- *******************************************************************************
12- Please connect to Port A, Use PaHUB Unit to expand multiple I2C devices and
13- scan the I2C addresses of the slave devices in order. 请连接端口A, 使用PaHUB
14- Unit扩展多个I2C设备,并依次扫描从设备的I2C地址。
15- */
161
17- #include < M5Stack.h>
2+ /*
3+ * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
4+ *
5+ * SPDX-License-Identifier: MIT
6+ *
7+ * @Dependent Library:
8+ * M5GFX@^0.2.3: https://github.com/m5stack/M5GFX
9+ * M5Unified@^0.2.2: https://github.com/m5stack/M5Unified
10+ * ClosedCube_I2C_Arduino: https://github.com/HariMurti12/ClosedCube_I2C_Arduino
11+ * ClosedCube_TCA9548A_Arduino: https://github.com/blacksn0w13/ClosedCube_TCA9548A_Arduino
12+ */
1813
14+ #include < M5Unified.h>
15+ #include < Wire.h>
1916#include " ClosedCube_TCA9548A.h"
2017
21- #define FRONT 2
22-
23- #define X_LOCAL 100
24- #define Y_LOCAL 35
25- #define X_OFFSET 160
26- #define Y_OFFSET 34
18+ #define FRONT (2 )
19+ #define X_LOCAL (100 )
20+ #define Y_LOCAL (35 )
21+ #define X_OFFSET (160 )
22+ #define Y_OFFSET (34 )
2723
28- #define PaHub_I2C_ADDRESS 0x70
24+ #define PaHub_I2C_ADDRESS ( 0x70 )
2925
3026ClosedCube::Wired::TCA9548A tca9548a;
3127
32- void setup () {
28+ void setup ()
29+ {
3330 M5.begin ();
3431 M5.Power .begin ();
3532 tca9548a.address (PaHub_I2C_ADDRESS); // Set the I2C address. 设置I2C地址
@@ -40,13 +37,15 @@ void setup() {
4037 M5.Lcd .setTextColor (TFT_WHITE, TFT_BLACK);
4138}
4239
43- void loop () {
40+ void loop ()
41+ {
4442 uint8_t returnCode = 0 ;
4543 uint8_t address;
44+ // Please connect to Port A, Use PaHUB Unit to expand multiple I2C devices and scan the I2C addresses of the slave
45+ // devices in order. 请连接端口A, 使用PaHUB Unit扩展多个I2C设备,并依次扫描从设备的I2C地址。
4646 for (uint8_t channel = 0 ; channel < TCA9548A_MAX_CHANNELS; channel++) {
4747 M5.Lcd .setCursor (X_LOCAL, Y_LOCAL + Y_OFFSET * channel, FRONT);
48- M5.Lcd .printf (
49- " " );
48+ M5.Lcd .printf (" " );
5049 M5.Lcd .setCursor (X_LOCAL, Y_LOCAL + Y_OFFSET * channel, FRONT);
5150 M5.Lcd .printf (" CH%d : " , channel);
5251 returnCode = tca9548a.selectChannel (channel);
0 commit comments