Compare commits

..

No commits in common. "master" and "refactor" have entirely different histories.

37 changed files with 870 additions and 2737 deletions

View file

@ -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

View file

@ -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/*

11
.gitignore vendored
View file

@ -1,11 +0,0 @@
*.mpy
.idea
__pycache__
_build
*.pyc
.env
bundles
*.DS_Store
.eggs
dist
**/*.egg-info

433
.pylintrc
View file

@ -1,433 +0,0 @@
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Use multiple processes to speed up Pylint.
# jobs=1
jobs=2
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
# Pickle collected data for later comparisons.
persistent=yes
# Specify a configuration file.
#rcfile=
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
confidence=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --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=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
# 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
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=
[REPORTS]
# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details
#msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio).You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=text
# Tells whether to display a full report or only the messages
reports=no
# Activate the evaluation score.
score=yes
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
[LOGGING]
# Logging modules to check that the string format arguments are in logging
# function parameter format
logging-modules=logging
[SPELLING]
# Spelling dictionary name. Available dictionaries: none. To make it working
# install python-enchant package.
spelling-dict=
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to indicated private dictionary in
# --spelling-private-dict-file option instead of raising a message.
spelling-store-unknown-words=no
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
# notes=FIXME,XXX,TODO
notes=FIXME,XXX
[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=board
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes
# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1
# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1
[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=
# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,_cb
# A regular expression matching the name of dummy variables (i.e. expectedly
# not used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,future.builtins
[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
# expected-line-ending-format=
expected-line-ending-format=LF
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=100
# Maximum number of lines in a module
max-module-lines=1000
# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,dict-separator
# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
[SIMILARITIES]
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
# Ignore imports when computing similarities.
ignore-imports=no
# Minimum lines number of a similarity.
min-similarity-lines=4
[BASIC]
# Naming hint for argument names
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct argument names
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Naming hint for attribute names
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct attribute names
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata
# Naming hint for class attribute names
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
# Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
# Naming hint for class names
# class-name-hint=[A-Z_][a-zA-Z0-9]+$
class-name-hint=[A-Z_][a-zA-Z0-9_]+$
# Regular expression matching correct class names
# class-rgx=[A-Z_][a-zA-Z0-9]+$
class-rgx=[A-Z_][a-zA-Z0-9_]+$
# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Naming hint for function names
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct function names
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-names=i,j,k,ex,Run,_
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
# Include a hint for the correct naming format with invalid-name
include-naming-hint=no
# Naming hint for inline iteration names
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
# Naming hint for method names
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct method names
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Naming hint for module names
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
property-classes=abc.abstractproperty
# Naming hint for variable names
variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct variable names
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
[IMPORTS]
# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
# Deprecated modules which should not be used, separated by a comma
deprecated-modules=optparse,tkinter.tix
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled)
ext-import-graph=
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
[CLASSES]
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,__new__,setUp
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,_fields,_replace,_source,_make
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=mcs
[DESIGN]
# Maximum number of arguments for function / method
max-args=5
# Maximum number of attributes for a class (see R0902).
# max-attributes=7
max-attributes=11
# Maximum number of boolean expressions in a if statement
max-bool-expr=5
# Maximum number of branch for function / method body
max-branches=12
# Maximum number of locals for function / method body
max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body
max-returns=6
# Maximum number of statements in function / method body
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=1
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception

59
.travis.yml Normal file
View file

@ -0,0 +1,59 @@
# Travis CI configuration for automated .mpy file generation.
# Version: 2.0 (support for both .mpy and packages)
# Author: Tony DiCola
# License: Public Domain
# This configuration will work with Travis CI (travis-ci.org) to automacially
# build .mpy files and packages for MicroPython when a new tagged release is
# created. This file is relatively generic and can be shared across multiple
# repositories by following these steps:
# 1. Copy this file into a .travis.yml file in the root of the repository.
# 2. Change the deploy > file section below to list each of the .mpy files or
# package .zip files that should be generated.
# For each .mpy file listed the config will automatically look for .py files
# with the same name as the source for generating the .mpy files. Note that
# the .mpy extension should be lower case!
# For each .zip file listed the config will assume a folder with the same
# name exists (minus the .zip extension) and will recursively walk the folder
# to generate .mpy versions of all .py files EXCEPT __init__.py (not supported
# right now because of a bug). Then a zip of the directory will be generated
# with just the .mpy and __init__.py files.
# 3. Commit the .travis.yml file and push it to GitHub.
# 4. Go to travis-ci.org and find the repository (it needs to be setup to access
# your github account, and your github account needs access to write to the
# repo). Flip the 'ON' switch on for Travis and the repo, see the Travis
# docs for more details: https://docs.travis-ci.com/user/getting-started/
# 5. Get a GitHub 'personal access token' which has at least 'public_repo' or
# 'repo' scope: https://help.github.com/articles/creating-an-access-token-for-command-line-use/
# Keep this token safe and secure! Anyone with the token will be able to
# access and write to your GitHub repositories. Travis will use the token
# to attach the .mpy files to the release.
# 6. In the Travis CI settings for the repository that was enabled find the
# environment variable editing page: https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
# Add an environment variable named GITHUB_TOKEN and set it to the value
# of the GitHub personal access token above. Keep 'Display value in build
# log' flipped off.
# 7. That's it! Tag a release and Travis should go to work to add .mpy files
# to the release. It takes about a 2-3 minutes for a worker to spin up,
# build mpy-cross, and add the binaries to the release.
language: generic
sudo: true
deploy:
provider: releases
api_key: $GITHUB_TOKEN
file:
- adafruit_character_lcd.zip
skip_cleanup: true
on:
tags: true
before_install:
- wget https://raw.githubusercontent.com/adafruit/MicroPython_TravisCI_Deploy/master/install_dependencies.sh
- chmod +x install_dependencies.sh
- source install_dependencies.sh
before_deploy:
- wget https://raw.githubusercontent.com/adafruit/MicroPython_TravisCI_Deploy/master/build_release.sh
- chmod +x build_release.sh
- ./build_release.sh

View file

@ -1,129 +1,74 @@
# Adafruit Community Code of Conduct
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and leaders pledge to making participation in our project and
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level or type of
experience, education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
We are committed to providing a friendly, safe and welcoming environment for
all.
Examples of behavior that contributes to creating a positive environment
include:
* Be kind and courteous to others
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Collaborating with other community members
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and sexual attention or advances
* The use of inappropriate images, including in a community member's avatar
* The use of inappropriate language, including in a community member's nickname
* Any spamming, flaming, baiting or other attention-stealing behavior
* Excessive or unwelcome helping; answering outside the scope of the question
asked
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* 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
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate
The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you dont just aim to be
"technically unimpeachable", but rather try to be your best self.
We value many things beyond technical expertise, including collaboration and
supporting others within our community. Providing a positive experience for
other community members can have a much more significant impact than simply
providing the correct answer.
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project leaders are responsible for clarifying the standards of acceptable
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project leaders have the right and responsibility to remove, edit, or
reject messages, comments, commits, code, issues, and other contributions
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any community member for other behaviors that they deem
inappropriate, threatening, offensive, or harmful.
## Moderation
Instances of behaviors that violate the Adafruit Community Code of Conduct
may be reported by any member of the community. Community members are
encouraged to report these situations, including situations they witness
involving other community members.
You may report in the following ways:
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
to all Community Moderators by tagging @community moderators. You may
also send an open message from any channel, or a direct message to
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
Email and direct message reports will be kept confidential.
In situations on Discord where the issue is particularly egregious, possibly
illegal, requires immediate action, or violates the Discord terms of service,
you should also report the message directly to Discord.
These are the steps for upholding our communitys standards of conduct.
1. Any member of the community may report any situation that violates the
Adafruit Community Code of Conduct. All reports will be reviewed and
investigated.
2. If the behavior is an egregious violation, the community member who
committed the violation may be banned immediately, without warning.
3. Otherwise, moderators will first respond to such behavior with a warning.
4. Moderators follow a soft "three strikes" policy - the community member may
be given another chance, if they are receptive to the warning and change their
behavior.
5. If the community member is unreceptive or unreasonable when warned by a
moderator, or the warning goes unheeded, they may be banned for a first or
second offense. Repeated offenses will result in the community member being
banned.
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct and the enforcement policies listed above apply to all
Adafruit Community venues. This includes but is not limited to any community
spaces (both public and private), the entire Adafruit Discord server, and
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
interaction at a conference.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. As a community
member, you are representing our community, and are expected to behave
accordingly.
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at support@adafruit.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
For other projects adopting the Adafruit Community Code of
Conduct, please contact the maintainers of those projects for enforcement.
If you wish to use this code of conduct for your own project, consider
explicitly mentioning your moderation policy or making a copy with your
own moderation policy so as to avoid confusion.
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

61
README.md Normal file
View file

@ -0,0 +1,61 @@
Introduction
============
This repo is compatible with standard Character LCDs.
Compatible with CircuitPython Versions: 1.0.0
Dependencies
=============
This driver depends on:
* [Adafruit CircuitPython](https://github.com/adafruit/circuitpython "cirpyth repo")
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
[the Adafruit library and driver bundle.](https://github.com/adafruit/Adafruit_CircuitPython_Bundle)
Usage Example
=============
The ``LCD`` class interfaces a predefined Character LCD display with CircuitPython.
import adafruit_character_lcd as LCD
You must define the data pins (``RS``, ``EN``, ``D4``, ``D5``, ``D6``, ``D7``) in your code before using the ``LCD`` class.
If you want to have on/off ``backlight`` functionality, you can also define your backlight as ``lcd_backlight``. Otherwise, the backlight will always remain on. An example of this is below
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)
You must also define the size of the CharLCD by specifying its ``lcd_columns`` and ``lcd_rows``:
lcd_columns = 16
lcd_rows = 2
After you have set up your LCD, we can make the device by calling it
lcd = LCD.cirpyth_char_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:
lcd.message('hello\ncircuitpython')
Custom character example with create_char() is provided within /examples/
Contributing
============
Contributions are welcome! Please read our [Code of Conduct](https://github.com/adafruit/Adafruit_CircuitPython_CircuitPython_CharLCD/blob/master/CODE_OF_CONDUCT.md)
before contributing to help this project stay welcoming.

View file

@ -1,123 +0,0 @@
Introduction
============
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-charlcd/badge/?version=latest
:target: https://circuitpython.readthedocs.io/projects/charlcd/en/latest/
:alt: Documentation Status
.. image :: https://img.shields.io/discord/327254708534116352.svg
:target: https://adafru.it/discord
:alt: Discord
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/workflows/Build%20CI/badge.svg
:target: https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/actions/
:alt: Build Status
This library is compatible with standard Character LCDs such as:
* `Adafruit Standard LCD 16x2 <https://www.adafruit.com/product/181>`_
* `Adafruit RGB backlight negative LCD 16x2 <https://www.adafruit.com/product/399>`_
* `Adafruit RGB backlight negative LCD 20x4 <https://www.adafruit.com/product/498>`_
Installing from PyPI
--------------------
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
=============
This driver depends on:
* `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:
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
Usage Example
=============
The ``Character_LCD`` class interfaces a predefined Character LCD display with CircuitPython.
.. code-block:: python
import board
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.
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. The following is an example setup.
.. code-block:: python
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)
You must also define the size of the CharLCD by specifying its ``lcd_columns`` and ``lcd_rows``:
.. code-block:: python
lcd_columns = 16
lcd_rows = 2
After you have set up your LCD, we can make the device by calling it
.. code-block:: python
lcd = character_lcd.Character_LCD_Mono(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
To verify that your pins are correct, print a hello message to the CharLCD:
.. code-block:: python
lcd.message = "Hello\nCircuitPython"
Custom character example with ``create_char()`` is provided within /examples/
Contributing
============
Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/CODE_OF_CONDUCT.md>`_ before contributing to help this project stay welcoming.
Documentation
=============
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>`_.

View file

@ -0,0 +1,2 @@
from adafruit_character_lcd.character_lcd import Character_LCD
from adafruit_character_lcd.character_lcd_RGB import Character_LCD_RGB

851
adafruit_character_lcd/character_lcd.py Executable file → Normal file
View file

@ -1,7 +1,6 @@
# The MIT License (MIT)
#
# 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
# of this software and associated documentation files (the "Software"), to deal
@ -21,711 +20,251 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
`adafruit_character_lcd.character_lcd`
`adafruit_CircuitPython_CharLCD`
====================================================
Module for interfacing with monochromatic character LCDs
* Author(s): Kattni Rembor, Brent Rubell, Asher Lieber,
Tony DiCola (original python charLCD library)
Implementation Notes
--------------------
**Hardware:**
"* `Adafruit Character LCDs <http://www.adafruit.com/category/63_96>`_"
**Software and Dependencies:**
* Adafruit CircuitPython firmware:
https://github.com/adafruit/circuitpython/releases
* Adafruit's Bus Device library (when using I2C/SPI):
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
TODO(description)
* Author(s):
-Brent Rubell
-Asher Lieber
-Tony DiCola for the original python charLCD library
"""
"""
`adafruit_character_lcd` - character lcd module
=================================================
module for interfacing with character lcds
"""
import time
import math
import digitalio
from micropython import const
from board import *
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CharLCD.git"
# 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)
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_ENTRYLEFT = const(0x02)
_LCD_ENTRYSHIFTDECREMENT = const(0x00)
LCD_ENTRYRIGHT = const(0x00)
LCD_ENTRYLEFT = const(0x02)
LCD_ENTRYSHIFTINCREMENT = const(0x01)
LCD_ENTRYSHIFTDECREMENT = const(0x00)
# Control flags
_LCD_DISPLAYON = const(0x04)
_LCD_CURSORON = const(0x02)
_LCD_CURSOROFF = const(0x00)
_LCD_BLINKON = const(0x01)
_LCD_BLINKOFF = const(0x00)
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_MOVERIGHT = const(0x04)
_LCD_MOVELEFT = const(0x00)
LCD_DISPLAYMOVE = const(0x08)
LCD_CURSORMOVE = const(0x00)
LCD_MOVERIGHT = const(0x04)
LCD_MOVELEFT = const(0x00)
# Function set flags
_LCD_4BITMODE = const(0x00)
_LCD_2LINE = const(0x08)
_LCD_1LINE = const(0x00)
_LCD_5X8DOTS = const(0x00)
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)
LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)
# pylint: enable-msg=bad-whitespace
class Character_LCD(object):
""" Interfaces with a character LCD
:param rs: The reset data line
:param en: The enable data line
:param d4, d5, d6, d7: The data lines 4 thru 7
:param cols: The columns on the charLCD
:param lines: The lines on the charLCD
:param backlight: The backlight pin, usually the last pin. Check with your datasheet
:param enable_pwm: The PWM CONTROL, TODO
:param initial_backlight: THE initial backlight status (on/off)
"""
def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
backlight = None,
enable_pwm = False,
initial_backlight = 1.0):
def _set_bit(byte_value, position, val):
# Given the specified byte_value set the bit at position to the provided
# boolean value val and return the modified byte.
ret = None
if val:
ret = byte_value | (1 << position)
else:
ret = byte_value & ~(1 << position)
return ret
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:
"""Base class for 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 columns: The columns on the charLCD
:param lines: The lines on the charLCD
"""
LEFT_TO_RIGHT = const(0)
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
# save pin numbers
self.reset = rs
self.enable = en
self.dl4 = d4
self.dl5 = d5
self.dl6 = d6
self.dl7 = d7
# set all pins as outputs
for pin in (rs, en, d4, d5, d6, d7):
pin.direction = digitalio.Direction.OUTPUT
# Initialise the display
self._write8(0x33)
self._write8(0x32)
# Initialise display control
self.displaycontrol = _LCD_DISPLAYON | _LCD_CURSOROFF | _LCD_BLINKOFF
# Initialise display function
self.displayfunction = _LCD_4BITMODE | _LCD_1LINE | _LCD_2LINE | _LCD_5X8DOTS
# Initialise display mode
self.displaymode = _LCD_ENTRYLEFT | _LCD_ENTRYSHIFTDECREMENT
# Write to displaycontrol
self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol)
# Write to displayfunction
self._write8(_LCD_FUNCTIONSET | self.displayfunction)
# Set entry mode
self._write8(_LCD_ENTRYMODESET | self.displaymode)
self.clear()
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
self.cols = cols
self.lines = lines
# save pin numbers
self.rs = rs
self.en = en
self.d4 = d4
self.d5 = d5
self.d6 = d6
self.d7 = d7
# backlight pin
self.backlight = backlight
# save backlight state
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()
def home(self):
"""Moves the cursor "home" to position (1, 1)."""
self._write8(_LCD_RETURNHOME)
time.sleep(0.003)
"""Moves the cursor back home pos(1,1)"""
self._write8(LCD_RETURNHOME)
time.sleep(0.003)
def clear(self):
"""Clears everything displayed on the LCD.
"""Clears the LCD"""
self._write8(LCD_CLEARDISPLAY)
time.sleep(0.003)
The following example displays, "Hello, world!", then clears the LCD.
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)
.. 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)
@property
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
@column_align.setter
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:
self.displaycontrol |= _LCD_CURSORON
else:
self.displaycontrol &= ~_LCD_CURSORON
self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol)
def cursor_position(self, column, row):
"""Move the cursor to position ``column``, ``row`` for the next
message only. Displaying a message resets the cursor position to (0, 0).
:param column: column location
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
# Clamp to last column of display
if column >= self.columns:
column = self.columns - 1
# Set location
self._write8(_LCD_SETDDRAMADDR | (column + _LCD_ROW_OFFSETS[row]))
# Update self.row and self.column to match setter
self.row = row
self.column = column
# 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]))
@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):
if blink:
self.displaycontrol |= _LCD_BLINKON
else:
self.displaycontrol &= ~_LCD_BLINKON
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
"""Blinks the cursor if blink = true."""
if blink == True:
self.displaycontrol |= LCD_BLINKON
else:
self.displaycontrol &= ~LCD_BLINKON
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)
def move_left(self):
"""Moves displayed text left one column.
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)
"""Moves display left one position"""
self._write8(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT)
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
import board
import busio
import adafruit_character_lcd.character_lcd_i2c as character_lcd
def enable_display(self, enable):
"""Enable or disable the display. Set enable to True to enable."""
if enable:
self.displaycontrol |= LCD_DISPLAYON
else:
self.displaycontrol &= ~LCD_DISPLAYON
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)
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)
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.
"""
self._write8(_LCD_CURSORSHIFT | _LCD_DISPLAYMOVE | _LCD_MOVERIGHT)
# one ms delay to prevent writing too quickly.
time.sleep(0.001)
# set character/data bit. (charmode = False)
self.rs.value = char_mode
# WRITE upper 4 bits
self.d4.value = ((value >> 4) & 1) > 0
self.d5.value = ((value >> 5) & 1) > 0
self.d6.value = ((value >> 6) & 1) > 0
self.d7.value = ((value >> 7) & 1) > 0
# send command
self._pulse_enable()
# WRITE lower 4 bits
self.d4.value = (value & 1) > 0
self.d5.value = ((value >> 1) & 1) > 0
self.d6.value = ((value >> 2) & 1) > 0
self.d7.value = ((value >> 3) & 1) > 0
self._pulse_enable()
@property
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.
def _pulse_enable(self):
""" Pulses (lo->hi->lo) to send commands. """
self.en.value = False
# 1microsec pause
time.sleep(0.0000001)
self.en.value = True
time.sleep(0.0000001)
self.en.value = False
time.sleep(0.0000001)
The following example displays "Hello, world!" from right to left.
def set_backlight(self, lighton):
""" Set lighton to turn the charLCD backlight on. """
if lighton:
self.backlight.value = 0
else:
self.backlight.value = 1
.. 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 message(self, text):
"""Write text to display, can include \n for newline"""
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)
def create_char(self, location, pattern):
"""
Fill one of the first 8 CGRAM locations with custom characters.
"""Fill one of the first 8 CGRAM locations with custom characters.
The location parameter should be between 0 and 7 and pattern should
provide an array of 8 bytes containing the pattern. E.g. you can easily
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, for example, ``lcd.message = "\x01"``
:param location: integer in range(8) to store the created character
:param ~bytes pattern: len(8) describes created character
To show your custom character use eg. lcd.message('\x01')
"""
# only position 0..7 are allowed
location &= 0x7
self._write8(_LCD_SETCGRAMADDR | (location << 3))
self._write8(LCD_SETCGRAMADDR | (location << 3))
for i in range(8):
self._write8(pattern[i], char_mode=True)
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)
# pylint: enable-msg=too-many-instance-attributes
# 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
@backlight.setter
def backlight(self, enable):
self._enable = enable
if enable:
self.backlight_pin.value = not self.backlight_inverted
else:
self.backlight_pin.value = self.backlight_inverted
class Character_LCD_RGB(Character_LCD):
"""Interfaces with RGB character LCDs.
:param ~digitalio.DigitalInOut rs: The reset data line
:param ~digitalio.DigitalInOut en: The enable data line
:param ~digitalio.DigitalInOut db4: The data line 4
:param ~digitalio.DigitalInOut db5: The data line 5
:param ~digitalio.DigitalInOut db6: The data line 6
:param ~digitalio.DigitalInOut db7: The data line 7
:param columns: The columns on the charLCD
:param lines: The lines on the charLCD
:param ~pulseio.PWMOut, ~digitalio.DigitalInOut red: Red RGB Anode
:param ~pulseio.PWMOut, ~digitalio.DigitalInOut green: Green RGB Anode
:param ~pulseio.PWMOut, ~digitalio.DigitalInOut blue: Blue RGB Anode
:param ~digitalio.DigitalInOut read_write: The rw pin. Determines whether to read to or
write from the display. Not necessary if only writing to the display. Used on shield.
"""
# pylint: disable-msg=too-many-arguments
def __init__(
self,
rs,
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]``.
``0`` is no color, or "off". ``100`` is maximum color. For example, the brightest red would
be ``[100, 0, 0]``, and a half-bright purple would be, ``[50, 0, 50]``.
If PWM is unavailable, ``0`` is off, and non-zero is on. For example, ``[1, 0, 0]`` would
be red.
The following example turns the LCD red and displays, "Hello, world!".
.. code-block:: python
import time
import board
import busio
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
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
@color.setter
def color(self, color):
self._color = color
for number, pin in enumerate(self.rgb_led):
if hasattr(pin, "duty_cycle"):
# Assume a pulseio.PWMOut or compatible interface and set duty cycle:
pin.duty_cycle = int(_map(color[number], 0, 100, 65535, 0))
elif hasattr(pin, "value"):
# If we don't have a PWM interface, all we can do is turn each color
# on / off. Assume a DigitalInOut (or compatible interface) and write
# 0 (on) to pin for any value greater than 0, or 1 (off) for 0:
pin.value = not color[number] > 1

View file

@ -0,0 +1,260 @@
# 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_CircuitPython_CharLCD`
====================================================
TODO(description)
* Author(s):
-Brent Rubell
-Asher Lieber
-Tony DiCola for the original python charLCD library
"""
"""
`adafruit_character_lcd_RGB` - RGB character lcd module
=================================================
module for interfacing with RGB character lcds
"""
import time
import math
import digitalio
import pulseio
from board import *
from micropython import const
# 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)
class Character_LCD_RGB(object):
""" Interfaces with a character LCD
:param ~microcontroller.Pin rs: The reset data line
:param ~microcontroller.Pin en: The enable data line
:param ~microcontroller.Pin d4, d5, d6, d7: The data lines 4 thru 7
:param ~microcontroller.Pin cols: The columns on the charLCD
:param ~microcontroller.Pin lines: The lines on the charLCD
:param ~microcontroller.Pin red: Red RGB Anode
:param ~microcontroller.Pin green: Green RGB Anode
:param ~microcontroller.Pin blue: Blue RGB Anode
:param ~microcontroller.Pin backlight: The backlight pin, usually the last pin. Consult the datasheet.
:param enable_pwm: PulseIO Control
:param initial_backlight: THE initial backlight status (on/off)
"""
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.rs = rs
self.en = en
self.d4 = d4
self.d5 = d5
self.d6 = d6
self.d7 = d7
# define color params
self.red = red
self.green = green
self.blue = blue
# define rgb led
self.RGBLED = [red, green, blue]
# define backlight pin
self.backlight = backlight
# save backlight state
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()
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. Set enable to True to enable."""
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.rs.value = char_mode
# WRITE upper 4 bits
self.d4.value = ((value >> 4) & 1) > 0
self.d5.value = ((value >> 5) & 1) > 0
self.d6.value = ((value >> 6) & 1) > 0
self.d7.value = ((value >> 7) & 1) > 0
# send command
self._pulse_enable()
# WRITE lower 4 bits
self.d4.value = (value & 1) > 0
self.d5.value = ((value >> 1) & 1) > 0
self.d6.value = ((value >> 2) & 1) > 0
self.d7.value = ((value >> 3) & 1) > 0
self._pulse_enable()
def _pulse_enable(self):
""" Pulses (lo->hi->lo) to send commands. """
self.en.value = False
# 1microsec pause
time.sleep(0.0000001)
self.en.value = True
time.sleep(0.0000001)
self.en.value = False
time.sleep(0.0000001)
def set_backlight(self, lighton):
""" Set lighton to turn the charLCD backlight on. """
if lighton:
self.backlight.value = 0
else:
self.backlight.value = 1
def _map(self, x, 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 = (x - in_min) * (outrange / inrange) + out_min
if (out_max > out_min):
return max(min(ret, out_max), out_min)
else:
return max(min(ret, out_min), out_max)
def setColor(self, color):
""" Method to set the duty cycle of the RGB LED """
self.RGBLED[0].duty_cycle = int(self._map(color[0], 0, 100, 65535, 0))
self.RGBLED[1].duty_cycle = int(self._map(color[1], 0, 100, 65535, 0))
self.RGBLED[2].duty_cycle = int(self._map(color[2], 0, 100, 65535, 0))
def message(self, text):
"""Write text to display, can include \n for newline"""
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)

View file

@ -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,
)

View file

@ -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

View file

@ -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,
)

5
api.rst Normal file
View file

@ -0,0 +1,5 @@
.. If you created a package, create one automodule per module in the package.
.. automodule:: adafruit_circuitpython_charlcd
:members:

View file

@ -2,8 +2,7 @@
import os
import sys
sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
@ -11,46 +10,34 @@ sys.path.insert(0, os.path.abspath(".."))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
]
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["micropython", "digitalio", "addfruit_bus_device"]
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),
}
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
# 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.
master_doc = "index"
master_doc = 'README'
# General information about the project.
project = "Adafruit CIRCUITPYTHON_CHARLCD Library"
copyright = "2017 Brent Rubell"
author = "Brent Rubell"
project = u'Adafruit CIRCUITPYTHON_CHARLCD Library'
copyright = u'2017 Brent Rubell'
author = u'Brent Rubell'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "1.0"
version = u'1.0'
# 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
# for a list of supported languages.
@ -62,7 +49,7 @@ language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# 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']
# The reST default role (used for this markup: `text`) to use for all
# documents.
@ -74,76 +61,64 @@ default_role = "any"
add_function_parentheses = True
# 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.
todo_include_todos = False
# If this is True, todo emits a warning for each TODO entries. The default is False.
todo_emit_warnings = True
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# 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
try:
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
except:
html_theme = "default"
html_theme_path = ["."]
html_theme = 'default'
html_theme_path = ['.']
else:
html_theme_path = ["."]
html_theme_path = ['.']
# 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,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# 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
# pixels large.
#
html_favicon = "_static/favicon.ico"
html_static_path = ['_static']
# Output file base name for HTML help builder.
htmlhelp_basename = "AdafruitCIRCUITPYTHON_CHARLCDLibrarydoc"
htmlhelp_basename = 'AdafruitCIRCUITPYTHON_CHARLCDLibrarydoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(
master_doc,
"AdafruitCIRCUITPYTHON_CHARLCDLibrary.tex",
"Adafruit CIRCUITPYTHON_CHARLCD Library Documentation",
author,
"manual",
),
(master_doc, 'AdafruitCIRCUITPYTHON_CHARLCDLibrary.tex', u'Adafruit CIRCUITPYTHON_CHARLCD Library Documentation',
author, 'manual'),
]
# -- Options for manual page output ---------------------------------------
@ -151,13 +126,8 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(
master_doc,
"adafruitCIRCUITPYTHON_CHARLCDlibrary",
"Adafruit CIRCUITPYTHON_CHARLCD Library Documentation",
[author],
1,
)
(master_doc, 'adafruitCIRCUITPYTHON_CHARLCDlibrary', u'Adafruit CIRCUITPYTHON_CHARLCD Library Documentation',
[author], 1)
]
# -- Options for Texinfo output -------------------------------------------
@ -166,13 +136,7 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"AdafruitCIRCUITPYTHON_CHARLCDLibrary",
"Adafruit CIRCUITPYTHON_CHARLCD Library Documentation",
author,
"AdafruitCIRCUITPYTHON_CHARLCDLibrary",
"One line description of project.",
"Miscellaneous",
),
(master_doc, 'AdafruitCIRCUITPYTHON_CHARLCDLibrary', u'Adafruit CIRCUITPYTHON_CHARLCD Library Documentation',
author, 'AdafruitCIRCUITPYTHON_CHARLCDLibrary', 'One line description of project.',
'Miscellaneous'),
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -1,14 +0,0 @@
.. If you created a package, create one automodule per module in the package.
.. automodule:: adafruit_character_lcd.character_lcd
: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:

View file

@ -1,24 +0,0 @@
Simple test
------------
Ensure your device works with this simple test.
.. literalinclude:: ../examples/charlcd_mono_simpletest.py
:caption: examples/charlcd_mono_simpletest.py
:linenos:
.. literalinclude:: ../examples/charlcd_rgb_simpletest.py
:caption: examples/charlcd_rgb_simpletest.py
:linenos:
.. literalinclude:: ../examples/charlcd_i2c_mono_simpletest.py
:caption: examples/charlcd_i2c_mono_simpletest.py
:linenos:
.. literalinclude:: ../examples/charlcd_spi_mono_simpletest.py
:caption: examples/charlcd_spi_mono_simpletest.py
:linenos:
.. literalinclude:: ../examples/charlcd_keypad_simpletest.py
:caption: examples/charlcd_keypad_simpletest.py
:linenos:

View file

@ -1,47 +0,0 @@
.. include:: ../README.rst
Table of Contents
=================
.. toctree::
:maxdepth: 4
:hidden:
self
.. toctree::
:caption: Examples
examples
.. toctree::
:caption: API Reference
:maxdepth: 3
api
.. toctree::
:caption: Tutorials
.. toctree::
:caption: Related Products
Adafruit Character LCDs <http://www.adafruit.com/category/63_96>
.. toctree::
:caption: Other Links
Download <https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/releases/latest>
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
Discord Chat <https://adafru.it/discord>
Adafruit Learning System <https://learn.adafruit.com>
Adafruit Blog <https://blog.adafruit.com>
Adafruit Store <https://www.adafruit.com>
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View file

@ -1,92 +0,0 @@
"""Use custom characters to display Nyan cat"""
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
# 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
)
head = [31, 17, 27, 17, 17, 21, 17, 31]
top_body = [31, 0, 31, 0, 18, 8, 2, 8]
top_left_corner_body = [31, 16, 16, 17, 22, 20, 20, 20]
top_right_corner_body = [31, 1, 1, 17, 13, 5, 5, 5]
# these three chars will be the above three reversed with a few minor changes to
# fit feet into the bottom
bot_body = []
bot_left_corner_body = []
bot_right_corner_body = []
tail_neutral = [0, 0, 0, 0, 31, 31, 0, 0]
tail_up = [0, 8, 12, 6, 3, 1, 0, 0]
for i in range(7, -1, -1):
bot_body.append(top_body[i])
bot_left_corner_body.append(top_left_corner_body[i])
bot_right_corner_body.append(top_right_corner_body[i])
# adding feet and making space for them
bot_body[6] = 31
bot_body[5] = 0
bot_body[4] = 31
bot_body[7] = 24
bot_left_corner_body[7] = 0
bot_left_corner_body[6] = 31
bot_left_corner_body[7] = 28
bot_right_corner_body[7] = 0
bot_right_corner_body[6] = 31
# bottom body with feet forward
bot_body2 = bot_body[:-1] + [3]
rainbow = [0, 0, 6, 25, 11, 29, 27, 12]
rainbow2 = [0, 0, 6, 31, 13, 5, 23, 12]
lcd.create_char(0, top_body)
lcd.create_char(1, top_left_corner_body)
lcd.create_char(2, rainbow)
lcd.create_char(3, bot_left_corner_body)
lcd.create_char(4, bot_body)
lcd.create_char(5, bot_right_corner_body)
lcd.create_char(6, head)
lcd.create_char(7, tail_neutral)
lcd.clear()
lcd.move_right()
lcd.message = (
"\x02\x02\x02\x02\x01\x00\x00\x00\x06\n\x02\x02\x02\x07\x03\x04\x04\x04\x05"
)
lcd.backlight = True
while True:
lcd.create_char(4, bot_body2)
lcd.create_char(7, tail_up)
lcd.create_char(2, rainbow2)
lcd.move_right()
time.sleep(0.4)
lcd.create_char(4, bot_body)
lcd.create_char(7, tail_neutral)
lcd.create_char(2, rainbow)
lcd.move_left()
time.sleep(0.4)

View file

@ -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"

View file

@ -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)

View file

@ -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()

View file

@ -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()

View file

@ -1,65 +0,0 @@
"""Simple test for monochromatic character LCD"""
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
# 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
)
# 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(3)
# Turn backlight off
lcd.backlight = False
time.sleep(2)

View file

@ -1,90 +0,0 @@
"""Simple test for RGB character LCD"""
import time
import board
import digitalio
import pulseio
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)
red = pulseio.PWMOut(board.D3)
green = pulseio.PWMOut(board.D5)
blue = pulseio.PWMOut(board.D6)
# 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.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()

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -0,0 +1,91 @@
import time, digitalio
import adafruit_character_lcd
from board import *
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)
head = [31,17,27,17,17,21,17,31]
top_body = [31,0,31,0,18,8,2,8]
top_left_corner_body = [31,16,16,17,22,20,20,20]
top_right_corner_body = [31,1,1,17,13,5,5,5]
# these three chars will be the above three reversed with a few minor changes to fit feet into the bottom
bot_body = []
bot_left_corner_body = []
bot_right_corner_body = []
tail_neutral = [0,0,0,0,31,31,0,0]
tail_up = [0,8,12,6,3,1,0,0]
for i in range(7, -1, -1):
bot_body.append(top_body[i])
bot_left_corner_body.append(top_left_corner_body[i])
bot_right_corner_body.append(top_right_corner_body[i])
# adding feet and making space for them
bot_body[6] = 31
bot_body[5] = 0
bot_body[4] = 31
bot_body[7] = 24
bot_left_corner_body[7] = 0
bot_left_corner_body[6] = 31
bot_left_corner_body[7] = 28
bot_right_corner_body[7] = 0
bot_right_corner_body[6] = 31
# bottom body with feet forward
bot_body2 = bot_body[:-1] + [3]
rainbow = [0,0,6,25,11,29,27,12]
rainbow2 = [0,0,6,31,13,5,23,12]
lcd.create_char(0, top_body)
lcd.create_char(1, top_left_corner_body)
lcd.create_char(2, rainbow)
lcd.create_char(3, bot_left_corner_body)
lcd.create_char(4, bot_body)
lcd.create_char(5, bot_right_corner_body)
lcd.create_char(6, head)
lcd.create_char(7, tail_neutral)
lcd.clear()
body_width = 3
lcd.move_right()
for i in range(4):
lcd.message('\x02')
lcd.message('\x01')
for i in range(body_width):
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:
lcd.create_char(4, bot_body2)
lcd.create_char(7, tail_up)
lcd.create_char(2, rainbow2)
lcd.move_right()
time.sleep(.4)
lcd.create_char(4, bot_body)
lcd.create_char(7, tail_neutral)
lcd.create_char(2, rainbow)
lcd.move_left()
time.sleep(.4)

View file

@ -0,0 +1,17 @@
import time, math, digitalio
import adafruit_character_lcd
from board import *
import analogio
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')

View file

@ -0,0 +1,59 @@
"""
'hello_CircuitPython.py'
=================================================
hello world using 16x2 character lcd
requires:
- CircuitPython_CharLCD Module
"""
import time, math, digitalio
import adafruit_character_lcd
from board import *
# Character LCD Config:
# modify this if you have a different sized charlcd
lcd_columns = 16
lcd_rows = 2
# Metro m0 Pin Config:
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)
# Init the lcd class
lcd = adafruit_character_lcd.Character_LCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
# 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)

View file

@ -0,0 +1,38 @@
import time, math, digitalio
import adafruit_character_lcd
import pulseio
from board import *
# Character LCD Config:
# modify this if you have a different sized charlcd
lcd_columns = 16
lcd_rows = 2
# Metro m0 Pin Config:
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)
red = pulseio.PWMOut(D3)
green = pulseio.PWMOut(D4)
blue = pulseio.PWMOut(D5)
# Init the lcd class
lcd = adafruit_character_lcd.Character_LCD_RGB(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, red, green, blue, lcd_backlight)
# only red
RED = [100, 0, 0]
GREEN = [0, 100, 0]
BLUE = [0, 0, 100]
while True:
lcd.message('CircuitPython\nRGB Test')
lcd.setColor(RED)
time.sleep(1)
lcd.setColor(GREEN)
time.sleep(1)
lcd.setColor(BLUE)
time.sleep(1)

View file

@ -1,3 +1,2 @@
python:
version: 3
requirements_file: requirements.txt

View file

@ -1,4 +1 @@
Adafruit-Blinka
adafruit-circuitpython-74hc595
adafruit-circuitpython-busdevice
adafruit-circuitpython-mcp230xx

View file

@ -1,57 +0,0 @@
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = f.read()
setup(
name="adafruit-circuitpython-charlcd",
use_scm_version=True,
setup_requires=["setuptools_scm"],
description="CircuitPython library for standard character LCDs.",
long_description=long_description,
long_description_content_type="text/x-rst",
# The project's main homepage.
url="https://github.com/adafruit/Adafruit_CircuitPython_CharLCD",
# Author details
author="Adafruit Industries",
author_email="circuitpython@adafruit.com",
install_requires=[
"Adafruit-Blinka",
"adafruit-circuitpython-74hc595",
"adafruit-circuitpython-busdevice",
"adafruit-circuitpython-mcp230xx",
],
# Choose your license
license="MIT",
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Hardware",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
],
# What does your project relate to?
keywords="adafruit character lcd rgb 16x2 20x4 hardware micropython circuitpython",
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=["adafruit_character_lcd"],
)