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 86
86
QUAD_SOLID_STATE_RELAY_DEFUALT_ADDR ,
87
87
QUAD_SOLID_STATE_RELAY_JUMPER_CLOSE_ADDR ]
88
88
89
+ # Define commands for changing i2c address to
90
+ SINGLE_CHANGE_ADDRESS = 0x03
91
+ QUAD_CHANGE_ADDRESS = 0xC7
92
+
89
93
# Define the register offsets of each relay
90
94
RELAY_ONE = 1
91
95
RELAY_TWO = 2
@@ -209,6 +213,23 @@ def set_relay_on(self, relayNum=None):
209
213
# set_relay_off(relayNum)
210
214
#
211
215
# 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
212
233
213
234
def set_relay_off (self , relayNum = None ):
214
235
"""
You can’t perform that action at this time.
0 commit comments