Skip to content

Commit 0f28c94

Browse files
Chris Nourseclaude
andcommitted
chore: pre-commit fixups (locale, ruff-format, trailing whitespace)
Auto-applied by pre-commit ahead of upstream PR: - locale/circuitpython.pot regenerated to include the new audioio MP_ERROR_TEXT strings ("DAC init error", "TIM6 init failed", etc.) - ruff-format reflow on the manual audioio test scripts - Trailing whitespace stripped from results.md No source-of-record changes; behaviour and APIs are identical. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2e97b27 commit 0f28c94

6 files changed

Lines changed: 121 additions & 48 deletions

File tree

locale/circuitpython.pot

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,18 @@ msgstr ""
630630
msgid "Audio source error"
631631
msgstr ""
632632

633+
#: ports/stm/common-hal/audioio/AudioOut.c
634+
msgid "AudioOut is deinited"
635+
msgstr ""
636+
637+
#: ports/stm/common-hal/audioio/AudioOut.c
638+
msgid "AudioOut requires pin A0 (PA04)"
639+
msgstr ""
640+
641+
#: ports/stm/common-hal/audioio/AudioOut.c
642+
msgid "AudioOut right channel requires pin A1 (PA05)"
643+
msgstr ""
644+
633645
#: shared-bindings/wifi/Radio.c
634646
msgid "AuthMode.OPEN is not used with password"
635647
msgstr ""
@@ -892,6 +904,14 @@ msgstr ""
892904
msgid "DAC Channel Init Error"
893905
msgstr ""
894906

907+
#: ports/stm/common-hal/audioio/AudioOut.c
908+
msgid "DAC DMA start failed"
909+
msgstr ""
910+
911+
#: ports/stm/common-hal/audioio/AudioOut.c
912+
msgid "DAC DMA start failed (right channel)"
913+
msgstr ""
914+
895915
#: ports/stm/common-hal/analogio/AnalogOut.c
896916
msgid "DAC Device Init Error"
897917
msgstr ""
@@ -900,6 +920,22 @@ msgstr ""
900920
msgid "DAC already in use"
901921
msgstr ""
902922

923+
#: ports/stm/common-hal/audioio/AudioOut.c
924+
msgid "DAC channel config error"
925+
msgstr ""
926+
927+
#: ports/stm/common-hal/audioio/AudioOut.c
928+
msgid "DAC init error"
929+
msgstr ""
930+
931+
#: ports/stm/common-hal/audioio/AudioOut.c
932+
msgid "DMA init failed"
933+
msgstr ""
934+
935+
#: ports/stm/common-hal/audioio/AudioOut.c
936+
msgid "DMA init failed (right)"
937+
msgstr ""
938+
903939
#: ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.c
904940
#: ports/nordic/common-hal/paralleldisplaybus/ParallelBus.c
905941
msgid "Data 0 pin must be byte aligned"
@@ -1541,6 +1577,7 @@ msgstr ""
15411577

15421578
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
15431579
#: ports/stm/common-hal/analogio/AnalogOut.c
1580+
#: ports/stm/common-hal/audioio/AudioOut.c
15441581
msgid "No DAC on chip"
15451582
msgstr ""
15461583

@@ -2109,6 +2146,14 @@ msgstr ""
21092146
msgid "System entry must be gnss.SatelliteSystem"
21102147
msgstr ""
21112148

2149+
#: ports/stm/common-hal/audioio/AudioOut.c
2150+
msgid "TIM6 init failed"
2151+
msgstr ""
2152+
2153+
#: ports/stm/common-hal/audioio/AudioOut.c
2154+
msgid "TIM6 master cfg failed"
2155+
msgstr ""
2156+
21122157
#: ports/stm/common-hal/microcontroller/Processor.c
21132158
msgid "Temperature read timed out"
21142159
msgstr ""
@@ -4049,7 +4094,7 @@ msgstr ""
40494094
msgid "output array must be contiguous"
40504095
msgstr ""
40514096

4052-
#: py/objint_mpz.c
4097+
#: py/objint_longlong.c py/objint_mpz.c
40534098
msgid "overflow converting long int to machine word"
40544099
msgstr ""
40554100

@@ -4162,6 +4207,10 @@ msgstr ""
41624207
msgid "rsplit(None,n)"
41634208
msgstr ""
41644209

4210+
#: ports/stm/common-hal/audioio/AudioOut.c
4211+
msgid "sample_rate must be > 0"
4212+
msgstr ""
4213+
41654214
#: shared-bindings/audiofreeverb/Freeverb.c
41664215
msgid "samples_signed must be true"
41674216
msgstr ""

tests/circuitpython-manual/audioio/results.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ Copying files to board via /Volumes/CIRCUITPY ...
2424
============================================================
2525
Output:
2626
playing jeplayer-splash-44100-16bit-mono-signed.wav
27-
27+
2828
playing jeplayer-splash-44100-16bit-stereo-signed.wav
29-
29+
3030
playing jeplayer-splash-8000-16bit-mono-signed.wav
31-
31+
3232
playing jeplayer-splash-8000-16bit-stereo-signed.wav
33-
33+
3434
playing jeplayer-splash-8000-8bit-mono-unsigned.wav
35-
35+
3636
done
3737
[PASS] played jeplayer-splash-44100-16bit-mono-signed.wav
3838
[PASS] played jeplayer-splash-44100-16bit-stereo-signed.wav
@@ -124,7 +124,7 @@ Output:
124124
resumed
125125
paused
126126
resumed
127-
127+
128128
playing with pause/resume: jeplayer-splash-44100-16bit-stereo-signed.wav
129129
paused
130130
resumed
@@ -198,7 +198,7 @@ Output:
198198
resumed
199199
paused
200200
resumed
201-
201+
202202
playing with pause/resume: jeplayer-splash-8000-16bit-mono-signed.wav
203203
paused
204204
resumed
@@ -270,7 +270,7 @@ Output:
270270
resumed
271271
paused
272272
resumed
273-
273+
274274
playing with pause/resume: jeplayer-splash-8000-16bit-stereo-signed.wav
275275
paused
276276
resumed
@@ -342,7 +342,7 @@ Output:
342342
resumed
343343
paused
344344
resumed
345-
345+
346346
playing with pause/resume: jeplayer-splash-8000-8bit-mono-unsigned.wav
347347
paused
348348
resumed
@@ -414,7 +414,7 @@ Output:
414414
resumed
415415
paused
416416
resumed
417-
417+
418418
done
419419
[PASS] pause/resume header for jeplayer-splash-44100-16bit-mono-signed.wav
420420
[PASS] pause/resume header for jeplayer-splash-44100-16bit-stereo-signed.wav
@@ -433,13 +433,13 @@ Output:
433433
============================================================
434434
Output:
435435
unsigned 8 bit
436-
436+
437437
signed 8 bit
438-
438+
439439
unsigned 16 bit
440-
440+
441441
signed 16 bit
442-
442+
443443
done
444444
[PASS] 'unsigned 8 bit' label printed
445445
[PASS] 'signed 8 bit' label printed
@@ -461,17 +461,17 @@ Output:
461461
============================================================
462462
Output:
463463
channel test: left only
464-
464+
465465
channel test: right only
466-
466+
467467
channel test: both channels
468-
468+
469469
pan sweep: left to right
470-
470+
471471
playing stereo: jeplayer-splash-44100-16bit-stereo-signed.wav
472-
472+
473473
playing stereo: jeplayer-splash-8000-16bit-stereo-signed.wav
474-
474+
475475
done
476476
[PASS] Left-only channel tone played
477477
[PASS] Right-only channel tone played

tests/circuitpython-manual/audioio/run_serial_tests.py

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
# mpremote helpers
6767
# ---------------------------------------------------------------------------
6868

69+
6970
def _mpremote(args: list, timeout: float = 30.0):
7071
"""Run an mpremote command, return (stdout, stderr). Raises on timeout."""
7172
try:
@@ -214,7 +215,12 @@ def find_port() -> str:
214215
# Fall back to any USB serial port that isn't Bluetooth/wlan
215216
for line in stdout.splitlines():
216217
parts = line.split()
217-
if parts and parts[0].startswith("/dev/") and "Bluetooth" not in line and "wlan" not in line:
218+
if (
219+
parts
220+
and parts[0].startswith("/dev/")
221+
and "Bluetooth" not in line
222+
and "wlan" not in line
223+
):
218224
return parts[0]
219225
raise RuntimeError(
220226
"No board detected. Connect the board and/or pass --port.\n"
@@ -225,16 +231,19 @@ def find_port() -> str:
225231
def find_circuitpy() -> str | None:
226232
"""Return the path to the mounted CIRCUITPY volume, or None if not found."""
227233
import platform
234+
228235
system = platform.system()
229236

230237
if system == "Darwin":
231238
# Glob so a second CIRCUITPY volume (mounted as "CIRCUITPY 1") is found.
232239
import glob
240+
233241
candidates = sorted(glob.glob("/Volumes/CIRCUITPY*"))
234242
elif system == "Windows":
235243
# Scan all drive letters for a CIRCUITPY volume label.
236244
import string
237245
import ctypes
246+
238247
candidates = []
239248
kernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined]
240249
buf = ctypes.create_unicode_buffer(256)
@@ -248,6 +257,7 @@ def find_circuitpy() -> str | None:
248257
candidates = ["/media/CIRCUITPY", "/run/media/CIRCUITPY"]
249258
try:
250259
import pwd
260+
251261
user = pwd.getpwuid(os.getuid()).pw_name
252262
candidates.insert(0, f"/run/media/{user}/CIRCUITPY")
253263
candidates.insert(0, f"/media/{user}/CIRCUITPY")
@@ -267,10 +277,9 @@ def copy_files(port: str, circuitpy: str | None = None):
267277
print(f"Copying files to board via {mount} ...")
268278
else:
269279
print("Copying files to board via mpremote ...")
270-
files = (
271-
[(os.path.join(AUDIOCORE_DIR, w), w) for w in WAV_FILES]
272-
+ [(os.path.join(SCRIPT_DIR, s), s) for s in TEST_SCRIPTS]
273-
)
280+
files = [(os.path.join(AUDIOCORE_DIR, w), w) for w in WAV_FILES] + [
281+
(os.path.join(SCRIPT_DIR, s), s) for s in TEST_SCRIPTS
282+
]
274283
# Check if device has enough space for test files
275284
if mount:
276285
needed = 0
@@ -285,11 +294,10 @@ def copy_files(port: str, circuitpy: str | None = None):
285294
if needed > free:
286295
short = needed - free
287296
print(f"ERROR: not enough space on {mount}.")
288-
print(f" need: {needed/1024:.1f} KiB")
289-
print(f" free: {free/1024:.1f} KiB")
290-
print(f" short: {short/1024:.1f} KiB")
291-
print(f" Delete unrelated files (e.g. an old code.py or "
292-
f"stale WAVs) and re-run.")
297+
print(f" need: {needed / 1024:.1f} KiB")
298+
print(f" free: {free / 1024:.1f} KiB")
299+
print(f" short: {short / 1024:.1f} KiB")
300+
print(f" Delete unrelated files (e.g. an old code.py or stale WAVs) and re-run.")
293301
sys.exit(1)
294302
missing = []
295303
for src, dst in files:
@@ -301,9 +309,7 @@ def copy_files(port: str, circuitpy: str | None = None):
301309
shutil.copy2(src, dest_path)
302310
print(f" {dst} (copied)")
303311
else:
304-
stdout, stderr = _mpremote(
305-
["connect", port, "fs", "cp", src, f":/{dst}"], timeout=30
306-
)
312+
stdout, stderr = _mpremote(["connect", port, "fs", "cp", src, f":/{dst}"], timeout=30)
307313
if stderr and "Error" in stderr:
308314
print(f" {dst} (FAILED: {stderr.strip()})")
309315
else:
@@ -349,9 +355,7 @@ def _run_exec(port: str, code: str, label: str, timeout: float, retries: int = 3
349355
print(f" [retry {attempt}/{retries}] port {port} not present — waited 10s")
350356
continue
351357
try:
352-
stdout, stderr = _mpremote(
353-
["connect", port, "exec", code], timeout=timeout
354-
)
358+
stdout, stderr = _mpremote(["connect", port, "exec", code], timeout=timeout)
355359
except TimeoutError as exc:
356360
print(f" [FAIL] {exc}")
357361
return False, "", ""
@@ -397,6 +401,7 @@ def _settle_between_tests(port: str) -> None:
397401
# Individual tests
398402
# ---------------------------------------------------------------------------
399403

404+
400405
def test1_wavefile_playback(port: str) -> bool:
401406
code = 'exec(open("/wavefile_playback.py").read())'
402407
ok, stdout, stderr = _run_exec(
@@ -422,7 +427,9 @@ def test2_pause_resume(port: str) -> bool:
422427
return False
423428
passed = True
424429
for wav in sorted(WAV_FILES):
425-
passed &= _check(f"playing with pause/resume: {wav}" in stdout, f"pause/resume header for {wav}")
430+
passed &= _check(
431+
f"playing with pause/resume: {wav}" in stdout, f"pause/resume header for {wav}"
432+
)
426433
passed &= _check("paused" in stdout, "At least one 'paused' line printed")
427434
passed &= _check("resumed" in stdout, "At least one 'resumed' line printed")
428435
passed &= _check("TIMEOUT" not in stdout, "No pause/resume hang timeout")
@@ -459,8 +466,14 @@ def test5_stereo_playback(port: str) -> bool:
459466
passed &= _check("channel test: right only" in stdout, "Right-only channel tone played")
460467
passed &= _check("channel test: both channels" in stdout, "Both-channel tone played")
461468
passed &= _check("pan sweep: left to right" in stdout, "Pan sweep played")
462-
passed &= _check("playing stereo: jeplayer-splash-44100-16bit-stereo-signed.wav" in stdout, "44100 Hz 16-bit stereo WAV played")
463-
passed &= _check("playing stereo: jeplayer-splash-8000-16bit-stereo-signed.wav" in stdout, "8000 Hz 16-bit stereo WAV played")
469+
passed &= _check(
470+
"playing stereo: jeplayer-splash-44100-16bit-stereo-signed.wav" in stdout,
471+
"44100 Hz 16-bit stereo WAV played",
472+
)
473+
passed &= _check(
474+
"playing stereo: jeplayer-splash-8000-16bit-stereo-signed.wav" in stdout,
475+
"8000 Hz 16-bit stereo WAV played",
476+
)
464477
passed &= _check("done" in stdout, "Script completed with 'done'")
465478
passed &= _check(not stderr, f"No exceptions (stderr={stderr!r})")
466479
return passed
@@ -482,6 +495,7 @@ def test4_deinit(port: str) -> bool:
482495
# Main
483496
# ---------------------------------------------------------------------------
484497

498+
485499
def main():
486500
parser = argparse.ArgumentParser(
487501
description=__doc__,

tests/circuitpython-manual/audioio/single_buffer_loop.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@
4848
dac = audioio.AudioOut(board.A0)
4949
for sample, name in zip(samples, sample_names):
5050
print(name)
51-
if trigger: trigger.value = False
51+
if trigger:
52+
trigger.value = False
5253
dac.play(sample, loop=True)
5354
time.sleep(1)
5455
dac.stop()
5556
time.sleep(0.1)
56-
if trigger: trigger.value = True
57+
if trigger:
58+
trigger.value = True
5759
print()
5860

5961
dac.deinit()

0 commit comments

Comments
 (0)