precommit fixes
This commit is contained in:
parent
cba9337368
commit
80de98b28c
4 changed files with 868 additions and 293 deletions
|
|
@ -16,12 +16,10 @@
|
|||
"""
|
||||
|
||||
# pylint: disable=ungrouped-imports
|
||||
import sys
|
||||
from is31fl3741 import is31fl3741_write
|
||||
from adafruit_register.i2c_struct import ROUnaryStruct, UnaryStruct
|
||||
from adafruit_register.i2c_struct import UnaryStruct
|
||||
from adafruit_register.i2c_bit import RWBit
|
||||
from adafruit_bus_device import i2c_device
|
||||
import time
|
||||
|
||||
try:
|
||||
import adafruit_pixelbuf
|
||||
|
|
@ -36,12 +34,13 @@ try:
|
|||
# Used only for typing
|
||||
from typing import Optional, Type
|
||||
from types import TracebackType
|
||||
import busio
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
__version__ = "0.0.0-auto.0"
|
||||
#__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741.git"
|
||||
# __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741.git"
|
||||
|
||||
|
||||
# Pixel color order constants
|
||||
|
|
@ -66,13 +65,15 @@ _IS3741_FUNCREG_CONFIG = 0x00
|
|||
_IS3741_FUNCREG_GCURRENT = 0x01
|
||||
_IS3741_FUNCREG_RESET = 0x3F
|
||||
|
||||
|
||||
class IS31FL3741_PixelBuf(adafruit_pixelbuf.PixelBuf):
|
||||
"""
|
||||
A sequence of LEDs controlled by an IS31FL3741 driver.
|
||||
|
||||
:param ~busio.I2C i2c: the I2C bus to output with
|
||||
:param ~int addr: the I2C address of the IS31FL3741 device
|
||||
:param ~Tuple[int, ...] mapping: map the pixels in the buffer to the order addressed by the driver chip
|
||||
:param ~Tuple[int, ...] mapping: map the pixels in the buffer to the order addressed
|
||||
by the driver chip
|
||||
:param int n: The number of neopixels in the chain
|
||||
:param int bpp: Bytes per pixel. 3 for RGB and 4 for RGBW pixels.
|
||||
:param float brightness: Brightness of the pixels between 0.0 and 1.0 where 1.0 is full
|
||||
|
|
@ -134,7 +135,7 @@ class IS31FL3741_PixelBuf(adafruit_pixelbuf.PixelBuf):
|
|||
self.i2c = i2c
|
||||
self.i2c_device = i2c_device.I2CDevice(i2c, addr)
|
||||
self.addr = addr
|
||||
if type(mapping) is not tuple:
|
||||
if not isinstance(mapping, tuple):
|
||||
raise AttributeError("Mapping must be a tuple")
|
||||
self.mapping = mapping
|
||||
|
||||
|
|
@ -181,11 +182,11 @@ class IS31FL3741_PixelBuf(adafruit_pixelbuf.PixelBuf):
|
|||
|
||||
self._lock_reg = 0xC5
|
||||
self._page_reg = 4
|
||||
self._gcurrent_reg = 0xFE # Set global current to max
|
||||
self._gcurrent_reg = 0xFE # Set global current to max
|
||||
|
||||
self._lock_reg = 0xC5
|
||||
self._page_reg = 4
|
||||
self._shutdown_bit = True # Enable driver chip
|
||||
self._shutdown_bit = True # Enable driver chip
|
||||
|
||||
@property
|
||||
def n(self) -> int:
|
||||
|
|
@ -201,4 +202,6 @@ class IS31FL3741_PixelBuf(adafruit_pixelbuf.PixelBuf):
|
|||
self.show()
|
||||
|
||||
def _transmit(self, buffer: bytearray) -> None:
|
||||
is31fl3741_write(i2c=self.i2c, addr=self.addr, mapping=self.mapping, buffer=buffer)
|
||||
is31fl3741_write(
|
||||
i2c=self.i2c, addr=self.addr, mapping=self.mapping, buffer=buffer
|
||||
)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -7,10 +7,14 @@ import board
|
|||
import busio
|
||||
from adafruit_display_text import label
|
||||
from adafruit_bitmap_font import bitmap_font
|
||||
from adafruit_is31fl3741.is31fl3741_PixelBuf import IS31FL3741_PixelBuf
|
||||
from adafruit_is31fl3741.led_glasses_map import glassesmatrix_ledmap, glassesmatrix_ledmap_no_ring, left_ring_map_no_inner, right_ring_map_no_inner
|
||||
from adafruit_led_animation.animation.comet import Comet
|
||||
from adafruit_led_animation.animation.chase import Chase
|
||||
from adafruit_is31fl3741.is31fl3741_PixelBuf import IS31FL3741_PixelBuf
|
||||
from adafruit_is31fl3741.led_glasses_map import (
|
||||
glassesmatrix_ledmap_no_ring,
|
||||
left_ring_map_no_inner,
|
||||
right_ring_map_no_inner,
|
||||
)
|
||||
|
||||
# Release any existing displays
|
||||
displayio.release_displays()
|
||||
|
|
@ -19,24 +23,35 @@ displayio.release_displays()
|
|||
i2c = busio.I2C(board.SCL, board.SDA, frequency=1000000)
|
||||
|
||||
# Initialize the IS31FL3741 displayio display
|
||||
is31 = is31fl3741.IS31FL3741(width=54, height=15, i2c=i2c, scale=True, gamma=True, mapping=glassesmatrix_ledmap_no_ring)
|
||||
is31 = is31fl3741.IS31FL3741(
|
||||
width=54,
|
||||
height=15,
|
||||
i2c=i2c,
|
||||
scale=True,
|
||||
gamma=True,
|
||||
mapping=glassesmatrix_ledmap_no_ring,
|
||||
)
|
||||
display = framebufferio.FramebufferDisplay(is31, auto_refresh=True)
|
||||
|
||||
# Turn the brightness down
|
||||
is31.brightness = 0.1
|
||||
|
||||
# Create pixel buffers for each eye. Init is False as the display setup initialized the chip
|
||||
eye_left = IS31FL3741_PixelBuf(i2c, left_ring_map_no_inner, 24, init=False, auto_write=False)
|
||||
eye_right = IS31FL3741_PixelBuf(i2c, right_ring_map_no_inner, 24, init=False, auto_write=False)
|
||||
eye_left = IS31FL3741_PixelBuf(
|
||||
i2c, left_ring_map_no_inner, 24, init=False, auto_write=False
|
||||
)
|
||||
eye_right = IS31FL3741_PixelBuf(
|
||||
i2c, right_ring_map_no_inner, 24, init=False, auto_write=False
|
||||
)
|
||||
|
||||
# Create a different animation for each eye ring
|
||||
chase = Chase(eye_left, speed=0.05, color=(0,0,150), size=8, spacing=4)
|
||||
comet = Comet(eye_right, speed=0.01, color=(0,0,150), tail_length=10, bounce=False)
|
||||
chase = Chase(eye_left, speed=0.05, color=(0, 0, 150), size=8, spacing=4)
|
||||
comet = Comet(eye_right, speed=0.01, color=(0, 0, 150), tail_length=10, bounce=False)
|
||||
|
||||
# Create text to scroll across the display
|
||||
font = bitmap_font.load_font("scrolly.bdf")
|
||||
text = "HELLO FROM CIRCUITPYTHON ON NATIVE DISPLAYIO"
|
||||
color = (255,210,0)
|
||||
color = (255, 210, 0)
|
||||
text_area = label.Label(font, text=text, color=color)
|
||||
|
||||
# Set the text location
|
||||
|
|
|
|||
2
examples/scrolly.bdf.license
Normal file
2
examples/scrolly.bdf.license
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# SPDX-FileCopyrightText: 2022 Mark Komus
|
||||
# SPDX-License-Identifier: MIT
|
||||
Loading…
Reference in a new issue