Compare commits

..

47 commits
patch ... main

Author SHA1 Message Date
foamyguy
8e59509ced
Merge pull request #29 from justmobilize/remove-secrets-usage
Remove secrets usage
2025-02-26 20:09:46 -06:00
Justin Myers
bba799d5ed Remove secrets usage 2025-02-26 15:31:00 -08:00
foamyguy
e3db30c001 add sphinx configuration to rtd.yaml
Signed-off-by: foamyguy <foamyguy@gmail.com>
2025-01-16 09:18:06 -06:00
foamyguy
fe6303465f
Merge pull request #28 from FoamyGuy/type_annotations
adding type annotations
2024-12-23 09:39:39 -06:00
foamyguy
67117e82a1 move pylint directives 2024-12-21 12:13:44 -06:00
foamyguy
d3a3e1bb02 adding type annotations 2024-12-21 11:33:06 -06:00
foamyguy
c15749258e remove deprecated get_html_theme_path() call
Signed-off-by: foamyguy <foamyguy@gmail.com>
2024-10-07 14:43:49 -05:00
foamyguy
59720f3e1d unpin sphinx and add sphinx-rtd-theme to docs reqs
Signed-off-by: foamyguy <foamyguy@gmail.com>
2023-12-04 09:55:42 -06:00
Dan Halbert
824435b961
Merge pull request #26 from prcutler/root-group-fix
Update root_group for CP 9 compatibility
2023-11-03 09:01:09 -04:00
Paul Cutler
29f7161faf Update root_group for CP 9 compatibility 2023-11-02 19:52:53 -05:00
foamyguy
a54031632a "fix rtd theme
"
2023-09-18 16:20:14 -05:00
Tekktrik
f0bcbbfbf0 Update .pylintrc, fix jQuery for docs
Signed-off-by: Tekktrik <tekktrik@gmail.com>
2023-05-23 21:10:53 -04:00
Tekktrik
ce00773925 Update pre-commit hooks
Signed-off-by: Tekktrik <tekktrik@gmail.com>
2023-05-10 15:22:03 -04:00
Alec Delaney
aa713f66f9 Add upload url to release action
Signed-off-by: Alec Delaney <89490472+tekktrik@users.noreply.github.com>
2023-01-19 23:50:06 -05:00
Alec Delaney
23448235ce Add .venv to .gitignore
Signed-off-by: Alec Delaney <89490472+tekktrik@users.noreply.github.com>
2022-11-30 19:39:02 -05:00
Alec Delaney
41521373c4
Merge pull request #21 from adafruit/disable-lambda-check
Fixed linting by disabling lambda check
2022-11-09 19:30:24 -05:00
evaherrada
4204ce8ee7
Fixed linting by disabling lambda check 2022-11-09 14:45:25 -05:00
Alec Delaney
76f6a573d3 Update .pylintrc for v2.15.5 2022-11-04 18:34:32 -04:00
Alec Delaney
a7a424b3ec Fix release CI files 2022-11-04 09:12:44 -04:00
Alec Delaney
052f9b4550 Update pylint to 2.15.5 2022-11-04 08:15:19 -04:00
Alec Delaney
17961f2e1f Updated pylint version to 2.13.0 2022-11-04 00:46:59 -04:00
Alec Delaney
43b9017cb6 Switching to composite actions 2022-11-04 00:02:49 -04:00
Alec Delaney
40ffdd80c2 Use year duration range for copyright attribution 2022-08-23 17:26:21 -04:00
Alec Delaney
c370998629 Keep copyright up to date in documentation 2022-08-22 21:36:31 -04:00
Alec Delaney
7629977dc9 Fix version strings in workflow files 2022-08-16 21:09:14 -04:00
Alec Delaney
5ddcbb9115 Update version string 2022-08-16 18:09:14 -04:00
Alec Delaney
e8dc80c477 Add setuptools-scm to build system requirements
Signed-off-by: Alec Delaney <tekktrik@gmail.com>
2022-08-09 13:31:28 -04:00
Alec Delaney
ffb90c513b Switched to pyproject.toml 2022-08-08 22:05:53 -04:00
Dan Halbert
d31ddc6358
Merge pull request #18 from adafruit/pypi
Prepared for adding to PyPI
2022-07-22 10:34:57 -04:00
evaherrada
04b8c31a78
Prepared for adding to PyPI 2022-07-21 14:25:55 -04:00
evaherrada
2177a695ee
Added cp.org link to index.rst 2022-06-07 15:34:46 -04:00
Alec Delaney
274317178d Set language to "en" for documentation
Signed-off-by: Alec Delaney <tekktrik@gmail.com>
2022-05-30 17:40:27 -04:00
Alec Delaney
2be00dc20e Increase min lines similarity
Signed-off-by: Alec Delaney <tekktrik@gmail.com>
2022-05-25 19:29:20 -04:00
Alec Delaney
a01cec4536 Patch .pre-commit-config.yaml 2022-05-15 12:48:22 -04:00
foamyguy
b92ec2d250 change discord badge 2022-04-24 13:55:48 -05:00
evaherrada
34020bd619
Patch: Replaced discord badge image 2022-04-22 15:59:06 -04:00
evaherrada
3d5b15fdda
Updated gitignore
Signed-off-by: evaherrada <eva.herrada@adafruit.com>
2022-04-21 16:54:33 -04:00
Kattni Rembor
72ff058feb Update Black to latest.
Signed-off-by: Kattni Rembor <kattni@adafruit.com>
2022-03-28 18:10:55 -04:00
dherrada
822fd27f2d Fixed readthedocs build
Signed-off-by: dherrada <dylan.herrada@adafruit.com>
2022-02-15 11:56:45 -05:00
tekktrik
9fe65edc9d
Post-patch cleanup
Manual fix after patch consolidating Documentation sections of READMEs
2022-02-10 12:09:08 -05:00
Alec Delaney
fade1c0ec7 Consolidate Documentation sections of README 2022-02-09 13:04:11 -05:00
dherrada
b611b20d3f Updated docs link, updated python docs link, updated setup.py 2022-01-24 16:46:17 -05:00
dherrada
c96e6b5e86 First part of patch
Signed-off-by: dherrada <dylan.herrada@adafruit.com>
2022-01-19 13:50:17 -05:00
foamyguy
67476617c6 update rtd py version 2021-11-23 13:06:09 -06:00
dherrada
3b628b8c66 Ran pre-commit 2021-11-12 14:44:31 -05:00
dherrada
e5cb126c43 Added PR template 2021-11-12 14:41:03 -05:00
Dylan Herrada
a471abf756
Merge pull request #15 from adafruit/patch
Pylint and RTD update patch, and other fixes
2021-11-12 13:41:52 -05:00
28 changed files with 306 additions and 349 deletions

View file

@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2021 Adafruit Industries
#
# SPDX-License-Identifier: MIT
Thank you for contributing! Before you submit a pull request, please read the following.
Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://docs.circuitpython.org/en/latest/docs/design_guide.html
If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs
Before submitting the pull request, make sure you've run Pylint and Black locally on your code. You can do this manually or using pre-commit. Instructions are available here: https://adafru.it/check-your-code
Please remove all of this text before submitting. Include an explanation or list of changes included in your PR, as well as, if applicable, a link to any related issues.

View file

@ -10,73 +10,5 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Dump GitHub context - name: Run Build CI workflow
env: uses: adafruit/workflows-circuitpython-libs/build@main
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.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- 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 Sphinx, pre-commit
run: |
pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit
- name: Library version
run: git describe --dirty --always --tags
- name: Setup problem matchers
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1
- name: Pre-commit hooks
run: |
pre-commit run --all-files
- name: Build assets
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
- name: Archive bundles
uses: actions/upload-artifact@v2
with:
name: bundles
path: ${{ github.workspace }}/bundles/
- name: Check For docs folder
id: need-docs
run: |
echo ::set-output name=docs::$( find . -wholename './docs' )
- name: Build docs
if: contains(steps.need-docs.outputs.docs, 'docs')
working-directory: docs
run: sphinx-build -E -W -b html . _build/html
- name: Check For setup.py
id: need-pypi
run: |
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
- name: Build Python package
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
run: |
pip install --upgrade setuptools wheel twine readme_renderer testresources
python setup.py sdist
python setup.py bdist_wheel --universal
twine check dist/*
- name: Setup problem matchers
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1

View file

@ -1,85 +0,0 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
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/*

19
.github/workflows/release_gh.yml vendored Normal file
View file

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
name: GitHub Release Actions
on:
release:
types: [published]
jobs:
upload-release-assets:
runs-on: ubuntu-latest
steps:
- name: Run GitHub Release CI workflow
uses: adafruit/workflows-circuitpython-libs/release-gh@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
upload-url: ${{ github.event.release.upload_url }}

19
.github/workflows/release_pypi.yml vendored Normal file
View file

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
name: PyPI Release Actions
on:
release:
types: [published]
jobs:
upload-release-assets:
runs-on: ubuntu-latest
steps:
- name: Run PyPI Release CI workflow
uses: adafruit/workflows-circuitpython-libs/release-pypi@main
with:
pypi-username: ${{ secrets.pypi_username }}
pypi-password: ${{ secrets.pypi_password }}

50
.gitignore vendored
View file

@ -1,18 +1,48 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries # SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries
# #
# SPDX-License-Identifier: Unlicense # SPDX-License-Identifier: MIT
# Do not include files and directories created by your personal work environment, such as the IDE
# you use, except for those already listed here. Pull requests including changes to this file will
# not be accepted.
# This .gitignore file contains rules for files generated by working with CircuitPython libraries,
# including building Sphinx, testing with pip, and creating a virual environment, as well as the
# MacOS and IDE-specific files generated by using MacOS in general, or the PyCharm or VSCode IDEs.
# If you find that there are files being generated on your machine that should not be included in
# your git commit, you should create a .gitignore_global file on your computer to include the
# files created by your personal setup. To do so, follow the two steps below.
# First, create a file called .gitignore_global somewhere convenient for you, and add rules for
# the files you want to exclude from git commits.
# Second, configure Git to use the exclude file for all Git repositories by running the
# following via commandline, replacing "path/to/your/" with the actual path to your newly created
# .gitignore_global file:
# git config --global core.excludesfile path/to/your/.gitignore_global
# CircuitPython-specific files
*.mpy *.mpy
.idea
# Python-specific files
__pycache__ __pycache__
_build
*.pyc *.pyc
# Sphinx build-specific files
_build
# This file results from running `pip -e install .` in a local repository
*.egg-info
# Virtual environment-specific files
.env .env
.python-version .venv
build*/
bundles # MacOS-specific files
*.DS_Store *.DS_Store
.eggs
dist # IDE-specific files
**/*.egg-info .idea
.vscode .vscode
*~

View file

@ -3,40 +3,40 @@
# SPDX-License-Identifier: Unlicense # SPDX-License-Identifier: Unlicense
repos: repos:
- repo: https://github.com/python/black - repo: https://github.com/python/black
rev: 20.8b1 rev: 23.3.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/fsfe/reuse-tool - repo: https://github.com/fsfe/reuse-tool
rev: v0.12.1 rev: v1.1.2
hooks: hooks:
- id: reuse - id: reuse
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0 rev: v4.4.0
hooks: hooks:
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/pycqa/pylint - repo: https://github.com/pycqa/pylint
rev: v2.11.1 rev: v2.17.4
hooks: hooks:
- id: pylint - id: pylint
name: pylint (library code) name: pylint (library code)
types: [python] types: [python]
args: args:
- --disable=consider-using-f-string - --disable=consider-using-f-string
exclude: "^(docs/|examples/|tests/|setup.py$)" exclude: "^(docs/|examples/|tests/|setup.py$)"
- id: pylint - id: pylint
name: pylint (example code) name: pylint (example code)
description: Run pylint rules on "examples/*.py" files description: Run pylint rules on "examples/*.py" files
types: [python] types: [python]
files: "^examples/" files: "^examples/"
args: args:
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code
- id: pylint - id: pylint
name: pylint (test code) name: pylint (test code)
description: Run pylint rules on "tests/*.py" files description: Run pylint rules on "tests/*.py" files
types: [python] types: [python]
files: "^tests/" files: "^tests/"
args: args:
- --disable=missing-docstring,consider-using-f-string,duplicate-code - --disable=missing-docstring,consider-using-f-string,duplicate-code

View file

@ -26,7 +26,7 @@ jobs=1
# List of plugins (as comma separated values of python modules names) to load, # List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers. # usually to register additional checkers.
load-plugins= load-plugins=pylint.extensions.no_self_use
# Pickle collected data for later comparisons. # Pickle collected data for later comparisons.
persistent=yes persistent=yes
@ -54,8 +54,8 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have # --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes # no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W" # --disable=W"
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call # disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,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,pointless-string-statement,unspecified-encoding disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding
# Enable the message, report, category or checker with the given id(s). You can # Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option # either give multiple identifier separated by comma (,) or put this option
@ -225,12 +225,6 @@ max-line-length=100
# Maximum number of lines in a module # Maximum number of lines in a module
max-module-lines=1000 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 # Allow the body of a class to be on the same line as the declaration if body
# contains single statement. # contains single statement.
single-line-class-stmt=no single-line-class-stmt=no
@ -252,43 +246,27 @@ ignore-docstrings=yes
ignore-imports=yes ignore-imports=yes
# Minimum lines number of a similarity. # Minimum lines number of a similarity.
min-similarity-lines=4 min-similarity-lines=12
[BASIC] [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 # Regular expression matching correct argument names
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 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 # Regular expression matching correct attribute names
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 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 variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata 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 # Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ 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 # Regular expression matching correct class names
# class-rgx=[A-Z_][a-zA-Z0-9]+$ # class-rgx=[A-Z_][a-zA-Z0-9]+$
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 # Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
@ -296,9 +274,6 @@ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# ones are exempt. # ones are exempt.
docstring-min-length=-1 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 # Regular expression matching correct function names
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
@ -309,21 +284,12 @@ 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 a hint for the correct naming format with invalid-name
include-naming-hint=no 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 # Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ 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 # Regular expression matching correct method names
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ 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 # Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
@ -339,9 +305,6 @@ no-docstring-rgx=^_
# to this list to register other decorators that produce valid properties. # to this list to register other decorators that produce valid properties.
property-classes=abc.abstractproperty 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 # Regular expression matching correct variable names
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
@ -433,4 +396,4 @@ min-public-methods=1
# Exceptions that will emit a warning when being caught. Defaults to # Exceptions that will emit a warning when being caught. Defaults to
# "Exception" # "Exception"
overgeneral-exceptions=Exception overgeneral-exceptions=builtins.Exception

View file

@ -8,8 +8,15 @@
# Required # Required
version: 2 version: 2
sphinx:
configuration: docs/conf.py
build:
os: ubuntu-20.04
tools:
python: "3"
python: python:
version: "3.6"
install: install:
- requirements: docs/requirements.txt - requirements: docs/requirements.txt
- requirements: requirements.txt - requirements: requirements.txt

View file

@ -3,11 +3,11 @@ Introduction
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-ov2640/badge/?version=latest .. image:: https://readthedocs.org/projects/adafruit-circuitpython-ov2640/badge/?version=latest
:target: https://circuitpython.readthedocs.io/projects/ov2640/en/latest/ :target: https://docs.circuitpython.org/projects/ov2640/en/latest/
:alt: Documentation Status :alt: Documentation Status
.. image:: https://img.shields.io/discord/327254708534116352.svg .. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg
:target: https://adafru.it/discord :target: https://adafru.it/discord
:alt: Discord :alt: Discord
@ -72,7 +72,9 @@ Using the ESP32-S2 Kaluga Dev Kit and its included camera, capture a 160x120 ima
Documentation Documentation
============= =============
API documentation for this library can be found on `Read the Docs <https://circuitpython.readthedocs.io/projects/ov2640/en/latest/>`_. API documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/ov2640/en/latest/>`_.
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>`_.
Contributing Contributing
============ ============
@ -80,9 +82,3 @@ Contributing
Contributions are welcome! Please read our `Code of Conduct Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_OV2640/blob/main/CODE_OF_CONDUCT.md>`_ <https://github.com/adafruit/Adafruit_CircuitPython_OV2640/blob/main/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming. 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

@ -26,10 +26,10 @@ Implementation Notes
* Adafruit's Bus Device library: https:# github.com/adafruit/Adafruit_CircuitPython_BusDevice * Adafruit's Bus Device library: https:# github.com/adafruit/Adafruit_CircuitPython_BusDevice
""" """
# pylint: disable=too-many-lines # pylint: disable=too-many-lines,unnecessary-lambda-assignment
# imports # imports
__version__ = "0.0.0-auto.0" __version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_OV7670.git" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_OV7670.git"
import time import time
@ -41,6 +41,14 @@ from adafruit_bus_device.i2c_device import I2CDevice
from micropython import const from micropython import const
try:
from typing import Optional, Union, Type, List
from busio import I2C
from microcontroller import Pin
from circuitpython_typing import WriteableBuffer
except ImportError:
pass
CTRLI = const(0x50) CTRLI = const(0x50)
_R_BYPASS = const(0x05) _R_BYPASS = const(0x05)
_QS = const(0x44) _QS = const(0x44)
@ -954,17 +962,17 @@ _ov2640_color_settings = {
class _RegBits: class _RegBits:
def __init__(self, bank, reg, shift, mask): def __init__(self, bank: int, reg: int, shift: int, mask: int) -> None:
self.bank = bank self.bank = bank
self.reg = reg self.reg = reg
self.shift = shift self.shift = shift
self.mask = mask self.mask = mask
def __get__(self, obj, objtype=None): def __get__(self, obj: "_SCCBCameraBase", objtype: Optional[Type] = None) -> int:
reg_value = obj._read_bank_register(self.bank, self.reg) reg_value = obj._read_bank_register(self.bank, self.reg)
return (reg_value >> self.shift) & self.mask return (reg_value >> self.shift) & self.mask
def __set__(self, obj, value): def __set__(self, obj: "_SCCBCameraBase", value: Union[bool, int]) -> None:
if value & ~self.mask: if value & ~self.mask:
raise ValueError( raise ValueError(
f"Value 0x{value:02x} does not fit in mask 0x{self.mask:02x}" f"Value 0x{value:02x} does not fit in mask 0x{self.mask:02x}"
@ -976,38 +984,38 @@ class _RegBits:
class _SCCBCameraBase: # pylint: disable=too-few-public-methods class _SCCBCameraBase: # pylint: disable=too-few-public-methods
def __init__(self, i2c_bus, i2c_address): def __init__(self, i2c_bus: I2C, i2c_address: int) -> None:
self._i2c_device = I2CDevice(i2c_bus, i2c_address) self._i2c_device = I2CDevice(i2c_bus, i2c_address)
self._bank = None self._bank = None
def _get_reg_bits(self, bank, reg, shift, mask): def _get_reg_bits(self, bank: int, reg: int, shift: int, mask: int) -> int:
return (self._read_bank_register(bank, reg) >> shift) & mask return (self._read_bank_register(bank, reg) >> shift) & mask
def _set_reg_bits( def _set_reg_bits( # pylint: disable=too-many-arguments
self, bank, reg, shift, mask, value self, bank: int, reg: int, shift: int, mask: int, value: int
): # pylint: disable=too-many-arguments ) -> None:
reg_value = self._read_bank_register(bank, reg) reg_value = self._read_bank_register(bank, reg)
reg_value &= ~(mask << shift) reg_value &= ~(mask << shift)
reg_value |= value << shift reg_value |= value << shift
self._write_register(reg, reg_value) self._write_register(reg, reg_value)
def _write_list(self, reg_list): def _write_list(self, reg_list: List[int]) -> None:
for i in range(0, len(reg_list), 2): for i in range(0, len(reg_list), 2):
self._write_register(reg_list[i], reg_list[i + 1]) self._write_register(reg_list[i], reg_list[i + 1])
time.sleep(0.001) time.sleep(0.001)
def _write_bank_register(self, bank, reg, value): def _write_bank_register(self, bank: int, reg: int, value: int) -> None:
if self._bank != bank: if self._bank != bank:
self._write_register(_BANK_SEL, bank) self._write_register(_BANK_SEL, bank)
self._write_register(reg, value) self._write_register(reg, value)
def _read_bank_register(self, bank, reg): def _read_bank_register(self, bank: int, reg: int) -> int:
if self._bank != bank: if self._bank != bank:
self._write_register(_BANK_SEL, bank) self._write_register(_BANK_SEL, bank)
result = self._read_register(reg) result = self._read_register(reg)
return result return result
def _write_register(self, reg, value): def _write_register(self, reg: int, value: int) -> None:
if reg == _BANK_SEL: if reg == _BANK_SEL:
if self._bank == value: if self._bank == value:
return return
@ -1019,7 +1027,7 @@ class _SCCBCameraBase: # pylint: disable=too-few-public-methods
with self._i2c_device as i2c: with self._i2c_device as i2c:
i2c.write(b) i2c.write(b)
def _read_register(self, reg): def _read_register(self, reg: int) -> int:
b = bytearray(1) b = bytearray(1)
b[0] = reg b[0] = reg
with self._i2c_device as i2c: with self._i2c_device as i2c:
@ -1039,17 +1047,17 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
def __init__( def __init__(
self, self,
i2c_bus, i2c_bus: I2C,
data_pins, data_pins: Pin,
clock, clock: Pin,
vsync, vsync: Pin,
href, href: Pin,
shutdown=None, shutdown: Optional[Pin] = None,
reset=None, reset: Optional[Pin] = None,
mclk=None, mclk: Optional[Pin] = None,
mclk_frequency=20_000_000, mclk_frequency: int = 20_000_000,
i2c_address=0x30, i2c_address: int = 0x30,
size=OV2640_SIZE_QQVGA, size: int = OV2640_SIZE_QQVGA,
): # pylint: disable=too-many-arguments ): # pylint: disable=too-many-arguments
""" """
Args: Args:
@ -1122,11 +1130,11 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
data_pins=data_pins, clock=clock, vsync=vsync, href=href data_pins=data_pins, clock=clock, vsync=vsync, href=href
) )
def capture(self, buf): def capture(self, buf: WriteableBuffer) -> Optional[memoryview]:
"""Capture an image into the buffer. """Capture an image into the buffer.
Args: Args:
buf (Union[bytearray, memoryview]): A WritableBuffer to contain the \ buf (WriteableBuffer): A WritableBuffer to contain the \
captured image. Note that this can be a ulab array or a displayio Bitmap. captured image. Note that this can be a ulab array or a displayio Bitmap.
""" """
self._imagecapture.capture(buf) self._imagecapture.capture(buf)
@ -1138,40 +1146,40 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
return None return None
@property @property
def capture_buffer_size(self): def capture_buffer_size(self) -> int:
"""Return the size of capture buffer to use with current resolution & colorspace settings""" """Return the size of capture buffer to use with current resolution & colorspace settings"""
if self.colorspace == OV2640_COLOR_JPEG: if self.colorspace == OV2640_COLOR_JPEG:
return self.width * self.height // 5 return self.width * self.height // 5
return self.width * self.height * 2 return self.width * self.height * 2
@property @property
def mclk_frequency(self): def mclk_frequency(self) -> Optional[int]:
"""Get the actual frequency the generated mclk, or None""" """Get the actual frequency the generated mclk, or None"""
return self._mclk_pwm.frequency if self._mclk_pwm else None return self._mclk_pwm.frequency if self._mclk_pwm else None
@property @property
def width(self): def width(self) -> int:
"""Get the image width in pixels. A buffer of 2*width*height bytes \ """Get the image width in pixels. A buffer of 2*width*height bytes \
stores a whole image.""" stores a whole image."""
return self._w return self._w
@property @property
def height(self): def height(self) -> int:
"""Get the image height in pixels. A buffer of 2*width*height bytes \ """Get the image height in pixels. A buffer of 2*width*height bytes \
stores a whole image.""" stores a whole image."""
return self._h return self._h
@property @property
def colorspace(self): def colorspace(self) -> bytes:
"""Get or set the colorspace, one of the ``OV2640_COLOR_`` constants.""" """Get or set the colorspace, one of the ``OV2640_COLOR_`` constants."""
return self._colorspace return self._colorspace
@colorspace.setter @colorspace.setter
def colorspace(self, colorspace): def colorspace(self, colorspace: bytes) -> None:
self._colorspace = colorspace self._colorspace = colorspace
self._set_size_and_colorspace() self._set_size_and_colorspace()
def _set_colorspace(self): def _set_colorspace(self) -> None:
colorspace = self._colorspace colorspace = self._colorspace
settings = _ov2640_color_settings[colorspace] settings = _ov2640_color_settings[colorspace]
@ -1180,7 +1188,7 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
self._write_list(settings) self._write_list(settings)
time.sleep(0.01) time.sleep(0.01)
def deinit(self): def deinit(self) -> None:
"""Deinitialize the camera""" """Deinitialize the camera"""
self._imagecapture.deinit() self._imagecapture.deinit()
if self._mclk_pwm: if self._mclk_pwm:
@ -1191,11 +1199,11 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
self._reset.deinit() self._reset.deinit()
@property @property
def size(self): def size(self) -> int:
"""Get or set the captured image size, one of the ``OV2640_SIZE_`` constants.""" """Get or set the captured image size, one of the ``OV2640_SIZE_`` constants."""
return self._size return self._size
def _set_size_and_colorspace(self): def _set_size_and_colorspace(self) -> None:
size = self._size size = self._size
width, height, ratio = _resolution_info[size] width, height, ratio = _resolution_info[size]
offset_x, offset_y, max_x, max_y = _ratio_table[ratio] offset_x, offset_y, max_x, max_y = _ratio_table[ratio]
@ -1218,11 +1226,11 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
self._set_window(mode, offset_x, offset_y, max_x, max_y, width, height) self._set_window(mode, offset_x, offset_y, max_x, max_y, width, height)
@size.setter @size.setter
def size(self, size): def size(self, size: int) -> None:
self._size = size self._size = size
self._set_size_and_colorspace() self._set_size_and_colorspace()
def _set_flip(self): def _set_flip(self) -> None:
bits = 0 bits = 0
if self._flip_x: if self._flip_x:
bits |= _REG04_HFLIP_IMG bits |= _REG04_HFLIP_IMG
@ -1231,38 +1239,45 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
self._write_bank_register(_BANK_SENSOR, _REG04, _REG04_SET(bits)) self._write_bank_register(_BANK_SENSOR, _REG04, _REG04_SET(bits))
@property @property
def flip_x(self): def flip_x(self) -> bool:
"""Get or set the X-flip flag""" """Get or set the X-flip flag"""
return self._flip_x return self._flip_x
@flip_x.setter @flip_x.setter
def flip_x(self, value): def flip_x(self, value: bool) -> None:
self._flip_x = bool(value) self._flip_x = bool(value)
self._set_flip() self._set_flip()
@property @property
def flip_y(self): def flip_y(self) -> bool:
"""Get or set the Y-flip flag""" """Get or set the Y-flip flag"""
return self._flip_y return self._flip_y
@flip_y.setter @flip_y.setter
def flip_y(self, value): def flip_y(self, value: bool) -> None:
self._flip_y = bool(value) self._flip_y = bool(value)
self._set_flip() self._set_flip()
@property @property
def product_id(self): def product_id(self) -> int:
"""Get the product id (PID) register. The expected value is 0x26.""" """Get the product id (PID) register. The expected value is 0x26."""
return self._read_bank_register(_BANK_SENSOR, _REG_PID) return self._read_bank_register(_BANK_SENSOR, _REG_PID)
@property @property
def product_version(self): def product_version(self) -> int:
"""Get the version (VER) register. The expected value is 0x4x.""" """Get the version (VER) register. The expected value is 0x41."""
return self._read_bank_register(_BANK_SENSOR, _REG_VER) return self._read_bank_register(_BANK_SENSOR, _REG_VER)
def _set_window( def _set_window( # pylint: disable=too-many-arguments, too-many-locals
self, mode, offset_x, offset_y, max_x, max_y, width, height self,
): # pylint: disable=too-many-arguments, too-many-locals mode: int,
offset_x: int,
offset_y: int,
max_x: int,
max_y: int,
width: int,
height: int,
) -> None:
self._w = width self._w = width
self._h = height self._h = height
@ -1335,7 +1350,7 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
self.test_pattern = self._test_pattern self.test_pattern = self._test_pattern
@property @property
def exposure(self): def exposure(self) -> int:
"""The exposure level of the sensor""" """The exposure level of the sensor"""
aec_9_2 = self._get_reg_bits(_BANK_SENSOR, _AEC, 0, 0xFF) aec_9_2 = self._get_reg_bits(_BANK_SENSOR, _AEC, 0, 0xFF)
aec_15_10 = self._get_reg_bits(_BANK_SENSOR, _REG45, 0, 0b111111) aec_15_10 = self._get_reg_bits(_BANK_SENSOR, _REG45, 0, 0b111111)
@ -1344,7 +1359,7 @@ class OV2640(_SCCBCameraBase): # pylint: disable=too-many-instance-attributes
return aec_1_0 | (aec_9_2 << 2) | (aec_15_10 << 10) return aec_1_0 | (aec_9_2 << 2) | (aec_15_10 << 10)
@exposure.setter @exposure.setter
def exposure(self, exposure): def exposure(self, exposure: int) -> None:
aec_1_0 = exposure & 0x11 aec_1_0 = exposure & 0x11
aec_9_2 = (exposure >> 2) & 0b11111111 aec_9_2 = (exposure >> 2) & 0b11111111
aec_15_10 = exposure >> 10 aec_15_10 = exposure >> 10

View file

@ -6,6 +6,7 @@
import os import os
import sys import sys
import datetime
sys.path.insert(0, os.path.abspath("..")) sys.path.insert(0, os.path.abspath(".."))
@ -16,6 +17,7 @@ sys.path.insert(0, os.path.abspath(".."))
# ones. # ones.
extensions = [ extensions = [
"sphinx.ext.autodoc", "sphinx.ext.autodoc",
"sphinxcontrib.jquery",
"sphinx.ext.intersphinx", "sphinx.ext.intersphinx",
"sphinx.ext.napoleon", "sphinx.ext.napoleon",
"sphinx.ext.todo", "sphinx.ext.todo",
@ -29,12 +31,12 @@ autodoc_mock_imports = ["adafruit_bus_device", "digitalio", "imagecapture", "pwm
intersphinx_mapping = { intersphinx_mapping = {
"python": ("https://docs.python.org/3.4", None), "python": ("https://docs.python.org/3", None),
"BusDevice": ( "BusDevice": (
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/", "https://docs.circuitpython.org/projects/busdevice/en/latest/",
None, None,
), ),
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None), "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None),
} }
# Show the docstring from both the class and its __init__() method. # Show the docstring from both the class and its __init__() method.
@ -50,7 +52,14 @@ master_doc = "index"
# General information about the project. # General information about the project.
project = "Adafruit CircuitPython OV2640 Library" project = "Adafruit CircuitPython OV2640 Library"
copyright = "2021 Jeff Epler" creation_year = "2021"
current_year = str(datetime.datetime.now().year)
year_duration = (
current_year
if current_year == creation_year
else creation_year + " - " + current_year
)
copyright = year_duration + " Jeff Epler"
author = "Jeff Epler" author = "Jeff Epler"
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
@ -67,7 +76,7 @@ release = "1.0"
# #
# This is also used if you do content translation via gettext catalogs. # This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases. # Usually you set "language" from the command line for these cases.
language = None language = "en"
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
@ -105,19 +114,9 @@ napoleon_numpy_docstring = False
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
# #
on_rtd = os.environ.get("READTHEDOCS", None) == "True" import sphinx_rtd_theme
if not on_rtd: # only import and set the theme if we're building docs locally html_theme = "sphinx_rtd_theme"
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, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,

View file

@ -89,7 +89,7 @@ Preview images on LCD then save BMP images to SD on Kaluga 1.3 fitted with an il
Kaluga 1.3 with Adafruit IO Kaluga 1.3 with Adafruit IO
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Upload JPEG images to Adafruit IO. Requires that WIFI and Adafruit IO be configured in ``secrets.py``. Upload JPEG images to Adafruit IO. Requires that WIFI and Adafruit IO be configured in ``settings.toml``.
.. literalinclude:: ../examples/ov2640_aio_kaluga1_3.py .. literalinclude:: ../examples/ov2640_aio_kaluga1_3.py
:caption: ov2640_aio_kaluga1_3.py :caption: ov2640_aio_kaluga1_3.py

View file

@ -27,8 +27,9 @@ Table of Contents
.. toctree:: .. toctree::
:caption: Other Links :caption: Other Links
Download <https://github.com/adafruit/Adafruit_CircuitPython_OV2640/releases/latest> Download from GitHub <https://github.com/adafruit/Adafruit_CircuitPython_OV2640/releases/latest>
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io> Download Library Bundle <https://circuitpython.org/libraries>
CircuitPython Reference Documentation <https://docs.circuitpython.org>
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60> CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
Discord Chat <https://adafru.it/discord> Discord Chat <https://adafru.it/discord>
Adafruit Learning System <https://learn.adafruit.com> Adafruit Learning System <https://learn.adafruit.com>

View file

@ -2,4 +2,6 @@
# #
# SPDX-License-Identifier: Unlicense # SPDX-License-Identifier: Unlicense
sphinx>=4.0.0 sphinx
sphinxcontrib-jquery
sphinx-rtd-theme

View file

@ -11,7 +11,7 @@ The audio board must be mounted between the Kaluga and the LCD, it provides the
I2C pull-ups(!) I2C pull-ups(!)
This example requires that your WIFI and Adafruit IO credentials be configured This example requires that your WIFI and Adafruit IO credentials be configured
in CIRCUITPY/secrets.py, and that you have created a feed called "image" with in CIRCUITPY/settings.toml, and that you have created a feed called "image" with
history disabled. history disabled.
The maximum image size is 100kB after base64 encoding, or about 65kB before The maximum image size is 100kB after base64 encoding, or about 65kB before
@ -21,31 +21,38 @@ base64 encoding. In practice, "SVGA" (800x600) images are typically around
""" """
import binascii import binascii
import ssl
import time import time
from secrets import secrets # pylint: disable=no-name-in-module from os import getenv
import board import board
import busio import busio
import wifi import wifi
import socketpool import adafruit_connection_manager
import adafruit_minimqtt.adafruit_minimqtt as MQTT import adafruit_minimqtt.adafruit_minimqtt as MQTT
from adafruit_io.adafruit_io import IO_MQTT from adafruit_io.adafruit_io import IO_MQTT
import adafruit_ov2640 import adafruit_ov2640
feed_name = "image" feed_name = "image"
# Get WiFi details and Adafruit IO keys, ensure these are setup in settings.toml
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
ssid = getenv("CIRCUITPY_WIFI_SSID")
password = getenv("CIRCUITPY_WIFI_PASSWORD")
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
aio_key = getenv("ADAFRUIT_AIO_KEY")
print("Connecting to WIFI") print("Connecting to WIFI")
wifi.radio.connect(secrets["ssid"], secrets["password"]) wifi.radio.connect(ssid, password)
pool = socketpool.SocketPool(wifi.radio) pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
print("Connecting to Adafruit IO") print("Connecting to Adafruit IO")
mqtt_client = MQTT.MQTT( mqtt_client = MQTT.MQTT(
broker="io.adafruit.com", broker="io.adafruit.com",
username=secrets["aio_username"], username=aio_username,
password=secrets["aio_key"], password=aio_key,
socket_pool=pool, socket_pool=pool,
ssl_context=ssl.create_default_context(), ssl_context=ssl_context,
) )
mqtt_client.connect() mqtt_client.connect()
io = IO_MQTT(mqtt_client) io = IO_MQTT(mqtt_client)

View file

@ -7,7 +7,7 @@
This exampl us for the Espressif Soala Wrover with an OV2640 Camera This exampl us for the Espressif Soala Wrover with an OV2640 Camera
This example requires that your WIFI and Adafruit IO credentials be configured This example requires that your WIFI and Adafruit IO credentials be configured
in CIRCUITPY/secrets.py, and that you have created a feed called "image" with in CIRCUITPY/settings.toml, and that you have created a feed called "image" with
history disabled. history disabled.
The maximum image size is 100kB after base64 encoding, or about 65kB before The maximum image size is 100kB after base64 encoding, or about 65kB before
@ -17,31 +17,38 @@ base64 encoding. In practice, "SVGA" (800x600) images are typically around
""" """
import binascii import binascii
import ssl
import time import time
from secrets import secrets # pylint: disable=no-name-in-module from os import getenv
import board import board
import busio import busio
import wifi import wifi
import socketpool import adafruit_connection_manager
import adafruit_minimqtt.adafruit_minimqtt as MQTT import adafruit_minimqtt.adafruit_minimqtt as MQTT
from adafruit_io.adafruit_io import IO_MQTT from adafruit_io.adafruit_io import IO_MQTT
import adafruit_ov2640 import adafruit_ov2640
feed_name = "image-saola-ov2640" feed_name = "image-saola-ov2640"
# Get WiFi details and Adafruit IO keys, ensure these are setup in settings.toml
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
ssid = getenv("CIRCUITPY_WIFI_SSID")
password = getenv("CIRCUITPY_WIFI_PASSWORD")
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
aio_key = getenv("ADAFRUIT_AIO_KEY")
print("Connecting to WIFI") print("Connecting to WIFI")
wifi.radio.connect(secrets["ssid"], secrets["password"]) wifi.radio.connect(ssid, password)
pool = socketpool.SocketPool(wifi.radio) pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
print("Connecting to Adafruit IO") print("Connecting to Adafruit IO")
mqtt_client = MQTT.MQTT( mqtt_client = MQTT.MQTT(
broker="io.adafruit.com", broker="io.adafruit.com",
username=secrets["aio_username"], username=aio_username,
password=secrets["aio_key"], password=aio_key,
socket_pool=pool, socket_pool=pool,
ssl_context=ssl.create_default_context(), ssl_context=ssl_context,
) )
mqtt_client.connect() mqtt_client.connect()
io = IO_MQTT(mqtt_client) io = IO_MQTT(mqtt_client)

View file

@ -109,7 +109,7 @@ tg = displayio.TileGrid(
), ),
) )
g.append(tg) g.append(tg)
display.show(g) display.root_group = g
sd_spi = busio.SPI(clock=board.IO18, MOSI=board.IO14, MISO=board.IO17) sd_spi = busio.SPI(clock=board.IO18, MOSI=board.IO14, MISO=board.IO17)

View file

@ -62,7 +62,7 @@ tg = displayio.TileGrid(
), ),
) )
g.append(tg) g.append(tg)
display.show(g) display.root_group = g
display.auto_refresh = False display.auto_refresh = False
while True: while True:

View file

@ -67,7 +67,7 @@ tg = displayio.TileGrid(
), ),
) )
g.append(tg) g.append(tg)
display.show(g) display.root_group = g
display.auto_refresh = False display.auto_refresh = False
while True: while True:

View file

@ -65,7 +65,7 @@ tg = displayio.TileGrid(
), ),
) )
g.append(tg) g.append(tg)
display.show(g) display.root_group = g
display.auto_refresh = False display.auto_refresh = False
while True: while True:

View file

@ -76,7 +76,7 @@ tg = TileGrid(
bitmap, pixel_shader=ColorConverter(input_colorspace=Colorspace.BGR565_SWAPPED) bitmap, pixel_shader=ColorConverter(input_colorspace=Colorspace.BGR565_SWAPPED)
) )
g.append(tg) g.append(tg)
display.show(g) display.root_group = g
display.auto_refresh = False display.auto_refresh = False
while True: while True:

View file

@ -80,7 +80,7 @@ tg = displayio.TileGrid(
), ),
) )
g.append(tg) g.append(tg)
display.show(g) display.root_group = g
display.auto_refresh = False display.auto_refresh = False

View file

@ -102,7 +102,7 @@ tg = TileGrid(
bitmap, pixel_shader=ColorConverter(input_colorspace=Colorspace.RGB565_SWAPPED) bitmap, pixel_shader=ColorConverter(input_colorspace=Colorspace.RGB565_SWAPPED)
) )
g.append(tg) g.append(tg)
display.show(g) display.root_group = g
display.auto_refresh = False display.auto_refresh = False

View file

@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

View file

@ -1,6 +1,45 @@
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò # SPDX-FileCopyrightText: 2022 Alec Delaney for Adafruit Industries
# #
# SPDX-License-Identifier: Unlicense # SPDX-License-Identifier: MIT
[tool.black] [build-system]
target-version = ['py35'] requires = [
"setuptools",
"wheel",
"setuptools-scm",
]
[project]
name = "adafruit-circuitpython-ov2640"
description = "CircuitPython driver for OV2640 cameras"
version = "0.0.0+auto.0"
readme = "README.rst"
authors = [
{name = "Adafruit Industries", email = "circuitpython@adafruit.com"}
]
urls = {Homepage = "https://github.com/adafruit/Adafruit_CircuitPython_OV2640"}
keywords = [
"adafruit",
"ov2640",
"camera",
"breakout",
"hardware",
"micropythoncircuitpython",
]
license = {text = "MIT"}
classifiers = [
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Embedded Systems",
"Topic :: System :: Hardware",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
]
dynamic = ["dependencies", "optional-dependencies"]
[tool.setuptools]
py-modules = ["adafruit_ov2640"]
[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
optional-dependencies = {optional = {file = ["optional_requirements.txt"]}}

View file

@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries # SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) 2021 Jeff Epler for Adafruit Industries
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: Unlicense
Adafruit-Blinka Adafruit-Blinka
adafruit-circuitpython-busdevice adafruit-circuitpython-busdevice

View file

@ -1,9 +0,0 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) 2021 Jeff Epler for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
This library is not deployed to PyPI. It is either a board-specific helper library, or
does not make sense for use on or is incompatible with single board computers and Linux.
"""