Skip to content

Commit 02aa570

Browse files
committed
Updated files to make an interesting ReadToDocs
1 parent fce56de commit 02aa570

7 files changed

+169
-13
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
__pycache__
2+
_build
3+
*.pyc
14
.env
25
build*
36
bundles

.pylintrc

+4-3
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]
@@ -300,7 +301,7 @@ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
300301

301302
# Good variable names which should always be accepted, separated by a comma
302303
# good-names=i,j,k,ex,Run,_
303-
good-names=r,g,b,i,j,k,n,ex,Run,_
304+
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
304305

305306
# Include a hint for the correct naming format with invalid-name
306307
include-naming-hint=no
@@ -422,7 +423,7 @@ max-returns=6
422423
max-statements=50
423424

424425
# Minimum number of public methods for a class (see R0903).
425-
min-public-methods=2
426+
min-public-methods=1
426427

427428

428429
[EXCEPTIONS]

.readthedocs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
python:
2+
version: 3
3+
requirements_file: requirements.txt

.travis.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ deploy:
1616
provider: releases
1717
api_key: $GITHUB_TOKEN
1818
file_glob: true
19-
file: bundles/*
19+
file: $TRAVIS_BUILD_DIR/bundles/*
2020
skip_cleanup: true
21+
overwrite: true
2122
on:
2223
tags: true
2324

2425
install:
25-
- pip install pylint circuitpython-build-tools
26+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2627

2728
script:
2829
- pylint adafruit_ssd1306.py
29-
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
30+
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
3031
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ssd1306 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

LICENSE

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

3-
Copyright (c) 2016 Adafruit Industries
3+
Copyright (c) 2016, 2017 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

+123-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,124 @@
1-
Adafruit CircuitPython driver for SSD1306 OLED displays.
1+
Introduction
2+
============
23

3-
This driver is based on the SSD1306 driver in the MicroPython source but differs
4-
by supporting hardware I2C interfaces and Adafruit CircuitPython API. For a
5-
MicroPython machine API compatible library see: https://github.com/adafruit/micropython-adafruit-ssd1306
4+
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-ssd1306/badge/?version=latest
5+
:target: https://circuitpython.readthedocs.io/projects/ssd1306/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
11+
12+
.. image:: https://travis-ci.org/adafruit/adafruit_CircuitPython_SSD1306.svg?branch=master
13+
:target: https://travis-ci.org/adafruit/adafruit_CircuitPython_SSD1306
14+
:alt: Build Status
15+
16+
Adafruit CircuitPython driver for SSD1306 OLED displays.
17+
18+
This driver is based on the SSD1306 driver in the MicroPython source but differs
19+
by supporting hardware I2C interfaces and Adafruit CircuitPython API. For a
20+
MicroPython machine API compatible library see: https://github.com/adafruit/micropython-adafruit-ssd1306
21+
22+
23+
Dependencies
24+
=============
25+
This driver depends on:
26+
27+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
28+
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
29+
30+
Please ensure all dependencies are available on the CircuitPython filesystem.
31+
This is easily achieved by downloading
32+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
33+
34+
Usage Example
35+
=============
36+
37+
.. code-block:: python3
38+
39+
# Basic example of clearing and drawing pixels on a SSD1306 OLED display.
40+
# This example and library is meant to work with Adafruit CircuitPython API.
41+
# Author: Tony DiCola
42+
# License: Public Domain
43+
44+
# Import all board pins.
45+
from board import SCL, SDA
46+
import busio
47+
48+
# Import the SSD1306 module.
49+
import adafruit_ssd1306
50+
51+
52+
# Create the I2C interface.
53+
i2c = busio.I2C(SCL, SDA)
54+
55+
# Create the SSD1306 OLED class.
56+
# The first two parameters are the pixel width and pixel height. Change these
57+
# to the right size for your display!
58+
display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
59+
# Alternatively you can change the I2C address of the device with an addr parameter:
60+
#display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31)
61+
62+
# Clear the display. Always call show after changing pixels to make the display
63+
# update visible!
64+
display.fill(0)
65+
66+
display.show()
67+
68+
69+
Contributing
70+
============
71+
72+
Contributions are welcome! Please read our `Code of Conduct
73+
<https://github.com/adafruit/adafruit_CircuitPython_SSD1306/blob/master/CODE_OF_CONDUCT.md>`_
74+
before contributing to help this project stay welcoming.
75+
76+
Building locally
77+
================
78+
79+
Zip release files
80+
-----------------
81+
82+
To build this library locally you'll need to install the
83+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
84+
85+
.. code-block:: shell
86+
87+
python3 -m venv .env
88+
source .env/bin/activate
89+
pip install circuitpython-build-tools
90+
91+
Once installed, make sure you are in the virtual environment:
92+
93+
.. code-block:: shell
94+
95+
source .env/bin/activate
96+
97+
Then run the build:
98+
99+
.. code-block:: shell
100+
101+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ssd1306 --library_location .
102+
103+
Sphinx documentation
104+
-----------------------
105+
106+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
107+
install dependencies (feel free to reuse the virtual environment from above):
108+
109+
.. code-block:: shell
110+
111+
python3 -m venv .env
112+
source .env/bin/activate
113+
pip install Sphinx sphinx-rtd-theme
114+
115+
Now, once you have the virtual environment activated:
116+
117+
.. code-block:: shell
118+
119+
cd docs
120+
sphinx-build -E -W -b html . _build/html
121+
122+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
123+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
124+
locally verify it will pass.

adafruit_ssd1306.py

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
1-
"""SSD1306 OLED driver, I2C and SPI interfaces"""
2-
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2017 Michael McWethy
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_SSD1306`
24+
====================================================
25+
26+
MicroPython SSD1306 OLED driver, I2C and SPI interfaces
27+
28+
* Author(s): Tony DiCola, Michael McWethy
29+
"""
30+
331
import time
432
import framebuf
533

0 commit comments

Comments
 (0)