Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nkpro2000sr authored and bessman committed Aug 2, 2021
1 parent ddfcf44 commit f81ed36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions pslab/bus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(SPI and UART still TODO)
"""

from pslab.bus.i2c import I2CMaster, I2CSlave

__all__ = (
Expand Down
1 change: 1 addition & 0 deletions pslab/bus/busio.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
>>> sensor = adafruit_bno055.BNO055_I2C(i2c)
>>> print(sensor.gyro)
"""

from typing import List, Union

from pslab.bus.i2c import I2CPrimitive
Expand Down
5 changes: 5 additions & 0 deletions pslab/bus/i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
>>> rtc = I2CSlave(address=104)
"""

import logging
from typing import List

Expand Down Expand Up @@ -385,6 +386,7 @@ def _read(self, bytes_to_read: int) -> bytearray:

for _ in range(bytes_to_read - 1):
data.append(self._read_more())

data.append(self._read_end())

return data
Expand Down Expand Up @@ -513,6 +515,7 @@ def ping(self) -> bool:
"""
response = self._start(self.address, self._READ)
self._stop()

return response == self._ACK

def read(self, bytes_to_read: int, register_address: int = 0x0) -> bytearray:
Expand Down Expand Up @@ -572,6 +575,7 @@ def read_int(self, register_address: int = 0x0) -> int:
Two bytes interpreted as a uint16.
"""
data = self.read(2, register_address)

return CP.ShortInt.unpack(data)[0]

def read_long(self, register_address: int = 0x0) -> int:
Expand All @@ -589,6 +593,7 @@ def read_long(self, register_address: int = 0x0) -> int:
Four bytes interpreted as a uint32.
"""
data = self.read(4, register_address)

return CP.Integer.unpack(data)[0]

def write(self, bytes_to_write: bytearray, register_address: int = 0x0):
Expand Down

0 comments on commit f81ed36

Please sign in to comment.