Skip to content

Commit 108a35d

Browse files
author
Alec Delaney
committed
Merge branch 'main' of https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground into dev/iterable-io-rework
2 parents 3c707f6 + 1ea6f32 commit 108a35d

File tree

11 files changed

+148
-83
lines changed

11 files changed

+148
-83
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit
4848
- name: Library version
4949
run: git describe --dirty --always --tags
50+
- name: Setup problem matchers
51+
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1
5052
- name: Pre-commit hooks
5153
run: |
5254
pre-commit run --all-files
@@ -60,16 +62,16 @@ jobs:
6062
- name: Build docs
6163
working-directory: docs
6264
run: sphinx-build -E -W -b html . _build/html
63-
- name: Check For setup.py
65+
- name: Check For pyproject.toml
6466
id: need-pypi
6567
run: |
66-
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
68+
echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' )
6769
- name: Build Python package
68-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
70+
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
6971
run: |
70-
pip install --upgrade setuptools wheel twine readme_renderer testresources
71-
python setup.py sdist
72-
python setup.py bdist_wheel --universal
72+
pip install --upgrade build twine
73+
for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do
74+
sed -i -e "s/0.0.0+auto.0/1.2.3/" $file;
75+
done;
76+
python -m build
7377
twine check dist/*
74-
- name: Setup problem matchers
75-
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1

.github/workflows/release.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,28 @@ jobs:
6161
runs-on: ubuntu-latest
6262
steps:
6363
- uses: actions/checkout@v1
64-
- name: Check For setup.py
64+
- name: Check For pyproject.toml
6565
id: need-pypi
6666
run: |
67-
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
67+
echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' )
6868
- name: Set up Python
69-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
69+
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
7070
uses: actions/setup-python@v2
7171
with:
7272
python-version: '3.x'
7373
- name: Install dependencies
74-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
74+
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
7575
run: |
7676
python -m pip install --upgrade pip
77-
pip install setuptools wheel twine
77+
pip install --upgrade build twine
7878
- name: Build and publish
79-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
79+
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
8080
env:
8181
TWINE_USERNAME: ${{ secrets.pypi_username }}
8282
TWINE_PASSWORD: ${{ secrets.pypi_password }}
8383
run: |
84-
python setup.py sdist
84+
for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do
85+
sed -i -e "s/0.0.0+auto.0/${{github.event.release.tag_name}}/" $file;
86+
done;
87+
python -m build
8588
twine upload dist/*

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Introduction
1414
:target: https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/actions/
1515
:alt: Build Status
1616

17+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
18+
:target: https://github.com/psf/black
19+
:alt: Code Style: Black
20+
1721
This high level library provides objects that represent Circuit Playground Express and Bluefruit hardware.
1822

1923
.. image :: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/main/docs/_static/circuit_playground_express_small.jpg

adafruit_circuitplayground/bluefruit.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
* `Circuit Playground Bluefruit <https://www.adafruit.com/product/4333>`_
1919
2020
"""
21+
try:
22+
import typing # pylint: disable=unused-import
23+
except ImportError:
24+
pass
2125

2226
import array
2327
import math
@@ -29,7 +33,7 @@
2933
from adafruit_circuitplayground.circuit_playground_base import CircuitPlaygroundBase
3034

3135

32-
__version__ = "0.0.0-auto.0"
36+
__version__ = "0.0.0+auto.0"
3337
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground.git"
3438

3539

@@ -38,7 +42,7 @@ class Bluefruit(CircuitPlaygroundBase):
3842

3943
_audio_out = audiopwmio.PWMAudioOut
4044

41-
def __init__(self):
45+
def __init__(self) -> None:
4246
# Only create the cpb module member when we aren't being imported by Sphinx
4347
if (
4448
"__module__" in dir(digitalio.DigitalInOut)
@@ -60,7 +64,7 @@ def __init__(self):
6064
self._samples = None
6165

6266
@staticmethod
63-
def _normalized_rms(values):
67+
def _normalized_rms(values) -> float:
6468
mean_values = int(sum(values) / len(values))
6569
return math.sqrt(
6670
sum(
@@ -71,7 +75,7 @@ def _normalized_rms(values):
7175
)
7276

7377
@property
74-
def sound_level(self):
78+
def sound_level(self) -> float:
7579
"""Obtain the sound level from the microphone (sound sensor).
7680
7781
.. image :: ../docs/_static/microphone.jpg
@@ -92,7 +96,7 @@ def sound_level(self):
9296
self._mic.record(self._samples, len(self._samples))
9397
return self._normalized_rms(self._samples)
9498

95-
def loud_sound(self, sound_threshold=200):
99+
def loud_sound(self, sound_threshold: int = 200) -> bool:
96100
"""Utilise a loud sound as an input.
97101
98102
:param int sound_threshold: Threshold sound level must exceed to return true (Default: 200)
@@ -134,7 +138,7 @@ def loud_sound(self, sound_threshold=200):
134138

135139
return self.sound_level > sound_threshold
136140

137-
def play_mp3(self, file_name):
141+
def play_mp3(self, file_name: str) -> None:
138142
"""Play a .mp3 file using the onboard speaker.
139143
140144
:param file_name: The name of your .mp3 file in quotation marks including .mp3

0 commit comments

Comments
 (0)