use ruff, correct homepage url in pyproject.toml
This commit is contained in:
parent
7d593464e8
commit
6043a1fa3f
25 changed files with 261 additions and 217 deletions
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
.py text eol=lf
|
||||
.rst text eol=lf
|
||||
.txt text eol=lf
|
||||
.yaml text eol=lf
|
||||
.toml text eol=lf
|
||||
.license text eol=lf
|
||||
.md text eol=lf
|
||||
|
|
@ -1,42 +1,21 @@
|
|||
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
|
||||
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/python/black
|
||||
rev: 23.3.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/fsfe/reuse-tool
|
||||
rev: v1.1.2
|
||||
hooks:
|
||||
- id: reuse
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.4.0
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: check-yaml
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/pycqa/pylint
|
||||
rev: v2.17.4
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.3.4
|
||||
hooks:
|
||||
- id: pylint
|
||||
name: pylint (library code)
|
||||
types: [python]
|
||||
args:
|
||||
- --disable=consider-using-f-string,duplicate-code
|
||||
exclude: "^(docs/|examples/|tests/|setup.py$)"
|
||||
- id: pylint
|
||||
name: pylint (example code)
|
||||
description: Run pylint rules on "examples/*.py" files
|
||||
types: [python]
|
||||
files: "^examples/"
|
||||
args:
|
||||
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code
|
||||
- id: pylint
|
||||
name: pylint (test code)
|
||||
description: Run pylint rules on "tests/*.py" files
|
||||
types: [python]
|
||||
files: "^tests/"
|
||||
args:
|
||||
- --disable=missing-docstring,consider-using-f-string,duplicate-code
|
||||
- id: ruff-format
|
||||
- id: ruff
|
||||
args: ["--fix"]
|
||||
- repo: https://github.com/fsfe/reuse-tool
|
||||
rev: v3.0.1
|
||||
hooks:
|
||||
- id: reuse
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ Introduction
|
|||
:target: https://github.com/adafruit/Adafruit_CircuitPython_PyBadger/actions/
|
||||
:alt: Build Status
|
||||
|
||||
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
||||
:target: https://github.com/psf/black
|
||||
:alt: Code Style: Black
|
||||
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
||||
:target: https://github.com/astral-sh/ruff
|
||||
:alt: Code Style: Ruff
|
||||
|
||||
Badge-focused CircuitPython helper library for PyBadge, PyBadge LC, PyGamer, CLUE, and Mag Tag.
|
||||
|
||||
|
|
|
|||
|
|
@ -26,13 +26,15 @@ Implementation Notes
|
|||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
import board
|
||||
import audiopwmio
|
||||
import keypad
|
||||
import adafruit_lsm6ds.lsm6ds33
|
||||
|
||||
import adafruit_lsm6ds.lsm6ds3trc
|
||||
import adafruit_lsm6ds.lsm6ds33
|
||||
import audiopwmio
|
||||
import board
|
||||
import keypad
|
||||
import neopixel
|
||||
from adafruit_pybadger.pybadger_base import PyBadgerBase, KeyStates
|
||||
|
||||
from adafruit_pybadger.pybadger_base import KeyStates, PyBadgerBase
|
||||
|
||||
__version__ = "0.0.0+auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
|
||||
|
|
@ -84,9 +86,7 @@ class Clue(PyBadgerBase):
|
|||
print("Button B")
|
||||
"""
|
||||
self._buttons.update()
|
||||
button_values = tuple(
|
||||
self._buttons.was_pressed(i) for i in range(self._keys.key_count)
|
||||
)
|
||||
button_values = tuple(self._buttons.was_pressed(i) for i in range(self._keys.key_count))
|
||||
return Buttons(button_values[0], button_values[1])
|
||||
|
||||
@property
|
||||
|
|
@ -101,5 +101,5 @@ class Clue(PyBadgerBase):
|
|||
light = _unsupported
|
||||
|
||||
|
||||
clue = Clue() # pylint: disable=invalid-name
|
||||
clue = Clue()
|
||||
"""Object that is automatically created on import."""
|
||||
|
|
|
|||
|
|
@ -27,17 +27,18 @@ Implementation Notes
|
|||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
import board
|
||||
import digitalio
|
||||
import analogio
|
||||
import busio
|
||||
import audiopwmio
|
||||
import keypad
|
||||
from adafruit_gizmo import tft_gizmo
|
||||
import adafruit_lis3dh
|
||||
import neopixel
|
||||
from adafruit_pybadger.pybadger_base import PyBadgerBase, KeyStates
|
||||
|
||||
import adafruit_lis3dh
|
||||
import analogio
|
||||
import audiopwmio
|
||||
import board
|
||||
import busio
|
||||
import digitalio
|
||||
import keypad
|
||||
import neopixel
|
||||
from adafruit_gizmo import tft_gizmo
|
||||
|
||||
from adafruit_pybadger.pybadger_base import KeyStates, PyBadgerBase
|
||||
|
||||
__version__ = "0.0.0+auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
|
||||
|
|
@ -91,9 +92,7 @@ class CPB_Gizmo(PyBadgerBase):
|
|||
print("Button B")
|
||||
"""
|
||||
self._buttons.update()
|
||||
button_values = tuple(
|
||||
self._buttons.was_pressed(i) for i in range(self._keys.key_count)
|
||||
)
|
||||
button_values = tuple(self._buttons.was_pressed(i) for i in range(self._keys.key_count))
|
||||
return Buttons(button_values[0], button_values[1])
|
||||
|
||||
@property
|
||||
|
|
@ -106,5 +105,5 @@ class CPB_Gizmo(PyBadgerBase):
|
|||
# NotImplementedError raised in the property above.
|
||||
|
||||
|
||||
cpb_gizmo = CPB_Gizmo() # pylint: disable=invalid-name
|
||||
cpb_gizmo = CPB_Gizmo()
|
||||
"""Object that is automatically created on import."""
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ Implementation Notes
|
|||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
import board
|
||||
import neopixel
|
||||
from adafruit_pybadger.pybadger_base import PyBadgerBase
|
||||
|
||||
from adafruit_pybadger.pybadger_base import PyBadgerBase
|
||||
|
||||
__version__ = "0.0.0+auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
|
||||
|
|
@ -81,5 +82,5 @@ class MagTag(PyBadgerBase):
|
|||
button = _unsupported
|
||||
|
||||
|
||||
magtag = MagTag() # pylint: disable=invalid-name
|
||||
magtag = MagTag()
|
||||
"""Object that is automatically created on import."""
|
||||
|
|
|
|||
|
|
@ -26,11 +26,12 @@ Implementation Notes
|
|||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
import board
|
||||
import audioio
|
||||
import keypad
|
||||
from adafruit_pybadger.pybadger_base import PyBadgerBase, KeyStates
|
||||
|
||||
import audioio
|
||||
import board
|
||||
import keypad
|
||||
|
||||
from adafruit_pybadger.pybadger_base import KeyStates, PyBadgerBase
|
||||
|
||||
__version__ = "0.0.0+auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
|
||||
|
|
@ -80,9 +81,7 @@ class PewPewM4(PyBadgerBase):
|
|||
print("Button O")
|
||||
"""
|
||||
self._buttons.update()
|
||||
button_values = tuple(
|
||||
self._buttons.was_pressed(i) for i in range(self._keys.key_count)
|
||||
)
|
||||
button_values = tuple(self._buttons.was_pressed(i) for i in range(self._keys.key_count))
|
||||
return Buttons(
|
||||
button_values[0],
|
||||
button_values[1],
|
||||
|
|
@ -106,5 +105,5 @@ class PewPewM4(PyBadgerBase):
|
|||
pixels = _unsupported
|
||||
|
||||
|
||||
pewpewm4 = PewPewM4() # pylint: disable=invalid-name
|
||||
pewpewm4 = PewPewM4()
|
||||
"""Object that is automatically created on import."""
|
||||
|
|
|
|||
|
|
@ -31,15 +31,16 @@ Implementation Notes
|
|||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
import board
|
||||
import digitalio
|
||||
|
||||
import adafruit_lis3dh
|
||||
import analogio
|
||||
import audioio
|
||||
import board
|
||||
import digitalio
|
||||
import keypad
|
||||
import adafruit_lis3dh
|
||||
import neopixel
|
||||
from adafruit_pybadger.pybadger_base import PyBadgerBase, KeyStates
|
||||
|
||||
from adafruit_pybadger.pybadger_base import KeyStates, PyBadgerBase
|
||||
|
||||
__version__ = "0.0.0+auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
|
||||
|
|
@ -75,12 +76,10 @@ class PyBadge(PyBadgerBase):
|
|||
break
|
||||
|
||||
# PyBadge LC doesn't have accelerometer
|
||||
if int(0x18) in _i2c_devices or int(0x19) in _i2c_devices:
|
||||
if 0x18 in _i2c_devices or 0x19 in _i2c_devices:
|
||||
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
|
||||
try:
|
||||
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(
|
||||
i2c, address=0x19, int1=int1
|
||||
)
|
||||
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1)
|
||||
except ValueError:
|
||||
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
|
||||
|
||||
|
|
@ -122,9 +121,7 @@ class PyBadge(PyBadgerBase):
|
|||
|
||||
"""
|
||||
self._buttons.update()
|
||||
button_values = tuple(
|
||||
self._buttons.was_pressed(i) for i in range(self._keys.key_count)
|
||||
)
|
||||
button_values = tuple(self._buttons.was_pressed(i) for i in range(self._keys.key_count))
|
||||
return Buttons(
|
||||
button_values[0],
|
||||
button_values[1],
|
||||
|
|
@ -137,5 +134,5 @@ class PyBadge(PyBadgerBase):
|
|||
)
|
||||
|
||||
|
||||
pybadge = PyBadge() # pylint: disable=invalid-name
|
||||
pybadge = PyBadge()
|
||||
"""Object that is automatically created on import."""
|
||||
|
|
|
|||
|
|
@ -29,19 +29,19 @@ Implementation Notes
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
import time
|
||||
import array
|
||||
import math
|
||||
import time
|
||||
|
||||
import adafruit_miniqr
|
||||
import board
|
||||
from micropython import const
|
||||
import digitalio
|
||||
from adafruit_bitmap_font import bitmap_font
|
||||
import displayio
|
||||
import terminalio
|
||||
from adafruit_bitmap_font import bitmap_font
|
||||
from adafruit_display_shapes.rect import Rect
|
||||
from adafruit_display_text import bitmap_label as label
|
||||
import terminalio
|
||||
import adafruit_miniqr
|
||||
from micropython import const
|
||||
|
||||
AUDIO_ENABLED = False
|
||||
try:
|
||||
|
|
@ -63,9 +63,10 @@ except ImportError:
|
|||
TYPE_CHECKING = const(0)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Union, Tuple, Optional, Generator
|
||||
from adafruit_bitmap_font.bdf import BDF # pylint: disable=ungrouped-imports
|
||||
from adafruit_bitmap_font.pcf import PCF # pylint: disable=ungrouped-imports
|
||||
from typing import Generator, Optional, Union
|
||||
|
||||
from adafruit_bitmap_font.bdf import BDF
|
||||
from adafruit_bitmap_font.pcf import PCF
|
||||
from fontio import BuiltinFont
|
||||
from keypad import Keys, ShiftRegisterKeys
|
||||
from neopixel import NeoPixel
|
||||
|
|
@ -87,7 +88,6 @@ def load_font(fontname: str, text: str) -> Union[BDF, PCF]:
|
|||
return font
|
||||
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
class PyBadgerBase:
|
||||
"""PyBadger base class."""
|
||||
|
||||
|
|
@ -168,9 +168,7 @@ class PyBadgerBase:
|
|||
self.root_group = self._background_group
|
||||
|
||||
if self._background_image_filename:
|
||||
file_handle = open( # pylint: disable=consider-using-with
|
||||
self._background_image_filename, "rb"
|
||||
)
|
||||
file_handle = open(self._background_image_filename, "rb")
|
||||
on_disk_bitmap = displayio.OnDiskBitmap(file_handle)
|
||||
background_image = displayio.TileGrid(
|
||||
on_disk_bitmap,
|
||||
|
|
@ -182,8 +180,8 @@ class PyBadgerBase:
|
|||
|
||||
def badge_background(
|
||||
self,
|
||||
background_color: Tuple[int, int, int] = RED,
|
||||
rectangle_color: Tuple[int, int, int] = WHITE,
|
||||
background_color: tuple[int, int, int] = RED,
|
||||
rectangle_color: tuple[int, int, int] = WHITE,
|
||||
rectangle_drop: float = 0.4,
|
||||
rectangle_height: float = 0.5,
|
||||
) -> displayio.Group:
|
||||
|
|
@ -219,8 +217,8 @@ class PyBadgerBase:
|
|||
|
||||
def _badge_background(
|
||||
self,
|
||||
background_color: Tuple[int, int, int] = RED,
|
||||
rectangle_color: Tuple[int, int, int] = WHITE,
|
||||
background_color: tuple[int, int, int] = RED,
|
||||
rectangle_color: tuple[int, int, int] = WHITE,
|
||||
rectangle_drop: float = 0.4,
|
||||
rectangle_height: float = 0.5,
|
||||
) -> displayio.Group:
|
||||
|
|
@ -231,9 +229,7 @@ class PyBadgerBase:
|
|||
color_palette = displayio.Palette(1)
|
||||
color_palette[0] = background_color
|
||||
|
||||
bg_sprite = displayio.TileGrid(
|
||||
color_bitmap, pixel_shader=color_palette, x=0, y=0
|
||||
)
|
||||
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
|
||||
background_group.append(bg_sprite)
|
||||
|
||||
rectangle = Rect(
|
||||
|
|
@ -263,11 +259,10 @@ class PyBadgerBase:
|
|||
"""
|
||||
self._background_image_filename = image_name
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
def badge_line(
|
||||
self,
|
||||
text: str = " ",
|
||||
color: Tuple[int, int, int] = BLACK,
|
||||
color: tuple[int, int, int] = BLACK,
|
||||
scale: int = 1,
|
||||
font: Union[BuiltinFont, BDF, PCF] = terminalio.FONT,
|
||||
left_justify: bool = False,
|
||||
|
|
@ -361,7 +356,6 @@ class PyBadgerBase:
|
|||
|
||||
self.root_group = self._background_group
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
def _create_label_group(
|
||||
self,
|
||||
text: str,
|
||||
|
|
@ -399,10 +393,7 @@ class PyBadgerBase:
|
|||
self._last_accelerometer = current_accelerometer
|
||||
return False
|
||||
acceleration_delta = sum(
|
||||
(
|
||||
abs(self._last_accelerometer[n] - current_accelerometer[n])
|
||||
for n in range(3)
|
||||
)
|
||||
abs(self._last_accelerometer[n] - current_accelerometer[n]) for n in range(3)
|
||||
)
|
||||
self._last_accelerometer = current_accelerometer
|
||||
return acceleration_delta > movement_threshold
|
||||
|
|
@ -449,13 +440,9 @@ class PyBadgerBase:
|
|||
return self._light_sensor.value
|
||||
|
||||
@property
|
||||
def acceleration(self) -> Tuple[int, int, int]:
|
||||
def acceleration(self) -> tuple[int, int, int]:
|
||||
"""Accelerometer data, +/- 2G sensitivity."""
|
||||
return (
|
||||
self._accelerometer.acceleration
|
||||
if self._accelerometer is not None
|
||||
else (0, 0, 0)
|
||||
)
|
||||
return self._accelerometer.acceleration if self._accelerometer is not None else (0, 0, 0)
|
||||
|
||||
@property
|
||||
def brightness(self) -> float:
|
||||
|
|
@ -467,7 +454,6 @@ class PyBadgerBase:
|
|||
self._display_brightness = value
|
||||
self.display.brightness = value
|
||||
|
||||
# pylint: disable=too-many-locals
|
||||
def show_business_card(
|
||||
self,
|
||||
*,
|
||||
|
|
@ -553,24 +539,21 @@ class PyBadgerBase:
|
|||
business_card_label_groups.append(email_two_group)
|
||||
|
||||
business_card_splash = displayio.Group()
|
||||
image_file = open(image_name, "rb") # pylint: disable=consider-using-with
|
||||
image_file = open(image_name, "rb")
|
||||
on_disk_bitmap = displayio.OnDiskBitmap(image_file)
|
||||
face_image = displayio.TileGrid(
|
||||
on_disk_bitmap, pixel_shader=on_disk_bitmap.pixel_shader
|
||||
)
|
||||
face_image = displayio.TileGrid(on_disk_bitmap, pixel_shader=on_disk_bitmap.pixel_shader)
|
||||
business_card_splash.append(face_image)
|
||||
for group in business_card_label_groups:
|
||||
business_card_splash.append(group)
|
||||
self.root_group = business_card_splash
|
||||
|
||||
# pylint: disable=too-many-locals
|
||||
def show_badge(
|
||||
self,
|
||||
*,
|
||||
background_color: Tuple[int, int, int] = RED,
|
||||
foreground_color: Tuple[int, int, int] = WHITE,
|
||||
background_text_color: Tuple[int, int, int] = WHITE,
|
||||
foreground_text_color: Tuple[int, int, int] = BLACK,
|
||||
background_color: tuple[int, int, int] = RED,
|
||||
foreground_color: tuple[int, int, int] = WHITE,
|
||||
background_text_color: tuple[int, int, int] = WHITE,
|
||||
foreground_text_color: tuple[int, int, int] = BLACK,
|
||||
hello_font: Union[BuiltinFont, BDF, PCF] = terminalio.FONT,
|
||||
hello_scale: int = 1,
|
||||
hello_string: str = "HELLO",
|
||||
|
|
@ -705,12 +688,8 @@ class PyBadgerBase:
|
|||
self.display.width // qr_bitmap.width,
|
||||
self.display.height // qr_bitmap.height,
|
||||
)
|
||||
qr_position_x = int(
|
||||
((self.display.width / qr_code_scale) - qr_bitmap.width) / 2
|
||||
)
|
||||
qr_position_y = int(
|
||||
((self.display.height / qr_code_scale) - qr_bitmap.height) / 2
|
||||
)
|
||||
qr_position_x = int(((self.display.width / qr_code_scale) - qr_bitmap.width) / 2)
|
||||
qr_position_y = int(((self.display.height / qr_code_scale) - qr_bitmap.height) / 2)
|
||||
qr_img = displayio.TileGrid(
|
||||
qr_bitmap, pixel_shader=palette, x=qr_position_x, y=qr_position_y
|
||||
)
|
||||
|
|
@ -730,10 +709,7 @@ class PyBadgerBase:
|
|||
if self._sample is not None:
|
||||
return
|
||||
self._sine_wave = array.array("H", PyBadgerBase._sine_sample(length))
|
||||
# pylint: disable=not-callable
|
||||
self._sample = self._audio_out(
|
||||
board.SPEAKER
|
||||
) # pylint: disable=not-callable
|
||||
self._sample = self._audio_out(board.SPEAKER)
|
||||
self._sine_wave_sample = audiocore.RawSample(self._sine_wave)
|
||||
else:
|
||||
print("Required audio modules were missing")
|
||||
|
|
@ -791,10 +767,8 @@ class PyBadgerBase:
|
|||
# Play a specified file.
|
||||
self.stop_tone()
|
||||
self._enable_speaker(enable=True)
|
||||
with self._audio_out(board.SPEAKER) as audio: # pylint: disable=not-callable
|
||||
wavefile = audiocore.WaveFile(
|
||||
open(file_name, "rb") # pylint: disable=consider-using-with
|
||||
)
|
||||
with self._audio_out(board.SPEAKER) as audio:
|
||||
wavefile = audiocore.WaveFile(open(file_name, "rb"))
|
||||
audio.play(wavefile)
|
||||
while audio.playing:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -26,14 +26,16 @@ Implementation Notes
|
|||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
import board
|
||||
import analogio
|
||||
import digitalio
|
||||
import audioio
|
||||
import neopixel
|
||||
import keypad
|
||||
|
||||
import adafruit_lis3dh
|
||||
from adafruit_pybadger.pybadger_base import PyBadgerBase, KeyStates
|
||||
import analogio
|
||||
import audioio
|
||||
import board
|
||||
import digitalio
|
||||
import keypad
|
||||
import neopixel
|
||||
|
||||
from adafruit_pybadger.pybadger_base import KeyStates, PyBadgerBase
|
||||
|
||||
try:
|
||||
from typing import Tuple
|
||||
|
|
@ -59,9 +61,7 @@ class PyGamer(PyBadgerBase):
|
|||
|
||||
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
|
||||
try:
|
||||
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(
|
||||
i2c, address=0x19, int1=int1
|
||||
)
|
||||
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1)
|
||||
except ValueError:
|
||||
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
|
||||
|
||||
|
|
@ -106,9 +106,7 @@ class PyGamer(PyBadgerBase):
|
|||
|
||||
"""
|
||||
self._buttons.update()
|
||||
button_values = tuple(
|
||||
self._buttons.was_pressed(i) for i in range(self._keys.key_count)
|
||||
)
|
||||
button_values = tuple(self._buttons.was_pressed(i) for i in range(self._keys.key_count))
|
||||
x, y = self.joystick
|
||||
return Buttons(
|
||||
button_values[0],
|
||||
|
|
@ -129,5 +127,5 @@ class PyGamer(PyBadgerBase):
|
|||
return x, y
|
||||
|
||||
|
||||
pygamer = PyGamer() # pylint: disable=invalid-name
|
||||
pygamer = PyGamer()
|
||||
"""Object that is automatically created on import."""
|
||||
|
|
|
|||
|
|
@ -24,10 +24,12 @@ Implementation Notes
|
|||
https://github.com/adafruit/circuitpython/releases
|
||||
|
||||
"""
|
||||
import board
|
||||
|
||||
import analogio
|
||||
import audioio
|
||||
import board
|
||||
import neopixel
|
||||
|
||||
from adafruit_pybadger.pybadger_base import PyBadgerBase
|
||||
|
||||
__version__ = "0.0.0+auto.0"
|
||||
|
|
@ -62,5 +64,5 @@ class PyPortal(PyBadgerBase):
|
|||
auto_dim_display = _unsupported
|
||||
|
||||
|
||||
pyportal = PyPortal() # pylint: disable=invalid-name
|
||||
pyportal = PyPortal()
|
||||
"""Object that is automatically created on import."""
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
|
||||
.. use this format as the module name: "adafruit_foo.foo"
|
||||
|
||||
API Reference
|
||||
#############
|
||||
|
||||
.. automodule:: adafruit_pybadger.pybadger_base
|
||||
:members:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
sys.path.insert(0, os.path.abspath("mocks"))
|
||||
|
|
@ -64,9 +62,7 @@ project = "Adafruit PyBadger Library"
|
|||
creation_year = "2019"
|
||||
current_year = str(datetime.datetime.now().year)
|
||||
year_duration = (
|
||||
current_year
|
||||
if current_year == creation_year
|
||||
else creation_year + " - " + current_year
|
||||
current_year if current_year == creation_year else creation_year + " - " + current_year
|
||||
)
|
||||
copyright = year_duration + " Kattni Rembor"
|
||||
author = "Kattni Rembor"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class ShiftRegisterKeys:
|
|||
key_count,
|
||||
value_when_pressed,
|
||||
interval=0.020,
|
||||
max_events=64
|
||||
max_events=64,
|
||||
):
|
||||
self.key_count = 123
|
||||
self.events = EventQueue()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
from adafruit_debouncer import Debouncer
|
||||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
b_btn = Debouncer(lambda: pybadger.button.b == 0)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
"""Custom badge example for Adafruit CLUE."""
|
||||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
pybadger.badge_background(
|
||||
|
|
@ -11,16 +12,10 @@ pybadger.badge_background(
|
|||
rectangle_height=0.6,
|
||||
)
|
||||
|
||||
pybadger.badge_line(
|
||||
text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=2, padding_above=2
|
||||
)
|
||||
pybadger.badge_line(text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=2, padding_above=2)
|
||||
pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=5, padding_above=6)
|
||||
pybadger.badge_line(
|
||||
text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2
|
||||
)
|
||||
pybadger.badge_line(
|
||||
text="she/her", color=pybadger.BLINKA_PINK, scale=4, padding_above=7
|
||||
)
|
||||
pybadger.badge_line(text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2)
|
||||
pybadger.badge_line(text="she/her", color=pybadger.BLINKA_PINK, scale=4, padding_above=7)
|
||||
|
||||
pybadger.show_custom_badge()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,14 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
"""Custom image badge example for Adafruit CLUE."""
|
||||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
pybadger.image_background("Blinka_CLUE.bmp")
|
||||
|
||||
pybadger.badge_line(text="@circuitpython", color=pybadger.SKY, scale=2, padding_above=2)
|
||||
pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=5, padding_above=3)
|
||||
pybadger.badge_line(
|
||||
text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2
|
||||
)
|
||||
pybadger.badge_line(text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2)
|
||||
pybadger.badge_line(text="she/her", color=pybadger.SKY, scale=4, padding_above=4)
|
||||
|
||||
while True:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
"""Custom badge for PyBadge or PyGamer."""
|
||||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
pybadger.badge_background(
|
||||
|
|
@ -11,16 +12,10 @@ pybadger.badge_background(
|
|||
rectangle_height=0.6,
|
||||
)
|
||||
|
||||
pybadger.badge_line(
|
||||
text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=1, padding_above=1
|
||||
)
|
||||
pybadger.badge_line(text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=1, padding_above=1)
|
||||
pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=3, padding_above=2)
|
||||
pybadger.badge_line(
|
||||
text="CircuitPythonista", color=pybadger.WHITE, scale=1, padding_above=1
|
||||
)
|
||||
pybadger.badge_line(
|
||||
text="she/her", color=pybadger.BLINKA_PINK, scale=2, padding_above=2
|
||||
)
|
||||
pybadger.badge_line(text="CircuitPythonista", color=pybadger.WHITE, scale=1, padding_above=1)
|
||||
pybadger.badge_line(text="she/her", color=pybadger.BLINKA_PINK, scale=2, padding_above=2)
|
||||
|
||||
while True:
|
||||
pybadger.show_custom_badge()
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
"""Simpletest example using the Mag Tag.
|
||||
Use the A, B, and C buttons to change between examples."""
|
||||
Use the A, B, and C buttons to change between examples."""
|
||||
|
||||
import time
|
||||
|
||||
import board
|
||||
import digitalio
|
||||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
|
||||
|
|
@ -44,9 +47,7 @@ prev_c = btn_c.value
|
|||
|
||||
SHOWING = "badge"
|
||||
|
||||
pybadger.show_badge(
|
||||
name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3
|
||||
)
|
||||
pybadger.show_badge(name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3)
|
||||
|
||||
try_refresh()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
"""Simpletest example using the Pew Pew M4.
|
||||
Use the O, X, and Z buttons to change between examples."""
|
||||
Use the O, X, and Z buttons to change between examples."""
|
||||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
pybadger.show_badge(
|
||||
name_string="Blinka", hello_scale=3, my_name_is_scale=3, name_scale=4
|
||||
)
|
||||
pybadger.show_badge(name_string="Blinka", hello_scale=3, my_name_is_scale=3, name_scale=4)
|
||||
|
||||
while True:
|
||||
if pybadger.button.o:
|
||||
|
|
@ -23,6 +22,4 @@ while True:
|
|||
elif pybadger.button.x:
|
||||
pybadger.show_qr_code(data="https://circuitpython.org")
|
||||
elif pybadger.button.z:
|
||||
pybadger.show_badge(
|
||||
name_string="Blinka", hello_scale=3, my_name_is_scale=3, name_scale=4
|
||||
)
|
||||
pybadger.show_badge(name_string="Blinka", hello_scale=3, my_name_is_scale=3, name_scale=4)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
# SPDX-FileCopyrightText: 2022 Jeff Epler for Adafruit Industries
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# pylint: disable=consider-using-with
|
||||
|
||||
import asyncio
|
||||
from displayio import TileGrid, OnDiskBitmap, Group
|
||||
|
||||
from displayio import Group, OnDiskBitmap, TileGrid
|
||||
from rainbowio import colorwheel
|
||||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
# If you choose to enter a pronoun it's shown on the "business card" page
|
||||
|
|
@ -26,13 +27,9 @@ pybadger.badge_background(
|
|||
rectangle_height=0.55,
|
||||
)
|
||||
|
||||
pybadger.badge_line(
|
||||
text="HELLO I'M", color=pybadger.BLINKA_PURPLE, scale=2, padding_above=1
|
||||
)
|
||||
pybadger.badge_line(text="HELLO I'M", color=pybadger.BLINKA_PURPLE, scale=2, padding_above=1)
|
||||
pybadger.badge_line(text=custom_line1, color=pybadger.WHITE, scale=6, padding_above=1)
|
||||
pybadger.badge_line(
|
||||
text=custom_line2, color=pybadger.BLINKA_PURPLE, scale=2, padding_above=0.25
|
||||
)
|
||||
pybadger.badge_line(text=custom_line2, color=pybadger.BLINKA_PURPLE, scale=2, padding_above=0.25)
|
||||
|
||||
# Start with the custom badge page
|
||||
pybadger.show_custom_badge()
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
"""Simpletest example using Adafruit PyPortal. Uses the touchscreen to advance between examples."""
|
||||
import board
|
||||
import adafruit_touchscreen
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
import adafruit_touchscreen
|
||||
import board
|
||||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
# These pins are used as both analog and digital! XL, XR and YU must be analog
|
||||
# and digital capable. YD just need to be digital
|
||||
|
|
@ -19,9 +19,7 @@ ts = adafruit_touchscreen.Touchscreen(
|
|||
size=(320, 240),
|
||||
)
|
||||
|
||||
pybadger.show_badge(
|
||||
name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3
|
||||
)
|
||||
pybadger.show_badge(name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3)
|
||||
|
||||
cur_example = 0
|
||||
prev_touch = None
|
||||
|
|
@ -45,6 +43,4 @@ while True:
|
|||
elif cur_example == 1:
|
||||
pybadger.show_qr_code(data="https://circuitpython.org")
|
||||
elif cur_example == 2:
|
||||
pybadger.show_badge(
|
||||
name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3
|
||||
)
|
||||
pybadger.show_badge(name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
from adafruit_pybadger import pybadger
|
||||
|
||||
pybadger.show_badge(
|
||||
name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3
|
||||
)
|
||||
pybadger.show_badge(name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3)
|
||||
|
||||
while True:
|
||||
pybadger.auto_dim_display(
|
||||
|
|
@ -22,6 +20,4 @@ while True:
|
|||
elif pybadger.button.b:
|
||||
pybadger.show_qr_code(data="https://circuitpython.org")
|
||||
elif pybadger.button.start:
|
||||
pybadger.show_badge(
|
||||
name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3
|
||||
)
|
||||
pybadger.show_badge(name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ readme = "README.rst"
|
|||
authors = [
|
||||
{name = "Adafruit Industries", email = "circuitpython@adafruit.com"}
|
||||
]
|
||||
urls = {Homepage = "https://github.com/adafruit/Adafruit_CircuitPython_REPLACE"}
|
||||
urls = {Homepage = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger"}
|
||||
keywords = [
|
||||
"adafruit",
|
||||
"pybadge",
|
||||
|
|
|
|||
108
ruff.toml
Normal file
108
ruff.toml
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
target-version = "py38"
|
||||
line-length = 100
|
||||
|
||||
[lint]
|
||||
preview = true
|
||||
select = ["I", "PL", "UP"]
|
||||
|
||||
extend-select = [
|
||||
"D419", # empty-docstring
|
||||
"E501", # line-too-long
|
||||
"W291", # trailing-whitespace
|
||||
"PLC0414", # useless-import-alias
|
||||
"PLC2401", # non-ascii-name
|
||||
"PLC2801", # unnecessary-dunder-call
|
||||
"PLC3002", # unnecessary-direct-lambda-call
|
||||
"E999", # syntax-error
|
||||
"PLE0101", # return-in-init
|
||||
"F706", # return-outside-function
|
||||
"F704", # yield-outside-function
|
||||
"PLE0116", # continue-in-finally
|
||||
"PLE0117", # nonlocal-without-binding
|
||||
"PLE0241", # duplicate-bases
|
||||
"PLE0302", # unexpected-special-method-signature
|
||||
"PLE0604", # invalid-all-object
|
||||
"PLE0605", # invalid-all-format
|
||||
"PLE0643", # potential-index-error
|
||||
"PLE0704", # misplaced-bare-raise
|
||||
"PLE1141", # dict-iter-missing-items
|
||||
"PLE1142", # await-outside-async
|
||||
"PLE1205", # logging-too-many-args
|
||||
"PLE1206", # logging-too-few-args
|
||||
"PLE1307", # bad-string-format-type
|
||||
"PLE1310", # bad-str-strip-call
|
||||
"PLE1507", # invalid-envvar-value
|
||||
"PLE2502", # bidirectional-unicode
|
||||
"PLE2510", # invalid-character-backspace
|
||||
"PLE2512", # invalid-character-sub
|
||||
"PLE2513", # invalid-character-esc
|
||||
"PLE2514", # invalid-character-nul
|
||||
"PLE2515", # invalid-character-zero-width-space
|
||||
"PLR0124", # comparison-with-itself
|
||||
"PLR0202", # no-classmethod-decorator
|
||||
"PLR0203", # no-staticmethod-decorator
|
||||
"UP004", # useless-object-inheritance
|
||||
"PLR0206", # property-with-parameters
|
||||
"PLR0904", # too-many-public-methods
|
||||
"PLR0911", # too-many-return-statements
|
||||
"PLR0912", # too-many-branches
|
||||
"PLR0913", # too-many-arguments
|
||||
"PLR0914", # too-many-locals
|
||||
"PLR0915", # too-many-statements
|
||||
"PLR0916", # too-many-boolean-expressions
|
||||
"PLR1702", # too-many-nested-blocks
|
||||
"PLR1704", # redefined-argument-from-local
|
||||
"PLR1711", # useless-return
|
||||
"C416", # unnecessary-comprehension
|
||||
"PLR1733", # unnecessary-dict-index-lookup
|
||||
"PLR1736", # unnecessary-list-index-lookup
|
||||
|
||||
# ruff reports this rule is unstable
|
||||
#"PLR6301", # no-self-use
|
||||
|
||||
"PLW0108", # unnecessary-lambda
|
||||
"PLW0120", # useless-else-on-loop
|
||||
"PLW0127", # self-assigning-variable
|
||||
"PLW0129", # assert-on-string-literal
|
||||
"B033", # duplicate-value
|
||||
"PLW0131", # named-expr-without-context
|
||||
"PLW0245", # super-without-brackets
|
||||
"PLW0406", # import-self
|
||||
"PLW0602", # global-variable-not-assigned
|
||||
"PLW0603", # global-statement
|
||||
"PLW0604", # global-at-module-level
|
||||
|
||||
# fails on the try: import typing used by libraries
|
||||
#"F401", # unused-import
|
||||
|
||||
"F841", # unused-variable
|
||||
"E722", # bare-except
|
||||
"PLW0711", # binary-op-exception
|
||||
"PLW1501", # bad-open-mode
|
||||
"PLW1508", # invalid-envvar-default
|
||||
"PLW1509", # subprocess-popen-preexec-fn
|
||||
"PLW2101", # useless-with-lock
|
||||
"PLW3301", # nested-min-max
|
||||
]
|
||||
|
||||
ignore = [
|
||||
"PLR2004", # magic-value-comparison
|
||||
"UP030", # format literals
|
||||
"PLW1514", # unspecified-encoding
|
||||
"PLR0913", # too-many-arguments
|
||||
"PLR0915", # too-many-statements
|
||||
"PLR0917", # too-many-positional-arguments
|
||||
"PLR0904", # too-many-public-methods
|
||||
"PLR0912", # too-many-branches
|
||||
"PLR0916", # too-many-boolean-expressions
|
||||
"PLR6301", # could-be-static no-self-use
|
||||
"PLC0415", # import outside toplevel
|
||||
"UP007", # x | y type annotation
|
||||
]
|
||||
|
||||
[format]
|
||||
line-ending = "lf"
|
||||
Loading…
Reference in a new issue