Types needed for type annotation that are not in
Author(s): Alec Delaney, Dan Halbert, Randy Hudson
Classes that implement alarms for sleeping and asynchronous notification. You can use these alarms to wake up from light or deep sleep.
- class circuitpython_typing.BlockDevice(*args, **kwargs)¶
Protocol for block device objects to enable a device to support CircuitPython filesystems. Classes which implement this protocol include
- ioctl(operation: int, arg: int | None = None) int | None ¶
Control the block device and query its parameters. The operation to perform is given by
operationwhich is one of the following integers:
1 - initialise the device (
2 - shutdown the device (
3 - sync the device (
4 - get a count of the number of blocks, should return an integer (
- 5 - get the number of bytes in a block, should return an integer,
Nonein which case the default value of 512 is used (
6 - erase a block, arg is the block number to erase
As a minimum
ioctl(4, ...)must be intercepted; for littlefs
ioctl(6, ...)must also be intercepted. The need for others is hardware dependent.
Prior to any call to
writeblocks(block, ...)littlefs issues
ioctl(6, block). This enables a device driver to erase the block prior to a write if the hardware requires it. Alternatively a driver might intercept
ioctl(6, block)and return 0 (success). In this case the driver assumes responsibility for detecting the need for erasure.
Unless otherwise stated
ioctl(operation, arg)can return
None. Consequently an implementation can ignore unused values of
operationis intercepted, the return value for operations 4 and 5 are as detailed above. Other operations should return 0 on success and non-zero for failure, with the value returned being an
- readblocks(block_num: int, buf: bytearray) None ¶
Read aligned, multiples of blocks. Starting at the block given by the index
block_num, read blocks from the device into
buf(an array of bytes). The number of blocks to read is given by the length of
buf, which will be a multiple of the block size.
- writeblocks(block_num: int, buf: bytearray) None ¶
Write aligned, multiples of blocks, and require that the blocks that are written to be first erased (if necessary) by this method. Starting at the block given by the index
block_num, write blocks from
buf(an array of bytes) to the device. The number of blocks to write is given by the length of
buf, which will be a multiple of the block size.
- class circuitpython_typing.ByteStream(*args, **kwargs)¶
- read(count: int | None = None) bytes | None ¶
countbytes from the stream. If
countbytes are not immediately available, or if the parameter is not specified in the call, the outcome is implementation-dependent.
- circuitpython_typing.FrameBuffer: TypeAlias = ForwardRef('rgbmatrix.RGBMatrix')¶
Classes that implement the framebuffer protocol.
Classes that implement the readable buffer protocol.
Classes that implement the writeable buffer protocol.
Type annotation definitions for sockets. Used for
adafruit_requests and similar libraries.
Author(s): Kevin Conley
- class circuitpython_typing.socket.CircuitPythonSocketType(*args, **kwargs)¶
Describes the structure every modern CircuitPython socket type must have.
- class circuitpython_typing.socket.CommonCircuitPythonSocketType(*args, **kwargs)¶
Describes the common structure every CircuitPython socket type must have.
- class circuitpython_typing.socket.CommonSocketType(*args, **kwargs)¶
Describes the common structure every socket type must have.
- send(data: bytes, flags: int = Ellipsis) None ¶
Send data to the socket. The meaning of the optional flags kwarg is implementation-specific.
- class circuitpython_typing.socket.InterfaceType(*args, **kwargs)¶
Describes the structure every interface type must have.
- class circuitpython_typing.socket.LegacyCircuitPythonSocketType(*args, **kwargs)¶
Describes the structure a legacy CircuitPython socket type must have.
- class circuitpython_typing.socket.StandardPythonSocketType(*args, **kwargs)¶
Describes the structure every standard Python socket type must have.
- class circuitpython_typing.socket.SupportsRecvInto(*args, **kwargs)¶
Describes a type that possesses a socket recv_into() method.
- recv_into(buffer: bytearray, nbytes: int = Ellipsis, flags: int = Ellipsis) int ¶
Receive up to nbytes bytes from the socket, storing the data into the provided buffer. If nbytes is not specified (or 0), receive up to the size available in the given buffer. The meaning of the optional flags kwarg is implementation-specific. Returns the number of bytes received.
- class circuitpython_typing.socket.SupportsRecvWithFlags(*args, **kwargs)¶
Describes a type that posseses a socket recv() method supporting the flags kwarg.
- recv(bufsize: int = Ellipsis, flags: int = Ellipsis) bytes ¶
Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by bufsize. The meaning of the optional flags kwarg is implementation-specific.