Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add isConnected(address, channel) #19

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.2.2] - 2024-01-01
- add **bool isConnected(uint8_t address, uint8_t channel)**
- minor edits


## [0.2.1] - 2023-12-09
- add derived classes
- PCA9543 (2 channel), PCA9545 (4 channel), PCA9546 (4 channel)
- add **uint8_t getInterruptMask()**
- fix begin() : remove wire-> begin() as dependency should be outside lib
- fix readme.md


## [0.2.0] - 2023-12-09
- refactor API, begin()
- update readme.md
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2023 Rob Tillaart
Copyright (c) 2021-2024 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ There are however small differences, check the data sheets to see the details.
deviceAddress = 0x70 .. 0x77, wire = Wire or WireN.
- **bool begin(uint8_t mask = 0x00)** set mask of channels to be enabled, default all disabled.
- **bool isConnected()** returns true if address of the multiplexer is found on I2C bus.

- **bool isConnected(uint8_t address, uint8_t channel)** find address on selected channel.
Note that this changes the selected and or enabled channels.
Returns true if found.

The derived classes PCA9548/PCA9546 have the same interface, except constructor.
(see #15)
Expand Down
9 changes: 8 additions & 1 deletion TCA9548.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: TCA9548.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.1
// VERSION: 0.2.2
// DATE: 2021-03-16
// PURPOSE: Arduino Library for TCA9548 I2C multiplexer and compatibles.

Expand Down Expand Up @@ -42,6 +42,13 @@ bool TCA9548::isConnected(uint8_t address)
}


bool TCA9548::isConnected(uint8_t address, uint8_t channel)
{
if (!selectChannel(channel)) return false;
return isConnected(_address);
}


uint8_t TCA9548::channelCount()
{
return _channels;
Expand Down
8 changes: 4 additions & 4 deletions TCA9548.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: TCA9548.h
// AUTHOR: Rob Tillaart
// VERSION: 0.2.1
// VERSION: 0.2.2
// DATE: 2021-03-16
// PURPOSE: Arduino Library for TCA9548 I2C multiplexer and compatibles.
// URL: https://github.com/RobTillaart/TCA9548
Expand All @@ -12,7 +12,7 @@
#include "Wire.h"


#define TCA9548_LIB_VERSION (F("0.2.1"))
#define TCA9548_LIB_VERSION (F("0.2.2"))


// ERROR CODES (to be elaborated)
Expand All @@ -31,7 +31,7 @@ class TCA9548
bool begin(uint8_t mask = 0x00); // default no channels enabled
bool isConnected(); // find multiplexer on I2C bus
bool isConnected(uint8_t address); // find any address on I2C bus

bool isConnected(uint8_t address, uint8_t channel); // find address on selected channel

// channel = 0..channelCount()-1
uint8_t channelCount();
Expand Down Expand Up @@ -95,7 +95,7 @@ class PCA9546 : public TCA9548
};


// DEVICES WITH INTERRUPT
// DEVICES WITH INTERRUPT

// SWITCH, 4 channel + reset + interrupt
class PCA9545 : public TCA9548
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/TCA9548"
},
"version": "0.2.1",
"version": "0.2.2",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TCA9548
version=0.2.1
version=0.2.2
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino Library for TCA9548 I2C multiplexer and compatibles.
Expand Down
Loading