Compare commits
No commits in common. "main" and "patch" have entirely different histories.
29 changed files with 958 additions and 757 deletions
11
.gitattributes
vendored
11
.gitattributes
vendored
|
|
@ -1,11 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Unlicense
|
|
||||||
|
|
||||||
.py text eol=lf
|
|
||||||
.rst text eol=lf
|
|
||||||
.txt text eol=lf
|
|
||||||
.yaml text eol=lf
|
|
||||||
.toml text eol=lf
|
|
||||||
.license text eol=lf
|
|
||||||
.md text eol=lf
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
Thank you for contributing! Before you submit a pull request, please read the following.
|
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
|
Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://circuitpython.readthedocs.io/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
|
If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs
|
||||||
|
|
||||||
|
|
|
||||||
74
.github/workflows/build.yml
vendored
74
.github/workflows/build.yml
vendored
|
|
@ -10,5 +10,75 @@ jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Run Build CI workflow
|
- name: Dump GitHub context
|
||||||
uses: adafruit/workflows-circuitpython-libs/build@main
|
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.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: Pre-commit hooks
|
||||||
|
run: |
|
||||||
|
pre-commit run --all-files
|
||||||
|
- name: run tests
|
||||||
|
run: |
|
||||||
|
pip install --upgrade tox
|
||||||
|
tox -e py
|
||||||
|
- 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
|
||||||
|
|
|
||||||
85
.github/workflows/release.yml
vendored
Normal file
85
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
# 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
19
.github/workflows/release_gh.yml
vendored
|
|
@ -1,19 +0,0 @@
|
||||||
# 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
19
.github/workflows/release_pypi.yml
vendored
|
|
@ -1,19 +0,0 @@
|
||||||
# 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 }}
|
|
||||||
57
.gitignore
vendored
57
.gitignore
vendored
|
|
@ -1,48 +1,17 @@
|
||||||
# SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries
|
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
# Python-specific files
|
|
||||||
__pycache__
|
|
||||||
*.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
|
|
||||||
.venv
|
|
||||||
|
|
||||||
# MacOS-specific files
|
|
||||||
*.DS_Store
|
|
||||||
|
|
||||||
# IDE-specific files
|
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
__pycache__
|
||||||
*~
|
_build
|
||||||
|
*.pyc
|
||||||
|
.env
|
||||||
|
bundles
|
||||||
|
*.DS_Store
|
||||||
|
.eggs
|
||||||
|
dist
|
||||||
|
**/*.egg-info
|
||||||
|
.tox
|
||||||
|
.coverage
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,42 @@
|
||||||
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
|
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Unlicense
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/python/black
|
||||||
rev: v4.5.0
|
rev: 20.8b1
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-yaml
|
- id: black
|
||||||
- id: end-of-file-fixer
|
- repo: https://github.com/fsfe/reuse-tool
|
||||||
- id: trailing-whitespace
|
rev: v0.12.1
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
||||||
rev: v0.3.4
|
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff-format
|
- id: reuse
|
||||||
- id: ruff
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
args: ["--fix"]
|
rev: v2.3.0
|
||||||
- repo: https://github.com/fsfe/reuse-tool
|
|
||||||
rev: v3.0.1
|
|
||||||
hooks:
|
hooks:
|
||||||
- id: reuse
|
- id: check-yaml
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- repo: https://github.com/pycqa/pylint
|
||||||
|
rev: v2.11.1
|
||||||
|
hooks:
|
||||||
|
- id: pylint
|
||||||
|
name: pylint (library code)
|
||||||
|
types: [python]
|
||||||
|
args:
|
||||||
|
- --disable=consider-using-f-string
|
||||||
|
exclude: "^(docs/|examples/|tests/|setup.py$)"
|
||||||
|
- id: pylint
|
||||||
|
name: pylint (example code)
|
||||||
|
description: Run pylint rules on "examples/*.py" files
|
||||||
|
types: [python]
|
||||||
|
files: "^examples/"
|
||||||
|
args:
|
||||||
|
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code
|
||||||
|
- id: pylint
|
||||||
|
name: pylint (test code)
|
||||||
|
description: Run pylint rules on "tests/*.py" files
|
||||||
|
types: [python]
|
||||||
|
files: "^tests/"
|
||||||
|
args:
|
||||||
|
- --disable=missing-docstring,consider-using-f-string,duplicate-code
|
||||||
|
|
|
||||||
436
.pylintrc
Normal file
436
.pylintrc
Normal file
|
|
@ -0,0 +1,436 @@
|
||||||
|
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
|
[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 ignore-list. They should be base names, not
|
||||||
|
# paths.
|
||||||
|
ignore=CVS
|
||||||
|
|
||||||
|
# Add files or directories matching the regex patterns to the ignore-list. 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
|
||||||
|
|
||||||
|
# List of plugins (as comma separated values of python modules names) to load,
|
||||||
|
# usually to register additional checkers.
|
||||||
|
load-plugins=
|
||||||
|
|
||||||
|
# Pickle collected data for later comparisons.
|
||||||
|
persistent=yes
|
||||||
|
|
||||||
|
# Specify a configuration file.
|
||||||
|
#rcfile=
|
||||||
|
|
||||||
|
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||||
|
# active Python interpreter and may run arbitrary code.
|
||||||
|
unsafe-load-any-extension=no
|
||||||
|
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
|
||||||
|
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||||
|
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
||||||
|
confidence=
|
||||||
|
|
||||||
|
# Disable the message, report, category or checker with the given id(s). You
|
||||||
|
# can either give multiple identifiers separated by comma (,) or put this
|
||||||
|
# option multiple times (only on the command line, not in the configuration
|
||||||
|
# file where it should appear only once).You can also use "--disable=all" to
|
||||||
|
# disable everything first and then reenable specific checks. For example, if
|
||||||
|
# you want to run only the similarities checker, you can use "--disable=all
|
||||||
|
# --enable=similarities". If you want to run only the classes checker, but have
|
||||||
|
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||||
|
# --disable=W"
|
||||||
|
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
|
||||||
|
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation,pointless-string-statement,unspecified-encoding
|
||||||
|
|
||||||
|
# Enable the message, report, category or checker with the given id(s). You can
|
||||||
|
# either give multiple identifier separated by comma (,) or put this option
|
||||||
|
# multiple time (only on the command line, not in the configuration file where
|
||||||
|
# it should appear only once). See also the "--disable" option for examples.
|
||||||
|
enable=
|
||||||
|
|
||||||
|
|
||||||
|
[REPORTS]
|
||||||
|
|
||||||
|
# Python expression which should return a note less than 10 (10 is the highest
|
||||||
|
# note). You have access to the variables errors warning, statement which
|
||||||
|
# respectively contain the number of errors / warnings messages and the total
|
||||||
|
# number of statements analyzed. This is used by the global evaluation report
|
||||||
|
# (RP0004).
|
||||||
|
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
|
||||||
|
|
||||||
|
# Template used to display messages. This is a python new-style format string
|
||||||
|
# used to format the message information. See doc for all details
|
||||||
|
#msg-template=
|
||||||
|
|
||||||
|
# Set the output format. Available formats are text, parseable, colorized, json
|
||||||
|
# and msvs (visual studio).You can also give a reporter class, eg
|
||||||
|
# mypackage.mymodule.MyReporterClass.
|
||||||
|
output-format=text
|
||||||
|
|
||||||
|
# Tells whether to display a full report or only the messages
|
||||||
|
reports=no
|
||||||
|
|
||||||
|
# Activate the evaluation score.
|
||||||
|
score=yes
|
||||||
|
|
||||||
|
|
||||||
|
[REFACTORING]
|
||||||
|
|
||||||
|
# Maximum number of nested blocks for function / method body
|
||||||
|
max-nested-blocks=5
|
||||||
|
|
||||||
|
|
||||||
|
[LOGGING]
|
||||||
|
|
||||||
|
# Logging modules to check that the string format arguments are in logging
|
||||||
|
# function parameter format
|
||||||
|
logging-modules=logging
|
||||||
|
|
||||||
|
|
||||||
|
[SPELLING]
|
||||||
|
|
||||||
|
# Spelling dictionary name. Available dictionaries: none. To make it working
|
||||||
|
# install python-enchant package.
|
||||||
|
spelling-dict=
|
||||||
|
|
||||||
|
# List of comma separated words that should not be checked.
|
||||||
|
spelling-ignore-words=
|
||||||
|
|
||||||
|
# A path to a file that contains private dictionary; one word per line.
|
||||||
|
spelling-private-dict-file=
|
||||||
|
|
||||||
|
# Tells whether to store unknown words to indicated private dictionary in
|
||||||
|
# --spelling-private-dict-file option instead of raising a message.
|
||||||
|
spelling-store-unknown-words=no
|
||||||
|
|
||||||
|
|
||||||
|
[MISCELLANEOUS]
|
||||||
|
|
||||||
|
# List of note tags to take in consideration, separated by a comma.
|
||||||
|
# notes=FIXME,XXX,TODO
|
||||||
|
notes=FIXME,XXX
|
||||||
|
|
||||||
|
|
||||||
|
[TYPECHECK]
|
||||||
|
|
||||||
|
# List of decorators that produce context managers, such as
|
||||||
|
# contextlib.contextmanager. Add to this list to register other decorators that
|
||||||
|
# produce valid context managers.
|
||||||
|
contextmanager-decorators=contextlib.contextmanager
|
||||||
|
|
||||||
|
# List of members which are set dynamically and missed by pylint inference
|
||||||
|
# system, and so shouldn't trigger E1101 when accessed. Python regular
|
||||||
|
# expressions are accepted.
|
||||||
|
generated-members=
|
||||||
|
|
||||||
|
# Tells whether missing members accessed in mixin class should be ignored. A
|
||||||
|
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
||||||
|
ignore-mixin-members=yes
|
||||||
|
|
||||||
|
# This flag controls whether pylint should warn about no-member and similar
|
||||||
|
# checks whenever an opaque object is returned when inferring. The inference
|
||||||
|
# can return multiple potential results while evaluating a Python object, but
|
||||||
|
# some branches might not be evaluated, which results in partial inference. In
|
||||||
|
# that case, it might be useful to still emit no-member and other checks for
|
||||||
|
# the rest of the inferred objects.
|
||||||
|
ignore-on-opaque-inference=yes
|
||||||
|
|
||||||
|
# List of class names for which member attributes should not be checked (useful
|
||||||
|
# for classes with dynamically set attributes). This supports the use of
|
||||||
|
# qualified names.
|
||||||
|
ignored-classes=optparse.Values,thread._local,_thread._local
|
||||||
|
|
||||||
|
# List of module names for which member attributes should not be checked
|
||||||
|
# (useful for modules/projects where namespaces are manipulated during runtime
|
||||||
|
# and thus existing member attributes cannot be deduced by static analysis. It
|
||||||
|
# supports qualified module names, as well as Unix pattern matching.
|
||||||
|
ignored-modules=board
|
||||||
|
|
||||||
|
# Show a hint with possible names when a member name was not found. The aspect
|
||||||
|
# of finding the hint is based on edit distance.
|
||||||
|
missing-member-hint=yes
|
||||||
|
|
||||||
|
# The minimum edit distance a name should have in order to be considered a
|
||||||
|
# similar match for a missing member name.
|
||||||
|
missing-member-hint-distance=1
|
||||||
|
|
||||||
|
# The total number of similar names that should be taken in consideration when
|
||||||
|
# showing a hint for a missing member.
|
||||||
|
missing-member-max-choices=1
|
||||||
|
|
||||||
|
|
||||||
|
[VARIABLES]
|
||||||
|
|
||||||
|
# List of additional names supposed to be defined in builtins. Remember that
|
||||||
|
# you should avoid to define new builtins when possible.
|
||||||
|
additional-builtins=
|
||||||
|
|
||||||
|
# Tells whether unused global variables should be treated as a violation.
|
||||||
|
allow-global-unused-variables=yes
|
||||||
|
|
||||||
|
# List of strings which can identify a callback function by name. A callback
|
||||||
|
# name must start or end with one of those strings.
|
||||||
|
callbacks=cb_,_cb
|
||||||
|
|
||||||
|
# A regular expression matching the name of dummy variables (i.e. expectedly
|
||||||
|
# not used).
|
||||||
|
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
|
||||||
|
|
||||||
|
# Argument names that match this expression will be ignored. Default to name
|
||||||
|
# with leading underscore
|
||||||
|
ignored-argument-names=_.*|^ignored_|^unused_
|
||||||
|
|
||||||
|
# Tells whether we should check for unused import in __init__ files.
|
||||||
|
init-import=no
|
||||||
|
|
||||||
|
# List of qualified module names which can have objects that can redefine
|
||||||
|
# builtins.
|
||||||
|
redefining-builtins-modules=six.moves,future.builtins
|
||||||
|
|
||||||
|
|
||||||
|
[FORMAT]
|
||||||
|
|
||||||
|
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
|
||||||
|
# expected-line-ending-format=
|
||||||
|
expected-line-ending-format=LF
|
||||||
|
|
||||||
|
# Regexp for a line that is allowed to be longer than the limit.
|
||||||
|
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
|
||||||
|
|
||||||
|
# Number of spaces of indent required inside a hanging or continued line.
|
||||||
|
indent-after-paren=4
|
||||||
|
|
||||||
|
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||||
|
# tab).
|
||||||
|
indent-string=' '
|
||||||
|
|
||||||
|
# Maximum number of characters on a single line.
|
||||||
|
max-line-length=100
|
||||||
|
|
||||||
|
# Maximum number of lines in a module
|
||||||
|
max-module-lines=1000
|
||||||
|
|
||||||
|
# List of optional constructs for which whitespace checking is disabled. `dict-
|
||||||
|
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
|
||||||
|
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
|
||||||
|
# `empty-line` allows space-only lines.
|
||||||
|
no-space-check=trailing-comma,dict-separator
|
||||||
|
|
||||||
|
# Allow the body of a class to be on the same line as the declaration if body
|
||||||
|
# contains single statement.
|
||||||
|
single-line-class-stmt=no
|
||||||
|
|
||||||
|
# Allow the body of an if to be on the same line as the test if there is no
|
||||||
|
# else.
|
||||||
|
single-line-if-stmt=no
|
||||||
|
|
||||||
|
|
||||||
|
[SIMILARITIES]
|
||||||
|
|
||||||
|
# Ignore comments when computing similarities.
|
||||||
|
ignore-comments=yes
|
||||||
|
|
||||||
|
# Ignore docstrings when computing similarities.
|
||||||
|
ignore-docstrings=yes
|
||||||
|
|
||||||
|
# Ignore imports when computing similarities.
|
||||||
|
ignore-imports=yes
|
||||||
|
|
||||||
|
# Minimum lines number of a similarity.
|
||||||
|
min-similarity-lines=4
|
||||||
|
|
||||||
|
|
||||||
|
[BASIC]
|
||||||
|
|
||||||
|
# Naming hint for argument names
|
||||||
|
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Regular expression matching correct argument names
|
||||||
|
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Naming hint for attribute names
|
||||||
|
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Regular expression matching correct attribute names
|
||||||
|
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Bad variable names which should always be refused, separated by a comma
|
||||||
|
bad-names=foo,bar,baz,toto,tutu,tata
|
||||||
|
|
||||||
|
# Naming hint for class attribute names
|
||||||
|
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||||
|
|
||||||
|
# Regular expression matching correct class attribute names
|
||||||
|
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
|
||||||
|
|
||||||
|
# Naming hint for class names
|
||||||
|
# class-name-hint=[A-Z_][a-zA-Z0-9]+$
|
||||||
|
class-name-hint=[A-Z_][a-zA-Z0-9_]+$
|
||||||
|
|
||||||
|
# Regular expression matching correct class names
|
||||||
|
# class-rgx=[A-Z_][a-zA-Z0-9]+$
|
||||||
|
class-rgx=[A-Z_][a-zA-Z0-9_]+$
|
||||||
|
|
||||||
|
# Naming hint for constant names
|
||||||
|
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||||
|
|
||||||
|
# Regular expression matching correct constant names
|
||||||
|
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||||
|
|
||||||
|
# Minimum line length for functions/classes that require docstrings, shorter
|
||||||
|
# ones are exempt.
|
||||||
|
docstring-min-length=-1
|
||||||
|
|
||||||
|
# Naming hint for function names
|
||||||
|
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Regular expression matching correct function names
|
||||||
|
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Good variable names which should always be accepted, separated by a comma
|
||||||
|
# good-names=i,j,k,ex,Run,_
|
||||||
|
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
|
||||||
|
|
||||||
|
# Include a hint for the correct naming format with invalid-name
|
||||||
|
include-naming-hint=no
|
||||||
|
|
||||||
|
# Naming hint for inline iteration names
|
||||||
|
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
|
||||||
|
|
||||||
|
# Regular expression matching correct inline iteration names
|
||||||
|
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
|
||||||
|
|
||||||
|
# Naming hint for method names
|
||||||
|
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Regular expression matching correct method names
|
||||||
|
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Naming hint for module names
|
||||||
|
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||||
|
|
||||||
|
# Regular expression matching correct module names
|
||||||
|
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||||
|
|
||||||
|
# Colon-delimited sets of names that determine each other's naming style when
|
||||||
|
# the name regexes allow several styles.
|
||||||
|
name-group=
|
||||||
|
|
||||||
|
# Regular expression which should only match function or class names that do
|
||||||
|
# not require a docstring.
|
||||||
|
no-docstring-rgx=^_
|
||||||
|
|
||||||
|
# List of decorators that produce properties, such as abc.abstractproperty. Add
|
||||||
|
# to this list to register other decorators that produce valid properties.
|
||||||
|
property-classes=abc.abstractproperty
|
||||||
|
|
||||||
|
# Naming hint for variable names
|
||||||
|
variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Regular expression matching correct variable names
|
||||||
|
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
|
||||||
|
|
||||||
|
|
||||||
|
[IMPORTS]
|
||||||
|
|
||||||
|
# Allow wildcard imports from modules that define __all__.
|
||||||
|
allow-wildcard-with-all=no
|
||||||
|
|
||||||
|
# Analyse import fallback blocks. This can be used to support both Python 2 and
|
||||||
|
# 3 compatible code, which means that the block might have code that exists
|
||||||
|
# only in one or another interpreter, leading to false positives when analysed.
|
||||||
|
analyse-fallback-blocks=no
|
||||||
|
|
||||||
|
# Deprecated modules which should not be used, separated by a comma
|
||||||
|
deprecated-modules=optparse,tkinter.tix
|
||||||
|
|
||||||
|
# Create a graph of external dependencies in the given file (report RP0402 must
|
||||||
|
# not be disabled)
|
||||||
|
ext-import-graph=
|
||||||
|
|
||||||
|
# Create a graph of every (i.e. internal and external) dependencies in the
|
||||||
|
# given file (report RP0402 must not be disabled)
|
||||||
|
import-graph=
|
||||||
|
|
||||||
|
# Create a graph of internal dependencies in the given file (report RP0402 must
|
||||||
|
# not be disabled)
|
||||||
|
int-import-graph=
|
||||||
|
|
||||||
|
# Force import order to recognize a module as part of the standard
|
||||||
|
# compatibility libraries.
|
||||||
|
known-standard-library=
|
||||||
|
|
||||||
|
# Force import order to recognize a module as part of a third party library.
|
||||||
|
known-third-party=enchant
|
||||||
|
|
||||||
|
|
||||||
|
[CLASSES]
|
||||||
|
|
||||||
|
# List of method names used to declare (i.e. assign) instance attributes.
|
||||||
|
defining-attr-methods=__init__,__new__,setUp
|
||||||
|
|
||||||
|
# List of member names, which should be excluded from the protected access
|
||||||
|
# warning.
|
||||||
|
exclude-protected=_asdict,_fields,_replace,_source,_make
|
||||||
|
|
||||||
|
# List of valid names for the first argument in a class method.
|
||||||
|
valid-classmethod-first-arg=cls
|
||||||
|
|
||||||
|
# List of valid names for the first argument in a metaclass class method.
|
||||||
|
valid-metaclass-classmethod-first-arg=mcs
|
||||||
|
|
||||||
|
|
||||||
|
[DESIGN]
|
||||||
|
|
||||||
|
# Maximum number of arguments for function / method
|
||||||
|
max-args=5
|
||||||
|
|
||||||
|
# Maximum number of attributes for a class (see R0902).
|
||||||
|
# max-attributes=7
|
||||||
|
max-attributes=11
|
||||||
|
|
||||||
|
# Maximum number of boolean expressions in a if statement
|
||||||
|
max-bool-expr=5
|
||||||
|
|
||||||
|
# Maximum number of branch for function / method body
|
||||||
|
max-branches=12
|
||||||
|
|
||||||
|
# Maximum number of locals for function / method body
|
||||||
|
max-locals=15
|
||||||
|
|
||||||
|
# Maximum number of parents for a class (see R0901).
|
||||||
|
max-parents=7
|
||||||
|
|
||||||
|
# Maximum number of public methods for a class (see R0904).
|
||||||
|
max-public-methods=20
|
||||||
|
|
||||||
|
# Maximum number of return / yield for function / method body
|
||||||
|
max-returns=6
|
||||||
|
|
||||||
|
# Maximum number of statements in function / method body
|
||||||
|
max-statements=50
|
||||||
|
|
||||||
|
# Minimum number of public methods for a class (see R0903).
|
||||||
|
min-public-methods=1
|
||||||
|
|
||||||
|
|
||||||
|
[EXCEPTIONS]
|
||||||
|
|
||||||
|
# Exceptions that will emit a warning when being caught. Defaults to
|
||||||
|
# "Exception"
|
||||||
|
overgeneral-exceptions=Exception
|
||||||
|
|
@ -8,15 +8,8 @@
|
||||||
# Required
|
# Required
|
||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
sphinx:
|
|
||||||
configuration: docs/conf.py
|
|
||||||
|
|
||||||
build:
|
|
||||||
os: ubuntu-lts-latest
|
|
||||||
tools:
|
|
||||||
python: "3"
|
|
||||||
|
|
||||||
python:
|
python:
|
||||||
|
version: "3.6"
|
||||||
install:
|
install:
|
||||||
- requirements: docs/requirements.txt
|
- requirements: docs/requirements.txt
|
||||||
- requirements: requirements.txt
|
- requirements: requirements.txt
|
||||||
|
|
|
||||||
21
README.rst
21
README.rst
|
|
@ -2,10 +2,10 @@ Introduction
|
||||||
============
|
============
|
||||||
|
|
||||||
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-gps/badge/?version=latest
|
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-gps/badge/?version=latest
|
||||||
:target: https://docs.circuitpython.org/projects/gps/en/latest/
|
:target: https://circuitpython.readthedocs.io/projects/gps/en/latest/
|
||||||
:alt: Documentation Status
|
:alt: Documentation Status
|
||||||
|
|
||||||
.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg
|
.. image :: https://img.shields.io/discord/327254708534116352.svg
|
||||||
:target: https://adafru.it/discord
|
:target: https://adafru.it/discord
|
||||||
:alt: Discord
|
:alt: Discord
|
||||||
|
|
||||||
|
|
@ -13,10 +13,6 @@ Introduction
|
||||||
:target: https://github.com/adafruit/Adafruit_CircuitPython_GPS/actions/
|
:target: https://github.com/adafruit/Adafruit_CircuitPython_GPS/actions/
|
||||||
:alt: Build Status
|
:alt: Build Status
|
||||||
|
|
||||||
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
||||||
:target: https://github.com/astral-sh/ruff
|
|
||||||
:alt: Code Style: Ruff
|
|
||||||
|
|
||||||
GPS parsing module. Can send commands to, and parse simple NMEA data sentences
|
GPS parsing module. Can send commands to, and parse simple NMEA data sentences
|
||||||
from serial and I2C GPS modules to read latitude, longitude, and more.
|
from serial and I2C GPS modules to read latitude, longitude, and more.
|
||||||
|
|
||||||
|
|
@ -52,8 +48,8 @@ To install in a virtual environment in your current project:
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
mkdir project-name && cd project-name
|
mkdir project-name && cd project-name
|
||||||
python3 -m venv .venv
|
python3 -m venv .env
|
||||||
source .venv/bin/activate
|
source .env/bin/activate
|
||||||
pip3 install adafruit-circuitpython-gps
|
pip3 install adafruit-circuitpython-gps
|
||||||
|
|
||||||
Usage Example
|
Usage Example
|
||||||
|
|
@ -126,9 +122,7 @@ should fix this.
|
||||||
Documentation
|
Documentation
|
||||||
=============
|
=============
|
||||||
|
|
||||||
API documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/gps/en/latest/>`_.
|
API documentation for this library can be found on `Read the Docs <https://circuitpython.readthedocs.io/projects/gps/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
|
||||||
============
|
============
|
||||||
|
|
@ -136,3 +130,8 @@ 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_gps/blob/main/CODE_OF_CONDUCT.md>`_
|
<https://github.com/adafruit/Adafruit_CircuitPython_gps/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>`_.
|
||||||
|
|
|
||||||
359
adafruit_gps.py
359
adafruit_gps.py
|
|
@ -26,21 +26,10 @@ Implementation Notes
|
||||||
https://github.com/adafruit/circuitpython/releases
|
https://github.com/adafruit/circuitpython/releases
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from micropython import const
|
from micropython import const
|
||||||
|
|
||||||
try:
|
__version__ = "0.0.0-auto.0"
|
||||||
from typing import List, Optional, Tuple
|
|
||||||
|
|
||||||
from busio import I2C, UART
|
|
||||||
from circuitpython_typing import ReadableBuffer
|
|
||||||
from typing_extensions import Literal
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
__version__ = "0.0.0+auto.0"
|
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_GPS.git"
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_GPS.git"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -56,17 +45,16 @@ _GSV11 = 6
|
||||||
_GSV15 = 7
|
_GSV15 = 7
|
||||||
_GSV19 = 8
|
_GSV19 = 8
|
||||||
_RMC_4_1 = 9
|
_RMC_4_1 = 9
|
||||||
_VTG = 10
|
|
||||||
_ST_MIN = _GLL
|
_ST_MIN = _GLL
|
||||||
_ST_MAX = _VTG
|
_ST_MAX = _RMC_4_1
|
||||||
|
|
||||||
_SENTENCE_PARAMS = (
|
_SENTENCE_PARAMS = (
|
||||||
# 0 - _GLL
|
# 0 - _GLL
|
||||||
"dcdcscC",
|
"dcdcfcC",
|
||||||
# 1 - _RMC
|
# 1 - _RMC
|
||||||
"scdcdcffsDCC",
|
"fcdcdcffiDCC",
|
||||||
# 2 - _GGA
|
# 2 - _GGA
|
||||||
"sdcdciiffsfsIS",
|
"fdcdciiffsfsIS",
|
||||||
# 3 - _GSA
|
# 3 - _GSA
|
||||||
"ciIIIIIIIIIIIIfff",
|
"ciIIIIIIIIIIIIfff",
|
||||||
# 4 - _GSA_4_11
|
# 4 - _GSA_4_11
|
||||||
|
|
@ -80,80 +68,50 @@ _SENTENCE_PARAMS = (
|
||||||
# 8 - _GSV19
|
# 8 - _GSV19
|
||||||
"iiiiiiIiiiIiiiIiiiI",
|
"iiiiiiIiiiIiiiIiiiI",
|
||||||
# 9 - _RMC_4_1
|
# 9 - _RMC_4_1
|
||||||
"scdcdcffsDCCC",
|
"fcdcdcffiDCCC",
|
||||||
# 10 - _VTG
|
|
||||||
"fcFCfcfcC",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Internal helper parsing functions.
|
# Internal helper parsing functions.
|
||||||
# These handle input that might be none or null and return none instead of
|
# These handle input that might be none or null and return none instead of
|
||||||
# throwing errors.
|
# throwing errors.
|
||||||
def _parse_degrees(nmea_data: str) -> int:
|
def _parse_degrees(nmea_data):
|
||||||
# Parse a NMEA lat/long data pair 'dddmm.mmmm' into a pure degrees value.
|
# Parse a NMEA lat/long data pair 'dddmm.mmmm' into a pure degrees value.
|
||||||
# Where ddd is the degrees, mm.mmmm is the minutes.
|
# Where ddd is the degrees, mm.mmmm is the minutes.
|
||||||
if nmea_data is None or len(nmea_data) < 3:
|
if nmea_data is None or len(nmea_data) < 3:
|
||||||
return None
|
return None
|
||||||
# To avoid losing precision handle degrees and minutes separately
|
raw = float(nmea_data)
|
||||||
# Return the final value as an integer. Further functions can parse
|
deg = raw // 100
|
||||||
# this into a float or separate parts to retain the precision
|
minutes = raw % 100
|
||||||
raw = nmea_data.split(".")
|
return deg + minutes / 60
|
||||||
degrees = int(raw[0]) // 100 * 1000000 # the ddd
|
|
||||||
minutes = int(raw[0]) % 100 # the mm.
|
|
||||||
minutes += int(f"{raw[1][:4]:0<4}") / 10000
|
|
||||||
minutes = int((minutes * 1000000) / 60)
|
|
||||||
return degrees + minutes
|
|
||||||
|
|
||||||
|
|
||||||
def _parse_int(nmea_data: str) -> int:
|
def _parse_int(nmea_data):
|
||||||
if nmea_data is None or not nmea_data:
|
if nmea_data is None or nmea_data == "":
|
||||||
return None
|
return None
|
||||||
return int(nmea_data)
|
return int(nmea_data)
|
||||||
|
|
||||||
|
|
||||||
def _parse_float(nmea_data: str) -> float:
|
def _parse_float(nmea_data):
|
||||||
if nmea_data is None or not nmea_data:
|
if nmea_data is None or nmea_data == "":
|
||||||
return None
|
return None
|
||||||
return float(nmea_data)
|
return float(nmea_data)
|
||||||
|
|
||||||
|
|
||||||
def _parse_str(nmea_data: str) -> str:
|
def _parse_str(nmea_data):
|
||||||
if nmea_data is None or not nmea_data:
|
if nmea_data is None or nmea_data == "":
|
||||||
return None
|
return None
|
||||||
return str(nmea_data)
|
return str(nmea_data)
|
||||||
|
|
||||||
|
|
||||||
def _read_degrees(data: List[float], index: int, neg: str) -> float:
|
def _read_degrees(data, index, neg):
|
||||||
# This function loses precision with float32
|
x = data[index]
|
||||||
x = data[index] / 1000000
|
|
||||||
if data[index + 1].lower() == neg:
|
if data[index + 1].lower() == neg:
|
||||||
x *= -1.0
|
x *= -1.0
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
def _read_deg_mins(data: List[str], index: int, neg: str) -> Tuple[int, float]:
|
def _parse_talker(data_type):
|
||||||
# the degrees come in different formats and vary between latitudes and
|
|
||||||
# longitudes, which makes parsing tricky:
|
|
||||||
# for latitudes: ddmm,mmmm (0 - 7 decimal places, not zero padded)
|
|
||||||
# for longitudes: dddmm,mmmm (0 - 7 decimal places, not zero padded)
|
|
||||||
if "." in data[index]:
|
|
||||||
int_part, minutes_decimal = data[index].split(".")
|
|
||||||
else:
|
|
||||||
int_part, minutes_decimal = data[index], 0
|
|
||||||
|
|
||||||
# we need to parse from right to left, minutes can only have 2 digits
|
|
||||||
minutes_int = int_part[-2:]
|
|
||||||
# the rest must be degrees which are either 2 or 3 digits
|
|
||||||
deg = int(int_part[:-2])
|
|
||||||
# combine the parts of the minutes, this also works when there are no
|
|
||||||
# decimal places specified in the sentence
|
|
||||||
minutes = float(f"{minutes_int}.{minutes_decimal}")
|
|
||||||
if data[index + 1].lower() == neg:
|
|
||||||
deg *= -1
|
|
||||||
return deg, minutes
|
|
||||||
|
|
||||||
|
|
||||||
def _parse_talker(data_type: bytes) -> Tuple[bytes, bytes]:
|
|
||||||
# Split the data_type into talker and sentence_type
|
# Split the data_type into talker and sentence_type
|
||||||
if data_type[:1] == b"P": # Proprietary codes
|
if data_type[:1] == b"P": # Proprietary codes
|
||||||
return (data_type[:1], data_type[1:])
|
return (data_type[:1], data_type[1:])
|
||||||
|
|
@ -161,10 +119,11 @@ def _parse_talker(data_type: bytes) -> Tuple[bytes, bytes]:
|
||||||
return (data_type[:2], data_type[2:])
|
return (data_type[:2], data_type[2:])
|
||||||
|
|
||||||
|
|
||||||
def _parse_data(sentence_type: int, data: List[str]) -> Optional[List]:
|
def _parse_data(sentence_type, data):
|
||||||
"""Parse sentence data for the specified sentence type and
|
"""Parse sentence data for the specified sentence type and
|
||||||
return a list of parameters in the correct format, or return None.
|
return a list of parameters in the correct format, or return None.
|
||||||
"""
|
"""
|
||||||
|
# pylint: disable=too-many-branches
|
||||||
|
|
||||||
if not _ST_MIN <= sentence_type <= _ST_MAX:
|
if not _ST_MIN <= sentence_type <= _ST_MAX:
|
||||||
# The sentence_type is unknown
|
# The sentence_type is unknown
|
||||||
|
|
@ -207,12 +166,6 @@ def _parse_data(sentence_type: int, data: List[str]) -> Optional[List]:
|
||||||
elif pti == "f":
|
elif pti == "f":
|
||||||
# A floating point number
|
# A floating point number
|
||||||
params.append(_parse_float(dti))
|
params.append(_parse_float(dti))
|
||||||
elif pti == "F":
|
|
||||||
# A floating point number or Nothing
|
|
||||||
if nothing:
|
|
||||||
params.append(None)
|
|
||||||
else:
|
|
||||||
params.append(_parse_float(dti))
|
|
||||||
elif pti == "i":
|
elif pti == "i":
|
||||||
# An integer
|
# An integer
|
||||||
params.append(_parse_int(dti))
|
params.append(_parse_int(dti))
|
||||||
|
|
@ -241,97 +194,48 @@ def _parse_data(sentence_type: int, data: List[str]) -> Optional[List]:
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
# lint warning about too many attributes disabled
|
||||||
|
# pylint: disable-msg=R0902
|
||||||
|
|
||||||
|
|
||||||
class GPS:
|
class GPS:
|
||||||
"""GPS parsing module. Can parse simple NMEA data sentences from serial
|
"""GPS parsing module. Can parse simple NMEA data sentences from serial
|
||||||
GPS modules to read latitude, longitude, and more.
|
GPS modules to read latitude, longitude, and more.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, uart: UART, debug: bool = False) -> None:
|
def __init__(self, uart, debug=False):
|
||||||
self._uart = uart
|
self._uart = uart
|
||||||
# Initialize null starting values for GPS attributes.
|
# Initialize null starting values for GPS attributes.
|
||||||
self.timestamp_utc = None
|
self.timestamp_utc = None
|
||||||
"""Timestamp in UTC"""
|
|
||||||
self.latitude = None
|
self.latitude = None
|
||||||
"""Degrees latitude"""
|
|
||||||
self.latitude_degrees = None
|
|
||||||
"""Degrees component of latitude measurement"""
|
|
||||||
self.latitude_minutes = None # Use for full precision minutes
|
|
||||||
"""Minutes component of latitude measurement"""
|
|
||||||
self.longitude = None
|
self.longitude = None
|
||||||
"""Degrees longitude"""
|
|
||||||
self.longitude_degrees = None
|
|
||||||
"""Degrees component of longitude measurement"""
|
|
||||||
self.longitude_minutes = None # Use for full precision minutes
|
|
||||||
"""Minutes component of longitude measurement"""
|
|
||||||
self.fix_quality = 0
|
self.fix_quality = 0
|
||||||
"""
|
|
||||||
GPS quality indicator
|
|
||||||
|
|
||||||
| 0 - fix not available
|
|
||||||
| 1 - GPS fix
|
|
||||||
| 2 - Differential GPS fix (values above 2 are 2.3 features)
|
|
||||||
| 3 - PPS fix
|
|
||||||
| 4 - Real Time Kinematic
|
|
||||||
| 5 - Float RTK
|
|
||||||
| 6 - estimated (dead reckoning)
|
|
||||||
| 7 - Manual input mode
|
|
||||||
| 8 - Simulation mode
|
|
||||||
"""
|
|
||||||
self.fix_quality_3d = 0
|
self.fix_quality_3d = 0
|
||||||
"""
|
|
||||||
The type of fix for a reading
|
|
||||||
|
|
||||||
| 1 - no fix
|
|
||||||
| 2 - 2D fix
|
|
||||||
| 3 - 3D fix
|
|
||||||
"""
|
|
||||||
self.satellites = None
|
self.satellites = None
|
||||||
"""The number of satellites in use, 0 - 12"""
|
|
||||||
self.satellites_prev = None
|
self.satellites_prev = None
|
||||||
"""The number of satellites in use from the previous data point, 0 - 12"""
|
|
||||||
self.horizontal_dilution = None
|
self.horizontal_dilution = None
|
||||||
"""Horizontal dilution of precision (GGA)"""
|
|
||||||
self.altitude_m = None
|
self.altitude_m = None
|
||||||
"""Antenna altitude relative to mean sea level"""
|
|
||||||
self.height_geoid = None
|
self.height_geoid = None
|
||||||
"""Geoidal separation relative to WGS 84"""
|
|
||||||
self.speed_knots = None
|
self.speed_knots = None
|
||||||
"""Ground speed in knots"""
|
|
||||||
self.speed_kmh = None
|
|
||||||
"""Ground speed in km/h"""
|
|
||||||
self.track_angle_deg = None
|
self.track_angle_deg = None
|
||||||
"""Track angle in degrees"""
|
|
||||||
self._sats = None # Temporary holder for information from GSV messages
|
self._sats = None # Temporary holder for information from GSV messages
|
||||||
self.sats = None
|
self.sats = None # Completed information from GSV messages
|
||||||
"""Information from GSV messages"""
|
|
||||||
self.isactivedata = None
|
self.isactivedata = None
|
||||||
"""Status Valid(A) or Invalid(V)"""
|
self.true_track = None
|
||||||
|
self.mag_track = None
|
||||||
self.sat_prns = None
|
self.sat_prns = None
|
||||||
"""Satellite pseudorandom noise code"""
|
|
||||||
self.sel_mode = None
|
self.sel_mode = None
|
||||||
"""
|
|
||||||
Selection mode
|
|
||||||
|
|
||||||
| 'M' - manual
|
|
||||||
| 'A' - automatic
|
|
||||||
"""
|
|
||||||
self.pdop = None
|
self.pdop = None
|
||||||
"""Dilution of precision"""
|
|
||||||
self.hdop = None
|
self.hdop = None
|
||||||
"""Horizontal dilution of precision (GSA)"""
|
|
||||||
self.vdop = None
|
self.vdop = None
|
||||||
"""Vertical dilution of precision"""
|
|
||||||
self.total_mess_num = None
|
self.total_mess_num = None
|
||||||
"""Number of messages"""
|
|
||||||
self.mess_num = None
|
self.mess_num = None
|
||||||
"""Message number"""
|
|
||||||
self._raw_sentence = None
|
self._raw_sentence = None
|
||||||
self._mode_indicator = None
|
self._mode_indicator = None
|
||||||
self._magnetic_variation = None
|
self._magnetic_variation = None
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
"""Toggles debug mode. When True, prints the incoming data sentence to the console"""
|
|
||||||
|
|
||||||
def update(self) -> bool:
|
def update(self):
|
||||||
"""Check for updated data from the GPS module and process it
|
"""Check for updated data from the GPS module and process it
|
||||||
accordingly. Returns True if new data was processed, and False if
|
accordingly. Returns True if new data was processed, and False if
|
||||||
nothing new was received.
|
nothing new was received.
|
||||||
|
|
@ -361,7 +265,7 @@ class GPS:
|
||||||
# GP - GPS
|
# GP - GPS
|
||||||
# GQ - QZSS
|
# GQ - QZSS
|
||||||
# GN - GNSS / More than one of the above
|
# GN - GNSS / More than one of the above
|
||||||
if talker not in {b"GA", b"GB", b"GI", b"GL", b"GP", b"GQ", b"GN"}:
|
if talker not in (b"GA", b"GB", b"GI", b"GL", b"GP", b"GQ", b"GN"):
|
||||||
# It's not a known GNSS source of data
|
# It's not a known GNSS source of data
|
||||||
# Assume it's a valid packet anyway
|
# Assume it's a valid packet anyway
|
||||||
return True
|
return True
|
||||||
|
|
@ -378,12 +282,10 @@ class GPS:
|
||||||
result = self._parse_gsv(talker, args)
|
result = self._parse_gsv(talker, args)
|
||||||
elif sentence_type == b"GSA": # GPS DOP and active satellites
|
elif sentence_type == b"GSA": # GPS DOP and active satellites
|
||||||
result = self._parse_gsa(talker, args)
|
result = self._parse_gsa(talker, args)
|
||||||
elif sentence_type == b"VTG": # Ground speed
|
|
||||||
result = self._parse_vtg(args)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def send_command(self, command: bytes, add_checksum: bool = True) -> None:
|
def send_command(self, command, add_checksum=True):
|
||||||
"""Send a command string to the GPS. If add_checksum is True (the
|
"""Send a command string to the GPS. If add_checksum is True (the
|
||||||
default) a NMEA checksum will automatically be computed and added.
|
default) a NMEA checksum will automatically be computed and added.
|
||||||
Note you should NOT add the leading $ and trailing * to the command
|
Note you should NOT add the leading $ and trailing * to the command
|
||||||
|
|
@ -396,53 +298,54 @@ class GPS:
|
||||||
for char in command:
|
for char in command:
|
||||||
checksum ^= char
|
checksum ^= char
|
||||||
self.write(b"*")
|
self.write(b"*")
|
||||||
self.write(bytes(f"{checksum:02x}".upper(), "ascii"))
|
self.write(bytes("{:02x}".format(checksum).upper(), "ascii"))
|
||||||
self.write(b"\r\n")
|
self.write(b"\r\n")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_fix(self) -> bool:
|
def has_fix(self):
|
||||||
"""True if a current fix for location information is available."""
|
"""True if a current fix for location information is available."""
|
||||||
return self.fix_quality is not None and self.fix_quality >= 1
|
return self.fix_quality is not None and self.fix_quality >= 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_3d_fix(self) -> bool:
|
def has_3d_fix(self):
|
||||||
"""Returns true if there is a 3d fix available.
|
"""Returns true if there is a 3d fix available.
|
||||||
use has_fix to determine if a 2d fix is available,
|
use has_fix to determine if a 2d fix is available,
|
||||||
passing it the same data"""
|
passing it the same data"""
|
||||||
return self.fix_quality_3d is not None and self.fix_quality_3d >= 2
|
return self.fix_quality_3d is not None and self.fix_quality_3d >= 2
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def datetime(self) -> Optional[time.struct_time]:
|
def datetime(self):
|
||||||
"""Return struct_time object to feed rtc.set_time_source() function"""
|
"""Return struct_time object to feed rtc.set_time_source() function"""
|
||||||
return self.timestamp_utc
|
return self.timestamp_utc
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def nmea_sentence(self) -> Optional[str]:
|
def nmea_sentence(self):
|
||||||
"""Return raw_sentence which is the raw NMEA sentence read from the GPS"""
|
"""Return raw_sentence which is the raw NMEA sentence read from the GPS"""
|
||||||
return self._raw_sentence
|
return self._raw_sentence
|
||||||
|
|
||||||
def read(self, num_bytes: Optional[int]) -> Optional[bytes]:
|
def read(self, num_bytes):
|
||||||
"""Read up to num_bytes of data from the GPS directly, without parsing.
|
"""Read up to num_bytes of data from the GPS directly, without parsing.
|
||||||
Returns a bytestring with up to num_bytes or None if nothing was read"""
|
Returns a bytearray with up to num_bytes or None if nothing was read"""
|
||||||
return self._uart.read(num_bytes)
|
return self._uart.read(num_bytes)
|
||||||
|
|
||||||
def write(self, bytestr: ReadableBuffer) -> Optional[int]:
|
def write(self, bytestr):
|
||||||
"""Write a bytestring data to the GPS directly, without parsing
|
"""Write a bytestring data to the GPS directly, without parsing
|
||||||
or checksums"""
|
or checksums"""
|
||||||
return self._uart.write(bytestr)
|
return self._uart.write(bytestr)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def in_waiting(self) -> int:
|
def in_waiting(self):
|
||||||
"""Returns number of bytes available in UART read buffer"""
|
"""Returns number of bytes available in UART read buffer"""
|
||||||
return self._uart.in_waiting
|
return self._uart.in_waiting
|
||||||
|
|
||||||
def readline(self) -> Optional[bytes]:
|
def readline(self):
|
||||||
"""Returns a newline terminated bytestring, must have timeout set for
|
"""Returns a newline terminated bytearray, must have timeout set for
|
||||||
the underlying UART or this will block forever!"""
|
the underlying UART or this will block forever!"""
|
||||||
return self._uart.readline()
|
return self._uart.readline()
|
||||||
|
|
||||||
def _read_sentence(self) -> Optional[str]:
|
def _read_sentence(self):
|
||||||
# Parse any NMEA sentence that is available.
|
# Parse any NMEA sentence that is available.
|
||||||
|
# pylint: disable=len-as-condition
|
||||||
# This needs to be refactored when it can be tested.
|
# This needs to be refactored when it can be tested.
|
||||||
|
|
||||||
# Only continue if we have at least 11 bytes in the input buffer
|
# Only continue if we have at least 11 bytes in the input buffer
|
||||||
|
|
@ -473,7 +376,7 @@ class GPS:
|
||||||
# At this point we don't have a valid sentence
|
# At this point we don't have a valid sentence
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _parse_sentence(self) -> Optional[Tuple[str, str]]:
|
def _parse_sentence(self):
|
||||||
sentence = self._read_sentence()
|
sentence = self._read_sentence()
|
||||||
|
|
||||||
# sentence is a valid NMEA with a valid checksum
|
# sentence is a valid NMEA with a valid checksum
|
||||||
|
|
@ -490,10 +393,10 @@ class GPS:
|
||||||
data_type = sentence[1:delimiter]
|
data_type = sentence[1:delimiter]
|
||||||
return (data_type, sentence[delimiter + 1 :])
|
return (data_type, sentence[delimiter + 1 :])
|
||||||
|
|
||||||
def _update_timestamp_utc(self, time_utc: str, date: Optional[str] = None) -> None:
|
def _update_timestamp_utc(self, time_utc, date=None):
|
||||||
hours = int(time_utc[0:2])
|
hours = time_utc // 10000
|
||||||
mins = int(time_utc[2:4])
|
mins = (time_utc // 100) % 100
|
||||||
secs = int(time_utc[4:6])
|
secs = time_utc % 100
|
||||||
if date is None:
|
if date is None:
|
||||||
if self.timestamp_utc is None:
|
if self.timestamp_utc is None:
|
||||||
day, month, year = 0, 0, 0
|
day, month, year = 0, 0, 0
|
||||||
|
|
@ -502,146 +405,127 @@ class GPS:
|
||||||
month = self.timestamp_utc.tm_mon
|
month = self.timestamp_utc.tm_mon
|
||||||
year = self.timestamp_utc.tm_year
|
year = self.timestamp_utc.tm_year
|
||||||
else:
|
else:
|
||||||
day = int(date[0:2])
|
day = date // 10000
|
||||||
month = int(date[2:4])
|
month = (date // 100) % 100
|
||||||
year = 2000 + int(date[4:6])
|
year = 2000 + date % 100
|
||||||
|
|
||||||
self.timestamp_utc = time.struct_time((year, month, day, hours, mins, secs, 0, 0, -1))
|
self.timestamp_utc = time.struct_time(
|
||||||
|
(year, month, day, hours, mins, secs, 0, 0, -1)
|
||||||
|
)
|
||||||
|
|
||||||
def _parse_vtg(self, data: List[str]) -> bool:
|
def _parse_gll(self, data):
|
||||||
# VTG - Course Over Ground and Ground Speed
|
|
||||||
|
|
||||||
if data is None or len(data) != 9:
|
|
||||||
return False # Unexpected number of params
|
|
||||||
|
|
||||||
parsed_data = _parse_data(_VTG, data)
|
|
||||||
if parsed_data is None:
|
|
||||||
return False # Params didn't parse
|
|
||||||
|
|
||||||
# Track made good, degrees true
|
|
||||||
self.track_angle_deg = parsed_data[0]
|
|
||||||
|
|
||||||
# Speed over ground, knots
|
|
||||||
self.speed_knots = parsed_data[4]
|
|
||||||
|
|
||||||
# Speed over ground, kilometers / hour
|
|
||||||
self.speed_kmh = parsed_data[6]
|
|
||||||
|
|
||||||
# Parse FAA mode indicator
|
|
||||||
self._mode_indicator = parsed_data[8]
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _parse_gll(self, data: List[str]) -> bool:
|
|
||||||
# GLL - Geographic Position - Latitude/Longitude
|
# GLL - Geographic Position - Latitude/Longitude
|
||||||
|
|
||||||
if data is None or len(data) != 7:
|
if data is None or len(data) != 7:
|
||||||
return False # Unexpected number of params.
|
return False # Unexpected number of params.
|
||||||
parsed_data = _parse_data(_GLL, data)
|
data = _parse_data(_GLL, data)
|
||||||
if parsed_data is None:
|
if data is None:
|
||||||
return False # Params didn't parse
|
return False # Params didn't parse
|
||||||
|
|
||||||
# Latitude
|
# Latitude
|
||||||
self.latitude = _read_degrees(parsed_data, 0, "s")
|
self.latitude = _read_degrees(data, 0, "s")
|
||||||
self.latitude_degrees, self.latitude_minutes = _read_deg_mins(data=data, index=0, neg="s")
|
|
||||||
|
|
||||||
# Longitude
|
# Longitude
|
||||||
self.longitude = _read_degrees(parsed_data, 2, "w")
|
self.longitude = _read_degrees(data, 2, "w")
|
||||||
self.longitude_degrees, self.longitude_minutes = _read_deg_mins(data=data, index=2, neg="w")
|
|
||||||
|
|
||||||
# UTC time of position
|
# UTC time of position
|
||||||
self._update_timestamp_utc(parsed_data[4])
|
self._update_timestamp_utc(int(data[4]))
|
||||||
|
|
||||||
# Status Valid(A) or Invalid(V)
|
# Status Valid(A) or Invalid(V)
|
||||||
self.isactivedata = parsed_data[5]
|
self.isactivedata = data[5]
|
||||||
|
|
||||||
# Parse FAA mode indicator
|
# Parse FAA mode indicator
|
||||||
self._mode_indicator = parsed_data[6]
|
self._mode_indicator = data[6]
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _parse_rmc(self, data: List[str]) -> bool:
|
def _parse_rmc(self, data):
|
||||||
# RMC - Recommended Minimum Navigation Information
|
# RMC - Recommended Minimum Navigation Information
|
||||||
|
|
||||||
if data is None or len(data) not in {12, 13}:
|
if data is None or len(data) not in (12, 13):
|
||||||
return False # Unexpected number of params.
|
return False # Unexpected number of params.
|
||||||
parsed_data = _parse_data({12: _RMC, 13: _RMC_4_1}[len(data)], data)
|
data = _parse_data({12: _RMC, 13: _RMC_4_1}[len(data)], data)
|
||||||
if parsed_data is None:
|
if data is None:
|
||||||
self.fix_quality = 0
|
self.fix_quality = 0
|
||||||
return False # Params didn't parse
|
return False # Params didn't parse
|
||||||
|
|
||||||
# UTC time of position and date
|
# UTC time of position and date
|
||||||
self._update_timestamp_utc(parsed_data[0], parsed_data[8])
|
self._update_timestamp_utc(int(data[0]), data[8])
|
||||||
|
|
||||||
# Status Valid(A) or Invalid(V)
|
# Status Valid(A) or Invalid(V)
|
||||||
self.isactivedata = parsed_data[1]
|
self.isactivedata = data[1]
|
||||||
if parsed_data[1].lower() == "a":
|
if data[1].lower() == "a":
|
||||||
if self.fix_quality == 0:
|
if self.fix_quality == 0:
|
||||||
self.fix_quality = 1
|
self.fix_quality = 1
|
||||||
else:
|
else:
|
||||||
self.fix_quality = 0
|
self.fix_quality = 0
|
||||||
|
|
||||||
# Latitude
|
# Latitude
|
||||||
self.latitude = _read_degrees(parsed_data, 2, "s")
|
self.latitude = _read_degrees(data, 2, "s")
|
||||||
self.latitude_degrees, self.latitude_minutes = _read_deg_mins(data=data, index=2, neg="s")
|
|
||||||
|
|
||||||
# Longitude
|
# Longitude
|
||||||
self.longitude = _read_degrees(parsed_data, 4, "w")
|
self.longitude = _read_degrees(data, 4, "w")
|
||||||
self.longitude_degrees, self.longitude_minutes = _read_deg_mins(data=data, index=4, neg="w")
|
|
||||||
|
|
||||||
# Speed over ground, knots
|
# Speed over ground, knots
|
||||||
self.speed_knots = parsed_data[6]
|
self.speed_knots = data[6]
|
||||||
|
|
||||||
# Track made good, degrees true
|
# Track made good, degrees true
|
||||||
self.track_angle_deg = parsed_data[7]
|
self.track_angle_deg = data[7]
|
||||||
|
|
||||||
# Magnetic variation
|
# Magnetic variation
|
||||||
if parsed_data[9] is None or parsed_data[10] is None:
|
if data[9] is None or data[10] is None:
|
||||||
self._magnetic_variation = None
|
self._magnetic_variation = None
|
||||||
else:
|
else:
|
||||||
self._magnetic_variation = _read_degrees(parsed_data, 9, "w")
|
self._magnetic_variation = _read_degrees(data, 9, "w")
|
||||||
|
|
||||||
# Parse FAA mode indicator
|
# Parse FAA mode indicator
|
||||||
self._mode_indicator = parsed_data[11]
|
self._mode_indicator = data[11]
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _parse_gga(self, data: List[str]) -> bool:
|
def _parse_gga(self, data):
|
||||||
# GGA - Global Positioning System Fix Data
|
# GGA - Global Positioning System Fix Data
|
||||||
|
|
||||||
if data is None or len(data) != 14:
|
if data is None or len(data) != 14:
|
||||||
return False # Unexpected number of params.
|
return False # Unexpected number of params.
|
||||||
parsed_data = _parse_data(_GGA, data)
|
data = _parse_data(_GGA, data)
|
||||||
if parsed_data is None:
|
if data is None:
|
||||||
self.fix_quality = 0
|
self.fix_quality = 0
|
||||||
return False # Params didn't parse
|
return False # Params didn't parse
|
||||||
|
|
||||||
# UTC time of position
|
# UTC time of position
|
||||||
self._update_timestamp_utc(parsed_data[0])
|
self._update_timestamp_utc(int(data[0]))
|
||||||
|
|
||||||
# Latitude
|
# Latitude
|
||||||
self.latitude = _read_degrees(parsed_data, 1, "s")
|
self.latitude = _read_degrees(data, 1, "s")
|
||||||
self.longitude_degrees, self.longitude_minutes = _read_deg_mins(data=data, index=3, neg="w")
|
|
||||||
|
|
||||||
# Longitude
|
# Longitude
|
||||||
self.longitude = _read_degrees(parsed_data, 3, "w")
|
self.longitude = _read_degrees(data, 3, "w")
|
||||||
self.latitude_degrees, self.latitude_minutes = _read_deg_mins(data=data, index=1, neg="s")
|
|
||||||
|
|
||||||
# GPS quality indicator
|
# GPS quality indicator
|
||||||
self.fix_quality = parsed_data[5]
|
# 0 - fix not available,
|
||||||
|
# 1 - GPS fix,
|
||||||
|
# 2 - Differential GPS fix (values above 2 are 2.3 features)
|
||||||
|
# 3 - PPS fix
|
||||||
|
# 4 - Real Time Kinematic
|
||||||
|
# 5 - Float RTK
|
||||||
|
# 6 - estimated (dead reckoning)
|
||||||
|
# 7 - Manual input mode
|
||||||
|
# 8 - Simulation mode
|
||||||
|
self.fix_quality = data[5]
|
||||||
|
|
||||||
# Number of satellites in use, 0 - 12
|
# Number of satellites in use, 0 - 12
|
||||||
self.satellites = parsed_data[6]
|
self.satellites = data[6]
|
||||||
|
|
||||||
# Horizontal dilution of precision
|
# Horizontal dilution of precision
|
||||||
self.horizontal_dilution = parsed_data[7]
|
self.horizontal_dilution = data[7]
|
||||||
|
|
||||||
# Antenna altitude relative to mean sea level
|
# Antenna altitude relative to mean sea level
|
||||||
self.altitude_m = _parse_float(parsed_data[8])
|
self.altitude_m = _parse_float(data[8])
|
||||||
# data[9] - antenna altitude unit, always 'M' ???
|
# data[9] - antenna altitude unit, always 'M' ???
|
||||||
|
|
||||||
# Geoidal separation relative to WGS 84
|
# Geoidal separation relative to WGS 84
|
||||||
self.height_geoid = _parse_float(parsed_data[10])
|
self.height_geoid = _parse_float(data[10])
|
||||||
# data[11] - geoidal separation unit, always 'M' ???
|
# data[11] - geoidal separation unit, always 'M' ???
|
||||||
|
|
||||||
# data[12] - Age of differential GPS data, can be null
|
# data[12] - Age of differential GPS data, can be null
|
||||||
|
|
@ -649,10 +533,10 @@ class GPS:
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _parse_gsa(self, talker: bytes, data: List[str]) -> bool:
|
def _parse_gsa(self, talker, data):
|
||||||
# GSA - GPS DOP and active satellites
|
# GSA - GPS DOP and active satellites
|
||||||
|
|
||||||
if data is None or len(data) not in {17, 18}:
|
if data is None or len(data) not in (17, 18):
|
||||||
return False # Unexpected number of params.
|
return False # Unexpected number of params.
|
||||||
if len(data) == 17:
|
if len(data) == 17:
|
||||||
data = _parse_data(_GSA, data)
|
data = _parse_data(_GSA, data)
|
||||||
|
|
@ -662,7 +546,7 @@ class GPS:
|
||||||
self.fix_quality_3d = 0
|
self.fix_quality_3d = 0
|
||||||
return False # Params didn't parse
|
return False # Params didn't parse
|
||||||
|
|
||||||
talker = str(talker, "ascii")
|
talker = talker.decode("ascii")
|
||||||
|
|
||||||
# Selection mode: 'M' - manual, 'A' - automatic
|
# Selection mode: 'M' - manual, 'A' - automatic
|
||||||
self.sel_mode = data[0]
|
self.sel_mode = data[0]
|
||||||
|
|
@ -673,7 +557,7 @@ class GPS:
|
||||||
satlist = list(filter(None, data[2:-4]))
|
satlist = list(filter(None, data[2:-4]))
|
||||||
self.sat_prns = []
|
self.sat_prns = []
|
||||||
for sat in satlist:
|
for sat in satlist:
|
||||||
self.sat_prns.append(f"{talker}{sat}")
|
self.sat_prns.append("{}{}".format(talker, sat))
|
||||||
|
|
||||||
# PDOP, dilution of precision
|
# PDOP, dilution of precision
|
||||||
self.pdop = _parse_float(data[14])
|
self.pdop = _parse_float(data[14])
|
||||||
|
|
@ -688,10 +572,11 @@ class GPS:
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _parse_gsv(self, talker: bytes, data: List[str]) -> bool:
|
def _parse_gsv(self, talker, data):
|
||||||
# GSV - Satellites in view
|
# GSV - Satellites in view
|
||||||
|
# pylint: disable=too-many-branches
|
||||||
|
|
||||||
if data is None or len(data) not in {7, 11, 15, 19}:
|
if data is None or len(data) not in (7, 11, 15, 19):
|
||||||
return False # Unexpected number of params.
|
return False # Unexpected number of params.
|
||||||
data = _parse_data(
|
data = _parse_data(
|
||||||
{7: _GSV7, 11: _GSV11, 15: _GSV15, 19: _GSV19}[len(data)],
|
{7: _GSV7, 11: _GSV11, 15: _GSV15, 19: _GSV19}[len(data)],
|
||||||
|
|
@ -700,7 +585,7 @@ class GPS:
|
||||||
if data is None:
|
if data is None:
|
||||||
return False # Params didn't parse
|
return False # Params didn't parse
|
||||||
|
|
||||||
talker = str(talker, "ascii")
|
talker = talker.decode("ascii")
|
||||||
|
|
||||||
# Number of messages
|
# Number of messages
|
||||||
self.total_mess_num = data[0]
|
self.total_mess_num = data[0]
|
||||||
|
|
@ -717,7 +602,7 @@ class GPS:
|
||||||
j = i * 4
|
j = i * 4
|
||||||
value = (
|
value = (
|
||||||
# Satellite number
|
# Satellite number
|
||||||
f"{talker}{sat_tup[0 + j]}",
|
"{}{}".format(talker, sat_tup[0 + j]),
|
||||||
# Elevation in degrees
|
# Elevation in degrees
|
||||||
sat_tup[1 + j],
|
sat_tup[1 + j],
|
||||||
# Azimuth in degrees
|
# Azimuth in degrees
|
||||||
|
|
@ -745,9 +630,10 @@ class GPS:
|
||||||
# been seen for 30 seconds
|
# been seen for 30 seconds
|
||||||
timestamp = time.monotonic()
|
timestamp = time.monotonic()
|
||||||
old = []
|
old = []
|
||||||
for sat_id, sat_data in self.sats.items():
|
for i in self.sats:
|
||||||
if (timestamp - sat_data[4]) > 30:
|
sat = self.sats[i]
|
||||||
old.append(sat_id)
|
if (timestamp - sat[4]) > 30:
|
||||||
|
old.append(i)
|
||||||
for i in old:
|
for i in old:
|
||||||
self.sats.pop(i)
|
self.sats.pop(i)
|
||||||
for sat in self._sats:
|
for sat in self._sats:
|
||||||
|
|
@ -765,14 +651,11 @@ class GPS_GtopI2C(GPS):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self, i2c_bus, *, address=_GPSI2C_DEFAULT_ADDRESS, debug=False, timeout=5
|
||||||
i2c_bus: I2C,
|
):
|
||||||
*,
|
from adafruit_bus_device import ( # pylint: disable=import-outside-toplevel
|
||||||
address: int = _GPSI2C_DEFAULT_ADDRESS,
|
i2c_device,
|
||||||
debug: bool = False,
|
)
|
||||||
timeout: float = 5.0,
|
|
||||||
) -> None:
|
|
||||||
from adafruit_bus_device import i2c_device # noqa: PLC0415
|
|
||||||
|
|
||||||
super().__init__(None, debug) # init the parent with no UART
|
super().__init__(None, debug) # init the parent with no UART
|
||||||
self._i2c = i2c_device.I2CDevice(i2c_bus, address)
|
self._i2c = i2c_device.I2CDevice(i2c_bus, address)
|
||||||
|
|
@ -781,7 +664,7 @@ class GPS_GtopI2C(GPS):
|
||||||
self._internalbuffer = []
|
self._internalbuffer = []
|
||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
|
|
||||||
def read(self, num_bytes: int = 1) -> bytearray:
|
def read(self, num_bytes=1):
|
||||||
"""Read up to num_bytes of data from the GPS directly, without parsing.
|
"""Read up to num_bytes of data from the GPS directly, without parsing.
|
||||||
Returns a bytearray with up to num_bytes or None if nothing was read"""
|
Returns a bytearray with up to num_bytes or None if nothing was read"""
|
||||||
result = []
|
result = []
|
||||||
|
|
@ -797,19 +680,19 @@ class GPS_GtopI2C(GPS):
|
||||||
self._lastbyte = char # keep track of the last character approved
|
self._lastbyte = char # keep track of the last character approved
|
||||||
return bytearray(result)
|
return bytearray(result)
|
||||||
|
|
||||||
def write(self, bytestr: ReadableBuffer) -> None:
|
def write(self, bytestr):
|
||||||
"""Write a bytestring data to the GPS directly, without parsing
|
"""Write a bytestring data to the GPS directly, without parsing
|
||||||
or checksums"""
|
or checksums"""
|
||||||
with self._i2c as i2c:
|
with self._i2c as i2c:
|
||||||
i2c.write(bytestr)
|
i2c.write(bytestr)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def in_waiting(self) -> Literal[16]:
|
def in_waiting(self):
|
||||||
"""Returns number of bytes available in UART read buffer, always 16
|
"""Returns number of bytes available in UART read buffer, always 16
|
||||||
since I2C does not have the ability to know how much data is available"""
|
since I2C does not have the ability to know how much data is available"""
|
||||||
return 16
|
return 16
|
||||||
|
|
||||||
def readline(self) -> Optional[bytearray]:
|
def readline(self):
|
||||||
"""Returns a newline terminated bytearray, must have timeout set for
|
"""Returns a newline terminated bytearray, must have timeout set for
|
||||||
the underlying UART or this will block forever!"""
|
the underlying UART or this will block forever!"""
|
||||||
timeout = time.monotonic() + self._timeout
|
timeout = time.monotonic() + self._timeout
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,5 @@
|
||||||
|
|
||||||
.. If you created a package, create one automodule per module in the package.
|
.. If you created a package, create one automodule per module in the package.
|
||||||
|
|
||||||
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
|
|
||||||
.. use this format as the module name: "adafruit_foo.foo"
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
#############
|
|
||||||
|
|
||||||
.. automodule:: adafruit_gps
|
.. automodule:: adafruit_gps
|
||||||
:members:
|
:members:
|
||||||
|
|
|
||||||
31
docs/conf.py
31
docs/conf.py
|
|
@ -1,8 +1,9 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import datetime
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
@ -15,14 +16,13 @@ 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.viewcode",
|
"sphinx.ext.viewcode",
|
||||||
]
|
]
|
||||||
|
|
||||||
intersphinx_mapping = {
|
intersphinx_mapping = {
|
||||||
"python": ("https://docs.python.org/3", None),
|
"python": ("https://docs.python.org/3.4", None),
|
||||||
"CircuitPython": ("https://docs.circuitpython.org/en/latest/", None),
|
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
|
|
@ -35,12 +35,7 @@ master_doc = "index"
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = "Adafruit GPS Library"
|
project = "Adafruit GPS Library"
|
||||||
creation_year = "2017"
|
copyright = "2017 Tony DiCola, 2021 James Carr"
|
||||||
current_year = str(datetime.datetime.now().year)
|
|
||||||
year_duration = (
|
|
||||||
current_year if current_year == creation_year else creation_year + " - " + current_year
|
|
||||||
)
|
|
||||||
copyright = year_duration + " Tony DiCola, James Carr"
|
|
||||||
author = "Tony DiCola, James Carr"
|
author = "Tony DiCola, James Carr"
|
||||||
|
|
||||||
# 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
|
||||||
|
|
@ -57,7 +52,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 = "en"
|
language = None
|
||||||
|
|
||||||
# List of patterns, relative to source directory, that match files and
|
# List of patterns, relative to source directory, that match files and
|
||||||
# directories to ignore when looking for source files.
|
# directories to ignore when looking for source files.
|
||||||
|
|
@ -88,9 +83,19 @@ todo_emit_warnings = True
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
#
|
#
|
||||||
import sphinx_rtd_theme
|
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
|
||||||
|
|
||||||
html_theme = "sphinx_rtd_theme"
|
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,
|
# 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,
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,8 @@ Table of Contents
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:caption: Other Links
|
:caption: Other Links
|
||||||
|
|
||||||
Download from GitHub <https://github.com/adafruit/Adafruit_CircuitPython_GPS/releases/latest>
|
Download <https://github.com/adafruit/Adafruit_CircuitPython_GPS/releases/latest>
|
||||||
Download Library Bundle <https://circuitpython.org/libraries>
|
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
|
||||||
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>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,4 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Unlicense
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
sphinx
|
sphinx>=4.0.0
|
||||||
sphinxcontrib-jquery
|
|
||||||
sphinx-rtd-theme
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,8 @@
|
||||||
# MUST carefully follow the steps in this guide to enable writes to the
|
# MUST carefully follow the steps in this guide to enable writes to the
|
||||||
# internal filesystem:
|
# internal filesystem:
|
||||||
# https://learn.adafruit.com/adafruit-ultimate-gps-featherwing/circuitpython-library
|
# https://learn.adafruit.com/adafruit-ultimate-gps-featherwing/circuitpython-library
|
||||||
import sys
|
|
||||||
|
|
||||||
import board
|
import board
|
||||||
import busio
|
import busio
|
||||||
|
|
||||||
import adafruit_gps
|
import adafruit_gps
|
||||||
|
|
||||||
# Path to the file to log GPS data. By default this will be appended to
|
# Path to the file to log GPS data. By default this will be appended to
|
||||||
|
|
@ -28,29 +25,22 @@ LOG_FILE = "gps.txt" # Example for writing to internal path gps.txt
|
||||||
# like to erase the file and start clean each time use the value 'wb' instead.
|
# like to erase the file and start clean each time use the value 'wb' instead.
|
||||||
LOG_MODE = "ab"
|
LOG_MODE = "ab"
|
||||||
|
|
||||||
# sdcardio and adafruit_sdcard are NOT supported on blinka. If you are using a
|
# If writing to SD card on a microcontroller customize and uncomment these
|
||||||
# Raspberry Pi or other single-board linux computer, the code will save the
|
# lines to import the necessary library and initialize the SD card:
|
||||||
# output to the path defined in LOG_FILE above.
|
# NOT for use with a single board computer like Raspberry Pi!
|
||||||
if sys.platform != "linux":
|
"""
|
||||||
import storage
|
import adafruit_sdcard
|
||||||
|
import digitalio
|
||||||
|
import storage
|
||||||
|
|
||||||
SD_CS_PIN = board.D10 # CS for SD card using Adalogger Featherwing
|
SD_CS_PIN = board.D10 # CS for SD card using Adalogger Featherwing
|
||||||
try:
|
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
|
||||||
import sdcardio
|
sd_cs = digitalio.DigitalInOut(SD_CS_PIN)
|
||||||
|
sdcard = adafruit_sdcard.SDCard(spi, sd_cs)
|
||||||
sdcard = sdcardio.SDCard(board.SPI, SD_CS_PIN)
|
vfs = storage.VfsFat(sdcard)
|
||||||
except ImportError:
|
storage.mount(vfs, '/sd') # Mount SD card under '/sd' path in filesystem.
|
||||||
import adafruit_sdcard
|
LOG_FILE = '/sd/gps.txt' # Example for writing to SD card path /sd/gps.txt
|
||||||
import digitalio
|
"""
|
||||||
|
|
||||||
sdcard = adafruit_sdcard.SDCard(
|
|
||||||
board.SPI(),
|
|
||||||
digitalio.DigitalInOut(SD_CS_PIN),
|
|
||||||
)
|
|
||||||
|
|
||||||
vfs = storage.VfsFat(sdcard)
|
|
||||||
storage.mount(vfs, "/sd") # Mount SD card under '/sd' path in filesystem.
|
|
||||||
LOG_FILE = "/sd/gps.txt" # Example for writing to SD card path /sd/gps.txt
|
|
||||||
|
|
||||||
# Create a serial connection for the GPS connection using default speed and
|
# Create a serial connection for the GPS connection using default speed and
|
||||||
# a slightly higher timeout (GPS modules typically update once a second).
|
# a slightly higher timeout (GPS modules typically update once a second).
|
||||||
|
|
@ -64,8 +54,7 @@ uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
||||||
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
|
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
|
||||||
|
|
||||||
# If using I2C, we'll create an I2C interface to talk to using default pins
|
# If using I2C, we'll create an I2C interface to talk to using default pins
|
||||||
# i2c = board.I2C() # uses board.SCL and board.SDA
|
# i2c = board.I2C()
|
||||||
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
|
||||||
|
|
||||||
# Create a GPS module instance.
|
# Create a GPS module instance.
|
||||||
gps = adafruit_gps.GPS(uart) # Use UART/pyserial
|
gps = adafruit_gps.GPS(uart) # Use UART/pyserial
|
||||||
|
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2024
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
import board
|
|
||||||
from adafruit_display_text.label import Label
|
|
||||||
from displayio import Group
|
|
||||||
from terminalio import FONT
|
|
||||||
|
|
||||||
import adafruit_gps
|
|
||||||
|
|
||||||
# import busio
|
|
||||||
# uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
|
||||||
i2c = board.I2C() # uses board.SCL and board.SDA
|
|
||||||
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector
|
|
||||||
|
|
||||||
# Create a GPS module instance.
|
|
||||||
# gps = adafruit_gps.GPS(uart, debug=False) # Use UART
|
|
||||||
gps = adafruit_gps.GPS_GtopI2C(i2c, debug=False) # Use I2C interface
|
|
||||||
|
|
||||||
# Turn on the basic GGA and RMC info (what you typically want)
|
|
||||||
gps.send_command(b"PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
|
|
||||||
|
|
||||||
# Set update rate to once a second 1hz (what you typically want)
|
|
||||||
gps.send_command(b"PMTK220,1000")
|
|
||||||
|
|
||||||
|
|
||||||
# Example written for boards with built-in displays
|
|
||||||
display = board.DISPLAY
|
|
||||||
|
|
||||||
# Create a main_group to hold anything we want to show on the display.
|
|
||||||
main_group = Group()
|
|
||||||
|
|
||||||
# Create a Label to show the readings. If you have a very small
|
|
||||||
# display you may need to change to scale=1.
|
|
||||||
display_output_label = Label(FONT, text="", scale=2)
|
|
||||||
|
|
||||||
# Place the label near the top left corner with anchored positioning
|
|
||||||
display_output_label.anchor_point = (0, 0)
|
|
||||||
display_output_label.anchored_position = (4, 4)
|
|
||||||
|
|
||||||
# Add the label to the main_group
|
|
||||||
main_group.append(display_output_label)
|
|
||||||
|
|
||||||
# Set the main_group as the root_group of the display
|
|
||||||
display.root_group = main_group
|
|
||||||
|
|
||||||
|
|
||||||
last_print = time.monotonic()
|
|
||||||
|
|
||||||
# Begin main loop
|
|
||||||
while True:
|
|
||||||
gps.update()
|
|
||||||
|
|
||||||
current = time.monotonic()
|
|
||||||
# Update display data every second
|
|
||||||
if current - last_print >= 1.0:
|
|
||||||
last_print = current
|
|
||||||
if not gps.has_fix:
|
|
||||||
# Try again if we don't have a fix yet.
|
|
||||||
display_output_label.text = "Waiting for fix..."
|
|
||||||
continue
|
|
||||||
# We have a fix! (gps.has_fix is true)
|
|
||||||
t = gps.timestamp_utc
|
|
||||||
|
|
||||||
# Update the label.text property to change the text on the display
|
|
||||||
display_output_label.text = f"Timestamp (UTC): \
|
|
||||||
\n{t.tm_mday}/{t.tm_mon}/{t.tm_year} {t.tm_hour}:{t.tm_min:02}:{t.tm_sec:02}\
|
|
||||||
\nLat: {gps.latitude:.6f}\
|
|
||||||
\nLong: {gps.longitude:.6f}"
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
# Will print NMEA sentences received from the GPS, great for testing connection
|
# Will print NMEA sentences received from the GPS, great for testing connection
|
||||||
# Uses the GPS to send some commands, then reads directly from the GPS
|
# Uses the GPS to send some commands, then reads directly from the GPS
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import board
|
import board
|
||||||
import busio
|
import busio
|
||||||
|
|
||||||
|
|
@ -22,8 +21,7 @@ uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
||||||
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
|
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
|
||||||
|
|
||||||
# If using I2C, we'll create an I2C interface to talk to using default pins
|
# If using I2C, we'll create an I2C interface to talk to using default pins
|
||||||
# i2c = board.I2C() # uses board.SCL and board.SDA
|
# i2c = board.I2C()
|
||||||
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
|
||||||
|
|
||||||
# Create a GPS module instance.
|
# Create a GPS module instance.
|
||||||
gps = adafruit_gps.GPS(uart) # Use UART/pyserial
|
gps = adafruit_gps.GPS(uart) # Use UART/pyserial
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
# * GSV - Satellites in view
|
# * GSV - Satellites in view
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import board
|
import board
|
||||||
|
|
||||||
import adafruit_gps
|
import adafruit_gps
|
||||||
|
|
@ -16,7 +15,6 @@ import adafruit_gps
|
||||||
# a slightly higher timeout (GPS modules typically update once a second).
|
# a slightly higher timeout (GPS modules typically update once a second).
|
||||||
# These are the defaults you should use for the GPS FeatherWing.
|
# These are the defaults you should use for the GPS FeatherWing.
|
||||||
# For other boards set RX = GPS module TX, and TX = GPS module RX pins.
|
# For other boards set RX = GPS module TX, and TX = GPS module RX pins.
|
||||||
# import busio
|
|
||||||
# uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
# uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
||||||
|
|
||||||
# for a computer, use the pyserial library for uart access
|
# for a computer, use the pyserial library for uart access
|
||||||
|
|
@ -24,8 +22,7 @@ import adafruit_gps
|
||||||
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
|
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
|
||||||
|
|
||||||
# If using I2C, we'll create an I2C interface to talk to using default pins
|
# If using I2C, we'll create an I2C interface to talk to using default pins
|
||||||
i2c = board.I2C() # uses board.SCL and board.SDA
|
i2c = board.I2C()
|
||||||
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
|
||||||
|
|
||||||
# Create a GPS module instance.
|
# Create a GPS module instance.
|
||||||
# gps = adafruit_gps.GPS(uart, debug=False) # Use UART/pyserial
|
# gps = adafruit_gps.GPS(uart, debug=False) # Use UART/pyserial
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
# Will wait for a fix and print a message every second with the current location
|
# Will wait for a fix and print a message every second with the current location
|
||||||
# and other details.
|
# and other details.
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import board
|
import board
|
||||||
import busio
|
import busio
|
||||||
|
|
||||||
|
|
@ -15,17 +14,14 @@ import adafruit_gps
|
||||||
# a slightly higher timeout (GPS modules typically update once a second).
|
# a slightly higher timeout (GPS modules typically update once a second).
|
||||||
# These are the defaults you should use for the GPS FeatherWing.
|
# These are the defaults you should use for the GPS FeatherWing.
|
||||||
# For other boards set RX = GPS module TX, and TX = GPS module RX pins.
|
# For other boards set RX = GPS module TX, and TX = GPS module RX pins.
|
||||||
rx = board.RX # Change to board.GP4 for Raspberry Pi Pico boards
|
uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
||||||
tx = board.TX # Change to board.GP5 for Raspberry Pi Pico boards
|
|
||||||
uart = busio.UART(rx, tx, baudrate=9600, timeout=10)
|
|
||||||
|
|
||||||
# for a computer, use the pyserial library for uart access
|
# for a computer, use the pyserial library for uart access
|
||||||
# import serial
|
# import serial
|
||||||
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
|
# uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10)
|
||||||
|
|
||||||
# If using I2C, we'll create an I2C interface to talk to using default pins
|
# If using I2C, we'll create an I2C interface to talk to using default pins
|
||||||
# i2c = board.I2C() # uses board.SCL and board.SDA
|
# i2c = board.I2C()
|
||||||
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
|
||||||
|
|
||||||
# Create a GPS module instance.
|
# Create a GPS module instance.
|
||||||
gps = adafruit_gps.GPS(uart, debug=False) # Use UART/pyserial
|
gps = adafruit_gps.GPS(uart, debug=False) # Use UART/pyserial
|
||||||
|
|
@ -39,8 +35,6 @@ gps = adafruit_gps.GPS(uart, debug=False) # Use UART/pyserial
|
||||||
|
|
||||||
# Turn on the basic GGA and RMC info (what you typically want)
|
# Turn on the basic GGA and RMC info (what you typically want)
|
||||||
gps.send_command(b"PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
|
gps.send_command(b"PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
|
||||||
# Turn on the basic GGA and RMC info + VTG for speed in km/h
|
|
||||||
# gps.send_command(b"PMTK314,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
|
|
||||||
# Turn on just minimum info (RMC only, location):
|
# Turn on just minimum info (RMC only, location):
|
||||||
# gps.send_command(b'PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
|
# gps.send_command(b'PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
|
||||||
# Turn off everything:
|
# Turn off everything:
|
||||||
|
|
@ -77,7 +71,7 @@ while True:
|
||||||
# Print out details about the fix like location, date, etc.
|
# Print out details about the fix like location, date, etc.
|
||||||
print("=" * 40) # Print a separator line.
|
print("=" * 40) # Print a separator line.
|
||||||
print(
|
print(
|
||||||
"Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}".format( # noqa: UP032
|
"Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}".format(
|
||||||
gps.timestamp_utc.tm_mon, # Grab parts of the time from the
|
gps.timestamp_utc.tm_mon, # Grab parts of the time from the
|
||||||
gps.timestamp_utc.tm_mday, # struct_time object that holds
|
gps.timestamp_utc.tm_mday, # struct_time object that holds
|
||||||
gps.timestamp_utc.tm_year, # the fix time. Note you might
|
gps.timestamp_utc.tm_year, # the fix time. Note you might
|
||||||
|
|
@ -86,24 +80,20 @@ while True:
|
||||||
gps.timestamp_utc.tm_sec,
|
gps.timestamp_utc.tm_sec,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print(f"Latitude: {gps.latitude:.6f} degrees")
|
print("Latitude: {0:.6f} degrees".format(gps.latitude))
|
||||||
print(f"Longitude: {gps.longitude:.6f} degrees")
|
print("Longitude: {0:.6f} degrees".format(gps.longitude))
|
||||||
print(f"Precise Latitude: {gps.latitude_degrees} degs, {gps.latitude_minutes:2.4f} mins")
|
print("Fix quality: {}".format(gps.fix_quality))
|
||||||
print(f"Precise Longitude: {gps.longitude_degrees} degs, {gps.longitude_minutes:2.4f} mins")
|
|
||||||
print(f"Fix quality: {gps.fix_quality}")
|
|
||||||
# Some attributes beyond latitude, longitude and timestamp are optional
|
# Some attributes beyond latitude, longitude and timestamp are optional
|
||||||
# and might not be present. Check if they're None before trying to use!
|
# and might not be present. Check if they're None before trying to use!
|
||||||
if gps.satellites is not None:
|
if gps.satellites is not None:
|
||||||
print(f"# satellites: {gps.satellites}")
|
print("# satellites: {}".format(gps.satellites))
|
||||||
if gps.altitude_m is not None:
|
if gps.altitude_m is not None:
|
||||||
print(f"Altitude: {gps.altitude_m} meters")
|
print("Altitude: {} meters".format(gps.altitude_m))
|
||||||
if gps.speed_knots is not None:
|
if gps.speed_knots is not None:
|
||||||
print(f"Speed: {gps.speed_knots} knots")
|
print("Speed: {} knots".format(gps.speed_knots))
|
||||||
if gps.speed_kmh is not None:
|
|
||||||
print(f"Speed: {gps.speed_kmh} km/h")
|
|
||||||
if gps.track_angle_deg is not None:
|
if gps.track_angle_deg is not None:
|
||||||
print(f"Track angle: {gps.track_angle_deg} degrees")
|
print("Track angle: {} degrees".format(gps.track_angle_deg))
|
||||||
if gps.horizontal_dilution is not None:
|
if gps.horizontal_dilution is not None:
|
||||||
print(f"Horizontal dilution: {gps.horizontal_dilution}")
|
print("Horizontal dilution: {}".format(gps.horizontal_dilution))
|
||||||
if gps.height_geoid is not None:
|
if gps.height_geoid is not None:
|
||||||
print(f"Height geoid: {gps.height_geoid} meters")
|
print("Height geoid: {} meters".format(gps.height_geoid))
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,9 @@
|
||||||
# time while there is powersource (ie coin cell battery)
|
# time while there is powersource (ie coin cell battery)
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import board
|
import board
|
||||||
import busio
|
import busio
|
||||||
import rtc
|
import rtc
|
||||||
|
|
||||||
import adafruit_gps
|
import adafruit_gps
|
||||||
|
|
||||||
uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
||||||
|
|
@ -28,13 +26,19 @@ the_rtc = rtc.RTC()
|
||||||
|
|
||||||
|
|
||||||
def _format_datetime(datetime):
|
def _format_datetime(datetime):
|
||||||
date_part = f"{datetime.tm_mon:02}/{datetime.tm_mday:02}/{datetime.tm_year}"
|
return "{:02}/{:02}/{} {:02}:{:02}:{:02}".format(
|
||||||
time_part = f"{datetime.tm_hour:02}:{datetime.tm_min:02}:{datetime.tm_sec:02}"
|
datetime.tm_mon,
|
||||||
return f"{date_part} {time_part}"
|
datetime.tm_mday,
|
||||||
|
datetime.tm_year,
|
||||||
|
datetime.tm_hour,
|
||||||
|
datetime.tm_min,
|
||||||
|
datetime.tm_sec,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
last_print = time.monotonic()
|
last_print = time.monotonic()
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
gps.update()
|
gps.update()
|
||||||
# Every second print out current time from GPS, RTC and time.localtime()
|
# Every second print out current time from GPS, RTC and time.localtime()
|
||||||
current = time.monotonic()
|
current = time.monotonic()
|
||||||
|
|
@ -44,12 +48,12 @@ while True:
|
||||||
print("No time data from GPS yet")
|
print("No time data from GPS yet")
|
||||||
continue
|
continue
|
||||||
# Time & date from GPS informations
|
# Time & date from GPS informations
|
||||||
print(f"Fix timestamp: {_format_datetime(gps.timestamp_utc)}")
|
print("Fix timestamp: {}".format(_format_datetime(gps.timestamp_utc)))
|
||||||
|
|
||||||
# Time & date from internal RTC
|
# Time & date from internal RTC
|
||||||
print(f"RTC timestamp: {_format_datetime(the_rtc.datetime)}")
|
print("RTC timestamp: {}".format(_format_datetime(the_rtc.datetime)))
|
||||||
|
|
||||||
# Time & date from time.localtime() function
|
# Time & date from time.localtime() function
|
||||||
local_time = time.localtime()
|
local_time = time.localtime()
|
||||||
|
|
||||||
print(f"Local time: {_format_datetime(local_time)}")
|
print("Local time: {}".format(_format_datetime(local_time)))
|
||||||
|
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2022 Alec Delaney for Adafruit Industries
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
[build-system]
|
|
||||||
requires = [
|
|
||||||
"setuptools",
|
|
||||||
"wheel",
|
|
||||||
"setuptools-scm",
|
|
||||||
]
|
|
||||||
|
|
||||||
[project]
|
|
||||||
name = "adafruit-circuitpython-gps"
|
|
||||||
description = "CircuitPython library for GPS modules."
|
|
||||||
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_GPS"}
|
|
||||||
keywords = [
|
|
||||||
"adafruit",
|
|
||||||
"gps",
|
|
||||||
"module",
|
|
||||||
"latitude",
|
|
||||||
"longitude",
|
|
||||||
"breakout",
|
|
||||||
"hardware",
|
|
||||||
"micropython",
|
|
||||||
"circuitpython",
|
|
||||||
]
|
|
||||||
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_gps"]
|
|
||||||
|
|
||||||
[tool.setuptools.dynamic]
|
|
||||||
dependencies = {file = ["requirements.txt"]}
|
|
||||||
optional-dependencies = {optional = {file = ["optional_requirements.txt"]}}
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
# SPDX-FileCopyrightText: 2021 Jonas Kittner
|
# SPDX-FileCopyrightText: 2021 Jonas Kittner
|
||||||
# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
|
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Unlicense
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
adafruit-circuitpython-sd
|
|
||||||
covdefaults
|
covdefaults
|
||||||
coverage
|
coverage
|
||||||
freezegun
|
freezegun
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
|
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Unlicense
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
Adafruit-Blinka
|
Adafruit-Blinka
|
||||||
adafruit-circuitpython-busdevice
|
|
||||||
pyserial
|
pyserial
|
||||||
adafruit-circuitpython-typing
|
adafruit-circuitpython-busdevice
|
||||||
typing-extensions~=4.0
|
|
||||||
|
|
|
||||||
108
ruff.toml
108
ruff.toml
|
|
@ -1,108 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
target-version = "py38"
|
|
||||||
line-length = 100
|
|
||||||
|
|
||||||
[lint]
|
|
||||||
preview = true
|
|
||||||
select = ["I", "PL", "UP"]
|
|
||||||
|
|
||||||
extend-select = [
|
|
||||||
"D419", # empty-docstring
|
|
||||||
"E501", # line-too-long
|
|
||||||
"W291", # trailing-whitespace
|
|
||||||
"PLC0414", # useless-import-alias
|
|
||||||
"PLC2401", # non-ascii-name
|
|
||||||
"PLC2801", # unnecessary-dunder-call
|
|
||||||
"PLC3002", # unnecessary-direct-lambda-call
|
|
||||||
"E999", # syntax-error
|
|
||||||
"PLE0101", # return-in-init
|
|
||||||
"F706", # return-outside-function
|
|
||||||
"F704", # yield-outside-function
|
|
||||||
"PLE0116", # continue-in-finally
|
|
||||||
"PLE0117", # nonlocal-without-binding
|
|
||||||
"PLE0241", # duplicate-bases
|
|
||||||
"PLE0302", # unexpected-special-method-signature
|
|
||||||
"PLE0604", # invalid-all-object
|
|
||||||
"PLE0605", # invalid-all-format
|
|
||||||
"PLE0643", # potential-index-error
|
|
||||||
"PLE0704", # misplaced-bare-raise
|
|
||||||
"PLE1141", # dict-iter-missing-items
|
|
||||||
"PLE1142", # await-outside-async
|
|
||||||
"PLE1205", # logging-too-many-args
|
|
||||||
"PLE1206", # logging-too-few-args
|
|
||||||
"PLE1307", # bad-string-format-type
|
|
||||||
"PLE1310", # bad-str-strip-call
|
|
||||||
"PLE1507", # invalid-envvar-value
|
|
||||||
"PLE2502", # bidirectional-unicode
|
|
||||||
"PLE2510", # invalid-character-backspace
|
|
||||||
"PLE2512", # invalid-character-sub
|
|
||||||
"PLE2513", # invalid-character-esc
|
|
||||||
"PLE2514", # invalid-character-nul
|
|
||||||
"PLE2515", # invalid-character-zero-width-space
|
|
||||||
"PLR0124", # comparison-with-itself
|
|
||||||
"PLR0202", # no-classmethod-decorator
|
|
||||||
"PLR0203", # no-staticmethod-decorator
|
|
||||||
"UP004", # useless-object-inheritance
|
|
||||||
"PLR0206", # property-with-parameters
|
|
||||||
"PLR0904", # too-many-public-methods
|
|
||||||
"PLR0911", # too-many-return-statements
|
|
||||||
"PLR0912", # too-many-branches
|
|
||||||
"PLR0913", # too-many-arguments
|
|
||||||
"PLR0914", # too-many-locals
|
|
||||||
"PLR0915", # too-many-statements
|
|
||||||
"PLR0916", # too-many-boolean-expressions
|
|
||||||
"PLR1702", # too-many-nested-blocks
|
|
||||||
"PLR1704", # redefined-argument-from-local
|
|
||||||
"PLR1711", # useless-return
|
|
||||||
"C416", # unnecessary-comprehension
|
|
||||||
"PLR1733", # unnecessary-dict-index-lookup
|
|
||||||
"PLR1736", # unnecessary-list-index-lookup
|
|
||||||
|
|
||||||
# ruff reports this rule is unstable
|
|
||||||
#"PLR6301", # no-self-use
|
|
||||||
|
|
||||||
"PLW0108", # unnecessary-lambda
|
|
||||||
"PLW0120", # useless-else-on-loop
|
|
||||||
"PLW0127", # self-assigning-variable
|
|
||||||
"PLW0129", # assert-on-string-literal
|
|
||||||
"B033", # duplicate-value
|
|
||||||
"PLW0131", # named-expr-without-context
|
|
||||||
"PLW0245", # super-without-brackets
|
|
||||||
"PLW0406", # import-self
|
|
||||||
"PLW0602", # global-variable-not-assigned
|
|
||||||
"PLW0603", # global-statement
|
|
||||||
"PLW0604", # global-at-module-level
|
|
||||||
|
|
||||||
# fails on the try: import typing used by libraries
|
|
||||||
#"F401", # unused-import
|
|
||||||
|
|
||||||
"F841", # unused-variable
|
|
||||||
"E722", # bare-except
|
|
||||||
"PLW0711", # binary-op-exception
|
|
||||||
"PLW1501", # bad-open-mode
|
|
||||||
"PLW1508", # invalid-envvar-default
|
|
||||||
"PLW1509", # subprocess-popen-preexec-fn
|
|
||||||
"PLW2101", # useless-with-lock
|
|
||||||
"PLW3301", # nested-min-max
|
|
||||||
]
|
|
||||||
|
|
||||||
ignore = [
|
|
||||||
"PLR2004", # magic-value-comparison
|
|
||||||
"UP030", # format literals
|
|
||||||
"PLW1514", # unspecified-encoding
|
|
||||||
"PLR0913", # too-many-arguments
|
|
||||||
"PLR0915", # too-many-statements
|
|
||||||
"PLR0917", # too-many-positional-arguments
|
|
||||||
"PLR0904", # too-many-public-methods
|
|
||||||
"PLR0912", # too-many-branches
|
|
||||||
"PLR0916", # too-many-boolean-expressions
|
|
||||||
]
|
|
||||||
|
|
||||||
[lint.per-file-ignores]
|
|
||||||
"tests/adafruit_gps_test.py" = ["PLC2701"]
|
|
||||||
|
|
||||||
[format]
|
|
||||||
line-ending = "lf"
|
|
||||||
60
setup.py
Normal file
60
setup.py
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
"""A setuptools based setup module.
|
||||||
|
|
||||||
|
See:
|
||||||
|
https://packaging.python.org/en/latest/distributing.html
|
||||||
|
https://github.com/pypa/sampleproject
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Always prefer setuptools over distutils
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
# To use a consistent encoding
|
||||||
|
from codecs import open
|
||||||
|
from os import path
|
||||||
|
|
||||||
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
|
||||||
|
# Get the long description from the README file
|
||||||
|
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
|
||||||
|
long_description = f.read()
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="adafruit-circuitpython-gps",
|
||||||
|
use_scm_version=True,
|
||||||
|
setup_requires=["setuptools_scm"],
|
||||||
|
description="CircuitPython library for GPS modules.",
|
||||||
|
long_description=long_description,
|
||||||
|
long_description_content_type="text/x-rst",
|
||||||
|
# The project's main homepage.
|
||||||
|
url="https://github.com/adafruit/Adafruit_CircuitPython_GPS",
|
||||||
|
# Author details
|
||||||
|
author="Adafruit Industries",
|
||||||
|
author_email="circuitpython@adafruit.com",
|
||||||
|
install_requires=[
|
||||||
|
"pyserial",
|
||||||
|
"Adafruit-Blinka",
|
||||||
|
"adafruit-circuitpython-busdevice",
|
||||||
|
],
|
||||||
|
# Choose your license
|
||||||
|
license="MIT",
|
||||||
|
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||||
|
classifiers=[
|
||||||
|
"Development Status :: 3 - Alpha",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"Topic :: Software Development :: Libraries",
|
||||||
|
"Topic :: System :: Hardware",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.4",
|
||||||
|
"Programming Language :: Python :: 3.5",
|
||||||
|
],
|
||||||
|
# What does your project relate to?
|
||||||
|
keywords="adafruit gps module latitude longitude breakout hardware micropython circuitpython",
|
||||||
|
# You can just specify the packages manually here if your project is
|
||||||
|
# simple. Or you can use find_packages().
|
||||||
|
py_modules=["adafruit_gps"],
|
||||||
|
)
|
||||||
|
|
@ -1,31 +1,29 @@
|
||||||
|
# pylint: disable=missing-function-docstring,missing-module-docstring,invalid-name,protected-access,no-self-use,missing-class-docstring
|
||||||
|
|
||||||
# SPDX-FileCopyrightText: 2021 Jonas Kittner
|
# SPDX-FileCopyrightText: 2021 Jonas Kittner
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
import time
|
import time
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
import pytest
|
||||||
|
|
||||||
from adafruit_gps import (
|
from adafruit_gps import _parse_degrees
|
||||||
GPS,
|
from adafruit_gps import _parse_int
|
||||||
_parse_data,
|
from adafruit_gps import _parse_float
|
||||||
_parse_degrees,
|
from adafruit_gps import _parse_str
|
||||||
_parse_float,
|
from adafruit_gps import _read_degrees
|
||||||
_parse_int,
|
from adafruit_gps import _parse_talker
|
||||||
_parse_str,
|
from adafruit_gps import _parse_data
|
||||||
_parse_talker,
|
from adafruit_gps import GPS
|
||||||
_read_deg_mins,
|
|
||||||
_read_degrees,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("val", "exp"),
|
("val", "exp"),
|
||||||
(
|
(
|
||||||
pytest.param("0023.456", 390933, id="leading zero"),
|
pytest.param("0023.456", 0.390933, id="leading zero"),
|
||||||
pytest.param("6413.9369", 64232281, id="regular value"),
|
pytest.param("6413.9369", 64.23228, id="regular value"),
|
||||||
pytest.param("2747.416122087989", 27790268, id="long value"),
|
pytest.param("2747.416122087989", 27.79027, id="long value"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_parse_degrees(val, exp):
|
def test_parse_degrees(val, exp):
|
||||||
|
|
@ -63,10 +61,10 @@ def test_parse_float_invalid(val):
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("data", "neg", "exp"),
|
("data", "neg", "exp"),
|
||||||
(
|
(
|
||||||
pytest.param([27790270, "S"], "s", -27.79027, id="south negative"),
|
pytest.param([27.79027, "S"], "s", -27.79027, id="south negative"),
|
||||||
pytest.param([64232280, "N"], "s", 64.23228, id="north not negative"),
|
pytest.param([64.23228, "N"], "s", 64.23228, id="north not negative"),
|
||||||
pytest.param([123456700, "W"], "w", -123.4567, id="west negative"),
|
pytest.param([123.4567, "W"], "w", -123.4567, id="west negative"),
|
||||||
pytest.param([10789100, "E"], "w", 10.7891, id="east not negative"),
|
pytest.param([10.7891, "E"], "w", 10.7891, id="east not negative"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_read_degrees(data, neg, exp):
|
def test_read_degrees(data, neg, exp):
|
||||||
|
|
@ -116,7 +114,7 @@ def test_parse_data_unexpected_parameter_type():
|
||||||
class UartMock:
|
class UartMock:
|
||||||
"""mocking the UART connection an its methods"""
|
"""mocking the UART connection an its methods"""
|
||||||
|
|
||||||
def write(self, bytestr): # noqa: PLR6301
|
def write(self, bytestr):
|
||||||
print(bytestr, end="")
|
print(bytestr, end="")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -142,14 +140,14 @@ def test_GPS_update_timestamp_UTC_date_None():
|
||||||
assert gps.datetime is None
|
assert gps.datetime is None
|
||||||
assert gps.timestamp_utc is None
|
assert gps.timestamp_utc is None
|
||||||
exp_struct = time.struct_time((0, 0, 0, 22, 14, 11, 0, 0, -1))
|
exp_struct = time.struct_time((0, 0, 0, 22, 14, 11, 0, 0, -1))
|
||||||
gps._update_timestamp_utc(time_utc="221411")
|
gps._update_timestamp_utc(time_utc=221411)
|
||||||
assert gps.timestamp_utc == exp_struct
|
assert gps.timestamp_utc == exp_struct
|
||||||
|
|
||||||
|
|
||||||
def test_GPS_update_timestamp_UTC_date_not_None():
|
def test_GPS_update_timestamp_UTC_date_not_None():
|
||||||
gps = GPS(uart=UartMock())
|
gps = GPS(uart=UartMock())
|
||||||
exp_struct = time.struct_time((2021, 10, 2, 22, 14, 11, 0, 0, -1))
|
exp_struct = time.struct_time((2021, 10, 2, 22, 14, 11, 0, 0, -1))
|
||||||
gps._update_timestamp_utc(time_utc="221411", date="021021")
|
gps._update_timestamp_utc(time_utc=221411, date=21021)
|
||||||
assert gps.timestamp_utc == exp_struct
|
assert gps.timestamp_utc == exp_struct
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -159,7 +157,7 @@ def test_GPS_update_timestamp_timestamp_utc_was_not_none_new_date_none():
|
||||||
gps.timestamp_utc = time.struct_time((2021, 10, 2, 22, 10, 11, 0, 0, -1))
|
gps.timestamp_utc = time.struct_time((2021, 10, 2, 22, 10, 11, 0, 0, -1))
|
||||||
exp_struct = time.struct_time((2021, 10, 2, 22, 14, 11, 0, 0, -1))
|
exp_struct = time.struct_time((2021, 10, 2, 22, 14, 11, 0, 0, -1))
|
||||||
# update the timestamp
|
# update the timestamp
|
||||||
gps._update_timestamp_utc(time_utc="221411")
|
gps._update_timestamp_utc(time_utc=221411)
|
||||||
assert gps.timestamp_utc == exp_struct
|
assert gps.timestamp_utc == exp_struct
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -179,10 +177,6 @@ def test_GPS_update_rmc_no_magnetic_variation():
|
||||||
assert gps.timestamp_utc == exp_time
|
assert gps.timestamp_utc == exp_time
|
||||||
assert gps.latitude == pytest.approx(12.57613)
|
assert gps.latitude == pytest.approx(12.57613)
|
||||||
assert gps.longitude == pytest.approx(1.385391)
|
assert gps.longitude == pytest.approx(1.385391)
|
||||||
assert gps.latitude_degrees == 12
|
|
||||||
assert gps.longitude_degrees == 1
|
|
||||||
assert gps.latitude_minutes == 34.5678
|
|
||||||
assert gps.longitude_minutes == 23.12345
|
|
||||||
assert gps.fix_quality == 1
|
assert gps.fix_quality == 1
|
||||||
assert gps.fix_quality_3d == 0
|
assert gps.fix_quality_3d == 0
|
||||||
assert gps.speed_knots == 0.45
|
assert gps.speed_knots == 0.45
|
||||||
|
|
@ -203,8 +197,12 @@ def test_GPS_update_rmc_no_magnetic_variation():
|
||||||
|
|
||||||
|
|
||||||
def test_GPS_update_rmc_fix_is_set():
|
def test_GPS_update_rmc_fix_is_set():
|
||||||
r_valid = b"$GPRMC,215032.086,A,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A*6A\r\n"
|
r_valid = (
|
||||||
r_invalid = b"$GPRMC,215032.086,V,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A*7D\r\n"
|
b"$GPRMC,215032.086,A,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A*6A\r\n"
|
||||||
|
)
|
||||||
|
r_invalid = (
|
||||||
|
b"$GPRMC,215032.086,V,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A*7D\r\n"
|
||||||
|
)
|
||||||
with mock.patch.object(GPS, "readline", return_value=r_valid):
|
with mock.patch.object(GPS, "readline", return_value=r_valid):
|
||||||
gps = GPS(uart=UartMock())
|
gps = GPS(uart=UartMock())
|
||||||
assert gps.update()
|
assert gps.update()
|
||||||
|
|
@ -218,7 +216,9 @@ def test_GPS_update_rmc_fix_is_set():
|
||||||
|
|
||||||
|
|
||||||
def test_GPS_update_rmc_fix_is_set_new():
|
def test_GPS_update_rmc_fix_is_set_new():
|
||||||
r_valid = b"$GPRMC,215032.086,A,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A*6A\r\n"
|
r_valid = (
|
||||||
|
b"$GPRMC,215032.086,A,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A*6A\r\n"
|
||||||
|
)
|
||||||
r_invalid = b"$GPRMC,215032.086,V,ABC,N,00123.12345,E,0.45,56.35,021021,,,A*1B\r\n"
|
r_invalid = b"$GPRMC,215032.086,V,ABC,N,00123.12345,E,0.45,56.35,021021,,,A*1B\r\n"
|
||||||
with mock.patch.object(GPS, "readline", return_value=r_valid):
|
with mock.patch.object(GPS, "readline", return_value=r_valid):
|
||||||
gps = GPS(uart=UartMock())
|
gps = GPS(uart=UartMock())
|
||||||
|
|
@ -285,8 +285,11 @@ def test_GPS_update_rmc_debug_shows_sentence(capsys):
|
||||||
gps = GPS(uart=UartMock(), debug=True)
|
gps = GPS(uart=UartMock(), debug=True)
|
||||||
assert gps.update()
|
assert gps.update()
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
assert not err
|
assert err == ""
|
||||||
assert out == "('GPRMC', '215032.086,A,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A')\n"
|
assert (
|
||||||
|
out
|
||||||
|
== "('GPRMC', '215032.086,A,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A')\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_GPS_update_data_type_too_short():
|
def test_GPS_update_data_type_too_short():
|
||||||
|
|
@ -300,7 +303,7 @@ def test_GPS_send_command_with_checksum(capsys):
|
||||||
gps = GPS(uart=UartMock())
|
gps = GPS(uart=UartMock())
|
||||||
gps.send_command(command=b"$PMTK001,314,3\r\n", add_checksum=True)
|
gps.send_command(command=b"$PMTK001,314,3\r\n", add_checksum=True)
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
assert not err
|
assert err == ""
|
||||||
assert out == ("b'$'" "b'$PMTK001,314,3\\r\\n'" "b'*'" "b'15'" "b'\\r\\n'")
|
assert out == ("b'$'" "b'$PMTK001,314,3\\r\\n'" "b'*'" "b'15'" "b'\\r\\n'")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -308,7 +311,7 @@ def test_GPS_send_command_without_checksum(capsys):
|
||||||
gps = GPS(uart=UartMock())
|
gps = GPS(uart=UartMock())
|
||||||
gps.send_command(command=b"$PMTK001,314,3\r\n", add_checksum=False)
|
gps.send_command(command=b"$PMTK001,314,3\r\n", add_checksum=False)
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
assert not err
|
assert err == ""
|
||||||
assert out == ("b'$'" "b'$PMTK001,314,3\\r\\n'" "b'\\r\\n'")
|
assert out == ("b'$'" "b'$PMTK001,314,3\\r\\n'" "b'\\r\\n'")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -321,10 +324,6 @@ def test_GPS_update_from_GLL():
|
||||||
assert gps.timestamp_utc == exp_time
|
assert gps.timestamp_utc == exp_time
|
||||||
assert gps.latitude == pytest.approx(49.27417)
|
assert gps.latitude == pytest.approx(49.27417)
|
||||||
assert gps.longitude == pytest.approx(-123.1853)
|
assert gps.longitude == pytest.approx(-123.1853)
|
||||||
assert gps.latitude_degrees == 49
|
|
||||||
assert gps.longitude_degrees == -123
|
|
||||||
assert gps.latitude_minutes == 16.45
|
|
||||||
assert gps.longitude_minutes == 11.12
|
|
||||||
assert gps.isactivedata == "A"
|
assert gps.isactivedata == "A"
|
||||||
assert gps._mode_indicator == "A"
|
assert gps._mode_indicator == "A"
|
||||||
assert gps.fix_quality == 0
|
assert gps.fix_quality == 0
|
||||||
|
|
@ -336,7 +335,7 @@ def test_GPS_update_from_GLL():
|
||||||
|
|
||||||
|
|
||||||
def test_GPS_update_from_RMC():
|
def test_GPS_update_from_RMC():
|
||||||
r = b"$GNRMC,001031.00,A,4404.1399,N,12118.8602,W,0.146,084.4,100117,,,A*5d\r\n"
|
r = b"$GNRMC,001031.00,A,4404.13993,N,12118.86023,W,0.146,084.4,100117,,,A*5d\r\n"
|
||||||
# TODO: length 13 and 14 version
|
# TODO: length 13 and 14 version
|
||||||
with mock.patch.object(GPS, "readline", return_value=r):
|
with mock.patch.object(GPS, "readline", return_value=r):
|
||||||
gps = GPS(uart=UartMock())
|
gps = GPS(uart=UartMock())
|
||||||
|
|
@ -350,10 +349,6 @@ def test_GPS_update_from_RMC():
|
||||||
assert gps.has_3d_fix is False
|
assert gps.has_3d_fix is False
|
||||||
assert gps.latitude == pytest.approx(44.069)
|
assert gps.latitude == pytest.approx(44.069)
|
||||||
assert gps.longitude == pytest.approx(-121.3143)
|
assert gps.longitude == pytest.approx(-121.3143)
|
||||||
assert gps.latitude_degrees == 44
|
|
||||||
assert gps.longitude_degrees == -121
|
|
||||||
assert gps.latitude_minutes == 4.1399
|
|
||||||
assert gps.longitude_minutes == 18.8602
|
|
||||||
assert gps.speed_knots == 0.146
|
assert gps.speed_knots == 0.146
|
||||||
assert gps.track_angle_deg == 84.4
|
assert gps.track_angle_deg == 84.4
|
||||||
assert gps._magnetic_variation is None
|
assert gps._magnetic_variation is None
|
||||||
|
|
@ -369,10 +364,6 @@ def test_GPS_update_from_GGA():
|
||||||
assert gps.timestamp_utc == exp_time
|
assert gps.timestamp_utc == exp_time
|
||||||
assert gps.latitude == pytest.approx(48.1173)
|
assert gps.latitude == pytest.approx(48.1173)
|
||||||
assert gps.longitude == pytest.approx(11.51667)
|
assert gps.longitude == pytest.approx(11.51667)
|
||||||
assert gps.latitude_degrees == 48
|
|
||||||
assert gps.longitude_degrees == 11
|
|
||||||
assert gps.latitude_minutes == 7.038
|
|
||||||
assert gps.longitude_minutes == 31.000
|
|
||||||
assert gps.fix_quality == 1
|
assert gps.fix_quality == 1
|
||||||
assert gps.fix_quality_3d == 0
|
assert gps.fix_quality_3d == 0
|
||||||
assert gps.satellites == 8
|
assert gps.satellites == 8
|
||||||
|
|
@ -383,17 +374,21 @@ def test_GPS_update_from_GGA():
|
||||||
assert gps.has_3d_fix is False
|
assert gps.has_3d_fix is False
|
||||||
assert gps.datetime == exp_time
|
assert gps.datetime == exp_time
|
||||||
assert (
|
assert (
|
||||||
gps._raw_sentence == "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"
|
gps._raw_sentence
|
||||||
|
== "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
gps.nmea_sentence == "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"
|
gps.nmea_sentence
|
||||||
|
== "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"r",
|
"r",
|
||||||
(
|
(
|
||||||
pytest.param(b"$GPGSA,A,3,15,18,14,,,31,,,23,,,,04.5,02.1,04.0*0f\r\n", id="smaller v4.1"),
|
pytest.param(
|
||||||
|
b"$GPGSA,A,3,15,18,14,,,31,,,23,,,,04.5,02.1,04.0*0f\r\n", id="smaller v4.1"
|
||||||
|
),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
b"$GPGSA,A,3,15,18,14,,,31,,,23,,,,04.5,02.1,04.0,3*10\r\n",
|
b"$GPGSA,A,3,15,18,14,,,31,,,23,,,,04.5,02.1,04.0,3*10\r\n",
|
||||||
id="greater v4.1",
|
id="greater v4.1",
|
||||||
|
|
@ -472,19 +467,3 @@ def test_GPS_update_from_GSV_both_parts_sats_are_removed():
|
||||||
assert gps.update()
|
assert gps.update()
|
||||||
assert gps.satellites == 2
|
assert gps.satellites == 2
|
||||||
assert set(gps.sats.keys()) == {"GP12", "GP14", "GP13", "GP15"}
|
assert set(gps.sats.keys()) == {"GP12", "GP14", "GP13", "GP15"}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
("input_str", "exp", "neg"),
|
|
||||||
(
|
|
||||||
(["3723.2475", "n"], (37, 23.2475), "s"),
|
|
||||||
(["3723.2475", "s"], (-37, 23.2475), "s"),
|
|
||||||
(["00123.1234", "e"], (1, 23.1234), "w"),
|
|
||||||
(["00123", "e"], (1, 23), "w"),
|
|
||||||
(["1234.5678", "e"], (12, 34.5678), "w"),
|
|
||||||
(["3723.2475123", "n"], (37, 23.2475123), "s"),
|
|
||||||
(["3723", "n"], (37, 23), "s"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
def test_read_min_secs(input_str, exp, neg):
|
|
||||||
assert _read_deg_mins(data=input_str, index=0, neg=neg) == exp
|
|
||||||
|
|
|
||||||
13
tox.ini
Normal file
13
tox.ini
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# SPDX-FileCopyrightText: 2021 Jonas Kittner
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
[tox]
|
||||||
|
envlist = py37
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
deps = -rrequirements-dev.txt
|
||||||
|
|
||||||
|
commands =
|
||||||
|
coverage erase
|
||||||
|
coverage run -m pytest tests/
|
||||||
|
coverage report
|
||||||
Loading…
Reference in a new issue