From 2eace650ca48387fb7a9f2ef65d016bd8a3855f4 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 7 Dec 2017 11:46:08 -0800 Subject: [PATCH 1/6] Update to new build process and turn on lint. --- .gitignore | 10 + .pylintrc | 433 +++++++++++++++++++++++++++++++++++ .travis.yml | 69 ++---- CODE_OF_CONDUCT.md | 74 ++++++ README.rst | 72 +++++- adafruit_ht16k33/ht16k33.py | 33 ++- adafruit_ht16k33/index.rst | 21 ++ adafruit_ht16k33/matrix.py | 34 +++ adafruit_ht16k33/segments.py | 83 +++++-- conf.py | 146 ++++++++++++ docs/Makefile | 177 -------------- docs/conf.py | 260 --------------------- docs/examples.rst | 17 -- docs/index.rst | 26 --- docs/make.bat | 242 -------------------- docs/matrix.rst | 40 ---- docs/segment.rst | 38 --- readthedocs.yml | 3 + requirements.txt | 1 + 19 files changed, 905 insertions(+), 874 deletions(-) create mode 100644 .gitignore create mode 100644 .pylintrc create mode 100644 CODE_OF_CONDUCT.md create mode 100644 adafruit_ht16k33/index.rst create mode 100644 conf.py delete mode 100644 docs/Makefile delete mode 100644 docs/conf.py delete mode 100644 docs/examples.rst delete mode 100644 docs/index.rst delete mode 100644 docs/make.bat delete mode 100644 docs/matrix.rst delete mode 100644 docs/segment.rst create mode 100644 readthedocs.yml create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a7becc0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.eggs/ +*.egg-info/ +dist +*.pyc +_build/ +*.mpy +.DS_Store +.env +build* +bundles diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..9cc6794 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,433 @@ +[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 + +# 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= + +# 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*(# )??$ + +# 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,i,j,k,n,x,y,z,ex,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=2 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/.travis.yml b/.travis.yml index 925003b..d479da8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,59 +1,30 @@ -# 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 +# This is a common .travis.yml for generating library release zip files for +# CircuitPython library releases using circuitpython-build-tools. +# See https://github.com/adafruit/circuitpython-build-tools for detailed setup +# instructions. -sudo: true +dist: trusty +sudo: false +language: python +python: + - "3.6" + +cache: + pip: true deploy: provider: releases api_key: $GITHUB_TOKEN - file: - - adafruit_ht16k33.zip + file_glob: true + file: bundles/* 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 +install: + - pip install pylint circuitpython-build-tools -before_deploy: - - wget https://raw.githubusercontent.com/adafruit/MicroPython_TravisCI_Deploy/master/build_release.sh - - chmod +x build_release.sh - - ./build_release.sh +script: + - pylint adafruit_ht16k33/*.py + - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,undefined-variable,wildcard-import examples/*.py) + - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ht16k33 --library_location . diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..1617586 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +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 of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* 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 unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* 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 in a + professional setting + +## Our Responsibilities + +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 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 contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +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 [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/README.rst b/README.rst index 5485627..70ce651 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,76 @@ -Adafruit CircuitPython Library for the HT16K33-based LED Matrices -****************************************************** +Introduction +============ + +.. image:: https://readthedocs.org/projects/adafruit-circuitpython-circuitplayground/badge/?version=latest + :target: https://circuitpython.readthedocs.io/projects/circuitplayground/en/latest/ + :alt: Documentation Status + +.. image :: https://img.shields.io/discord/327254708534116352.svg + :target: https://adafru.it/discord + :alt: Discord This is a library for using the I²C-based LED matrices with the HT16K33 chip. It supports both 16x8 and 8x8 matrices, as well as 7- and 14-segment displays. Note this library is intended for Adafruit CircuitPython's API. For a library compatible with MicroPython machine API see this library: https://github.com/adafruit/micropython-adafruit-ht16k33 + +Installation +============= +This driver depends on many other libraries! Please install it by downloading +`the Adafruit library and driver bundle `_. + +Usage Example +============= +Using it is super simple. Simply import the `cpx` variable from the module +and then use it. + +.. code-block :: python + + # Import all board pins. + from board import * + import busio + + # Import the HT16K33 LED matrix module. + from adafruit_ht16k33 import matrix + + # Create the I2C interface. + i2c = busio.I2C(SCL, SDA) + + # Create the matrix class. + # This creates a 16x8 matrix: + matrix = matrix.Matrix16x8(i2c) + # Or this creates a 8x8 matrix: + #matrix = matrix.Matrix8x8(i2c) + # Or this creates a 8x8 bicolor matrix: + #matrix = matrix.Matrix8x8x2 + # Finally you can optionally specify a custom I2C address of the HT16k33 like: + #matrix = matrix.Matrix16x8(i2c, address=0x70) + + # Clear the matrix. Always call show after changing pixels to make the display + # update visible! + matrix.fill(0) + matrix.show() + + # Set a pixel in the origin 0,0 position. + matrix.pixel(0, 0, 1) + # Set a pixel in the middle 8, 4 position. + matrix.pixel(8, 4, 1) + # Set a pixel in the opposite 15, 7 position. + matrix.pixel(15, 7, 1) + matrix.show() + +Contributing +============ + +Contributions are welcome! Please read our `Code of Conduct +`_ +before contributing to help this project stay welcoming. + +API Reference +============= + +.. toctree:: + :maxdepth: 2 + + adafruit_ht16k33/index diff --git a/adafruit_ht16k33/ht16k33.py b/adafruit_ht16k33/ht16k33.py index e7f4275..4e6077e 100644 --- a/adafruit_ht16k33/ht16k33.py +++ b/adafruit_ht16k33/ht16k33.py @@ -1,5 +1,29 @@ -from adafruit_register import i2c_struct +# The MIT License (MIT) +# +# Copyright (c) 2016 Radomir Dopieralski & Tony DiCola 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. + +""".. currentmodule:: adafruit_ht16k33""" + from adafruit_bus_device import i2c_device +from micropython import const _HT16K33_BLINK_CMD = const(0x80) @@ -9,12 +33,15 @@ class HT16K33: + """The base class for all displays. Contains common methods.""" def __init__(self, i2c, address=0x70): self.i2c_device = i2c_device.I2CDevice(i2c, address) self._temp = bytearray(1) self._buffer = bytearray(17) self.fill(0) self._write_cmd(_HT16K33_OSCILATOR_ON) + self._blink_rate = None + self._brightness = None self.blink_rate(0) self.brightness(15) @@ -24,6 +51,7 @@ def _write_cmd(self, byte): self.i2c_device.write(self._temp) def blink_rate(self, rate=None): + """Get or set the blink rate. Range 0-3.""" if rate is None: return self._blink_rate rate = rate & 0x03 @@ -32,6 +60,7 @@ def blink_rate(self, rate=None): _HT16K33_BLINK_DISPLAYON | rate << 1) def brightness(self, brightness): + """Get or set the brightness. Range 0-15.""" if brightness is None: return self._brightness brightness = brightness & 0x0F @@ -39,12 +68,14 @@ def brightness(self, brightness): self._write_cmd(_HT16K33_CMD_BRIGHTNESS | brightness) def show(self): + """Refresh the display and show the changes.""" with self.i2c_device: # Byte 0 is 0x00, address of LED data register. The remaining 16 # bytes are the display register data to set. self.i2c_device.write(self._buffer) def fill(self, color): + """Fill the whole display with the given color.""" fill = 0xff if color else 0x00 for i in range(16): self._buffer[i+1] = fill diff --git a/adafruit_ht16k33/index.rst b/adafruit_ht16k33/index.rst new file mode 100644 index 0000000..0dd755e --- /dev/null +++ b/adafruit_ht16k33/index.rst @@ -0,0 +1,21 @@ + +Variety of HT16K33 displays +=========================================== + +`ht16k33` - Base class for the displays +----------------------------------------------------- + +.. automodule:: adafruit_ht16k33.ht16k33 + :members: + +`matrix` - Matrix of dots in the displays +----------------------------------------------------- + +.. automodule:: adafruit_ht16k33.matrix + :members: + +`segments` - Segments display such as those on alarm clocks +------------------------------------------------------------ + +.. automodule:: adafruit_ht16k33.segments + :members: diff --git a/adafruit_ht16k33/matrix.py b/adafruit_ht16k33/matrix.py index de1f650..a23f419 100644 --- a/adafruit_ht16k33/matrix.py +++ b/adafruit_ht16k33/matrix.py @@ -1,8 +1,37 @@ +# The MIT License (MIT) +# +# Copyright (c) 2016 Radomir Dopieralski & Tony DiCola 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. + +"""Matrix Displays +**************** + +.. currentmodule:: adafruit_ht16k33.matrix""" + from adafruit_ht16k33.ht16k33 import HT16K33 class Matrix16x8(HT16K33): + """A double matrix or the matrix wing.""" def pixel(self, x, y, color=None): + """Get or set the color of a given pixel.""" if not 0 <= x <= 15: return if not 0 <= y <= 7: @@ -14,7 +43,9 @@ def pixel(self, x, y, color=None): class Matrix8x8(HT16K33): + """A single matrix.""" def pixel(self, x, y, color=None): + """Get or set the color of a given pixel.""" if not 0 <= x <= 7: return if not 0 <= y <= 7: @@ -24,7 +55,9 @@ def pixel(self, x, y, color=None): class Matrix8x8x2(HT16K33): + """A bi-color matrix.""" def pixel(self, x, y, color=None): + """Get or set the color of a given pixel.""" if not 0 <= x <= 7: return if not 0 <= y <= 7: @@ -36,6 +69,7 @@ def pixel(self, x, y, color=None): return super()._pixel(y, x) | super()._pixel(y + 8, x) << 1 def fill(self, color): + """Fill the whole display with the given color.""" fill1 = 0xff if color & 0x01 else 0x00 fill2 = 0xff if color & 0x02 else 0x00 for i in range(8): diff --git a/adafruit_ht16k33/segments.py b/adafruit_ht16k33/segments.py index 2dd71cb..d58f38a 100644 --- a/adafruit_ht16k33/segments.py +++ b/adafruit_ht16k33/segments.py @@ -1,5 +1,31 @@ -from adafruit_ht16k33.ht16k33 import HT16K33 +# The MIT License (MIT) +# +# Copyright (c) 2016 Radomir Dopieralski & Tony DiCola 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. + +"""Segment Displays +**************** +.. currentmodule:: adafruit_ht16k33.segments""" + +from adafruit_ht16k33.ht16k33 import HT16K33 CHARS = ( 0b00000000, 0b00000000, # @@ -121,7 +147,9 @@ class Seg14x4(HT16K33): + """Alpha-numeric, 14-segment display.""" def scroll(self, count=1): + """Scroll the display by specified number of places.""" if count >= 0: offset = 0 else: @@ -130,6 +158,7 @@ def scroll(self, count=1): self._set_buffer(i + offset, self._get_buffer(i + 2 * count)) def put(self, char, index=0): + """Put a character at the specified place.""" if not 0 <= index <= 3: return if not 32 <= ord(char) <= 127: @@ -137,72 +166,82 @@ def put(self, char, index=0): if char == '.': self._set_buffer(index * 2 + 1, self._get_buffer(index * 2 + 1) | 0b01000000) return - c = ord(char) * 2 - 64 - self._set_buffer(index * 2, CHARS[1 + c]) - self._set_buffer(index * 2 + 1, CHARS[c]) + character = ord(char) * 2 - 64 + self._set_buffer(index * 2, CHARS[1 + character]) + self._set_buffer(index * 2 + 1, CHARS[character]) def push(self, char): + """Scroll the display and add a character at the end.""" if char != '.' or self._get_buffer(7) & 0b01000000: self.scroll() self.put(' ', 3) self.put(char, 3) def text(self, text): - for c in text: - self.push(c) + """Display the specified text.""" + for character in text: + self.push(character) def number(self, number): - s = "{:f}".format(number) - if len(s) > 4: - if s.find('.') > 4: + """Display the specified decimal number.""" + string = "{:f}".format(number) + if len(string) > 4: + if string.find('.') > 4: raise ValueError("Overflow") self.fill(False) places = 4 - if '.' in s: + if '.' in string: places += 1 - self.text(s[:places]) + self.text(string[:places]) def hex(self, number): - s = "{:x}".format(number) - if len(s) > 4: + """Display the specified hexadecimal number.""" + string = "{:x}".format(number) + if len(string) > 4: raise ValueError("Overflow") self.fill(False) - self.text(s) + self.text(string) class Seg7x4(Seg14x4): - P = [0, 2, 6, 8] # The positions of characters. + """Numeric 7-segment display. It has the same methods as the alphanumeric display, but only + supports displaying decimal and hex digits, period and a minus sign.""" + POSITIONS = [0, 2, 6, 8] # The positions of characters. def scroll(self, count=1): + """Scroll the display by specified number of places.""" if count >= 0: offset = 0 else: offset = 1 for i in range(3): - self._set_buffer(self.P[i + offset], self._get_buffer(self.P[i + count])) + self._set_buffer(self.POSITIONS[i + offset], + self._get_buffer(self.POSITIONS[i + count])) def push(self, char): + """Scroll the display and add a character at the end.""" if char in ':;': self.put(char) else: super().push(char) def put(self, char, index=0): + """Put a character at the specified place.""" if not 0 <= index <= 3: return char = char.lower() - index = self.P[index] + index = self.POSITIONS[index] if char == '.': self._set_buffer(index, self._get_buffer(index) | 0b10000000) return elif char in 'abcdef': - c = ord(char) - 97 + 10 + character = ord(char) - 97 + 10 elif char == '-': - c = 16 + character = 16 elif char in '0123456789': - c = ord(char) - 48 + character = ord(char) - 48 elif char == ' ': - c = 0x00 + character = 0x00 elif char == ':': self._set_buffer(4, 0x02) return @@ -211,4 +250,4 @@ def put(self, char, index=0): return else: return - self._set_buffer(index, NUMBERS[c]) + self._set_buffer(index, NUMBERS[character]) diff --git a/conf.py b/conf.py new file mode 100644 index 0000000..4bcde7b --- /dev/null +++ b/conf.py @@ -0,0 +1,146 @@ +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'sphinx.ext.viewcode', +] + +intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None), + 'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} + +# Libraries we depend on but don't need for generating docs. +autodoc_mock_imports = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'README' + +# General information about the project. +project = u'Adafruit HT16K33 Library' +copyright = u'2016 Radomir Dopieralski' +author = u'Radomir Dopieralski' + +# 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 = u'1.0' +# The full version, including alpha/beta/rc tags. +release = u'1.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +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'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# +default_role = "any" + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +add_function_parentheses = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- 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' + +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(), '.'] + except: + html_theme = 'default' + html_theme_path = ['.'] +else: + 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'] + +# Output file base name for HTML help builder. +htmlhelp_basename = 'AdafruitHT16K33Librarydoc' + +# -- 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', +} + +# 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, 'AdafruitHT16K33Library.tex', u'Adafruit HT16K33 Library Documentation', + author, 'manual'), +] + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'adafruitHT16K33library', u'Adafruit HT16K33 Library Documentation', + [author], 1) +] + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'AdafruitHT16K33Library', u'Adafruit HT16K33 Library Documentation', + author, 'AdafruitHT16K33Library', 'One line description of project.', + 'Miscellaneous'), +] diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index 23408b1..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,177 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = _build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) -endif - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " xml to make Docutils-native XML files" - @echo " pseudoxml to make pseudoxml-XML files for display purposes" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/AdafruitHT16K33.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/AdafruitHT16K33.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/AdafruitHT16K33" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/AdafruitHT16K33" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -latexpdfja: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through platex and dvipdfmx..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." - -xml: - $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml - @echo - @echo "Build finished. The XML files are in $(BUILDDIR)/xml." - -pseudoxml: - $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml - @echo - @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/conf.py b/docs/conf.py deleted file mode 100644 index 05f33a0..0000000 --- a/docs/conf.py +++ /dev/null @@ -1,260 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Adafruit HT16K33 documentation build configuration file, created by -# sphinx-quickstart on Wed Oct 19 01:39:00 2016. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.viewcode', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'Adafruit HT16K33' -copyright = u'2016, Radomir Dopieralski' - -# 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' -# The full version, including alpha/beta/rc tags. -release = '1.0' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# 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'] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -#html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'AdafruitHT16K33doc' - - -# -- 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': '', -} - -# 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 = [ - ('index', 'AdafruitHT16K33.tex', u'Adafruit HT16K33 Documentation', - u'Radomir Dopieralski', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'adafruitht16k33', u'Adafruit HT16K33 Documentation', - [u'Radomir Dopieralski'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'AdafruitHT16K33', u'Adafruit HT16K33 Documentation', - u'Radomir Dopieralski', 'AdafruitHT16K33', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False diff --git a/docs/examples.rst b/docs/examples.rst deleted file mode 100644 index a623b90..0000000 --- a/docs/examples.rst +++ /dev/null @@ -1,17 +0,0 @@ -Example -******* - -This is an example for the ESP8266 port of MicroPython:: - - from machine import I2C, Pin - from ht16k33_matrix import Matrix8x8 - i2c = I2C(sda=Pin(4), scl=Pin(5)) - display = Matrix8x8(i2c) - display.brightness(8) - display.blink_rate(2) - display.fill(True) - display.pixel(0, 0, False) - display.pixel(7, 0, False) - display.pixel(0, 7, False) - display.pixel(7, 7, False) - display.show() diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index f1c2772..0000000 --- a/docs/index.rst +++ /dev/null @@ -1,26 +0,0 @@ -.. Adafruit HT16K33 documentation master file, created by - sphinx-quickstart on Wed Oct 19 01:39:00 2016. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to Adafruit HT16K33's documentation! -============================================ - -Contents: - -.. toctree:: - :maxdepth: 2 - - matrix - segment - exmaples - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100644 index e54d346..0000000 --- a/docs/make.bat +++ /dev/null @@ -1,242 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set BUILDDIR=_build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . -set I18NSPHINXOPTS=%SPHINXOPTS% . -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% - set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. dirhtml to make HTML files named index.html in directories - echo. singlehtml to make a single large HTML file - echo. pickle to make pickle files - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. devhelp to make HTML files and a Devhelp project - echo. epub to make an epub - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. text to make text files - echo. man to make manual pages - echo. texinfo to make Texinfo files - echo. gettext to make PO message catalogs - echo. changes to make an overview over all changed/added/deprecated items - echo. xml to make Docutils-native XML files - echo. pseudoxml to make pseudoxml-XML files for display purposes - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - goto end -) - -if "%1" == "clean" ( - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - - -%SPHINXBUILD% 2> nul -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. - goto end -) - -if "%1" == "singlehtml" ( - %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %BUILDDIR%/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\AdafruitHT16K33.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\AdafruitHT16K33.ghc - goto end -) - -if "%1" == "devhelp" ( - %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. - goto end -) - -if "%1" == "epub" ( - %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub file is in %BUILDDIR%/epub. - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdf" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf - cd %BUILDDIR%/.. - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdfja" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf-ja - cd %BUILDDIR%/.. - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "text" ( - %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The text files are in %BUILDDIR%/text. - goto end -) - -if "%1" == "man" ( - %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The manual pages are in %BUILDDIR%/man. - goto end -) - -if "%1" == "texinfo" ( - %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. - goto end -) - -if "%1" == "gettext" ( - %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The message catalogs are in %BUILDDIR%/locale. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes - if errorlevel 1 exit /b 1 - echo. - echo.The overview file is in %BUILDDIR%/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck - if errorlevel 1 exit /b 1 - echo. - echo.Link check complete; look for any errors in the above output ^ -or in %BUILDDIR%/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -if "%1" == "xml" ( - %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The XML files are in %BUILDDIR%/xml. - goto end -) - -if "%1" == "pseudoxml" ( - %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. - goto end -) - -:end diff --git a/docs/matrix.rst b/docs/matrix.rst deleted file mode 100644 index f2d9bca..0000000 --- a/docs/matrix.rst +++ /dev/null @@ -1,40 +0,0 @@ -Matrices -******** - -.. module:: ht16k33_matrix - -.. class:: HT16K33(i2c, address=0x70) - - The base class for all displays. Contains common methods. - - .. method:: blink_rate([rate]) - - Get or set the blink rate. Range 0-3. - - .. method:: brightness([brightness]) - - Get or set the brightness. Range 0-15. - - .. method:: show() - - Refresh the display and show the changes. - - .. method:: fill(color) - - Fill the whole display with the given color. - - .. method:: pixel(x, y, [color]) - - Get or set the color of a given pixel. - -.. class:: Matrix16x18 - - A double matrix or the matrix wing. - -.. class:: Matrix8x8 - - A single matrix. - -.. class:: Matrix8x8x2 - - A bi-color matrix. diff --git a/docs/segment.rst b/docs/segment.rst deleted file mode 100644 index a93e189..0000000 --- a/docs/segment.rst +++ /dev/null @@ -1,38 +0,0 @@ -Segment Displays -**************** - -.. module:: ht16k33_seg - -.. class:: Seg14x4(i2c, address=0x70) - - Alpha-numeric, 14-segment display. - - .. method:: scroll(self, count=1) - - Scroll the display by specified number of places. - - .. method:: put(self, char, index=0) - - Put a character at the specified place. - - .. method:: push(self, char) - - Scroll the display and add a character at the end. - - .. method:: text(text) - - Display the specified text. - - .. method:: number(number) - - Display the specified decimal number. - - .. method:: hex(number) - - Display the specified hexadecimal number. - -.. class:: Seg7x4(i2c, address-0x70) - - Numeric 7-segment display. It has the same methods as the alphanumeric - diplsay, but only supports displaying decimal and hex digits, period and - a minus sign. diff --git a/readthedocs.yml b/readthedocs.yml new file mode 100644 index 0000000..f4243ad --- /dev/null +++ b/readthedocs.yml @@ -0,0 +1,3 @@ +python: + version: 3 +requirements_file: requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ + From 0a1d70e7f9b11e3eb2e1998816b9ca9293d0cffd Mon Sep 17 00:00:00 2001 From: Kattni Date: Fri, 5 Jan 2018 14:50:47 -0500 Subject: [PATCH 2/6] changed doc url and updated usage example --- README.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 70ce651..7726650 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,8 @@ Introduction ============ -.. image:: https://readthedocs.org/projects/adafruit-circuitpython-circuitplayground/badge/?version=latest - :target: https://circuitpython.readthedocs.io/projects/circuitplayground/en/latest/ +.. image:: https://readthedocs.org/projects/adafruit-circuitpython-ht16k33/badge/?version=latest + :target: https://circuitpython.readthedocs.io/projects/ht16k33/en/latest/ :alt: Documentation Status .. image :: https://img.shields.io/discord/327254708534116352.svg @@ -22,8 +22,6 @@ This driver depends on many other libraries! Please install it by downloading Usage Example ============= -Using it is super simple. Simply import the `cpx` variable from the module -and then use it. .. code-block :: python From d6b0108cac38bd56329d6ae6f2054e5996f93958 Mon Sep 17 00:00:00 2001 From: Kattni Date: Fri, 5 Jan 2018 14:52:03 -0500 Subject: [PATCH 3/6] fixes typo --- adafruit_ht16k33/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_ht16k33/index.rst b/adafruit_ht16k33/index.rst index 0dd755e..e7528fc 100644 --- a/adafruit_ht16k33/index.rst +++ b/adafruit_ht16k33/index.rst @@ -14,7 +14,7 @@ Variety of HT16K33 displays .. automodule:: adafruit_ht16k33.matrix :members: -`segments` - Segments display such as those on alarm clocks +`segments` - Segment display such as those on alarm clocks ------------------------------------------------------------ .. automodule:: adafruit_ht16k33.segments From 5b0c6b089abd8f01f95be38fb25c7c21beeee3df Mon Sep 17 00:00:00 2001 From: Kattni Date: Fri, 5 Jan 2018 15:12:26 -0500 Subject: [PATCH 4/6] linting update --- adafruit_ht16k33/matrix.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/adafruit_ht16k33/matrix.py b/adafruit_ht16k33/matrix.py index a23f419..cb55982 100644 --- a/adafruit_ht16k33/matrix.py +++ b/adafruit_ht16k33/matrix.py @@ -33,9 +33,9 @@ class Matrix16x8(HT16K33): def pixel(self, x, y, color=None): """Get or set the color of a given pixel.""" if not 0 <= x <= 15: - return + return None if not 0 <= y <= 7: - return + return None if x >= 8: x -= 8 y += 8 @@ -47,9 +47,9 @@ class Matrix8x8(HT16K33): def pixel(self, x, y, color=None): """Get or set the color of a given pixel.""" if not 0 <= x <= 7: - return + return None if not 0 <= y <= 7: - return + return None x = (x - 1) % 8 return super()._pixel(x, y, color) @@ -59,9 +59,9 @@ class Matrix8x8x2(HT16K33): def pixel(self, x, y, color=None): """Get or set the color of a given pixel.""" if not 0 <= x <= 7: - return + return None if not 0 <= y <= 7: - return + return None if color is not None: super()._pixel(y, x, (color & 0x01)) super()._pixel(y + 8, x, (color >> 1) & 0x01) From 4411aa833bfd38984262846ee201a4e250b8dd89 Mon Sep 17 00:00:00 2001 From: Kattni Date: Fri, 5 Jan 2018 15:21:58 -0500 Subject: [PATCH 5/6] linting update --- adafruit_ht16k33/ht16k33.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adafruit_ht16k33/ht16k33.py b/adafruit_ht16k33/ht16k33.py index 4e6077e..a29a851 100644 --- a/adafruit_ht16k33/ht16k33.py +++ b/adafruit_ht16k33/ht16k33.py @@ -58,6 +58,7 @@ def blink_rate(self, rate=None): self._blink_rate = rate self._write_cmd(_HT16K33_BLINK_CMD | _HT16K33_BLINK_DISPLAYON | rate << 1) + return None def brightness(self, brightness): """Get or set the brightness. Range 0-15.""" @@ -66,6 +67,7 @@ def brightness(self, brightness): brightness = brightness & 0x0F self._brightness = brightness self._write_cmd(_HT16K33_CMD_BRIGHTNESS | brightness) + return None def show(self): """Refresh the display and show the changes.""" @@ -90,6 +92,7 @@ def _pixel(self, x, y, color=None): else: self._buffer[(y * 2) + 1] &= ~(mask & 0xff) self._buffer[(y * 2) + 2] &= ~(mask >> 8) + return None def _set_buffer(self, i, value): self._buffer[i+1] = value # Offset by 1 to move past register address. From fabbebd2fe8b8f60fdf9af8f356072b6c2ac4047 Mon Sep 17 00:00:00 2001 From: Kattni Date: Fri, 5 Jan 2018 15:26:53 -0500 Subject: [PATCH 6/6] linting update again --- adafruit_ht16k33/matrix.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_ht16k33/matrix.py b/adafruit_ht16k33/matrix.py index cb55982..da1b44b 100644 --- a/adafruit_ht16k33/matrix.py +++ b/adafruit_ht16k33/matrix.py @@ -67,6 +67,7 @@ def pixel(self, x, y, color=None): super()._pixel(y + 8, x, (color >> 1) & 0x01) else: return super()._pixel(y, x) | super()._pixel(y + 8, x) << 1 + return None def fill(self, color): """Fill the whole display with the given color."""