@@ -160,7 +160,9 @@ def enable(self) -> None:
160
160
"""Enable this channel"""
161
161
config = self ._device ._read_register (CONFIGURATION , 2 )
162
162
config_value = (config [0 ] << 8 ) | config [1 ]
163
- config_value |= 1 << (14 - self ._channel ) # Set the bit for the specific channel
163
+ config_value |= 1 << (
164
+ 14 - self ._channel
165
+ ) # Set the bit for the specific channel
164
166
high_byte = (config_value >> 8 ) & 0xFF
165
167
low_byte = config_value & 0xFF
166
168
self ._device ._write_register (CONFIGURATION , bytes ([high_byte , low_byte ]))
@@ -177,10 +179,14 @@ def bus_voltage(self) -> float:
177
179
@property
178
180
def shunt_voltage (self ) -> float :
179
181
"""Shunt voltage in millivolts."""
180
- reg_address = [SHUNTVOLTAGE_CH1 , SHUNTVOLTAGE_CH2 , SHUNTVOLTAGE_CH3 ][self ._channel ]
182
+ reg_address = [SHUNTVOLTAGE_CH1 , SHUNTVOLTAGE_CH2 , SHUNTVOLTAGE_CH3 ][
183
+ self ._channel
184
+ ]
181
185
result = self ._device ._read_register (reg_address , 2 )
182
186
raw_value = int .from_bytes (result , "big" )
183
- raw_value = raw_value - 0x10000 if raw_value & 0x8000 else raw_value # convert to signed int16
187
+ raw_value = (
188
+ raw_value - 0x10000 if raw_value & 0x8000 else raw_value
189
+ ) # convert to signed int16
184
190
return (raw_value >> 3 ) * 40e-6
185
191
186
192
@property
@@ -246,7 +252,9 @@ def warning_alert_threshold(self, current: float) -> None:
246
252
class INA3221 :
247
253
"""Driver for the INA3221 device with three channels."""
248
254
249
- def __init__ (self , i2c , address : int = DEFAULT_ADDRESS , enable : List = [0 ,1 ,2 ]) -> None :
255
+ def __init__ (
256
+ self , i2c , address : int = DEFAULT_ADDRESS , enable : List = [0 , 1 , 2 ]
257
+ ) -> None :
250
258
"""Initializes the INA3221 class over I2C
251
259
Args:
252
260
i2c (I2C): The I2C bus to which the INA3221 is connected.
@@ -255,7 +263,9 @@ def __init__(self, i2c, address: int = DEFAULT_ADDRESS, enable: List = [0,1,2])
255
263
self .i2c_dev = I2CDevice (i2c , address )
256
264
self .reset ()
257
265
258
- self .channels : List [INA3221Channel ] = [INA3221Channel (self , i ) for i in range (3 )]
266
+ self .channels : List [INA3221Channel ] = [
267
+ INA3221Channel (self , i ) for i in range (3 )
268
+ ]
259
269
for i in enable :
260
270
self .channels [i ].enable ()
261
271
self .mode : int = MODE .SHUNT_BUS_CONT
@@ -439,7 +449,9 @@ def summation_channels(self) -> tuple:
439
449
@summation_channels .setter
440
450
def summation_channels (self , channels : tuple ) -> None :
441
451
if len (channels ) != 3 :
442
- raise ValueError ("Must pass a tuple of three boolean values (ch1, ch2, ch3)" )
452
+ raise ValueError (
453
+ "Must pass a tuple of three boolean values (ch1, ch2, ch3)"
454
+ )
443
455
ch1 , ch2 , ch3 = channels
444
456
scc_value = (ch1 << 2 ) | (ch2 << 1 ) | (ch3 << 0 )
445
457
result = self ._read_register (MASK_ENABLE , 2 )
0 commit comments