47
47
48
48
try :
49
49
from typing import Optional
50
- from digitalio import DigitalInOut
50
+ from circuitpython_typing import ReadableBuffer
51
51
from microcontroller import Pin
52
52
from busio import SPI
53
53
except ImportError :
@@ -99,7 +99,7 @@ class VS1053:
99
99
# This is NOT thread/re-entrant safe (by design, for less memory hit).
100
100
_SCI_SPI_BUFFER = bytearray (4 )
101
101
102
- def __init__ (self , spi : SPI , cs : DigitalInOut , xdcs : Pin , dreq : Pin ) -> None :
102
+ def __init__ (self , spi : SPI , cs : Pin , xdcs : Pin , dreq : Pin ) -> None :
103
103
# Create SPI device for VS1053
104
104
self ._cs = digitalio .DigitalInOut (cs )
105
105
self ._vs1053_spi = SPIDevice (
@@ -118,7 +118,7 @@ def __init__(self, spi: SPI, cs: DigitalInOut, xdcs: Pin, dreq: Pin) -> None:
118
118
f"Expected version 4 (VS1053) but got: { self .version } Check wiring!"
119
119
)
120
120
121
- def _sci_write (self , address , value ) -> None :
121
+ def _sci_write (self , address : int , value : int ) -> None :
122
122
# Write a 16-bit big-endian value to the provided 8-bit address.
123
123
self ._SCI_SPI_BUFFER [0 ] = _VS1053_SCI_WRITE
124
124
self ._SCI_SPI_BUFFER [1 ] = address & 0xFF
@@ -218,7 +218,7 @@ def stop_playback(self) -> None:
218
218
)
219
219
220
220
def play_data (
221
- self , data_buffer : bytearray , start : int = 0 , end : Optional [int ] = None
221
+ self , data_buffer : ReadableBuffer , start : int = 0 , end : Optional [int ] = None
222
222
):
223
223
"""Send a buffer of file data to the VS1053 for playback. Make sure
224
224
the ready_for_data property is True before calling!
@@ -235,7 +235,7 @@ def play_data(
235
235
finally :
236
236
self ._xdcs .value = True
237
237
238
- def sine_test (self , n : int , seconds : int ) :
238
+ def sine_test (self , n : int , seconds : float ) -> None :
239
239
"""Play a sine wave for the specified number of seconds. Useful to
240
240
test the VS1053 is working.
241
241
"""
0 commit comments