Skip to content

Commit

Permalink
fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyIvan359 committed Feb 26, 2021
1 parent 5e39609 commit 3252ee0
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions mqttany/modules/i2c/device/mcp230xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __init__(

if direction == Direction.INPUT:
if resistor == Resistor.PULL_UP:
self._device._gppu = _set_bit(self._device._gppu, pin)
self._device.gppu = _set_bit(self._device.gppu, pin)
else:
self._device.iodir = _clear_bit(self._device.iodir, pin)
self.state = initial
Expand All @@ -179,13 +179,13 @@ def state(self) -> bool:
"""
Returns pin state as ``bool`` after applying invert flag
"""
return bool(_get_bit(self._device._gpio, self._pin) ^ self._invert)
return bool(_get_bit(self._device.gpio, self._pin) ^ self._invert)

@state.setter
def state(self, value: bool) -> None:
if self._direction == Direction.OUTPUT:
self._device._gpio = _set_bit(
self._device._gpio, self._pin, int(value) ^ self._invert
self._device.gpio = _set_bit(
self._device.gpio, self._pin, int(value) ^ self._invert
)

@property
Expand Down Expand Up @@ -392,9 +392,9 @@ def __init__(
self._pin_from_path: t.Dict[str, int] = {}
self._pin_max: int = 0
self._pins: t.List[Pin] = []
self._gpio: int = 0x0 # set by subclass
self._iodir: int = 0x0
self._gppu: int = 0x0
self.gpio: int = 0x0 # set by subclass
self.iodir: int = 0x0
self.gppu: int = 0x0

def get_node(self) -> BusNode:
node = super().get_node()
Expand Down Expand Up @@ -423,7 +423,7 @@ def cleanup(self) -> None:
Subclasses may override this method
"""
if self._setup:
self._gpio = 0
self.gpio = 0
for pin in self._pins:
if pin is not None:
pin.state = False # set all pins to configured OFF
Expand Down Expand Up @@ -658,9 +658,9 @@ def __init__(
self._log = logger.get_logger("i2c.mcp23008")
self._pin_max = 7
self._pins: t.List[Pin] = [None] * (self._pin_max + 1) # type: ignore
self._gpio = 0x00
self._iodir = 0xFF
self._gppu = 0x00
self.gpio = 0x00
self.iodir = 0xFF
self.gppu = 0x00
super()._build_pins(device_config)

def setup(self) -> bool:
Expand All @@ -682,16 +682,16 @@ def setup(self) -> bool:
0x00,
bytes(
[
self._iodir,
self.iodir,
0x00, # IPOL
0x00, # GPINTEN
0x00, # DEFVAL
0x00, # INTCON
0x04, # IOCON
self._gppu,
self.gppu,
0x00, # INTF
0x00, # INTCAP
self._gpio,
self.gpio,
]
),
):
Expand All @@ -702,10 +702,10 @@ def setup(self) -> bool:
def read_gpio(self) -> None:
gpio = self._read_byte(self._GPIO)
if gpio is not None:
self._gpio = gpio
self.gpio = gpio

def write_gpio(self) -> None:
self._write_byte(self._GPIO, self._gpio)
self._write_byte(self._GPIO, self.gpio)


class MCP23017(MCP230xx):
Expand Down Expand Up @@ -753,9 +753,9 @@ def __init__(
self._log = logger.get_logger("i2c.mcp23017")
self._pin_max = 15
self._pins: t.List[Pin] = [None] * (self._pin_max + 1) # type: ignore
self._gpio = 0x0000
self._iodir = 0xFFFF
self._gppu = 0x0000
self.gpio = 0x0000
self.iodir = 0xFFFF
self.gppu = 0x0000
super()._build_pins(device_config)

def setup(self) -> bool:
Expand All @@ -777,8 +777,8 @@ def setup(self) -> bool:
0x00,
bytes(
[
self._iodir & 0xFF, # IODIRA
self._iodir >> 8, # IODIRB
self.iodir & 0xFF, # IODIRA
self.iodir >> 8, # IODIRB
0x00, # IPOLA
0x00, # IPOLB
0x00, # GPINTENA
Expand All @@ -789,14 +789,14 @@ def setup(self) -> bool:
0x00, # INTCONB
0x04, # IOCON
0x04, # IOCON
self._gppu & 0xFF, # GPPUA
self._gppu >> 8, # GPPUB
self.gppu & 0xFF, # GPPUA
self.gppu >> 8, # GPPUB
0x00, # INTFA
0x00, # INTFB
0x00, # INTCAPA
0x00, # INTCAPB
self._gpio & 0xFF, # GPIOA
self._gpio >> 8, # GPIOB
self.gpio & 0xFF, # GPIOA
self.gpio >> 8, # GPIOB
]
),
):
Expand All @@ -807,10 +807,10 @@ def setup(self) -> bool:
def read_gpio(self) -> None:
gpio = self._read_word(self._GPIOA)
if gpio is not None:
self._gpio = gpio
self.gpio = gpio

def write_gpio(self) -> None:
self._write_word(self._GPIOA, self._gpio)
self._write_word(self._GPIOA, self.gpio)


SUPPORTED_DEVICES: t.Dict[str, t.Type[I2CDevice]] = {
Expand Down

0 comments on commit 3252ee0

Please sign in to comment.