Skip to content

Improve Ref Docs #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
c706cfe
renamed some examples
sommersoft Feb 24, 2018
a1d6d32
setup docs folder
sommersoft Feb 24, 2018
cdaf85e
updated .travis & .readthedocs yml
sommersoft Feb 24, 2018
87234e0
updated README
sommersoft Feb 24, 2018
bcd9483
sphinx fix
sommersoft Feb 24, 2018
1085e3f
sphinx fixes; docstring indentation
sommersoft Feb 24, 2018
c0a05de
more sphinx fix
sommersoft Feb 24, 2018
833de06
more trial-n-error sphinx fixes
sommersoft Feb 24, 2018
715182f
sphinx; stubborn 'block quote ends without blank line' won't budge
sommersoft Feb 24, 2018
2b197dc
pylint fixes; still trying sphinx fix
sommersoft Feb 24, 2018
2a6c1c7
still trying to get sphinx to build
sommersoft Feb 24, 2018
f6a72ca
sphinx fix; think it was an unescaped use of '\n'
sommersoft Feb 24, 2018
18a9a02
still trying to escape '\n'
sommersoft Feb 24, 2018
f8e36dd
added adafruit_character_lcd to conf.py automock
sommersoft Feb 24, 2018
9f24a0a
updated api.rst
sommersoft Feb 24, 2018
387f690
updated title docstrings
sommersoft Feb 24, 2018
a127769
updated api.rst...again
sommersoft Feb 24, 2018
bc6bfe6
more sphinx api title fixes
sommersoft Feb 24, 2018
56dbdfa
fixed typo
sommersoft Feb 24, 2018
c6d678b
still debugging api-no-title shpinx
sommersoft Feb 24, 2018
060f58e
still debugging api-no-title shpinx
sommersoft Feb 24, 2018
36fa08e
still debugging api-no-title shpinx
sommersoft Feb 24, 2018
916f7e2
requirements missing bus_device
sommersoft Feb 24, 2018
9013a84
still debugging api-no-title shpinx
sommersoft Feb 24, 2018
f797411
sphinx api title fix
sommersoft Mar 5, 2018
f3ed452
renamed some examples
sommersoft Feb 24, 2018
d03b2ab
setup docs folder
sommersoft Feb 24, 2018
efb673c
updated .travis & .readthedocs yml
sommersoft Feb 24, 2018
f5f23d0
updated README
sommersoft Feb 24, 2018
4eb0758
sphinx fix
sommersoft Feb 24, 2018
c9da84a
sphinx fixes; docstring indentation
sommersoft Feb 24, 2018
05cc3f3
more sphinx fix
sommersoft Feb 24, 2018
79b908c
more trial-n-error sphinx fixes
sommersoft Feb 24, 2018
22b6c4e
sphinx; stubborn 'block quote ends without blank line' won't budge
sommersoft Feb 24, 2018
e9a0c59
pylint fixes; still trying sphinx fix
sommersoft Feb 24, 2018
7603f0d
still trying to get sphinx to build
sommersoft Feb 24, 2018
d4fb210
sphinx fix; think it was an unescaped use of '\n'
sommersoft Feb 24, 2018
8cb6a21
still trying to escape '\n'
sommersoft Feb 24, 2018
14bc319
added adafruit_character_lcd to conf.py automock
sommersoft Feb 24, 2018
00e4b42
updated api.rst
sommersoft Feb 24, 2018
e8ceca3
updated title docstrings
sommersoft Feb 24, 2018
82487be
updated api.rst...again
sommersoft Feb 24, 2018
d4a744d
more sphinx api title fixes
sommersoft Feb 24, 2018
79647c0
fixed typo
sommersoft Feb 24, 2018
0e28792
still debugging api-no-title shpinx
sommersoft Feb 24, 2018
2079f90
still debugging api-no-title shpinx
sommersoft Feb 24, 2018
304a6ca
still debugging api-no-title shpinx
sommersoft Feb 24, 2018
035fc25
requirements missing bus_device
sommersoft Feb 24, 2018
116e651
still debugging api-no-title shpinx
sommersoft Feb 24, 2018
b35c7ca
sphinx api title fix
sommersoft Mar 5, 2018
0593619
Merge branch 'new_docs' of https://github.com/sommersoft/Adafruit_Cir…
sommersoft Mar 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ deploy:
provider: releases
api_key: $GITHUB_TOKEN
file_glob: true
file: bundles/*
file: $TRAVIS_BUILD_DIR/bundles/*
skip_cleanup: true
on:
tags: true

install:
- pip install pylint circuitpython-build-tools
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme

script:
- pylint adafruit_character_lcd/*.py
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-charlcd --library_location .
- cd docs && sphinx-build -E -W -b html . _build/html
81 changes: 71 additions & 10 deletions README.md → README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,49 @@
Introduction
============

.. image:: https://readthedocs.org/projects/adafruit-circuitpython-charlcd/badge/?version=latest
:target: https://circuitpython.readthedocs.io/projects/charlcd/en/latest/
:alt: Documentation Status

.. image :: https://img.shields.io/discord/327254708534116352.svg
:target: https://discord.gg/nBQh6qu
:alt: Discord

This library is compatible with standard Character LCDs such as:
* [Adafruit Standard LCD 16x2](https://www.adafruit.com/product/181)
* [Adafruit RGB backlight negative LCD 16x2](https://www.adafruit.com/product/399)
* [Adafruit RGB backlight negative LCD 20x4](https://www.adafruit.com/product/498)
* `Adafruit Standard LCD 16x2 <https://www.adafruit.com/product/181>`_
* `Adafruit RGB backlight negative LCD 16x2 <https://www.adafruit.com/product/399>`_
* `Adafruit RGB backlight negative LCD 20x4 <https://www.adafruit.com/product/498>`_

Compatible with CircuitPython Versions: 2.x

Dependencies
=============
This driver depends on:

* [Adafruit CircuitPython](https://github.com/adafruit/circuitpython "CircuitPython")
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_

I2C & SPI displays also depend on:

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

Please ensure all dependencies are available on the CircuitPython filesystem.
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://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.

Usage Example
=============

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

.. code-block:: python

import adafruit_character_lcd

You must define the data pins (``RS``, ``EN``, ``D4``, ``D5``, ``D6``, ``D7``) in your code before using the ``Character_LCD`` class.
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

.. code-block:: python

lcd_rs = digitalio.DigitalInOut(D7)
lcd_en = digitalio.DigitalInOut(D8)
lcd_d7 = digitalio.DigitalInOut(D12)
Expand All @@ -40,16 +55,22 @@ If you want to have on/off ``backlight`` functionality, you can also define your

You must also define the size of the CharLCD by specifying its ``lcd_columns`` and ``lcd_rows``:

.. code-block:: python

lcd_columns = 16
lcd_rows = 2

After you have set up your LCD, we can make the device by calling it

.. code-block:: python

lcd = adafruit_character_lcd.Character_LCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)


To verify that your pins are correct, print a hello message to the CharLCD:

.. code-block:: python

lcd.message('hello\ncircuitpython')


Expand All @@ -73,9 +94,49 @@ To install:
#. Download and unzip the `latest release zip <https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/releases>`_.
#. Copy the unzipped ``adafruit_character_lcd`` to the ``lib`` directory on the ``CIRCUITPY`` or ``MICROPYTHON`` drive.

API
===
.. toctree::
:maxdepth: 3
Building locally
================

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 adafruit-circuitpython-charlcd --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

api
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.
106 changes: 70 additions & 36 deletions adafruit_character_lcd/character_lcd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""Character_LCD - module for interfacing with character lcds
# The MIT License (MIT)
#
# Copyright (c) 2017 Brent Rubell for Adafruit Industries
Expand All @@ -20,16 +19,30 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
`adafruit_CircuitPython_CharLCD`
"""
`adafruit_character_lcd.character_lcd`
====================================================
* Author(s):
-Brent Rubell
-Asher Lieber
-Tony DiCola for the original python charLCD library

:mod:`adafruit_character_lcd`
=================================================
module for interfacing with character lcds"""
Module for interfacing with monochromatic character LCDs

* Author(s): Brent Rubell, Asher Lieber, Tony DiCola (original python charLCD library)

Implementation Notes
--------------------

**Hardware:**

* Adafruit `Character LCDs
<http://www.adafruit.com/category/63_96>`_

**Software and Dependencies:**

* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
https://github.com/adafruit/circuitpython/releases
* Adafruit's Bus Device library (when using I2C/SPI):
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

"""

import time
import digitalio
Expand Down Expand Up @@ -113,17 +126,19 @@ def _set_bit(byte_value, position, val):

#pylint: disable-msg=too-many-instance-attributes
class Character_LCD(object):
""" Interfaces with a character LCD
:param ~digitalio.DigitalInOut rs: The reset data line
:param ~digitalio.DigitalInOut en: The enable data line
:param ~digitalio.DigitalInOut d4: The data line 4
:param ~digitalio.DigitalInOut d5: The data line 5
:param ~digitalio.DigitalInOut d6: The data line 6
:param ~digitalio.DigitalInOut d7: The data line 7
:param cols: The columns on the charLCD
:param lines: The lines on the charLCD
:param ~digitalio.DigitalInOut backlight: The backlight pin, usually
the last pin. Check with your datasheet
"""
Interfaces with a character LCD
:param ~digitalio.DigitalInOut rs: The reset data line
:param ~digitalio.DigitalInOut en: The enable data line
:param ~digitalio.DigitalInOut d4: The data line 4
:param ~digitalio.DigitalInOut d5: The data line 5
:param ~digitalio.DigitalInOut d6: The data line 6
:param ~digitalio.DigitalInOut d7: The data line 7
:param cols: The columns on the charLCD
:param lines: The lines on the charLCD
:param ~digitalio.DigitalInOut backlight: The backlight pin, usually
the last pin. Check with your datasheet

"""
#pylint: disable-msg=too-many-arguments
def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
Expand Down Expand Up @@ -180,8 +195,11 @@ def clear(self):
time.sleep(0.003)

def show_cursor(self, show):
"""Show or hide the cursor
:param show: True to show cursor, False to hide
"""
Show or hide the cursor

:param show: True to show cursor, False to hide

"""
if show:
self.displaycontrol |= LCD_CURSORON
Expand All @@ -190,9 +208,12 @@ def show_cursor(self, show):
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)

def set_cursor(self, col, row):
"""Sets the cursor to ``row`` and ``col``
:param col: column location
:param row: row location
"""
Sets the cursor to ``row`` and ``col``

:param col: column location
:param row: row location

"""
# Clamp row to the last row of the display
if row > self.lines:
Expand All @@ -201,8 +222,11 @@ def set_cursor(self, col, row):
self._write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))

def blink(self, blink):
"""Blinks the cursor if blink = true.
:param blink: True to blink, False no blink
"""
Blinks the cursor if blink = true.

:param blink: True to blink, False no blink

"""
if blink is True:
self.displaycontrol |= LCD_BLINKON
Expand All @@ -229,8 +253,11 @@ def set_right_to_left(self):
self._write8(LCD_ENTRYMODESET | self.displaymode)

def enable_display(self, enable):
"""Enable or disable the display.
:param enable: True to enable display, False to disable
"""
Enable or disable the display.

:param enable: True to enable display, False to disable

"""
if enable:
self.displaycontrol |= LCD_DISPLAYON
Expand Down Expand Up @@ -272,8 +299,11 @@ def _pulse_enable(self):
time.sleep(0.0000001)

def set_backlight(self, lighton):
""" Set lighton to turn the charLCD backlight on.
:param lighton: True to turn backlight on, False to turn off
"""
Set lighton to turn the charLCD backlight on.

:param lighton: True to turn backlight on, False to turn off

"""
if lighton:
self.backlight.value = 0
Expand All @@ -282,8 +312,10 @@ def set_backlight(self, lighton):


def message(self, text):
"""Write text to display, can include \n for newline
:param text: string to display
"""
Write text to display. Can include ``\\n`` for newline.

:param text: text string to display
"""
line = 0
# iterate thru each char
Expand All @@ -299,13 +331,15 @@ def message(self, text):
self._write8(ord(char), True)

def create_char(self, location, pattern):
"""Fill one of the first 8 CGRAM locations with custom characters.
"""
Fill one of the first 8 CGRAM locations with custom characters.
The location parameter should be between 0 and 7 and pattern should
provide an array of 8 bytes containing the pattern. E.g. you can easyly
design your custom character at http://www.quinapalus.com/hd44780udg.html
To show your custom character use eg. lcd.message('\x01')
:param location: integer in range(8) to store the created character
:param ~bytes pattern: len(8) describes created character

:param location: integer in range(8) to store the created character
:param ~bytes pattern: len(8) describes created character

"""
# only position 0..7 are allowed
Expand Down
29 changes: 20 additions & 9 deletions adafruit_character_lcd/character_lcd_rgb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""Character_LCD_RGB - module for interfacing with character lcds
# The MIT License (MIT)
#
# Copyright (c) 2017 Brent Rubell for Adafruit Industries
Expand All @@ -20,20 +19,32 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

`adafruit_CircuitPython_CharLCD`
"""
`adafruit_character_lcd.character_lcd_rgb`
====================================================

Character_LCD - module for interfacing with RGB character LCDs

* Author(s):
-Brent Rubell
-Asher Lieber
-Tony DiCola for the original python charLCD library
-Brent Rubell
-Asher Lieber
-Tony DiCola for the original python charLCD library

Implementation Notes
--------------------

**Hardware:**

* Adafruit `Character LCDs
<http://www.adafruit.com/category/63_96>`_

**Software and Dependencies:**

* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
https://github.com/adafruit/circuitpython/releases
* Adafruit's Bus Device library (when using I2C/SPI):
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

:mod:`adafruit_character_lcd_RGB`
=================================================
module for interfacing with RGB character lcds
"""
import time
import digitalio
Expand Down
13 changes: 10 additions & 3 deletions adafruit_character_lcd/mcp23008.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
"""MCP23008 I2C GPIO Extender Driver
"""
`adafruit_character_lcd.mcp23008`
=========================================

MCP23008 I2C GPIO Extender Driver
Bare-bones driver for the MCP23008 driver, as used by the character LCD
backpack. This exposes the MCP2308 and its pins as standard CircuitPython
digitalio pins. Currently this is integrated in the character LCD class for
simplicity and reduction in dependent imports, but it could be broken out
into a standalone library later."""
# Author: Tony DiCola
into a standalone library later.

* Author: Tony DiCola

"""
import digitalio

import adafruit_bus_device.i2c_device as i2c_device
Expand Down
Loading