Did struct, supervisor, terminalio

This commit is contained in:
dherrada 2020-05-12 11:28:33 -04:00
parent 603df58f97
commit 991045b9ce
No known key found for this signature in database
GPG Key ID: CE2ADBAB8775CE81
5 changed files with 82 additions and 84 deletions

View File

@ -38,7 +38,7 @@
#include "shared-module/struct/__init__.h"
#include "supervisor/shared/translate.h"
//| :mod:`struct` --- manipulation of c-style data
//| """:mod:`struct` --- manipulation of c-style data
//| ========================================================
//|
//| .. module:: struct
@ -52,13 +52,13 @@
//| Supported size/byte order prefixes: *@*, *<*, *>*, *!*.
//|
//| Supported format codes: *b*, *B*, *x*, *h*, *H*, *i*, *I*, *l*, *L*, *q*, *Q*,
//| *s*, *P*, *f*, *d* (the latter 2 depending on the floating-point support).
//| *s*, *P*, *f*, *d* (the latter 2 depending on the floating-point support)."""
//|
//| .. function:: calcsize(fmt)
//|
//| Return the number of bytes needed to store the given fmt.
//| def calcsize(fmt: Any) -> Any:
//| """Return the number of bytes needed to store the given fmt."""
//| ...
//|
STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
@ -67,10 +67,10 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize);
//| .. function:: pack(fmt, *values)
//|
//| Pack the values according to the format string fmt.
//| The return value is a bytes object encoding the values.
//| def pack(fmt: Any, *values: Any) -> Any:
//| """Pack the values according to the format string fmt.
//| The return value is a bytes object encoding the values."""
//| ...
//|
STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
@ -85,10 +85,10 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack);
//| .. function:: pack_into(fmt, buffer, offset, *values)
//|
//| Pack the values according to the format string fmt into a buffer
//| starting at offset. offset may be negative to count from the end of buffer.
//| def pack_into(fmt: Any, buffer: Any, offset: Any, *values: Any) -> Any:
//| """Pack the values according to the format string fmt into a buffer
//| starting at offset. offset may be negative to count from the end of buffer."""
//| ...
//|
STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
@ -111,11 +111,11 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into);
//| .. function:: unpack(fmt, data)
//|
//| Unpack from the data according to the format string fmt. The return value
//| is a tuple of the unpacked values. The buffer size must match the size
//| required by the format.
//| def unpack(fmt: Any, data: Any) -> Any:
//| """Unpack from the data according to the format string fmt. The return value
//| is a tuple of the unpacked values. The buffer size must match the size
//| required by the format."""
//| ...
//|
STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) {
@ -129,12 +129,12 @@ STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_obj, 2, 3, struct_unpack);
//| .. function:: unpack_from(fmt, data, offset=0)
//|
//| Unpack from the data starting at offset according to the format string fmt.
//| offset may be negative to count from the end of buffer. The return value is
//| a tuple of the unpacked values. The buffer size must be at least as big
//| as the size required by the form.
//| def unpack_from(fmt: Any, data: Any, offset: Any = 0) -> Any:
//| """Unpack from the data starting at offset according to the format string fmt.
//| offset may be negative to count from the end of buffer. The return value is
//| a tuple of the unpacked values. The buffer size must be at least as big
//| as the size required by the form."""
//| ...
//|
STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {

View File

@ -29,35 +29,35 @@
#include "shared-bindings/supervisor/Runtime.h"
//TODO: add USB, REPL to description once they're operational
//| .. currentmodule:: supervisor
//| class Runtime:
//| """.. currentmodule:: supervisor
//|
//| :class:`Runtime` --- Supervisor Runtime information
//| ----------------------------------------------------
//| :class:`Runtime` --- Supervisor Runtime information
//| ----------------------------------------------------
//|
//| Get current status of runtime objects.
//| Get current status of runtime objects.
//|
//| Usage::
//| Usage::
//|
//| import supervisor
//| if supervisor.runtime.serial_connected:
//| print("Hello World!")
//| import supervisor
//| if supervisor.runtime.serial_connected:
//| print("Hello World!")"""
//|
//| .. class:: Runtime()
//|
//| You cannot create an instance of `supervisor.Runtime`.
//| Use `supervisor.runtime` to access the sole instance available.
//| def __init__(self, ):
//| """You cannot create an instance of `supervisor.Runtime`.
//| Use `supervisor.runtime` to access the sole instance available."""
//| ...
//|
//| .. attribute:: runtime.serial_connected
//|
//| Returns the USB serial communication status (read-only).
//| runtime.serial_connected: Any = ...
//| """Returns the USB serial communication status (read-only).
//|
//| .. note::
//|
//| SAMD: Will return ``True`` if the USB serial connection
//| has been established at any point. Will not reset if
//| USB is disconnected but power remains (e.g. battery connected)
//| USB is disconnected but power remains (e.g. battery connected)"""
//|
STATIC mp_obj_t supervisor_get_serial_connected(mp_obj_t self){
@ -78,11 +78,10 @@ const mp_obj_property_t supervisor_serial_connected_obj = {
};
//| .. attribute:: runtime.serial_bytes_available
//|
//| Returns the whether any bytes are available to read
//| on the USB serial input. Allows for polling to see whether
//| to call the built-in input() or wait. (read-only)
//| runtime.serial_bytes_available: Any = ...
//| """Returns the whether any bytes are available to read
//| on the USB serial input. Allows for polling to see whether
//| to call the built-in input() or wait. (read-only)"""
//|
STATIC mp_obj_t supervisor_get_serial_bytes_available(mp_obj_t self){
if (!common_hal_get_serial_bytes_available()) {

View File

@ -36,7 +36,7 @@
#include "shared-bindings/supervisor/__init__.h"
#include "shared-bindings/supervisor/Runtime.h"
//| :mod:`supervisor` --- Supervisor settings
//| """:mod:`supervisor` --- Supervisor settings
//| =================================================
//|
//| .. module:: supervisor
@ -50,19 +50,18 @@
//| .. toctree::
//| :maxdepth: 3
//|
//| Runtime
//| Runtime"""
//|
//| .. attribute:: runtime
//|
//| Runtime information, such as `runtime.serial_connected`
//| (USB serial connection status).
//| This object is the sole instance of `supervisor.Runtime`.
//| runtime: Any = ...
//| """Runtime information, such as `runtime.serial_connected`
//| (USB serial connection status).
//| This object is the sole instance of `supervisor.Runtime`."""
//|
//| .. method:: enable_autoreload()
//|
//| Enable autoreload based on USB file write activity.
//| def enable_autoreload(self, ) -> Any:
//| """Enable autoreload based on USB file write activity."""
//| ...
//|
STATIC mp_obj_t supervisor_enable_autoreload(void) {
autoreload_enable();
@ -70,10 +69,10 @@ STATIC mp_obj_t supervisor_enable_autoreload(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_enable_autoreload_obj, supervisor_enable_autoreload);
//| .. method:: disable_autoreload()
//|
//| Disable autoreload based on USB file write activity until
//| `enable_autoreload` is called.
//| def disable_autoreload(self, ) -> Any:
//| """Disable autoreload based on USB file write activity until
//| `enable_autoreload` is called."""
//| ...
//|
STATIC mp_obj_t supervisor_disable_autoreload(void) {
autoreload_disable();
@ -81,10 +80,10 @@ STATIC mp_obj_t supervisor_disable_autoreload(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_autoreload);
//| .. method:: set_rgb_status_brightness()
//|
//| Set brightness of status neopixel from 0-255
//| `set_rgb_status_brightness` is called.
//| def set_rgb_status_brightness(self, ) -> Any:
//| """Set brightness of status neopixel from 0-255
//| `set_rgb_status_brightness` is called."""
//| ...
//|
STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){
// This must be int. If cast to uint8_t first, will never raise a ValueError.
@ -97,9 +96,9 @@ STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){
}
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness);
//| .. method:: reload()
//|
//| Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL).
//| def reload(self, ) -> Any:
//| """Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL)."""
//| ...
//|
STATIC mp_obj_t supervisor_reload(void) {
reload_requested = true;
@ -108,9 +107,9 @@ STATIC mp_obj_t supervisor_reload(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload);
//| .. method:: set_next_stack_limit(size)
//|
//| Set the size of the stack for the next vm run. If its too large, the default will be used.
//| def set_next_stack_limit(self, size: Any) -> Any:
//| """Set the size of the stack for the next vm run. If its too large, the default will be used."""
//| ...
//|
STATIC mp_obj_t supervisor_set_next_stack_limit(mp_obj_t size_obj) {
mp_int_t size = mp_obj_get_int(size_obj);

View File

@ -37,16 +37,16 @@
#include "shared-bindings/fontio/BuiltinFont.h"
#include "supervisor/shared/translate.h"
//| .. currentmodule:: terminalio
//| class Terminal:
//| """.. currentmodule:: terminalio
//|
//| :class:`Terminal` -- display a character stream with a TileGrid
//| ================================================================
//| :class:`Terminal` -- display a character stream with a TileGrid
//| ================================================================"""
//|
//| .. class:: Terminal(tilegrid, font)
//|
//| Terminal manages tile indices and cursor position based on VT100 commands. The font should be
//| a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap.
//| def __init__(self, tilegrid: Any, font: Any):
//| """Terminal manages tile indices and cursor position based on VT100 commands. The font should be
//| a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap."""
//| ...
//|
STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@ -75,12 +75,12 @@ STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n
// These are standard stream methods. Code is in py/stream.c.
//
//| .. method:: write(buf)
//| def write(self, buf: Any) -> Any:
//| """Write the buffer of bytes to the bus.
//|
//| Write the buffer of bytes to the bus.
//|
//| :return: the number of bytes written
//| :rtype: int or None
//| :return: the number of bytes written
//| :rtype: int or None"""
//| ...
//|
STATIC mp_uint_t terminalio_terminal_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
terminalio_terminal_obj_t *self = MP_OBJ_TO_PTR(self_in);

View File

@ -35,7 +35,7 @@
#include "py/runtime.h"
//| :mod:`terminalio` --- Displays text in a TileGrid
//| """:mod:`terminalio` --- Displays text in a TileGrid
//| =================================================
//|
//| .. module:: terminalio
@ -49,7 +49,7 @@
//| .. toctree::
//| :maxdepth: 3
//|
//| Terminal
//| Terminal"""
//|
//|
STATIC const mp_rom_map_elem_t terminalio_module_globals_table[] = {