Merge remote-tracking branch 'origin/main' into stm32-sdioio

This commit is contained in:
Jeff Epler 2020-08-10 12:54:12 -05:00
commit 1cf3762392
110 changed files with 925 additions and 780 deletions

7
.gitignore vendored
View File

@ -57,7 +57,7 @@ _build
######################
genrst/
/autoapi/
/shared-bindings/**/*.rst
/shared-bindings/*/**/*.rst
# ctags and similar
###################
@ -80,3 +80,8 @@ TAGS
*.mo
.vscode
# Python Virtual Environments
####################
.venv
.env

View File

@ -8,6 +8,10 @@
version: 2
submodules:
include:
- extmod/ulab
python:
version: 3
install:

View File

@ -245,6 +245,10 @@ stubs:
@$(PYTHON) tools/extract_pyi.py ports/atmel-samd/bindings $(STUBDIR)
@$(PYTHON) setup.py -q sdist
.PHONY: check-stubs
check-stubs: stubs
MYPYPATH=$(STUBDIR) mypy --strict $(STUBDIR)
update-frozen-libraries:
@echo "Updating all frozen libraries to latest tagged version."
cd frozen; for library in *; do cd $$library; ../../tools/git-checkout-latest-tag.sh; cd ..; done

57
conf.py
View File

@ -17,14 +17,17 @@
#
# SPDX-License-Identifier: MIT
import json
import logging
import os
import re
import subprocess
import sys
import urllib.parse
import recommonmark
from sphinx.transforms import SphinxTransform
from docutils import nodes
from sphinx import addnodes
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@ -84,6 +87,7 @@ autoapi_dirs = [os.path.join('circuitpython-stubs', x) for x in os.listdir('circ
autoapi_add_toctree_entry = False
autoapi_options = ['members', 'undoc-members', 'private-members', 'show-inheritance', 'special-members', 'show-module-summary']
autoapi_template_dir = 'docs/autoapi/templates'
autoapi_python_class_content = "both"
autoapi_python_use_implicit_namespaces = True
autoapi_root = "shared-bindings"
@ -106,7 +110,25 @@ copyright = '2014-2020, MicroPython & CircuitPython contributors (https://github
#
# We don't follow "The short X.Y version" vs "The full version, including alpha/beta/rc tags"
# breakdown, so use the same version identifier for both to avoid confusion.
version = release = '0.0.0'
final_version = ""
git_describe = subprocess.run(
["git", "describe", "--dirty", "--tags"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
encoding="utf-8"
)
if git_describe.returncode == 0:
git_version = re.search(
r"^\d(?:\.\d){0,2}(?:\-(?:alpha|beta|rc)\.\d+){0,1}",
str(git_describe.stdout)
)
if git_version:
final_version = git_version[0]
else:
print("Failed to retrieve git version:", git_describe.stdout)
version = release = final_version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -423,7 +445,38 @@ def generate_redirects(app):
with open(redirected_filename, 'w') as f:
f.write(TEMPLATE % urllib.parse.quote(to_path, '#/'))
class CoreModuleTransform(SphinxTransform):
default_priority = 870
def _convert_first_paragraph_into_title(self):
title = self.document.next_node(nodes.title)
paragraph = self.document.next_node(nodes.paragraph)
if not title or not paragraph:
return
if isinstance(paragraph[0], nodes.paragraph):
paragraph = paragraph[0]
if all(isinstance(child, nodes.Text) for child in paragraph.children):
for child in paragraph.children:
title.append(nodes.Text(" \u2013 "))
title.append(child)
paragraph.parent.remove(paragraph)
def _enable_linking_to_nonclass_targets(self):
for desc in self.document.traverse(addnodes.desc):
for xref in desc.traverse(addnodes.pending_xref):
if xref.attributes.get("reftype") == "class":
xref.attributes.pop("refspecific", None)
def apply(self, **kwargs):
docname = self.env.docname
if docname.startswith(autoapi_root) and docname.endswith("/index"):
self._convert_first_paragraph_into_title()
self._enable_linking_to_nonclass_targets()
def setup(app):
app.add_css_file("customstyle.css")
app.add_config_value('redirects_file', 'redirects', 'env')
app.connect('builder-inited', generate_redirects)
app.add_transform(CoreModuleTransform)

View File

@ -18,8 +18,7 @@
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
{% if visible_subpackages %}
.. toctree::
:titlesonly:
:maxdepth: 3
:maxdepth: 2
{% for subpackage in visible_subpackages %}
{{ subpackage.short_name }}/index.rst

View File

@ -1,4 +1,4 @@
sphinx<3
sphinx<4
recommonmark==0.6.0
sphinxcontrib-svg2pdfconverter==0.1.0
astroid

View File

@ -520,7 +520,7 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t base_in, mp_obj_t index_in, mp_ob
uint val_type = GET_TYPE(arr_sz, VAL_TYPE_BITS);
arr_sz &= VALUE_MASK(VAL_TYPE_BITS);
if (index >= arr_sz) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("struct: index out of range")));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_struct);
}
if (t->len == 2) {

View File

@ -42,7 +42,7 @@ const byte fresult_to_errno_table[20] = {
STATIC void file_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_printf(print, "<io.%s %p>", mp_obj_get_type_str(self_in), MP_OBJ_TO_PTR(self_in));
mp_printf(print, "<io.%q %p>", mp_obj_get_type_qstr(self_in), MP_OBJ_TO_PTR(self_in));
}
STATIC mp_uint_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {

View File

@ -34,7 +34,7 @@ STATIC void check_fd_is_open(const mp_obj_vfs_posix_file_t *o) {
STATIC void vfs_posix_file_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_vfs_posix_file_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "<io.%s %d>", mp_obj_get_type_str(self_in), self->fd);
mp_printf(print, "<io.%q %d>", mp_obj_get_type_qstr(self_in), self->fd);
}
mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_obj_t mode_in) {

@ -1 +1 @@
Subproject commit 5d584576ef79ca36506e6c7470e7ac5204cf0a8d
Subproject commit 41f7a3530d4cacdbf668399d3a015ea29c7e169b

@ -1 +1 @@
Subproject commit 3ffb3f02d2046910e09d1f5a74721bd1a4cdf8cf
Subproject commit 6a034887e370caa61fee5f51db8dd393d3e72542

@ -1 +1 @@
Subproject commit e9411c4244984b69ec6928370ede40cec014c10b
Subproject commit eb4b21e216efd8ec0c4862a938e81b56be961724

@ -1 +1 @@
Subproject commit e9f15d61502f34173912ba271aaaf9446dae8da1
Subproject commit 3c540329b63163e45f108df4bfebc387d5352c4f

@ -1 +1 @@
Subproject commit 0e1230676a54da17a309d1dfffdd7fa90240191c
Subproject commit 809646ba11366b5aedbc8a90be1da1829304bf62

@ -1 +1 @@
Subproject commit 7914a6390318687bb8e2e9c4119aa932fea01531
Subproject commit 209edd164eb640a8ced561a54505792fc99a67b9

@ -1 +1 @@
Subproject commit 0d49a1fcd96c13a94e8bdf26f92abe79b8517906
Subproject commit 5d81a9ea822a85e46be4a512ac44abf21e77d816

@ -1 +1 @@
Subproject commit 94b03517c1f4ff68cc2bb09b0963f7e7e3ce3d04
Subproject commit 01f3f6674b4493ba29b857e0f43deb69975736ec

@ -1 +1 @@
Subproject commit 72968d3546f9d6c5af138d4c179343007cb9662c
Subproject commit 1e3312ab1cba0b1d3bb1f559c52acfdc1a6d57b8

@ -1 +1 @@
Subproject commit 65fb213b8c554181d54b77f75335e16e2f4c0987
Subproject commit 829ba0f0a2d8a63f7d0215c6c9fc821e14e52a93

@ -1 +1 @@
Subproject commit d435fc9a9d90cb063608ae037bf5284b33bc5e84
Subproject commit fc3a7b479874a1ea315ddb3bf6c5e281e16ef097

@ -1 +1 @@
Subproject commit 457aba6dd59ad00502b80c9031655d3d26ecc82b
Subproject commit 9fe8f314c032cee89b9ad7697d61e9cba76431ff

@ -1 +1 @@
Subproject commit ee8f2187d4795b08ae4aa60558f564d26c997be9
Subproject commit f1cc47f024b27e670b9bf2a51c89e32f93c1b957

@ -1 +1 @@
Subproject commit 5fd72fb963c4a0318d29282ca2cc988f19787fda
Subproject commit 434e5b5346cb0a1a9eb15989b00278be87cb2ff1

@ -1 +1 @@
Subproject commit 56358b4494da825cd99a56a854119f926abca670
Subproject commit 6143ec2a96a6d218041e9cab5968de26702d7bbf

@ -1 +1 @@
Subproject commit 41de8b3c05dd78d7be8893a0f6cb47a7e9b421a2
Subproject commit 43017e30a1e772b67ac68293a944e863c031e389

@ -1 +1 @@
Subproject commit b5bbdbd56ca205c581ba2c84d927ef99befce88e
Subproject commit fb773e0ed1891cda2ace6271fafc5312e167d275

@ -1 +1 @@
Subproject commit 76c0dd13294ce8ae0518cb9882dcad5d3668977e
Subproject commit 88738da275a83acabb14b7140d1c79b33cdc7b02

View File

@ -35,9 +35,9 @@
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
*/
#ifdef __STDC__
static const __int32_t two_over_pi[] = {
static const __uint8_t two_over_pi[] = {
#else
static __int32_t two_over_pi[] = {
static __uint8_t two_over_pi[] = {
#endif
0xA2, 0xF9, 0x83, 0x6E, 0x4E, 0x44, 0x15, 0x29, 0xFC,
0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62,
@ -145,6 +145,7 @@ pio2_3t = 6.1232342629e-17; /* 0x248d3132 */
return -1;
}
}
#if CIRCUITPY_FULL_BUILD
if(ix<=0x43490f80) { /* |x| ~<= 2^7*(pi/2), medium size */
t = fabsf(x);
n = (__int32_t) (t*invpio2+half);
@ -180,6 +181,11 @@ pio2_3t = 6.1232342629e-17; /* 0x248d3132 */
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
else return n;
}
#else
// Suppress "defined but not used" diagnostics
(void) j; (void) fn; (void) r; (void) t; (void) w; (void) pio2_3t;
(void) pio2_3; (void) invpio2; (void)half; (void)npio2_hw;
#endif
/*
* all other (large) arguments
*/

View File

@ -188,7 +188,7 @@ extern float __ieee754_scalbf __P((float,float));
extern float __kernel_sinf __P((float,float,int));
extern float __kernel_cosf __P((float,float));
extern float __kernel_tanf __P((float,float,int));
extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const __int32_t*));
extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const __uint8_t*));
/* A union which permits us to convert between a float and a 32 bit
int. */

View File

@ -62,10 +62,10 @@ two8 = 2.5600000000e+02, /* 0x43800000 */
twon8 = 3.9062500000e-03; /* 0x3b800000 */
#ifdef __STDC__
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2)
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __uint8_t *ipio2)
#else
int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2)
float x[], y[]; int e0,nx,prec; __int32_t ipio2[];
float x[], y[]; int e0,nx,prec; __uint8_t ipio2[];
#endif
{
__int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-03 21:01-0500\n"
"POT-Creation-Date: 2020-08-10 12:54-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -66,12 +66,16 @@ msgstr ""
msgid "%q in use"
msgstr ""
#: py/obj.c
#: extmod/moductypes.c ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
#: ports/stm/common-hal/pulseio/PulseIn.c py/obj.c py/objstr.c
#: py/objstrunicode.c
msgid "%q index out of range"
msgstr ""
#: py/obj.c
msgid "%q indices must be integers, not %s"
msgid "%q indices must be integers, not %q"
msgstr ""
#: shared-bindings/vectorio/Polygon.c
@ -110,6 +114,42 @@ msgstr ""
msgid "'%q' argument required"
msgstr ""
#: py/runtime.c
msgid "'%q' object cannot assign attribute '%q'"
msgstr ""
#: py/proto.c
msgid "'%q' object does not support '%q'"
msgstr ""
#: py/obj.c
msgid "'%q' object does not support item assignment"
msgstr ""
#: py/obj.c
msgid "'%q' object does not support item deletion"
msgstr ""
#: py/runtime.c
msgid "'%q' object has no attribute '%q'"
msgstr ""
#: py/runtime.c
msgid "'%q' object is not an iterator"
msgstr ""
#: py/objtype.c py/runtime.c
msgid "'%q' object is not callable"
msgstr ""
#: py/runtime.c
msgid "'%q' object is not iterable"
msgstr ""
#: py/obj.c
msgid "'%q' object is not subscriptable"
msgstr ""
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@ -160,48 +200,6 @@ msgstr ""
msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr ""
#: py/runtime.c
msgid "'%s' object cannot assign attribute '%q'"
msgstr ""
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c
#, c-format
msgid "'%s' object does not support item assignment"
msgstr ""
#: py/obj.c
#, c-format
msgid "'%s' object does not support item deletion"
msgstr ""
#: py/runtime.c
msgid "'%s' object has no attribute '%q'"
msgstr ""
#: py/runtime.c
#, c-format
msgid "'%s' object is not an iterator"
msgstr ""
#: py/objtype.c py/runtime.c
#, c-format
msgid "'%s' object is not callable"
msgstr ""
#: py/runtime.c
#, c-format
msgid "'%s' object is not iterable"
msgstr ""
#: py/obj.c
#, c-format
msgid "'%s' object is not subscriptable"
msgstr ""
#: py/objstr.c
msgid "'=' alignment not allowed in string format specifier"
msgstr ""
@ -1232,6 +1230,10 @@ msgstr ""
msgid "Not playing"
msgstr ""
#: main.c
msgid "Not running saved code.\n"
msgstr ""
#: shared-bindings/util.c
msgid ""
"Object has been deinitialized and can no longer be used. Create a new object."
@ -1317,10 +1319,6 @@ msgstr ""
msgid "Polygon needs at least 3 points"
msgstr ""
#: shared-bindings/ps2io/Ps2.c
msgid "Pop from an empty Ps2 buffer"
msgstr ""
#: shared-bindings/_bleio/Adapter.c
msgid "Prefix buffer must be on the heap"
msgstr ""
@ -1393,11 +1391,7 @@ msgid "Row entry must be digitalio.DigitalInOut"
msgstr ""
#: main.c
msgid "Running in safe mode! Auto-reload is off.\n"
msgstr ""
#: main.c
msgid "Running in safe mode! Not running saved code.\n"
msgid "Running in safe mode! "
msgstr ""
#: shared-module/sdcardio/SDCard.c
@ -1768,8 +1762,7 @@ msgid "__init__() should return None"
msgstr ""
#: py/objtype.c
#, c-format
msgid "__init__() should return None, not '%s'"
msgid "__init__() should return None, not '%q'"
msgstr ""
#: py/objobject.c
@ -1923,7 +1916,7 @@ msgstr ""
msgid "bytes value out of range"
msgstr ""
#: ports/atmel-samd/bindings/samd/Clock.c
#: ports/atmel-samd/bindings/samd/Clock.c ports/atmel-samd/common-hal/rtc/RTC.c
msgid "calibration is out of range"
msgstr ""
@ -1955,47 +1948,16 @@ msgstr ""
msgid "can't assign to expression"
msgstr ""
#: py/obj.c
#, c-format
msgid "can't convert %s to complex"
msgstr ""
#: py/obj.c
#, c-format
msgid "can't convert %s to float"
msgstr ""
#: py/obj.c
#, c-format
msgid "can't convert %s to int"
#: py/obj.c py/objint.c shared-bindings/i2cperipheral/I2CPeripheral.c
msgid "can't convert %q to %q"
msgstr ""
#: py/objstr.c
msgid "can't convert '%q' object to %q implicitly"
msgstr ""
#: py/objint.c
msgid "can't convert NaN to int"
msgstr ""
#: shared-bindings/i2cperipheral/I2CPeripheral.c
msgid "can't convert address to int"
msgstr ""
#: py/objint.c
msgid "can't convert inf to int"
msgstr ""
#: py/obj.c
msgid "can't convert to complex"
msgstr ""
#: py/obj.c
msgid "can't convert to float"
msgstr ""
#: py/obj.c
msgid "can't convert to int"
msgid "can't convert to %q"
msgstr ""
#: py/objstr.c
@ -2403,7 +2365,7 @@ msgstr ""
msgid "function missing required positional argument #%d"
msgstr ""
#: py/argcheck.c py/bc.c py/objnamedtuple.c
#: py/argcheck.c py/bc.c py/objnamedtuple.c shared-bindings/time/__init__.c
#, c-format
msgid "function takes %d positional arguments but %d were given"
msgstr ""
@ -2452,10 +2414,7 @@ msgstr ""
msgid "index is out of bounds"
msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
#: ports/stm/common-hal/pulseio/PulseIn.c py/obj.c
#: py/obj.c
msgid "index out of range"
msgstr ""
@ -2811,8 +2770,7 @@ msgid "number of points must be at least 2"
msgstr ""
#: py/obj.c
#, c-format
msgid "object '%s' is not a tuple or list"
msgid "object '%q' is not a tuple or list"
msgstr ""
#: py/obj.c
@ -2848,8 +2806,7 @@ msgid "object not iterable"
msgstr ""
#: py/obj.c
#, c-format
msgid "object of type '%s' has no len()"
msgid "object of type '%q' has no len()"
msgstr ""
#: py/obj.c
@ -2942,20 +2899,9 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr ""
#: py/objset.c
msgid "pop from an empty set"
msgstr ""
#: py/objlist.c
msgid "pop from empty list"
msgstr ""
#: py/objdict.c
msgid "popitem(): dictionary is empty"
#: ports/stm/common-hal/pulseio/PulseIn.c py/objdict.c py/objlist.c py/objset.c
#: shared-bindings/ps2io/Ps2.c
msgid "pop from empty %q"
msgstr ""
#: py/objint_mpz.c
@ -3112,12 +3058,7 @@ msgid "stream operation not supported"
msgstr ""
#: py/objstrunicode.c
msgid "string index out of range"
msgstr ""
#: py/objstrunicode.c
#, c-format
msgid "string indices must be integers, not %s"
msgid "string indices must be integers, not %q"
msgstr ""
#: py/stream.c
@ -3128,10 +3069,6 @@ msgstr ""
msgid "struct: cannot index"
msgstr ""
#: extmod/moductypes.c
msgid "struct: index out of range"
msgstr ""
#: extmod/moductypes.c
msgid "struct: no fields"
msgstr ""
@ -3201,7 +3138,7 @@ msgstr ""
msgid "trapz is defined for 1D arrays of equal length"
msgstr ""
#: extmod/ulab/code/linalg/linalg.c py/objstr.c
#: extmod/ulab/code/linalg/linalg.c
msgid "tuple index out of range"
msgstr ""
@ -3268,8 +3205,7 @@ msgid "unknown conversion specifier %c"
msgstr ""
#: py/objstr.c
#, c-format
msgid "unknown format code '%c' for object of type '%s'"
msgid "unknown format code '%c' for object of type '%q'"
msgstr ""
#: py/compile.c
@ -3309,7 +3245,7 @@ msgid "unsupported format character '%c' (0x%x) at index %d"
msgstr ""
#: py/runtime.c
msgid "unsupported type for %q: '%s'"
msgid "unsupported type for %q: '%q'"
msgstr ""
#: py/runtime.c
@ -3317,7 +3253,7 @@ msgid "unsupported type for operator"
msgstr ""
#: py/runtime.c
msgid "unsupported types for %q: '%s', '%s'"
msgid "unsupported types for %q: '%q', '%q'"
msgstr ""
#: py/objint.c

20
main.c
View File

@ -181,7 +181,7 @@ void stop_mp(void) {
// Look for the first file that exists in the list of filenames, using mp_import_stat().
// Return its index. If no file found, return -1.
const char* first_existing_file_in_list(const char ** filenames) {
const char* first_existing_file_in_list(const char * const * filenames) {
for (int i = 0; filenames[i] != (char*)""; i++) {
mp_import_stat_t stat = mp_import_stat(filenames[i]);
if (stat == MP_IMPORT_STAT_FILE) {
@ -191,7 +191,7 @@ const char* first_existing_file_in_list(const char ** filenames) {
return NULL;
}
bool maybe_run_list(const char ** filenames, pyexec_result_t* exec_result) {
bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec_result) {
const char* filename = first_existing_file_in_list(filenames);
if (filename == NULL) {
return false;
@ -234,7 +234,8 @@ bool run_code_py(safe_mode_t safe_mode) {
if (autoreload_is_enabled()) {
serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n"));
} else if (safe_mode != NO_SAFE_MODE) {
serial_write_compressed(translate("Running in safe mode! Auto-reload is off.\n"));
serial_write_compressed(translate("Running in safe mode! "));
serial_write_compressed(translate("Auto-reload is off.\n"));
} else if (!autoreload_is_enabled()) {
serial_write_compressed(translate("Auto-reload is off.\n"));
}
@ -250,25 +251,30 @@ bool run_code_py(safe_mode_t safe_mode) {
bool found_main = false;
if (safe_mode != NO_SAFE_MODE) {
serial_write_compressed(translate("Running in safe mode! Not running saved code.\n"));
serial_write_compressed(translate("Running in safe mode! "));
serial_write_compressed(translate("Not running saved code.\n"));
} else {
new_status_color(MAIN_RUNNING);
static const char *supported_filenames[] = STRING_LIST("code.txt", "code.py", "main.py", "main.txt");
static const char *double_extension_filenames[] = STRING_LIST("code.txt.py", "code.py.txt", "code.txt.txt","code.py.py",
static const char * const supported_filenames[] = STRING_LIST("code.txt", "code.py", "main.py", "main.txt");
#if CIRCUITPY_FULL_BUILD
static const char * const double_extension_filenames[] = STRING_LIST("code.txt.py", "code.py.txt", "code.txt.txt","code.py.py",
"main.txt.py", "main.py.txt", "main.txt.txt","main.py.py");
#endif
stack_resize();
filesystem_flush();
supervisor_allocation* heap = allocate_remaining_memory();
start_mp(heap);
found_main = maybe_run_list(supported_filenames, &result);
#if CIRCUITPY_FULL_BUILD
if (!found_main){
found_main = maybe_run_list(double_extension_filenames, &result);
if (found_main) {
serial_write_compressed(translate("WARNING: Your code filename has two extensions\n"));
}
}
#endif
cleanup_after_vm(heap);
if (result.return_code & PYEXEC_FORCED_EXIT) {
@ -337,7 +343,7 @@ void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
// If not in safe mode, run boot before initing USB and capture output in a
// file.
if (filesystem_present() && safe_mode == NO_SAFE_MODE && MP_STATE_VM(vfs_mount_table) != NULL) {
static const char *boot_py_filenames[] = STRING_LIST("settings.txt", "settings.py", "boot.py", "boot.txt");
static const char * const boot_py_filenames[] = STRING_LIST("settings.txt", "settings.py", "boot.py", "boot.txt");
new_status_color(BOOT_RUNNING);

View File

@ -82,4 +82,6 @@ endif
OBJ = $(PY_O)
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
$(BUILD)/supervisor/shared/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h
include $(TOP)/py/mkrules.mk

View File

@ -298,7 +298,7 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) {
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
if (self->len == 0) {
mp_raise_IndexError(translate("pop from an empty PulseIn"));
mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn);
}
common_hal_mcu_disable_interrupts();
uint16_t value = self->buffer[self->start];
@ -330,7 +330,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self,
}
if (index < 0 || index >= self->len) {
common_hal_mcu_enable_interrupts();
mp_raise_IndexError(translate("index out of range"));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
}
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
common_hal_mcu_enable_interrupts();

View File

@ -68,7 +68,11 @@ int common_hal_rtc_get_calibration(void) {
void common_hal_rtc_set_calibration(int calibration) {
if (calibration > 127 || calibration < -127) {
#if CIRCUITPY_FULL_BUILD
mp_raise_ValueError(translate("calibration value out of range +/-127"));
#else
mp_raise_ValueError(translate("calibration is out of range"));
#endif
}
hri_rtcmode0_write_FREQCORR_SIGN_bit(RTC, calibration < 0 ? 0 : 1);

View File

@ -160,7 +160,7 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t *self) {
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) {
if (self->len == 0) {
mp_raise_IndexError(translate("pop from an empty PulseIn"));
mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn);
}
common_hal_mcu_disable_interrupts();
uint16_t value = self->buffer[self->start];
@ -190,7 +190,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_
}
if (index < 0 || index >= self->len) {
common_hal_mcu_enable_interrupts();
mp_raise_IndexError(translate("index out of range"));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
}
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
common_hal_mcu_enable_interrupts();

View File

@ -201,7 +201,7 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) {
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
// if (self->len == 0) {
// mp_raise_IndexError(translate("pop from an empty PulseIn"));
// mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn);
// }
// common_hal_mcu_disable_interrupts();
// uint16_t value = self->buffer[self->start];
@ -237,7 +237,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self,
// }
// if (index < 0 || index >= self->len) {
// common_hal_mcu_enable_interrupts();
// mp_raise_IndexError(translate("index out of range"));
// mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
// }
// uint16_t value = self->buffer[(self->start + index) % self->maxlen];
// common_hal_mcu_enable_interrupts();

View File

@ -271,7 +271,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_
if ( !self->paused ) {
nrfx_gpiote_in_event_enable(self->pin, true);
}
mp_raise_IndexError(translate("index out of range"));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
}
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
@ -284,7 +284,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
if (self->len == 0) {
mp_raise_IndexError(translate("pop from an empty PulseIn"));
mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn);
}
if ( !self->paused ) {

View File

@ -249,7 +249,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_
}
if (index < 0 || index >= self->len) {
HAL_NVIC_EnableIRQ(self->irq);
mp_raise_IndexError(translate("index out of range"));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_PulseIn);
}
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
HAL_NVIC_EnableIRQ(self->irq);
@ -258,7 +258,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
if (self->len == 0) {
mp_raise_IndexError(translate("pop from an empty PulseIn"));
mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn);
}
HAL_NVIC_DisableIRQ(self->irq);
uint16_t value = self->buffer[self->start];

View File

@ -60,7 +60,7 @@ extern const mp_obj_type_t mp_type_textio;
STATIC void fdfile_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_fdfile_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "<io.%s %d>", mp_obj_get_type_str(self_in), self->fd);
mp_printf(print, "<io.%q %d>", mp_obj_get_type_qstr(self_in), self->fd);
}
STATIC mp_uint_t fdfile_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {

View File

@ -58,7 +58,7 @@ mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) {
}
const char *mp_obj_get_type_str(mp_const_obj_t o_in) {
return qstr_str(mp_obj_get_type(o_in)->name);
return qstr_str(mp_obj_get_type_qstr(o_in));
}
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
@ -260,10 +260,10 @@ mp_int_t mp_obj_get_int(mp_const_obj_t arg) {
return mp_obj_int_get_checked(arg);
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("can't convert to int"));
mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_int);
} else {
mp_raise_TypeError_varg(
translate("can't convert %s to int"), mp_obj_get_type_str(arg));
translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_int);
}
}
}
@ -323,10 +323,10 @@ mp_float_t mp_obj_get_float(mp_obj_t arg) {
if (!mp_obj_get_float_maybe(arg, &val)) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("can't convert to float"));
mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_float);
} else {
mp_raise_TypeError_varg(
translate("can't convert %s to float"), mp_obj_get_type_str(arg));
translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_float);
}
}
@ -356,10 +356,10 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
mp_obj_complex_get(arg, real, imag);
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("can't convert to complex"));
mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_complex);
} else {
mp_raise_TypeError_varg(
translate("can't convert %s to complex"), mp_obj_get_type_str(arg));
translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_complex);
}
}
}
@ -377,7 +377,7 @@ void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) {
mp_raise_TypeError(translate("expected tuple/list"));
} else {
mp_raise_TypeError_varg(
translate("object '%s' is not a tuple or list"), mp_obj_get_type_str(o));
translate("object '%q' is not a tuple or list"), mp_obj_get_type_qstr(o));
}
}
}
@ -406,8 +406,8 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool
mp_raise_TypeError(translate("indices must be integers"));
} else {
mp_raise_TypeError_varg(
translate("%q indices must be integers, not %s"),
type->name, mp_obj_get_type_str(index));
translate("%q indices must be integers, not %q"),
type->name, mp_obj_get_type_qstr(index));
}
}
@ -461,7 +461,7 @@ mp_obj_t mp_obj_len(mp_obj_t o_in) {
mp_raise_TypeError(translate("object has no len"));
} else {
mp_raise_TypeError_varg(
translate("object of type '%s' has no len()"), mp_obj_get_type_str(o_in));
translate("object of type '%q' has no len()"), mp_obj_get_type_qstr(o_in));
}
} else {
return len;
@ -504,21 +504,21 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) {
mp_raise_TypeError(translate("object does not support item deletion"));
} else {
mp_raise_TypeError_varg(
translate("'%s' object does not support item deletion"), mp_obj_get_type_str(base));
translate("'%q' object does not support item deletion"), mp_obj_get_type_qstr(base));
}
} else if (value == MP_OBJ_SENTINEL) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("object is not subscriptable"));
} else {
mp_raise_TypeError_varg(
translate("'%s' object is not subscriptable"), mp_obj_get_type_str(base));
translate("'%q' object is not subscriptable"), mp_obj_get_type_qstr(base));
}
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("object does not support item assignment"));
} else {
mp_raise_TypeError_varg(
translate("'%s' object does not support item assignment"), mp_obj_get_type_str(base));
translate("'%q' object does not support item assignment"), mp_obj_get_type_qstr(base));
}
}
}

View File

@ -680,6 +680,7 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items);
mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in);
const char *mp_obj_get_type_str(mp_const_obj_t o_in);
#define mp_obj_get_type_qstr(o_in) (mp_obj_get_type((o_in))->name)
bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); // arguments should be type objects
mp_obj_t mp_instance_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type);

View File

@ -313,7 +313,7 @@ STATIC mp_obj_t dict_popitem(mp_obj_t self_in) {
size_t cur = 0;
mp_map_elem_t *next = dict_iter_next(self, &cur);
if (next == NULL) {
mp_raise_msg(&mp_type_KeyError, translate("popitem(): dictionary is empty"));
mp_raise_msg_varg(&mp_type_KeyError, translate("pop from empty %q"), MP_QSTR_dict);
}
self->map.used--;
mp_obj_t items[] = {next->key, next->value};

View File

@ -141,9 +141,9 @@ STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
mp_obj_t mp_obj_new_int_from_float(mp_float_t val) {
int cl = fpclassify(val);
if (cl == FP_INFINITE) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OverflowError, translate("can't convert inf to int")));
mp_raise_OverflowError_varg(translate("can't convert %q to %q"), MP_QSTR_inf, MP_QSTR_int);
} else if (cl == FP_NAN) {
mp_raise_ValueError(translate("can't convert NaN to int"));
mp_raise_ValueError_varg(translate("can't convert %q to %q"), MP_QSTR_NaN, MP_QSTR_int);
} else {
mp_fp_as_int_class_t icl = mp_classify_fp_as_int(val);
if (icl == MP_FP_CLASS_FIT_SMALLINT) {

View File

@ -274,7 +274,7 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args) {
mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_list));
mp_obj_list_t *self = mp_instance_cast_to_native_base(args[0], &mp_type_list);
if (self->len == 0) {
mp_raise_IndexError(translate("pop from empty list"));
mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_list);
}
size_t index = mp_get_index(self->base.type, self->len, n_args == 1 ? MP_OBJ_NEW_SMALL_INT(-1) : args[1], false);
mp_obj_t ret = self->items[index];

View File

@ -368,7 +368,7 @@ STATIC mp_obj_t set_pop(mp_obj_t self_in) {
mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
mp_obj_t obj = mp_set_remove_first(&self->set);
if (obj == MP_OBJ_NULL) {
mp_raise_msg(&mp_type_KeyError, translate("pop from an empty set"));
mp_raise_msg_varg(&mp_type_KeyError, translate("pop from empty %q"), MP_QSTR_set);
}
return obj;
}

View File

@ -1076,7 +1076,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
}
field_name = str_to_int(field_name, field_name_top, &index);
if ((uint)index >= n_args - 1) {
mp_raise_IndexError(translate("tuple index out of range"));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_tuple);
}
arg = args[index + 1];
*arg_i = -1;
@ -1104,7 +1104,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
}
}
if ((uint)*arg_i >= n_args - 1) {
mp_raise_IndexError(translate("tuple index out of range"));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_tuple);
}
arg = args[(*arg_i) + 1];
(*arg_i)++;
@ -1280,8 +1280,8 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError_varg(
translate("unknown format code '%c' for object of type '%s'"),
type, mp_obj_get_type_str(arg));
translate("unknown format code '%c' for object of type '%q'"),
type, mp_obj_get_type_qstr(arg));
}
}
}
@ -1352,8 +1352,8 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError_varg(
translate("unknown format code '%c' for object of type '%s'"),
type, mp_obj_get_type_str(arg));
translate("unknown format code '%c' for object of type '%q'"),
type, mp_obj_get_type_qstr(arg));
}
}
} else {
@ -1388,8 +1388,8 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
terse_str_format_value_error();
} else {
mp_raise_ValueError_varg(
translate("unknown format code '%c' for object of type '%s'"),
type, mp_obj_get_type_str(arg));
translate("unknown format code '%c' for object of type '%q'"),
type, mp_obj_get_type_qstr(arg));
}
}
}
@ -2133,7 +2133,7 @@ STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("can't convert to str implicitly"));
} else {
const qstr src_name = mp_obj_get_type(self_in)->name;
const qstr src_name = mp_obj_get_type_qstr(self_in);
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
translate("can't convert '%q' object to %q implicitly"),
src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str));

View File

@ -151,7 +151,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (MP_OBJ_IS_SMALL_INT(index)) {
i = MP_OBJ_SMALL_INT_VALUE(index);
} else if (!mp_obj_get_int_maybe(index, &i)) {
mp_raise_TypeError_varg(translate("string indices must be integers, not %s"), mp_obj_get_type_str(index));
mp_raise_TypeError_varg(translate("string indices must be integers, not %q"), mp_obj_get_type_qstr(index));
}
const byte *s, *top = self_data + self_len;
if (i < 0)
@ -162,7 +162,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (is_slice) {
return self_data;
}
mp_raise_IndexError(translate("string index out of range"));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_str);
}
if (!UTF8_IS_CONT(*s)) {
++i;
@ -181,7 +181,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
if (is_slice) {
return top;
}
mp_raise_IndexError(translate("string index out of range"));
mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_str);
}
// Then check completion
if (i-- == 0) {

View File

@ -193,7 +193,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
printf("mp_obj_class_lookup: Returning: ");
mp_obj_print(lookup->dest[0], PRINT_REPR); printf(" ");
// Don't try to repr() lookup->dest[1], as we can be called recursively
printf("<%s @%p>\n", mp_obj_get_type_str(lookup->dest[1]), lookup->dest[1]);
printf("<%q @%p>\n", mp_obj_get_type_qstr(lookup->dest[1]), lookup->dest[1]);
#endif
return;
}
@ -285,7 +285,7 @@ STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_k
}
// TODO: CPython prints fully-qualified type name
mp_printf(print, "<%s object at %p>", mp_obj_get_type_str(self_in), self);
mp_printf(print, "<%q object at %p>", mp_obj_get_type_qstr(self_in), self);
}
mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
@ -376,8 +376,8 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, cons
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("__init__() should return None"));
} else {
mp_raise_TypeError_varg(translate("__init__() should return None, not '%s'"),
mp_obj_get_type_str(init_ret));
mp_raise_TypeError_varg(translate("__init__() should return None, not '%q'"),
mp_obj_get_type_qstr(init_ret));
}
}
@ -891,8 +891,8 @@ mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("object not callable"));
} else {
mp_raise_TypeError_varg(translate("'%s' object is not callable"),
mp_obj_get_type_str(self_in));
mp_raise_TypeError_varg(translate("'%q' object is not callable"),
mp_obj_get_type_qstr(self_in));
}
}
mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);

View File

@ -45,6 +45,6 @@ const void *mp_proto_get_or_throw(uint16_t name, mp_const_obj_t obj) {
if (proto) {
return proto;
}
mp_raise_TypeError_varg(translate("'%s' object does not support '%q'"),
mp_obj_get_type_str(obj), name);
mp_raise_TypeError_varg(translate("'%q' object does not support '%q'"),
mp_obj_get_type_qstr(obj), name);
}

View File

@ -279,8 +279,8 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) {
mp_raise_TypeError(translate("unsupported type for operator"));
} else {
mp_raise_TypeError_varg(
translate("unsupported type for %q: '%s'"),
mp_unary_op_method_name[op], mp_obj_get_type_str(arg));
translate("unsupported type for %q: '%q'"),
mp_unary_op_method_name[op], mp_obj_get_type_qstr(arg));
}
}
}
@ -586,8 +586,8 @@ unsupported_op:
mp_raise_TypeError(translate("unsupported type for operator"));
} else {
mp_raise_TypeError_varg(
translate("unsupported types for %q: '%s', '%s'"),
mp_binary_op_method_name[op], mp_obj_get_type_str(lhs), mp_obj_get_type_str(rhs));
translate("unsupported types for %q: '%q', '%q'"),
mp_binary_op_method_name[op], mp_obj_get_type_qstr(lhs), mp_obj_get_type_qstr(rhs));
}
zero_division:
@ -627,7 +627,7 @@ mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, cons
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("object not callable"));
} else {
mp_raise_TypeError_varg(translate("'%s' object is not callable"), mp_obj_get_type_str(fun_in));
mp_raise_TypeError_varg(translate("'%q' object is not callable"), mp_obj_get_type_qstr(fun_in));
}
}
@ -1104,8 +1104,8 @@ void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) {
((mp_obj_type_t*)MP_OBJ_TO_PTR(base))->name, attr));
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError,
translate("'%s' object has no attribute '%q'"),
mp_obj_get_type_str(base), attr));
translate("'%q' object has no attribute '%q'"),
mp_obj_get_type_qstr(base), attr));
}
}
}
@ -1172,8 +1172,8 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) {
mp_raise_AttributeError(translate("no such attribute"));
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError,
translate("'%s' object cannot assign attribute '%q'"),
mp_obj_get_type_str(base), attr));
translate("'%q' object cannot assign attribute '%q'"),
mp_obj_get_type_qstr(base), attr));
}
}
@ -1213,7 +1213,7 @@ mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
mp_raise_TypeError(translate("object not iterable"));
} else {
mp_raise_TypeError_varg(
translate("'%s' object is not iterable"), mp_obj_get_type_str(o_in));
translate("'%q' object is not iterable"), mp_obj_get_type_qstr(o_in));
}
}
@ -1234,8 +1234,8 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("object not an iterator"));
} else {
mp_raise_TypeError_varg(translate("'%s' object is not an iterator"),
mp_obj_get_type_str(o_in));
mp_raise_TypeError_varg(translate("'%q' object is not an iterator"),
mp_obj_get_type_qstr(o_in));
}
}
}
@ -1270,8 +1270,8 @@ mp_obj_t mp_iternext(mp_obj_t o_in) {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
mp_raise_TypeError(translate("object not an iterator"));
} else {
mp_raise_TypeError_varg(translate("'%s' object is not an iterator"),
mp_obj_get_type_str(o_in));
mp_raise_TypeError_varg(translate("'%q' object is not an iterator"),
mp_obj_get_type_qstr(o_in));
}
}
}
@ -1522,12 +1522,16 @@ NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_strin
}
}
NORETURN void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list argptr) {
mp_obj_t exception = mp_obj_new_exception_msg_vlist(exc_type, fmt, argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(exc_type, fmt, argptr);
mp_raise_msg_vlist(exc_type, fmt, argptr);
va_end(argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_AttributeError(const compressed_string_t *msg) {
@ -1546,6 +1550,13 @@ NORETURN void mp_raise_IndexError(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_IndexError, msg);
}
NORETURN void mp_raise_IndexError_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_raise_msg_vlist(&mp_type_IndexError, fmt, argptr);
va_end(argptr);
}
NORETURN void mp_raise_ValueError(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_ValueError, msg);
}
@ -1553,9 +1564,8 @@ NORETURN void mp_raise_ValueError(const compressed_string_t *msg) {
NORETURN void mp_raise_ValueError_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_ValueError, fmt, argptr);
mp_raise_msg_vlist(&mp_type_ValueError, fmt, argptr);
va_end(argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_TypeError(const compressed_string_t *msg) {
@ -1565,9 +1575,8 @@ NORETURN void mp_raise_TypeError(const compressed_string_t *msg) {
NORETURN void mp_raise_TypeError_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_TypeError, fmt, argptr);
mp_raise_msg_vlist(&mp_type_TypeError, fmt, argptr);
va_end(argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_OSError(int errno_) {
@ -1589,9 +1598,8 @@ NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str) {
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_OSError, fmt, argptr);
mp_raise_msg_vlist(&mp_type_OSError, fmt, argptr);
va_end(argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg) {
@ -1601,17 +1609,15 @@ NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg) {
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_NotImplementedError, fmt, argptr);
mp_raise_msg_vlist(&mp_type_NotImplementedError, fmt, argptr);
va_end(argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_OverflowError, fmt, argptr);
mp_raise_msg_vlist(&mp_type_OverflowError, fmt, argptr);
va_end(argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_MpyError(const compressed_string_t *msg) {

View File

@ -152,6 +152,7 @@ void mp_import_all(mp_obj_t module);
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg);
NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...);
NORETURN void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list argptr);
NORETURN void mp_raise_ValueError(const compressed_string_t *msg);
NORETURN void mp_raise_ValueError_varg(const compressed_string_t *fmt, ...);
NORETURN void mp_raise_TypeError(const compressed_string_t *msg);
@ -160,6 +161,7 @@ NORETURN void mp_raise_AttributeError(const compressed_string_t *msg);
NORETURN void mp_raise_RuntimeError(const compressed_string_t *msg);
NORETURN void mp_raise_ImportError(const compressed_string_t *msg);
NORETURN void mp_raise_IndexError(const compressed_string_t *msg);
NORETURN void mp_raise_IndexError_varg(const compressed_string_t *msg, ...);
NORETURN void mp_raise_OSError(int errno_);
NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str);
NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg);

View File

@ -145,8 +145,8 @@ const mp_obj_property_t bleio_adapter_name_obj = {
//| .. note: If you set ``anonymous=True``, then a timeout must be specified. If no timeout is
//| specified, then the maximum allowed timeout will be selected automatically.
//|
//| :param buf data: advertising data packet bytes
//| :param buf scan_response: scan response data packet bytes. ``None`` if no scan response is needed.
//| :param ~_typing.ReadableBuffer data: advertising data packet bytes
//| :param ~_typing.ReadableBuffer scan_response: scan response data packet bytes. ``None`` if no scan response is needed.
//| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral.
//| :param bool anonymous: If `True` then this device's MAC address is randomized before advertising.
//| :param int timeout: If set, we will only advertise for this many seconds.
@ -219,7 +219,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapt
//| """Starts a BLE scan and returns an iterator of results. Advertisements and scan responses are
//| filtered and returned separately.
//|
//| :param sequence prefixes: Sequence of byte string prefixes to filter advertising packets
//| :param ~_typing.ReadableBuffer prefixes: Sequence of byte string prefixes to filter advertising packets
//| with. A packet without an advertising structure that matches one of the prefixes is
//| ignored. Format is one byte for length (n) and n bytes of prefix and can be repeated.
//| :param int buffer_size: the maximum number of advertising bytes to buffer.
@ -334,7 +334,7 @@ const mp_obj_property_t bleio_adapter_connected_obj = {
(mp_obj_t)&mp_const_none_obj },
};
//| connections: tuple
//| connections: Tuple[Connection]
//| """Tuple of active connections including those initiated through
//| :py:meth:`_bleio.Adapter.connect`. (read-only)"""
//|

View File

@ -42,7 +42,7 @@
//| """Create a new Address object encapsulating the address value.
//| The value itself can be one of:
//|
//| :param buf address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes.
//| :param ~_typing.ReadableBuffer address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes.
//| :param int address_type: one of the integer values: `PUBLIC`, `RANDOM_STATIC`,
//| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`."""
//| ...
@ -128,7 +128,7 @@ const mp_obj_property_t bleio_address_type_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| def __eq__(self, other: Address) -> bool:
//| def __eq__(self, other: object) -> bool:
//| """Two Address objects are equal if their addresses and address types are equal."""
//| ...
//|

View File

@ -63,7 +63,7 @@
//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum
//| number of data bytes that fit in a single BLE 4.x ATT packet.
//| :param bool fixed_length: True if the characteristic value is of fixed length.
//| :param buf initial_value: The initial value for this characteristic. If not given, will be
//| :param ~_typing.ReadableBuffer initial_value: The initial value for this characteristic. If not given, will be
//| filled with zeros.
//|
//| :return: the new Characteristic."""

View File

@ -116,7 +116,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_pair_obj, 1, bleio_connection
//|
//| :param iterable service_uuids_whitelist:
//|
//| an iterable of :py:class:~`UUID` objects for the services provided by the peripheral
//| an iterable of :py:class:`UUID` objects for the services provided by the peripheral
//| that you want to use.
//|
//| The peripheral may provide more services, but services not listed are ignored
@ -126,7 +126,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_pair_obj, 1, bleio_connection
//| slow.
//|
//| If the service UUID is 128-bit, or its characteristic UUID's are 128-bit, you
//| you must have already created a :py:class:~`UUID` object for that UUID in order for the
//| you must have already created a :py:class:`UUID` object for that UUID in order for the
//| service or characteristic to be discovered. Creating the UUID causes the UUID to be
//| registered for use. (This restriction may be lifted in the future.)
//|

View File

@ -46,7 +46,7 @@
//| as part of remote Characteristics in the remote Services that are discovered."""
//|
//| @classmethod
//| def add_to_characteristic(characteristic: Characteristic, uuid: UUID, *, read_perm: int = Attribute.OPEN, write_perm: int = Attribute.OPEN, max_length = 20, fixed_length: bool = False, initial_value: ReadableBuffer = b'') -> Descriptor:
//| def add_to_characteristic(cls, characteristic: Characteristic, uuid: UUID, *, read_perm: int = Attribute.OPEN, write_perm: int = Attribute.OPEN, max_length: int = 20, fixed_length: bool = False, initial_value: ReadableBuffer = b'') -> Descriptor:
//| """Create a new Descriptor object, and add it to this Service.
//|
//| :param Characteristic characteristic: The characteristic that will hold this descriptor
@ -61,7 +61,7 @@
//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum
//| number of data bytes that fit in a single BLE 4.x ATT packet.
//| :param bool fixed_length: True if the descriptor value is of fixed length.
//| :param buf initial_value: The initial value for this descriptor.
//| :param ~_typing.ReadableBuffer initial_value: The initial value for this descriptor.
//|
//| :return: the new Descriptor."""
//| ...

View File

@ -48,7 +48,7 @@
//| temporary 16-bit UUID that can be used in place of the full 128-bit UUID.
//|
//| :param value: The uuid value to encapsulate
//| :type value: int or typing.ByteString"""
//| :type value: int, ~_typing.ReadableBuffer or str"""
//| ...
//|
STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@ -248,7 +248,7 @@ STATIC mp_obj_t bleio_uuid_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
//| def __eq__(self, other: UUID) -> bool:
//| def __eq__(self, other: object) -> bool:
//| """Two UUID objects are equal if their values match and they are both 128-bit or both 16-bit."""
//| ...
//|

View File

@ -41,7 +41,8 @@
#include "shared-bindings/_bleio/Service.h"
#include "shared-bindings/_bleio/UUID.h"
//| """
//| """Bluetooth Low Energy (BLE) communication
//|
//| The `_bleio` module provides necessary low-level functionality for communicating
//| using Bluetooth Low Energy (BLE). The '_' prefix indicates this module is meant
//| for internal use by libraries but not by the end user. Its API may change incompatibly
@ -50,11 +51,11 @@
//| `adafruit_ble <https://circuitpython.readthedocs.io/projects/ble/en/latest/>`_
//| CircuitPython library instead, which builds on `_bleio`, and
//| provides higher-level convenience functionality, including predefined beacons, clients,
//| servers.
//| servers."""
//|
//| .. attribute:: adapter
//|
//| BLE Adapter used to manage device discovery and connections.
//| adapter: Adapter
//| """BLE Adapter used to manage device discovery and connections.
//| This object is the sole instance of `_bleio.Adapter`."""
//|

View File

@ -41,6 +41,9 @@
//| buffers and appending basic graphics commands."""
//|
//| class _EVE:
//|
typedef struct _mp_obj__EVE_t {
mp_obj_base_t base;
common_hal__eve_t _eve;
@ -51,6 +54,9 @@ STATIC const mp_obj_type_t _EVE_type;
#define EVEHAL(s) \
(&((mp_obj__EVE_t*)mp_instance_cast_to_native_base((s), &_EVE_type))->_eve)
//| def register(self, o: object) -> None:
//| ...
//|
STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) {
common_hal__eve_t *eve = EVEHAL(self);
mp_load_method(o, MP_QSTR_write, eve->dest);
@ -73,7 +79,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush);
//| def cc(self, b: ReadableBuffer) -> None:
//| """Append bytes to the command FIFO.
//|
//| :param bytes b: The bytes to add"""
//| :param ~_typing.ReadableBuffer b: The bytes to add"""
//| ...
//|
STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) {
@ -990,12 +996,13 @@ STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0);
//| def cmd(self, n: int, fmt: str, args: tuple) -> None:
//| def cmd(self, n: int, fmt: str, args: Tuple[str, ...]) -> None:
//| """Append a command packet to the FIFO.
//|
//| :param int n: The command code
//| :param str fmt: The command format `struct` layout
//| :param tuple args: The command's arguments
//| :param args: The command's arguments
//| :type args: tuple(str, ...)
//|
//| Supported format codes: h, H, i, I.
//|

View File

@ -48,26 +48,8 @@
//| def __init__(
//| self,
//| buffer: ReadableBuffer,
//| rows: List[
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| ],
//| cols: List[
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| digitalio.DigitalInOut,
//| ],
//| rows: List[digitalio.DigitalInOut],
//| cols: List[digitalio.DigitalInOut],
//| buttons: digitalio.DigitalInOut,
//| ) -> None:
//| """Initializes matrix scanning routines.

View File

@ -58,12 +58,12 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t
//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte for each
//| pixel.
//|
//| :param ~int size: Number of pixels
//| :param ~str byteorder: Byte order string (such as "RGB", "RGBW" or "PBGR")
//| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
//| :param ~bool auto_write: Whether to automatically write pixels (Default False)
//| :param bytes header: Sequence of bytes to always send before pixel values.
//| :param bytes trailer: Sequence of bytes to always send after pixel values."""
//| :param int size: Number of pixels
//| :param str byteorder: Byte order string (such as "RGB", "RGBW" or "PBGR")
//| :param float brightness: Brightness (0 to 1.0, default 1.0)
//| :param bool auto_write: Whether to automatically write pixels (Default False)
//| :param ~_typing.ReadableBuffer header: Sequence of bytes to always send before pixel values.
//| :param ~_typing.ReadableBuffer trailer: Sequence of bytes to always send after pixel values."""
//| ...
//|
STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@ -257,7 +257,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show);
//| def fill(self, color: Union[int, Tuple[int, int, int]]) -> None:
//| def fill(self, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, float]]) -> None:
//| """Fills the given pixelbuf with the given color."""
//| ...
//|
@ -270,18 +270,20 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) {
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill);
//| @overload
//| def __getitem__(self, index: slice) -> Tuple[Tuple, ...]: ...
//| def __getitem__(self, index: int) -> Tuple:
//| def __getitem__(self, index: slice) -> Union[Tuple[Tuple[int, int, int], ...], Tuple[Tuple[int, int, int, float], ...]]: ...
//| @overload
//| def __getitem__(self, index: int) -> Union[Tuple[int, int, int], Tuple[int, int, int, float]]:
//| """Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values
//| between 0 and 255. When in PWM (DotStar) mode, the 4th tuple value is a float of the pixel
//| intensity from 0-1.0."""
//| ...
//|
//| @overload
//| def __setitem__(self, index: slice, value: Tuple[Union[int, Tuple, List], ...]) -> None: ...
//| def __setitem__(self, index: slice, value: Tuple[Union[int, Tuple[float, ...], List[float]], ...]) -> None: ...
//| @overload
//| def __setitem__(self, index: slice, value: List[Union[int, Tuple, List]]) -> None: ...
//| def __setitem__(self, index: int, value: Union[int, Tuple, List]) -> None:
//| def __setitem__(self, index: slice, value: List[Union[int, Tuple[float, ...], List[float]]]) -> None: ...
//| @overload
//| def __setitem__(self, index: int, value: Union[int, Tuple[float, ...], List[float]]) -> None:
//| """Sets the pixel value at the given index. Value can either be a tuple or integer. Tuples are
//| The individual (Red, Green, Blue[, White]) values between 0 and 255. If given an integer, the
//| red, green and blue values are packed into the lower three bytes (0xRRGGBB).

View File

@ -33,7 +33,7 @@
#include "shared-bindings/_pixelbuf/PixelBuf.h"
//| """A fast RGB(W) pixel buffer library for like NeoPixel and DotStar.
//| """A fast RGB(W) pixel buffer library for like NeoPixel and DotStar
//|
//| The `_pixelbuf` module provides the :py:class:`PixelBuf` class to accelerate
//| RGB(W) strip/matrix manipulation, such as DotStar and Neopixel.

View File

@ -40,9 +40,9 @@
//|
//| :param int width: The width of the grid in tiles, or 1 for sprites.
//| :param int height: The height of the grid in tiles, or 1 for sprites.
//| :param bytearray graphic: The graphic data of the tiles.
//| :param bytearray palette: The color palette to be used.
//| :param bytearray grid: The contents of the grid map.
//| :param ~_typing.ReadableBuffer graphic: The graphic data of the tiles.
//| :param ~_typing.ReadableBuffer palette: The color palette to be used.
//| :param ~_typing.ReadableBuffer grid: The contents of the grid map.
//|
//| This class is intended for internal use in the ``stage`` library and
//| it shouldn't be used on its own."""

View File

@ -40,9 +40,9 @@
//|
//| :param int width: The width of the grid in tiles, or 1 for sprites.
//| :param int height: The height of the grid in tiles, or 1 for sprites.
//| :param bytearray font: The font data of the characters.
//| :param bytearray palette: The color palette to be used.
//| :param bytearray chars: The contents of the character grid.
//| :param ~_typing.ReadableBuffer font: The font data of the characters.
//| :param ~_typing.ReadableBuffer palette: The color palette to be used.
//| :param ~_typing.ReadableBuffer chars: The contents of the character grid.
//|
//| This class is intended for internal use in the ``stage`` library and
//| it shouldn't be used on its own."""

View File

@ -39,15 +39,16 @@
//| The `_stage` module contains native code to speed-up the ```stage`` Library
//| <https://github.com/python-ugame/circuitpython-stage>`_."""
//|
//| def render(x0: int, y0: int, x1: int, y1: int, layers: list, buffer: WriteableBuffer, display: displayio.Display, scale: int, background: int) -> None:
//| def render(x0: int, y0: int, x1: int, y1: int, layers: List[Layer], buffer: WriteableBuffer, display: displayio.Display, scale: int, background: int) -> None:
//| """Render and send to the display a fragment of the screen.
//|
//| :param int x0: Left edge of the fragment.
//| :param int y0: Top edge of the fragment.
//| :param int x1: Right edge of the fragment.
//| :param int y1: Bottom edge of the fragment.
//| :param list layers: A list of the :py:class:`~_stage.Layer` objects.
//| :param bytearray buffer: A buffer to use for rendering.
//| :param layers: A list of the :py:class:`~_stage.Layer` objects.
//| :type layers: list[Layer]
//| :param ~_typing.WriteableBuffer buffer: A buffer to use for rendering.
//| :param ~displayio.Display display: The display to use.
//| :param int scale: How many times should the image be scaled up.
//| :param int background: What color to display when nothing is there.

View File

@ -0,0 +1,54 @@
"""Types for the C-level protocols"""
from typing import Union
import array
import audiocore
import audiomixer
import audiomp3
import rgbmatrix
import ulab
ReadableBuffer = Union[
bytes, bytearray, memoryview, array.array, ulab.array, rgbmatrix.RGBMatrix
]
"""Classes that implement the readable buffer protocol
- `bytes`
- `bytearray`
- `memoryview`
- `array.array`
- `ulab.array`
- `rgbmatrix.RGBMatrix`
"""
WriteableBuffer = Union[
bytearray, memoryview, array.array, ulab.array, rgbmatrix.RGBMatrix
]
"""Classes that implement the writeable buffer protocol
- `bytearray`
- `memoryview`
- `array.array`
- `ulab.array`
- `rgbmatrix.RGBMatrix`
"""
AudioSample = Union[
audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer, audiomp3.MP3Decoder
]
"""Classes that implement the audiosample protocol
- `audiocore.WaveFile`
- `audiocore.RawSample`
- `audiomixer.Mixer`
- `audiomp3.MP3Decoder`
You can play these back with `audioio.AudioOut`, `audiobusio.I2SOut` or `audiopwmio.PWMAudioOut`.
"""
FrameBuffer = Union[rgbmatrix.RGBMatrix]
"""Classes that implement the framebuffer protocol
- `rgbmatrix.RGBMatrix`
"""

View File

@ -15,10 +15,10 @@
//| def __init__(self, key: ReadableBuffer, mode: int = 0, iv: Optional[ReadableBuffer] = None, segment_size: int = 8) -> None:
//| """Create a new AES state with the given key.
//|
//| :param bytearray key: A 16-, 24-, or 32-byte key
//| :param ~_typing.ReadableBuffer key: A 16-, 24-, or 32-byte key
//| :param int mode: AES mode to use. One of: AES.MODE_ECB, AES.MODE_CBC, or
//| AES.MODE_CTR
//| :param bytearray iv: Initialization vector to use for CBC or CTR mode
//| :param ~_typing.ReadableBuffer iv: Initialization vector to use for CBC or CTR mode
//|
//| Additional arguments are supported for legacy reasons.
//|

View File

@ -155,11 +155,11 @@ STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *ar
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, audiobusio_i2sout_obj___exit__);
//| def play(self, sample: audiocore._AudioSample, *, loop: bool = False) -> None:
//| def play(self, sample: _typing.AudioSample, *, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`.
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, `audiomixer.Mixer` or `audiomp3.MP3Decoder`.
//|
//| The sample itself should consist of 8 bit or 16 bit samples."""
//| ...

View File

@ -44,7 +44,7 @@
//| first sample will be for channel 1, the second sample will be for channel two, the third for
//| channel 1 and so on.
//|
//| :param ReadableBuffer buffer: A buffer with samples
//| :param ~_typing.ReadableBuffer buffer: A buffer with samples
//| :param int channel_count: The number of channels in the buffer
//| :param int sample_rate: The desired playback sample rate
//|

View File

@ -40,11 +40,11 @@
//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
//| an internal buffer."""
//|
//| def __init__(self, file: typing.BinaryIO, buffer: ReadableBuffer) -> None:
//| def __init__(self, file: typing.BinaryIO, buffer: WriteableBuffer) -> None:
//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
//| :param typing.BinaryIO file: Already opened wave file
//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally.
//| :param ~_typing.WriteableBuffer buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally.
//|
//|
//| Playing a wave file from flash::

View File

@ -38,13 +38,6 @@
//| """Support for audio samples"""
//|
//| _AudioSample = Union[audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer, audiomp3.MP3Decoder]
//| """An audio sample for playback with `audioio.AudioOut`, `audiobusio.I2SOut` or `audiopwmio.PWMAudioOut`.
//|
//| Supported sources are :py:class:`audiocore.WaveFile`, :py:class:`audiocore.RawSample`,
//| :py:class:`audiomixer.Mixer` and :py:class:`audiomp3.MP3Decoder`."""
//|
STATIC const mp_rom_map_elem_t audiocore_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiocore) },
{ MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },

View File

@ -146,11 +146,11 @@ STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *arg
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, audioio_audioout_obj___exit__);
//| def play(self, sample: audiocore._AudioSample, *, loop: bool = False) -> None:
//| def play(self, sample: _typing.AudioSample, *, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`.
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, `audiomixer.Mixer` or `audiomp3.MP3Decoder`.
//|
//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output
//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit

View File

@ -211,11 +211,11 @@ const mp_obj_property_t audiomixer_mixer_voice_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| def play(self, sample: audiocore._AudioSample, *, voice: int = 0, loop: bool = False) -> None:
//| def play(self, sample: _typing.AudioSample, *, voice: int = 0, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`.
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, `audiomixer.Mixer` or `audiomp3.MP3Decoder`.
//|
//| The sample must match the Mixer's encoding settings given in the constructor."""
//| ...

View File

@ -56,11 +56,11 @@ STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t
return MP_OBJ_FROM_PTR(self);
}
//| def play(self, sample: audiocore._AudioSample, *, loop: bool = False) -> None:
//| def play(self, sample: _typing.AudioSample, *, loop: bool = False) -> None:
//| """Plays the sample once when ``loop=False``, and continuously when ``loop=True``.
//| Does not block. Use `playing` to block.
//|
//| Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`.
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, `audiomixer.Mixer` or `audiomp3.MP3Decoder`.
//|
//| The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor."""
//| ...

View File

@ -42,7 +42,7 @@
//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
//| :param typing.BinaryIO file: Already opened mp3 file
//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file.
//| :param ~_typing.WriteableBuffer buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file.
//|
//|
//| Playing a mp3 file from flash::
@ -106,7 +106,7 @@ STATIC void check_for_deinit(audiomp3_mp3file_obj_t *self) {
}
}
//| def __enter__(self) -> MP3:
//| def __enter__(self) -> MP3Decoder:
//| """No-op used by Context Managers."""
//| ...
//|
@ -124,7 +124,7 @@ STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *arg
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__);
//| file: file
//| file: typing.BinaryIO
//| """File to play back."""
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) {

View File

@ -148,11 +148,11 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj___exit__(size_t n_args, const mp_obj_
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_pwmaudioout___exit___obj, 4, 4, audiopwmio_pwmaudioout_obj___exit__);
//| def play(self, sample: audiocore._AudioSample, *, loop: bool = False) -> None:
//| def play(self, sample: _typing.AudioSample, *, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`.
//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, `audiomixer.Mixer` or `audiomp3.MP3Decoder`.
//|
//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output
//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit

View File

@ -120,7 +120,7 @@ static void check_lock(bitbangio_i2c_obj_t *self) {
}
}
//| def scan(self) -> list:
//| def scan(self) -> List[int]:
//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of
//| those that respond. A device responds if it pulls the SDA line low after
//| its address (including a read bit) is sent on the bus."""
@ -175,7 +175,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock);
//| ``buf[start:end]`` will so it saves memory.
//|
//| :param int address: 7-bit device address
//| :param bytearray buffer: buffer to write into
//| :param ~_typing.WriteableBuffer buffer: buffer to write into
//| :param int start: Index to start writing at
//| :param int end: Index to write up to but not include"""
//| ...
@ -230,7 +230,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_rea
//| to poll for the existence of a device.
//|
//| :param int address: 7-bit device address
//| :param bytearray buffer: buffer containing the bytes to write
//| :param ~_typing.ReadableBuffer buffer: buffer containing the bytes to write
//| :param int start: Index to start writing from
//| :param int end: Index to read up to but not include"""
//| ...
@ -274,7 +274,7 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_writeto);
//| def writeto_then_readfrom(self, address: int, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None:
//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[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.
@ -284,8 +284,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_wr
//| will so it saves memory.
//|
//| :param int address: 7-bit device address
//| :param bytearray out_buffer: buffer containing the bytes to write
//| :param bytearray in_buffer: buffer to write into
//| :param ~_typing.ReadableBuffer out_buffer: buffer containing the bytes to write
//| :param ~_typing.WriteableBuffer in_buffer: buffer to write into
//| :param int out_start: Index to start writing from
//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
//| :param int in_start: Index to start writing at

View File

@ -254,8 +254,8 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_spi_readinto_obj, 2, 2, bitbangio_
//| must be equal.
//| If buffer slice lengths are both 0, nothing happens.
//|
//| :param bytearray buffer_out: Write out the data in this buffer
//| :param bytearray buffer_in: Read data into this buffer
//| :param ~_typing.ReadableBuffer buffer_out: Write out the data in this buffer
//| :param ~_typing.WriteableBuffer buffer_in: Read data into this buffer
//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]``
//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)``
//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]``

View File

@ -125,7 +125,7 @@ static void check_lock(busio_i2c_obj_t *self) {
}
}
//| def scan(self) -> list:
//| def scan(self) -> List[int]:
//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a
//| list of those that respond.
//|
@ -185,7 +185,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock);
//| ``buf[start:end]`` will so it saves memory.
//|
//| :param int address: 7-bit device address
//| :param bytearray buffer: buffer to write into
//| :param ~_typing.WriteableBuffer buffer: buffer to write into
//| :param int start: Index to start writing at
//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``"""
//| ...
@ -239,7 +239,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_in
//| to poll for the existence of a device.
//|
//| :param int address: 7-bit device address
//| :param bytearray buffer: buffer containing the bytes to write
//| :param ~_typing.ReadbleBuffer buffer: buffer containing the bytes to write
//| :param int start: Index to start writing from
//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)``"""
//| ...
@ -291,8 +291,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto);
//| will so it saves memory.
//|
//| :param int address: 7-bit device address
//| :param bytearray out_buffer: buffer containing the bytes to write
//| :param bytearray in_buffer: buffer to write into
//| :param ~_typing.ReadbleBuffer out_buffer: buffer containing the bytes to write
//| :param ~_typing.WriteableBuffer in_buffer: buffer to write into
//| :param int out_start: Index to start writing from
//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
//| :param int in_start: Index to start writing at

View File

@ -232,7 +232,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock);
//| """Write the data contained in ``buffer``. The SPI object must be locked.
//| If the buffer is empty, nothing happens.
//|
//| :param bytearray buffer: Write out the data in this buffer
//| :param ~_typing.ReadableBuffer buffer: Write out the data in this buffer
//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]``
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``"""
//| ...
@ -275,7 +275,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write);
//| The SPI object must be locked.
//| If the number of bytes to read is 0, nothing happens.
//|
//| :param bytearray buffer: Read data into this buffer
//| :param ~_typing.WriteableBuffer buffer: Read data into this buffer
//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]``
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``
//| :param int write_value: Value to write while reading. (Usually ignored.)"""
@ -314,15 +314,15 @@ 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: ReadableBuffer, buffer_in: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None:
//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: WriteableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[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]``
//| must be equal.
//| If buffer slice lengths are both 0, nothing happens.
//|
//| :param bytearray buffer_out: Write out the data in this buffer
//| :param bytearray buffer_in: Read data into this buffer
//| :param ~_typing.ReadableBuffer buffer_out: Write out the data in this buffer
//| :param ~_typing.WriteableBuffer buffer_in: Read data into this buffer
//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]``
//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)``
//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]``

View File

@ -81,8 +81,8 @@
//| of the display to minimize tearing artifacts.
//|
//| :param display_bus: The bus that the display is connected to
//| :type display_bus: FourWire, ParallelBus or I2CDisplay
//| :param buffer init_sequence: Byte-packed initialization sequence.
//| :type _DisplayBus: FourWire, ParallelBus or I2CDisplay
//| :param ~_typing.ReadableBuffer init_sequence: Byte-packed initialization sequence.
//| :param int width: Width in pixels
//| :param int height: Height in pixels
//| :param int colstart: The index if the first visible column
@ -344,7 +344,7 @@ const mp_obj_property_t displayio_display_auto_brightness_obj = {
//| width: int
//| Gets the width of the board
//| """Gets the width of the board"""
//|
STATIC mp_obj_t displayio_display_obj_get_width(mp_obj_t self_in) {
displayio_display_obj_t *self = native_display(self_in);
@ -420,7 +420,7 @@ const mp_obj_property_t displayio_display_bus_obj = {
//| """Extract the pixels from a single row
//|
//| :param int y: The top edge of the area
//| :param bytearray buffer: The buffer in which to place the pixel data"""
//| :param ~_typing.WriteableBuffer buffer: The buffer in which to place the pixel data"""
//| ...
//|
STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {

View File

@ -60,9 +60,9 @@
//| begin a new command definition.
//|
//| :param display_bus: The bus that the display is connected to
//| :type display_bus: displayio.FourWire or displayio.ParallelBus
//| :param buffer start_sequence: Byte-packed initialization sequence.
//| :param buffer stop_sequence: Byte-packed initialization sequence.
//| :type _DisplayBus: displayio.FourWire or displayio.ParallelBus
//| :param ~_typing.ReadableBuffer start_sequence: Byte-packed initialization sequence.
//| :param ~_typing.ReadableBuffer stop_sequence: Byte-packed initialization sequence.
//| :param int width: Width in pixels
//| :param int height: Height in pixels
//| :param int ram_width: RAM width in pixels

View File

@ -190,7 +190,7 @@ const mp_obj_property_t displayio_group_y_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| def append(self, layer: Union[vectorio.Shape, Group, TileGrid]) -> None:
//| def append(self, layer: Union[vectorio.VectorShape, Group, TileGrid]) -> None:
//| """Append a layer to the group. It will be drawn above other layers."""
//| ...
//|
@ -201,7 +201,7 @@ STATIC mp_obj_t displayio_group_obj_append(mp_obj_t self_in, mp_obj_t layer) {
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_append_obj, displayio_group_obj_append);
//| def insert(self, index: int, layer: Union[vectorio.Shape, Group, TileGrid]) -> None:
//| def insert(self, index: int, layer: Union[vectorio.VectorShape, Group, TileGrid]) -> None:
//| """Insert a layer into the group."""
//| ...
//|
@ -217,7 +217,7 @@ STATIC mp_obj_t displayio_group_obj_insert(mp_obj_t self_in, mp_obj_t index_obj,
MP_DEFINE_CONST_FUN_OBJ_3(displayio_group_insert_obj, displayio_group_obj_insert);
//| def index(self, layer: Union[vectorio.Shape, Group, TileGrid]) -> int:
//| def index(self, layer: Union[vectorio.VectorShape, Group, TileGrid]) -> int:
//| """Returns the index of the first copy of layer. Raises ValueError if not found."""
//| ...
//|
@ -231,7 +231,7 @@ STATIC mp_obj_t displayio_group_obj_index(mp_obj_t self_in, mp_obj_t layer) {
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_index_obj, displayio_group_obj_index);
//| def pop(self, i: int = -1) -> Union[vectorio.Shape, Group, TileGrid]:
//| def pop(self, i: int = -1) -> Union[vectorio.VectorShape, Group, TileGrid]:
//| """Remove the ith item and return it."""
//| ...
//|
@ -254,7 +254,7 @@ STATIC mp_obj_t displayio_group_obj_pop(size_t n_args, const mp_obj_t *pos_args,
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_group_pop_obj, 1, displayio_group_obj_pop);
//| def remove(self, layer: Union[vectorio.Shape, Group, TileGrid]) -> None:
//| def remove(self, layer: Union[vectorio.VectorShape, Group, TileGrid]) -> None:
//| """Remove the first copy of layer. Raises ValueError if it is not present."""
//| ...
//|
@ -284,7 +284,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
//| def __getitem__(self, index: int) -> Union[vectorio.Shape, Group, TileGrid]:
//| def __getitem__(self, index: int) -> Union[vectorio.VectorShape, Group, TileGrid]:
//| """Returns the value at the given index.
//|
//| This allows you to::
@ -292,7 +292,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
//| print(group[0])"""
//| ...
//|
//| def __setitem__(self, index: int, value: Union[vectorio.Shape, Group, TileGrid]) -> None:
//| def __setitem__(self, index: int, value: Union[vectorio.VectorShape, Group, TileGrid]) -> None:
//| """Sets the value at the given index.
//|
//| This allows you to::

View File

@ -39,7 +39,7 @@
//| dx: int,
//| dy: int,
//| shift_x: int,
//| shift_y: int):
//| shift_y: int) -> None:
//| """Named tuple used to capture a single glyph and its attributes.
//|
//| :param bitmap: the bitmap including the glyph

View File

@ -47,11 +47,10 @@
//| objects in CircuitPython, Display objects live until `displayio.release_displays()`
//| is called. This is done so that CircuitPython can use the display itself."""
//|
//| def __init__(self, framebuffer: rgbmatrix.RGBMatrix, *, rotation: int = 0, auto_refresh: bool = True) -> None:
//| def __init__(self, framebuffer: _typing.FrameBuffer, *, rotation: int = 0, auto_refresh: bool = True) -> None:
//| """Create a Display object with the given framebuffer (a buffer, array, ulab.array, etc)
//|
//| :param framebuffer: The framebuffer that the display is connected to
//| :type framebuffer: any core object implementing the framebuffer protocol
//| :param ~_typing.FrameBuffer framebuffer: The framebuffer that the display is connected to
//| :param bool auto_refresh: Automatically refresh the screen
//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270)"""
//| ...
@ -299,7 +298,7 @@ const mp_obj_property_t framebufferio_framebufferdisplay_rotation_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| framebuffer: rgbmatrix.RGBMatrix
//| framebuffer: _typing.FrameBuffer
//| """The framebuffer being used by the display"""
//|
//|
@ -317,11 +316,11 @@ const mp_obj_property_t framebufferio_framebufferframebuffer_obj = {
};
//| def fill_row(self, y: int, buffer: WriteableBuffer) -> displayio:
//| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer:
//| """Extract the pixels from a single row
//|
//| :param int y: The top edge of the area
//| :param bytearray buffer: The buffer in which to place the pixel data"""
//| :param ~_typing.WriteableBuffer buffer: The buffer in which to place the pixel data"""
//| ...
//|
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {

View File

@ -22,7 +22,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
:func:`help` - Built-in method to provide helpful information
:func:`help` -- Built-in method to provide helpful information
==============================================================
.. function:: help(object=None)

View File

@ -52,13 +52,14 @@ STATIC mp_obj_t mp_obj_new_i2cperipheral_i2c_peripheral_request(i2cperipheral_i2
//| class I2CPeripheral:
//| """Two wire serial protocol peripheral"""
//|
//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, addresses: tuple, smbus: bool = False) -> None:
//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, addresses: Sequence[int], smbus: bool = False) -> None:
//| """I2C is a two-wire protocol for communicating between devices.
//| This implements the peripheral (sensor, secondary) side.
//|
//| :param ~microcontroller.Pin scl: The clock pin
//| :param ~microcontroller.Pin sda: The data pin
//| :param tuple addresses: The I2C addresses to respond to (how many is hw dependent).
//| :param addresses: The I2C addresses to respond to (how many is hw dependent).
//| :type addresses: list[int]
//| :param bool smbus: Use SMBUS timings if the hardware supports it"""
//| ...
//|
@ -86,7 +87,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_make_new(const mp_obj_type_t *type,
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
mp_int_t value;
if (!mp_obj_get_int_maybe(item, &value)) {
mp_raise_TypeError(translate("can't convert address to int"));
mp_raise_TypeError_varg(translate("can't convert %q to %q"), MP_QSTR_address, MP_QSTR_int);
}
if (value < 0x00 || value > 0x7f) {
mp_raise_ValueError(translate("address out of bounds"));
@ -352,7 +353,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(i2cperipheral_i2c_peripheral_request_read_obj, 1, i2c
//| def write(self, buffer: ReadableBuffer) -> int:
//| """Write the data contained in buffer.
//|
//| :param buffer: Write out the data in this buffer
//| :param ~_typing.ReadableBuffer buffer: Write out the data in this buffer
//| :return: Number of bytes written"""
//| ...
//|

View File

@ -47,6 +47,9 @@
//| The `microcontroller` module defines the pins from the perspective of the
//| microcontroller. See `board` for board-specific pin mappings."""
//|
//| from nvm import ByteArray
//| from watchdog import WatchDogTimer
//|
//| cpu: Processor
//| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency``
@ -133,14 +136,14 @@ STATIC mp_obj_t mcu_reset(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset);
//| nvm: Optional[nvm.ByteArray]
//| nvm: Optional[ByteArray]
//| """Available non-volatile memory.
//| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise.
//|
//| :type: nvm.ByteArray or None"""
//|
//| watchdog: Optional[watchdog.WatchDogTimer]
//| watchdog: Optional[WatchDogTimer]
//| """Available watchdog timer.
//| This object is the sole instance of `watchdog.WatchDogTimer` when available or ``None`` otherwise."""
//|

View File

@ -78,7 +78,7 @@ STATIC mp_obj_t multiterminal_obj_clear_secondary_terminal() {
}
MP_DEFINE_CONST_FUN_OBJ_0(multiterminal_clear_secondary_terminal_obj, multiterminal_obj_clear_secondary_terminal);
//| def schedule_secondary_terminal_read(socket: secondary_terminal) -> None:
//| def schedule_secondary_terminal_read(socket: socket.socket) -> None:
//| """In cases where the underlying OS is doing task scheduling, this notifies
//| the OS when more data is available on the socket to read. This is useful
//| as a callback for lwip sockets."""

View File

@ -53,8 +53,8 @@
//| def neopixel_write(digitalinout: digitalio.DigitalInOut, buf: ReadableBuffer) -> None:
//| """Write buf out on the given DigitalInOut.
//|
//| :param digitalinout: the DigitalInOut to output with
//| :param buf: The bytes to clock out. No assumption is made about color order"""
//| :param ~digitalio.DigitalInOut digitalinout: the DigitalInOut to output with
//| :param ~_typing.ReadableBuffer buf: The bytes to clock out. No assumption is made about color order"""
//| ...
STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj_t buf) {
if (!MP_OBJ_IS_TYPE(digitalinout_obj, &digitalio_digitalinout_type)) {

View File

@ -47,7 +47,7 @@
//| It is used by the 'socket' module to look up a suitable
//| NIC when a socket is created."""
//|
//| def route() -> list:
//| def route() -> List[object]:
//| """Returns a list of all configured NICs."""
//| ...
//|

View File

@ -73,12 +73,14 @@ STATIC MP_DEFINE_CONST_DICT(nvm_bytearray_locals_dict, nvm_bytearray_locals_dict
//| @overload
//| def __getitem__(self, index: slice) -> bytearray: ...
//| @overload
//| def __getitem__(self, index: int) -> int:
//| """Returns the value at the given index."""
//| ...
//|
//| @overload
//| def __setitem__(self, index: slice, value: ReadableBuffer) -> None: ...
//| @overload
//| def __setitem__(self, index: int, value: int) -> None:
//| """Set the value at the given index."""
//| ...

View File

@ -43,12 +43,22 @@
//| code written in CircuitPython will work in CPython but not necessarily the
//| other way around."""
//|
//| import typing
//| def uname() -> tuple:
//| def uname() -> _Uname:
//| """Returns a named tuple of operating specific and CircuitPython port
//| specific information."""
//| ...
//|
//| class _Uname(typing.NamedTuple):
//| """The type of values that :py:func:`.uname()` returns"""
//|
//| sysname: str
//| nodename: str
//| release: str
//| version: str
//| machine: str
//|
STATIC mp_obj_t os_uname(void) {
return common_hal_os_uname();
}
@ -134,7 +144,7 @@ mp_obj_t os_rmdir(mp_obj_t path_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir);
//| def stat(path: str) -> str:
//| def stat(path: str) -> Tuple[int, int, int, int, int, int, int, int, int, int]:
//| """Get the status of a file or directory.
//|
//| .. note:: On builds without long integers, the number of seconds

View File

@ -133,7 +133,7 @@ STATIC mp_obj_t ps2io_ps2_obj_popleft(mp_obj_t self_in) {
int b = common_hal_ps2io_ps2_popleft(self);
if (b < 0) {
mp_raise_IndexError(translate("Pop from an empty Ps2 buffer"));
mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_Ps2_space_buffer);
}
return MP_OBJ_NEW_SMALL_INT(b);
}

View File

@ -128,7 +128,7 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_
}
}
//| def __init__(self, *, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: List[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0) -> None:
//| def __init__(self, *, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: Sequence[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0) -> None:
//| """Create a RGBMatrix object with the given attributes. The height of
//| the display is determined by the number of rgb and address pins:
//| len(rgb_pins) // 3 * 2 ** len(address_pins). With 6 RGB pins and 4

View File

@ -38,10 +38,9 @@
//| The `rotaryio` module contains classes to read different rotation encoding schemes. See
//| `Wikipedia's Rotary Encoder page <https://en.wikipedia.org/wiki/Rotary_encoder>`_ for more
//| background.
//|
//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the :ref:`module-support-matrix` for more info.
//|
//| All classes change hardware state and should be deinitialized when they
//| are no longer needed if the program continues after use. To do so, either
//| call :py:meth:`!deinit` or use a context manager. See

View File

@ -125,7 +125,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_deinit_obj, sdcardio_sdcard_deinit);
//| """Read one or more blocks from the card
//|
//| :param int start_block: The block to start reading from
//| :param bytearray buf: The buffer to write into. Length must be multiple of 512.
//| :param ~_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512.
//|
//| :return: None"""
//|
@ -149,7 +149,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(sdcardio_sdcard_readblocks_obj, sdcardio_sdcard_readbl
//| """Write one or more blocks to the card
//|
//| :param int start_block: The block to start writing from
//| :param bytearray buf: The buffer to read from. Length must be multiple of 512.
//| :param ~_typing.ReadableBuffer buf: The buffer to read from. Length must be multiple of 512.
//|
//| :return: None"""
//|

View File

@ -165,7 +165,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_count_obj, sdioio_sdcard_count);
//| """Read one or more blocks from the card
//|
//| :param int start_block: The block to start reading from
//| :param bytearray buf: The buffer to write into. Length must be multiple of 512.
//| :param ~_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512.
//|
//| :return: None"""
mp_obj_t sdioio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) {
@ -182,12 +182,12 @@ mp_obj_t sdioio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_
MP_DEFINE_CONST_FUN_OBJ_3(sdioio_sdcard_readblocks_obj, sdioio_sdcard_readblocks);
//| def writeblocks(self, start_block: int, buf: WriteableBuffer) -> None:
//| def writeblocks(self, start_block: int, buf: ReadableBuffer) -> None:
//|
//| """Write one or more blocks to the card
//|
//| :param int start_block: The block to start writing from
//| :param bytearray buf: The buffer to read from. Length must be multiple of 512.
//| :param ~_typing.ReadableBuffer buf: The buffer to read from. Length must be multiple of 512.
//|
//| :return: None"""
//|

View File

@ -52,11 +52,17 @@ STATIC const mp_obj_type_t socket_type;
//| def __init__(self, family: int, type: int, proto: int) -> None:
//| """Create a new socket
//|
//| :param ~int family: AF_INET or AF_INET6
//| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW
//| :param ~int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)"""
//| :param int family: AF_INET or AF_INET6
//| :param int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW
//| :param int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)"""
//| ...
//|
//| AF_INET: int
//| AF_INET6: int
//| SOCK_STREAM: int
//| SOCK_DGRAM: int
//| SOCK_RAW: int
//|
STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 0, 4, false);
@ -96,10 +102,11 @@ STATIC void socket_select_nic(mod_network_socket_obj_t *self, const byte *ip) {
}
}
//| def bind(self, address: tuple) -> None:
//| def bind(self, address: Tuple[str, int]) -> None:
//| """Bind a socket to an address
//|
//| :param ~tuple address: tuple of (remote_address, remote_port)"""
//| :param address: tuple of (remote_address, remote_port)
//| :type address: tuple(str, int)"""
//| ...
//|
@ -126,7 +133,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind);
//| def listen(self, backlog: int) -> None:
//| """Set socket to listen for incoming connections
//|
//| :param ~int backlog: length of backlog queue for waiting connetions"""
//| :param int backlog: length of backlog queue for waiting connetions"""
//| ...
//|
@ -148,7 +155,7 @@ STATIC mp_obj_t socket_listen(mp_obj_t self_in, mp_obj_t backlog) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_listen_obj, socket_listen);
//| def accept(self) -> tuple:
//| def accept(self) -> Tuple[socket, str]:
//| """Accept a connection on a listening socket of type SOCK_STREAM,
//| creating a new socket of type SOCK_STREAM.
//| Returns a tuple of (new_socket, remote_address)"""
@ -185,10 +192,11 @@ STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_accept_obj, socket_accept);
//| def connect(self, address: tuple) -> None:
//| def connect(self, address: Tuple[str, int]) -> None:
//| """Connect a socket to a remote address
//|
//| :param ~tuple address: tuple of (remote_address, remote_port)"""
//| :param address: tuple of (remote_address, remote_port)
//| :type address: tuple(str, int)"""
//| ...
//|
@ -216,7 +224,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_connect_obj, socket_connect);
//| """Send some bytes to the connected remote address.
//| Suits sockets of type SOCK_STREAM
//|
//| :param ~bytes bytes: some bytes to send"""
//| :param ~_typing.ReadableBuffer bytes: some bytes to send"""
//| ...
//|
@ -259,7 +267,7 @@ STATIC mp_int_t _socket_recv_into(mod_network_socket_obj_t *sock, byte *buf, mp_
//| Suits sockets of type SOCK_STREAM
//| Returns an int of number of bytes read.
//|
//| :param bytearray buffer: buffer to receive into
//| :param ~_typing.WriteableBuffer buffer: buffer to receive into
//| :param int bufsize: optionally, a maximum number of bytes to read."""
//| ...
//|
@ -290,7 +298,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_recv_into_obj, 2, 3, socket_re
//| Suits sockets of type SOCK_STREAM
//| Returns a bytes() of length <= bufsize
//|
//| :param ~int bufsize: maximum number of bytes to receive"""
//| :param int bufsize: maximum number of bytes to receive"""
//| ...
//|
@ -312,12 +320,13 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_recv_obj, socket_recv);
//| def sendto(self, bytes: ReadableBuffer, address: tuple) -> int:
//| def sendto(self, bytes: ReadableBuffer, address: Tuple[str, int]) -> int:
//| """Send some bytes to a specific address.
//| Suits sockets of type SOCK_DGRAM
//|
//| :param ~bytes bytes: some bytes to send
//| :param ~tuple address: tuple of (remote_address, remote_port)"""
//| :param ~_typing.ReadableBuffer bytes: some bytes to send
//| :param address: tuple of (remote_address, remote_port)
//| :type address: tuple(str, int)"""
//| ...
//|
@ -346,7 +355,7 @@ STATIC mp_obj_t socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(socket_sendto_obj, socket_sendto);
//| def recvfrom(self, bufsize: int) -> Tuple[bytes, tuple]:
//| def recvfrom(self, bufsize: int) -> Tuple[bytes, Tuple[str, int]]:
//| """Reads some bytes from the connected remote address.
//| Suits sockets of type SOCK_STREAM
//|
@ -354,7 +363,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(socket_sendto_obj, socket_sendto);
//| * a bytes() of length <= bufsize
//| * a remote_address, which is a tuple of ip address and port number
//|
//| :param ~int bufsize: maximum number of bytes to receive"""
//| :param int bufsize: maximum number of bytes to receive"""
//| ...
//|
@ -422,7 +431,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_setsockopt_obj, 4, 4, socket_s
//| def settimeout(self, value: int) -> None:
//| """Set the timeout value for this socket.
//|
//| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely."""
//| :param int value: timeout in seconds. 0 means non-blocking. None means block indefinitely."""
//| ...
//|
@ -453,7 +462,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_settimeout_obj, socket_settimeout);
//| def setblocking(self, flag: bool) -> Optional[int]:
//| """Set the blocking behaviour of this socket.
//|
//| :param ~bool flag: False means non-blocking, True means block indefinitely."""
//| :param bool flag: False means non-blocking, True means block indefinitely."""
//| ...
//|
@ -512,7 +521,7 @@ STATIC const mp_obj_type_t socket_type = {
.locals_dict = (mp_obj_dict_t*)&socket_locals_dict,
};
//| def getaddrinfo(host: str, port: int) -> tuple:
//| def getaddrinfo(host: str, port: int) -> Tuple[int, int, int, str, str]:
//| """Gets the address information for a hostname and port
//|
//| Returns the appropriate family, socket type, socket protocol and

Some files were not shown because too many files have changed in this diff Show More