Skip to content

Commit 12cbadb

Browse files
authored
Merge pull request #12 from mrmcwethy/relint
relinted to match cookiecutter
2 parents 7e3ae1d + 23791c9 commit 12cbadb

23 files changed

+567
-836
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.DS_Store
2+
__pycache__
3+
_build
4+
*.pyc
25
.env
36
build*
47
bundles

.pylintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ spelling-store-unknown-words=no
119119
[MISCELLANEOUS]
120120

121121
# List of note tags to take in consideration, separated by a comma.
122-
notes=FIXME,XXX,TODO
122+
# notes=FIXME,XXX,TODO
123+
notes=FIXME,XXX
123124

124125

125126
[TYPECHECK]

CODE_OF_CONDUCT.md

+74
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Radomir Dopieralski and Adafruit Industries
3+
Copyright (c) 2017 Radomir Dopieralski and Adafruit Industries
44

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

README.rst

+96-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
Display drivers for Adafruit CircuitPython.
2-
=========================================
1+
Introduction
2+
============
3+
4+
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-rgb_display/badge/?version=latest
5+
:target: https://circuitpython.readthedocs.io/projects/rgb_display/en/latest/
6+
:alt: Documentation Status
7+
8+
.. image :: https://img.shields.io/discord/327254708534116352.svg
9+
:target: https://discord.gg/nBQh6qu
10+
:alt: Discord
311
412
Port of display drivers from https://github.com/adafruit/micropython-adafruit-rgb-display
513
to Adafruit CircuitPython for use on Adafruit's SAMD21-based and other CircuitPython
@@ -10,3 +18,89 @@ board too: https://github.com/adafruit/Adafruit_MicroPython_BusDevice
1018

1119
Note that this driver currently won't work on micropython.org firmware, instead
1220
you want the micropython-adafruit-rgb-display driver linked above!
21+
22+
Dependencies
23+
=============
24+
This driver depends on:
25+
26+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
27+
28+
Please ensure all dependencies are available on the CircuitPython filesystem.
29+
This is easily achieved by downloading
30+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
31+
32+
Usage Example
33+
=============
34+
35+
.. code-block:: python
36+
37+
import busio
38+
import digitalio
39+
from board import SCK, MOSI, MISO, D2, D2
40+
41+
from adafruit_rgb_display import color565
42+
import adafruit_rgb_display.ili9341 as ili9341
43+
44+
45+
# Configuration for CS and DC pins:
46+
CS_PIN = D2
47+
DC_PIN = D3
48+
49+
# Setup SPI bus using hardware SPI:
50+
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)
51+
52+
# Create the ILI9341 display:
53+
display = ili9341.ILI9341(spi, cs=digitalio.DigitalInOut(CS_PIN),
54+
dc=digitalio.DigitalInOut(DC_PIN))
55+
56+
# Main loop:
57+
while True:
58+
# Clear the display
59+
display.fill(0)
60+
# Draw a red pixel in the center.
61+
display.pixel(120, 160, color565(255, 0, 0))
62+
# Pause 2 seconds.
63+
time.sleep(2)
64+
# Clear the screen blue.
65+
display.fill(color565(0, 0, 255))
66+
# Pause 2 seconds.
67+
time.sleep(2)
68+
69+
API Reference
70+
=============
71+
72+
.. toctree::
73+
:maxdepth: 2
74+
75+
api
76+
77+
Contributing
78+
============
79+
80+
Contributions are welcome! Please read our `Code of Conduct
81+
<https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/master/CODE_OF_CONDUCT.md>`_
82+
before contributing to help this project stay welcoming.
83+
84+
Building locally
85+
================
86+
87+
To build this library locally you'll need to install the
88+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
89+
90+
.. code-block:: shell
91+
92+
python3 -m venv .env
93+
source .env/bin/activate
94+
pip install circuitpython-build-tools
95+
96+
Once installed, make sure you are in the virtual environment:
97+
98+
.. code-block:: shell
99+
100+
source .env/bin/activate
101+
102+
Then run the build:
103+
104+
.. code-block:: shell
105+
106+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-rgb_display --library_location .

adafruit_rgb_display/hx8353.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1-
"""A simple driver for the HX8353-based displays."""
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2017 Radomir Dopieralski and Adafruit Industries
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
"""
23+
`adafruit_RGB_Display.hx8353`
24+
====================================================
25+
26+
A simple driver for the HX8353-based displays.
27+
28+
* Author(s): Radomir Dopieralski, Michael McWethy
29+
"""
230
from adafruit_rgb_display.rgb import DisplaySPI
331
from micropython import const
432

adafruit_rgb_display/ili9341.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1-
"""A simple driver for the ILI9341/ILI9340-based displays."""
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2017 Radomir Dopieralski and Adafruit Industries
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
"""
23+
`adafruit_RGB_Display.ili9341`
24+
====================================================
25+
26+
A simple driver for the ILI9341/ILI9340-based displays.
27+
28+
* Author(s): Radomir Dopieralski, Michael McWethy
29+
"""
230

331
try:
432
import struct

adafruit_rgb_display/rgb.py

+42-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
1-
""" Base class for all RGB Display devices """
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2017 Radomir Dopieralski and Adafruit Industries
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
"""
23+
`adafruit_RGB_Display.rgb`
24+
====================================================
25+
26+
Base class for all RGB Display devices
27+
28+
* Author(s): Radomir Dopieralski, Michael McWethy
29+
"""
30+
231
import time
332
from micropython import const
433
try:
@@ -17,12 +46,14 @@
1746

1847

1948
def color565(r, g, b):
20-
"""Format color code for device"""
49+
"""Convert red, green and blue values (0-255) into a 16-bit 565 encoding. As
50+
a convenience this is also available in the parent adafruit_rgb_display
51+
package namespace."""
2152
return (r & 0xf8) << 8 | (g & 0xfc) << 3 | b >> 3
2253

2354

2455
class DummyPin:
25-
"""A fake gpio pin for when you want to skip pins."""
56+
"""Can be used in place of a ``Pin()`` when you don't want to skip it."""
2657
def init(self, *args, **kwargs):
2758
"""Dummy Pin init"""
2859
pass
@@ -37,7 +68,10 @@ def high(self):
3768

3869

3970
class Display: #pylint: disable-msg=no-member
40-
"""Base class for all RGB display devices"""
71+
"""Base class for all RGB display devices
72+
:param width: number of pixels wide
73+
:param height: number of pixels high
74+
"""
4175
_PAGE_SET = None
4276
_COLUMN_SET = None
4377
_RAM_WRITE = None
@@ -83,7 +117,7 @@ def _decode_pixel(self, data):
83117
return color565(*struct.unpack(self._DECODE_PIXEL, data))
84118

85119
def pixel(self, x, y, color=None):
86-
"""Read or write a pixel."""
120+
"""Read or write a pixel at a given position."""
87121
if color is None:
88122
return self._decode_pixel(self._block(x, y, x, y))
89123

@@ -93,7 +127,8 @@ def pixel(self, x, y, color=None):
93127

94128
#pylint: disable-msg=too-many-arguments
95129
def fill_rectangle(self, x, y, width, height, color):
96-
"""Draw a filled rectangle."""
130+
"""Draw a rectangle at specified position with specified width and
131+
height, and fill it with the specified color."""
97132
x = min(self.width - 1, max(0, x))
98133
y = min(self.height - 1, max(0, y))
99134
width = min(self.width - x, max(1, width))
@@ -109,7 +144,7 @@ def fill_rectangle(self, x, y, width, height, color):
109144
#pylint: enable-msg=too-many-arguments
110145

111146
def fill(self, color=0):
112-
"""Fill whole screen."""
147+
"""Fill the whole display with the specified color."""
113148
self.fill_rectangle(0, 0, self.width, self.height, color)
114149

115150
def hline(self, x, y, width, color):

0 commit comments

Comments
 (0)