update cookiecutter and address lint

This commit is contained in:
Roy Hooper 2020-01-04 00:09:00 -05:00
parent bad8defb8a
commit ed7ababf00
9 changed files with 154 additions and 119 deletions

View file

@ -40,8 +40,8 @@ Examples of unacceptable behavior by participants include:
* Other conduct which could reasonably be considered inappropriate * Other conduct which could reasonably be considered inappropriate
The goal of the standards and moderation guidelines outlined here is to build The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you dont just aim to be and maintain a respectful community. We ask that you dont just aim to be
"technically unimpeachable", but rather try to be your best self. "technically unimpeachable", but rather try to be your best self.
We value many things beyond technical expertise, including collaboration and We value many things beyond technical expertise, including collaboration and
supporting others within our community. Providing a positive experience for supporting others within our community. Providing a positive experience for
@ -72,7 +72,7 @@ You may report in the following ways:
In any situation, you may send an email to <support@adafruit.com>. In any situation, you may send an email to <support@adafruit.com>.
On the Adafruit Discord, you may send an open message from any channel On the Adafruit Discord, you may send an open message from any channel
to all Community Helpers by tagging @community helpers. You may also send an to all Community Helpers by tagging @community moderators. You may also send an
open message from any channel, or a direct message to @kattni#1507, open message from any channel, or a direct message to @kattni#1507,
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or @tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
@Andon#8175. @Andon#8175.
@ -83,7 +83,7 @@ In situations on Discord where the issue is particularly egregious, possibly
illegal, requires immediate action, or violates the Discord terms of service, illegal, requires immediate action, or violates the Discord terms of service,
you should also report the message directly to Discord. you should also report the message directly to Discord.
These are the steps for upholding our communitys standards of conduct. These are the steps for upholding our communitys standards of conduct.
1. Any member of the community may report any situation that violates the 1. Any member of the community may report any situation that violates the
Adafruit Community Code of Conduct. All reports will be reviewed and Adafruit Community Code of Conduct. All reports will be reviewed and
@ -124,4 +124,4 @@ For other projects adopting the Adafruit Community Code of
Conduct, please contact the maintainers of those projects for enforcement. Conduct, please contact the maintainers of those projects for enforcement.
If you wish to use this code of conduct for your own project, consider If you wish to use this code of conduct for your own project, consider
explicitly mentioning your moderation policy or making a copy with your explicitly mentioning your moderation policy or making a copy with your
own moderation policy so as to avoid confusion. own moderation policy so as to avoid confusion.

View file

@ -1,6 +1,7 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2017 Adam Patt Copyright (c) 2017 Adam Patt
Copyright (c) 2019-2020 Roy Hooper, Kattni Rembor
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,8 +1,8 @@
Introduction Introduction
============ ============
.. image:: https://readthedocs.org/projects/adafruit_circuitpython_led_animation/badge/?version=latest .. image:: https://readthedocs.org/projects/adafruit-circuitpython-led_animation/badge/?version=latest
:target: https://adafruit_circuitpython_led_animation.readthedocs.io/ :target: https://circuitpython.readthedocs.io/projects/led_animation/en/latest/
:alt: Documentation Status :alt: Documentation Status
.. image:: https://img.shields.io/discord/327254708534116352.svg .. image:: https://img.shields.io/discord/327254708534116352.svg
@ -13,7 +13,8 @@ Introduction
:target: https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation/actions :target: https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation/actions
:alt: Build Status :alt: Build Status
Perform a variety of LED animation tasks A library to easily generate LED animations
Dependencies Dependencies
============= =============
@ -23,76 +24,60 @@ This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading This is easily achieved by downloading
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. `the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_.
Installing from PyPI
=====================
.. note:: This library is not available on PyPI yet. Install documentation is included
as a standard element. Stay tuned for PyPI availability!
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/adafruit-circuitpython-led_animation/>`_. To install for current user:
.. code-block:: shell
pip3 install adafruit-circuitpython-led-animation
To install system-wide (this may be required in some cases):
.. code-block:: shell
sudo pip3 install adafruit-circuitpython-led-animation
To install in a virtual environment in your current project:
.. code-block:: shell
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-led-animation
Usage Example Usage Example
============= =============
.. code-block:: python .. code-block:: python
import adafruit_dotstar as dotstar from adafruit_led_animation.animation import Comet, AnimationSequence, Chase
import neopixel
import board import board
from led_animation import color
# setup the pixel pixels = neopixel.NeoPixel(board.D6, 32, brightness=0.2, auto_write=False)
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=.2) comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
# set the color by name chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE)
dot[0] = color.GOLD animations = AnimationSequence(comet, chase, advance_interval=15)
# show the pixel
dot.show() while True:
animations.animate()
Contributing Contributing
============ ============
Contributions are welcome! Please read our `Code of Conduct Contributions are welcome! Please read our `Code of Conduct
<https://github.com/apatt/CircuitPython_LED_Animation/blob/master/CODE_OF_CONDUCT.md>`_ <https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation/blob/master/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming. before contributing to help this project stay welcoming.
Building locally Documentation
================ =============
Zip release files For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.
-----------------
To build this library locally you'll need to install the
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
.. code-block:: shell
python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools
Once installed, make sure you are in the virtual environment:
.. code-block:: shell
source .env/bin/activate
Then run the build:
.. code-block:: shell
circuitpython-build-bundles --filename_prefix circuitpython-led_animation --library_location .
Sphinx documentation
-----------------------
Sphinx is used to build the documentation based on rST files and comments in the code. First,
install dependencies (feel free to reuse the virtual environment from above):
.. code-block:: shell
python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme
Now, once you have the virtual environment activated:
.. code-block:: shell
cd docs
sphinx-build -E -W -b html . _build/html
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
locally verify it will pass.

View file

@ -196,7 +196,7 @@ class ColorCycle(Animation):
Animate a sequence of one or more colors, cycling at the specified speed. Animate a sequence of one or more colors, cycling at the specified speed.
:param pixel_object: The initialised LED object. :param pixel_object: The initialised LED object.
:param int speed: Animation speed in seconds, e.g. ``0.1``. :param float speed: Animation speed in seconds, e.g. ``0.1``.
:param colors: A list of colors to cycle through in ``(r, g, b)`` tuple, or ``0x000000`` hex :param colors: A list of colors to cycle through in ``(r, g, b)`` tuple, or ``0x000000`` hex
format. Defaults to a rainbow color cycle. format. Defaults to a rainbow color cycle.
""" """
@ -231,7 +231,7 @@ class Blink(ColorCycle):
Blink a color on and off. Blink a color on and off.
:param pixel_object: The initialised LED object. :param pixel_object: The initialised LED object.
:param int speed: Animation speed in seconds, e.g. ``0.1``. :param float speed: Animation speed in seconds, e.g. ``0.1``.
:param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format. :param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
""" """
def __init__(self, pixel_object, speed, color, name=None): def __init__(self, pixel_object, speed, color, name=None):
@ -263,7 +263,7 @@ class Comet(Animation):
A comet animation. A comet animation.
:param pixel_object: The initialised LED object. :param pixel_object: The initialised LED object.
:param int speed: Animation speed in seconds, e.g. ``0.1``. :param float speed: Animation speed in seconds, e.g. ``0.1``.
:param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format. :param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
:param int tail_length: The length of the comet. Defaults to 10. Cannot exceed the number of :param int tail_length: The length of the comet. Defaults to 10. Cannot exceed the number of
pixels present in the pixel object, e.g. if the strip is 30 pixels pixels present in the pixel object, e.g. if the strip is 30 pixels
@ -344,7 +344,7 @@ class Sparkle(Animation):
Sparkle animation of a single color. Sparkle animation of a single color.
:param pixel_object: The initialised LED object. :param pixel_object: The initialised LED object.
:param int speed: Animation speed in seconds, e.g. ``0.1``. :param float speed: Animation speed in seconds, e.g. ``0.1``.
:param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format. :param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
:param num_sparkles: Number of sparkles to generate per animation cycle. :param num_sparkles: Number of sparkles to generate per animation cycle.
""" """
@ -385,22 +385,20 @@ class Pulse(Animation):
Pulse all pixels a single color. Pulse all pixels a single color.
:param pixel_object: The initialised LED object. :param pixel_object: The initialised LED object.
:param int speed: Animation refresh rate in seconds, e.g. ``0.1``. :param float speed: Animation refresh rate in seconds, e.g. ``0.1``.
:param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format. :param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
:param period: Period to pulse the LEDs over. Default 5. :param period: Period to pulse the LEDs over. Default 5.
:param max_intensity: The maximum intensity to pulse, between 0 and 1.0. Default 1.
:param min_intensity: The minimum intensity to pulse, between 0 and 1.0. Default 0.
""" """
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, pixel_object, speed, color, period=5, name=None): def __init__(self, pixel_object, speed, color, period=5, name=None):
super(Pulse, self).__init__(pixel_object, speed, color, name=name) super(Pulse, self).__init__(pixel_object, speed, color, name=name)
self._period = period self._period = period
self._generator = self._pulse_generator(period) self._generator = self._pulse_generator()
def _pulse_generator(self, period): def _pulse_generator(self):
period = int(period * NANOS_PER_SECOND) period = int(self._period * NANOS_PER_SECOND)
white = len(self.pixel_object[0]) > 3 and type(self.pixel_object[0][-1]) is not float white = len(self.pixel_object[0]) > 3 and isinstance(self.pixel_object[0][-1], float)
half_period = period // 2 half_period = period // 2
last_update = monotonic_ns() last_update = monotonic_ns()
@ -434,7 +432,7 @@ class Pulse(Animation):
""" """
Resets the animation. Resets the animation.
""" """
self._generator = self._pulse_generator(self._period) self._generator = self._pulse_generator()
class ColorWheel(Animation): class ColorWheel(Animation):
@ -442,17 +440,18 @@ class ColorWheel(Animation):
The classic adafruit colorwheel. The classic adafruit colorwheel.
:param pixel_object: The initialised LED object. :param pixel_object: The initialised LED object.
:param int speed: Animation refresh rate in seconds, e.g. ``0.1``. :param float speed: Animation refresh rate in seconds, e.g. ``0.1``.
:param period: Period to cycle the colorwheel over. Default 5. :param period: Period to cycle the colorwheel over. Default 5.
""" """
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, pixel_object, speed, period=5, name=None): def __init__(self, pixel_object, speed, period=5, name=None):
super(ColorWheel, self).__init__(pixel_object, speed, BLACK, name=name) super(ColorWheel, self).__init__(pixel_object, speed, BLACK, name=name)
self._generator = self._wheel_generator(period) self._period = period
self._generator = self._wheel_generator()
def _wheel_generator(self, period): def _wheel_generator(self):
period = int(period * NANOS_PER_SECOND) period = int(self._period * NANOS_PER_SECOND)
last_update = monotonic_ns() last_update = monotonic_ns()
cycle_position = 0 cycle_position = 0
@ -478,7 +477,7 @@ class ColorWheel(Animation):
""" """
Resets the animation. Resets the animation.
""" """
self._generator = self._wheel_generator(period) self._generator = self._wheel_generator()
class Chase(Animation): class Chase(Animation):
@ -486,7 +485,7 @@ class Chase(Animation):
Chase pixels in one direction in a single color, like a theater marquee sign. Chase pixels in one direction in a single color, like a theater marquee sign.
:param pixel_object: The initialised LED object. :param pixel_object: The initialised LED object.
:param int speed: Animation speed rate in seconds, e.g. ``0.1``. :param float speed: Animation speed rate in seconds, e.g. ``0.1``.
:param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format. :param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
:param size: Number of pixels to turn on in a row. :param size: Number of pixels to turn on in a row.
:param spacing: Number of pixels to turn off in a row. :param spacing: Number of pixels to turn off in a row.
@ -504,12 +503,12 @@ class Chase(Animation):
self._reverse = reverse self._reverse = reverse
self._n = 0 self._n = 0
def resetter(): def _resetter():
self._n = 0 self._n = 0
self._reverse = reverse self._reverse = reverse
self._direction = 1 if not reverse else -1 self._direction = 1 if not reverse else -1
self._reset = resetter self._reset = _resetter
super(Chase, self).__init__(pixel_object, speed, color, name=name) super(Chase, self).__init__(pixel_object, speed, color, name=name)
@ -787,7 +786,7 @@ class AnimationGroup:
for item in self._members: for item in self._members:
item.resume() item.resume()
def done_handler(self, animation): def done_handler(self, animation): # pylint: disable=unused-argument
""" """
Called by some animations when they complete a cycle. For an AnimationGroup this is the Called by some animations when they complete a cycle. For an AnimationGroup this is the
first member of the group, if any. first member of the group, if any.

View file

@ -1,10 +1,8 @@
API Reference
*************
.. If you created a package, create one automodule per module in the package. .. If you created a package, create one automodule per module in the package.
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py) .. 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" .. use this format as the module name: "adafruit_foo.foo"
.. automodule:: led_animation .. automodule:: adafruit_led_animation
:members: :members:

View file

@ -20,7 +20,7 @@ extensions = [
# Uncomment the below if you use native CircuitPython modules such as # Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the # digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning. # autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["led_animation"] # autodoc_mock_imports = ["digitalio", "busio"]
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
@ -34,9 +34,9 @@ source_suffix = '.rst'
master_doc = 'index' master_doc = 'index'
# General information about the project. # General information about the project.
project = u'LED_Animation Library' project = u'Adafruit_LED_Animation Library'
copyright = u'2017 Adam Patt' copyright = u'2020 Roy Hooper'
author = u'Adam Patt' author = u'Roy Hooper'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
@ -109,7 +109,7 @@ html_static_path = ['_static']
html_favicon = '_static/favicon.ico' html_favicon = '_static/favicon.ico'
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'Led_animationLibrarydoc' htmlhelp_basename = 'Adafruit_LED_animation_Librarydoc'
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
@ -135,7 +135,8 @@ latex_elements = {
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'LED_AnimationLibrary.tex', u'LED_Animation Library Documentation', (master_doc, 'Adafruit_LED_Animation_Library.tex',
u'Adafruit_LED_Animation Library Documentation',
author, 'manual'), author, 'manual'),
] ]
@ -144,7 +145,7 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
(master_doc, 'LED_Animationlibrary', u'LED_Animation Library Documentation', (master_doc, 'Adafruit_LED_Animation_library', u'Adafruit LED_Animation Library Documentation',
[author], 1) [author], 1)
] ]
@ -154,7 +155,7 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'LED_AnimationLibrary', u' LED_Animation Library Documentation', (master_doc, 'Adafruit_LED_Animation_library', u'Adafruit LED_Animation Library Documentation',
author, 'LED_AnimationLibrary', 'One line description of project.', author, 'Adafruit_LED_Animation_library', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]

View file

@ -20,16 +20,10 @@ Table of Contents
api api
.. toctree::
:caption: Tutorials
.. toctree::
:caption: Related Products
.. toctree:: .. toctree::
:caption: Other Links :caption: Other Links
Download <https://github.com/apatt/CircuitPython_LED_Animation/releases/latest> Download <https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation/releases/latest>
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io> CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60> CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
Discord Chat <https://adafru.it/discord> Discord Chat <https://adafru.it/discord>

View file

@ -1,17 +1,14 @@
"""Blink LED animation.""" """
import board Example animation sequence.
"""
from adafruit_led_animation.animation import Comet, AnimationSequence, Chase
import neopixel import neopixel
from adafruit_led_animation.animation import Blink import board
import adafruit_led_animation.color as color
# Works on Circuit Playground Express and Bluefruit. pixels = neopixel.NeoPixel(board.D6, 32, brightness=0.2, auto_write=False)
# For other boards, change board.NEOPIXEL to match the pin to which the NeoPixels are attached. comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
pixel_pin = board.NEOPIXEL chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE)
# Change to match the number of pixels you have attached to your board. animations = AnimationSequence(comet, chase, advance_interval=15)
num_pixels = 10
pixels = neopixel.NeoPixel(pixel_pin, num_pixels)
blink = Blink(pixels, 0.5, color.PURPLE)
while True: while True:
blink.animate() animations.animate()

60
setup.py Normal file
View file

@ -0,0 +1,60 @@
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='adafruit-circuitpython-led-animation',
use_scm_version=True,
setup_requires=['setuptools_scm'],
description='A library to easily generate LED animations',
long_description=long_description,
long_description_content_type='text/x-rst',
# The project's main homepage.
url='https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation',
# Author details
author='Adafruit Industries',
author_email='circuitpython@adafruit.com',
install_requires=[
'Adafruit-Blinka'
],
# Choose your license
license='MIT',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
'Topic :: System :: Hardware',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
# What does your project relate to?
keywords='adafruit blinka circuitpython micropython led_animation led animation neopixel '
'dotstar',
py_modules=['adafruit_led_animation'],
)