28
28
from micropython import const
29
29
30
30
try :
31
- from typing import Optional
31
+ from typing import Optional , Literal
32
32
import circuitpython_typing
33
33
import busio
34
34
except ImportError :
@@ -112,12 +112,12 @@ def version(self) -> str:
112
112
return str (self ._buffer [:readlen ], "ascii" )
113
113
114
114
@property
115
- def baudrate (self ) -> int :
115
+ def baudrate (self ) -> Literal [ 9600 , 19200 , 38400 , 57600 , 115200 ] :
116
116
"""Return the currently configured baud rate."""
117
117
return self ._uart .baudrate
118
118
119
119
@baudrate .setter
120
- def baudrate (self , baud : int ) -> None :
120
+ def baudrate (self , baud : Literal [ 9600 , 19200 , 38400 , 57600 , 115200 ] ) -> None :
121
121
"""Set the baudrate to 9600, 19200, 38400, 57600, or 115200."""
122
122
divider = None
123
123
if baud == 9600 :
@@ -184,7 +184,7 @@ def resume_video(self) -> bool:
184
184
"""
185
185
return self ._run_command (_FBUF_CTRL , bytes ([0x1 , _RESUMEFRAME ]), 5 )
186
186
187
- def read_picture_into (self , buf : bytearray ) -> int :
187
+ def read_picture_into (self , buf : circuitpython_typing . WriteableBuffer ) -> int :
188
188
"""Read the next bytes of frame/picture data into the provided buffer.
189
189
Returns the number of bytes written to the buffer (might be less than
190
190
the size of the buffer). Buffer MUST be a multiple of 4 and 100 or
@@ -252,7 +252,7 @@ def _run_command(
252
252
return True
253
253
254
254
def _read_response (
255
- self , result : circuitpython_typing .ReadableBuffer , numbytes : int
255
+ self , result : circuitpython_typing .WriteableBuffer , numbytes : int
256
256
) -> Optional [int ]:
257
257
return self ._uart .readinto (memoryview (result )[0 :numbytes ])
258
258
@@ -265,7 +265,7 @@ def _verify_response(self, cmd: int) -> bool:
265
265
)
266
266
267
267
def _send_command (
268
- self , cmd : int , args : Optional [circuitpython_typing .WriteableBuffer ] = None
268
+ self , cmd : int , args : Optional [circuitpython_typing .ReadableBuffer ] = None
269
269
) -> None :
270
270
self ._command_header [0 ] = 0x56
271
271
self ._command_header [1 ] = _SERIAL
0 commit comments