Skip to content

Commit fd30159

Browse files
committed
run black
1 parent 68add87 commit fd30159

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

adafruit_ina3221.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ def enable(self) -> None:
160160
"""Enable this channel"""
161161
config = self._device._read_register(CONFIGURATION, 2)
162162
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
164166
high_byte = (config_value >> 8) & 0xFF
165167
low_byte = config_value & 0xFF
166168
self._device._write_register(CONFIGURATION, bytes([high_byte, low_byte]))
@@ -177,10 +179,14 @@ def bus_voltage(self) -> float:
177179
@property
178180
def shunt_voltage(self) -> float:
179181
"""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+
]
181185
result = self._device._read_register(reg_address, 2)
182186
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
184190
return (raw_value >> 3) * 40e-6
185191

186192
@property
@@ -246,7 +252,9 @@ def warning_alert_threshold(self, current: float) -> None:
246252
class INA3221:
247253
"""Driver for the INA3221 device with three channels."""
248254

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:
250258
"""Initializes the INA3221 class over I2C
251259
Args:
252260
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])
255263
self.i2c_dev = I2CDevice(i2c, address)
256264
self.reset()
257265

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+
]
259269
for i in enable:
260270
self.channels[i].enable()
261271
self.mode: int = MODE.SHUNT_BUS_CONT
@@ -439,7 +449,9 @@ def summation_channels(self) -> tuple:
439449
@summation_channels.setter
440450
def summation_channels(self, channels: tuple) -> None:
441451
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+
)
443455
ch1, ch2, ch3 = channels
444456
scc_value = (ch1 << 2) | (ch2 << 1) | (ch3 << 0)
445457
result = self._read_register(MASK_ENABLE, 2)

0 commit comments

Comments
 (0)