Skip to content

Updating to use rainbowio. #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ repos:
name: pylint (examples code)
description: Run pylint rules on "examples/*.py" files
entry: /usr/bin/env bash -c
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)']
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name,consider-using-f-string $example; done)']
language: system
2 changes: 1 addition & 1 deletion adafruit_led_animation/animation/rainbowchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RainbowChase(Chase):
:param size: Number of pixels to turn on in a row.
:param spacing: Number of pixels to turn off in a row.
:param reverse: Reverse direction of movement.
:param step: How many colors to skip in `colorwheel` per bar (default 8)
:param step: How many colors to skip in ``colorwheel`` per bar (default 8)
"""

# pylint: disable=too-many-arguments
Expand Down
26 changes: 3 additions & 23 deletions adafruit_led_animation/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
* Adafruit CircuitPython firmware for the supported boards:
https://circuitpython.org/downloads
"""
# Makes colorwheel() available.
from rainbowio import colorwheel # pylint: disable=unused-import

RED = (255, 0, 0)
"""Red."""
YELLOW = (255, 150, 0)
Expand Down Expand Up @@ -70,29 +73,6 @@
"""RAINBOW is a list of colors to use for cycling through.
Includes, in order: red, orange, yellow, green, blue, and purple."""

try:
try:
# Backwards compatibility for 5.3.0 and prior
from _pixelbuf import colorwheel # pylint: disable=unused-import
except ImportError:
from _pixelbuf import wheel as colorwheel # pylint: disable=unused-import
except ImportError:

def colorwheel(pos):
"""Colorwheel is built into CircuitPython's _pixelbuf. A separate colorwheel is included
here for use with CircuitPython builds that do not include _pixelbuf, as with some of the
SAMD21 builds. To use: input a value 0 to 255 to get a color value.
The colours are a transition from red to green to blue and back to red."""
if pos < 0 or pos > 255:
return 0, 0, 0
if pos < 85:
return int(255 - pos * 3), int(pos * 3), 0
if pos < 170:
pos -= 85
return 0, int(255 - pos * 3), int(pos * 3)
pos -= 170
return int(pos * 3), 0, int(255 - (pos * 3))


def calculate_intensity(color, intensity=1.0):
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = []
autodoc_mock_imports = ["rainbowio"]


intersphinx_mapping = {
Expand Down