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
- */
16
1
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
+ */
18
13
14
+ #include < M5Unified.h>
15
+ #include < Wire.h>
19
16
#include " ClosedCube_TCA9548A.h"
20
17
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 )
27
23
28
- #define PaHub_I2C_ADDRESS 0x70
24
+ #define PaHub_I2C_ADDRESS ( 0x70 )
29
25
30
26
ClosedCube::Wired::TCA9548A tca9548a;
31
27
32
- void setup () {
28
+ void setup ()
29
+ {
33
30
M5.begin ();
34
31
M5.Power .begin ();
35
32
tca9548a.address (PaHub_I2C_ADDRESS); // Set the I2C address. 设置I2C地址
@@ -40,13 +37,15 @@ void setup() {
40
37
M5.Lcd .setTextColor (TFT_WHITE, TFT_BLACK);
41
38
}
42
39
43
- void loop () {
40
+ void loop ()
41
+ {
44
42
uint8_t returnCode = 0 ;
45
43
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地址。
46
46
for (uint8_t channel = 0 ; channel < TCA9548A_MAX_CHANNELS; channel++) {
47
47
M5.Lcd .setCursor (X_LOCAL, Y_LOCAL + Y_OFFSET * channel, FRONT);
48
- M5.Lcd .printf (
49
- " " );
48
+ M5.Lcd .printf (" " );
50
49
M5.Lcd .setCursor (X_LOCAL, Y_LOCAL + Y_OFFSET * channel, FRONT);
51
50
M5.Lcd .printf (" CH%d : " , channel);
52
51
returnCode = tca9548a.selectChannel (channel);
0 commit comments