Did busio, fixed up analogio

This commit is contained in:
dherrada 2020-07-02 10:23:17 -04:00
parent 6fd6747e9e
commit cb259de5ef
6 changed files with 42 additions and 41 deletions

View File

@ -86,7 +86,7 @@ STATIC void check_for_deinit(analogio_analogin_obj_t *self) {
raise_deinited_error();
}
}
//| def __enter__(self, ) -> None:
//| def __enter__(self, ) -> AnalogIn:
//| """No-op used by Context Managers."""
//| ...
//|

View File

@ -79,7 +79,7 @@ STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogout_deinit);
//| def __enter__(self, ) -> None:
//| def __enter__(self, ) -> AnalogOut:
//| """No-op used by Context Managers."""
//| ...
//|

View File

@ -83,7 +83,7 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con
return (mp_obj_t)self;
}
//| def deinit(self, ) -> Any:
//| def deinit(self, ) -> None:
//| """Releases control of the underlying hardware so other classes can use it."""
//| ...
//|
@ -100,13 +100,13 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) {
}
}
//| def __enter__(self, ) -> Any:
//| def __enter__(self, ) -> I2C:
//| """No-op used in Context Managers."""
//| ...
//|
// Provided by context manager helper.
//| def __exit__(self, ) -> Any:
//| def __exit__(self, ) -> None:
//| """Automatically deinitializes the hardware on context exit. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@ -125,7 +125,7 @@ static void check_lock(busio_i2c_obj_t *self) {
}
}
//| def scan(self, ) -> Any:
//| def scan(self, ) -> list:
//|
//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a
//| list of those that respond.
@ -150,7 +150,7 @@ STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan);
//| def try_lock(self, ) -> Any:
//| def try_lock(self, ) -> bool:
//| """Attempts to grab the I2C lock. Returns True on success.
//|
//| :return: True when lock has been grabbed
@ -164,7 +164,7 @@ STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock);
//| def unlock(self, ) -> Any:
//| def unlock(self, ) -> none:
//| """Releases the I2C lock."""
//| ...
//|
@ -176,7 +176,7 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock);
//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any:
//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> None:
//| """Read into ``buffer`` from the device selected by ``address``.
//| The number of bytes read will be the length of ``buffer``.
//| At least one byte must be read.
@ -228,7 +228,7 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args,
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into);
//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any:
//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> None:
//| """Write the bytes from ``buffer`` to the device selected by ``address``.
//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be
//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and
@ -287,7 +287,7 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto);
//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any:
//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> None:
//| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop
//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
//| ``in_buffer`` can be the same buffer because they are used sequentially.

View File

@ -77,7 +77,7 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(self);
}
//| def deinit(self, ) -> Any:
//| def deinit(self, ) -> None:
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
//| ...
//|
@ -94,13 +94,13 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) {
}
}
//| def __enter__(self, ) -> Any:
//| def __enter__(self, ) -> OneWire:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
//| def __exit__(self, ) -> Any:
//| def __exit__(self, ) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@ -112,7 +112,7 @@ STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__);
//| def reset(self, ) -> Any:
//| def reset(self, ) -> bool:
//| """Reset the OneWire bus and read presence
//|
//| :returns: False when at least one device is present
@ -127,7 +127,7 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
//| def read_bit(self, ) -> Any:
//| def read_bit(self, ) -> bool:
//| """Read in a bit
//|
//| :returns: bit state read
@ -142,7 +142,7 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit);
//| def write_bit(self, value: Any) -> Any:
//| def write_bit(self, value: bool) -> None:
//| """Write out a bit based on value."""
//| ...
//|

View File

@ -100,7 +100,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con
return MP_OBJ_FROM_PTR(self);
}
//| def deinit(self, ) -> Any:
//| def deinit(self, ) -> None:
//| """Turn off the SPI bus."""
//| ...
//|
@ -111,13 +111,13 @@ STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit);
//| def __enter__(self, ) -> Any:
//| def __enter__(self, ) -> SPI:
//| """No-op used by Context Managers.
//| Provided by context manager helper."""
//| ...
//|
//| def __exit__(self, ) -> Any:
//| def __exit__(self, ) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@ -142,7 +142,7 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) {
}
}
//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any:
//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> None:
//| """Configures the SPI bus. The SPI object must be locked.
//|
//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower
@ -201,7 +201,7 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure);
//| def try_lock(self, ) -> Any:
//| def try_lock(self, ) -> bool:
//| """Attempts to grab the SPI lock. Returns True on success.
//|
//| :return: True when lock has been grabbed
@ -215,7 +215,7 @@ STATIC mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock);
//| def unlock(self, ) -> Any:
//| def unlock(self, ) -> None:
//| """Releases the SPI lock."""
//| ...
//|
@ -228,7 +228,7 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock);
//| def write(self, buffer: bytearray, *, start: Any = 0, end: int = None) -> Any:
//| def write(self, buffer: bytes, *, start: int = 0, end: int = None) -> None:
//| """Write the data contained in ``buffer``. The SPI object must be locked.
//| If the buffer is empty, nothing happens.
//|
@ -270,7 +270,7 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write);
//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any:
//| def readinto(self, buffer: bytearray, *, start: int = 0, end: int = None, write_value: int = 0) -> None:
//| """Read into ``buffer`` while writing ``write_value`` for each byte read.
//| The SPI object must be locked.
//| If the number of bytes to read is 0, nothing happens.
@ -314,7 +314,7 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto);
//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any:
//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: int = 0, out_end: int = None, in_start: None = 0, in_end: int = None) -> None:
//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``.
//| The SPI object must be locked.
//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]``
@ -377,7 +377,7 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto);
//| frequency: Any = ...
//| frequency: int = ...
//| """The actual SPI bus frequency. This may not match the frequency requested
//| due to internal limitations."""
//|

View File

@ -142,7 +142,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
return (mp_obj_t)self;
}
//| def deinit(self, ) -> Any:
//| def deinit(self, ) -> None:
//| """Deinitialises the UART and releases any hardware resources for reuse."""
//| ...
//|
@ -159,13 +159,13 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) {
}
}
//| def __enter__(self, ) -> Any:
//| def __enter__(self, ) -> UART:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
//| def __exit__(self, ) -> Any:
//| def __exit__(self, ) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@ -179,7 +179,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
// These are standard stream methods. Code is in py/stream.c.
//
//| def read(self, nbytes: Any = None) -> Any:
//| def read(self, nbytes: int = None) -> Optional[bytes]:
//| """Read characters. If ``nbytes`` is specified then read at most that many
//| bytes. Otherwise, read everything that arrives until the connection
//| times out. Providing the number of bytes expected is highly recommended
@ -190,7 +190,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
//| ...
//|
//| def readinto(self, buf: Any) -> Any:
//| def readinto(self, buf: bytes) -> Optional[int]:
//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes.
//|
//| :return: number of bytes read and stored into ``buf``
@ -200,7 +200,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
//| ...
//|
//| def readline(self, ) -> Any:
//| def readline(self, ) -> Optional[int]:
//| """Read a line, ending in a newline character.
//|
//| :return: the line read
@ -208,7 +208,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
//| ...
//|
//| def write(self, buf: Any) -> Any:
//| def write(self, buf: bytearray) -> Optional[int]:
//| """Write the buffer of bytes to the bus.
//|
//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string.
@ -261,7 +261,7 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t
return ret;
}
//| baudrate: Any = ...
//| baudrate: int = ...
//| """The current baudrate."""
//|
STATIC mp_obj_t busio_uart_obj_get_baudrate(mp_obj_t self_in) {
@ -287,7 +287,7 @@ const mp_obj_property_t busio_uart_baudrate_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| in_waiting: Any = ...
//| in_waiting: int = ...
//| """The number of bytes in the input buffer, available to be read"""
//|
STATIC mp_obj_t busio_uart_obj_get_in_waiting(mp_obj_t self_in) {
@ -304,7 +304,7 @@ const mp_obj_property_t busio_uart_in_waiting_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| timeout: Any = ...
//| timeout: float = ...
//| """The current timeout, in seconds (float)."""
//|
STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) {
@ -332,8 +332,9 @@ const mp_obj_property_t busio_uart_timeout_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| def reset_input_buffer(self, ) -> Any: ...
//| """Discard any unread characters in the input buffer."""
//| def reset_input_buffer(self, ) -> None:
//| """Discard any unread characters in the input buffer."""
//| ...
//|
STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) {
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -346,10 +347,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_o
//| class Parity:
//| """Enum-like class to define the parity used to verify correct data transfer."""
//|
//| ODD: Any = ...
//| ODD: int = ...
//| """Total number of ones should be odd."""
//|
//| EVEN: Any = ...
//| EVEN: int = ...
//| """Total number of ones should be even."""
//|
const mp_obj_type_t busio_uart_parity_type;