Skip to content

Commit 6bb5b72

Browse files
authored
Merge pull request #8 from sommersoft/new_docs
Improve Ref Docs
2 parents e2c6689 + 0593619 commit 6bb5b72

18 files changed

+270
-80
lines changed
File renamed without changes.

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ 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
2121
on:
2222
tags: true
2323

2424
install:
25-
- pip install pylint circuitpython-build-tools
25+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2626

2727
script:
2828
- pylint adafruit_character_lcd/*.py
2929
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3030
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-charlcd --library_location .
31+
- cd docs && sphinx-build -E -W -b html . _build/html

README.md renamed to README.rst

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,49 @@
22
Introduction
33
============
44

5+
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-charlcd/badge/?version=latest
6+
:target: https://circuitpython.readthedocs.io/projects/charlcd/en/latest/
7+
:alt: Documentation Status
8+
9+
.. image :: https://img.shields.io/discord/327254708534116352.svg
10+
:target: https://discord.gg/nBQh6qu
11+
:alt: Discord
12+
513
This library is compatible with standard Character LCDs such as:
6-
* [Adafruit Standard LCD 16x2](https://www.adafruit.com/product/181)
7-
* [Adafruit RGB backlight negative LCD 16x2](https://www.adafruit.com/product/399)
8-
* [Adafruit RGB backlight negative LCD 20x4](https://www.adafruit.com/product/498)
14+
* `Adafruit Standard LCD 16x2 <https://www.adafruit.com/product/181>`_
15+
* `Adafruit RGB backlight negative LCD 16x2 <https://www.adafruit.com/product/399>`_
16+
* `Adafruit RGB backlight negative LCD 20x4 <https://www.adafruit.com/product/498>`_
917

1018
Compatible with CircuitPython Versions: 2.x
1119

1220
Dependencies
1321
=============
1422
This driver depends on:
1523

16-
* [Adafruit CircuitPython](https://github.com/adafruit/circuitpython "CircuitPython")
24+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
25+
26+
I2C & SPI displays also depend on:
1727

28+
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
1829

1930
Please ensure all dependencies are available on the CircuitPython filesystem.
2031
This is easily achieved by downloading
21-
[the Adafruit library and driver bundle.](https://github.com/adafruit/Adafruit_CircuitPython_Bundle)
32+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
2233

2334
Usage Example
2435
=============
2536

2637
The ``Character_LCD`` class interfaces a predefined Character LCD display with CircuitPython.
2738

39+
.. code-block:: python
40+
2841
import adafruit_character_lcd
2942
3043
You must define the data pins (``RS``, ``EN``, ``D4``, ``D5``, ``D6``, ``D7``) in your code before using the ``Character_LCD`` class.
3144
If you want to have on/off ``backlight`` functionality, you can also define your backlight as ``lcd_backlight``. Otherwise, the backlight will always remain on. An example of this is below
3245

46+
.. code-block:: python
47+
3348
lcd_rs = digitalio.DigitalInOut(D7)
3449
lcd_en = digitalio.DigitalInOut(D8)
3550
lcd_d7 = digitalio.DigitalInOut(D12)
@@ -40,16 +55,22 @@ If you want to have on/off ``backlight`` functionality, you can also define your
4055
4156
You must also define the size of the CharLCD by specifying its ``lcd_columns`` and ``lcd_rows``:
4257

58+
.. code-block:: python
59+
4360
lcd_columns = 16
4461
lcd_rows = 2
4562
4663
After you have set up your LCD, we can make the device by calling it
4764

65+
.. code-block:: python
66+
4867
lcd = adafruit_character_lcd.Character_LCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
4968
5069
5170
To verify that your pins are correct, print a hello message to the CharLCD:
5271

72+
.. code-block:: python
73+
5374
lcd.message('hello\ncircuitpython')
5475
5576
@@ -73,9 +94,49 @@ To install:
7394
#. Download and unzip the `latest release zip <https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/releases>`_.
7495
#. Copy the unzipped ``adafruit_character_lcd`` to the ``lib`` directory on the ``CIRCUITPY`` or ``MICROPYTHON`` drive.
7596

76-
API
77-
===
78-
.. toctree::
79-
:maxdepth: 3
97+
Building locally
98+
================
99+
100+
To build this library locally you'll need to install the
101+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
102+
103+
.. code-block:: shell
104+
105+
python3 -m venv .env
106+
source .env/bin/activate
107+
pip install circuitpython-build-tools
108+
109+
Once installed, make sure you are in the virtual environment:
110+
111+
.. code-block:: shell
112+
113+
source .env/bin/activate
114+
115+
Then run the build:
116+
117+
.. code-block:: shell
118+
119+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-charlcd --library_location .
120+
121+
Sphinx documentation
122+
-----------------------
123+
124+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
125+
install dependencies (feel free to reuse the virtual environment from above):
126+
127+
.. code-block:: shell
128+
129+
python3 -m venv .env
130+
source .env/bin/activate
131+
pip install Sphinx sphinx-rtd-theme
132+
133+
Now, once you have the virtual environment activated:
134+
135+
.. code-block:: shell
136+
137+
cd docs
138+
sphinx-build -E -W -b html . _build/html
80139
81-
api
140+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
141+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
142+
locally verify it will pass.

adafruit_character_lcd/character_lcd.py

Lines changed: 70 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
"""Character_LCD - module for interfacing with character lcds
21
# The MIT License (MIT)
32
#
43
# Copyright (c) 2017 Brent Rubell for Adafruit Industries
@@ -20,16 +19,30 @@
2019
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2120
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2221
# THE SOFTWARE.
23-
`adafruit_CircuitPython_CharLCD`
22+
"""
23+
`adafruit_character_lcd.character_lcd`
2424
====================================================
25-
* Author(s):
26-
-Brent Rubell
27-
-Asher Lieber
28-
-Tony DiCola for the original python charLCD library
2925
30-
:mod:`adafruit_character_lcd`
31-
=================================================
32-
module for interfacing with character lcds"""
26+
Module for interfacing with monochromatic character LCDs
27+
28+
* Author(s): Brent Rubell, Asher Lieber, Tony DiCola (original python charLCD library)
29+
30+
Implementation Notes
31+
--------------------
32+
33+
**Hardware:**
34+
35+
* Adafruit `Character LCDs
36+
<http://www.adafruit.com/category/63_96>`_
37+
38+
**Software and Dependencies:**
39+
40+
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
41+
https://github.com/adafruit/circuitpython/releases
42+
* Adafruit's Bus Device library (when using I2C/SPI):
43+
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
44+
45+
"""
3346

3447
import time
3548
import digitalio
@@ -113,17 +126,19 @@ def _set_bit(byte_value, position, val):
113126

114127
#pylint: disable-msg=too-many-instance-attributes
115128
class Character_LCD(object):
116-
""" Interfaces with a character LCD
117-
:param ~digitalio.DigitalInOut rs: The reset data line
118-
:param ~digitalio.DigitalInOut en: The enable data line
119-
:param ~digitalio.DigitalInOut d4: The data line 4
120-
:param ~digitalio.DigitalInOut d5: The data line 5
121-
:param ~digitalio.DigitalInOut d6: The data line 6
122-
:param ~digitalio.DigitalInOut d7: The data line 7
123-
:param cols: The columns on the charLCD
124-
:param lines: The lines on the charLCD
125-
:param ~digitalio.DigitalInOut backlight: The backlight pin, usually
126-
the last pin. Check with your datasheet
129+
"""
130+
Interfaces with a character LCD
131+
:param ~digitalio.DigitalInOut rs: The reset data line
132+
:param ~digitalio.DigitalInOut en: The enable data line
133+
:param ~digitalio.DigitalInOut d4: The data line 4
134+
:param ~digitalio.DigitalInOut d5: The data line 5
135+
:param ~digitalio.DigitalInOut d6: The data line 6
136+
:param ~digitalio.DigitalInOut d7: The data line 7
137+
:param cols: The columns on the charLCD
138+
:param lines: The lines on the charLCD
139+
:param ~digitalio.DigitalInOut backlight: The backlight pin, usually
140+
the last pin. Check with your datasheet
141+
127142
"""
128143
#pylint: disable-msg=too-many-arguments
129144
def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
@@ -180,8 +195,11 @@ def clear(self):
180195
time.sleep(0.003)
181196

182197
def show_cursor(self, show):
183-
"""Show or hide the cursor
184-
:param show: True to show cursor, False to hide
198+
"""
199+
Show or hide the cursor
200+
201+
:param show: True to show cursor, False to hide
202+
185203
"""
186204
if show:
187205
self.displaycontrol |= LCD_CURSORON
@@ -190,9 +208,12 @@ def show_cursor(self, show):
190208
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)
191209

192210
def set_cursor(self, col, row):
193-
"""Sets the cursor to ``row`` and ``col``
194-
:param col: column location
195-
:param row: row location
211+
"""
212+
Sets the cursor to ``row`` and ``col``
213+
214+
:param col: column location
215+
:param row: row location
216+
196217
"""
197218
# Clamp row to the last row of the display
198219
if row > self.lines:
@@ -201,8 +222,11 @@ def set_cursor(self, col, row):
201222
self._write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))
202223

203224
def blink(self, blink):
204-
"""Blinks the cursor if blink = true.
205-
:param blink: True to blink, False no blink
225+
"""
226+
Blinks the cursor if blink = true.
227+
228+
:param blink: True to blink, False no blink
229+
206230
"""
207231
if blink is True:
208232
self.displaycontrol |= LCD_BLINKON
@@ -229,8 +253,11 @@ def set_right_to_left(self):
229253
self._write8(LCD_ENTRYMODESET | self.displaymode)
230254

231255
def enable_display(self, enable):
232-
"""Enable or disable the display.
233-
:param enable: True to enable display, False to disable
256+
"""
257+
Enable or disable the display.
258+
259+
:param enable: True to enable display, False to disable
260+
234261
"""
235262
if enable:
236263
self.displaycontrol |= LCD_DISPLAYON
@@ -272,8 +299,11 @@ def _pulse_enable(self):
272299
time.sleep(0.0000001)
273300

274301
def set_backlight(self, lighton):
275-
""" Set lighton to turn the charLCD backlight on.
276-
:param lighton: True to turn backlight on, False to turn off
302+
"""
303+
Set lighton to turn the charLCD backlight on.
304+
305+
:param lighton: True to turn backlight on, False to turn off
306+
277307
"""
278308
if lighton:
279309
self.backlight.value = 0
@@ -282,8 +312,10 @@ def set_backlight(self, lighton):
282312

283313

284314
def message(self, text):
285-
"""Write text to display, can include \n for newline
286-
:param text: string to display
315+
"""
316+
Write text to display. Can include ``\\n`` for newline.
317+
318+
:param text: text string to display
287319
"""
288320
line = 0
289321
# iterate thru each char
@@ -299,13 +331,15 @@ def message(self, text):
299331
self._write8(ord(char), True)
300332

301333
def create_char(self, location, pattern):
302-
"""Fill one of the first 8 CGRAM locations with custom characters.
334+
"""
335+
Fill one of the first 8 CGRAM locations with custom characters.
303336
The location parameter should be between 0 and 7 and pattern should
304337
provide an array of 8 bytes containing the pattern. E.g. you can easyly
305338
design your custom character at http://www.quinapalus.com/hd44780udg.html
306339
To show your custom character use eg. lcd.message('\x01')
307-
:param location: integer in range(8) to store the created character
308-
:param ~bytes pattern: len(8) describes created character
340+
341+
:param location: integer in range(8) to store the created character
342+
:param ~bytes pattern: len(8) describes created character
309343
310344
"""
311345
# only position 0..7 are allowed

adafruit_character_lcd/character_lcd_rgb.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
"""Character_LCD_RGB - module for interfacing with character lcds
21
# The MIT License (MIT)
32
#
43
# Copyright (c) 2017 Brent Rubell for Adafruit Industries
@@ -20,20 +19,32 @@
2019
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2120
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2221
# THE SOFTWARE.
23-
24-
`adafruit_CircuitPython_CharLCD`
22+
"""
23+
`adafruit_character_lcd.character_lcd_rgb`
2524
====================================================
2625
26+
Character_LCD - module for interfacing with RGB character LCDs
2727
2828
* Author(s):
29-
-Brent Rubell
30-
-Asher Lieber
31-
-Tony DiCola for the original python charLCD library
29+
-Brent Rubell
30+
-Asher Lieber
31+
-Tony DiCola for the original python charLCD library
32+
33+
Implementation Notes
34+
--------------------
35+
36+
**Hardware:**
37+
38+
* Adafruit `Character LCDs
39+
<http://www.adafruit.com/category/63_96>`_
40+
41+
**Software and Dependencies:**
3242
43+
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
44+
https://github.com/adafruit/circuitpython/releases
45+
* Adafruit's Bus Device library (when using I2C/SPI):
46+
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
3347
34-
:mod:`adafruit_character_lcd_RGB`
35-
=================================================
36-
module for interfacing with RGB character lcds
3748
"""
3849
import time
3950
import digitalio

adafruit_character_lcd/mcp23008.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
"""MCP23008 I2C GPIO Extender Driver
1+
"""
2+
`adafruit_character_lcd.mcp23008`
3+
=========================================
4+
5+
MCP23008 I2C GPIO Extender Driver
26
Bare-bones driver for the MCP23008 driver, as used by the character LCD
37
backpack. This exposes the MCP2308 and its pins as standard CircuitPython
48
digitalio pins. Currently this is integrated in the character LCD class for
59
simplicity and reduction in dependent imports, but it could be broken out
6-
into a standalone library later."""
7-
# Author: Tony DiCola
10+
into a standalone library later.
11+
12+
* Author: Tony DiCola
13+
14+
"""
815
import digitalio
916

1017
import adafruit_bus_device.i2c_device as i2c_device

0 commit comments

Comments
 (0)