22# Install python3 HID package https://pypi.org/project/hid/
33# Install python3 matplotlib package https://pypi.org/project/matplotlib/
44
5- from ctypes import *
5+ from ctypes import Structure , c_uint32 , c_uint8 , c_int8 , c_int16 , c_uint16
6+ import signal
67try :
78 import hid
89 import matplotlib .pyplot as plt
910 import matplotlib .animation as animation
1011except :
1112 print ("Missing import, please try 'pip install hid matplotlib' or consult your OS's python package manager." )
13+ exit (1 )
1214
1315# Example must be compiled with CFG_AUDIO_DEBUG=1
1416VID = 0xcafe
@@ -29,6 +31,7 @@ class audio_debug_info_t (Structure):
2931dev = hid .Device (VID , PID )
3032
3133if dev :
34+ signal .signal (signal .SIGINT , signal .SIG_DFL )
3235 # Create figure for plotting
3336 fig = plt .figure ()
3437 ax = fig .add_subplot (1 , 1 , 1 )
@@ -61,10 +64,10 @@ def animate(i):
6164 ax .set_ylim (bottom = 0 , top = info .fifo_size )
6265
6366 # Format plot
64- plt . title ('FIFO information' )
65- plt .grid ()
67+ ax . set_title ('FIFO information' )
68+ ax .grid (True )
6669
6770 print (f'Sample rate:{ info .sample_rate } | Alt settings:{ info .alt_settings } | Volume:{ info .volume [:]} ' )
6871
69- ani = animation .FuncAnimation (fig , animate , interval = 10 )
70- plt .show ()
72+ ani = animation .FuncAnimation (fig , animate , interval = 10 , cache_frame_data = False ) # type: ignore
73+ plt .show (block = True )
0 commit comments