Compare commits
No commits in common. "master" and "kattni-patch-1" have entirely different histories.
master
...
kattni-pat
33 changed files with 1286 additions and 1833 deletions
57
.github/workflows/build.yml
vendored
57
.github/workflows/build.yml
vendored
|
|
@ -1,57 +0,0 @@
|
||||||
name: Build CI
|
|
||||||
|
|
||||||
on: [pull_request, push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Dump GitHub context
|
|
||||||
env:
|
|
||||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
||||||
run: echo "$GITHUB_CONTEXT"
|
|
||||||
- name: Translate Repo Name For Build Tools filename_prefix
|
|
||||||
id: repo-name
|
|
||||||
run: |
|
|
||||||
echo ::set-output name=repo-name::$(
|
|
||||||
echo ${{ github.repository }} |
|
|
||||||
awk -F '\/' '{ print tolower($2) }' |
|
|
||||||
tr '_' '-'
|
|
||||||
)
|
|
||||||
- name: Set up Python 3.6
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: 3.6
|
|
||||||
- name: Versions
|
|
||||||
run: |
|
|
||||||
python3 --version
|
|
||||||
- name: Checkout Current Repo
|
|
||||||
uses: actions/checkout@v1
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- name: Checkout tools repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: adafruit/actions-ci-circuitpython-libs
|
|
||||||
path: actions-ci
|
|
||||||
- name: Install dependencies
|
|
||||||
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
|
|
||||||
run: |
|
|
||||||
source actions-ci/install.sh
|
|
||||||
- name: Pip install pylint, black, & Sphinx
|
|
||||||
run: |
|
|
||||||
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
|
|
||||||
- name: Library version
|
|
||||||
run: git describe --dirty --always --tags
|
|
||||||
- name: Check formatting
|
|
||||||
run: |
|
|
||||||
black --check --target-version=py35 .
|
|
||||||
- name: PyLint
|
|
||||||
run: |
|
|
||||||
pylint $( find . -path './adafruit*.py' )
|
|
||||||
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" ))
|
|
||||||
- name: Build assets
|
|
||||||
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
|
|
||||||
- name: Build docs
|
|
||||||
working-directory: docs
|
|
||||||
run: sphinx-build -E -W -b html . _build/html
|
|
||||||
81
.github/workflows/release.yml
vendored
81
.github/workflows/release.yml
vendored
|
|
@ -1,81 +0,0 @@
|
||||||
name: Release Actions
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
upload-release-assets:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Dump GitHub context
|
|
||||||
env:
|
|
||||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
||||||
run: echo "$GITHUB_CONTEXT"
|
|
||||||
- name: Translate Repo Name For Build Tools filename_prefix
|
|
||||||
id: repo-name
|
|
||||||
run: |
|
|
||||||
echo ::set-output name=repo-name::$(
|
|
||||||
echo ${{ github.repository }} |
|
|
||||||
awk -F '\/' '{ print tolower($2) }' |
|
|
||||||
tr '_' '-'
|
|
||||||
)
|
|
||||||
- name: Set up Python 3.6
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: 3.6
|
|
||||||
- name: Versions
|
|
||||||
run: |
|
|
||||||
python3 --version
|
|
||||||
- name: Checkout Current Repo
|
|
||||||
uses: actions/checkout@v1
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- name: Checkout tools repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: adafruit/actions-ci-circuitpython-libs
|
|
||||||
path: actions-ci
|
|
||||||
- name: Install deps
|
|
||||||
run: |
|
|
||||||
source actions-ci/install.sh
|
|
||||||
- name: Build assets
|
|
||||||
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
|
|
||||||
- name: Upload Release Assets
|
|
||||||
# the 'official' actions version does not yet support dynamically
|
|
||||||
# supplying asset names to upload. @csexton's version chosen based on
|
|
||||||
# discussion in the issue below, as its the simplest to implement and
|
|
||||||
# allows for selecting files with a pattern.
|
|
||||||
# https://github.com/actions/upload-release-asset/issues/4
|
|
||||||
#uses: actions/upload-release-asset@v1.0.1
|
|
||||||
uses: csexton/release-asset-action@master
|
|
||||||
with:
|
|
||||||
pattern: "bundles/*"
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
upload-pypi:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Check For setup.py
|
|
||||||
id: need-pypi
|
|
||||||
run: |
|
|
||||||
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
|
|
||||||
- name: Set up Python
|
|
||||||
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
- name: Install dependencies
|
|
||||||
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install setuptools wheel twine
|
|
||||||
- name: Build and publish
|
|
||||||
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
|
|
||||||
env:
|
|
||||||
TWINE_USERNAME: ${{ secrets.pypi_username }}
|
|
||||||
TWINE_PASSWORD: ${{ secrets.pypi_password }}
|
|
||||||
run: |
|
|
||||||
python setup.py sdist
|
|
||||||
twine upload dist/*
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,6 +4,7 @@ __pycache__
|
||||||
_build
|
_build
|
||||||
*.pyc
|
*.pyc
|
||||||
.env
|
.env
|
||||||
|
build*
|
||||||
bundles
|
bundles
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
.eggs
|
.eggs
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ confidence=
|
||||||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||||
# --disable=W"
|
# --disable=W"
|
||||||
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
|
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
|
||||||
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation
|
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error
|
||||||
|
|
||||||
# Enable the message, report, category or checker with the given id(s). You can
|
# Enable the message, report, category or checker with the given id(s). You can
|
||||||
# either give multiple identifier separated by comma (,) or put this option
|
# either give multiple identifier separated by comma (,) or put this option
|
||||||
|
|
@ -119,8 +119,7 @@ spelling-store-unknown-words=no
|
||||||
[MISCELLANEOUS]
|
[MISCELLANEOUS]
|
||||||
|
|
||||||
# List of note tags to take in consideration, separated by a comma.
|
# List of note tags to take in consideration, separated by a comma.
|
||||||
# notes=FIXME,XXX,TODO
|
notes=FIXME,XXX,TODO
|
||||||
notes=FIXME,XXX
|
|
||||||
|
|
||||||
|
|
||||||
[TYPECHECK]
|
[TYPECHECK]
|
||||||
|
|
@ -301,7 +300,7 @@ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
# Good variable names which should always be accepted, separated by a comma
|
# Good variable names which should always be accepted, separated by a comma
|
||||||
# good-names=i,j,k,ex,Run,_
|
# good-names=i,j,k,ex,Run,_
|
||||||
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
|
good-names=r,g,b,i,j,k,n,ex,Run,_
|
||||||
|
|
||||||
# Include a hint for the correct naming format with invalid-name
|
# Include a hint for the correct naming format with invalid-name
|
||||||
include-naming-hint=no
|
include-naming-hint=no
|
||||||
|
|
@ -423,7 +422,7 @@ max-returns=6
|
||||||
max-statements=50
|
max-statements=50
|
||||||
|
|
||||||
# Minimum number of public methods for a class (see R0903).
|
# Minimum number of public methods for a class (see R0903).
|
||||||
min-public-methods=1
|
min-public-methods=2
|
||||||
|
|
||||||
|
|
||||||
[EXCEPTIONS]
|
[EXCEPTIONS]
|
||||||
|
|
|
||||||
32
.travis.yml
Normal file
32
.travis.yml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
dist: trusty
|
||||||
|
sudo: false
|
||||||
|
language: python
|
||||||
|
python:
|
||||||
|
- '3.6'
|
||||||
|
cache:
|
||||||
|
pip: true
|
||||||
|
deploy:
|
||||||
|
- provider: releases
|
||||||
|
api_key: "$GITHUB_TOKEN"
|
||||||
|
file_glob: true
|
||||||
|
file: "$TRAVIS_BUILD_DIR/bundles/*"
|
||||||
|
skip_cleanup: true
|
||||||
|
overwrite: true
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
- provider: pypi
|
||||||
|
user: adafruit-travis
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
password:
|
||||||
|
secure: oFtv5bdkv05CtHQWGsGErePA41nC81eH9rBtTmvLV8eBU6+KMLwP5mn6u9bRryAiK7xXvdn9YWQfB1w+OTgdZjCMxITGXoPGBxsQ5Fg7k8Jft127e2zJFdFfpa5oSEnP4fEm+C5GzlH3a8WRa8NbGY44zetSxK6HhbSpaItVYyQ7rPcz+sPxfyyBIKVsAzj9DD7tLlDsNJw6Gsp9pL//yvdEzv7/hr7tjwyEmEPHAczbmrXu/824zJjHIB9Dkbv9etXLvhGwtLToP/pbwsTNDRSdI8n3yr4zDmGSqFGJa+awOlohWFPjmitmQodoXr9XKqZO7GtKocQ1z1MLopueYcQiVs9hIqYlMWNg8dVlSrCALGnNeF3NwMQq30DNC1gUXhhGPY6cxcBruJtXVJ65MyD3pEkHio5ET+ct5MUJi0nmikQSh3jPZolzCecZSC0gI9xO4Yqy6vVKWD7GzhNYo4plhWtu0CZW/ixmjUCTVN9CNV2JXbRNV985axDunrx3gu3In2hihC2XGtkxSJomkSsXexvtEeKstjlmhA5LSHauIbnAIM4hOPUpyWk5IqTZQblmzBigiZ5JRZzAzuNN80H1WWlaEEynV2nHO6pFVphu3bWpEyzhhLByWi3fk27w3Y0sroJ6yx5YcAJuq/PNEUyeA3JATXkd55OFzujH+2A=
|
||||||
|
install:
|
||||||
|
- pip install -r requirements.txt
|
||||||
|
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
|
||||||
|
- pip install --force-reinstall pylint==1.9.2
|
||||||
|
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 && cd ..
|
||||||
|
|
@ -34,15 +34,13 @@ Examples of unacceptable behavior by participants include:
|
||||||
* Excessive or unwelcome helping; answering outside the scope of the question
|
* Excessive or unwelcome helping; answering outside the scope of the question
|
||||||
asked
|
asked
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
* Promoting or spreading disinformation, lies, or conspiracy theories against
|
|
||||||
a person, group, organisation, project, or community
|
|
||||||
* Public or private harassment
|
* Public or private harassment
|
||||||
* Publishing others' private information, such as a physical or electronic
|
* Publishing others' private information, such as a physical or electronic
|
||||||
address, without explicit permission
|
address, without explicit permission
|
||||||
* Other conduct which could reasonably be considered inappropriate
|
* Other conduct which could reasonably be considered inappropriate
|
||||||
|
|
||||||
The goal of the standards and moderation guidelines outlined here is to build
|
The goal of the standards and moderation guidelines outlined here is to build
|
||||||
and maintain a respectful community. We ask that you don’t just aim to be
|
and maintain a respectful community. We ask that you don’t just aim to be
|
||||||
"technically unimpeachable", but rather try to be your best self.
|
"technically unimpeachable", but rather try to be your best self.
|
||||||
|
|
||||||
We value many things beyond technical expertise, including collaboration and
|
We value many things beyond technical expertise, including collaboration and
|
||||||
|
|
@ -74,10 +72,10 @@ You may report in the following ways:
|
||||||
In any situation, you may send an email to <support@adafruit.com>.
|
In any situation, you may send an email to <support@adafruit.com>.
|
||||||
|
|
||||||
On the Adafruit Discord, you may send an open message from any channel
|
On the Adafruit Discord, you may send an open message from any channel
|
||||||
to all Community Moderators by tagging @community moderators. You may
|
to all Community Helpers by tagging @community helpers. You may also send an
|
||||||
also send an open message from any channel, or a direct message to
|
open message from any channel, or a direct message to @kattni#1507,
|
||||||
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
|
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
|
||||||
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
|
@Andon#8175.
|
||||||
|
|
||||||
Email and direct message reports will be kept confidential.
|
Email and direct message reports will be kept confidential.
|
||||||
|
|
||||||
|
|
@ -85,7 +83,7 @@ In situations on Discord where the issue is particularly egregious, possibly
|
||||||
illegal, requires immediate action, or violates the Discord terms of service,
|
illegal, requires immediate action, or violates the Discord terms of service,
|
||||||
you should also report the message directly to Discord.
|
you should also report the message directly to Discord.
|
||||||
|
|
||||||
These are the steps for upholding our community’s standards of conduct.
|
These are the steps for upholding our community’s standards of conduct.
|
||||||
|
|
||||||
1. Any member of the community may report any situation that violates the
|
1. Any member of the community may report any situation that violates the
|
||||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||||
|
|
|
||||||
123
README.rst
123
README.rst
|
|
@ -7,11 +7,11 @@ Introduction
|
||||||
:alt: Documentation Status
|
:alt: Documentation Status
|
||||||
|
|
||||||
.. image :: https://img.shields.io/discord/327254708534116352.svg
|
.. image :: https://img.shields.io/discord/327254708534116352.svg
|
||||||
:target: https://adafru.it/discord
|
:target: https://discord.gg/nBQh6qu
|
||||||
:alt: Discord
|
:alt: Discord
|
||||||
|
|
||||||
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/workflows/Build%20CI/badge.svg
|
.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_CharLCD.svg?branch=master
|
||||||
:target: https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/actions/
|
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_CharLCD
|
||||||
:alt: Build Status
|
:alt: Build Status
|
||||||
|
|
||||||
This library is compatible with standard Character LCDs such as:
|
This library is compatible with standard Character LCDs such as:
|
||||||
|
|
@ -19,39 +19,13 @@ This library is compatible with standard Character LCDs such as:
|
||||||
* `Adafruit RGB backlight negative LCD 16x2 <https://www.adafruit.com/product/399>`_
|
* `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 RGB backlight negative LCD 20x4 <https://www.adafruit.com/product/498>`_
|
||||||
|
|
||||||
Installing from PyPI
|
Compatible with CircuitPython Versions: 2.x
|
||||||
--------------------
|
|
||||||
|
|
||||||
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
|
|
||||||
PyPI <https://pypi.org/project/adafruit-circuitpython-charlcd/>`_. To install for current user:
|
|
||||||
|
|
||||||
.. code-block:: shell
|
|
||||||
|
|
||||||
pip3 install adafruit-circuitpython-charlcd
|
|
||||||
|
|
||||||
To install system-wide (this may be required in some cases):
|
|
||||||
|
|
||||||
.. code-block:: shell
|
|
||||||
|
|
||||||
sudo pip3 install adafruit-circuitpython-charlcd
|
|
||||||
|
|
||||||
To install in a virtual environment in your current project:
|
|
||||||
|
|
||||||
.. code-block:: shell
|
|
||||||
|
|
||||||
mkdir project-name && cd project-name
|
|
||||||
python3 -m venv .env
|
|
||||||
source .env/bin/activate
|
|
||||||
pip3 install adafruit-circuitpython-charlcd
|
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
=============
|
=============
|
||||||
This driver depends on:
|
This driver depends on:
|
||||||
|
|
||||||
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
|
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
|
||||||
* `Adafruit CircuitPython BusDevice <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
|
|
||||||
* `Adafruit CircuitPython MCP230xx <https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx>`_
|
|
||||||
* `Adafruit CircuitPython 74HC595 <https://github.com/adafruit/Adafruit_CircuitPython_74HC595>`_
|
|
||||||
|
|
||||||
I2C & SPI displays also depend on:
|
I2C & SPI displays also depend on:
|
||||||
|
|
||||||
|
|
@ -68,23 +42,20 @@ The ``Character_LCD`` class interfaces a predefined Character LCD display with C
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import board
|
import adafruit_character_lcd
|
||||||
import digitalio
|
|
||||||
import adafruit_character_lcd.character_lcd as character_lcd
|
|
||||||
|
|
||||||
You must define the data pins (``RS``, ``EN``, ``D4``, ``D5``, ``D6``, ``D7``) in your code before using the ``Character_LCD`` class.
|
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
|
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
|
||||||
will always remain on. The following is an example setup.
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
lcd_rs = digitalio.DigitalInOut(board.D7)
|
lcd_rs = digitalio.DigitalInOut(D7)
|
||||||
lcd_en = digitalio.DigitalInOut(board.D8)
|
lcd_en = digitalio.DigitalInOut(D8)
|
||||||
lcd_d7 = digitalio.DigitalInOut(board.D12)
|
lcd_d7 = digitalio.DigitalInOut(D12)
|
||||||
lcd_d6 = digitalio.DigitalInOut(board.D11)
|
lcd_d6 = digitalio.DigitalInOut(D11)
|
||||||
lcd_d5 = digitalio.DigitalInOut(board.D10)
|
lcd_d5 = digitalio.DigitalInOut(D10)
|
||||||
lcd_d4 = digitalio.DigitalInOut(board.D9)
|
lcd_d4 = digitalio.DigitalInOut(D9)
|
||||||
lcd_backlight = digitalio.DigitalInOut(board.D13)
|
lcd_backlight = digitalio.DigitalInOut(D13)
|
||||||
|
|
||||||
You must also define the size of the CharLCD by specifying its ``lcd_columns`` and ``lcd_rows``:
|
You must also define the size of the CharLCD by specifying its ``lcd_columns`` and ``lcd_rows``:
|
||||||
|
|
||||||
|
|
@ -97,27 +68,79 @@ After you have set up your LCD, we can make the device by calling it
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
lcd = character_lcd.Character_LCD_Mono(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
|
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:
|
To verify that your pins are correct, print a hello message to the CharLCD:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
lcd.message('hello\ncircuitpython')
|
||||||
|
|
||||||
|
|
||||||
Custom character example with ``create_char()`` is provided within /examples/
|
Custom character example with create_char() is provided within /examples/
|
||||||
|
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
============
|
============
|
||||||
|
|
||||||
Contributions are welcome! Please read our `Code of Conduct
|
Contributions are welcome! Please read our [Code of Conduct](https://github.com/adafruit/Adafruit_CircuitPython_CircuitPython_CharLCD/blob/master/CODE_OF_CONDUCT.md)
|
||||||
<https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/CODE_OF_CONDUCT.md>`_ before contributing to help this project stay welcoming.
|
before contributing to help this project stay welcoming.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
Documentation
|
This library is **NOT** built into CircuitPython to make it easy to update. To
|
||||||
=============
|
install it either follow the directions below or :ref:`install the library bundle <bundle_installation>`.
|
||||||
|
|
||||||
For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.
|
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.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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.
|
||||||
3
adafruit_character_lcd/__init__.py
Normal file
3
adafruit_character_lcd/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
"""include all classes"""
|
||||||
|
from adafruit_character_lcd.character_lcd import Character_LCD, Character_LCD_I2C, Character_LCD_SPI
|
||||||
|
from adafruit_character_lcd.character_lcd_rgb import Character_LCD_RGB
|
||||||
837
adafruit_character_lcd/character_lcd.py
Executable file → Normal file
837
adafruit_character_lcd/character_lcd.py
Executable file → Normal file
|
|
@ -1,7 +1,6 @@
|
||||||
# The MIT License (MIT)
|
# The MIT License (MIT)
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017 Brent Rubell for Adafruit Industries
|
# Copyright (c) 2017 Brent Rubell for Adafruit Industries
|
||||||
# Copyright (c) 2018 Kattni Rembor for Adafruit Industries
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
@ -26,19 +25,19 @@
|
||||||
|
|
||||||
Module for interfacing with monochromatic character LCDs
|
Module for interfacing with monochromatic character LCDs
|
||||||
|
|
||||||
* Author(s): Kattni Rembor, Brent Rubell, Asher Lieber,
|
* Author(s): Brent Rubell, Asher Lieber, Tony DiCola (original python charLCD library)
|
||||||
Tony DiCola (original python charLCD library)
|
|
||||||
|
|
||||||
Implementation Notes
|
Implementation Notes
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
**Hardware:**
|
**Hardware:**
|
||||||
|
|
||||||
"* `Adafruit Character LCDs <http://www.adafruit.com/category/63_96>`_"
|
* Adafruit `Character LCDs
|
||||||
|
<http://www.adafruit.com/category/63_96>`_
|
||||||
|
|
||||||
**Software and Dependencies:**
|
**Software and Dependencies:**
|
||||||
|
|
||||||
* Adafruit CircuitPython firmware:
|
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
|
||||||
https://github.com/adafruit/circuitpython/releases
|
https://github.com/adafruit/circuitpython/releases
|
||||||
* Adafruit's Bus Device library (when using I2C/SPI):
|
* Adafruit's Bus Device library (when using I2C/SPI):
|
||||||
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
|
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
|
||||||
|
|
@ -52,44 +51,67 @@ from micropython import const
|
||||||
__version__ = "0.0.0-auto.0"
|
__version__ = "0.0.0-auto.0"
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CharLCD.git"
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CharLCD.git"
|
||||||
|
|
||||||
# pylint: disable-msg=bad-whitespace
|
#pylint: disable-msg=bad-whitespace
|
||||||
# Commands
|
# Commands
|
||||||
_LCD_CLEARDISPLAY = const(0x01)
|
LCD_CLEARDISPLAY = const(0x01)
|
||||||
_LCD_RETURNHOME = const(0x02)
|
LCD_RETURNHOME = const(0x02)
|
||||||
_LCD_ENTRYMODESET = const(0x04)
|
LCD_ENTRYMODESET = const(0x04)
|
||||||
_LCD_DISPLAYCONTROL = const(0x08)
|
LCD_DISPLAYCONTROL = const(0x08)
|
||||||
_LCD_CURSORSHIFT = const(0x10)
|
LCD_CURSORSHIFT = const(0x10)
|
||||||
_LCD_FUNCTIONSET = const(0x20)
|
LCD_FUNCTIONSET = const(0x20)
|
||||||
_LCD_SETCGRAMADDR = const(0x40)
|
LCD_SETCGRAMADDR = const(0x40)
|
||||||
_LCD_SETDDRAMADDR = const(0x80)
|
LCD_SETDDRAMADDR = const(0x80)
|
||||||
|
|
||||||
# Entry flags
|
# Entry flags
|
||||||
_LCD_ENTRYLEFT = const(0x02)
|
LCD_ENTRYRIGHT = const(0x00)
|
||||||
_LCD_ENTRYSHIFTDECREMENT = const(0x00)
|
LCD_ENTRYLEFT = const(0x02)
|
||||||
|
LCD_ENTRYSHIFTINCREMENT = const(0x01)
|
||||||
|
LCD_ENTRYSHIFTDECREMENT = const(0x00)
|
||||||
|
|
||||||
# Control flags
|
# Control flags
|
||||||
_LCD_DISPLAYON = const(0x04)
|
LCD_DISPLAYON = const(0x04)
|
||||||
_LCD_CURSORON = const(0x02)
|
LCD_DISPLAYOFF = const(0x00)
|
||||||
_LCD_CURSOROFF = const(0x00)
|
LCD_CURSORON = const(0x02)
|
||||||
_LCD_BLINKON = const(0x01)
|
LCD_CURSOROFF = const(0x00)
|
||||||
_LCD_BLINKOFF = const(0x00)
|
LCD_BLINKON = const(0x01)
|
||||||
|
LCD_BLINKOFF = const(0x00)
|
||||||
|
|
||||||
# Move flags
|
# Move flags
|
||||||
_LCD_DISPLAYMOVE = const(0x08)
|
LCD_DISPLAYMOVE = const(0x08)
|
||||||
_LCD_MOVERIGHT = const(0x04)
|
LCD_CURSORMOVE = const(0x00)
|
||||||
_LCD_MOVELEFT = const(0x00)
|
LCD_MOVERIGHT = const(0x04)
|
||||||
|
LCD_MOVELEFT = const(0x00)
|
||||||
|
|
||||||
# Function set flags
|
# Function set flags
|
||||||
_LCD_4BITMODE = const(0x00)
|
LCD_8BITMODE = const(0x10)
|
||||||
_LCD_2LINE = const(0x08)
|
LCD_4BITMODE = const(0x00)
|
||||||
_LCD_1LINE = const(0x00)
|
LCD_2LINE = const(0x08)
|
||||||
_LCD_5X8DOTS = const(0x00)
|
LCD_1LINE = const(0x00)
|
||||||
|
LCD_5X10DOTS = const(0x04)
|
||||||
|
LCD_5X8DOTS = const(0x00)
|
||||||
|
|
||||||
# Offset for up to 4 rows.
|
# Offset for up to 4 rows.
|
||||||
_LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)
|
LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)
|
||||||
|
|
||||||
# pylint: enable-msg=bad-whitespace
|
# MCP23008 I2C backpack pin mapping from LCD logical pin to MCP23008 pin.
|
||||||
|
_MCP23008_LCD_RS = const(1)
|
||||||
|
_MCP23008_LCD_EN = const(2)
|
||||||
|
_MCP23008_LCD_D4 = const(3)
|
||||||
|
_MCP23008_LCD_D5 = const(4)
|
||||||
|
_MCP23008_LCD_D6 = const(5)
|
||||||
|
_MCP23008_LCD_D7 = const(6)
|
||||||
|
_MCP23008_LCD_BACKLIGHT = const(7)
|
||||||
|
|
||||||
|
# 74HC595 SPI backpack pin mapping from LCD logical pin to 74HC595 pin.
|
||||||
|
_74HC595_LCD_RS = const(1)
|
||||||
|
_74HC595_LCD_EN = const(2)
|
||||||
|
_74HC595_LCD_D4 = const(6)
|
||||||
|
_74HC595_LCD_D5 = const(5)
|
||||||
|
_74HC595_LCD_D6 = const(4)
|
||||||
|
_74HC595_LCD_D7 = const(3)
|
||||||
|
_74HC595_LCD_BACKLIGHT = const(7)
|
||||||
|
|
||||||
|
#pylint: enable-msg=bad-whitespace
|
||||||
|
|
||||||
def _set_bit(byte_value, position, val):
|
def _set_bit(byte_value, position, val):
|
||||||
# Given the specified byte_value set the bit at position to the provided
|
# Given the specified byte_value set the bit at position to the provided
|
||||||
|
|
@ -99,43 +121,33 @@ def _set_bit(byte_value, position, val):
|
||||||
ret = byte_value | (1 << position)
|
ret = byte_value | (1 << position)
|
||||||
else:
|
else:
|
||||||
ret = byte_value & ~(1 << position)
|
ret = byte_value & ~(1 << position)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
#pylint: disable-msg=too-many-instance-attributes
|
||||||
def _map(xval, in_min, in_max, out_min, out_max):
|
class Character_LCD(object):
|
||||||
# Affine transfer/map with constrained output.
|
"""
|
||||||
outrange = float(out_max - out_min)
|
Interfaces with a character LCD
|
||||||
inrange = float(in_max - in_min)
|
|
||||||
ret = (xval - in_min) * (outrange / inrange) + out_min
|
|
||||||
if out_max > out_min:
|
|
||||||
ret = max(min(ret, out_max), out_min)
|
|
||||||
else:
|
|
||||||
ret = max(min(ret, out_min), out_max)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable-msg=too-many-instance-attributes
|
|
||||||
class Character_LCD:
|
|
||||||
"""Base class for character LCD.
|
|
||||||
|
|
||||||
:param ~digitalio.DigitalInOut rs: The reset data line
|
:param ~digitalio.DigitalInOut rs: The reset data line
|
||||||
:param ~digitalio.DigitalInOut en: The enable data line
|
:param ~digitalio.DigitalInOut en: The enable data line
|
||||||
:param ~digitalio.DigitalInOut d4: The data line 4
|
:param ~digitalio.DigitalInOut d4: The data line 4
|
||||||
:param ~digitalio.DigitalInOut d5: The data line 5
|
:param ~digitalio.DigitalInOut d5: The data line 5
|
||||||
:param ~digitalio.DigitalInOut d6: The data line 6
|
:param ~digitalio.DigitalInOut d6: The data line 6
|
||||||
:param ~digitalio.DigitalInOut d7: The data line 7
|
:param ~digitalio.DigitalInOut d7: The data line 7
|
||||||
:param columns: The columns on the charLCD
|
:param cols: The columns on the charLCD
|
||||||
:param lines: The lines 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,
|
||||||
|
backlight=None #,
|
||||||
|
#enable_pwm = False,
|
||||||
|
#initial_backlight = 1.0
|
||||||
|
):
|
||||||
|
|
||||||
LEFT_TO_RIGHT = const(0)
|
self.cols = cols
|
||||||
RIGHT_TO_LEFT = const(1)
|
|
||||||
|
|
||||||
# pylint: disable-msg=too-many-arguments
|
|
||||||
def __init__(self, rs, en, d4, d5, d6, d7, columns, lines):
|
|
||||||
|
|
||||||
self.columns = columns
|
|
||||||
self.lines = lines
|
self.lines = lines
|
||||||
# save pin numbers
|
# save pin numbers
|
||||||
self.reset = rs
|
self.reset = rs
|
||||||
|
|
@ -144,370 +156,114 @@ class Character_LCD:
|
||||||
self.dl5 = d5
|
self.dl5 = d5
|
||||||
self.dl6 = d6
|
self.dl6 = d6
|
||||||
self.dl7 = d7
|
self.dl7 = d7
|
||||||
|
# backlight pin
|
||||||
|
self.backlight = backlight
|
||||||
|
# self.pwn_enabled = enable_pwm
|
||||||
# set all pins as outputs
|
# set all pins as outputs
|
||||||
for pin in (rs, en, d4, d5, d6, d7):
|
for pin in(rs, en, d4, d5, d6, d7):
|
||||||
pin.direction = digitalio.Direction.OUTPUT
|
pin.direction = digitalio.Direction.OUTPUT
|
||||||
|
# Setup backlight
|
||||||
# Initialise the display
|
if backlight is not None:
|
||||||
|
self.backlight.direction = digitalio.Direction.OUTPUT
|
||||||
|
self.backlight.value = 0 # turn backlight on
|
||||||
|
# initialize the display
|
||||||
self._write8(0x33)
|
self._write8(0x33)
|
||||||
self._write8(0x32)
|
self._write8(0x32)
|
||||||
# Initialise display control
|
# init. display control
|
||||||
self.displaycontrol = _LCD_DISPLAYON | _LCD_CURSOROFF | _LCD_BLINKOFF
|
self.displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF
|
||||||
# Initialise display function
|
# init display function
|
||||||
self.displayfunction = _LCD_4BITMODE | _LCD_1LINE | _LCD_2LINE | _LCD_5X8DOTS
|
self.displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_2LINE | LCD_5X8DOTS
|
||||||
# Initialise display mode
|
# init display mode
|
||||||
self.displaymode = _LCD_ENTRYLEFT | _LCD_ENTRYSHIFTDECREMENT
|
self.displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT
|
||||||
# Write to displaycontrol
|
# write to display control
|
||||||
self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol)
|
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)
|
||||||
# Write to displayfunction
|
# write displayfunction
|
||||||
self._write8(_LCD_FUNCTIONSET | self.displayfunction)
|
self._write8(LCD_FUNCTIONSET | self.displayfunction)
|
||||||
# Set entry mode
|
# set the entry mode
|
||||||
self._write8(_LCD_ENTRYMODESET | self.displaymode)
|
self._write8(LCD_ENTRYMODESET | self.displaymode)
|
||||||
self.clear()
|
self.clear()
|
||||||
|
#pylint: enable-msg=too-many-arguments
|
||||||
self._message = None
|
|
||||||
self._enable = None
|
|
||||||
self._direction = None
|
|
||||||
# track row and column used in cursor_position
|
|
||||||
# initialize to 0,0
|
|
||||||
self.row = 0
|
|
||||||
self.column = 0
|
|
||||||
self._column_align = False
|
|
||||||
|
|
||||||
# pylint: enable-msg=too-many-arguments
|
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
"""Moves the cursor "home" to position (1, 1)."""
|
"""Moves the cursor back home pos(1,1)"""
|
||||||
self._write8(_LCD_RETURNHOME)
|
self._write8(LCD_RETURNHOME)
|
||||||
time.sleep(0.003)
|
time.sleep(0.003)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""Clears everything displayed on the LCD.
|
"""Clears the LCD"""
|
||||||
|
self._write8(LCD_CLEARDISPLAY)
|
||||||
The following example displays, "Hello, world!", then clears the LCD.
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
lcd.message = "Hello, world!"
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.clear()
|
|
||||||
"""
|
|
||||||
self._write8(_LCD_CLEARDISPLAY)
|
|
||||||
time.sleep(0.003)
|
time.sleep(0.003)
|
||||||
|
|
||||||
@property
|
def show_cursor(self, show):
|
||||||
def column_align(self):
|
|
||||||
"""If True, message text after '\\n' starts directly below start of first
|
|
||||||
character in message. If False, text after '\\n' starts at column zero.
|
|
||||||
"""
|
"""
|
||||||
return self._column_align
|
Show or hide the cursor
|
||||||
|
|
||||||
@column_align.setter
|
:param show: True to show cursor, False to hide
|
||||||
def column_align(self, enable):
|
|
||||||
if isinstance(enable, bool):
|
|
||||||
self._column_align = enable
|
|
||||||
else:
|
|
||||||
raise ValueError("The column_align value must be either True or False")
|
|
||||||
|
|
||||||
@property
|
|
||||||
def cursor(self):
|
|
||||||
"""True if cursor is visible. False to stop displaying the cursor.
|
|
||||||
|
|
||||||
The following example shows the cursor after a displayed message:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
lcd.cursor = True
|
|
||||||
lcd.message = "Cursor! "
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.displaycontrol & _LCD_CURSORON == _LCD_CURSORON
|
|
||||||
|
|
||||||
@cursor.setter
|
|
||||||
def cursor(self, show):
|
|
||||||
if show:
|
if show:
|
||||||
self.displaycontrol |= _LCD_CURSORON
|
self.displaycontrol |= LCD_CURSORON
|
||||||
else:
|
else:
|
||||||
self.displaycontrol &= ~_LCD_CURSORON
|
self.displaycontrol &= ~LCD_DISPLAYON
|
||||||
self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol)
|
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)
|
||||||
|
|
||||||
def cursor_position(self, column, row):
|
def set_cursor(self, col, row):
|
||||||
"""Move the cursor to position ``column``, ``row`` for the next
|
"""
|
||||||
message only. Displaying a message resets the cursor position to (0, 0).
|
Sets the cursor to ``row`` and ``col``
|
||||||
|
|
||||||
|
:param col: column location
|
||||||
|
:param row: row location
|
||||||
|
|
||||||
:param column: column location
|
|
||||||
:param row: row location
|
|
||||||
"""
|
"""
|
||||||
# Clamp row to the last row of the display
|
# Clamp row to the last row of the display
|
||||||
if row >= self.lines:
|
if row > self.lines:
|
||||||
row = self.lines - 1
|
row = self.lines - 1
|
||||||
# Clamp to last column of display
|
|
||||||
if column >= self.columns:
|
|
||||||
column = self.columns - 1
|
|
||||||
# Set location
|
# Set location
|
||||||
self._write8(_LCD_SETDDRAMADDR | (column + _LCD_ROW_OFFSETS[row]))
|
self._write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))
|
||||||
# Update self.row and self.column to match setter
|
|
||||||
self.row = row
|
|
||||||
self.column = column
|
|
||||||
|
|
||||||
@property
|
|
||||||
def blink(self):
|
|
||||||
"""
|
|
||||||
Blink the cursor. True to blink the cursor. False to stop blinking.
|
|
||||||
|
|
||||||
The following example shows a message followed by a blinking cursor for five seconds.
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
lcd.blink = True
|
|
||||||
lcd.message = "Blinky cursor!"
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.blink = False
|
|
||||||
"""
|
|
||||||
return self.displaycontrol & _LCD_BLINKON == _LCD_BLINKON
|
|
||||||
|
|
||||||
@blink.setter
|
|
||||||
def blink(self, blink):
|
def blink(self, blink):
|
||||||
if blink:
|
"""
|
||||||
self.displaycontrol |= _LCD_BLINKON
|
Blinks the cursor if blink = true.
|
||||||
|
|
||||||
|
:param blink: True to blink, False no blink
|
||||||
|
|
||||||
|
"""
|
||||||
|
if blink is True:
|
||||||
|
self.displaycontrol |= LCD_BLINKON
|
||||||
else:
|
else:
|
||||||
self.displaycontrol &= ~_LCD_BLINKON
|
self.displaycontrol &= ~LCD_BLINKON
|
||||||
self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol)
|
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)
|
||||||
|
|
||||||
@property
|
|
||||||
def display(self):
|
|
||||||
"""
|
|
||||||
Enable or disable the display. True to enable the display. False to disable the display.
|
|
||||||
|
|
||||||
The following example displays, "Hello, world!" on the LCD and then turns the display off.
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
lcd.message = "Hello, world!"
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.display = False
|
|
||||||
"""
|
|
||||||
return self.displaycontrol & _LCD_DISPLAYON == _LCD_DISPLAYON
|
|
||||||
|
|
||||||
@display.setter
|
|
||||||
def display(self, enable):
|
|
||||||
if enable:
|
|
||||||
self.displaycontrol |= _LCD_DISPLAYON
|
|
||||||
else:
|
|
||||||
self.displaycontrol &= ~_LCD_DISPLAYON
|
|
||||||
self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def message(self):
|
|
||||||
"""Display a string of text on the character LCD.
|
|
||||||
Start position is (0,0) if cursor_position is not set.
|
|
||||||
If cursor_position is set, message starts at the set
|
|
||||||
position from the left for left to right text and from
|
|
||||||
the right for right to left text. Resets cursor column
|
|
||||||
and row to (0,0) after displaying the message.
|
|
||||||
|
|
||||||
The following example displays, "Hello, world!" on the LCD.
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
lcd.message = "Hello, world!"
|
|
||||||
time.sleep(5)
|
|
||||||
"""
|
|
||||||
return self._message
|
|
||||||
|
|
||||||
@message.setter
|
|
||||||
def message(self, message):
|
|
||||||
self._message = message
|
|
||||||
# Set line to match self.row from cursor_position()
|
|
||||||
line = self.row
|
|
||||||
# Track times through iteration, to act on the initial character of the message
|
|
||||||
initial_character = 0
|
|
||||||
# iterate through each character
|
|
||||||
for character in message:
|
|
||||||
# If this is the first character in the string:
|
|
||||||
if initial_character == 0:
|
|
||||||
# Start at (0, 0) unless direction is set right to left, in which case start
|
|
||||||
# on the opposite side of the display if cursor_position not set or (0,0)
|
|
||||||
# If cursor_position is set then starts at the specified location for
|
|
||||||
# LEFT_TO_RIGHT. If RIGHT_TO_LEFT cursor_position is determined from right.
|
|
||||||
# allows for cursor_position to work in RIGHT_TO_LEFT mode
|
|
||||||
if self.displaymode & _LCD_ENTRYLEFT > 0:
|
|
||||||
col = self.column
|
|
||||||
else:
|
|
||||||
col = self.columns - 1 - self.column
|
|
||||||
self.cursor_position(col, line)
|
|
||||||
initial_character += 1
|
|
||||||
# If character is \n, go to next line
|
|
||||||
if character == "\n":
|
|
||||||
line += 1
|
|
||||||
# Start the second line at (0, 1) unless direction is set right to left in
|
|
||||||
# which case start on the opposite side of the display if cursor_position
|
|
||||||
# is (0,0) or not set. Start second line at same column as first line when
|
|
||||||
# cursor_position is set
|
|
||||||
if self.displaymode & _LCD_ENTRYLEFT > 0:
|
|
||||||
col = self.column * self._column_align
|
|
||||||
else:
|
|
||||||
if self._column_align:
|
|
||||||
col = self.column
|
|
||||||
else:
|
|
||||||
col = self.columns - 1
|
|
||||||
self.cursor_position(col, line)
|
|
||||||
# Write string to display
|
|
||||||
else:
|
|
||||||
self._write8(ord(character), True)
|
|
||||||
# reset column and row to (0,0) after message is displayed
|
|
||||||
self.column, self.row = 0, 0
|
|
||||||
|
|
||||||
def move_left(self):
|
def move_left(self):
|
||||||
"""Moves displayed text left one column.
|
"""Moves display left one position"""
|
||||||
|
self._write8(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT)
|
||||||
The following example scrolls a message to the left off the screen.
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
scroll_message = "<-- Scroll"
|
|
||||||
lcd.message = scroll_message
|
|
||||||
time.sleep(2)
|
|
||||||
for i in range(len(scroll_message)):
|
|
||||||
lcd.move_left()
|
|
||||||
time.sleep(0.5)
|
|
||||||
"""
|
|
||||||
self._write8(_LCD_CURSORSHIFT | _LCD_DISPLAYMOVE | _LCD_MOVELEFT)
|
|
||||||
|
|
||||||
def move_right(self):
|
def move_right(self):
|
||||||
"""Moves displayed text right one column.
|
"""Moves display right one position"""
|
||||||
|
self._write8(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT)
|
||||||
|
|
||||||
The following example scrolls a message to the right off the screen.
|
def set_left_to_right(self):
|
||||||
|
"""Set direction of text to read from left to right"""
|
||||||
|
self.displaymode |= LCD_ENTRYLEFT
|
||||||
|
self._write8(LCD_ENTRYMODESET | self.displaymode)
|
||||||
|
|
||||||
.. code-block:: python
|
def set_right_to_left(self):
|
||||||
|
"""Set direction of text to read from right to left"""
|
||||||
|
self.displaymode |= LCD_ENTRYLEFT
|
||||||
|
self._write8(LCD_ENTRYMODESET | self.displaymode)
|
||||||
|
|
||||||
import time
|
def enable_display(self, enable):
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
scroll_message = "Scroll -->"
|
|
||||||
lcd.message = scroll_message
|
|
||||||
time.sleep(2)
|
|
||||||
for i in range(len(scroll_message) + 16):
|
|
||||||
lcd.move_right()
|
|
||||||
time.sleep(0.5)
|
|
||||||
"""
|
"""
|
||||||
self._write8(_LCD_CURSORSHIFT | _LCD_DISPLAYMOVE | _LCD_MOVERIGHT)
|
Enable or disable the display.
|
||||||
|
|
||||||
@property
|
:param enable: True to enable display, False to disable
|
||||||
def text_direction(self):
|
|
||||||
"""The direction the text is displayed. To display the text left to right beginning on the
|
|
||||||
left side of the LCD, set ``text_direction = LEFT_TO_RIGHT``. To display the text right
|
|
||||||
to left beginning on the right size of the LCD, set ``text_direction = RIGHT_TO_LEFT``.
|
|
||||||
Text defaults to displaying from left to right.
|
|
||||||
|
|
||||||
The following example displays "Hello, world!" from right to left.
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
lcd.text_direction = lcd.RIGHT_TO_LEFT
|
|
||||||
lcd.message = "Hello, world!"
|
|
||||||
time.sleep(5)
|
|
||||||
"""
|
|
||||||
return self._direction
|
|
||||||
|
|
||||||
@text_direction.setter
|
|
||||||
def text_direction(self, direction):
|
|
||||||
self._direction = direction
|
|
||||||
if direction == self.LEFT_TO_RIGHT:
|
|
||||||
self._left_to_right()
|
|
||||||
elif direction == self.RIGHT_TO_LEFT:
|
|
||||||
self._right_to_left()
|
|
||||||
|
|
||||||
def _left_to_right(self):
|
|
||||||
# Displays text from left to right on the LCD.
|
|
||||||
self.displaymode |= _LCD_ENTRYLEFT
|
|
||||||
self._write8(_LCD_ENTRYMODESET | self.displaymode)
|
|
||||||
|
|
||||||
def _right_to_left(self):
|
|
||||||
# Displays text from right to left on the LCD.
|
|
||||||
self.displaymode &= ~_LCD_ENTRYLEFT
|
|
||||||
self._write8(_LCD_ENTRYMODESET | self.displaymode)
|
|
||||||
|
|
||||||
def create_char(self, location, pattern):
|
|
||||||
"""
|
|
||||||
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 easily
|
|
||||||
design your custom character at http://www.quinapalus.com/hd44780udg.html
|
|
||||||
To show your custom character use, for example, ``lcd.message = "\x01"``
|
|
||||||
|
|
||||||
: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
|
if enable:
|
||||||
location &= 0x7
|
self.displaycontrol |= LCD_DISPLAYON
|
||||||
self._write8(_LCD_SETCGRAMADDR | (location << 3))
|
else:
|
||||||
for i in range(8):
|
self.displaycontrol &= ~LCD_DISPLAYON
|
||||||
self._write8(pattern[i], char_mode=True)
|
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)
|
||||||
|
|
||||||
def _write8(self, value, char_mode=False):
|
def _write8(self, value, char_mode=False):
|
||||||
# Sends 8b ``value`` in ``char_mode``.
|
# Sends 8b ``value`` in ``char_mode``.
|
||||||
|
|
@ -542,190 +298,169 @@ class Character_LCD:
|
||||||
self.enable.value = False
|
self.enable.value = False
|
||||||
time.sleep(0.0000001)
|
time.sleep(0.0000001)
|
||||||
|
|
||||||
|
def set_backlight(self, lighton):
|
||||||
|
"""
|
||||||
|
Set lighton to turn the charLCD backlight on.
|
||||||
|
|
||||||
# pylint: enable-msg=too-many-instance-attributes
|
:param lighton: True to turn backlight on, False to turn off
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable-msg=too-many-instance-attributes
|
|
||||||
class Character_LCD_Mono(Character_LCD):
|
|
||||||
"""Interfaces with monochromatic character LCDs.
|
|
||||||
|
|
||||||
: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 columns: The columns on the charLCD
|
|
||||||
:param lines: The lines on the charLCD
|
|
||||||
:param ~digitalio.DigitalInOut backlight_pin: The backlight pin
|
|
||||||
:param bool backlight_inverted: ``False`` if LCD is not inverted, i.e. backlight pin is
|
|
||||||
connected to common anode. ``True`` if LCD is inverted i.e. backlight pin is connected
|
|
||||||
to common cathode.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# pylint: disable-msg=too-many-arguments
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
rs,
|
|
||||||
en,
|
|
||||||
db4,
|
|
||||||
db5,
|
|
||||||
db6,
|
|
||||||
db7,
|
|
||||||
columns,
|
|
||||||
lines,
|
|
||||||
backlight_pin=None,
|
|
||||||
backlight_inverted=False,
|
|
||||||
):
|
|
||||||
|
|
||||||
# Backlight pin and inversion
|
|
||||||
self.backlight_pin = backlight_pin
|
|
||||||
self.backlight_inverted = backlight_inverted
|
|
||||||
|
|
||||||
# Setup backlight
|
|
||||||
if backlight_pin is not None:
|
|
||||||
self.backlight_pin.direction = digitalio.Direction.OUTPUT
|
|
||||||
self.backlight = True
|
|
||||||
super().__init__(rs, en, db4, db5, db6, db7, columns, lines)
|
|
||||||
|
|
||||||
# pylint: enable-msg=too-many-arguments
|
|
||||||
|
|
||||||
@property
|
|
||||||
def backlight(self):
|
|
||||||
"""Enable or disable backlight. True if backlight is on. False if backlight is off.
|
|
||||||
|
|
||||||
The following example turns the backlight off, then displays, "Hello, world?", then turns
|
|
||||||
the backlight on and displays, "Hello, world!"
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
lcd.backlight = False
|
|
||||||
lcd.message = "Hello, world?"
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.backlight = True
|
|
||||||
lcd.message = "Hello, world!"
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self._enable
|
if lighton:
|
||||||
|
self.backlight.value = 0
|
||||||
@backlight.setter
|
|
||||||
def backlight(self, enable):
|
|
||||||
self._enable = enable
|
|
||||||
if enable:
|
|
||||||
self.backlight_pin.value = not self.backlight_inverted
|
|
||||||
else:
|
else:
|
||||||
self.backlight_pin.value = self.backlight_inverted
|
self.backlight.value = 1
|
||||||
|
|
||||||
|
|
||||||
class Character_LCD_RGB(Character_LCD):
|
def message(self, text):
|
||||||
"""Interfaces with RGB character LCDs.
|
"""
|
||||||
|
Write text to display. Can include ``\\n`` for newline.
|
||||||
|
|
||||||
:param ~digitalio.DigitalInOut rs: The reset data line
|
:param text: text string to display
|
||||||
:param ~digitalio.DigitalInOut en: The enable data line
|
"""
|
||||||
:param ~digitalio.DigitalInOut db4: The data line 4
|
line = 0
|
||||||
:param ~digitalio.DigitalInOut db5: The data line 5
|
# iterate thru each char
|
||||||
:param ~digitalio.DigitalInOut db6: The data line 6
|
for char in text:
|
||||||
:param ~digitalio.DigitalInOut db7: The data line 7
|
# if character is \n, go to next line
|
||||||
:param columns: The columns on the charLCD
|
if char == '\n':
|
||||||
:param lines: The lines on the charLCD
|
line += 1
|
||||||
:param ~pulseio.PWMOut, ~digitalio.DigitalInOut red: Red RGB Anode
|
# move to left/right depending on text direction
|
||||||
:param ~pulseio.PWMOut, ~digitalio.DigitalInOut green: Green RGB Anode
|
col = 0 if self.displaymode & LCD_ENTRYLEFT > 0 else self.cols-1
|
||||||
:param ~pulseio.PWMOut, ~digitalio.DigitalInOut blue: Blue RGB Anode
|
self.set_cursor(col, line)
|
||||||
:param ~digitalio.DigitalInOut read_write: The rw pin. Determines whether to read to or
|
# Write character to display
|
||||||
write from the display. Not necessary if only writing to the display. Used on shield.
|
else:
|
||||||
|
self._write8(ord(char), True)
|
||||||
|
|
||||||
|
def create_char(self, location, pattern):
|
||||||
|
"""
|
||||||
|
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
|
||||||
|
|
||||||
|
"""
|
||||||
|
# only position 0..7 are allowed
|
||||||
|
location &= 0x7
|
||||||
|
self._write8(LCD_SETCGRAMADDR | (location << 3))
|
||||||
|
for i in range(8):
|
||||||
|
self._write8(pattern[i], char_mode=True)
|
||||||
|
|
||||||
|
#pylint: enable-msg=too-many-instance-attributes
|
||||||
|
|
||||||
|
class Character_LCD_I2C(Character_LCD):
|
||||||
|
"""Character LCD connected to I2C/SPI backpack using its I2C connection.
|
||||||
|
This is a subclass of Character_LCD and implements all of the same
|
||||||
|
functions and functionality.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# pylint: disable-msg=too-many-arguments
|
def __init__(self, i2c, cols, lines):
|
||||||
def __init__(
|
"""Initialize character LCD connectedto backpack using I2C connection
|
||||||
self,
|
on the specified I2C bus and of the specified number of columns and
|
||||||
rs,
|
lines on the display.
|
||||||
en,
|
|
||||||
db4,
|
|
||||||
db5,
|
|
||||||
db6,
|
|
||||||
db7,
|
|
||||||
columns,
|
|
||||||
lines,
|
|
||||||
red,
|
|
||||||
green,
|
|
||||||
blue,
|
|
||||||
read_write=None,
|
|
||||||
):
|
|
||||||
|
|
||||||
# Define read_write (rw) pin
|
|
||||||
self.read_write = read_write
|
|
||||||
|
|
||||||
# Setup rw pin if used
|
|
||||||
if read_write is not None:
|
|
||||||
self.read_write.direction = digitalio.Direction.OUTPUT
|
|
||||||
|
|
||||||
# define color params
|
|
||||||
self.rgb_led = [red, green, blue]
|
|
||||||
|
|
||||||
for pin in self.rgb_led:
|
|
||||||
if hasattr(pin, "direction"):
|
|
||||||
# Assume a digitalio.DigitalInOut or compatible interface:
|
|
||||||
pin.direction = digitalio.Direction.OUTPUT
|
|
||||||
elif not hasattr(pin, "duty_cycle"):
|
|
||||||
raise TypeError(
|
|
||||||
"RGB LED objects must be instances of digitalio.DigitalInOut"
|
|
||||||
" or pulseio.PWMOut, or provide a compatible interface."
|
|
||||||
)
|
|
||||||
|
|
||||||
self._color = [0, 0, 0]
|
|
||||||
super().__init__(rs, en, db4, db5, db6, db7, columns, lines)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def color(self):
|
|
||||||
"""
|
"""
|
||||||
The color of the display. Provide a list of three integers ranging 0 - 100, ``[R, G, B]``.
|
# Import the MCP23008 module here when the class is used
|
||||||
``0`` is no color, or "off". ``100`` is maximum color. For example, the brightest red would
|
# to keep memory usage low. If you attempt to import globally at the
|
||||||
be ``[100, 0, 0]``, and a half-bright purple would be, ``[50, 0, 50]``.
|
# top of this file you WILL run out of memory on the M0, even with
|
||||||
|
# MPY files. The amount of code and classes implicitly imported
|
||||||
|
# by all the SPI and I2C code is too high. Thus import on demand.
|
||||||
|
import adafruit_character_lcd.mcp23008 as mcp23008
|
||||||
|
self._mcp = mcp23008.MCP23008(i2c)
|
||||||
|
# Setup pins for I2C backpack, see diagram:
|
||||||
|
# https://learn.adafruit.com/assets/35681
|
||||||
|
reset = self._mcp.DigitalInOut(_MCP23008_LCD_RS, self._mcp)
|
||||||
|
enable = self._mcp.DigitalInOut(_MCP23008_LCD_EN, self._mcp)
|
||||||
|
dl4 = self._mcp.DigitalInOut(_MCP23008_LCD_D4, self._mcp)
|
||||||
|
dl5 = self._mcp.DigitalInOut(_MCP23008_LCD_D5, self._mcp)
|
||||||
|
dl6 = self._mcp.DigitalInOut(_MCP23008_LCD_D6, self._mcp)
|
||||||
|
dl7 = self._mcp.DigitalInOut(_MCP23008_LCD_D7, self._mcp)
|
||||||
|
backlight = self._mcp.DigitalInOut(_MCP23008_LCD_BACKLIGHT, self._mcp)
|
||||||
|
# Call superclass initializer with MCP23008 pins.
|
||||||
|
super().__init__(reset, enable, dl4, dl5, dl6, dl7, cols, lines,
|
||||||
|
backlight=backlight)
|
||||||
|
|
||||||
If PWM is unavailable, ``0`` is off, and non-zero is on. For example, ``[1, 0, 0]`` would
|
def _write8(self, value, char_mode=False):
|
||||||
be red.
|
# Optimize a command write by changing all GPIO pins at once instead
|
||||||
|
# of letting the super class try to set each one invidually (far too
|
||||||
|
# slow with overhead of I2C communication).
|
||||||
|
gpio = self._mcp.gpio
|
||||||
|
# Make sure enable is low.
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_EN, False)
|
||||||
|
# Set character/data bit. (charmode = False).
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_RS, char_mode)
|
||||||
|
# Set upper 4 bits.
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_D4, ((value >> 4) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_D5, ((value >> 5) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_D6, ((value >> 6) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_D7, ((value >> 7) & 1) > 0)
|
||||||
|
self._mcp.gpio = gpio
|
||||||
|
# Send command.
|
||||||
|
self._pulse_enable()
|
||||||
|
# Now repeat for lower 4 bits.
|
||||||
|
gpio = self._mcp.gpio
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_EN, False)
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_RS, char_mode)
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_D4, (value & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_D5, ((value >> 1) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_D6, ((value >> 2) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _MCP23008_LCD_D7, ((value >> 3) & 1) > 0)
|
||||||
|
self._mcp.gpio = gpio
|
||||||
|
self._pulse_enable()
|
||||||
|
|
||||||
The following example turns the LCD red and displays, "Hello, world!".
|
|
||||||
|
|
||||||
.. code-block:: python
|
class Character_LCD_SPI(Character_LCD):
|
||||||
|
"""Character LCD connected to I2C/SPI backpack using its SPI connection.
|
||||||
|
This is a subclass of Character_LCD and implements all of the same
|
||||||
|
functions and functionality.
|
||||||
|
"""
|
||||||
|
|
||||||
import time
|
def __init__(self, spi, latch, cols, lines):
|
||||||
import board
|
"""Initialize character LCD connectedto backpack using SPI connection
|
||||||
import busio
|
on the specified SPI bus and latch line with the specified number of
|
||||||
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
|
columns and lines on the display.
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
|
|
||||||
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
lcd.color = [100, 0, 0]
|
|
||||||
lcd.message = "Hello, world!"
|
|
||||||
time.sleep(5)
|
|
||||||
"""
|
"""
|
||||||
return self._color
|
# See comment above on I2C class for why this is imported here:
|
||||||
|
import adafruit_character_lcd.shift_reg_74hc595 as shift_reg_74hc595
|
||||||
|
self._sr = shift_reg_74hc595.ShiftReg74HC595(spi, latch)
|
||||||
|
# Setup pins for SPI backpack, see diagram:
|
||||||
|
# https://learn.adafruit.com/assets/35681
|
||||||
|
reset = self._sr.DigitalInOut(_74HC595_LCD_RS, self._sr)
|
||||||
|
enable = self._sr.DigitalInOut(_74HC595_LCD_EN, self._sr)
|
||||||
|
dl4 = self._sr.DigitalInOut(_74HC595_LCD_D4, self._sr)
|
||||||
|
dl5 = self._sr.DigitalInOut(_74HC595_LCD_D5, self._sr)
|
||||||
|
dl6 = self._sr.DigitalInOut(_74HC595_LCD_D6, self._sr)
|
||||||
|
dl7 = self._sr.DigitalInOut(_74HC595_LCD_D7, self._sr)
|
||||||
|
backlight = self._sr.DigitalInOut(_74HC595_LCD_BACKLIGHT, self._sr)
|
||||||
|
# Call superclass initializer with shift register pins.
|
||||||
|
super().__init__(reset, enable, dl4, dl5, dl6, dl7, cols, lines,
|
||||||
|
backlight=backlight)
|
||||||
|
|
||||||
@color.setter
|
def _write8(self, value, char_mode=False):
|
||||||
def color(self, color):
|
# Optimize a command write by changing all GPIO pins at once instead
|
||||||
self._color = color
|
# of letting the super class try to set each one invidually (far too
|
||||||
for number, pin in enumerate(self.rgb_led):
|
# slow with overhead of SPI communication).
|
||||||
if hasattr(pin, "duty_cycle"):
|
gpio = self._sr.gpio
|
||||||
# Assume a pulseio.PWMOut or compatible interface and set duty cycle:
|
# Make sure enable is low.
|
||||||
pin.duty_cycle = int(_map(color[number], 0, 100, 65535, 0))
|
gpio = _set_bit(gpio, _74HC595_LCD_EN, False)
|
||||||
elif hasattr(pin, "value"):
|
# Set character/data bit. (charmode = False).
|
||||||
# If we don't have a PWM interface, all we can do is turn each color
|
gpio = _set_bit(gpio, _74HC595_LCD_RS, char_mode)
|
||||||
# on / off. Assume a DigitalInOut (or compatible interface) and write
|
# Set upper 4 bits.
|
||||||
# 0 (on) to pin for any value greater than 0, or 1 (off) for 0:
|
gpio = _set_bit(gpio, _74HC595_LCD_D4, ((value >> 4) & 1) > 0)
|
||||||
pin.value = not color[number] > 1
|
gpio = _set_bit(gpio, _74HC595_LCD_D5, ((value >> 5) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _74HC595_LCD_D6, ((value >> 6) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _74HC595_LCD_D7, ((value >> 7) & 1) > 0)
|
||||||
|
self._sr.gpio = gpio
|
||||||
|
# Send command.
|
||||||
|
self._pulse_enable()
|
||||||
|
# Now repeat for lower 4 bits.
|
||||||
|
gpio = self._sr.gpio
|
||||||
|
gpio = _set_bit(gpio, _74HC595_LCD_EN, False)
|
||||||
|
gpio = _set_bit(gpio, _74HC595_LCD_RS, char_mode)
|
||||||
|
gpio = _set_bit(gpio, _74HC595_LCD_D4, (value & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _74HC595_LCD_D5, ((value >> 1) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _74HC595_LCD_D6, ((value >> 2) & 1) > 0)
|
||||||
|
gpio = _set_bit(gpio, _74HC595_LCD_D7, ((value >> 3) & 1) > 0)
|
||||||
|
self._sr.gpio = gpio
|
||||||
|
self._pulse_enable()
|
||||||
|
|
|
||||||
|
|
@ -1,92 +0,0 @@
|
||||||
# The MIT License (MIT)
|
|
||||||
#
|
|
||||||
# Copyright (c) 2018 Kattni Rembor for Adafruit Industries
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# 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_character_lcd.character_lcd_i2c`
|
|
||||||
====================================================
|
|
||||||
|
|
||||||
Module for using I2C with I2C/SPI character LCD backpack
|
|
||||||
|
|
||||||
* Author(s): Kattni Rembor
|
|
||||||
|
|
||||||
Implementation Notes
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
**Hardware:**
|
|
||||||
|
|
||||||
"* `I2C / SPI character LCD backpack <https://www.adafruit.com/product/292>`_"
|
|
||||||
|
|
||||||
**Software and Dependencies:**
|
|
||||||
|
|
||||||
* Adafruit CircuitPython firmware:
|
|
||||||
https://github.com/adafruit/circuitpython/releases
|
|
||||||
* Adafruit's Bus Device library (when using I2C/SPI):
|
|
||||||
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from adafruit_mcp230xx.mcp23008 import MCP23008
|
|
||||||
from adafruit_character_lcd.character_lcd import Character_LCD_Mono
|
|
||||||
|
|
||||||
__version__ = "0.0.0-auto.0"
|
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CharLCD.git"
|
|
||||||
|
|
||||||
|
|
||||||
class Character_LCD_I2C(Character_LCD_Mono):
|
|
||||||
# pylint: disable=too-few-public-methods, too-many-arguments
|
|
||||||
"""Character LCD connected to I2C/SPI backpack using its I2C connection.
|
|
||||||
This is a subclass of Character_LCD and implements all of the same
|
|
||||||
functions and functionality.
|
|
||||||
|
|
||||||
To use, import and initialise as follows:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
from adafruit_character_lcd.character_lcd_i2c import Character_LCD_I2C
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = Character_LCD_I2C(i2c, 16, 2)
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, i2c, columns, lines, address=None, backlight_inverted=False):
|
|
||||||
"""Initialize character LCD connected to backpack using I2C connection
|
|
||||||
on the specified I2C bus with the specified number of columns and
|
|
||||||
lines on the display. Optionally specify if backlight is inverted.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if address:
|
|
||||||
mcp = MCP23008(i2c, address=address)
|
|
||||||
else:
|
|
||||||
mcp = MCP23008(i2c)
|
|
||||||
super().__init__(
|
|
||||||
mcp.get_pin(1),
|
|
||||||
mcp.get_pin(2),
|
|
||||||
mcp.get_pin(3),
|
|
||||||
mcp.get_pin(4),
|
|
||||||
mcp.get_pin(5),
|
|
||||||
mcp.get_pin(6),
|
|
||||||
columns,
|
|
||||||
lines,
|
|
||||||
backlight_pin=mcp.get_pin(7),
|
|
||||||
backlight_inverted=backlight_inverted,
|
|
||||||
)
|
|
||||||
287
adafruit_character_lcd/character_lcd_rgb.py
Executable file
287
adafruit_character_lcd/character_lcd_rgb.py
Executable file
|
|
@ -0,0 +1,287 @@
|
||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017 Brent Rubell for Adafruit Industries
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# 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_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
|
||||||
|
|
||||||
|
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
|
||||||
|
from micropython import const
|
||||||
|
|
||||||
|
#pylint: disable-msg=bad-whitespace
|
||||||
|
# Commands
|
||||||
|
_LCD_CLEARDISPLAY = const(0x01)
|
||||||
|
_LCD_RETURNHOME = const(0x02)
|
||||||
|
_LCD_ENTRYMODESET = const(0x04)
|
||||||
|
_LCD_DISPLAYCONTROL = const(0x08)
|
||||||
|
_LCD_CURSORSHIFT = const(0x10)
|
||||||
|
_LCD_FUNCTIONSET = const(0x20)
|
||||||
|
_LCD_SETCGRAMADDR = const(0x40)
|
||||||
|
_LCD_SETDDRAMADDR = const(0x80)
|
||||||
|
|
||||||
|
# Entry flags
|
||||||
|
_LCD_ENTRYRIGHT = const(0x00)
|
||||||
|
_LCD_ENTRYLEFT = const(0x02)
|
||||||
|
_LCD_ENTRYSHIFTINCREMENT = const(0x01)
|
||||||
|
_LCD_ENTRYSHIFTDECREMENT = const(0x00)
|
||||||
|
|
||||||
|
# Control flags
|
||||||
|
_LCD_DISPLAYON = const(0x04)
|
||||||
|
_LCD_DISPLAYOFF = const(0x00)
|
||||||
|
LCD_CURSORON = const(0x02)
|
||||||
|
_LCD_CURSOROFF = const(0x00)
|
||||||
|
_LCD_BLINKON = const(0x01)
|
||||||
|
_LCD_BLINKOFF = const(0x00)
|
||||||
|
|
||||||
|
# Move flags
|
||||||
|
_LCD_DISPLAYMOVE = const(0x08)
|
||||||
|
_LCD_CURSORMOVE = const(0x00)
|
||||||
|
_LCD_MOVERIGHT = const(0x04)
|
||||||
|
_LCD_MOVELEFT = const(0x00)
|
||||||
|
|
||||||
|
# Function set flags
|
||||||
|
_LCD_8BITMODE = const(0x10)
|
||||||
|
_LCD_4BITMODE = const(0x00)
|
||||||
|
_LCD_2LINE = const(0x08)
|
||||||
|
_LCD_1LINE = const(0x00)
|
||||||
|
_LCD_5X10DOTS = const(0x04)
|
||||||
|
_LCD_5X8DOTS = const(0x00)
|
||||||
|
|
||||||
|
# Offset for up to 4 rows.
|
||||||
|
LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)
|
||||||
|
|
||||||
|
#pylint: enable-msg=bad-whitespace
|
||||||
|
|
||||||
|
def _map(xval, in_min, in_max, out_min, out_max):
|
||||||
|
# Affine transfer/map with constrained output.
|
||||||
|
outrange = float(out_max - out_min)
|
||||||
|
inrange = float(in_max - in_min)
|
||||||
|
ret = (xval - in_min) * (outrange / inrange) + out_min
|
||||||
|
if out_max > out_min:
|
||||||
|
ret = max(min(ret, out_max), out_min)
|
||||||
|
else:
|
||||||
|
ret = max(min(ret, out_min), out_max)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
#pylint: disable-msg=too-many-instance-attributes
|
||||||
|
class Character_LCD_RGB(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 ~pulseio.PWMOut red: Red RGB Anode
|
||||||
|
:param ~pulseio.PWMOut green: Green RGB Anode
|
||||||
|
:param ~pulseio.PWMOut blue: Blue RGB Anode
|
||||||
|
:param ~digitalio.DigitalInOut backlight: The backlight pin, usually the last pin.
|
||||||
|
Consult the datasheet. Note that Pin value 0 means backlight is lit.
|
||||||
|
|
||||||
|
"""
|
||||||
|
#pylint: disable-msg=too-many-arguments
|
||||||
|
def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
|
||||||
|
red,
|
||||||
|
green,
|
||||||
|
blue,
|
||||||
|
backlight=None #,
|
||||||
|
#enable_pwm = False,
|
||||||
|
#initial_backlight = 1.0
|
||||||
|
):
|
||||||
|
# define columns and lines
|
||||||
|
self.cols = cols
|
||||||
|
self.lines = lines
|
||||||
|
# define pin params
|
||||||
|
self.reset = rs
|
||||||
|
self.enable = en
|
||||||
|
self.dl4 = d4
|
||||||
|
self.dl5 = d5
|
||||||
|
self.dl6 = d6
|
||||||
|
self.dl7 = d7
|
||||||
|
# define color params
|
||||||
|
self.red = red
|
||||||
|
self.green = green
|
||||||
|
self.blue = blue
|
||||||
|
# define rgb led
|
||||||
|
self.rgb_led = [red, green, blue]
|
||||||
|
# define backlight pin
|
||||||
|
self.backlight = backlight
|
||||||
|
# self.pwn_enabled = enable_pwm
|
||||||
|
# set all pins as outputs
|
||||||
|
for pin in(rs, en, d4, d5, d6, d7):
|
||||||
|
pin.direction = digitalio.Direction.OUTPUT
|
||||||
|
# setup backlight
|
||||||
|
if backlight is not None:
|
||||||
|
self.backlight.direction = digitalio.Direction.OUTPUT
|
||||||
|
self.backlight.value = 0 # turn backlight on
|
||||||
|
# initialize the display
|
||||||
|
self._write8(0x33)
|
||||||
|
self._write8(0x32)
|
||||||
|
# init. display control
|
||||||
|
self.displaycontrol = _LCD_DISPLAYON | _LCD_CURSOROFF | _LCD_BLINKOFF
|
||||||
|
# init display function
|
||||||
|
self.displayfunction = _LCD_4BITMODE | _LCD_1LINE | _LCD_2LINE | _LCD_5X8DOTS
|
||||||
|
# init display mode
|
||||||
|
self.displaymode = _LCD_ENTRYLEFT | _LCD_ENTRYSHIFTDECREMENT
|
||||||
|
# write to display control
|
||||||
|
self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol)
|
||||||
|
# write displayfunction
|
||||||
|
self._write8(_LCD_FUNCTIONSET | self.displayfunction)
|
||||||
|
# set the entry mode
|
||||||
|
self._write8(_LCD_ENTRYMODESET | self.displaymode)
|
||||||
|
self.clear()
|
||||||
|
#pylint: enable-msg=too-many-arguments
|
||||||
|
|
||||||
|
def home(self):
|
||||||
|
"""Moves the cursor back home pos(1,1)"""
|
||||||
|
self._write8(_LCD_RETURNHOME)
|
||||||
|
time.sleep(0.003)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Clears the LCD"""
|
||||||
|
self._write8(_LCD_CLEARDISPLAY)
|
||||||
|
time.sleep(0.003)
|
||||||
|
|
||||||
|
def show_cursor(self, show):
|
||||||
|
"""Show or hide the cursor"""
|
||||||
|
if show:
|
||||||
|
self.displaycontrol |= LCD_CURSORON
|
||||||
|
else:
|
||||||
|
self.displaycontrol &= ~_LCD_DISPLAYON
|
||||||
|
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
|
||||||
|
"""
|
||||||
|
# Clamp row to the last row of the display
|
||||||
|
if row > self.lines:
|
||||||
|
row = self.lines - 1
|
||||||
|
# Set location
|
||||||
|
self._write8(_LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))
|
||||||
|
|
||||||
|
def enable_display(self, enable):
|
||||||
|
"""Enable or disable the display.
|
||||||
|
:param enable: True to enable display, False to disable
|
||||||
|
"""
|
||||||
|
if enable:
|
||||||
|
self.displaycontrol |= _LCD_DISPLAYON
|
||||||
|
else:
|
||||||
|
self.displaycontrol &= ~_LCD_DISPLAYON
|
||||||
|
self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol)
|
||||||
|
|
||||||
|
def _write8(self, value, char_mode=False):
|
||||||
|
# Sends 8b ``value`` in ``char_mode``.
|
||||||
|
# :param value: bytes
|
||||||
|
# :param char_mode: character/data mode selector. False (default) for
|
||||||
|
# data only, True for character bits.
|
||||||
|
# one ms delay to prevent writing too quickly.
|
||||||
|
time.sleep(0.001)
|
||||||
|
# set character/data bit. (charmode = False)
|
||||||
|
self.reset.value = char_mode
|
||||||
|
# WRITE upper 4 bits
|
||||||
|
self.dl4.value = ((value >> 4) & 1) > 0
|
||||||
|
self.dl5.value = ((value >> 5) & 1) > 0
|
||||||
|
self.dl6.value = ((value >> 6) & 1) > 0
|
||||||
|
self.dl7.value = ((value >> 7) & 1) > 0
|
||||||
|
# send command
|
||||||
|
self._pulse_enable()
|
||||||
|
# WRITE lower 4 bits
|
||||||
|
self.dl4.value = (value & 1) > 0
|
||||||
|
self.dl5.value = ((value >> 1) & 1) > 0
|
||||||
|
self.dl6.value = ((value >> 2) & 1) > 0
|
||||||
|
self.dl7.value = ((value >> 3) & 1) > 0
|
||||||
|
self._pulse_enable()
|
||||||
|
|
||||||
|
def _pulse_enable(self):
|
||||||
|
# Pulses (lo->hi->lo) to send commands.
|
||||||
|
self.enable.value = False
|
||||||
|
# 1microsec pause
|
||||||
|
time.sleep(0.0000001)
|
||||||
|
self.enable.value = True
|
||||||
|
time.sleep(0.0000001)
|
||||||
|
self.enable.value = False
|
||||||
|
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
|
||||||
|
"""
|
||||||
|
if lighton:
|
||||||
|
self.backlight.value = 0
|
||||||
|
else:
|
||||||
|
self.backlight.value = 1
|
||||||
|
|
||||||
|
def set_color(self, color):
|
||||||
|
""" Method to set the duty cycle of the RGB LED
|
||||||
|
:param color: list of 3 integers in range(100). ``[R,G,B]`` 0 is no
|
||||||
|
color, 100 it maximum color
|
||||||
|
"""
|
||||||
|
self.rgb_led[0].duty_cycle = int(_map(color[0], 0, 100, 65535, 0))
|
||||||
|
self.rgb_led[1].duty_cycle = int(_map(color[1], 0, 100, 65535, 0))
|
||||||
|
self.rgb_led[2].duty_cycle = int(_map(color[2], 0, 100, 65535, 0))
|
||||||
|
|
||||||
|
def message(self, text):
|
||||||
|
"""Write text to display, can include \n for newline
|
||||||
|
:param text: string to display
|
||||||
|
"""
|
||||||
|
line = 0
|
||||||
|
# iterate thru each char
|
||||||
|
for char in text:
|
||||||
|
# if character is \n, go to next line
|
||||||
|
if char == '\n':
|
||||||
|
line += 1
|
||||||
|
# move to left/right depending on text direction
|
||||||
|
col = 0 if self.displaymode & _LCD_ENTRYLEFT > 0 else self.cols-1
|
||||||
|
self.set_cursor(col, line)
|
||||||
|
# Write character to display
|
||||||
|
else:
|
||||||
|
self._write8(ord(char), True)
|
||||||
|
|
||||||
|
#pylint: enable-msg=too-many-instance-attributes
|
||||||
|
|
@ -1,234 +0,0 @@
|
||||||
# The MIT License (MIT)
|
|
||||||
#
|
|
||||||
# Copyright (c) 2018 Kattni Rembor for Adafruit Industries
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# 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_character_lcd.character_lcd_i2c`
|
|
||||||
====================================================
|
|
||||||
|
|
||||||
Module for using I2C with I2C RGB LCD Shield or I2C RGB LCD Pi Plate
|
|
||||||
|
|
||||||
* Author(s): Kattni Rembor
|
|
||||||
|
|
||||||
Implementation Notes
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
**Hardware:**
|
|
||||||
|
|
||||||
"* `RGB LCD Shield Kit w/ 16x2 Character Display - Negative Display
|
|
||||||
<https://www.adafruit.com/product/714>`_"
|
|
||||||
|
|
||||||
"* `RGB LCD Shield Kit w/ 16x2 Character Display - Positive Display
|
|
||||||
<https://www.adafruit.com/product/716>`_"
|
|
||||||
|
|
||||||
"* `Adafruit RGB Negative 16x2 LCD+Keypad Kit for Raspberry Pi
|
|
||||||
<https://www.adafruit.com/product/1110>`_"
|
|
||||||
|
|
||||||
"* `Adafruit RGB Positive 16x2 LCD+Keypad Kit for Raspberry Pi
|
|
||||||
<https://www.adafruit.com/product/1109>`_"
|
|
||||||
|
|
||||||
**Software and Dependencies:**
|
|
||||||
|
|
||||||
* Adafruit CircuitPython firmware:
|
|
||||||
https://github.com/adafruit/circuitpython/releases
|
|
||||||
* Adafruit's Bus Device library (when using I2C/SPI):
|
|
||||||
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import digitalio
|
|
||||||
from adafruit_mcp230xx.mcp23017 import MCP23017
|
|
||||||
from adafruit_character_lcd.character_lcd import Character_LCD_RGB
|
|
||||||
|
|
||||||
__version__ = "0.0.0-auto.0"
|
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CharLCD.git"
|
|
||||||
|
|
||||||
|
|
||||||
class Character_LCD_RGB_I2C(Character_LCD_RGB):
|
|
||||||
"""RGB Character LCD connected to I2C shield or Pi plate using I2C connection.
|
|
||||||
This is a subclass of Character_LCD_RGB and implements all of the same
|
|
||||||
functions and functionality.
|
|
||||||
|
|
||||||
To use, import and initialise as follows:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = Character_LCD_RGB_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, i2c, columns, lines, address=None):
|
|
||||||
# pylint: disable=too-many-locals
|
|
||||||
"""Initialize RGB character LCD connected to shield using I2C connection
|
|
||||||
on the specified I2C bus with the specified number of columns and lines
|
|
||||||
on the display.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if address:
|
|
||||||
mcp = MCP23017(i2c, address=address)
|
|
||||||
else:
|
|
||||||
mcp = MCP23017(i2c)
|
|
||||||
|
|
||||||
self._left_button = mcp.get_pin(4)
|
|
||||||
self._up_button = mcp.get_pin(3)
|
|
||||||
self._down_button = mcp.get_pin(2)
|
|
||||||
self._right_button = mcp.get_pin(1)
|
|
||||||
self._select_button = mcp.get_pin(0)
|
|
||||||
|
|
||||||
self._buttons = [
|
|
||||||
self._left_button,
|
|
||||||
self._up_button,
|
|
||||||
self._down_button,
|
|
||||||
self._right_button,
|
|
||||||
self._select_button,
|
|
||||||
]
|
|
||||||
|
|
||||||
for pin in self._buttons:
|
|
||||||
pin.switch_to_input(pull=digitalio.Pull.UP)
|
|
||||||
|
|
||||||
super().__init__(
|
|
||||||
mcp.get_pin(15),
|
|
||||||
mcp.get_pin(13),
|
|
||||||
mcp.get_pin(12),
|
|
||||||
mcp.get_pin(11),
|
|
||||||
mcp.get_pin(10),
|
|
||||||
mcp.get_pin(9),
|
|
||||||
columns,
|
|
||||||
lines,
|
|
||||||
mcp.get_pin(6),
|
|
||||||
mcp.get_pin(7),
|
|
||||||
mcp.get_pin(8),
|
|
||||||
mcp.get_pin(14),
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def left_button(self):
|
|
||||||
"""The left button on the RGB Character LCD I2C Shield or Pi plate.
|
|
||||||
|
|
||||||
The following example prints "Left!" to the LCD when the left button is pressed:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = Character_LCD_RGB_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if lcd.left_button:
|
|
||||||
lcd.message = "Left!"
|
|
||||||
|
|
||||||
"""
|
|
||||||
return not self._left_button.value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def up_button(self):
|
|
||||||
"""The up button on the RGB Character LCD I2C Shield or Pi plate.
|
|
||||||
|
|
||||||
The following example prints "Up!" to the LCD when the up button is pressed:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = Character_LCD_RGB_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if lcd.up_button:
|
|
||||||
lcd.message = "Up!"
|
|
||||||
|
|
||||||
"""
|
|
||||||
return not self._up_button.value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def down_button(self):
|
|
||||||
"""The down button on the RGB Character LCD I2C Shield or Pi plate.
|
|
||||||
|
|
||||||
The following example prints "Down!" to the LCD when the down button is pressed:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = Character_LCD_RGB_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if lcd.down_button:
|
|
||||||
lcd.message = "Down!"
|
|
||||||
|
|
||||||
"""
|
|
||||||
return not self._down_button.value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def right_button(self):
|
|
||||||
"""The right button on the RGB Character LCD I2C Shield or Pi plate.
|
|
||||||
|
|
||||||
The following example prints "Right!" to the LCD when the right button is pressed:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = Character_LCD_RGB_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if lcd.right_button:
|
|
||||||
lcd.message = "Right!"
|
|
||||||
|
|
||||||
"""
|
|
||||||
return not self._right_button.value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def select_button(self):
|
|
||||||
"""The select button on the RGB Character LCD I2C Shield or Pi plate.
|
|
||||||
|
|
||||||
The following example prints "Select!" to the LCD when the select button is pressed:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C
|
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
lcd = Character_LCD_RGB_I2C(i2c, 16, 2)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if lcd.select_button:
|
|
||||||
lcd.message = "Select!"
|
|
||||||
|
|
||||||
"""
|
|
||||||
return not self._select_button.value
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
# The MIT License (MIT)
|
|
||||||
#
|
|
||||||
# Copyright (c) 2018 Kattni Rembor for Adafruit Industries
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# 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_character_lcd.character_lcd_spi`
|
|
||||||
====================================================
|
|
||||||
|
|
||||||
Module for using SPI with I2C/SPI character LCD backpack
|
|
||||||
|
|
||||||
* Author(s): Kattni Rembor
|
|
||||||
|
|
||||||
Implementation Notes
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
**Hardware:**
|
|
||||||
|
|
||||||
"* `I2C / SPI character LCD backpack <https://www.adafruit.com/product/292>`_"
|
|
||||||
|
|
||||||
**Software and Dependencies:**
|
|
||||||
|
|
||||||
* Adafruit CircuitPython firmware:
|
|
||||||
https://github.com/adafruit/circuitpython/releases
|
|
||||||
* Adafruit's Bus Device library (when using I2C/SPI):
|
|
||||||
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import adafruit_74hc595
|
|
||||||
from adafruit_character_lcd.character_lcd import Character_LCD_Mono
|
|
||||||
|
|
||||||
__version__ = "0.0.0-auto.0"
|
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CharLCD.git"
|
|
||||||
|
|
||||||
|
|
||||||
class Character_LCD_SPI(Character_LCD_Mono): # pylint: disable=too-few-public-methods
|
|
||||||
"""Character LCD connected to I2C/SPI backpack using its SPI connection.
|
|
||||||
This is a subclass of Character_LCD and implements all of the same
|
|
||||||
functions and functionality.
|
|
||||||
|
|
||||||
To use, import and initialise as follows:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import digitalio
|
|
||||||
import adafruit_character_lcd.character_lcd_mono as character_lcd
|
|
||||||
|
|
||||||
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
|
|
||||||
latch = digitalio.DigitalInOut(board.D5)
|
|
||||||
lcd = character_lcd.Character_LCD_SPI(spi, latch, 16, 2)
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, spi, latch, columns, lines, backlight_inverted=False):
|
|
||||||
# pylint: disable=too-many-arguments
|
|
||||||
"""Initialize character LCD connected to backpack using SPI connection
|
|
||||||
on the specified SPI bus and latch line with the specified number of
|
|
||||||
columns and lines on the display. Optionally specify if backlight is
|
|
||||||
inverted.
|
|
||||||
"""
|
|
||||||
# pylint: enable=too-many-arguments
|
|
||||||
|
|
||||||
self._shift_register = adafruit_74hc595.ShiftRegister74HC595(spi, latch)
|
|
||||||
reset = self._shift_register.get_pin(1)
|
|
||||||
enable = self._shift_register.get_pin(2)
|
|
||||||
db4 = self._shift_register.get_pin(6)
|
|
||||||
db5 = self._shift_register.get_pin(5)
|
|
||||||
db6 = self._shift_register.get_pin(4)
|
|
||||||
db7 = self._shift_register.get_pin(3)
|
|
||||||
backlight_pin = self._shift_register.get_pin(7)
|
|
||||||
super().__init__(
|
|
||||||
reset,
|
|
||||||
enable,
|
|
||||||
db4,
|
|
||||||
db5,
|
|
||||||
db6,
|
|
||||||
db7,
|
|
||||||
columns,
|
|
||||||
lines,
|
|
||||||
backlight_pin=backlight_pin,
|
|
||||||
backlight_inverted=backlight_inverted,
|
|
||||||
)
|
|
||||||
169
adafruit_character_lcd/mcp23008.py
Normal file
169
adafruit_character_lcd/mcp23008.py
Normal file
|
|
@ -0,0 +1,169 @@
|
||||||
|
"""
|
||||||
|
`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
|
||||||
|
|
||||||
|
"""
|
||||||
|
import digitalio
|
||||||
|
|
||||||
|
import adafruit_bus_device.i2c_device as i2c_device
|
||||||
|
|
||||||
|
from micropython import const
|
||||||
|
|
||||||
|
#pylint: disable-msg=bad-whitespace
|
||||||
|
# Registers and other constants:
|
||||||
|
_MCP23008_ADDRESS = const(0x20)
|
||||||
|
_MCP23008_IODIR = const(0x00)
|
||||||
|
_MCP23008_IPOL = const(0x01)
|
||||||
|
_MCP23008_GPINTEN = const(0x02)
|
||||||
|
_MCP23008_DEFVAL = const(0x03)
|
||||||
|
_MCP23008_INTCON = const(0x04)
|
||||||
|
_MCP23008_IOCON = const(0x05)
|
||||||
|
_MCP23008_GPPU = const(0x06)
|
||||||
|
_MCP23008_INTF = const(0x07)
|
||||||
|
_MCP23008_INTCAP = const(0x08)
|
||||||
|
_MCP23008_GPIO = const(0x09)
|
||||||
|
_MCP23008_OLAT = const(0x0A)
|
||||||
|
|
||||||
|
#pylint: enable-msg=bad-whitespace
|
||||||
|
|
||||||
|
|
||||||
|
class MCP23008:
|
||||||
|
|
||||||
|
"""Class-level buffer for reading and writing registers with the device.
|
||||||
|
This reduces memory allocations but makes the code non-reentrant/thread-
|
||||||
|
safe!"""
|
||||||
|
_BUFFER = bytearray(2)
|
||||||
|
|
||||||
|
class DigitalInOut:
|
||||||
|
"""Digital input/output of the MCP23008. The interface is exactly the
|
||||||
|
same as the digitalio.DigitalInOut class (however the MCP23008 does not
|
||||||
|
support pull-down resistors and an exception will be thrown
|
||||||
|
attempting to set one).
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, pin_number, mcp23008):
|
||||||
|
"""Specify the pin number of the MCP23008 (0...7) and MCP23008
|
||||||
|
instance.
|
||||||
|
"""
|
||||||
|
self._pin = pin_number
|
||||||
|
self._mcp = mcp23008
|
||||||
|
|
||||||
|
# kwargs in switch functions below are _necessary_ for compatibility
|
||||||
|
# with DigitalInout class (which allows specifying pull, etc. which
|
||||||
|
# is unused by this class). Do not remove them, instead turn off pylint
|
||||||
|
# in this case.
|
||||||
|
#pylint: disable=unused-argument
|
||||||
|
def switch_to_output(self, value=False, **kwargs):
|
||||||
|
"""DigitalInOut switch_to_output"""
|
||||||
|
self.direction = digitalio.Direction.OUTPUT
|
||||||
|
self.value = value
|
||||||
|
|
||||||
|
def switch_to_input(self, pull=None, **kwargs):
|
||||||
|
"""DigitalInOut switch_to_input"""
|
||||||
|
self.direction = digitalio.Direction.INPUT
|
||||||
|
self.pull = pull
|
||||||
|
#pylint: enable=unused-argument
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self):
|
||||||
|
"""Get ot Set pin value: True or False"""
|
||||||
|
gpio = self._mcp.gpio
|
||||||
|
return bool(gpio & (1 << self._pin))
|
||||||
|
|
||||||
|
@value.setter
|
||||||
|
def value(self, val):
|
||||||
|
gpio = self._mcp.gpio
|
||||||
|
if val:
|
||||||
|
gpio |= (1 << self._pin)
|
||||||
|
else:
|
||||||
|
gpio &= ~(1 << self._pin)
|
||||||
|
self._mcp.gpio = gpio
|
||||||
|
|
||||||
|
@property
|
||||||
|
def direction(self):
|
||||||
|
"""Set or Get pin Directtion INPUT or OUTPUT"""
|
||||||
|
iodir = self._mcp.read_u8(_MCP23008_IODIR)
|
||||||
|
if iodir & (1 << self._pin) > 0:
|
||||||
|
return digitalio.Direction.INPUT
|
||||||
|
|
||||||
|
return digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
|
@direction.setter
|
||||||
|
def direction(self, val):
|
||||||
|
iodir = self._mcp.read_u8(_MCP23008_IODIR)
|
||||||
|
if val == digitalio.Direction.INPUT:
|
||||||
|
iodir |= (1 << self._pin)
|
||||||
|
elif val == digitalio.Direction.OUTPUT:
|
||||||
|
iodir &= ~(1 << self._pin)
|
||||||
|
else:
|
||||||
|
raise ValueError('Expected INPUT or OUTPUT direction!')
|
||||||
|
self._mcp.write_u8(_MCP23008_IODIR, iodir)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pull(self):
|
||||||
|
"""Set or Get Pull UP state: only digitalio.Pull.UP is supported"""
|
||||||
|
gppu = self._mcp.read_u8(_MCP23008_GPPU)
|
||||||
|
if gppu & (1 << self._pin) > 0:
|
||||||
|
return digitalio.Pull.UP
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
@pull.setter
|
||||||
|
def pull(self, val):
|
||||||
|
gppu = self._mcp.read_u8(_MCP23008_GPPU)
|
||||||
|
if val is None:
|
||||||
|
gppu &= ~(1 << self._pin) # Disable pull-up
|
||||||
|
elif val == digitalio.Pull.UP:
|
||||||
|
gppu |= (1 << self._pin)
|
||||||
|
elif val == digitalio.Pull.DOWN:
|
||||||
|
raise ValueError('Pull-down resistors are not supported!')
|
||||||
|
else:
|
||||||
|
raise ValueError('Expected UP, DOWN, or None for pull state!')
|
||||||
|
self._mcp.write_u8(_MCP23008_GPPU, gppu)
|
||||||
|
|
||||||
|
def __init__(self, i2c, address=_MCP23008_ADDRESS):
|
||||||
|
"""Initialize MCP23008 instance on specified I2C bus and optionally
|
||||||
|
at the specified I2C address.
|
||||||
|
"""
|
||||||
|
self._device = i2c_device.I2CDevice(i2c, address)
|
||||||
|
# Reset device state to all pins as inputs (safest option).
|
||||||
|
with self._device as device:
|
||||||
|
# Write to MCP23008_IODIR register 0xFF followed by 9 zeros
|
||||||
|
# for defaults of other registers.
|
||||||
|
device.write('\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
||||||
|
|
||||||
|
def read_u8(self, register):
|
||||||
|
"""Read an unsigned 8 bit value from the specified 8-bit register."""
|
||||||
|
with self._device as i2c:
|
||||||
|
self._BUFFER[0] = register & 0xFF
|
||||||
|
i2c.write(self._BUFFER, end=1, stop=False)
|
||||||
|
i2c.readinto(self._BUFFER, end=1)
|
||||||
|
return self._BUFFER[0]
|
||||||
|
|
||||||
|
def write_u8(self, register, val):
|
||||||
|
"""Write an 8 bit value to the specified 8-bit register."""
|
||||||
|
with self._device as i2c:
|
||||||
|
self._BUFFER[0] = register & 0xFF
|
||||||
|
self._BUFFER[1] = val & 0xFF
|
||||||
|
i2c.write(self._BUFFER)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gpio(self):
|
||||||
|
"""Get and set the raw GPIO output register. Each bit represents the
|
||||||
|
output value of the associated pin (0 = low, 1 = high), assuming that
|
||||||
|
pin has been configured as an output previously.
|
||||||
|
"""
|
||||||
|
return self.read_u8(_MCP23008_GPIO)
|
||||||
|
|
||||||
|
@gpio.setter
|
||||||
|
def gpio(self, val):
|
||||||
|
self.write_u8(_MCP23008_GPIO, val)
|
||||||
110
adafruit_character_lcd/shift_reg_74hc595.py
Normal file
110
adafruit_character_lcd/shift_reg_74hc595.py
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
"""
|
||||||
|
`adafruit_character_led.shift_reg_74hc595`
|
||||||
|
===============================================
|
||||||
|
|
||||||
|
74HC595 Serial to Paralllel Shift Register Driver
|
||||||
|
Bare-bones driver for the 74HC595, as used by the character LCD
|
||||||
|
backpack. This exposes the 74HC595 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
|
||||||
|
"""
|
||||||
|
import digitalio
|
||||||
|
|
||||||
|
import adafruit_bus_device.spi_device as spi_device
|
||||||
|
|
||||||
|
|
||||||
|
#pylint: disable-msg=too-few-public-methods
|
||||||
|
#pylint: disable-msg=no-self-use
|
||||||
|
class ShiftReg74HC595:
|
||||||
|
"""Shift Register 74LS95 driver class"""
|
||||||
|
class DigitalInOut:
|
||||||
|
"""Digital input/output of the 74HC595. The interface is exactly the
|
||||||
|
same as the digitalio.DigitalInOut class, however note that by design
|
||||||
|
this device is OUTPUT ONLY! Attempting to read inputs or set
|
||||||
|
direction as input will raise an exception.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, pin_number, shift_reg_74ls595):
|
||||||
|
"""Specify the pin number of the shift register (0...7) and
|
||||||
|
ShiftReg74HC595 instance.
|
||||||
|
"""
|
||||||
|
self._pin = pin_number
|
||||||
|
self._sr = shift_reg_74ls595
|
||||||
|
|
||||||
|
# kwargs in switch functions below are _necessary_ for compatibility
|
||||||
|
# with DigitalInout class (which allows specifying pull, etc. which
|
||||||
|
# is unused by this class). Do not remove them, instead turn off pylint
|
||||||
|
# in this case.
|
||||||
|
#pylint: disable=unused-argument
|
||||||
|
def switch_to_output(self, value=False, **kwargs):
|
||||||
|
"""DigitalInOut switch_to_output"""
|
||||||
|
self.direction = digitalio.Direction.OUTPUT
|
||||||
|
self.value = value
|
||||||
|
|
||||||
|
def switch_to_input(self, **kwargs):
|
||||||
|
"""do not call switch_to_input"""
|
||||||
|
raise RuntimeError('Unable to use 74HC595 as digital input!')
|
||||||
|
#pylint: enable=unused-argument
|
||||||
|
|
||||||
|
@property
|
||||||
|
def value(self):
|
||||||
|
"""do not call value"""
|
||||||
|
raise RuntimeError('Unable to use 74HC595 as digital input!')
|
||||||
|
|
||||||
|
@value.setter
|
||||||
|
def value(self, val):
|
||||||
|
# Only supported operation, writing a digital output.
|
||||||
|
gpio = self._sr.gpio
|
||||||
|
if val:
|
||||||
|
gpio |= (1 << self._pin)
|
||||||
|
else:
|
||||||
|
gpio &= ~(1 << self._pin)
|
||||||
|
self._sr.gpio = gpio
|
||||||
|
|
||||||
|
@property
|
||||||
|
def direction(self):
|
||||||
|
"""ALWAYS an output!"""
|
||||||
|
return digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
|
@direction.setter
|
||||||
|
def direction(self, val):
|
||||||
|
"""Can only be set as OUTPUT!"""
|
||||||
|
if val != digitalio.Direction.OUTPUT:
|
||||||
|
raise RuntimeError('Unable to use 74HC595 as digital input!')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pull(self):
|
||||||
|
"""Pull-up/down not supported, return NonLiberty e for no pull-up/down."""
|
||||||
|
return None
|
||||||
|
|
||||||
|
@pull.setter
|
||||||
|
def pull(self, val):
|
||||||
|
"""Only supports null/no pull state."""
|
||||||
|
if val is not None:
|
||||||
|
raise RuntimeError('Unable to set 74HC595 pull!')
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, spi, latch):
|
||||||
|
self._device = spi_device.SPIDevice(spi, latch, baudrate=1000000)
|
||||||
|
self._gpio = bytearray(1)
|
||||||
|
self._gpio[0] = 0x00
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gpio(self):
|
||||||
|
"""Get and set the raw GPIO output register. Each bit represents the
|
||||||
|
output value of the associated pin (0 = low, 1 = high).
|
||||||
|
"""
|
||||||
|
return self._gpio[0]
|
||||||
|
|
||||||
|
@gpio.setter
|
||||||
|
def gpio(self, val):
|
||||||
|
self._gpio[0] = val & 0xFF
|
||||||
|
with self._device as spi:
|
||||||
|
# pylint: disable=no-member
|
||||||
|
spi.write(self._gpio)
|
||||||
|
|
||||||
|
#pylint: enable-msg=no-self-use
|
||||||
|
#pylint: enable-msg=too-few-public-methods
|
||||||
|
|
@ -3,12 +3,3 @@
|
||||||
|
|
||||||
.. automodule:: adafruit_character_lcd.character_lcd
|
.. automodule:: adafruit_character_lcd.character_lcd
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
.. automodule:: adafruit_character_lcd.character_lcd_i2c
|
|
||||||
:members:
|
|
||||||
|
|
||||||
.. automodule:: adafruit_character_lcd.character_lcd_spi
|
|
||||||
:members:
|
|
||||||
|
|
||||||
.. automodule:: adafruit_character_lcd.character_lcd_rgb_i2c
|
|
||||||
:members:
|
|
||||||
|
|
|
||||||
114
docs/conf.py
114
docs/conf.py
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
sys.path.insert(0, os.path.abspath('..'))
|
||||||
sys.path.insert(0, os.path.abspath(".."))
|
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -11,9 +10,9 @@ sys.path.insert(0, os.path.abspath(".."))
|
||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
# ones.
|
# ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
"sphinx.ext.autodoc",
|
'sphinx.ext.autodoc',
|
||||||
"sphinx.ext.intersphinx",
|
'sphinx.ext.intersphinx',
|
||||||
"sphinx.ext.viewcode",
|
'sphinx.ext.viewcode',
|
||||||
]
|
]
|
||||||
|
|
||||||
# Uncomment the below if you use native CircuitPython modules such as
|
# Uncomment the below if you use native CircuitPython modules such as
|
||||||
|
|
@ -21,36 +20,29 @@ extensions = [
|
||||||
# autodoc module docs will fail to generate with a warning.
|
# autodoc module docs will fail to generate with a warning.
|
||||||
# autodoc_mock_imports = ["micropython", "digitalio", "addfruit_bus_device"]
|
# autodoc_mock_imports = ["micropython", "digitalio", "addfruit_bus_device"]
|
||||||
|
|
||||||
intersphinx_mapping = {
|
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
|
||||||
"python": ("https://docs.python.org/3.4", None),
|
|
||||||
"BusDevice": (
|
|
||||||
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
|
|
||||||
None,
|
|
||||||
),
|
|
||||||
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
templates_path = ["_templates"]
|
templates_path = ['_templates']
|
||||||
|
|
||||||
source_suffix = ".rst"
|
source_suffix = '.rst'
|
||||||
|
|
||||||
# The master toctree document.
|
# The master toctree document.
|
||||||
master_doc = "index"
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = "Adafruit CIRCUITPYTHON_CHARLCD Library"
|
project = u'Adafruit CIRCUITPYTHON_CHARLCD Library'
|
||||||
copyright = "2017 Brent Rubell"
|
copyright = u'2017 Brent Rubell'
|
||||||
author = "Brent Rubell"
|
author = u'Brent Rubell'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = "1.0"
|
version = u'1.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = "1.0"
|
release = u'1.0'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|
@ -62,7 +54,7 @@ language = None
|
||||||
# List of patterns, relative to source directory, that match files and
|
# List of patterns, relative to source directory, that match files and
|
||||||
# directories to ignore when looking for source files.
|
# directories to ignore when looking for source files.
|
||||||
# This patterns also effect to html_static_path and html_extra_path
|
# This patterns also effect to html_static_path and html_extra_path
|
||||||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
|
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`) to use for all
|
# The reST default role (used for this markup: `text`) to use for all
|
||||||
# documents.
|
# documents.
|
||||||
|
|
@ -74,7 +66,7 @@ default_role = "any"
|
||||||
add_function_parentheses = True
|
add_function_parentheses = True
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
pygments_style = "sphinx"
|
pygments_style = 'sphinx'
|
||||||
|
|
||||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||||
todo_include_todos = False
|
todo_include_todos = False
|
||||||
|
|
@ -88,62 +80,59 @@ todo_emit_warnings = True
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
#
|
#
|
||||||
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
|
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||||
|
|
||||||
if not on_rtd: # only import and set the theme if we're building docs locally
|
if not on_rtd: # only import and set the theme if we're building docs locally
|
||||||
try:
|
try:
|
||||||
import sphinx_rtd_theme
|
import sphinx_rtd_theme
|
||||||
|
html_theme = 'sphinx_rtd_theme'
|
||||||
html_theme = "sphinx_rtd_theme"
|
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
|
||||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
|
|
||||||
except:
|
except:
|
||||||
html_theme = "default"
|
html_theme = 'default'
|
||||||
html_theme_path = ["."]
|
html_theme_path = ['.']
|
||||||
else:
|
else:
|
||||||
html_theme_path = ["."]
|
html_theme_path = ['.']
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
html_static_path = ["_static"]
|
html_static_path = ['_static']
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to use as a favicon of
|
# The name of an image file (relative to this directory) to use as a favicon of
|
||||||
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
#
|
#
|
||||||
html_favicon = "_static/favicon.ico"
|
html_favicon = '_static/favicon.ico'
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = "AdafruitCIRCUITPYTHON_CHARLCDLibrarydoc"
|
htmlhelp_basename = 'AdafruitCIRCUITPYTHON_CHARLCDLibrarydoc'
|
||||||
|
|
||||||
# -- Options for LaTeX output ---------------------------------------------
|
# -- Options for LaTeX output ---------------------------------------------
|
||||||
|
|
||||||
latex_elements = {
|
latex_elements = {
|
||||||
# The paper size ('letterpaper' or 'a4paper').
|
# The paper size ('letterpaper' or 'a4paper').
|
||||||
#
|
#
|
||||||
# 'papersize': 'letterpaper',
|
# 'papersize': 'letterpaper',
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
|
||||||
#
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
# 'pointsize': '10pt',
|
#
|
||||||
# Additional stuff for the LaTeX preamble.
|
# 'pointsize': '10pt',
|
||||||
#
|
|
||||||
# 'preamble': '',
|
# Additional stuff for the LaTeX preamble.
|
||||||
# Latex figure (float) alignment
|
#
|
||||||
#
|
# 'preamble': '',
|
||||||
# 'figure_align': 'htbp',
|
|
||||||
|
# Latex figure (float) alignment
|
||||||
|
#
|
||||||
|
# 'figure_align': 'htbp',
|
||||||
}
|
}
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
(
|
(master_doc, 'AdafruitCIRCUITPYTHON_CHARLCDLibrary.tex', u'Adafruit CIRCUITPYTHON_CHARLCD Library Documentation',
|
||||||
master_doc,
|
author, 'manual'),
|
||||||
"AdafruitCIRCUITPYTHON_CHARLCDLibrary.tex",
|
|
||||||
"Adafruit CIRCUITPYTHON_CHARLCD Library Documentation",
|
|
||||||
author,
|
|
||||||
"manual",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# -- Options for manual page output ---------------------------------------
|
# -- Options for manual page output ---------------------------------------
|
||||||
|
|
@ -151,13 +140,8 @@ latex_documents = [
|
||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
(
|
(master_doc, 'adafruitCIRCUITPYTHON_CHARLCDlibrary', u'Adafruit CIRCUITPYTHON_CHARLCD Library Documentation',
|
||||||
master_doc,
|
[author], 1)
|
||||||
"adafruitCIRCUITPYTHON_CHARLCDlibrary",
|
|
||||||
"Adafruit CIRCUITPYTHON_CHARLCD Library Documentation",
|
|
||||||
[author],
|
|
||||||
1,
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# -- Options for Texinfo output -------------------------------------------
|
# -- Options for Texinfo output -------------------------------------------
|
||||||
|
|
@ -166,13 +150,7 @@ man_pages = [
|
||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
(
|
(master_doc, 'AdafruitCIRCUITPYTHON_CHARLCDLibrary', u'Adafruit CIRCUITPYTHON_CHARLCD Library Documentation',
|
||||||
master_doc,
|
author, 'AdafruitCIRCUITPYTHON_CHARLCDLibrary', 'One line description of project.',
|
||||||
"AdafruitCIRCUITPYTHON_CHARLCDLibrary",
|
'Miscellaneous'),
|
||||||
"Adafruit CIRCUITPYTHON_CHARLCD Library Documentation",
|
|
||||||
author,
|
|
||||||
"AdafruitCIRCUITPYTHON_CHARLCDLibrary",
|
|
||||||
"One line description of project.",
|
|
||||||
"Miscellaneous",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,10 @@ Ensure your device works with this simple test.
|
||||||
:caption: examples/charlcd_rgb_simpletest.py
|
:caption: examples/charlcd_rgb_simpletest.py
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
.. literalinclude:: ../examples/charlcd_i2c_mono_simpletest.py
|
.. literalinclude:: ../examples/charlcd_I2C_simpletest.py
|
||||||
:caption: examples/charlcd_i2c_mono_simpletest.py
|
:caption: examples/charlcd_I2C_simpletest.py
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
.. literalinclude:: ../examples/charlcd_spi_mono_simpletest.py
|
.. literalinclude:: ../examples/charlcd_SPI_simpletest.py
|
||||||
:caption: examples/charlcd_spi_mono_simpletest.py
|
:caption: examples/charlcd_SPI_simpletest.py
|
||||||
:linenos:
|
|
||||||
|
|
||||||
.. literalinclude:: ../examples/charlcd_keypad_simpletest.py
|
|
||||||
:caption: examples/charlcd_keypad_simpletest.py
|
|
||||||
:linenos:
|
:linenos:
|
||||||
50
examples/charlcd_I2C_simpletest.py
Normal file
50
examples/charlcd_I2C_simpletest.py
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
# Hello World using 16x2 character lcd and an MCP23008 I2C LCD backpack.
|
||||||
|
import time
|
||||||
|
|
||||||
|
import board
|
||||||
|
import busio
|
||||||
|
|
||||||
|
import adafruit_character_lcd
|
||||||
|
|
||||||
|
|
||||||
|
# Character LCD Config:
|
||||||
|
# modify this if you have a different sized charlcd
|
||||||
|
lcd_columns = 16
|
||||||
|
lcd_rows = 2
|
||||||
|
|
||||||
|
# Initialize I2C bus.
|
||||||
|
i2c = busio.I2C(board.SCL, board.SDA)
|
||||||
|
|
||||||
|
# Init the lcd class
|
||||||
|
lcd = adafruit_character_lcd.Character_LCD_I2C(i2c, lcd_columns, lcd_rows)
|
||||||
|
|
||||||
|
# Print a 2x line message
|
||||||
|
lcd.message('hello\ncircuitpython')
|
||||||
|
# Wait 5s
|
||||||
|
time.sleep(5)
|
||||||
|
# Demo showing cursor
|
||||||
|
lcd.clear()
|
||||||
|
lcd.show_cursor(True)
|
||||||
|
lcd.message('showing cursor ')
|
||||||
|
# Wait 5s
|
||||||
|
time.sleep(5)
|
||||||
|
# Demo showing the blinking cursor
|
||||||
|
lcd.clear()
|
||||||
|
lcd.blink(True)
|
||||||
|
lcd.message('Blinky Cursor!')
|
||||||
|
# Wait 5s
|
||||||
|
time.sleep(5)
|
||||||
|
lcd.blink(False)
|
||||||
|
# Demo scrolling message LEFT
|
||||||
|
lcd.clear()
|
||||||
|
scroll_msg = 'Scroll'
|
||||||
|
lcd.message(scroll_msg)
|
||||||
|
# Scroll to the left
|
||||||
|
for i in range(lcd_columns - len(scroll_msg)):
|
||||||
|
time.sleep(0.5)
|
||||||
|
lcd.move_left()
|
||||||
|
# Demo turning backlight off
|
||||||
|
lcd.clear()
|
||||||
|
lcd.message("going to sleep\ncya later!")
|
||||||
|
lcd.set_backlight(False)
|
||||||
|
time.sleep(2)
|
||||||
57
examples/charlcd_SPI_simpletest.py
Normal file
57
examples/charlcd_SPI_simpletest.py
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
# Hello World using 16x2 character lcd and an 74LS595 SPI LCD backpack.
|
||||||
|
import time
|
||||||
|
|
||||||
|
import board
|
||||||
|
import busio
|
||||||
|
import digitalio
|
||||||
|
|
||||||
|
import adafruit_character_lcd
|
||||||
|
|
||||||
|
|
||||||
|
# Character LCD Config:
|
||||||
|
# modify this if you have a different sized charlcd
|
||||||
|
lcd_columns = 16
|
||||||
|
lcd_rows = 2
|
||||||
|
|
||||||
|
# Backpack connection configuration:
|
||||||
|
clk = board.SCK # Pin connected to backpack CLK.
|
||||||
|
data = board.MOSI # Pin connected to backpack DAT/data.
|
||||||
|
latch = board.D5 # Pin connected to backpack LAT/latch.
|
||||||
|
|
||||||
|
# Initialize SPI bus.
|
||||||
|
spi = busio.SPI(clk, MOSI=data)
|
||||||
|
|
||||||
|
# Init the lcd class
|
||||||
|
latch = digitalio.DigitalInOut(latch)
|
||||||
|
lcd = adafruit_character_lcd.Character_LCD_SPI(spi, latch, lcd_columns, lcd_rows)
|
||||||
|
|
||||||
|
# Print a 2x line message
|
||||||
|
lcd.message('hello\ncircuitpython')
|
||||||
|
# Wait 5s
|
||||||
|
time.sleep(5)
|
||||||
|
# Demo showing cursor
|
||||||
|
lcd.clear()
|
||||||
|
lcd.show_cursor(True)
|
||||||
|
lcd.message('showing cursor ')
|
||||||
|
# Wait 5s
|
||||||
|
time.sleep(5)
|
||||||
|
# Demo showing the blinking cursor
|
||||||
|
lcd.clear()
|
||||||
|
lcd.blink(True)
|
||||||
|
lcd.message('Blinky Cursor!')
|
||||||
|
# Wait 5s
|
||||||
|
time.sleep(5)
|
||||||
|
lcd.blink(False)
|
||||||
|
# Demo scrolling message LEFT
|
||||||
|
lcd.clear()
|
||||||
|
scroll_msg = 'Scroll'
|
||||||
|
lcd.message(scroll_msg)
|
||||||
|
# Scroll to the left
|
||||||
|
for i in range(lcd_columns - len(scroll_msg)):
|
||||||
|
time.sleep(0.5)
|
||||||
|
lcd.move_left()
|
||||||
|
# Demo turning backlight off
|
||||||
|
lcd.clear()
|
||||||
|
lcd.message("going to sleep\ncya later!")
|
||||||
|
lcd.set_backlight(False)
|
||||||
|
time.sleep(2)
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
"""Display a custom character"""
|
|
||||||
import board
|
|
||||||
import digitalio
|
|
||||||
import adafruit_character_lcd.character_lcd as characterlcd
|
|
||||||
|
|
||||||
# Modify this if you have a different sized character LCD
|
|
||||||
lcd_columns = 16
|
|
||||||
lcd_rows = 2
|
|
||||||
|
|
||||||
# Metro M0/M4 Pin Config:
|
|
||||||
lcd_rs = digitalio.DigitalInOut(board.D7)
|
|
||||||
lcd_en = digitalio.DigitalInOut(board.D8)
|
|
||||||
lcd_d7 = digitalio.DigitalInOut(board.D12)
|
|
||||||
lcd_d6 = digitalio.DigitalInOut(board.D11)
|
|
||||||
lcd_d5 = digitalio.DigitalInOut(board.D10)
|
|
||||||
lcd_d4 = digitalio.DigitalInOut(board.D9)
|
|
||||||
lcd_backlight = digitalio.DigitalInOut(board.D13)
|
|
||||||
|
|
||||||
# Initialise the LCD class
|
|
||||||
lcd = characterlcd.Character_LCD_Mono(
|
|
||||||
lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight
|
|
||||||
)
|
|
||||||
|
|
||||||
checkmark = bytes([0x0, 0x0, 0x1, 0x3, 0x16, 0x1C, 0x8, 0x0])
|
|
||||||
|
|
||||||
# Store in LCD character memory 0
|
|
||||||
lcd.create_char(0, checkmark)
|
|
||||||
|
|
||||||
lcd.clear()
|
|
||||||
lcd.message = "\x00"
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
"""Simple test for 16x2 character lcd connected to an MCP23008 I2C LCD backpack."""
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_i2c as character_lcd
|
|
||||||
|
|
||||||
# Modify this if you have a different sized Character LCD
|
|
||||||
lcd_columns = 16
|
|
||||||
lcd_rows = 2
|
|
||||||
|
|
||||||
# Initialise I2C bus.
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
|
|
||||||
# Initialise the lcd class
|
|
||||||
lcd = character_lcd.Character_LCD_I2C(i2c, lcd_columns, lcd_rows)
|
|
||||||
|
|
||||||
# Turn backlight on
|
|
||||||
lcd.backlight = True
|
|
||||||
# Print a two line message
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.clear()
|
|
||||||
# Print two line message right to left
|
|
||||||
lcd.text_direction = lcd.RIGHT_TO_LEFT
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Return text direction to left to right
|
|
||||||
lcd.text_direction = lcd.LEFT_TO_RIGHT
|
|
||||||
# Display cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.cursor = True
|
|
||||||
lcd.message = "Cursor! "
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Display blinking cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.blink = True
|
|
||||||
lcd.message = "Blinky Cursor!"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.blink = False
|
|
||||||
lcd.clear()
|
|
||||||
# Create message to scroll
|
|
||||||
scroll_msg = "<-- Scroll"
|
|
||||||
lcd.message = scroll_msg
|
|
||||||
# Scroll message to the left
|
|
||||||
for i in range(len(scroll_msg)):
|
|
||||||
time.sleep(0.5)
|
|
||||||
lcd.move_left()
|
|
||||||
lcd.clear()
|
|
||||||
lcd.message = "Going to sleep\nCya later!"
|
|
||||||
time.sleep(5)
|
|
||||||
# Turn backlight off
|
|
||||||
lcd.backlight = False
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
"""Simple test for I2C RGB character LCD shield kit"""
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
|
|
||||||
|
|
||||||
# Modify this if you have a different sized Character LCD
|
|
||||||
lcd_columns = 16
|
|
||||||
lcd_rows = 2
|
|
||||||
|
|
||||||
# Initialise I2C bus.
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
|
|
||||||
# Initialise the LCD class
|
|
||||||
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows)
|
|
||||||
|
|
||||||
lcd.clear()
|
|
||||||
# Set LCD color to red
|
|
||||||
lcd.color = [100, 0, 0]
|
|
||||||
time.sleep(1)
|
|
||||||
# Print two line message
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Set LCD color to blue
|
|
||||||
lcd.color = [0, 100, 0]
|
|
||||||
time.sleep(1)
|
|
||||||
# Set LCD color to green
|
|
||||||
lcd.color = [0, 0, 100]
|
|
||||||
time.sleep(1)
|
|
||||||
# Set LCD color to purple
|
|
||||||
lcd.color = [50, 0, 50]
|
|
||||||
time.sleep(1)
|
|
||||||
lcd.clear()
|
|
||||||
# Print two line message right to left
|
|
||||||
lcd.text_direction = lcd.RIGHT_TO_LEFT
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Return text direction to left to right
|
|
||||||
lcd.text_direction = lcd.LEFT_TO_RIGHT
|
|
||||||
# Display cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.cursor = True
|
|
||||||
lcd.message = "Cursor! "
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Display blinking cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.blink = True
|
|
||||||
lcd.message = "Blinky Cursor!"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.blink = False
|
|
||||||
lcd.clear()
|
|
||||||
# Create message to scroll
|
|
||||||
scroll_msg = "<-- Scroll"
|
|
||||||
lcd.message = scroll_msg
|
|
||||||
# Scroll to the left
|
|
||||||
for i in range(len(scroll_msg)):
|
|
||||||
time.sleep(0.5)
|
|
||||||
lcd.move_left()
|
|
||||||
lcd.clear()
|
|
||||||
time.sleep(1)
|
|
||||||
lcd.message = "Going to sleep\nCya later!"
|
|
||||||
time.sleep(5)
|
|
||||||
# Turn off LCD backlights and clear text
|
|
||||||
lcd.color = [0, 0, 0]
|
|
||||||
lcd.clear()
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
"""Simple test for keypad on I2C RGB character LCD Shield or Pi Plate kits"""
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
|
|
||||||
|
|
||||||
# Modify this if you have a different sized Character LCD
|
|
||||||
lcd_columns = 16
|
|
||||||
lcd_rows = 2
|
|
||||||
|
|
||||||
# Initialise I2C bus.
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
|
||||||
|
|
||||||
# Initialise the LCD class
|
|
||||||
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows)
|
|
||||||
|
|
||||||
lcd.clear()
|
|
||||||
lcd.color = [100, 0, 0]
|
|
||||||
while True:
|
|
||||||
if lcd.left_button:
|
|
||||||
print("Left!")
|
|
||||||
lcd.message = "Left!"
|
|
||||||
|
|
||||||
elif lcd.up_button:
|
|
||||||
print("Up!")
|
|
||||||
lcd.message = "Up!"
|
|
||||||
|
|
||||||
elif lcd.down_button:
|
|
||||||
print("Down!")
|
|
||||||
lcd.message = "Down!"
|
|
||||||
|
|
||||||
elif lcd.right_button:
|
|
||||||
print("Right!")
|
|
||||||
lcd.message = "Right!"
|
|
||||||
|
|
||||||
elif lcd.select_button:
|
|
||||||
print("Select!")
|
|
||||||
lcd.message = "Select!"
|
|
||||||
|
|
||||||
else:
|
|
||||||
time.sleep(0.1)
|
|
||||||
lcd.clear()
|
|
||||||
|
|
@ -1,65 +1,61 @@
|
||||||
"""Simple test for monochromatic character LCD"""
|
"""
|
||||||
import time
|
'hello_CircuitPython.py'
|
||||||
import board
|
=================================================
|
||||||
import digitalio
|
hello world using 16x2 character lcd
|
||||||
import adafruit_character_lcd.character_lcd as characterlcd
|
requires:
|
||||||
|
- CircuitPython_CharLCD Module
|
||||||
|
"""
|
||||||
|
|
||||||
# Modify this if you have a different sized character LCD
|
import time
|
||||||
|
from board import D7, D8, D9, D10, D11, D12, D13
|
||||||
|
import digitalio
|
||||||
|
import adafruit_character_lcd
|
||||||
|
|
||||||
|
# Character LCD Config:
|
||||||
|
# modify this if you have a different sized charlcd
|
||||||
lcd_columns = 16
|
lcd_columns = 16
|
||||||
lcd_rows = 2
|
lcd_rows = 2
|
||||||
|
|
||||||
# Metro M0/M4 Pin Config:
|
# Metro m0 Pin Config:
|
||||||
lcd_rs = digitalio.DigitalInOut(board.D7)
|
lcd_rs = digitalio.DigitalInOut(D7)
|
||||||
lcd_en = digitalio.DigitalInOut(board.D8)
|
lcd_en = digitalio.DigitalInOut(D8)
|
||||||
lcd_d7 = digitalio.DigitalInOut(board.D12)
|
lcd_d7 = digitalio.DigitalInOut(D12)
|
||||||
lcd_d6 = digitalio.DigitalInOut(board.D11)
|
lcd_d6 = digitalio.DigitalInOut(D11)
|
||||||
lcd_d5 = digitalio.DigitalInOut(board.D10)
|
lcd_d5 = digitalio.DigitalInOut(D10)
|
||||||
lcd_d4 = digitalio.DigitalInOut(board.D9)
|
lcd_d4 = digitalio.DigitalInOut(D9)
|
||||||
lcd_backlight = digitalio.DigitalInOut(board.D13)
|
lcd_backlight = digitalio.DigitalInOut(D13)
|
||||||
|
|
||||||
# Initialise the LCD class
|
# Init the lcd class
|
||||||
lcd = characterlcd.Character_LCD_Mono(
|
lcd = adafruit_character_lcd.Character_LCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6,
|
||||||
lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight
|
lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
|
||||||
)
|
|
||||||
|
|
||||||
# Turn backlight on
|
# Print a 2x line message
|
||||||
lcd.backlight = True
|
lcd.message('hello\ncircuitpython')
|
||||||
# Print a two line message
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
# Wait 5s
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
# Demo showing cursor
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
# Print two line message right to left
|
lcd.show_cursor(True)
|
||||||
lcd.text_direction = lcd.RIGHT_TO_LEFT
|
lcd.message('showing cursor ')
|
||||||
lcd.message = "Hello\nCircuitPython"
|
# Wait 5s
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
# Return text direction to left to right
|
# Demo showing the blinking cursor
|
||||||
lcd.text_direction = lcd.LEFT_TO_RIGHT
|
|
||||||
# Display cursor
|
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
lcd.cursor = True
|
lcd.blink(True)
|
||||||
lcd.message = "Cursor! "
|
lcd.message('Blinky Cursor!')
|
||||||
# Wait 5s
|
# Wait 5s
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
# Display blinking cursor
|
lcd.blink(False)
|
||||||
|
# Demo scrolling message LEFT
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
lcd.blink = True
|
scroll_msg = 'Scroll'
|
||||||
lcd.message = "Blinky Cursor!"
|
lcd.message(scroll_msg)
|
||||||
# Wait 5s
|
# Scroll to the left
|
||||||
time.sleep(5)
|
for i in range(lcd_columns - len(scroll_msg)):
|
||||||
lcd.blink = False
|
|
||||||
lcd.clear()
|
|
||||||
# Create message to scroll
|
|
||||||
scroll_msg = "<-- Scroll"
|
|
||||||
lcd.message = scroll_msg
|
|
||||||
# Scroll message to the left
|
|
||||||
for i in range(len(scroll_msg)):
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
lcd.move_left()
|
lcd.move_left()
|
||||||
|
# Demo turning backlight off
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
lcd.message = "Going to sleep\nCya later!"
|
lcd.message("going to sleep\ncya later!")
|
||||||
time.sleep(3)
|
lcd.set_backlight(False)
|
||||||
# Turn backlight off
|
|
||||||
lcd.backlight = False
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
|
||||||
|
|
@ -1,90 +1,43 @@
|
||||||
"""Simple test for RGB character LCD"""
|
|
||||||
import time
|
import time
|
||||||
import board
|
from board import D3, D4, D5, D7, D8, D9, D10, D11, D12, D13
|
||||||
import digitalio
|
import digitalio
|
||||||
|
import adafruit_character_lcd
|
||||||
import pulseio
|
import pulseio
|
||||||
import adafruit_character_lcd.character_lcd as characterlcd
|
|
||||||
|
|
||||||
# Modify this if you have a different sized character LCD
|
# Character LCD Config:
|
||||||
|
# modify this if you have a different sized charlcd
|
||||||
lcd_columns = 16
|
lcd_columns = 16
|
||||||
lcd_rows = 2
|
lcd_rows = 2
|
||||||
|
|
||||||
# Metro M0/M4 Pin Config:
|
# Metro m0 Pin Config:
|
||||||
lcd_rs = digitalio.DigitalInOut(board.D7)
|
lcd_rs = digitalio.DigitalInOut(D7)
|
||||||
lcd_en = digitalio.DigitalInOut(board.D8)
|
lcd_en = digitalio.DigitalInOut(D8)
|
||||||
lcd_d7 = digitalio.DigitalInOut(board.D12)
|
lcd_d7 = digitalio.DigitalInOut(D12)
|
||||||
lcd_d6 = digitalio.DigitalInOut(board.D11)
|
lcd_d6 = digitalio.DigitalInOut(D11)
|
||||||
lcd_d5 = digitalio.DigitalInOut(board.D10)
|
lcd_d5 = digitalio.DigitalInOut(D10)
|
||||||
lcd_d4 = digitalio.DigitalInOut(board.D9)
|
lcd_d4 = digitalio.DigitalInOut(D9)
|
||||||
red = pulseio.PWMOut(board.D3)
|
lcd_backlight = digitalio.DigitalInOut(D13)
|
||||||
green = pulseio.PWMOut(board.D5)
|
red = pulseio.PWMOut(D3)
|
||||||
blue = pulseio.PWMOut(board.D6)
|
green = pulseio.PWMOut(D4)
|
||||||
|
blue = pulseio.PWMOut(D5)
|
||||||
|
|
||||||
# Initialise the LCD class
|
# Init the lcd class
|
||||||
lcd = characterlcd.Character_LCD_RGB(
|
lcd = adafruit_character_lcd.Character_LCD_RGB(lcd_rs, lcd_en, lcd_d4, lcd_d5,
|
||||||
lcd_rs,
|
lcd_d6, lcd_d7, lcd_columns, lcd_rows,
|
||||||
lcd_en,
|
red, green, blue, lcd_backlight)
|
||||||
lcd_d4,
|
|
||||||
lcd_d5,
|
|
||||||
lcd_d6,
|
|
||||||
lcd_d7,
|
|
||||||
lcd_columns,
|
|
||||||
lcd_rows,
|
|
||||||
red,
|
|
||||||
green,
|
|
||||||
blue,
|
|
||||||
)
|
|
||||||
|
|
||||||
lcd.clear()
|
#pylint: disable-msg=bad-whitespace
|
||||||
# Set LCD color to red
|
# only red
|
||||||
lcd.color = [100, 0, 0]
|
RED = [100, 0, 0]
|
||||||
time.sleep(1)
|
GREEN = [0, 100, 0]
|
||||||
# Print two line message
|
BLUE = [0, 0, 100]
|
||||||
lcd.message = "Hello\nCircuitPython"
|
#pylint: enable-msg=bad-whitespace
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
while True:
|
||||||
# Set LCD color to blue
|
lcd.message('CircuitPython\nRGB Test')
|
||||||
lcd.color = [0, 100, 0]
|
lcd.set_color(RED)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
# Set LCD color to green
|
lcd.set_color(GREEN)
|
||||||
lcd.color = [0, 0, 100]
|
time.sleep(1)
|
||||||
time.sleep(1)
|
lcd.set_color(BLUE)
|
||||||
# Set LCD color to purple
|
time.sleep(1)
|
||||||
lcd.color = [50, 0, 50]
|
|
||||||
time.sleep(1)
|
|
||||||
lcd.clear()
|
|
||||||
# Print two line message right to left
|
|
||||||
lcd.text_direction = lcd.RIGHT_TO_LEFT
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Return text direction to left to right
|
|
||||||
lcd.text_direction = lcd.LEFT_TO_RIGHT
|
|
||||||
# Display cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.cursor = True
|
|
||||||
lcd.message = "Cursor! "
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Display blinking cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.blink = True
|
|
||||||
lcd.message = "Blinky Cursor!"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.blink = False
|
|
||||||
lcd.clear()
|
|
||||||
# Create message to scroll
|
|
||||||
scroll_msg = "<-- Scroll"
|
|
||||||
lcd.message = scroll_msg
|
|
||||||
# Scroll to the left
|
|
||||||
for i in range(len(scroll_msg)):
|
|
||||||
time.sleep(0.5)
|
|
||||||
lcd.move_left()
|
|
||||||
lcd.clear()
|
|
||||||
time.sleep(1)
|
|
||||||
lcd.message = "Going to sleep\nCya later!"
|
|
||||||
time.sleep(5)
|
|
||||||
# Turn off LCD backlights and clear text
|
|
||||||
lcd.color = [0, 0, 0]
|
|
||||||
lcd.clear()
|
|
||||||
|
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
"""Simple test for monochromatic character LCD on Raspberry Pi"""
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import digitalio
|
|
||||||
import adafruit_character_lcd.character_lcd as characterlcd
|
|
||||||
|
|
||||||
# Modify this if you have a different sized character LCD
|
|
||||||
lcd_columns = 16
|
|
||||||
lcd_rows = 2
|
|
||||||
|
|
||||||
# Raspberry Pi Pin Config:
|
|
||||||
lcd_rs = digitalio.DigitalInOut(board.D26)
|
|
||||||
lcd_en = digitalio.DigitalInOut(board.D19)
|
|
||||||
lcd_d7 = digitalio.DigitalInOut(board.D27)
|
|
||||||
lcd_d6 = digitalio.DigitalInOut(board.D22)
|
|
||||||
lcd_d5 = digitalio.DigitalInOut(board.D24)
|
|
||||||
lcd_d4 = digitalio.DigitalInOut(board.D25)
|
|
||||||
lcd_backlight = digitalio.DigitalInOut(board.D4)
|
|
||||||
|
|
||||||
# Initialise the lcd class
|
|
||||||
lcd = characterlcd.Character_LCD_Mono(
|
|
||||||
lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight
|
|
||||||
)
|
|
||||||
|
|
||||||
# Turn backlight on
|
|
||||||
lcd.backlight = True
|
|
||||||
# Print a two line message
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.clear()
|
|
||||||
# Print two line message right to left
|
|
||||||
lcd.text_direction = lcd.RIGHT_TO_LEFT
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Return text direction to left to right
|
|
||||||
lcd.text_direction = lcd.LEFT_TO_RIGHT
|
|
||||||
# Display cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.cursor = True
|
|
||||||
lcd.message = "Cursor! "
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Display blinking cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.blink = True
|
|
||||||
lcd.message = "Blinky Cursor!"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.blink = False
|
|
||||||
lcd.clear()
|
|
||||||
# Create message to scroll
|
|
||||||
scroll_msg = "<-- Scroll"
|
|
||||||
lcd.message = scroll_msg
|
|
||||||
# Scroll message to the left
|
|
||||||
for i in range(len(scroll_msg)):
|
|
||||||
time.sleep(0.5)
|
|
||||||
lcd.move_left()
|
|
||||||
lcd.clear()
|
|
||||||
lcd.message = "Going to sleep\nCya later!"
|
|
||||||
# Turn backlight off
|
|
||||||
lcd.backlight = False
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
"""Simple test for RGB character LCD on Raspberry Pi"""
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import digitalio
|
|
||||||
import adafruit_character_lcd.character_lcd as characterlcd
|
|
||||||
|
|
||||||
# Modify this if you have a different sized character LCD
|
|
||||||
lcd_columns = 16
|
|
||||||
lcd_rows = 2
|
|
||||||
|
|
||||||
# Raspberry Pi Pin Config:
|
|
||||||
lcd_rs = digitalio.DigitalInOut(board.D26) # pin 4
|
|
||||||
lcd_en = digitalio.DigitalInOut(board.D19) # pin 6
|
|
||||||
lcd_d7 = digitalio.DigitalInOut(board.D27) # pin 14
|
|
||||||
lcd_d6 = digitalio.DigitalInOut(board.D22) # pin 13
|
|
||||||
lcd_d5 = digitalio.DigitalInOut(board.D24) # pin 12
|
|
||||||
lcd_d4 = digitalio.DigitalInOut(board.D25) # pin 11
|
|
||||||
lcd_backlight = digitalio.DigitalInOut(board.D4)
|
|
||||||
|
|
||||||
red = digitalio.DigitalInOut(board.D21)
|
|
||||||
green = digitalio.DigitalInOut(board.D12)
|
|
||||||
blue = digitalio.DigitalInOut(board.D18)
|
|
||||||
|
|
||||||
# Initialise the LCD class
|
|
||||||
lcd = characterlcd.Character_LCD_RGB(
|
|
||||||
lcd_rs,
|
|
||||||
lcd_en,
|
|
||||||
lcd_d4,
|
|
||||||
lcd_d5,
|
|
||||||
lcd_d6,
|
|
||||||
lcd_d7,
|
|
||||||
lcd_columns,
|
|
||||||
lcd_rows,
|
|
||||||
red,
|
|
||||||
green,
|
|
||||||
blue,
|
|
||||||
lcd_backlight,
|
|
||||||
)
|
|
||||||
|
|
||||||
RED = [1, 0, 0]
|
|
||||||
GREEN = [0, 1, 0]
|
|
||||||
BLUE = [0, 0, 1]
|
|
||||||
|
|
||||||
while True:
|
|
||||||
lcd.clear()
|
|
||||||
lcd.message = "CircuitPython\nRGB Test: RED"
|
|
||||||
lcd.color = RED
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
lcd.clear()
|
|
||||||
lcd.message = "CircuitPython\nRGB Test: GREEN"
|
|
||||||
lcd.color = GREEN
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
lcd.clear()
|
|
||||||
lcd.message = "CircuitPython\nRGB Test: BLUE"
|
|
||||||
lcd.color = BLUE
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
"""Simple test for 16x2 character LCD connected to 74HC595 SPI LCD backpack."""
|
|
||||||
import time
|
|
||||||
import board
|
|
||||||
import busio
|
|
||||||
import digitalio
|
|
||||||
import adafruit_character_lcd.character_lcd_spi as character_lcd
|
|
||||||
|
|
||||||
# Modify this if you have a different sized character LCD
|
|
||||||
lcd_columns = 16
|
|
||||||
lcd_rows = 2
|
|
||||||
|
|
||||||
# Backpack connection configuration:
|
|
||||||
clk = board.SCK # Pin connected to backpack CLK.
|
|
||||||
data = board.MOSI # Pin connected to backpack DAT/data.
|
|
||||||
latch = board.D5 # Pin connected to backpack LAT/latch.
|
|
||||||
|
|
||||||
# Initialise SPI bus.
|
|
||||||
spi = busio.SPI(clk, MOSI=data)
|
|
||||||
|
|
||||||
# Initialise the LCD class
|
|
||||||
latch = digitalio.DigitalInOut(latch)
|
|
||||||
lcd = character_lcd.Character_LCD_SPI(spi, latch, lcd_columns, lcd_rows)
|
|
||||||
|
|
||||||
# Turn backlight on
|
|
||||||
lcd.backlight = True
|
|
||||||
# Print a two line message
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.clear()
|
|
||||||
# Print two line message right to left
|
|
||||||
lcd.text_direction = lcd.RIGHT_TO_LEFT
|
|
||||||
lcd.message = "Hello\nCircuitPython"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Return text direction to left to right
|
|
||||||
lcd.text_direction = lcd.LEFT_TO_RIGHT
|
|
||||||
# Display cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.cursor = True
|
|
||||||
lcd.message = "Cursor! "
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
# Display blinking cursor
|
|
||||||
lcd.clear()
|
|
||||||
lcd.blink = True
|
|
||||||
lcd.message = "Blinky Cursor!"
|
|
||||||
# Wait 5s
|
|
||||||
time.sleep(5)
|
|
||||||
lcd.blink = False
|
|
||||||
lcd.clear()
|
|
||||||
# Create message to scroll
|
|
||||||
scroll_msg = "<-- Scroll"
|
|
||||||
lcd.message = scroll_msg
|
|
||||||
# Scroll message to the left
|
|
||||||
for i in range(len(scroll_msg)):
|
|
||||||
time.sleep(0.5)
|
|
||||||
lcd.move_left()
|
|
||||||
lcd.clear()
|
|
||||||
lcd.message = "Going to sleep\nCya later!"
|
|
||||||
# Turn backlight off
|
|
||||||
lcd.backlight = False
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
@ -1,26 +1,19 @@
|
||||||
"""Use custom characters to display Nyan cat"""
|
|
||||||
import time
|
import time
|
||||||
import board
|
from board import D7, D8, D9, D10, D11, D12, D13
|
||||||
import digitalio
|
import digitalio
|
||||||
import adafruit_character_lcd.character_lcd as characterlcd
|
import adafruit_character_lcd
|
||||||
|
|
||||||
# Modify this if you have a different sized character LCD
|
|
||||||
lcd_columns = 16
|
lcd_columns = 16
|
||||||
lcd_rows = 2
|
lcd_rows = 2
|
||||||
|
lcd_rs = digitalio.DigitalInOut(D7)
|
||||||
# Metro M0/M4 Pin Config:
|
lcd_en = digitalio.DigitalInOut(D8)
|
||||||
lcd_rs = digitalio.DigitalInOut(board.D7)
|
lcd_d7 = digitalio.DigitalInOut(D12)
|
||||||
lcd_en = digitalio.DigitalInOut(board.D8)
|
lcd_d6 = digitalio.DigitalInOut(D11)
|
||||||
lcd_d7 = digitalio.DigitalInOut(board.D12)
|
lcd_d5 = digitalio.DigitalInOut(D10)
|
||||||
lcd_d6 = digitalio.DigitalInOut(board.D11)
|
lcd_d4 = digitalio.DigitalInOut(D9)
|
||||||
lcd_d5 = digitalio.DigitalInOut(board.D10)
|
lcd_backlight = digitalio.DigitalInOut(D13)
|
||||||
lcd_d4 = digitalio.DigitalInOut(board.D9)
|
lcd = adafruit_character_lcd.Character_LCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6,
|
||||||
lcd_backlight = digitalio.DigitalInOut(board.D13)
|
lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
|
||||||
|
|
||||||
# Initialise the LCD class
|
|
||||||
lcd = characterlcd.Character_LCD_Mono(
|
|
||||||
lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight
|
|
||||||
)
|
|
||||||
|
|
||||||
head = [31, 17, 27, 17, 17, 21, 17, 31]
|
head = [31, 17, 27, 17, 17, 21, 17, 31]
|
||||||
|
|
||||||
|
|
@ -72,21 +65,30 @@ lcd.create_char(7, tail_neutral)
|
||||||
|
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
|
|
||||||
|
body_width = 3
|
||||||
lcd.move_right()
|
lcd.move_right()
|
||||||
lcd.message = (
|
for i in range(4):
|
||||||
"\x02\x02\x02\x02\x01\x00\x00\x00\x06\n\x02\x02\x02\x07\x03\x04\x04\x04\x05"
|
lcd.message('\x02')
|
||||||
)
|
lcd.message('\x01')
|
||||||
|
for i in range(body_width):
|
||||||
lcd.backlight = True
|
lcd.message('\x00')
|
||||||
|
lcd.message('\x06')
|
||||||
|
lcd.message('\n')
|
||||||
|
lcd.message('\x02\x02\x02')
|
||||||
|
lcd.message('\x07')
|
||||||
|
lcd.message('\x03')
|
||||||
|
for i in range(body_width):
|
||||||
|
lcd.message('\x04')
|
||||||
|
lcd.message('\x05')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
lcd.create_char(4, bot_body2)
|
lcd.create_char(4, bot_body2)
|
||||||
lcd.create_char(7, tail_up)
|
lcd.create_char(7, tail_up)
|
||||||
lcd.create_char(2, rainbow2)
|
lcd.create_char(2, rainbow2)
|
||||||
lcd.move_right()
|
lcd.move_right()
|
||||||
time.sleep(0.4)
|
time.sleep(.4)
|
||||||
lcd.create_char(4, bot_body)
|
lcd.create_char(4, bot_body)
|
||||||
lcd.create_char(7, tail_neutral)
|
lcd.create_char(7, tail_neutral)
|
||||||
lcd.create_char(2, rainbow)
|
lcd.create_char(2, rainbow)
|
||||||
lcd.move_left()
|
lcd.move_left()
|
||||||
time.sleep(0.4)
|
time.sleep(.4)
|
||||||
19
examples/customcharacter.py
Normal file
19
examples/customcharacter.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import digitalio
|
||||||
|
from board import D7, D8, D9, D10, D11, D12, D13
|
||||||
|
import adafruit_character_lcd
|
||||||
|
|
||||||
|
|
||||||
|
lcd_columns = 16
|
||||||
|
lcd_rows = 2
|
||||||
|
lcd_rs = digitalio.DigitalInOut(D7)
|
||||||
|
lcd_en = digitalio.DigitalInOut(D8)
|
||||||
|
lcd_d7 = digitalio.DigitalInOut(D12)
|
||||||
|
lcd_d6 = digitalio.DigitalInOut(D11)
|
||||||
|
lcd_d5 = digitalio.DigitalInOut(D10)
|
||||||
|
lcd_d4 = digitalio.DigitalInOut(D9)
|
||||||
|
lcd_backlight = digitalio.DigitalInOut(D13)
|
||||||
|
lcd = adafruit_character_lcd.Character_LCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6,
|
||||||
|
lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
|
||||||
|
checkmark = bytes([0x0, 0x0, 0x1, 0x3, 0x16, 0x1c, 0x8, 0x0])
|
||||||
|
lcd.clear()
|
||||||
|
lcd.message('\x00')
|
||||||
|
|
@ -1,4 +1,2 @@
|
||||||
Adafruit-Blinka
|
|
||||||
adafruit-circuitpython-74hc595
|
|
||||||
adafruit-circuitpython-busdevice
|
adafruit-circuitpython-busdevice
|
||||||
adafruit-circuitpython-mcp230xx
|
Adafruit-Blinka
|
||||||
55
setup.py
55
setup.py
|
|
@ -7,7 +7,6 @@ https://github.com/pypa/sampleproject
|
||||||
|
|
||||||
# Always prefer setuptools over distutils
|
# Always prefer setuptools over distutils
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
# To use a consistent encoding
|
# To use a consistent encoding
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path
|
from os import path
|
||||||
|
|
@ -15,43 +14,47 @@ from os import path
|
||||||
here = path.abspath(path.dirname(__file__))
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
|
||||||
# Get the long description from the README file
|
# Get the long description from the README file
|
||||||
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
|
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="adafruit-circuitpython-charlcd",
|
name='adafruit-circuitpython-charlcd',
|
||||||
|
|
||||||
use_scm_version=True,
|
use_scm_version=True,
|
||||||
setup_requires=["setuptools_scm"],
|
setup_requires=['setuptools_scm'],
|
||||||
description="CircuitPython library for standard character LCDs.",
|
|
||||||
|
description='CircuitPython library for standard character LCDs.',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/x-rst",
|
long_description_content_type='text/x-rst',
|
||||||
|
|
||||||
# The project's main homepage.
|
# The project's main homepage.
|
||||||
url="https://github.com/adafruit/Adafruit_CircuitPython_CharLCD",
|
url='https://github.com/adafruit/Adafruit_CircuitPython_CharLCD',
|
||||||
|
|
||||||
# Author details
|
# Author details
|
||||||
author="Adafruit Industries",
|
author='Adafruit Industries',
|
||||||
author_email="circuitpython@adafruit.com",
|
author_email='circuitpython@adafruit.com',
|
||||||
install_requires=[
|
|
||||||
"Adafruit-Blinka",
|
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'],
|
||||||
"adafruit-circuitpython-74hc595",
|
|
||||||
"adafruit-circuitpython-busdevice",
|
|
||||||
"adafruit-circuitpython-mcp230xx",
|
|
||||||
],
|
|
||||||
# Choose your license
|
# Choose your license
|
||||||
license="MIT",
|
license='MIT',
|
||||||
|
|
||||||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 3 - Alpha",
|
'Development Status :: 3 - Alpha',
|
||||||
"Intended Audience :: Developers",
|
'Intended Audience :: Developers',
|
||||||
"Topic :: Software Development :: Libraries",
|
'Topic :: Software Development :: Libraries',
|
||||||
"Topic :: System :: Hardware",
|
'Topic :: System :: Hardware',
|
||||||
"License :: OSI Approved :: MIT License",
|
'License :: OSI Approved :: MIT License',
|
||||||
"Programming Language :: Python :: 3",
|
'Programming Language :: Python :: 3',
|
||||||
"Programming Language :: Python :: 3.4",
|
'Programming Language :: Python :: 3.4',
|
||||||
"Programming Language :: Python :: 3.5",
|
'Programming Language :: Python :: 3.5',
|
||||||
],
|
],
|
||||||
|
|
||||||
# What does your project relate to?
|
# What does your project relate to?
|
||||||
keywords="adafruit character lcd rgb 16x2 20x4 hardware micropython circuitpython",
|
keywords='adafruit character lcd rgb 16x2 20x4 hardware micropython circuitpython',
|
||||||
|
|
||||||
# You can just specify the packages manually here if your project is
|
# You can just specify the packages manually here if your project is
|
||||||
# simple. Or you can use find_packages().
|
# simple. Or you can use find_packages().
|
||||||
packages=["adafruit_character_lcd"],
|
packages=['adafruit_character_lcd'],
|
||||||
)
|
)
|
||||||
Loading…
Reference in a new issue