6767# Some devices have multiple availabel addresses - this is a list of these addresses (0x70 - 0x77).
6868# NOTE: The first address in this list is considered the default I2C address for the
6969# device (0x70).
70- _AVAILABLE_I2C_ADDRESS = [ * range (0x70 ,0x77 + 1 )]
70+ _AVAILABLE_I2C_ADDRESS = range (0x70 ,0x77 + 1 )
7171
7272class QwiicTCA9548A (object ):
7373 """
@@ -94,7 +94,7 @@ class QwiicTCA9548A(object):
9494
9595 #----------------------------------------------
9696 # Available Channels:
97- available_channels = [ * range (0 ,7 + 1 )]
97+ available_channels = range (0 ,7 + 1 )
9898
9999 #----------------------------------------------
100100 # Constructor
@@ -150,6 +150,15 @@ def is_connected(self):
150150
151151 connected = property (is_connected )
152152
153+ def get_enabled_channels (self ):
154+ """
155+ This method returns the enabled channels on the Qwiic Mux.
156+ :return: Enabled channels on the Qwiic Mux
157+ :rtype: Integer
158+ """
159+
160+ # Return enabled channels
161+ return self ._i2c .readByte (self .address , None ) # Note, passing "None" will simply read from device rather than targetting a specific register
153162
154163 def enable_channels (self , enable ):
155164 """
@@ -161,8 +170,7 @@ def enable_channels(self, enable):
161170 an individual integer into a list.
162171 Range- 0 to 7
163172 """
164- command = self ._i2c .readByte (self .address )
165-
173+ command = self .get_enabled_channels ()
166174 # If entry is an integer and not a list; turn it into a list of (1)
167175 if type (enable ) is not list : enable = [ enable ]
168176
@@ -188,7 +196,7 @@ def disable_channels(self, disable):
188196 convert an individual integer into a list.
189197 Range- 0 to 7
190198 """
191- command = self ._i2c . readByte ( self . address )
199+ command = self .get_enabled_channels ( )
192200
193201 # If entry is an integer and not a list; turn it into a list of (1)
194202 if type (disable ) is not list : disable = [ disable ]
@@ -229,7 +237,7 @@ def list_channels(self):
229237 configuration (enabled or disabled) on the Qwiic Mux.
230238 """
231239
232- enabled_channels = self ._i2c . readByte ( self . address )
240+ enabled_channels = self .get_enabled_channels ( )
233241
234242 for x in self .available_channels :
235243 if (enabled_channels & (1 << x )) >> x == 0 :
0 commit comments