Skip to content

Commit 1142f1c

Browse files
committed
Add auto-write support, RGB hex support and slicing support. Also
adds much better docs.
1 parent 42c3b61 commit 1142f1c

File tree

11 files changed

+477
-22
lines changed

11 files changed

+477
-22
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_build
2+
__pycache__

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ before_install:
4545
- sudo apt-get -yqq update
4646
- sudo apt-get install -y build-essential git python python-pip
4747
- git clone https://github.com/adafruit/micropython.git
48+
- cd micropython
49+
- git checkout stable
50+
- cd ..
4851
- make -C micropython/mpy-cross
4952
- export PATH=$PATH:$PWD/micropython/mpy-cross/
5053
- sudo pip install shyaml

CODE_OF_CONDUCT.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [http://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

LICENSE

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
MIT License
1+
The MIT License (MIT)
22

3-
Copyright (c) 2016 Adafruit Industries
3+
Copyright (c) 2016 Damien P. George
4+
Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
Introduction
3+
============
4+
5+
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-neopixel/badge/?version=latest
6+
:target: https://circuitpython.readthedocs.io/projects/neopixel/en/latest/
7+
:alt: Documentation Status
8+
9+
.. image :: https://badges.gitter.im/adafruit/circuitpython.svg
10+
:target: https://gitter.im/adafruit/circuitpython?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
11+
:alt: Gitter
12+
13+
Higher level NeoPixel driver that presents the strip as a sequence. This is a
14+
supercharged version of the original MicroPython driver. Its now more like a
15+
normal Python sequence and features slice support, ``repr`` and ``len`` support.
16+
17+
Colors are now stored as ints by default rather than tuples. However, you can
18+
still use the tuple syntax to set values. For example, ``0x100000`` is equivalent
19+
to ``(0x10, 0, 0)``.
20+
21+
.. note:: This API represents the brightness of the white pixel when present by
22+
setting the RGB channels to identical values. For example, full white is
23+
0xffffff but is actually (0, 0, 0, 0xff) in the tuple syntax. Setting a pixel
24+
value with an int will use the white pixel if the RGB channels are identical.
25+
For full, independent, control of each color component use the tuple syntax
26+
and ignore the readback value.
27+
28+
Dependencies
29+
=============
30+
This driver depends on:
31+
32+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
33+
34+
Please ensure all dependencies are available on the CircuitPython filesystem.
35+
This is easily achieved by downloading
36+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
37+
38+
Usage Example
39+
=============
40+
41+
This example demonstrates the library with the single built-in NeoPixel on the
42+
`Feather M0 Express <https://www.adafruit.com/product/3403>`_ and
43+
`Metro M0 Express <https://www.adafruit.com/product/3505>`_.
44+
45+
.. code-block:: python
46+
47+
import board
48+
import neopixel
49+
50+
pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
51+
pixels[0] = (10, 0, 0)
52+
53+
This example demonstrates the library with the ten built-in NeoPixels on the
54+
`Circuit Playground Express <https://www.adafruit.com/product/3333>`_. It turns off
55+
``auto_write`` so that all pixels are updated at once.
56+
57+
.. code-block:: python
58+
59+
import board
60+
import neopixel
61+
62+
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, auto_write=False)
63+
pixels[0] = (10, 0, 0)
64+
pixels[9] = (0, 10, 0)
65+
pixels.show()
66+
67+
Contributing
68+
============
69+
70+
Contributions are welcome! Please read our `Code of Conduct
71+
<https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/blob/master/CODE_OF_CONDUCT.md>`_
72+
before contributing to help this project stay welcoming.
73+
74+
API Reference
75+
=============
76+
77+
.. toctree::
78+
:maxdepth: 2
79+
80+
api

api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
.. If you created a package, create one automodule per module in the package.
3+
4+
.. automodule:: neopixel
5+
:members:

conf.py

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import os
4+
import sys
5+
sys.path.insert(0, os.path.abspath('.'))
6+
7+
# -- General configuration ------------------------------------------------
8+
9+
# Add any Sphinx extension module names here, as strings. They can be
10+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
11+
# ones.
12+
extensions = [
13+
'sphinx.ext.autodoc',
14+
'sphinx.ext.intersphinx',
15+
'sphinx.ext.viewcode',
16+
]
17+
18+
autodoc_mock_imports = ["digitalio", "neopixel_write"]
19+
20+
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
21+
22+
# Add any paths that contain templates here, relative to this directory.
23+
templates_path = ['_templates']
24+
25+
source_suffix = '.rst'
26+
27+
# The master toctree document.
28+
master_doc = 'README'
29+
30+
# General information about the project.
31+
project = u'Adafruit CircuitPython NeoPixel Library'
32+
copyright = u'2017 Scott Shawcroft & Damien P. George'
33+
author = u'Scott Shawcroft & Damien P. George'
34+
35+
# The version info for the project you're documenting, acts as replacement for
36+
# |version| and |release|, also used in various other places throughout the
37+
# built documents.
38+
#
39+
# The short X.Y version.
40+
version = u'1.0'
41+
# The full version, including alpha/beta/rc tags.
42+
release = u'1.0'
43+
44+
# The language for content autogenerated by Sphinx. Refer to documentation
45+
# for a list of supported languages.
46+
#
47+
# This is also used if you do content translation via gettext catalogs.
48+
# Usually you set "language" from the command line for these cases.
49+
language = None
50+
51+
# List of patterns, relative to source directory, that match files and
52+
# directories to ignore when looking for source files.
53+
# This patterns also effect to html_static_path and html_extra_path
54+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
55+
56+
# The reST default role (used for this markup: `text`) to use for all
57+
# documents.
58+
#
59+
default_role = "any"
60+
61+
# If true, '()' will be appended to :func: etc. cross-reference text.
62+
#
63+
add_function_parentheses = True
64+
65+
# The name of the Pygments (syntax highlighting) style to use.
66+
pygments_style = 'sphinx'
67+
68+
# If true, `todo` and `todoList` produce output, else they produce nothing.
69+
todo_include_todos = False
70+
71+
72+
# -- Options for HTML output ----------------------------------------------
73+
74+
# The theme to use for HTML and HTML Help pages. See the documentation for
75+
# a list of builtin themes.
76+
#
77+
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
78+
79+
if not on_rtd: # only import and set the theme if we're building docs locally
80+
try:
81+
import sphinx_rtd_theme
82+
html_theme = 'sphinx_rtd_theme'
83+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
84+
except:
85+
html_theme = 'default'
86+
html_theme_path = ['.']
87+
else:
88+
html_theme_path = ['.']
89+
90+
# Add any paths that contain custom static files (such as style sheets) here,
91+
# relative to this directory. They are copied after the builtin static files,
92+
# so a file named "default.css" will overwrite the builtin "default.css".
93+
html_static_path = ['_static']
94+
95+
# Output file base name for HTML help builder.
96+
htmlhelp_basename = 'AdafruitNEOPIXEL2Librarydoc'
97+
98+
# -- Options for LaTeX output ---------------------------------------------
99+
100+
latex_elements = {
101+
# The paper size ('letterpaper' or 'a4paper').
102+
#
103+
# 'papersize': 'letterpaper',
104+
105+
# The font size ('10pt', '11pt' or '12pt').
106+
#
107+
# 'pointsize': '10pt',
108+
109+
# Additional stuff for the LaTeX preamble.
110+
#
111+
# 'preamble': '',
112+
113+
# Latex figure (float) alignment
114+
#
115+
# 'figure_align': 'htbp',
116+
}
117+
118+
# Grouping the document tree into LaTeX files. List of tuples
119+
# (source start file, target name, title,
120+
# author, documentclass [howto, manual, or own class]).
121+
latex_documents = [
122+
(master_doc, 'AdafruitNeoPixelLibrary.tex', u'Adafruit NeoPixel Library Documentation',
123+
author, 'manual'),
124+
]
125+
126+
# -- Options for manual page output ---------------------------------------
127+
128+
# One entry per manual page. List of tuples
129+
# (source start file, name, description, authors, manual section).
130+
man_pages = [
131+
(master_doc, 'adafruitneoPixellibrary', u'Adafruit NeoPixel Library Documentation',
132+
[author], 1)
133+
]
134+
135+
# -- Options for Texinfo output -------------------------------------------
136+
137+
# Grouping the document tree into Texinfo files. List of tuples
138+
# (source start file, target name, title, author,
139+
# dir menu entry, description, category)
140+
texinfo_documents = [
141+
(master_doc, 'AdafruitNeoPixelLibrary', u'Adafruit NeoPixel Library Documentation',
142+
author, 'AdafruitNeoPixelLibrary', 'One line description of project.',
143+
'Miscellaneous'),
144+
]

0 commit comments

Comments
 (0)