mirror of
https://github.com/m5stack/M5Stack.git
synced 2026-05-20 10:06:46 -07:00
renletao:PaHUB_TCA9548A dependency update
This commit is contained in:
@@ -1,35 +1,32 @@
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2023 by M5Stack
|
||||
* Equipped with M5Core sample source code
|
||||
* 配套 M5Core 示例源代码
|
||||
* Visit for more information: https://docs.m5stack.com/en/unit/pahub
|
||||
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/pahub
|
||||
*
|
||||
* Describe: PaHUB.
|
||||
* Date: 2021/8/31
|
||||
*******************************************************************************
|
||||
Please connect to Port A, Use PaHUB Unit to expand multiple I2C devices and
|
||||
scan the I2C addresses of the slave devices in order. 请连接端口A, 使用PaHUB
|
||||
Unit扩展多个I2C设备,并依次扫描从设备的I2C地址。
|
||||
*/
|
||||
|
||||
#include <M5Stack.h>
|
||||
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* @Dependent Library:
|
||||
* M5GFX@^0.2.3: https://github.com/m5stack/M5GFX
|
||||
* M5Unified@^0.2.2: https://github.com/m5stack/M5Unified
|
||||
* ClosedCube_I2C_Arduino: https://github.com/HariMurti12/ClosedCube_I2C_Arduino
|
||||
* ClosedCube_TCA9548A_Arduino: https://github.com/blacksn0w13/ClosedCube_TCA9548A_Arduino
|
||||
*/
|
||||
|
||||
#include <M5Unified.h>
|
||||
#include <Wire.h>
|
||||
#include "ClosedCube_TCA9548A.h"
|
||||
|
||||
#define FRONT 2
|
||||
#define FRONT (2)
|
||||
#define X_LOCAL (100)
|
||||
#define Y_LOCAL (35)
|
||||
#define X_OFFSET (160)
|
||||
#define Y_OFFSET (34)
|
||||
|
||||
#define X_LOCAL 100
|
||||
#define Y_LOCAL 35
|
||||
#define X_OFFSET 160
|
||||
#define Y_OFFSET 34
|
||||
|
||||
#define PaHub_I2C_ADDRESS 0x70
|
||||
#define PaHub_I2C_ADDRESS (0x70)
|
||||
|
||||
ClosedCube::Wired::TCA9548A tca9548a;
|
||||
|
||||
void setup() {
|
||||
void setup()
|
||||
{
|
||||
M5.begin();
|
||||
M5.Power.begin();
|
||||
tca9548a.address(PaHub_I2C_ADDRESS); // Set the I2C address. 设置I2C地址
|
||||
@@ -40,13 +37,15 @@ void setup() {
|
||||
M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
void loop()
|
||||
{
|
||||
uint8_t returnCode = 0;
|
||||
uint8_t address;
|
||||
// Please connect to Port A, Use PaHUB Unit to expand multiple I2C devices and scan the I2C addresses of the slave
|
||||
// devices in order. 请连接端口A, 使用PaHUB Unit扩展多个I2C设备,并依次扫描从设备的I2C地址。
|
||||
for (uint8_t channel = 0; channel < TCA9548A_MAX_CHANNELS; channel++) {
|
||||
M5.Lcd.setCursor(X_LOCAL, Y_LOCAL + Y_OFFSET * channel, FRONT);
|
||||
M5.Lcd.printf(
|
||||
" ");
|
||||
M5.Lcd.printf(" ");
|
||||
M5.Lcd.setCursor(X_LOCAL, Y_LOCAL + Y_OFFSET * channel, FRONT);
|
||||
M5.Lcd.printf("CH%d : ", channel);
|
||||
returnCode = tca9548a.selectChannel(channel);
|
||||
|
||||
Reference in New Issue
Block a user