Skip to content

Commit

Permalink
in my hour of deperation, chatgpt
Browse files Browse the repository at this point in the history
  • Loading branch information
DJDevon3 committed Apr 15, 2024
1 parent 393aeb8 commit e2b91c2
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions adafruit_is31fl3731/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,22 @@
try:
import typing
import busio
from circuitpython_typing import TypeAlias, Union
from circuitpython_typing import (
WriteableBuffer,
ReadableBuffer,
) # Import ReadableBuffer here

from typing import (
TYPE_CHECKING,
List,
Tuple,
Optional,
Iterable,
ReadableBuffer,
WriteableBuffer,
)

from PIL import Image

if TYPE_CHECKING:
from circuitpython_typing import ReadableBuffer, WriteableBuffer
except ImportError as e:
pass

Expand Down Expand Up @@ -124,7 +127,7 @@ def __init__(
self._frame = None
self._init(frames=frames)

def _i2c_read_reg(self, result: WriteableBuffer, reg: Optional[int] = None) -> None:
def _i2c_read_reg(self, reg: Optional[int] = None, result: Optional[int] = None):
# Read a buffer of data from the specified 8-bit I2C register address.
# The provided result parameter will be filled to capacity with bytes
# of data read from the register.
Expand All @@ -133,12 +136,14 @@ def _i2c_read_reg(self, result: WriteableBuffer, reg: Optional[int] = None) -> N
return result
return None

def _i2c_write_reg(self, data: ReadableBuffer, reg: Optional[int] = None) -> None:
def _i2c_write_reg(
self, reg: Optional[int] = None, data: Optional[ReadableBuffer] = None
) -> None:
# Write a contiguous block of data (bytearray) starting at the
# specified I2C register address (register passed as argument).
self._i2c_write_block(bytes([reg]) + data)

def _i2c_write_block(self, data: ReadableBuffer) -> None:
def _i2c_write_block(self, data: Optional[ReadableBuffer]) -> None:
# Write a buffer of data (byte array) to the specified I2C register
# address.
with self.i2c_device as i2c:
Expand Down Expand Up @@ -443,7 +448,9 @@ def image(self, img: Optional[str], frame: Optional[int], blink: bool = False):
imwidth, imheight = img.size
if imwidth != self.width or imheight != self.height:
raise ValueError(
f"Image must be same dimensions as display {self.width}x{self.height}"
"Image must be same dimensions as display ({0}x{1}).".format(
self.width, self.height
)
)
# Grab all the pixels from the image, faster than getpixel.
pixels = img.load()
Expand Down

0 comments on commit e2b91c2

Please sign in to comment.