diff --git a/docs/design_guide.rst b/docs/design_guide.rst index b68398827d..03a0c88309 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -309,7 +309,7 @@ following structure: param_type ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The type of the parameter. This could be among other `int`, `float`, `str` `bool`, etc. +The type of the parameter. This could be, among others, ``int``, ``float``, ``str``, ``bool``, etc. To document an object in the CircuitPython domain, you need to include a ``~`` before the definition as shown in the following example: diff --git a/docs/library/builtins.rst b/docs/library/builtins.rst index a3be5ae16e..5358f3cda3 100644 --- a/docs/library/builtins.rst +++ b/docs/library/builtins.rst @@ -1,8 +1,11 @@ :mod:`builtins` -- builtin functions and exceptions =================================================== +.. module:: builtins + :synopsis: builtin Python functions + All builtin functions and exceptions are described here. They are also -available via ``builtins`` module. +available via the ``builtins`` module. For more information about built-ins, see the following CPython documentation: diff --git a/docs/library/collections.rst b/docs/library/collections.rst index b7a5fb1765..2cc1a215d1 100644 --- a/docs/library/collections.rst +++ b/docs/library/collections.rst @@ -28,7 +28,7 @@ Classes - The optional *flags* can be 1 to check for overflow when adding items. - As well as supporting `bool` and `len`, deque objects have the following + As well as supporting ``bool`` and ``len``, deque objects have the following methods: .. method:: deque.append(x) diff --git a/docs/library/micropython.rst b/docs/library/micropython.rst index 2623aab582..dddb813d34 100644 --- a/docs/library/micropython.rst +++ b/docs/library/micropython.rst @@ -76,7 +76,7 @@ Functions .. function:: heap_locked() Lock or unlock the heap. When locked no memory allocation can occur and a - `MemoryError` will be raised if any heap allocation is attempted. + ``MemoryError`` will be raised if any heap allocation is attempted. `heap_locked()` returns a true value if the heap is currently locked. These functions can be nested, ie `heap_lock()` can be called multiple times diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index c4bf105898..5b9b63d8fd 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -56,13 +56,23 @@ ALIASES_BRAND_NAMES = { } ADDITIONAL_MODULES = { - "fontio": "CIRCUITPY_DISPLAYIO", - "terminalio": "CIRCUITPY_DISPLAYIO", + "_asyncio": "MICROPY_PY_UASYNCIO", "adafruit_bus_device": "CIRCUITPY_BUSDEVICE", "adafruit_pixelbuf": "CIRCUITPY_PIXELBUF", + "array": "CIRCUITPY_ARRAY", + # always available, so depend on something that's always 1. + "builtins": "CIRCUITPY", + "collections": "CIRCUITPY_COLLECTIONS", + "fontio": "CIRCUITPY_DISPLAYIO", + "io": "CIRCUITPY_IO", + "select": "MICROPY_PY_USELECT_SELECT", + "terminalio": "CIRCUITPY_DISPLAYIO", + "sys": "CIRCUITPY_SYS", "usb": "CIRCUITPY_USB_HOST", } +MODULES_NOT_IN_SHARED_BINDINGS = ["_asyncio", "array", "binascii", "builtins", "collections", "errno", "json", "re", "select", "sys", "ulab"] + FROZEN_EXCLUDES = ["examples", "docs", "tests", "utils", "conf.py", "setup.py"] """Files and dirs at the root of a frozen directory that should be ignored. This is the same list as in the preprocess_frozen_modules script.""" @@ -82,7 +92,7 @@ def get_shared_bindings(): """ Get a list of modules in shared-bindings based on folder names. """ shared_bindings_dir = get_circuitpython_root_dir() / "shared-bindings" - return [item.name for item in shared_bindings_dir.iterdir()] + ["binascii", "errno", "json", "re", "ulab"] + return [item.name for item in shared_bindings_dir.iterdir()] + MODULES_NOT_IN_SHARED_BINDINGS def get_board_mapping(): diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 7c497c6106..e09c17d85e 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -35,7 +35,8 @@ #include // This is CircuitPython. -#define CIRCUITPY 1 +// Always 1: defined in circuitpy_mpconfig.mk +// #define CIRCUITPY (1) // REPR_C encodes qstrs, 31-bit ints, and 30-bit floats in a single 32-bit word. #ifndef MICROPY_OBJ_REPR @@ -91,7 +92,7 @@ extern void common_hal_mcu_enable_interrupts(void); #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) #define MICROPY_PERSISTENT_CODE_LOAD (1) -#define MICROPY_PY_ARRAY (1) +#define MICROPY_PY_ARRAY (CIRCUITPY_ARRAY) #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) #define MICROPY_PY_ATTRTUPLE (1) @@ -113,21 +114,30 @@ extern void common_hal_mcu_enable_interrupts(void); #define MICROPY_PY_BUILTINS_STR_UNICODE (1) #define MICROPY_PY_CMATH (0) -#define MICROPY_PY_COLLECTIONS (1) +#define MICROPY_PY_COLLECTIONS (CIRCUITPY_COLLECTIONS) #define MICROPY_PY_DESCRIPTORS (1) #define MICROPY_PY_IO_FILEIO (1) #define MICROPY_PY_GC (1) // Supplanted by shared-bindings/math +#define MICROPY_PY_IO (CIRCUITPY_IO) #define MICROPY_PY_MATH (0) #define MICROPY_PY_MICROPYTHON_MEM_INFO (0) // Supplanted by shared-bindings/struct #define MICROPY_PY_STRUCT (0) -#define MICROPY_PY_SYS (1) +#define MICROPY_PY_SYS (CIRCUITPY_SYS) #define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_STDFILES (1) +// In extmod +#define MICROPY_PY_UBINASCII (CIRCUITPY_BINASCII) +#define MICROPY_PY_UERRNO (CIRCUITPY_ERRNO) +// Uses about 80 bytes. +#define MICROPY_PY_UERRNO_ERRORCODE (CIRCUITPY_ERRNO) // Supplanted by shared-bindings/random #define MICROPY_PY_URANDOM (0) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) +// In extmod +#define MICROPY_PY_UJSON (CIRCUITPY_JSON) +#define MICROPY_PY_URE (CIRCUITPY_RE) #define MICROPY_PY___FILE__ (1) #define MICROPY_QSTR_BYTES_IN_HASH (1) @@ -349,26 +359,6 @@ typedef long mp_off_t; extern const struct _mp_obj_module_t nvm_module; #endif -// Following modules are implemented in either extmod or py directory. - -#define MICROPY_PY_UBINASCII CIRCUITPY_BINASCII - -#define MICROPY_PY_UERRNO CIRCUITPY_ERRNO -// Uses about 80 bytes. -#define MICROPY_PY_UERRNO_ERRORCODE CIRCUITPY_ERRNO - -#define MICROPY_PY_URE CIRCUITPY_RE - -#if CIRCUITPY_JSON -#define MICROPY_PY_UJSON (1) -#define MICROPY_PY_IO (1) -#else -#ifndef MICROPY_PY_IO -// We don't need MICROPY_PY_IO unless someone else wants it. -#define MICROPY_PY_IO (0) -#endif -#endif - #ifndef ULAB_SUPPORTS_COMPLEX #define ULAB_SUPPORTS_COMPLEX (0) #endif diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index fc270f2c59..96165997ce 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -26,6 +26,10 @@ # Boards default to all modules enabled (with exceptions) # Manually disable by overriding in #mpconfigboard.mk +# Always on. Present here to help generate documentation module support matrix for "builtins". +CIRCUITPY = 1 +CFLAGS += -DCIRCUITPY=$(CIRCUITPY) + # Smaller builds can be forced for resource constrained chips (typically SAMD21s # without external flash) by setting CIRCUITPY_FULL_BUILD=0. Avoid using this # for merely incomplete ports, as it changes settings in other files. @@ -68,6 +72,9 @@ CFLAGS += -DCIRCUITPY_ANALOGBUFIO=$(CIRCUITPY_ANALOGBUFIO) CIRCUITPY_ANALOGIO ?= 1 CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO) +CIRCUITPY_ARRAY ?= 1 +CFLAGS += -DCIRCUITPY_ARRAY=$(CIRCUITPY_ARRAY) + CIRCUITPY_ATEXIT ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_ATEXIT=$(CIRCUITPY_ATEXIT) @@ -159,21 +166,18 @@ CFLAGS += -DCIRCUITPY_CAMERA=$(CIRCUITPY_CAMERA) CIRCUITPY_CANIO ?= 0 CFLAGS += -DCIRCUITPY_CANIO=$(CIRCUITPY_CANIO) +CIRCUITPY_COLLECTIONS ?= 1 +CFLAGS += -DCIRCUITPY_COLLECTIONS=$(CIRCUITPY_COLLECTIONS) + +CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE ?= 0 +CFLAGS += -DCIRCUITPY_COMPUTED_GOTO_SAVE_SPACE=$(CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE) + CIRCUITPY_CYW43 ?= 0 CFLAGS += -DCIRCUITPY_CYW43=$(CIRCUITPY_CYW43) CIRCUITPY_DIGITALIO ?= 1 CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) -CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE ?= 0 -CFLAGS += -DCIRCUITPY_COMPUTED_GOTO_SAVE_SPACE=$(CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE) - -CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH ?= 1 -CFLAGS += -DCIRCUITPY_OPT_LOAD_ATTR_FAST_PATH=$(CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH) - -CIRCUITPY_OPT_MAP_LOOKUP_CACHE ?= $(CIRCUITPY_FULL_BUILD) -CFLAGS += -DCIRCUITPY_OPT_MAP_LOOKUP_CACHE=$(CIRCUITPY_OPT_MAP_LOOKUP_CACHE) - CIRCUITPY_COUNTIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) @@ -257,6 +261,10 @@ CFLAGS += -DCIRCUITPY_I2CTARGET=$(CIRCUITPY_I2CTARGET) CIRCUITPY_IMAGECAPTURE ?= 0 CFLAGS += -DCIRCUITPY_IMAGECAPTURE=$(CIRCUITPY_IMAGECAPTURE) +# io - needed by JSON support +CIRCUITPY_IO ?= $(CIRCUITPY_JSON) +CFLAGS += -DCIRCUITPY_IO=$(CIRCUITPY_IO) + CIRCUITPY_IPADDRESS ?= $(CIRCUITPY_WIFI) CFLAGS += -DCIRCUITPY_IPADDRESS=$(CIRCUITPY_IPADDRESS) @@ -293,6 +301,12 @@ CFLAGS += -DCIRCUITPY_NVM=$(CIRCUITPY_NVM) CIRCUITPY_ONEWIREIO ?= $(CIRCUITPY_BUSIO) CFLAGS += -DCIRCUITPY_ONEWIREIO=$(CIRCUITPY_ONEWIREIO) +CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH ?= 1 +CFLAGS += -DCIRCUITPY_OPT_LOAD_ATTR_FAST_PATH=$(CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH) + +CIRCUITPY_OPT_MAP_LOOKUP_CACHE ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_OPT_MAP_LOOKUP_CACHE=$(CIRCUITPY_OPT_MAP_LOOKUP_CACHE) + CIRCUITPY_OS ?= 1 CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS) @@ -374,7 +388,6 @@ CFLAGS += -DCIRCUITPY_SOCKETPOOL=$(CIRCUITPY_SOCKETPOOL) CIRCUITPY_SSL ?= $(CIRCUITPY_WIFI) CFLAGS += -DCIRCUITPY_SSL=$(CIRCUITPY_SSL) -# Currently always off. CIRCUITPY_STAGE ?= 0 CFLAGS += -DCIRCUITPY_STAGE=$(CIRCUITPY_STAGE) @@ -393,6 +406,9 @@ CFLAGS += -DCIRCUITPY_SUPERVISOR=$(CIRCUITPY_SUPERVISOR) CIRCUITPY_SYNTHIO ?= $(CIRCUITPY_AUDIOCORE) CFLAGS += -DCIRCUITPY_SYNTHIO=$(CIRCUITPY_SYNTHIO) +CIRCUITPY_SYS ?= 1 +CFLAGS += -DCIRCUITPY_SYS=$(CIRCUITPY_SYS) + CIRCUITPY_TERMINALIO ?= $(CIRCUITPY_DISPLAYIO) CFLAGS += -DCIRCUITPY_TERMINALIO=$(CIRCUITPY_TERMINALIO) diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index 5bacc74073..0ca0e09023 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -117,7 +117,7 @@ MP_PROPERTY_GETTER(analogio_analogin_value_obj, //| reference_voltage: float //| """The maximum voltage measurable (also known as the reference voltage) as a -//| `float` in Volts. Note the ADC value may not scale to the actual voltage linearly +//| ``float`` in Volts. Note the ADC value may not scale to the actual voltage linearly //| at ends of the analog range.""" //| STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) { diff --git a/shared-bindings/support_matrix.rst b/shared-bindings/support_matrix.rst index c54bfa94e1..3d5e544ea0 100644 --- a/shared-bindings/support_matrix.rst +++ b/shared-bindings/support_matrix.rst @@ -6,6 +6,11 @@ Module Support Matrix - Which Modules Are Available on Which Boards The following table lists the available built-in modules for each CircuitPython capable board, as well as each :term:`frozen module` included on it. +You can filter this list by typing one or more module names or partial names into the search box. +Only those boards that provide those modules will be listed. +To exclude boards that provide a module, type a "-" in front of the module name. +You can also type a regular expression as a filter. + .. raw:: html

(all)