# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyupm_tca9548a', [dirname(__file__)])
except ImportError:
import _pyupm_tca9548a
return _pyupm_tca9548a
if fp is not None:
try:
_mod = imp.load_module('_pyupm_tca9548a', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_tca9548a = swig_import_helper()
del swig_import_helper
else:
import _pyupm_tca9548a
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def getVersion():
return _pyupm_tca9548a.getVersion()
getVersion = _pyupm_tca9548a.getVersion
_pyupm_tca9548a.TCA9548A_I2C_BUS_swigconstant(_pyupm_tca9548a)
TCA9548A_I2C_BUS = _pyupm_tca9548a.TCA9548A_I2C_BUS
_pyupm_tca9548a.TCA9548A_DEFAULT_ADDR_swigconstant(_pyupm_tca9548a)
TCA9548A_DEFAULT_ADDR = _pyupm_tca9548a.TCA9548A_DEFAULT_ADDR
_pyupm_tca9548a.TCA9548A_NO_PORTS_swigconstant(_pyupm_tca9548a)
TCA9548A_NO_PORTS = _pyupm_tca9548a.TCA9548A_NO_PORTS
_pyupm_tca9548a.TCA9548A_ALL_PORTS_swigconstant(_pyupm_tca9548a)
TCA9548A_ALL_PORTS = _pyupm_tca9548a.TCA9548A_ALL_PORTS
_pyupm_tca9548a.TCA9548A_MIN_PORT_swigconstant(_pyupm_tca9548a)
TCA9548A_MIN_PORT = _pyupm_tca9548a.TCA9548A_MIN_PORT
_pyupm_tca9548a.TCA9548A_MAX_PORT_swigconstant(_pyupm_tca9548a)
TCA9548A_MAX_PORT = _pyupm_tca9548a.TCA9548A_MAX_PORT
[docs]class TCA9548A(_object):
"""
API TCA9548A Multiplexer Breakout.
ID: TCA9548A
Name: 1-to-8 I2C Multiplexer Breakout
Category: multiplexer
Manufacturer: adafruit
Connection: i2c
Link:https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-
multiplexer- breakout/overview The TCA9548A device has eight
bidirectional translating switches that can be controlled through the
I2C bus. The SCL/SDA upstream pair fans out to eight downstream pairs,
or channels. Any individual SCn/SDn channel or combination of channels
can be selected, determined by the contents of the programmable
control register.
The TCA9548A Multiplexer Breakout enables to get - up to 8 same-
address I2C devices hooked up to one microcontroller - or up to 8
independent I2C buses. This multiplexer acts as a gatekeeper,
shuttling the commands to the selected set of I2C pins with your
command. The TCA9548A multiplexer is interesting in that it has an I2C
address (0x70 by default) - and you basically send it a command to
tell it which I2C multiplexed output you want to talk to, then you can
address the board you want to address. You simply write a single byte
with the desired multiplexed output number to that port, and bam - any
future I2C packets will get sent to that port.
The TCA9548A Multiplexer provides three pins (A0-A1-A2) that enable to
change its address in case 0x70 address is used by another sensor on
the same bus. By connecting one of the Ax pin to Vin you change its
value from 0 to 1, these values change the value of the three first
bits of the address :
Address 0b01110-A2-A1-A0 No wiring A2=0 A1=0 A0=0 Address 0b01110000
0x70 A0 wired A2=0 A1=0 A0=1 Address 0b01110000 0x71 A2 wired A2=1
A1=0 A0=0 Address 0b01110100 0x74 Any address between 0x70 and 0x77
can be selected.
Tested with Adafriut TCA9548A board.
C++ includes: tca9548a.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, TCA9548A, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, TCA9548A, name)
__repr__ = _swig_repr
DISABLED = _pyupm_tca9548a.TCA9548A_DISABLED
ENABLED = _pyupm_tca9548a.TCA9548A_ENABLED
EXCLUSIVE = _pyupm_tca9548a.TCA9548A_EXCLUSIVE
INCLUSIVE = _pyupm_tca9548a.TCA9548A_INCLUSIVE
def __init__(self, bus, address=0x70):
"""
TCA9548A(int bus,
uint8_t address=0x70)
TCA9548A constructor
Parameters:
-----------
address.: Device address. Default is 0x70.
"""
this = _pyupm_tca9548a.new_TCA9548A(bus, address)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_tca9548a.delete_TCA9548A
__del__ = lambda self: None
[docs] def name(self):
"""
std::string name()
Returns the name of the switch
"""
return _pyupm_tca9548a.TCA9548A_name(self)
[docs] def getPort(self, port):
"""
bool getPort(int port)
Returns the status of a port as configured in the multiplexer.
Parameters:
-----------
port: Switch port to check
"""
return _pyupm_tca9548a.TCA9548A_getPort(self, port)
[docs] def setPort(self, port, state, mode):
"""
void setPort(int port,
TCA9548A_PORT_STATE state, TCA9548A_PORT_MODE mode)
Configure an individual port on the multiplexer
Parameters:
-----------
port: Port to configure
enabled: Set to true to enable the port, false to disable the port.
exclusive: Set to true to disable all other ports, false to leave
existing port config untouched. When exclusive is set to false, an
additional i2c read is required to read the current port setting.
"""
return _pyupm_tca9548a.TCA9548A_setPort(self, port, state, mode)
[docs] def disableAllPorts(self):
"""
void
disableAllPorts()
Disables all ports on the multiplexer.
"""
return _pyupm_tca9548a.TCA9548A_disableAllPorts(self)
[docs] def enableAllPorts(self):
"""
void
enableAllPorts()
Enables all ports on the multiplexer. Useful when the multiplexer is
used to electrically extend the bus rather than resolve address
conflicts.
"""
return _pyupm_tca9548a.TCA9548A_enableAllPorts(self)
TCA9548A_swigregister = _pyupm_tca9548a.TCA9548A_swigregister
TCA9548A_swigregister(TCA9548A)
# This file is compatible with both classic and new-style classes.