File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 8686 QUAD_SOLID_STATE_RELAY_DEFUALT_ADDR ,
8787 QUAD_SOLID_STATE_RELAY_JUMPER_CLOSE_ADDR ]
8888
89+ # Define commands for changing i2c address to
90+ SINGLE_CHANGE_ADDRESS = 0x03
91+ QUAD_CHANGE_ADDRESS = 0xC7
92+
8993# Define the register offsets of each relay
9094RELAY_ONE = 1
9195RELAY_TWO = 2
@@ -209,6 +213,23 @@ def set_relay_on(self, relayNum=None):
209213 # set_relay_off(relayNum)
210214 #
211215 # Turn's off a specific relay number, if we're using a single relay, do not pass in a relay number.
216+
217+ def change_address (self , newAddress , singleRelay = True ):
218+ """
219+ Change the I2C address of the relay
220+
221+ :param: The new address to change to
222+ :param: If we're changing the address of a single or quad relay
223+ """
224+ if (newAddress < 0x07 ) or (newAddress > 0x78 ):
225+ return
226+
227+ if singleRelay :
228+ return self ._i2c .writeByte (self .address , SINGLE_CHANGE_ADDRESS , newAddress )
229+ else :
230+ return self ._i2c .writeByte (self .address , QUAD_CHANGE_ADDRESS , newAddress )
231+
232+ self .address = newAddress
212233
213234 def set_relay_off (self , relayNum = None ):
214235 """
You can’t perform that action at this time.
0 commit comments