diff options
| author | HiFiPhile <[email protected]> | 2024-05-12 13:57:17 +0200 |
|---|---|---|
| committer | HiFiPhile <[email protected]> | 2024-05-12 13:57:17 +0200 |
| commit | 08f9e4e0c8f95b28207603309974e6f15cfee87e (patch) | |
| tree | 31bcdcf97c0bc7fa95155792b8bbb0d4f39f9e20 | |
| parent | 256ccc47571b36dd8f5aaeaebe583cb7640a4b8d (diff) | |
Hint missing import, exit on error.
| -rw-r--r-- | examples/device/uac2_speaker_fb/src/audio_debug.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/device/uac2_speaker_fb/src/audio_debug.py b/examples/device/uac2_speaker_fb/src/audio_debug.py index 182d6ca89..336c46c01 100644 --- a/examples/device/uac2_speaker_fb/src/audio_debug.py +++ b/examples/device/uac2_speaker_fb/src/audio_debug.py @@ -1,8 +1,13 @@ # Install python3 HID package https://pypi.org/project/hid/ -import hid +# Install python3 matplotlib package https://pypi.org/project/matplotlib/ + from ctypes import * -import matplotlib.pyplot as plt -import matplotlib.animation as animation +try: + import hid + import matplotlib.pyplot as plt + import matplotlib.animation as animation +except: + print("Missing import, please try 'pip install hid matplotlib' or consult your OS's python package manager.") # Example must be compiled with CFG_AUDIO_DEBUG=1 VID = 0xcafe @@ -32,15 +37,16 @@ if dev: def animate(i): info = None for i in range(30): - str_in = dev.read(64, 10) - if str_in: + try: + str_in = dev.read(64, 50) info = audio_debug_info_t.from_buffer_copy(str_in) global fifo_avg global fifo_cnt fifo_avg.append(info.fifo_count_avg) fifo_cnt.append(info.fifo_count) - + except: + exit(1) # Limit to 1000 items fifo_avg = fifo_avg[-1000:] fifo_cnt = fifo_cnt[-1000:] |
