diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c05d52cc33..0fa10f2043 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v5.0.0 hooks: - id: check-yaml - id: end-of-file-fixer @@ -39,10 +39,23 @@ repos: - id: formatting name: Formatting entry: python3 tools/codeformat.py - types_or: [c, python] + types: [c] language: system exclude: | (?x)^( lib/tinyusb| ports/raspberrypi/sdk ) +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.9.4 + hooks: + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format +- repo: https://github.com/tox-dev/pyproject-fmt + rev: "v2.5.0" + hooks: + - id: pyproject-fmt diff --git a/conf.py b/conf.py index 998c0370db..7555540174 100644 --- a/conf.py +++ b/conf.py @@ -35,12 +35,12 @@ from sphinx.ext import intersphinx # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('docs')) -sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath("docs")) +sys.path.insert(0, os.path.abspath(".")) import shared_bindings_matrix -master_doc = 'docs/index' +master_doc = "docs/index" # Grab the JSON values to use while building the module support matrix # in 'shared-bindings/index.rst' @@ -48,7 +48,7 @@ master_doc = 'docs/index' # The stubs must be built before we calculate the shared bindings matrix subprocess.check_output(["make", "stubs"]) -#modules_support_matrix = shared_bindings_matrix.support_matrix_excluded_boards() +# modules_support_matrix = shared_bindings_matrix.support_matrix_excluded_boards() modules_support_matrix = shared_bindings_matrix.support_matrix_by_board() modules_support_matrix_reverse = defaultdict(list) for board, matrix_info in modules_support_matrix.items(): @@ -56,55 +56,65 @@ for board, matrix_info in modules_support_matrix.items(): modules_support_matrix_reverse[module].append(board) modules_support_matrix_reverse = dict( - (module, sorted(boards)) - for module, boards in modules_support_matrix_reverse.items() + (module, sorted(boards)) for module, boards in modules_support_matrix_reverse.items() ) html_context = { - 'support_matrix': modules_support_matrix, - 'support_matrix_reverse': modules_support_matrix_reverse + "support_matrix": modules_support_matrix, + "support_matrix_reverse": modules_support_matrix_reverse, } # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = '1.3' +needs_sphinx = "1.3" # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', + "sphinx.ext.autodoc", + "sphinx.ext.doctest", "sphinxcontrib.jquery", - 'sphinxcontrib.rsvgconverter', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx_search.extension', - 'rstjinja', - 'myst_parser', + "sphinxcontrib.rsvgconverter", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx_search.extension", + "rstjinja", + "myst_parser", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['templates', "docs/templates"] +templates_path = ["templates", "docs/templates"] # The suffix of source filenames. source_suffix = { - '.rst': 'restructuredtext', - '.md': 'markdown', + ".rst": "restructuredtext", + ".md": "markdown", } -extensions.append('autoapi.extension') +extensions.append("autoapi.extension") -autoapi_type = 'python' +autoapi_type = "python" # Uncomment this if debugging autoapi autoapi_keep_files = True -autoapi_dirs = [os.path.join('circuitpython-stubs', x) for x in os.listdir('circuitpython-stubs') if os.path.exists(os.path.join("circuitpython-stubs", x, "__init__.pyi"))] +autoapi_dirs = [ + os.path.join("circuitpython-stubs", x) + for x in os.listdir("circuitpython-stubs") + if os.path.exists(os.path.join("circuitpython-stubs", x, "__init__.pyi")) +] print("autoapi_dirs", autoapi_dirs) 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_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" @@ -115,23 +125,25 @@ autoapi_file_patterns = ["*.pyi"] # See https://github.com/sphinx-doc/sphinx/issues/12300 suppress_warnings = ["config.cache"] -def autoapi_prepare_jinja_env(jinja_env): - jinja_env.globals['support_matrix_reverse'] = modules_support_matrix_reverse -redirects_file = 'docs/redirects.txt' +def autoapi_prepare_jinja_env(jinja_env): + jinja_env.globals["support_matrix_reverse"] = modules_support_matrix_reverse + + +redirects_file = "docs/redirects.txt" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -#master_doc = 'index' +# master_doc = 'index' # Get current date (execution) for copyright year current_date = time.localtime() # General information about the project. -project = 'Adafruit CircuitPython' -copyright = f'2014-{current_date.tm_year}, MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)' +project = "Adafruit CircuitPython" +copyright = f"2014-{current_date.tm_year}, MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)" # These are overwritten on ReadTheDocs. # The version info for the project you're documenting, acts as replacement for @@ -143,15 +155,11 @@ copyright = f'2014-{current_date.tm_year}, MicroPython & CircuitPython contribut final_version = "" git_describe = subprocess.run( - ["python", "py/version.py"], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - encoding="utf-8" + ["python", "py/version.py"], 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) + r"^\d(?:\.\d){0,2}(?:\-(?:alpha|beta|rc)\.\d+){0,1}", str(git_describe.stdout) ) if git_version: final_version = git_version[0] @@ -162,13 +170,13 @@ version = release = final_version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -176,14 +184,11 @@ include_patterns = [ # Top directory documentation "*.rst", "*.md", - # Docs inherited from microypython (but not templates or README.md, see below) "docs/**", - # Module documentation "shared-bindings/**", "ports/*/bindings/**", - # Port READMEs in various formats "ports/*/README*", ] @@ -191,27 +196,27 @@ exclude_patterns = ["docs/autoapi/templates/**", "docs/README.md"] # The reST default role (used for this markup: `text`) to use for all # documents. -default_role = 'any' +default_role = "any" # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # Global include files. Sphinx docs suggest using rst_epilog in preference # of rst_prolog, so we follow. Absolute paths below mean "from the base @@ -223,137 +228,141 @@ rst_epilog = """ # -- Options for HTML output ---------------------------------------------- import sphinx_rtd_theme -html_theme = 'sphinx_rtd_theme' + +html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = ['.'] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = '../../logo/trans-logo.png' +# html_logo = '../../logo/trans-logo.png' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = 'docs/static/favicon.ico' +html_favicon = "docs/static/favicon.ico" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['docs/static'] +html_static_path = ["docs/static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -html_last_updated_fmt = '%d %b %Y' +html_last_updated_fmt = "%d %b %Y" # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {"index": "topindex.html"} +# html_additional_pages = {"index": "topindex.html"} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'CircuitPythondoc' +htmlhelp_basename = "CircuitPythondoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -# Include 3 levels of headers in PDF ToC -'preamble': r''' + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', + # Include 3 levels of headers in PDF ToC + "preamble": r""" \setcounter{tocdepth}{2} \hbadness=99999 \hfuzz=20pt \usepackage{pdflscape} -''', +""", } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ("docs/pdf", 'CircuitPython.tex', 'CircuitPython Documentation', - 'CircuitPython Contributors', 'manual'), - # Uncomment this if you want to build a PDF of the board -> module support matrix. - # ("shared-bindings/support_matrix", 'SupportMatrix.tex', 'Board Support Matrix', - # 'CircuitPython Contributors', 'manual'), + ( + "docs/pdf", + "CircuitPython.tex", + "CircuitPython Documentation", + "CircuitPython Contributors", + "manual", + ), + # Uncomment this if you want to build a PDF of the board -> module support matrix. + # ("shared-bindings/support_matrix", 'SupportMatrix.tex', 'Board Support Matrix', + # 'CircuitPython Contributors', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- @@ -361,12 +370,11 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'CircuitPython', 'CircuitPython Documentation', - ['CircuitPython contributors'], 1), + ("index", "CircuitPython", "CircuitPython Documentation", ["CircuitPython contributors"], 1), ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -375,29 +383,40 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'CircuitPython', 'CircuitPython Documentation', - 'CircuitPython contributors', 'CircuitPython', 'Python for Microcontrollers.', - 'Miscellaneous'), + ( + master_doc, + "CircuitPython", + "CircuitPython Documentation", + "CircuitPython contributors", + "CircuitPython", + "Python for Microcontrollers.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {"python": ('https://docs.python.org/3/', None), - "register": ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None), - "mcp2515": ('https://circuitpython.readthedocs.io/projects/mcp2515/en/latest/', None), - "typing": ('https://circuitpython.readthedocs.io/projects/adafruit-circuitpython-typing/en/latest/', None)} +intersphinx_mapping = { + "python": ("https://docs.python.org/3/", None), + "register": ("https://circuitpython.readthedocs.io/projects/register/en/latest/", None), + "mcp2515": ("https://circuitpython.readthedocs.io/projects/mcp2515/en/latest/", None), + "typing": ( + "https://circuitpython.readthedocs.io/projects/adafruit-circuitpython-typing/en/latest/", + None, + ), +} # Adapted from sphinxcontrib-redirects from sphinx.builders import html as builders @@ -415,20 +434,21 @@ def generate_redirects(app): return if not isinstance(app.builder, builders.StandaloneHTMLBuilder): - logging.warn("The 'sphinxcontib-redirects' plugin is only supported " - "by the 'html' builder and subclasses. Skipping...") + logging.warn( + "The 'sphinxcontib-redirects' plugin is only supported " + "by the 'html' builder and subclasses. Skipping..." + ) logging.warn(f"Builder is {app.builder.name} ({type(app.builder)})") return with open(path) as redirects: for line in redirects.readlines(): - from_path, to_path = line.rstrip().split(' ') + from_path, to_path = line.rstrip().split(" ") logging.debug("Redirecting '%s' to '%s'" % (from_path, to_path)) from_path = os.path.splitext(from_path)[0] + ".html" - to_path_prefix = '..%s' % os.path.sep * ( - len(from_path.split(os.path.sep)) - 1) + to_path_prefix = "..%s" % os.path.sep * (len(from_path.split(os.path.sep)) - 1) to_path = to_path_prefix + to_path redirected_filename = os.path.join(app.builder.outdir, from_path) @@ -436,8 +456,9 @@ def generate_redirects(app): if not os.path.exists(redirected_directory): os.makedirs(redirected_directory) - with open(redirected_filename, 'w') as f: - f.write(TEMPLATE % urllib.parse.quote(to_path, '#/')) + with open(redirected_filename, "w") as f: + f.write(TEMPLATE % urllib.parse.quote(to_path, "#/")) + def adafruit_typing_workaround(app, env, node, contnode): # Sphinx marks a requesting node that uses circuitpython-typing @@ -493,7 +514,7 @@ def setup(app): app.add_css_file("customstyle.css") app.add_css_file("filter.css") app.add_js_file("filter.js") - app.add_config_value('redirects_file', 'redirects', 'env') - app.connect('builder-inited', generate_redirects) - app.connect('missing-reference', adafruit_typing_workaround) + app.add_config_value("redirects_file", "redirects", "env") + app.connect("builder-inited", generate_redirects) + app.connect("missing-reference", adafruit_typing_workaround) app.add_transform(CoreModuleTransform) diff --git a/docs/rstjinja.py b/docs/rstjinja.py index 7d5fff5c6c..e7d8a312f1 100644 --- a/docs/rstjinja.py +++ b/docs/rstjinja.py @@ -3,11 +3,13 @@ import re + def render_with_jinja(docname, source): - if re.search('^\s*.. jinja$', source[0], re.M): + if re.search("^\s*.. jinja$", source[0], re.M): return True return False + def rstjinja(app, docname, source): """ Render our pages as a jinja template for fancy templating goodness. @@ -24,18 +26,15 @@ def rstjinja(app, docname, source): print(f"rendering {docname} as jinja templates") if app.builder.format == "html": - rendered = app.builder.templates.render_string( - src, app.config.html_context - ) + rendered = app.builder.templates.render_string(src, app.config.html_context) else: from sphinx.util.template import BaseRenderer + renderer = BaseRenderer() - rendered = renderer.render_string( - src, - app.config.html_context - ) + rendered = renderer.render_string(src, app.config.html_context) source[0] = rendered + def setup(app): app.connect("source-read", rstjinja) diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index 51f73a4716..60c2765a4d 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -58,8 +58,7 @@ ALIASES_BY_BOARD = { ALIASES_BRAND_NAMES = { "circuitplayground_express_4h": "Adafruit Circuit Playground Express 4-H", - "circuitplayground_express_digikey_pycon2019": - "Circuit Playground Express Digi-Key PyCon 2019", + "circuitplayground_express_digikey_pycon2019": "Circuit Playground Express Digi-Key PyCon 2019", "edgebadge": "Adafruit EdgeBadge", "pyportal_pynt": "Adafruit PyPortal Pynt", "gemma_m0_pycon2018": "Adafruit Gemma M0 PyCon 2018", @@ -119,8 +118,12 @@ def get_bindings(): bindings_modules = [] for d in get_circuitpython_root_dir().glob("ports/*/bindings"): bindings_modules.extend(module.name for module in d.iterdir() if d.is_dir()) - return shared_bindings_modules + bindings_modules + MODULES_NOT_IN_BINDINGS + \ - list(ADDITIONAL_MODULES.keys()) + return ( + shared_bindings_modules + + bindings_modules + + MODULES_NOT_IN_BINDINGS + + list(ADDITIONAL_MODULES.keys()) + ) def get_board_mapping(): @@ -188,16 +191,23 @@ def get_settings_from_makefile(port_dir, board_name): This list must explicitly include any setting queried by tools/ci_set_matrix.py. """ - if os.getenv('NO_BINDINGS_MATRIX'): - return { - 'CIRCUITPY_BUILD_EXTENSIONS': '.bin' - } + if os.getenv("NO_BINDINGS_MATRIX"): + return {"CIRCUITPY_BUILD_EXTENSIONS": ".bin"} contents = subprocess.run( - ["make", "-C", port_dir, "-f", "Makefile", f"BOARD={board_name}", - "print-CFLAGS", "print-CIRCUITPY_BUILD_EXTENSIONS", - "print-FROZEN_MPY_DIRS", "print-SRC_PATTERNS", - "print-SRC_SUPERVISOR"], + [ + "make", + "-C", + port_dir, + "-f", + "Makefile", + f"BOARD={board_name}", + "print-CFLAGS", + "print-CIRCUITPY_BUILD_EXTENSIONS", + "print-FROZEN_MPY_DIRS", + "print-SRC_PATTERNS", + "print-SRC_SUPERVISOR", + ], encoding="utf-8", errors="replace", stdout=subprocess.PIPE, @@ -213,8 +223,8 @@ def get_settings_from_makefile(port_dir, board_name): settings = {} for line in contents.stdout.split("\n"): - if line.startswith('CFLAGS ='): - for m in re.findall(r'-D([A-Z][A-Z0-9_]*)=(\d+)', line): + if line.startswith("CFLAGS ="): + for m in re.findall(r"-D([A-Z][A-Z0-9_]*)=(\d+)", line): settings[m[0]] = m[1] elif m := re.match(r"^([A-Z][A-Z0-9_]*) = (.*)$", line): settings[m.group(1)] = m.group(2) @@ -259,11 +269,13 @@ def get_repository_url(directory): repository_urls[directory] = path return path + def remove_prefix(s, prefix): if not s.startswith(prefix): raise ValueError(f"{s=} does not start with {prefix=}") return s.removeprefix(prefix) + def frozen_modules_from_dirs(frozen_mpy_dirs, withurl): """ Go through the list of frozen directories and extract the python modules. @@ -275,7 +287,7 @@ def frozen_modules_from_dirs(frozen_mpy_dirs, withurl): """ frozen_modules = [] for frozen_path in filter(lambda x: x, frozen_mpy_dirs.split(" ")): - frozen_path = remove_prefix(frozen_path, '../../') + frozen_path = remove_prefix(frozen_path, "../../") source_dir = get_circuitpython_root_dir() / frozen_path url_repository = get_repository_url(source_dir) for sub in source_dir.glob("*"): @@ -304,9 +316,14 @@ def lookup_setting(settings, key, default=""): return value -def support_matrix_by_board(use_branded_name=True, withurl=True, - add_port=False, add_chips=False, - add_pins=False, add_branded_name=False): +def support_matrix_by_board( + use_branded_name=True, + withurl=True, + add_port=False, + add_chips=False, + add_pins=False, + add_branded_name=False, +): """Compiles a list of the available core modules available for each board. """ @@ -335,13 +352,11 @@ def support_matrix_by_board(use_branded_name=True, withurl=True, else: with open(board_directory / "mpconfigboard.h") as get_name: board_contents = get_name.read() - board_name_re = re.search( - r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)", board_contents - ) + board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)", board_contents) if board_name_re: branded_name = board_name_re.group(1).strip('"') if '"' in branded_name: # sometimes the closing " is not at line end - branded_name = branded_name[:branded_name.index('"')] + branded_name = branded_name[: branded_name.index('"')] board_name = branded_name if use_branded_name: @@ -352,25 +367,21 @@ def support_matrix_by_board(use_branded_name=True, withurl=True, if add_chips: with open(board_directory / "mpconfigboard.h") as get_name: board_contents = get_name.read() - mcu_re = re.search( - r'(?<=MICROPY_HW_MCU_NAME)\s+(.+)', board_contents - ) + mcu_re = re.search(r"(?<=MICROPY_HW_MCU_NAME)\s+(.+)", board_contents) if mcu_re: mcu = mcu_re.group(1).strip('"') if '"' in mcu: # in case the closing " is not at line end - mcu = mcu[:mcu.index('"')] + mcu = mcu[: mcu.index('"')] else: mcu = "" with open(board_directory / "mpconfigboard.mk") as get_name: board_contents = get_name.read() - flash_re = re.search( - r'(?<=EXTERNAL_FLASH_DEVICES)\s+=\s+(.+)', board_contents - ) + flash_re = re.search(r"(?<=EXTERNAL_FLASH_DEVICES)\s+=\s+(.+)", board_contents) if flash_re: # deal with the variability in the way multiple flash chips # are denoted. We want them to end up as a quoted, # comma separated string - flash = flash_re.group(1).replace('"','') + flash = flash_re.group(1).replace('"', "") flash = f'"{flash}"' else: flash = "" @@ -406,28 +417,23 @@ def support_matrix_by_board(use_branded_name=True, withurl=True, if "CIRCUITPY_BUILD_EXTENSIONS" in settings: board_extensions = settings["CIRCUITPY_BUILD_EXTENSIONS"] if isinstance(board_extensions, str): - board_extensions = [ - extension.strip() - for extension in board_extensions.split(",") - ] + board_extensions = [extension.strip() for extension in board_extensions.split(",")] else: raise OSError(f"Board extensions undefined: {board_name}.") frozen_modules = [] if "FROZEN_MPY_DIRS" in settings: - frozen_modules = frozen_modules_from_dirs( - settings["FROZEN_MPY_DIRS"], withurl - ) + frozen_modules = frozen_modules_from_dirs(settings["FROZEN_MPY_DIRS"], withurl) if frozen_modules: frozen_modules.sort() # generate alias boards too board_info = { - "modules": board_modules, - "frozen_libraries": frozen_modules, - "extensions": board_extensions, - } + "modules": board_modules, + "frozen_libraries": frozen_modules, + "extensions": board_extensions, + } if add_branded_name: board_info["branded_name"] = branded_name if add_port: @@ -437,12 +443,7 @@ def support_matrix_by_board(use_branded_name=True, withurl=True, board_info["flash"] = flash if add_pins: board_info["pins"] = pins - board_matrix = [ - ( - board_name, - board_info - ) - ] + board_matrix = [(board_name, board_info)] if board_id in ALIASES_BY_BOARD: for alias in ALIASES_BY_BOARD[board_id]: if use_branded_name: @@ -454,7 +455,7 @@ def support_matrix_by_board(use_branded_name=True, withurl=True, "modules": board_modules, "frozen_libraries": frozen_modules, "extensions": board_extensions, - } + } if add_branded_name: board_info["branded_name"] = branded_name if add_port: @@ -464,16 +465,10 @@ def support_matrix_by_board(use_branded_name=True, withurl=True, board_info["flash"] = flash if add_pins: board_info["pins"] = pins - board_matrix.append( - ( - alias, - board_info - ) - ) + board_matrix.append((alias, board_info)) return board_matrix # this is now a list of (board,modules) - board_mapping = get_board_mapping() real_boards = [] for board in board_mapping: @@ -483,9 +478,7 @@ def support_matrix_by_board(use_branded_name=True, withurl=True, mapped_exec = executor.map(support_matrix, real_boards) # flatmap with comprehensions boards = dict( - sorted( - [board for matrix in mapped_exec for board in matrix], key=lambda x: x[0] - ) + sorted([board for matrix in mapped_exec for board in matrix], key=lambda x: x[0]) ) return boards diff --git a/ports/atmel-samd/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c index 1564d65fc8..9610c6e8c3 100644 --- a/ports/atmel-samd/bindings/samd/Clock.c +++ b/ports/atmel-samd/bindings/samd/Clock.c @@ -74,6 +74,7 @@ MP_PROPERTY_GETTER(samd_clock_frequency_obj, //| calibration: int //| """Clock calibration. Not all clocks can be calibrated.""" //| +//| static mp_obj_t samd_clock_get_calibration(mp_obj_t self_in) { samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_int_from_uint(clock_get_calibration(self->type, self->index)); diff --git a/ports/atmel-samd/bindings/samd/__init__.c b/ports/atmel-samd/bindings/samd/__init__.c index 9f3ad1c3dd..114a1e7b74 100644 --- a/ports/atmel-samd/bindings/samd/__init__.c +++ b/ports/atmel-samd/bindings/samd/__init__.c @@ -11,6 +11,7 @@ #include "bindings/samd/Clock.h" //| """SAMD implementation settings""" +//| //| """:mod:`samd.clock` --- samd clock names //| -------------------------------------------------------- diff --git a/ports/atmel-samd/tools/gen_pin_name_table.py b/ports/atmel-samd/tools/gen_pin_name_table.py deleted file mode 100644 index 16af2540bd..0000000000 --- a/ports/atmel-samd/tools/gen_pin_name_table.py +++ /dev/null @@ -1,380 +0,0 @@ -# This file is part of the CircuitPython project: https://circuitpython.org -# -# SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -# This helper generates the pinout tables in ../README.rst. - -import os -import os.path - -pins = [ - "PA00", - "PA01", - "PA02", - "PA03", - "PB08", - "PB09", - "PA04", - "PA05", - "PA06", - "PA07", - "PA08", - "PA09", - "PA10", - "PA11", - "PB10", - "PB11", - "PA12", - "PA13", - "PA14", - "PA15", - "PA16", - "PA17", - "PA18", - "PA19", - "PA20", - "PA21", - "PA22", - "PA23", - "PA24", - "PA25", - "PB22", - "PB23", - "PA27", - "PA28", - "PA29", - "PA30", - "PA31", - "PB02", - "PB03", -] - -# Dictionary keys: [board][pin] = list of pin names -mapping = {} - -QSTR = " { MP_OBJ_NEW_QSTR(MP_QSTR_" - -for board in os.listdir("boards"): - if not os.path.isdir("boards/" + board): - continue - mapping[board] = {} - with open("boards/" + board + "/pins.c", "r") as f: - for line in f: - if line.startswith(QSTR): - board_name, _, pin = line.split(")") - board_name = board_name[len(QSTR) :] - pin = pin[-8:-4] - if pin not in mapping[board]: - mapping[board][pin] = [] - mapping[board][pin].append(board_name) - -column_width = {} -for board in mapping: - column_width[board] = len(board) - for pin in mapping[board]: - l = len(" / ".join("``" + x + "``" for x in mapping[board][pin])) - column_width[board] = max(l, column_width[board]) - -first_column_width = len("`microcontroller.pin`") -print("=" * first_column_width, end="") -total_board_width = -2 -for board in column_width: - column = " " + "=" * column_width[board] - total_board_width += len(column) - print(column, end="") - -print() -print("`microcontroller.pin` `board`") -print("-" * first_column_width + " " + "-" * total_board_width) - -print("Datasheet".ljust(first_column_width), end="") -for board in column_width: - print(" " + board.ljust(column_width[board]), end="") -print() - -print("=" * first_column_width, end="") -for board in column_width: - column = " " + "=" * column_width[board] - print(column, end="") -print() - -for pin in pins: - print(pin.ljust(first_column_width), end="") - for board in column_width: - if pin in mapping[board]: - names = " / ".join("``" + x + "``" for x in mapping[board][pin]) - print(" " + names.ljust(column_width[board]), end="") - else: - print(" " * (column_width[board] + 2), end="") - print() - -print("=" * first_column_width, end="") -for board in column_width: - column = " " + "=" * column_width[board] - print(column, end="") -print() - -print() -print() -# Generate pin capabilities too. - -ALL_BUT_USB = list(pins) -ALL_BUT_USB.remove("PA24") -ALL_BUT_USB.remove("PA25") - -# dictionary is [module][class] = [pins] -capabilities = { - "analogio": { - "AnalogIn": [ - "PA02", - "PA03", - "PB08", - "PB09", - "PA04", - "PA05", - "PA06", - "PA07", - "PA08", - "PA09", - "PA10", - "PA11", - "PB02", - "PB03", - ], - "AnalogOut": ["PA02"], - }, - "audioio": {"AudioOut": ["PA02"]}, - "bitbangio": {"I2C": ALL_BUT_USB, "SPI": ALL_BUT_USB}, - "busio": { - "I2C - SDA": ["PA00", "PB08", "PA08", "PA12", "PA16", "PA22", "PB02"], # SERCOM pad 0 - "I2C - SCL": ["PA01", "PB09", "PA09", "PA13", "PA17", "PA23", "PB03"], # SERCOM pad 1 - "SPI - MISO": [ - "PA00", - "PA01", - "PB08", - "PB09", - "PA04", - "PA05", - "PA06", - "PA07", - "PA08", - "PA09", - "PA10", - "PA11", - "PB10", - "PB11", - "PA12", - "PA13", - "PA14", - "PA15", - "PA16", - "PA17", - "PA18", - "PA19", - "PA20", - "PA21", - "PA22", - "PA23", - "PB22", - "PB23", - "PA30", - "PA31", - "PB02", - "PB03", - ], # any SERCOM pad - "SPI - MOSI": [ - "PA00", - "PB08", - "PA04", - "PA06", - "PA08", - "PA10", - "PA11", - "PB10", - "PB11", - "PA14", - "PA15", - "PA16", - "PA18", - "PA19", - "PA20", - "PA21", - "PA22", - "PB22", - "PB23", - "PA30", - "PA31", - "PB02", - ], # any pad but 1 - "SPI - SCK": [ - "PA01", - "PB09", - "PA05", - "PA07", - "PA09", - "PA11", - "PB11", - "PA13", - "PA15", - "PA17", - "PA19", - "PA21", - "PA23", - "PB23", - "PA31", - "PB03", - ], # 1 or 3 - "UART - RX": [ - "PA00", - "PA01", - "PB08", - "PB09", - "PA04", - "PA05", - "PA06", - "PA07", - "PA08", - "PA09", - "PA10", - "PA11", - "PB10", - "PB11", - "PA12", - "PA13", - "PA14", - "PA15", - "PA16", - "PA17", - "PA18", - "PA19", - "PA20", - "PA21", - "PA22", - "PA23", - "PB22", - "PB23", - "PA30", - "PA31", - "PB02", - "PB03", - ], # any pad - "UART - TX": [ - "PA00", - "PB08", - "PA04", - "PA06", - "PA08", - "PA10", - "PB10", - "PA12", - "PA14", - "PA16", - "PA18", - "PA20", - "PA22", - "PB22", - "PA30", - "PB02", - ], # pad 0 or 2 - }, - "digitalio": {"DigitalInOut": ALL_BUT_USB}, - "onewireio": {"OneWire": ALL_BUT_USB}, - "pulseio": { - "PulseIn": ALL_BUT_USB, - "PWMOut": [ - "PA01", - "PB09", - "PA04", - "PA05", - "PA06", - "PA07", - "PA08", - "PA09", - "PA10", - "PA11", - "PB10", - "PB11", - "PA12", - "PA13", - "PA14", - "PA15", - "PA16", - "PA17", - "PA18", - "PA19", - "PA20", - "PA21", - "PA22", - "PA23", - "PA30", - "PA31", - ], - }, - "ps2io": {"Ps2": ALL_BUT_USB}, - "touchio": { - "TouchIn": ["PA02", "PA03", "PB08", "PB09", "PA04", "PA05", "PA06", "PA07", "PB02", "PB03"] - }, -} - -column_width = {} -for module in capabilities: - for c in capabilities[module]: - column_width[module + c] = max(len("**Yes**"), len(c)) - -module_width = {} -for module in capabilities: - module_width[module] = 0 - for c in capabilities[module]: - module_width[module] += column_width[module + c] + 2 - module_width[module] -= 2 - - if module_width[module] < (len(module) + 2): - column_width[module + c] += len(module) + 2 - module_width[module] - module_width[module] = len(module) + 2 - -first_column_width = len("`microcontroller.pin`") -print("=" * first_column_width, end="") -for module in capabilities: - for c in capabilities[module]: - print(" " + "=" * column_width[module + c], end="") -print() - -print("`microcontroller.pin`", end="") -for module in capabilities: - print(" " + ("`" + module + "`").ljust(module_width[module]), end="") -print() - -print("-" * first_column_width, end="") -for module in capabilities: - print(" " + "-" * module_width[module], end="") -print() - -print("Datasheet".ljust(first_column_width), end="") -for module in capabilities: - for c in capabilities[module]: - print(" " + c.ljust(column_width[module + c]), end="") -print() - -print("=" * first_column_width, end="") -for module in capabilities: - for c in capabilities[module]: - print(" " + "=" * column_width[module + c], end="") -print() - -for pin in pins: - print(pin.ljust(first_column_width), end="") - for module in capabilities: - for c in capabilities[module]: - if pin in capabilities[module][c]: - print(" " + "**Yes**".ljust(column_width[module + c]), end="") - else: - print(" " * (column_width[module + c] + 2), end="") - print() - -print("=" * first_column_width, end="") -for module in capabilities: - for c in capabilities[module]: - print(" " + "=" * column_width[module + c], end="") -print() diff --git a/ports/atmel-samd/tools/mkcandata.py b/ports/atmel-samd/tools/mkcandata.py index d505c81bdc..06731a9154 100755 --- a/ports/atmel-samd/tools/mkcandata.py +++ b/ports/atmel-samd/tools/mkcandata.py @@ -15,8 +15,8 @@ def defines(name, suffix): {{&pin_{pin}, {instance}, PIN_{pin}, {pinmux} & 0xffff}}, #endif""" ) - print(f"{{NULL, 0, 0}}") - print(f"}};") + print("{NULL, 0, 0}") + print("};") print() diff --git a/ports/atmel-samd/tools/mksdiodata.py b/ports/atmel-samd/tools/mksdiodata.py index bfdcd696c2..5e59c6249b 100755 --- a/ports/atmel-samd/tools/mksdiodata.py +++ b/ports/atmel-samd/tools/mksdiodata.py @@ -14,8 +14,8 @@ def defines(name, function): {{&pin_{pin}, {instance}, PIN_{pin}, {pinmux} & 0xffff}}, #endif""" ) - print(f"{{NULL, 0, 0}}") - print(f"}};") + print("{NULL, 0, 0}") + print("};") print() diff --git a/ports/broadcom/bindings/videocore/Framebuffer.c b/ports/broadcom/bindings/videocore/Framebuffer.c index f5d8ab8d34..66135baa7f 100644 --- a/ports/broadcom/bindings/videocore/Framebuffer.c +++ b/ports/broadcom/bindings/videocore/Framebuffer.c @@ -26,6 +26,7 @@ //| //| A Framebuffer is often used in conjunction with a //| `framebufferio.FramebufferDisplay`.""" +//| static mp_obj_t videocore_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_width, ARG_height, }; @@ -51,6 +52,7 @@ static mp_obj_t videocore_framebuffer_make_new(const mp_obj_type_t *type, size_t //| rgbmatrix instance. After deinitialization, no further operations //| may be performed.""" //| ... +//| static mp_obj_t videocore_framebuffer_deinit(mp_obj_t self_in) { videocore_framebuffer_obj_t *self = (videocore_framebuffer_obj_t *)self_in; common_hal_videocore_framebuffer_deinit(self); @@ -79,6 +81,7 @@ MP_PROPERTY_GETTER(videocore_framebuffer_width_obj, //| height: int //| """The height of the display, in pixels""" //| +//| static mp_obj_t videocore_framebuffer_get_height(mp_obj_t self_in) { videocore_framebuffer_obj_t *self = (videocore_framebuffer_obj_t *)self_in; check_for_deinit(self); diff --git a/ports/cxd56/tools/flash_writer.py b/ports/cxd56/tools/flash_writer.py index fc15cf8c28..9c53e1b56c 100755 --- a/ports/cxd56/tools/flash_writer.py +++ b/ports/cxd56/tools/flash_writer.py @@ -595,11 +595,11 @@ def main(): if subprocess.call("cd " + sys.path[0] + "; ./reset_board.sh", shell=True) == 0: print("auto reset board success!!") do_wait_reset = False - bootrom_msg = writer.cancel_autoboot() + writer.cancel_autoboot() if ConfigArgs.DTR_RESET: do_wait_reset = False - bootrom_msg = writer.cancel_autoboot() + writer.cancel_autoboot() if ConfigArgs.WAIT_RESET is False and do_wait_reset is True: rx = writer.recv() @@ -617,7 +617,7 @@ def main(): # Wait to reset the board print("Please press RESET button on target board") sys.stdout.flush() - bootrom_msg = writer.cancel_autoboot() + writer.cancel_autoboot() # Remove files if ConfigArgs.ERASE_NAME: diff --git a/ports/espressif/bindings/espcamera/Camera.c b/ports/espressif/bindings/espcamera/Camera.c index 41d47a01d1..5768427a13 100644 --- a/ports/espressif/bindings/espcamera/Camera.c +++ b/ports/espressif/bindings/espcamera/Camera.c @@ -70,6 +70,7 @@ //| :param framebuffer_count: The number of framebuffers (1 for single-buffered and 2 for double-buffered) //| :param grab_mode: When to grab a new frame //| """ +//| static mp_obj_t espcamera_camera_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_data_pins, ARG_pixel_clock_pin, ARG_vsync_pin, ARG_href_pin, ARG_i2c, ARG_external_clock_pin, ARG_external_clock_frequency, ARG_powerdown_pin, ARG_reset_pin, ARG_pixel_format, ARG_frame_size, ARG_jpeg_quality, ARG_framebuffer_count, ARG_grab_mode, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -143,6 +144,7 @@ static mp_obj_t espcamera_camera_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Deinitialises the camera and releases all memory resources for reuse.""" //| ... +//| static mp_obj_t espcamera_camera_deinit(mp_obj_t self_in) { espcamera_camera_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_espcamera_camera_deinit(self); @@ -159,12 +161,14 @@ static void check_for_deinit(espcamera_camera_obj_t *self) { //| def __enter__(self) -> Camera: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t espcamera_camera_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; return espcamera_camera_deinit(args[0]); @@ -173,6 +177,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espcamera_camera___exit___obj, 4, 4, //| frame_available: bool //| """True if a frame is available, False otherwise""" +//| static mp_obj_t espcamera_camera_frame_available_get(const mp_obj_t self_in) { espcamera_camera_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -193,6 +198,7 @@ MP_PROPERTY_GETTER(espcamera_camera_frame_available_obj, //| If `pixel_format` is `PixelFormat.JPEG`, the returned value is a read-only `memoryview`. //| Otherwise, the returned value is a read-only `displayio.Bitmap`. //| """ +//| static mp_obj_t espcamera_camera_take(size_t n_args, const mp_obj_t *args) { espcamera_camera_obj_t *self = MP_OBJ_TO_PTR(args[0]); mp_float_t timeout = n_args < 2 ? MICROPY_FLOAT_CONST(0.25) : mp_obj_get_float(args[1]); @@ -229,6 +235,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espcamera_camera_take_obj, 1, 2, espc //| the other properties to set, they are set together in a single function call. //| //| If an argument is unspecified or None, then the setting is unchanged.""" +//| static mp_obj_t espcamera_camera_reconfigure(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { espcamera_camera_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -912,6 +919,7 @@ MP_PROPERTY_GETTER(espcamera_camera_grab_mode_obj, //| framebuffer_count: int //| """True if double buffering is used""" //| +//| static mp_obj_t espcamera_camera_get_framebuffer_count(const mp_obj_t self_in) { espcamera_camera_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/ports/espressif/bindings/espcamera/__init__.c b/ports/espressif/bindings/espcamera/__init__.c index 3443ccee42..dbdb0ffb48 100644 --- a/ports/espressif/bindings/espcamera/__init__.c +++ b/ports/espressif/bindings/espcamera/__init__.c @@ -26,6 +26,7 @@ //| //| """ //| +//| //| class GrabMode: //| """Controls when a new frame is grabbed.""" @@ -36,6 +37,7 @@ //| LATEST: GrabMode //| """Except when 1 frame buffer is used, queue will always contain the last ``fb_count`` frames""" //| +//| MAKE_ENUM_VALUE(espcamera_grab_mode_type, grab_mode, WHEN_EMPTY, CAMERA_GRAB_WHEN_EMPTY); MAKE_ENUM_VALUE(espcamera_grab_mode_type, grab_mode, LATEST, CAMERA_GRAB_LATEST); @@ -65,6 +67,7 @@ camera_grab_mode_t validate_grab_mode(mp_obj_t obj, qstr arg_name) { //| JPEG: PixelFormat //| """A compressed format""" //| +//| MAKE_ENUM_VALUE(espcamera_pixel_format_type, pixel_format, RGB565, PIXFORMAT_RGB565); MAKE_ENUM_VALUE(espcamera_pixel_format_type, pixel_format, GRAYSCALE, PIXFORMAT_GRAYSCALE); @@ -153,6 +156,7 @@ pixformat_t validate_pixel_format(mp_obj_t obj, qstr arg_name) { //| QSXGA: FrameSize //| """2560x1920""" //| +//| MAKE_ENUM_VALUE(espcamera_frame_size_type, frame_size, R96X96, FRAMESIZE_96X96); MAKE_ENUM_VALUE(espcamera_frame_size_type, frame_size, R240X240, FRAMESIZE_240X240); @@ -222,6 +226,7 @@ framesize_t validate_frame_size(mp_obj_t obj, qstr arg_name) { //| GAIN_64X: GainCeiling //| GAIN_128X: GainCeiling //| +//| MAKE_ENUM_VALUE(espcamera_gain_ceiling_type, gain_ceiling, GAIN_2X, GAINCEILING_2X); MAKE_ENUM_VALUE(espcamera_gain_ceiling_type, gain_ceiling, GAIN_4X, GAINCEILING_4X); diff --git a/ports/espressif/bindings/espidf/__init__.c b/ports/espressif/bindings/espidf/__init__.c index 3d6321017f..012ed7d9f9 100644 --- a/ports/espressif/bindings/espidf/__init__.c +++ b/ports/espressif/bindings/espidf/__init__.c @@ -20,11 +20,13 @@ //| that could be implemented by other frameworks. It should only include ESP-IDF specific //| things.""" //| +//| //| def heap_caps_get_total_size() -> int: //| """Return the total size of the ESP-IDF, which includes the CircuitPython heap.""" //| ... //| +//| static mp_obj_t espidf_heap_caps_get_total_size(void) { return MP_OBJ_NEW_SMALL_INT(heap_caps_get_total_size(MALLOC_CAP_8BIT)); @@ -35,6 +37,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(espidf_heap_caps_get_total_size_obj, espidf_heap_caps_ //| """Return total free memory in the ESP-IDF heap.""" //| ... //| +//| static mp_obj_t espidf_heap_caps_get_free_size(void) { return MP_OBJ_NEW_SMALL_INT(heap_caps_get_free_size(MALLOC_CAP_8BIT)); @@ -45,6 +48,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(espidf_heap_caps_get_free_size_obj, espidf_heap_caps_g //| """Return the size of largest free memory block in the ESP-IDF heap.""" //| ... //| +//| static mp_obj_t espidf_heap_caps_get_largest_free_block(void) { return MP_OBJ_NEW_SMALL_INT(heap_caps_get_largest_free_block(MALLOC_CAP_8BIT)); @@ -58,6 +62,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(espidf_heap_caps_get_largest_free_block_obj, espidf_he //| layout of data in nvs has changed. The old data will be lost when you perform this operation. //| """ //| +//| static mp_obj_t espidf_erase_nvs(void) { ESP_ERROR_CHECK(nvs_flash_deinit()); ESP_ERROR_CHECK(nvs_flash_erase()); @@ -84,6 +89,7 @@ static void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_pr //| //| ... //| +//| MP_DEFINE_CONST_OBJ_TYPE( mp_type_espidf_IDFError, MP_QSTR_IDFError, @@ -99,6 +105,7 @@ MP_DEFINE_CONST_OBJ_TYPE( //| //| ... //| +//| NORETURN void mp_raise_espidf_MemoryError(void) { nlr_raise(mp_obj_new_exception(&mp_type_espidf_MemoryError)); } @@ -116,6 +123,7 @@ MP_DEFINE_CONST_OBJ_TYPE( //| def get_total_psram() -> int: //| """Returns the number of bytes of psram detected, or 0 if psram is not present or not configured""" //| +//| static mp_obj_t espidf_get_total_psram(void) { return MP_OBJ_NEW_SMALL_INT(common_hal_espidf_get_total_psram()); } diff --git a/ports/espressif/bindings/espnow/ESPNow.c b/ports/espressif/bindings/espnow/ESPNow.c index 80dfac93c1..890873573e 100644 --- a/ports/espressif/bindings/espnow/ESPNow.c +++ b/ports/espressif/bindings/espnow/ESPNow.c @@ -41,6 +41,7 @@ static void espnow_check_for_deinit(espnow_obj_t *self) { //| `wifi_phy_rate_t `_ //| """ //| ... +//| static mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_buffer_size, ARG_phy_rate }; static const mp_arg_t allowed_args[] = { @@ -71,6 +72,7 @@ static mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, size_t //| def deinit(self) -> None: //| """Deinitializes ESP-NOW and releases it for another program.""" //| ... +//| static mp_obj_t espnow_deinit(mp_obj_t self_in) { espnow_obj_t *self = MP_OBJ_TO_PTR(self_in); espnow_check_for_deinit(self); @@ -82,12 +84,14 @@ static MP_DEFINE_CONST_FUN_OBJ_1(espnow_deinit_obj, espnow_deinit); //| def __enter__(self) -> ESPNow: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t espnow_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; return espnow_deinit(args[0]); @@ -109,6 +113,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espnow___exit___obj, 4, 4, espnow_obj //| :param Peer peer: Send message to this peer. If `None`, send to all registered peers. //| """ //| ... +//| static mp_obj_t espnow_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_message, ARG_peer }; static const mp_arg_t allowed_args[] = { @@ -143,6 +148,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(espnow_send_obj, 2, espnow_send); //| //| :returns: An `ESPNowPacket` if available in the buffer, otherwise `None`.""" //| ... +//| static mp_obj_t espnow_read(mp_obj_t self_in) { espnow_obj_t *self = MP_OBJ_TO_PTR(self_in); espnow_check_for_deinit(self); @@ -204,6 +210,7 @@ MP_PROPERTY_GETTER(espnow_read_failure_obj, //| //| :param ReadableBuffer pmk: The ESP-NOW Primary Master Key (length = 16 bytes).""" //| ... +//| static mp_obj_t espnow_set_pmk(mp_obj_t self_in, mp_obj_t key) { espnow_obj_t *self = MP_OBJ_TO_PTR(self_in); espnow_check_for_deinit(self); @@ -325,6 +332,7 @@ static const mp_stream_p_t espnow_stream_p = { //| """Return the number of `bytes` available to read. Used to implement ``len()``.""" //| ... //| +//| static mp_obj_t espnow_unary_op(mp_unary_op_t op, mp_obj_t self_in) { espnow_obj_t *self = MP_OBJ_TO_PTR(self_in); espnow_check_for_deinit(self); diff --git a/ports/espressif/bindings/espnow/ESPNowPacket.c b/ports/espressif/bindings/espnow/ESPNowPacket.c index c53ed9dc77..3d85c88fc4 100644 --- a/ports/espressif/bindings/espnow/ESPNowPacket.c +++ b/ports/espressif/bindings/espnow/ESPNowPacket.c @@ -21,6 +21,7 @@ //| time: int //| """The time in milliseconds since the device last booted when the packet was received.""" //| +//| const mp_obj_namedtuple_type_t espnow_packet_type_obj = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_ESPNowPacket), diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index 70600a4fb1..3e73184914 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -32,6 +32,7 @@ //| :param bool encrypted: Whether or not to use encryption. //| """ //| ... +//| static mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_mac, ARG_lmk, ARG_channel, ARG_interface, ARG_encrypted }; static const mp_arg_t allowed_args[] = { @@ -167,6 +168,7 @@ MP_PROPERTY_GETSET(espnow_peer_interface_obj, //| encrypted: bool //| """Whether or not to use encryption.""" //| +//| static mp_obj_t espnow_peer_get_encrypted(const mp_obj_t self_in) { espnow_peer_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_bool(self->peer_info.encrypt); diff --git a/ports/espressif/bindings/espnow/Peers.c b/ports/espressif/bindings/espnow/Peers.c index 2f168768c9..57ab2d5f6c 100644 --- a/ports/espressif/bindings/espnow/Peers.c +++ b/ports/espressif/bindings/espnow/Peers.c @@ -21,6 +21,7 @@ //| def __init__(self) -> None: //| """You cannot create an instance of `Peers`.""" //| ... +//| //| def append(self, peer: Peer) -> None: //| """Append peer. @@ -28,6 +29,7 @@ //| :param Peer peer: The peer object to append. //| """ //| ... +//| static mp_obj_t espnow_peers_append(mp_obj_t self_in, mp_obj_t arg) { espnow_peer_obj_t *peer = MP_OBJ_TO_PTR(mp_arg_validate_type(arg, &espnow_peer_type, MP_QSTR_Peer)); CHECK_ESP_RESULT(esp_now_add_peer(&peer->peer_info)); @@ -43,6 +45,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(espnow_peers_append_obj, espnow_peers_append); //| """ //| ... //| +//| static mp_obj_t espnow_peers_remove(mp_obj_t self_in, mp_obj_t arg) { espnow_peer_obj_t *peer = MP_OBJ_TO_PTR(mp_arg_validate_type(arg, &espnow_peer_type, MP_QSTR_Peer)); CHECK_ESP_RESULT(esp_now_del_peer(peer->peer_info.peer_addr)); diff --git a/ports/espressif/bindings/espnow/__init__.c b/ports/espressif/bindings/espnow/__init__.c index 79bc0b0f3a..6415bf0d1e 100644 --- a/ports/espressif/bindings/espnow/__init__.c +++ b/ports/espressif/bindings/espnow/__init__.c @@ -51,6 +51,7 @@ //| for packet in packets: //| print(packet) //| """ +//| //| ... //| diff --git a/ports/espressif/bindings/espulp/Architecture.c b/ports/espressif/bindings/espulp/Architecture.c index ee45035e89..bcf094e7e1 100644 --- a/ports/espressif/bindings/espulp/Architecture.c +++ b/ports/espressif/bindings/espulp/Architecture.c @@ -20,6 +20,7 @@ MAKE_ENUM_VALUE(espulp_architecture_type, architecture, RISCV, RISCV); //| RISCV: Architecture //| """The ULP RISC-V Coprocessor.""" //| +//| MAKE_ENUM_MAP(espulp_architecture) { MAKE_ENUM_MAP_ENTRY(architecture, FSM), MAKE_ENUM_MAP_ENTRY(architecture, RISCV), diff --git a/ports/espressif/bindings/espulp/ULP.c b/ports/espressif/bindings/espulp/ULP.c index fb7c84495e..dac1ef914a 100644 --- a/ports/espressif/bindings/espulp/ULP.c +++ b/ports/espressif/bindings/espulp/ULP.c @@ -22,6 +22,7 @@ //| :param Architecture arch: The ulp arch. //| """ //| ... +//| static mp_obj_t espulp_ulp_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_arch }; static const mp_arg_t allowed_args[] = { @@ -49,6 +50,7 @@ static void check_for_deinit(espulp_ulp_obj_t *self) { //| def deinit(self) -> None: //| """Deinitialises the ULP and releases it for another program.""" //| ... +//| static mp_obj_t espulp_ulp_deinit(mp_obj_t self_in) { espulp_ulp_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_espulp_ulp_deinit(self); @@ -59,12 +61,14 @@ static MP_DEFINE_CONST_FUN_OBJ_1(espulp_ulp_deinit_obj, espulp_ulp_deinit); //| def __enter__(self) -> ULP: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t espulp_ulp_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; return espulp_ulp_deinit(args[0]); @@ -79,6 +83,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espulp_ulp___exit___obj, 4, 4, espulp //| By default, the value stored in period index 0 is used. //| :param int period_us: The wakeup period given in microseconds.""" //| ... +//| static mp_obj_t espulp_ulp_set_wakeup_period(mp_obj_t self_in, mp_obj_t period_index, mp_obj_t period_us) { espulp_ulp_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -95,7 +100,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(espulp_ulp_set_wakeup_period_obj, espulp_ulp_se //| program: ReadableBuffer, //| *, //| entrypoint: int = 0, -//| pins: Sequence[microcontroller.Pin] = () +//| pins: Sequence[microcontroller.Pin] = (), //| ) -> None: //| """Loads the program into ULP memory and then runs the program. //| @@ -107,6 +112,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(espulp_ulp_set_wakeup_period_obj, espulp_ulp_se //| :param Sequence[microcontroller.Pin] pins: Pins made available to the ULP. //| The pins are claimed and not reset until `halt()` is called.""" //| ... +//| static mp_obj_t espulp_ulp_run(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { espulp_ulp_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); @@ -155,6 +161,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(espulp_ulp_run_obj, 2, espulp_ulp_run); //| Note: for the FSM ULP, a running ULP program is not actually interrupted. //| Instead, only the wakeup timer is stopped.""" //| ... +//| static mp_obj_t espulp_ulp_halt(mp_obj_t self_in) { espulp_ulp_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -167,6 +174,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(espulp_ulp_halt_obj, espulp_ulp_halt); //| arch: Architecture //| """The ulp architecture. (read-only)""" //| +//| static mp_obj_t espulp_ulp_get_arch(mp_obj_t self_in) { espulp_ulp_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/ports/espressif/bindings/espulp/ULPAlarm.c b/ports/espressif/bindings/espulp/ULPAlarm.c index edff8e44b8..6c31137f9a 100644 --- a/ports/espressif/bindings/espulp/ULPAlarm.c +++ b/ports/espressif/bindings/espulp/ULPAlarm.c @@ -20,6 +20,7 @@ //| :param ULP ulp: The ulp instance""" //| ... //| +//| static mp_obj_t espulp_ulpalarm_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_ulp }; static const mp_arg_t allowed_args[] = { diff --git a/ports/espressif/bindings/espulp/__init__.c b/ports/espressif/bindings/espulp/__init__.c index 59a3519868..9808ab55f4 100644 --- a/ports/espressif/bindings/espulp/__init__.c +++ b/ports/espressif/bindings/espulp/__init__.c @@ -33,14 +33,17 @@ //| print(shared_mem[0]) //| # ulp.halt() //| """ +//| //| ... //| +//| //| def get_rtc_gpio_number(pin: microcontroller.Pin) -> Optional[int]: //| """Return the RTC GPIO number of the given pin or None if not connected //| to RTC GPIO.""" //| ... //| +//| static mp_obj_t espulp_get_rtc_gpio_number(mp_obj_t pin_obj) { const mcu_pin_obj_t *pin = validate_obj_is_pin(pin_obj, MP_QSTR_pin); diff --git a/ports/espressif/tools/check-sdkconfig.py b/ports/espressif/tools/check-sdkconfig.py index 8a7ef88217..12254a71d0 100755 --- a/ports/espressif/tools/check-sdkconfig.py +++ b/ports/espressif/tools/check-sdkconfig.py @@ -29,7 +29,7 @@ def validate(sdk_config, circuitpy_config): if circuitpy_config.get(var): with open(partition_table) as f: content = f.read() - if not "ota_1" in content: + if "ota_1" not in content: raise SystemExit( f"{var} is incompatible with {partition_table=} (no ota_1 partition)" ) diff --git a/ports/espressif/tools/decode_backtrace.py b/ports/espressif/tools/decode_backtrace.py index 6d2772d39f..024e636207 100644 --- a/ports/espressif/tools/decode_backtrace.py +++ b/ports/espressif/tools/decode_backtrace.py @@ -1,10 +1,10 @@ """Simple script that translates "Backtrace:" lines from the ESP output to files - and line numbers. +and line numbers. - Run with: python3 tools/decode_backtrace.py +Run with: python3 tools/decode_backtrace.py - Enter the backtrace line at the "? " prompt. CTRL-C to exit the script. - """ +Enter the backtrace line at the "? " prompt. CTRL-C to exit the script. +""" import subprocess import sys diff --git a/ports/espressif/tools/update_sdkconfig.py b/ports/espressif/tools/update_sdkconfig.py index f69e845374..78ffa8590c 100644 --- a/ports/espressif/tools/update_sdkconfig.py +++ b/ports/espressif/tools/update_sdkconfig.py @@ -1,5 +1,5 @@ """This script updates the sdkconfigs based on the menuconfig results in a given - build.""" +build.""" import pathlib import click @@ -157,7 +157,7 @@ def sym_default(sym): default=False, help="Updates the sdkconfigs outside of the board directory.", ) -def update(debug, board, update_all): +def update(debug, board, update_all): # noqa: C901: too complex """Updates related sdkconfig files based on the build directory version that was likely modified by menuconfig.""" @@ -202,7 +202,7 @@ def update(debug, board, update_all): kconfig_path = pathlib.Path(f"build-{board}/esp-idf/kconfigs.in") - kconfig_path = pathlib.Path(f"esp-idf/Kconfig") + kconfig_path = pathlib.Path("esp-idf/Kconfig") kconfig = kconfiglib.Kconfig(kconfig_path) input_config = pathlib.Path(f"build-{board}/esp-idf/sdkconfig") @@ -230,7 +230,7 @@ def update(debug, board, update_all): sdkconfigs.extend((flash_size_config, flash_mode_config, flash_freq_config)) if psram_size != "0": - psram_config = pathlib.Path(f"esp-idf-config/sdkconfig-psram.defaults") + psram_config = pathlib.Path("esp-idf-config/sdkconfig-psram.defaults") psram_size_config = pathlib.Path(f"esp-idf-config/sdkconfig-psram-{psram_size}.defaults") psram_mode_config = pathlib.Path(f"esp-idf-config/sdkconfig-psram-{psram_mode}.defaults") psram_freq_config = pathlib.Path(f"esp-idf-config/sdkconfig-psram-{psram_freq}.defaults") @@ -238,7 +238,7 @@ def update(debug, board, update_all): target_config = pathlib.Path(f"esp-idf-config/sdkconfig-{target}.defaults") sdkconfigs.append(target_config) if ble_enabled: - ble_config = pathlib.Path(f"esp-idf-config/sdkconfig-ble.defaults") + ble_config = pathlib.Path("esp-idf-config/sdkconfig-ble.defaults") sdkconfigs.append(ble_config) board_config = pathlib.Path(f"boards/{board}/sdkconfig") # Don't include the board file in cp defaults. The board may have custom diff --git a/ports/mimxrt10xx/tools/gen_peripherals_data.py b/ports/mimxrt10xx/tools/gen_peripherals_data.py index 664e1c6556..e9ceeb63f2 100644 --- a/ports/mimxrt10xx/tools/gen_peripherals_data.py +++ b/ports/mimxrt10xx/tools/gen_peripherals_data.py @@ -288,7 +288,7 @@ for device in devices: pins_h.append("// Pads can be reset. Other pins like USB cannot be.") pins_h.append(f"#define PAD_COUNT ({pin_number})") pins_h.append(f"#define PIN_COUNT (PAD_COUNT + {len(usb_pins)})") - pins_h.append(f"extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];") + pins_h.append("extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];") pins_h.append("") out_dir.mkdir(exist_ok=True) @@ -307,7 +307,7 @@ for device in devices: "", ] - for ptype in SIGNALS: + for ptype, signals in SIGNALS: instances = all_peripherals[ptype] short_name = ptype.lower() if short_name.startswith("lp"): @@ -323,7 +323,7 @@ for device in devices: f"{ptype}_Type *const mcu_{short_name}_banks[{len(instances)}] = {{ {joined_instances} }};" ) periph_c.append("") - for signal in SIGNALS[ptype]: + for signal in signals: pin_count = 0 for instance in instances: if instance not in peripheral_inputs or signal not in peripheral_inputs[instance]: @@ -357,8 +357,8 @@ for device in devices: periph_c.append( f" PERIPH_PIN({instance_number}, {alt}, {select_input}, {input_value}, &pin_{pin_name})," ) - periph_c.append(f"}};") - periph_c.append(f"") + periph_c.append("};") + periph_c.append("") periph_h.append("") pwm_outputs.sort(key=lambda x: x[:3]) @@ -373,7 +373,7 @@ for device in devices: periph_c.append( f" PWM_PIN(PWM{pwm_instance}, kPWM_Module_{module}, kPWM_Pwm{channel}, IOMUXC_{pin_name}_{connection}, &pin_{pin_name})," ) - periph_c.append(f"}};") + periph_c.append("};") periph_c.append("") periph_h.append("") diff --git a/ports/raspberrypi/bindings/cyw43/__init__.c b/ports/raspberrypi/bindings/cyw43/__init__.c index 83aacdc48a..c14f15212f 100644 --- a/ports/raspberrypi/bindings/cyw43/__init__.c +++ b/ports/raspberrypi/bindings/cyw43/__init__.c @@ -35,6 +35,7 @@ void bindings_cyw43_wifi_enforce_pm(void) { //| in :py:mod:`board`. A `CywPin` can be used as a DigitalInOut, but not with other //| peripherals such as `PWMOut`.""" //| +//| MP_DEFINE_CONST_OBJ_TYPE( cyw43_pin_type, MP_QSTR_CywPin, @@ -51,6 +52,7 @@ MP_DEFINE_CONST_OBJ_TYPE( //| PM_DISABLED: int //| """Disable power management and always use highest power mode. CircuitPython sets this value at reset time, because it provides the best connectivity reliability.""" //| +//| //| def set_power_management(value: int) -> None: //| """Set the power management register //| @@ -80,6 +82,7 @@ MP_DEFINE_CONST_OBJ_TYPE( //| usage. //| """ //| +//| static mp_obj_t cyw43_set_power_management(const mp_obj_t value_in) { mp_int_t value = mp_obj_get_int(value_in); power_management_value = value; @@ -91,6 +94,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(cyw43_set_power_management_obj, cyw43_set_power //| def get_power_management() -> int: //| """Retrieve the power management register""" //| +//| static mp_obj_t cyw43_get_power_management() { return mp_obj_new_int(power_management_value); } diff --git a/ports/raspberrypi/bindings/picodvi/Framebuffer.c b/ports/raspberrypi/bindings/picodvi/Framebuffer.c index 0ada4fba7c..4530708152 100644 --- a/ports/raspberrypi/bindings/picodvi/Framebuffer.c +++ b/ports/raspberrypi/bindings/picodvi/Framebuffer.c @@ -85,6 +85,7 @@ //| :param int color_depth: the color depth of the framebuffer in bits. 1, 2 for grayscale //| and 4 (RP2350 only), 8 or 16 for color //| """ +//| static mp_obj_t picodvi_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_width, ARG_height, ARG_clk_dp, ARG_clk_dn, ARG_red_dp, ARG_red_dn, ARG_green_dp, @@ -136,6 +137,7 @@ static mp_obj_t picodvi_framebuffer_make_new(const mp_obj_type_t *type, size_t n //| `picodvi.Framebuffer` instance. After deinitialization, no further operations //| may be performed.""" //| ... +//| static mp_obj_t picodvi_framebuffer_deinit(mp_obj_t self_in) { picodvi_framebuffer_obj_t *self = (picodvi_framebuffer_obj_t *)self_in; common_hal_picodvi_framebuffer_deinit(self); @@ -164,6 +166,7 @@ MP_PROPERTY_GETTER(picodvi_framebuffer_width_obj, //| height: int //| """The width of the framebuffer, in pixels. It may be doubled for output.""" //| +//| static mp_obj_t picodvi_framebuffer_get_height(mp_obj_t self_in) { picodvi_framebuffer_obj_t *self = (picodvi_framebuffer_obj_t *)self_in; check_for_deinit(self); diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index aed2f15d63..7882577f54 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -32,6 +32,7 @@ //| MovStatusType_piov0 = Literal["txfifo"] //| """A type representing the string ``"txfifo"``. This value is supported on RP2350 and RP2040. For type-checking only, not actually defined in CircuitPython.""" //| +//| //| class StateMachine: //| """A single PIO StateMachine //| @@ -161,6 +162,7 @@ //| :param MovStatusType mov_status_n: The FIFO depth or IRQ the ``mov status`` instruction checks for. For ``mov_status irq`` this includes the encoding of the ``next``/``prev`` selection bits. //| """ //| ... +//| static int one_of(qstr_short_t what, mp_obj_t arg, size_t n_options, const qstr_short_t options[], const int values[]) { for (size_t i = 0; i < n_options; i++) { @@ -357,6 +359,7 @@ static mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n //| def deinit(self) -> None: //| """Turn off the state machine and release its resources.""" //| ... +//| static mp_obj_t rp2pio_statemachine_obj_deinit(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_rp2pio_statemachine_deinit(self); @@ -368,11 +371,13 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_deinit_obj, rp2pio_statemachine_ob //| """No-op used by Context Managers. //| Provided by context manager helper.""" //| ... +//| //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t rp2pio_statemachine_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_rp2pio_statemachine_deinit(args[0]); @@ -390,6 +395,7 @@ static void check_for_deinit(rp2pio_statemachine_obj_t *self) { //| def restart(self) -> None: //| """Resets this state machine, runs any init and enables the clock.""" //| ... +//| // TODO: "and any others given. They must share an underlying PIO. An exception will be raised otherwise."" static mp_obj_t rp2pio_statemachine_restart(mp_obj_t self_obj) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_obj); @@ -408,6 +414,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_restart_obj, rp2pio_statemachine_r //| This can be used to output internal state to the RX FIFO and then //| read with `readinto`.""" //| ... +//| static mp_obj_t rp2pio_statemachine_run(mp_obj_t self_obj, mp_obj_t instruction_obj) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_obj); check_for_deinit(self); @@ -426,6 +433,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(rp2pio_statemachine_run_obj, rp2pio_statemachine_run); //| def stop(self) -> None: //| """Stops the state machine clock. Use `restart` to enable it.""" //| ... +//| static mp_obj_t rp2pio_statemachine_stop(mp_obj_t self_obj) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_obj); check_for_deinit(self); @@ -457,6 +465,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_stop_obj, rp2pio_statemachine_stop //| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` //| :param bool swap: For 2- and 4-byte elements, swap (reverse) the byte order""" //| ... +//| static mp_obj_t rp2pio_statemachine_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_swap }; static const mp_arg_t allowed_args[] = { @@ -545,6 +554,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_write_obj, 2, rp2pio_statemachine //| :param bool swap: For 2- and 4-byte elements, swap (reverse) the byte order //| """ //| ... +//| static void fill_buf_info(sm_buf_info *info, mp_obj_t obj, size_t *stride_in_bytes, mp_uint_t direction) { if (obj != mp_const_none) { @@ -602,6 +612,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_background_write_obj, 1, rp2pio_s //| """Immediately stop a background write, if one is in progress. Any //| DMA in progress is halted, but items already in the TX FIFO are not //| affected.""" +//| static mp_obj_t rp2pio_statemachine_obj_stop_background_write(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); bool ok = common_hal_rp2pio_statemachine_stop_background_write(self); @@ -634,6 +645,7 @@ MP_PROPERTY_GETTER(rp2pio_statemachine_writing_obj, //| If the number is 0, then a `StateMachine.background_write` call will not block. //| Note that `pending` is a deprecated alias for `pending_write` and will be removed //| in a future version of CircuitPython.""" +//| static mp_obj_t rp2pio_statemachine_obj_get_pending_write(mp_obj_t self_in) { @@ -688,6 +700,7 @@ MP_PROPERTY_GETTER(rp2pio_statemachine_pending_write_obj, //| :param bool swap: For 2- and 4-byte elements, swap (reverse) the byte order //| """ //| ... +//| static mp_obj_t rp2pio_statemachine_background_read(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -729,6 +742,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_background_read_obj, 1, rp2pio_st //| """Immediately stop a background read, if one is in progress. Any //| DMA in progress is halted, but items already in the RX FIFO are not //| affected.""" +//| static mp_obj_t rp2pio_statemachine_obj_stop_background_read(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); bool ok = common_hal_rp2pio_statemachine_stop_background_read(self); @@ -757,6 +771,7 @@ MP_PROPERTY_GETTER(rp2pio_statemachine_reading_obj, //| """Returns the number of pending buffers for background reading. //| //| If the number is 0, then a `StateMachine.background_read` call will not block.""" +//| static mp_obj_t rp2pio_statemachine_obj_get_pending_read(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_int(common_hal_rp2pio_statemachine_get_pending_read(self)); @@ -793,6 +808,7 @@ MP_PROPERTY_GETTER(rp2pio_statemachine_pending_read_obj, //| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` //| :param bool swap: For 2- and 4-byte elements, swap (reverse) the byte order""" //| ... +//| static mp_obj_t rp2pio_statemachine_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_swap }; @@ -863,6 +879,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_readinto_obj, 2, rp2pio_statemach //| :param bool swap_in: For 2- and 4-rx elements, swap (reverse) the byte order for the buffer being received (read) //| """ //| ... +//| static mp_obj_t rp2pio_statemachine_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end, ARG_swap_out, ARG_swap_in }; @@ -928,6 +945,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_write_readinto_obj, 2, rp2pio_sta //| def clear_rxfifo(self) -> None: //| """Clears any unread bytes in the rxfifo.""" //| ... +//| static mp_obj_t rp2pio_statemachine_obj_clear_rxfifo(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_rp2pio_statemachine_clear_rxfifo(self); @@ -938,6 +956,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_clear_rxfifo_obj, rp2pio_statemach //| def clear_txstall(self) -> None: //| """Clears the txstall flag.""" //| ... +//| static mp_obj_t rp2pio_statemachine_obj_clear_txstall(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_rp2pio_statemachine_clear_txstall(self); @@ -1093,6 +1112,7 @@ MP_PROPERTY_GETTER(rp2pio_statemachine_last_read_obj, //| changes or restarts. //| """ //| +//| static mp_obj_t rp2pio_statemachine_obj_get_last_write(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/ports/raspberrypi/bindings/rp2pio/__init__.c b/ports/raspberrypi/bindings/rp2pio/__init__.c index 6f981de3dc..e68c376ae8 100644 --- a/ports/raspberrypi/bindings/rp2pio/__init__.c +++ b/ports/raspberrypi/bindings/rp2pio/__init__.c @@ -24,11 +24,13 @@ //| See the warning in `digitalio` for more information. //| """ //| +//| //| def pins_are_sequential(pins: List[microcontroller.Pin]) -> bool: //| """Return True if the pins have sequential GPIO numbers, False otherwise""" //| ... //| +//| static mp_obj_t rp2pio_pins_are_sequential(mp_obj_t pins_obj) { size_t len; mp_obj_t *items; diff --git a/ports/raspberrypi/gen_stage2.py b/ports/raspberrypi/gen_stage2.py index 759384e17f..005994dc10 100644 --- a/ports/raspberrypi/gen_stage2.py +++ b/ports/raspberrypi/gen_stage2.py @@ -45,8 +45,6 @@ def main(input_template: pathlib.Path, output_path: pathlib.Path, skus: str = ty quad_ok = quad_enable_status_byte is not None and quad_enable_bit_mask is not None - max_clock_speed_mhz = min((x.get("max_clock_speed_mhz", 1000) for x in flashes["nvm"])) - default_power_of_two = None for nvm in flashes["nvm"]: capacity = nvm.get("capacity", 0) diff --git a/ports/silabs/tools/make_pins.py b/ports/silabs/tools/make_pins.py index da662094b3..9ae370bf6d 100644 --- a/ports/silabs/tools/make_pins.py +++ b/ports/silabs/tools/make_pins.py @@ -124,7 +124,7 @@ def make_pin_function_lists(functions, pins): fcn_list[pin][i] = 1 i += 1 for pin in pins.keys(): - if not pin in fcn_list: + if pin not in fcn_list: fcn_list[pin] = [] decl += make_pin_function_list_decl(pin, fcn_list[pin]) diff --git a/ports/stm/boards/swan_r5/tests/analog_output.py b/ports/stm/boards/swan_r5/tests/analog_output.py index 6af931e65d..f2ef97dc2c 100644 --- a/ports/stm/boards/swan_r5/tests/analog_output.py +++ b/ports/stm/boards/swan_r5/tests/analog_output.py @@ -31,7 +31,7 @@ def test_dac_digital(p_in, p_out): def test_dual(pair1, pair2): # verifies that the DACs can be set independently - print(f"Running pair test\n") + print("Running pair test\n") pin1_in = analogio.AnalogIn(pair1[0]) pin1_out = analogio.AnalogOut(pair1[1]) pin2_in = analogio.AnalogIn(pair2[0]) diff --git a/ports/stm/boards/swan_r5/tests/enable_3v3.py b/ports/stm/boards/swan_r5/tests/enable_3v3.py index c32bbc58b8..fecd05a3c5 100644 --- a/ports/stm/boards/swan_r5/tests/enable_3v3.py +++ b/ports/stm/boards/swan_r5/tests/enable_3v3.py @@ -13,9 +13,9 @@ assert board.ENABLE_3V3 is not None # Then the symbol "board.DISCHARGE_3V3" is defined assert board.DISCHARGE_3V3 is not None # And the symbol "board.DISABLE_DISCHARGING" is defined to be "True" -assert board.DISABLE_DISCHARGING is not None and board.DISABLE_DISCHARGING == True +assert board.DISABLE_DISCHARGING is not None and board.DISABLE_DISCHARGING # And the symbol "board.ENABLE_DISCHARGING" is defined to be "False" -assert board.ENABLE_DISCHARGING is not None and board.ENABLE_DISCHARGING == False +assert board.ENABLE_DISCHARGING is not None and not board.ENABLE_DISCHARGING # Scenario: Toggle ENBLE_3V3 # Given I have a LED connected between the 3V3 and GND pins diff --git a/ports/zephyr-cp/bindings/zephyr_serial/UART.c b/ports/zephyr-cp/bindings/zephyr_serial/UART.c index 91cb17d143..cd0b849b31 100644 --- a/ports/zephyr-cp/bindings/zephyr_serial/UART.c +++ b/ports/zephyr-cp/bindings/zephyr_serial/UART.c @@ -60,6 +60,7 @@ static zephyr_serial_uart_obj_t *native_uart(mp_obj_t uart_obj) { //| def deinit(self) -> None: //| """Deinitialises the UART and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t _zephyr_serial_uart_obj_deinit(mp_obj_t self_in) { zephyr_serial_uart_obj_t *self = native_uart(self_in); zephyr_serial_uart_deinit(self); @@ -76,12 +77,14 @@ static void check_for_deinit(zephyr_serial_uart_obj_t *self) { //| def __enter__(self) -> UART: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t _zephyr_serial_uart_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; zephyr_serial_uart_deinit(MP_OBJ_TO_PTR(args[0])); @@ -104,6 +107,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(_zephyr_serial_uart___exit___obj, 4, //| :return: Data read //| :rtype: bytes or None""" //| ... +//| //| def readinto(self, buf: WriteableBuffer) -> Optional[int]: //| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. @@ -113,6 +117,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(_zephyr_serial_uart___exit___obj, 4, //| //| *New in CircuitPython 4.0:* No length parameter is permitted.""" //| ... +//| //| def readline(self) -> bytes: //| """Read a line, ending in a newline character, or @@ -123,6 +128,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(_zephyr_serial_uart___exit___obj, 4, //| :return: the line read //| :rtype: bytes or None""" //| ... +//| //| def write(self, buf: ReadableBuffer) -> Optional[int]: //| """Write the buffer of bytes to the bus. @@ -132,6 +138,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(_zephyr_serial_uart___exit___obj, 4, //| :return: the number of bytes written //| :rtype: int or None""" //| ... +//| // These three methods are used by the shared stream methods. static mp_uint_t _zephyr_serial_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) { @@ -212,6 +219,7 @@ MP_PROPERTY_GETTER(_zephyr_serial_uart_in_waiting_obj, //| timeout: float //| """The current timeout, in seconds (float).""" +//| static mp_obj_t _zephyr_serial_uart_obj_get_timeout(mp_obj_t self_in) { zephyr_serial_uart_obj_t *self = native_uart(self_in); check_for_deinit(self); @@ -238,6 +246,7 @@ MP_PROPERTY_GETSET(_zephyr_serial_uart_timeout_obj, //| """Discard any unread characters in the input buffer.""" //| ... //| +//| static mp_obj_t _zephyr_serial_uart_obj_reset_input_buffer(mp_obj_t self_in) { zephyr_serial_uart_obj_t *self = native_uart(self_in); check_for_deinit(self); diff --git a/ports/zephyr-cp/bindings/zephyr_serial/__init__.c b/ports/zephyr-cp/bindings/zephyr_serial/__init__.c index 29521be1c6..f4a3c7b92e 100644 --- a/ports/zephyr-cp/bindings/zephyr_serial/__init__.c +++ b/ports/zephyr-cp/bindings/zephyr_serial/__init__.c @@ -15,8 +15,7 @@ #include "py/runtime.h" -//| """Zephyr UART driver for fixed busses. -//| """ +//| """Zephyr UART driver for fixed busses.""" static const mp_rom_map_elem_t zephyr_serial_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_zephyr_serial) }, diff --git a/ports/zephyr-cp/cptools/build_circuitpython.py b/ports/zephyr-cp/cptools/build_circuitpython.py index acc609e33c..e6ebd97b3b 100644 --- a/ports/zephyr-cp/cptools/build_circuitpython.py +++ b/ports/zephyr-cp/cptools/build_circuitpython.py @@ -502,7 +502,7 @@ async def build_circuitpython(): not autogen_board_info_fn.exists() or autogen_board_info_fn.read_text() != tomlkit.dumps(autogen_board_info) ): - logger.error(f"autogen_board_info.toml is out of date.") + logger.error("autogen_board_info.toml is out of date.") raise RuntimeError( f"autogen_board_info.toml is missing or out of date. Please run `make BOARD={board}` locally and commit {autogen_board_info_fn}." ) @@ -519,7 +519,6 @@ async def build_circuitpython(): source_files.append(file) qstr_flags = "-DNO_QSTR" async with asyncio.TaskGroup() as tg: - extra_source_flags = {} for source_file in source_files: tg.create_task( preprocess_and_split_defs( diff --git a/ports/zephyr-cp/cptools/cpbuild.py b/ports/zephyr-cp/cptools/cpbuild.py index 03895883b7..335234b8c7 100644 --- a/ports/zephyr-cp/cptools/cpbuild.py +++ b/ports/zephyr-cp/cptools/cpbuild.py @@ -318,7 +318,7 @@ def parse_depfile(f): if dep.startswith("/"): extradeps.append(pathlib.Path(dep)) else: - extradeps.append(self.srcdir / dep) + raise RuntimeError(f"Unexpected depfile entry {dep}") class Compiler: @@ -397,40 +397,3 @@ class Compiler: working_directory=self.srcdir, extradeps=objects, ) - - async def link( - self, - objects: list[pathlib.Path], - output_file: pathlib.Path, - linker_script: pathlib.Path, - flags: list[str] = [], - print_memory_use=True, - output_map_file=True, - gc_sections=True, - ): - output_file.parent.mkdir(parents=True, exist_ok=True) - link_flags = [] - if print_memory_use: - link_flags.append("-Wl,--print-memory-usage") - if output_map_file: - link_flags.append( - "-Wl,-Map=" - + str(output_file.with_suffix(".elf.map").relative_to(caller_directory)) - ) - if gc_sections: - link_flags.append("-Wl,--gc-sections") - await run_command( - [ - self.c_compiler, - *link_flags, - *flags, - *objects, - "-fuse-ld=lld", - "-T", - linker_script, - "-o", - output_file, - ], - description=f"Link {output_file.relative_to(cwd)}", - working_directory=caller_directory, - ) diff --git a/ports/zephyr-cp/cptools/zephyr2cp.py b/ports/zephyr-cp/cptools/zephyr2cp.py index f6a63a256d..cd0e3a6f2a 100644 --- a/ports/zephyr-cp/cptools/zephyr2cp.py +++ b/ports/zephyr-cp/cptools/zephyr2cp.py @@ -93,7 +93,7 @@ CONNECTORS = { @cpbuild.run_in_thread -def zephyr_dts_to_cp_board(builddir, zephyrbuilddir): +def zephyr_dts_to_cp_board(builddir, zephyrbuilddir): # noqa: C901 board_dir = builddir / "board" # Auto generate board files from device tree. @@ -125,8 +125,6 @@ def zephyr_dts_to_cp_board(builddir, zephyrbuilddir): # print(board_id_yaml) # board_name = board_id_yaml["name"] - enabled_modules = [] - dts = zephyrbuilddir / "zephyr.dts" edt_pickle = dtlib.DT(dts) node2alias = {} @@ -291,7 +289,7 @@ def zephyr_dts_to_cp_board(builddir, zephyrbuilddir): board_pin_mapping = [] for ioport in sorted(ioports.keys()): for num in ioports[ioport]: - pin_object_name = f"P{ioport[len(shared_prefix):].upper()}_{num:02d}" + pin_object_name = f"P{ioport[len(shared_prefix) :].upper()}_{num:02d}" if status_led and (ioport, num) == status_led: status_led = pin_object_name pin_defs.append( diff --git a/py/maketranslationdata.py b/py/maketranslationdata.py index fdec4f8aee..3933387b64 100644 --- a/py/maketranslationdata.py +++ b/py/maketranslationdata.py @@ -90,8 +90,8 @@ def translate(translation_file, i18ns): translations = [] for original in i18ns: unescaped = original - for s in C_ESCAPES: - unescaped = unescaped.replace(C_ESCAPES[s], s) + for s, replacement in C_ESCAPES.items(): + unescaped = unescaped.replace(replacement, s) if original == "en_US": translation = table.info()["language"] else: @@ -593,12 +593,15 @@ def output_translation_data(encoding_table, i18ns, out): total_text_compressed_size += len(compressed) decompressed = decompress(encoding_table, compressed, encoded_length_bits) assert decompressed == translation, (decompressed, translation) - for c in C_ESCAPES: - decompressed = decompressed.replace(c, C_ESCAPES[c]) + for c, replacement in C_ESCAPES.items(): + decompressed = decompressed.replace(c, replacement) formatted = ["{:d}".format(x) for x in compressed] out.write( "const struct compressed_string translation{} = {{ .data = {}, .tail = {{ {} }} }}; // {}\n".format( - i, formatted[0], ", ".join(formatted[1:]), original, decompressed + i, + formatted[0], + ", ".join(formatted[1:]), + original, ) ) total_text_size += len(translation.encode("utf-8")) diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index cfcad5d8c6..4b45aa6d60 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -65,7 +65,7 @@ def make_version_header(repo_path, filename): """ % ( git_tag, git_hash, - datetime.date.today().strftime("%Y-%m-%d"), + build_date.strftime("%Y-%m-%d"), ver[0].replace("v", ""), ver[1], ver[2], diff --git a/pyproject.toml b/pyproject.toml index 271171183a..0db7eb70a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,3 +4,58 @@ [tool.setuptools_scm] # can be empty if no extra settings are needed, presence enables setuptools-scm + +# Ruff settings copied from MicroPython + +[tool.ruff] +target-version = "py37" + +line-length = 99 +# Exclude third-party code from linting and formatting. Ruff doesn't know how to ignore submodules. +# Exclude the following tests: +# repl_: not real python files +# viper_args: uses f(*) +extend-exclude = [ + "extmod/ulab", + "frozen", + "lib", + "ports/analog/msdk", + "ports/atmel-samd/asf4", + "ports/broadcom/peripherals", + "ports/espressif/esp-idf", + "ports/espressif/esp-protocols", + "ports/raspberrypi/sdk", + "ports/silabs/gecko_sdk", + "ports/silabs/tools/slc_cli_linux", + "ports/stm/st_driver", + "tests/*/repl_*.py", + "tests/micropython/viper_args.py", + "tools/adabot", + "tools/bitmap_font", + "tools/cc1", + "tools/huffman", + "tools/msgfmt.py", + "tools/python-semver", + "tools/uf2", +] +# Exclude third-party code, and exclude the following tests: +# basics: needs careful attention before applying automatic formatting +format.exclude = [ "tests/basics/*.py" ] +lint.extend-select = [ "C9", "PLC" ] +lint.ignore = [ + "E401", + "E402", + "E722", + "E731", + "E741", + "F401", + "F403", + "F405", + "PLC1901", +] +# manifest.py files are evaluated with some global names pre-defined +lint.per-file-ignores."**/manifest.py" = [ "F821" ] +lint.per-file-ignores."ports/**/boards/**/manifest_*.py" = [ "F821" ] +# Exclude all tests from linting (does not apply to formatting). +lint.per-file-ignores."tests/**/*.py" = [ "ALL" ] +lint.mccabe.max-complexity = 40 diff --git a/requirements-dev.txt b/requirements-dev.txt index a97ffef26d..4a8db2d3c8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -14,7 +14,7 @@ requests-cache polib # For pre-commit -black +ruff pyyaml pre-commit micropython-uncrustify diff --git a/runtime.py b/runtime.py index 28bf98962e..28193ce590 100644 --- a/runtime.py +++ b/runtime.py @@ -1,10 +1,11 @@ import pathlib + paths = pathlib.Path(".").glob("**/*.c") -translate_h = "#include \"supervisor/shared/translate/translate.h\"" +translate_h = '#include "supervisor/shared/translate/translate.h"' for p in paths: if "esp-idf" in p: continue lines = p.read_text().split("\n") - if "#include \"py/runtime.h\"" in lines and translate_h in lines: + if '#include "py/runtime.h"' in lines and translate_h in lines: lines.remove(translate_h) p.write_text("\n".join(lines)) diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 7190594c10..92b910c8b2 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -62,6 +62,7 @@ //| Use `_bleio.adapter` to access the sole instance already available. //| """ //| ... +//| static mp_obj_t bleio_adapter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_BLEIO_HCI bleio_adapter_obj_t *self = common_hal_bleio_allocate_adapter_or_raise(); @@ -135,6 +136,7 @@ MP_PROPERTY_GETSET(bleio_adapter_address_obj, //| """name of the BLE adapter used once connected. //| The name is "CIRCUITPY" + the last four hex digits of ``adapter.address``, //| to make it easy to distinguish multiple CircuitPython boards.""" +//| static mp_obj_t _bleio_adapter_get_name(mp_obj_t self) { return MP_OBJ_FROM_PTR(common_hal_bleio_adapter_get_name(self)); } @@ -161,7 +163,7 @@ MP_PROPERTY_GETSET(bleio_adapter_name_obj, //| timeout: int = 0, //| interval: float = 0.1, //| tx_power: int = 0, -//| directed_to: Optional[Address] = None +//| directed_to: Optional[Address] = None, //| ) -> None: //| """Starts advertising until `stop_advertising` is called or if connectable, another device //| connects to us. @@ -181,6 +183,7 @@ MP_PROPERTY_GETSET(bleio_adapter_name_obj, //| :param int tx_power: transmitter power while advertising in dBm //| :param Address directed_to: peer to advertise directly to""" //| ... +//| static mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -243,6 +246,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 1, bleio_ //| def stop_advertising(self) -> None: //| """Stop sending advertising packets.""" //| ... +//| static mp_obj_t bleio_adapter_stop_advertising(mp_obj_t self_in) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -262,7 +266,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapt //| interval: float = 0.1, //| window: float = 0.1, //| minimum_rssi: int = -80, -//| active: bool = True +//| active: bool = True, //| ) -> Iterable[ScanEntry]: //| """Starts a BLE scan and returns an iterator of results. Advertisements and scan responses are //| filtered and returned separately. @@ -282,6 +286,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapt //| :returns: an iterable of `_bleio.ScanEntry` objects //| :rtype: iterable""" //| ... +//| static mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_prefixes, ARG_buffer_size, ARG_extended, ARG_timeout, ARG_interval, ARG_window, ARG_minimum_rssi, ARG_active }; static const mp_arg_t allowed_args[] = { @@ -346,6 +351,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_scan_obj, 1, bleio_adapter //| def stop_scan(self) -> None: //| """Stop the current scan.""" //| ... +//| static mp_obj_t bleio_adapter_stop_scan(mp_obj_t self_in) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -381,6 +387,7 @@ MP_PROPERTY_GETTER(bleio_adapter_connected_obj, //| connections: Tuple[Connection] //| """Tuple of active connections including those initiated through //| :py:meth:`_bleio.Adapter.connect`. (read-only)""" +//| static mp_obj_t bleio_adapter_get_connections(mp_obj_t self) { return common_hal_bleio_adapter_get_connections(self); } @@ -395,6 +402,7 @@ MP_PROPERTY_GETTER(bleio_adapter_connections_obj, //| :param Address address: The address of the peripheral to connect to //| :param float/int timeout: Try to connect for timeout seconds.""" //| ... +//| static mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -418,6 +426,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 1, bleio_adapter_co //| """Erase all bonding information stored in flash memory.""" //| ... //| +//| static mp_obj_t bleio_adapter_erase_bonding(mp_obj_t self_in) { bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 5cedd2b466..58f8a8adc1 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -26,6 +26,7 @@ //| :param int address_type: one of the integer values: `PUBLIC`, `RANDOM_STATIC`, //| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`.""" //| ... +//| static mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_address, ARG_address_type }; static const mp_arg_t allowed_args[] = { @@ -86,6 +87,7 @@ MP_PROPERTY_GETTER(bleio_address_address_bytes_obj, //| //| One of the integer values: `PUBLIC`, `RANDOM_STATIC`, `RANDOM_PRIVATE_RESOLVABLE`, //| or `RANDOM_PRIVATE_NON_RESOLVABLE`.""" +//| static mp_obj_t bleio_address_get_type(mp_obj_t self_in) { bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -99,6 +101,7 @@ MP_PROPERTY_GETTER(bleio_address_type_obj, //| def __eq__(self, other: object) -> bool: //| """Two Address objects are equal if their addresses and address types are equal.""" //| ... +//| static mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { switch (op) { // Two Addresses are equal if their address bytes and address_type are equal @@ -124,6 +127,7 @@ static mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_o //| def __hash__(self) -> int: //| """Returns a hash for the Address data.""" //| ... +//| static mp_obj_t bleio_address_unary_op(mp_unary_op_t op, mp_obj_t self_in) { switch (op) { // Two Addresses are equal if their address bytes and address_type are equal @@ -166,6 +170,7 @@ static void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_pr //| RANDOM_PRIVATE_NON_RESOLVABLE: int //| """A randomly generated address that changes on every connection.""" //| +//| static const mp_rom_map_elem_t bleio_address_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_address_bytes), MP_ROM_PTR(&bleio_address_address_bytes_obj) }, { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&bleio_address_type_obj) }, diff --git a/shared-bindings/_bleio/Attribute.c b/shared-bindings/_bleio/Attribute.c index fe890d875e..f91fa22568 100644 --- a/shared-bindings/_bleio/Attribute.c +++ b/shared-bindings/_bleio/Attribute.c @@ -19,6 +19,7 @@ //| def __init__(self) -> None: //| """You cannot create an instance of :py:class:`~_bleio.Attribute`.""" //| ... +//| static const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = { @@ -42,6 +43,7 @@ static const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = { //| //| SIGNED_WITH_MITM: int //| """security_mode: authenticated data signing, without man-in-the-middle protection""" +//| //| { MP_ROM_QSTR(MP_QSTR_NO_ACCESS), MP_ROM_INT(SECURITY_MODE_NO_ACCESS) }, { MP_ROM_QSTR(MP_QSTR_OPEN), MP_ROM_INT(SECURITY_MODE_OPEN) }, diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 24ea0b5409..8d6ac43e48 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -25,6 +25,7 @@ //| Remote Characteristic objects are created by `Connection.discover_remote_services()` //| as part of remote Services.""" //| ... +//| //| @classmethod //| def add_to_service( @@ -38,7 +39,7 @@ //| max_length: int = 20, //| fixed_length: bool = False, //| initial_value: Optional[ReadableBuffer] = None, -//| user_description: Optional[str] = None +//| user_description: Optional[str] = None, //| ) -> Characteristic: //| """Create a new Characteristic object, and add it to this Service. //| @@ -63,6 +64,7 @@ //| //| :return: the new Characteristic.""" //| ... +//| static mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { // class is arg[0], which we can ignore. @@ -143,6 +145,7 @@ static MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_characteristic_add_to_service_obj, //| def deinit(self) -> None: //| """Deinitialises the Characteristic and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t bleio_characteristic_deinit(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_bleio_characteristic_deinit(self); @@ -246,6 +249,7 @@ MP_PROPERTY_GETTER(bleio_characteristic_descriptors_obj, //| service: Service //| """The Service this Characteristic is a part of.""" +//| static mp_obj_t bleio_characteristic_get_service(mp_obj_t self_in) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -264,6 +268,7 @@ MP_PROPERTY_GETTER(bleio_characteristic_service_obj, //| :param float indicate: True if Characteristic should receive indications of remote writes //| """ //| ... +//| static mp_obj_t bleio_characteristic_set_cccd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); @@ -312,6 +317,7 @@ static const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = { //| //| WRITE_NO_RESPONSE: int //| """property: clients may write this characteristic; no response will be sent back""" +//| //| { MP_ROM_QSTR(MP_QSTR_BROADCAST), MP_ROM_INT(CHAR_PROP_BROADCAST) }, { MP_ROM_QSTR(MP_QSTR_INDICATE), MP_ROM_INT(CHAR_PROP_INDICATE) }, diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index 24b8b14680..3cca67c93c 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -37,6 +37,7 @@ static void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self //| :param int buffer_size: Size of ring buffer that stores incoming data coming from client. //| Must be >= 1.""" //| ... +//| static mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_characteristic, ARG_timeout, ARG_buffer_size, }; static const mp_arg_t allowed_args[] = { @@ -95,6 +96,7 @@ static void check_for_deinit(bleio_characteristic_buffer_obj_t *self) { //| :return: the line read //| :rtype: int or None""" //| ... +//| // These three methods are used by the shared stream methods. static mp_uint_t bleio_characteristic_buffer_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) { @@ -140,6 +142,7 @@ static mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t r //| in_waiting: int //| """The number of bytes in the input buffer, available to be read""" +//| static mp_obj_t bleio_characteristic_buffer_obj_get_in_waiting(mp_obj_t self_in) { bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -158,6 +161,7 @@ MP_PROPERTY_GETTER(bleio_characteristic_buffer_in_waiting_obj, //| def reset_input_buffer(self) -> None: //| """Discard any unread characters in the input buffer.""" //| ... +//| static mp_obj_t bleio_characteristic_buffer_obj_reset_input_buffer(mp_obj_t self_in) { bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -170,6 +174,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_reset_input_buffer_ //| """Disable permanently.""" //| ... //| +//| static mp_obj_t bleio_characteristic_buffer_deinit(mp_obj_t self_in) { bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_bleio_characteristic_buffer_deinit(self); diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index ec3f349fcb..4a81d75343 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -56,6 +56,7 @@ void bleio_connection_ensure_connected(bleio_connection_obj_t *self) { //| def disconnect(self) -> None: //| """Disconnects from the remote peripheral. Does nothing if already disconnected.""" //| ... +//| static mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); // common_hal_bleio_connection_disconnect() does nothing if already disconnected. @@ -71,6 +72,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_disconnect_obj, bleio_connecti //| **Limitation**: Currently ``bond``must be ``True``: bonding always occurs. //| """ //| ... +//| static mp_obj_t bleio_connection_pair(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -117,6 +119,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_pair_obj, 1, bleio_connection //| //| :return: A tuple of `_bleio.Service` objects provided by the remote peripheral.""" //| ... +//| static mp_obj_t bleio_connection_discover_remote_services(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -188,6 +191,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_get_connection_interval_obj, b //| But for a regular characteristic read or write, may be sent in multiple packets, //| so this limit does not apply.""" //| +//| static mp_obj_t bleio_connection_get_max_packet_length(mp_obj_t self_in) { bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index f8615fd28a..57cc605029 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -35,7 +35,7 @@ //| write_perm: int = Attribute.OPEN, //| max_length: int = 20, //| fixed_length: bool = False, -//| initial_value: ReadableBuffer = b"" +//| initial_value: ReadableBuffer = b"", //| ) -> Descriptor: //| """Create a new Descriptor object, and add it to this Service. //| @@ -55,6 +55,7 @@ //| //| :return: the new Descriptor.""" //| ... +//| static mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { // class is arg[0], which we can ignore. @@ -147,6 +148,7 @@ MP_PROPERTY_GETTER(bleio_descriptor_characteristic_obj, //| value: bytearray //| """The value of this descriptor.""" //| +//| static mp_obj_t bleio_descriptor_get_value(mp_obj_t self_in) { bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index dc89d9b33d..6348e578a5 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -21,7 +21,7 @@ //| characteristic: Characteristic, //| *, //| buffer_size: int, -//| max_packet_size: Optional[int] = None +//| max_packet_size: Optional[int] = None, //| ) -> None: //| """Accumulates a Characteristic's incoming packets in a FIFO buffer and facilitates packet aware //| outgoing writes. A packet's size is either the characteristic length or the maximum transmission @@ -39,6 +39,7 @@ //| :param int max_packet_size: Maximum size of packets. Overrides value from the characteristic. //| (Remote characteristics may not have the correct length.)""" //| ... +//| static mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_characteristic, ARG_buffer_size, ARG_max_packet_size }; static const mp_arg_t allowed_args[] = { @@ -79,6 +80,7 @@ static void check_for_deinit(bleio_packet_buffer_obj_t *self) { //| :return: number of bytes read and stored into ``buf`` //| :rtype: int""" //| ... +//| static mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_obj) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -104,6 +106,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_ //| :return: number of bytes written. May include header bytes when packet is empty. //| :rtype: int""" //| ... +//| // TODO: Add a kwarg `merge=False` to dictate whether subsequent writes are merged into a pending // one. static mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -149,6 +152,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bleio_packet_buffer_write_obj, 1, bleio_packet //| def deinit(self) -> None: //| """Disable permanently.""" //| ... +//| static mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_bleio_packet_buffer_deinit(self); @@ -175,6 +179,7 @@ MP_PROPERTY_GETTER(bleio_packet_buffer_incoming_packet_length_obj, //| outgoing_packet_length: int //| """Maximum length in bytes of a packet we are writing.""" //| +//| static mp_obj_t bleio_packet_buffer_get_outgoing_packet_length(mp_obj_t self_in) { bleio_packet_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index a2c79b557b..6b1591093a 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -30,6 +30,7 @@ //| than the scan filtering which accepts any advertisements that match any of the prefixes //| where ``match_all`` is False.""" //| ... +//| static mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -97,6 +98,7 @@ MP_PROPERTY_GETTER(bleio_scanentry_connectable_obj, //| scan_response: bool //| """True if the entry was a scan response. (read-only)""" //| +//| static mp_obj_t scanentry_get_scan_response(mp_obj_t self_in) { bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_bool(common_hal_bleio_scanentry_get_scan_response(self)); diff --git a/shared-bindings/_bleio/ScanResults.c b/shared-bindings/_bleio/ScanResults.c index 81680902e4..2b52615f81 100644 --- a/shared-bindings/_bleio/ScanResults.c +++ b/shared-bindings/_bleio/ScanResults.c @@ -40,6 +40,7 @@ static mp_obj_t scanresults_iternext(mp_obj_t self_in) { //| """ //| ... //| +//| MP_DEFINE_CONST_OBJ_TYPE( bleio_scanresults_type, diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index 6f6e686c70..cea9a68e69 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -27,6 +27,7 @@ //| //| :return: the new Service""" //| ... +//| static mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_uuid, ARG_secondary }; static const mp_arg_t allowed_args[] = { @@ -51,6 +52,7 @@ static mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, //| def deinit(self) -> None: //| """Disable and deinitialise the Service.""" //| ... +//| static mp_obj_t bleio_service_deinit(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_bleio_service_deinit(self); @@ -99,6 +101,7 @@ MP_PROPERTY_GETTER(bleio_service_secondary_obj, //| //| Will be ``None`` if the 128-bit UUID for this service is not known.""" //| +//| static mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) { bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index 5dac1b3ecf..2d28d5a9b6 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -30,6 +30,7 @@ //| :param value: The uuid value to encapsulate //| :type value: int, ~circuitpython_typing.ReadableBuffer or str""" //| ... +//| static mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); @@ -138,6 +139,7 @@ MP_PROPERTY_GETTER(bleio_uuid_uuid128_obj, //| 16-bit Bluetooth SIG assigned UUID. (read-only) 32-bit UUIDs are not currently supported. //| //| :type: int""" +//| static mp_obj_t bleio_uuid_get_size(mp_obj_t self_in) { bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(self_in); return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_uuid_get_size(self)); @@ -152,6 +154,7 @@ MP_PROPERTY_GETTER(bleio_uuid_size_obj, //| def pack_into(self, buffer: WriteableBuffer, offset: int = 0) -> None: //| """Packs the UUID into the given buffer at the given offset.""" //| ... +//| static mp_obj_t bleio_uuid_pack_into(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -214,6 +217,7 @@ static mp_obj_t bleio_uuid_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| """Two UUID objects are equal if their values match and they are both 128-bit or both 16-bit.""" //| ... //| +//| static mp_obj_t bleio_uuid_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { switch (op) { // Two UUID's are equal if their uuid16 values match or their uuid128 values match. diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c index 049deb05cf..3bf8c1a2c9 100644 --- a/shared-bindings/_bleio/__init__.c +++ b/shared-bindings/_bleio/__init__.c @@ -41,17 +41,20 @@ //| Pico W boards do *not* support BLE using the on-board CYW43 co-processor, //| but do support using an external AirLift. //| """ +//| //| adapter: Adapter //| """BLE Adapter used to manage device discovery and connections. //| This object is the sole instance of `_bleio.Adapter`.""" //| +//| //| class BluetoothError(Exception): //| """Catchall exception for Bluetooth related errors.""" //| //| ... //| +//| MP_DEFINE_BLEIO_EXCEPTION(BluetoothError, Exception) NORETURN void mp_raise_bleio_BluetoothError(mp_rom_error_text_t fmt, ...) { va_list argptr; @@ -67,6 +70,7 @@ NORETURN void mp_raise_bleio_BluetoothError(mp_rom_error_text_t fmt, ...) { //| //| ... //| +//| MP_DEFINE_BLEIO_EXCEPTION(RoleError, bleio_BluetoothError) NORETURN void mp_raise_bleio_RoleError(mp_rom_error_text_t msg) { mp_raise_msg(&mp_type_bleio_RoleError, msg); @@ -77,6 +81,7 @@ NORETURN void mp_raise_bleio_RoleError(mp_rom_error_text_t msg) { //| //| ... //| +//| MP_DEFINE_BLEIO_EXCEPTION(SecurityError, bleio_BluetoothError) NORETURN void mp_raise_bleio_SecurityError(mp_rom_error_text_t fmt, ...) { va_list argptr; @@ -108,6 +113,7 @@ static mp_obj_dict_t bleio_module_globals; //| Raises `NotImplementedError` when the adapter is a singleton and cannot be set.""" //| ... //| +//| mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj) { #if CIRCUITPY_BLEIO_HCI (void)mp_arg_validate_type_or_none(adapter_obj, &bleio_adapter_type, MP_QSTR_adapter); diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 25919892e8..000e3526ed 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -25,9 +25,11 @@ //| contains methods for constructing EVE command //| buffers and appending basic graphics commands.""" //| +//| //| class _EVE: //| def __init__(self) -> None: //| """Create an _EVE object""" +//| typedef struct _mp_obj__EVE_t { mp_obj_base_t base; common_hal__eve_t _eve; @@ -38,7 +40,10 @@ static const mp_obj_type_t _EVE_type; #define EVEHAL(s) \ (&((mp_obj__EVE_t *)mp_obj_cast_to_native_base((s), &_EVE_type))->_eve) -//| def register(self, o: object) -> None: ... +//| def register(self, o: object) -> None: +//| """Register an object's ``write()`` function""" +//| ... +//| 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); @@ -46,7 +51,11 @@ static mp_obj_t _register(mp_obj_t self, mp_obj_t o) { } static MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register); -//| def setmodel(self, m: int) -> None: ... +//| +//| def setmodel(self, m: int) -> None: +//| """Set the model number of the EVE chip""" +//| ... +//| static mp_obj_t _setmodel(mp_obj_t self, mp_obj_t m) { common_hal__eve_t *eve = EVEHAL(self); eve->model = mp_obj_get_int_truncated(m); @@ -54,11 +63,13 @@ static mp_obj_t _setmodel(mp_obj_t self, mp_obj_t m) { } static MP_DEFINE_CONST_FUN_OBJ_2(setmodel_obj, _setmodel); +//| //| def flush(self) -> None: //| """Send any queued drawing commands directly to the hardware. //| //| :param int width: The width of the grid in tiles, or 1 for sprites.""" //| ... +//| static mp_obj_t _flush(mp_obj_t self) { common_hal__eve_flush(EVEHAL(self)); return mp_const_none; @@ -70,6 +81,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); //| //| :param ~circuitpython_typing.ReadableBuffer b: The bytes to add""" //| ... +//| static mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { mp_buffer_info_t buffer_info; mp_get_buffer_raise(b, &buffer_info, MP_BUFFER_READ); @@ -89,6 +101,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t func = mp_obj_get_int_truncated(a0); @@ -106,6 +119,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); //| Valid primitives are ``BITMAPS``, ``POINTS``, ``LINES``, ``LINE_STRIP``, ``EDGE_STRIP_R``, ``EDGE_STRIP_L``, ``EDGE_STRIP_A``, ``EDGE_STRIP_B`` and ``RECTS``. //| """ //| ... +//| static mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { uint32_t prim = mp_obj_get_int_truncated(a0); @@ -119,6 +133,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); //| //| :param int format: bitmap pixel format.""" //| ... +//| static mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { uint32_t fmt = mp_obj_get_int_truncated(a0); @@ -135,6 +150,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) { uint32_t handle = mp_obj_get_int_truncated(a0); @@ -149,6 +165,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle); //| :param int linestride: high part of bitmap line stride, in bytes. Range 0-7 //| :param int height: high part of bitmap height, in lines. Range 0-3""" //| ... +//| static mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t linestride = mp_obj_get_int_truncated(a0); @@ -165,6 +182,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth); //| :param int linestride: bitmap line stride, in bytes. Range 0-1023 //| :param int height: bitmap height, in lines. Range 0-511""" //| ... +//| static mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) { uint32_t format = mp_obj_get_int_truncated(args[1]); @@ -181,6 +199,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout //| :param int width: high part of drawn bitmap width, in pixels. Range 0-3 //| :param int height: high part of drawn bitmap height, in pixels. Range 0-3""" //| ... +//| static mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t width = mp_obj_get_int_truncated(a0); @@ -199,6 +218,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); //| :param int width: drawn bitmap width, in pixels. Range 0-511 //| :param int height: drawn bitmap height, in pixels. Range 0-511""" //| ... +//| static mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { uint32_t filter = mp_obj_get_int_truncated(args[1]); @@ -217,6 +237,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); //| :param int addr: Bitmap start address, pixel-aligned, low part. //| """ //| ... +//| static mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { uint32_t addr = mp_obj_get_int_truncated(a0); @@ -231,6 +252,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); //| :param int addr: Bitmap start address, pixel-aligned, high part. //| """ //| ... +//| static mp_obj_t _bitmapsourceh(mp_obj_t self, mp_obj_t a0) { uint32_t addr = mp_obj_get_int_truncated(a0); @@ -247,6 +269,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmapsourceh_obj, _bitmapsourceh); //| :param int b: blue component source channel. Range 0-7 //| :param int a: alpha component source channel. Range 0-7""" //| ... +//| static mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { uint32_t r = mp_obj_get_int_truncated(args[1]); @@ -268,6 +291,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizz //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static void _transform1(uint32_t *p, uint32_t *v, size_t n_args, const mp_obj_t *args) { common_hal__eve_t *eve = EVEHAL(args[0]); @@ -313,6 +337,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaptransforma_obj, 2, 3, _bitmaptr //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _bitmaptransformb(size_t n_args, const mp_obj_t *args) { uint32_t p, v; @@ -332,6 +357,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaptransformb_obj, 2, 3, _bitmaptr //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0) { common_hal__eve_t *eve = EVEHAL(self); @@ -357,6 +383,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformc_obj, _bitmaptransformc); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _bitmaptransformd(size_t n_args, const mp_obj_t *args) { uint32_t p, v; @@ -376,6 +403,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaptransformd_obj, 2, 3, _bitmaptr //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _bitmaptransforme(size_t n_args, const mp_obj_t *args) { uint32_t p, v; @@ -395,6 +423,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaptransforme_obj, 2, 3, _bitmaptr //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0) { common_hal__eve_t *eve = EVEHAL(self); @@ -419,6 +448,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformf_obj, _bitmaptransformf); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t src = mp_obj_get_int_truncated(a0); @@ -433,6 +463,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); //| //| :param int dest: display list address. Range 0-65535""" //| ... +//| static mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { uint32_t dest = mp_obj_get_int_truncated(a0); @@ -449,6 +480,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { uint32_t cell = mp_obj_get_int_truncated(a0); @@ -465,6 +497,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { uint32_t alpha = mp_obj_get_int_truncated(a0); @@ -483,6 +516,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { uint32_t red = mp_obj_get_int_truncated(args[1]); @@ -500,6 +534,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorr //| :param int s: clear stencil buffer. Range 0-1 //| :param int t: clear tag buffer. Range 0-1""" //| ... +//| static mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; @@ -518,6 +553,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { uint32_t s = mp_obj_get_int_truncated(a0); @@ -533,6 +569,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); //| //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ +//| static mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { uint32_t s = mp_obj_get_int_truncated(a0); @@ -549,6 +586,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { uint32_t alpha = mp_obj_get_int_truncated(a0); @@ -568,6 +606,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { uint32_t r = mp_obj_get_int_truncated(args[1]); @@ -589,6 +628,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { uint32_t red = mp_obj_get_int_truncated(args[1]); @@ -602,6 +642,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb); //| def Display(self) -> None: //| """End the display list""" //| ... +//| static mp_obj_t _display(mp_obj_t self) { @@ -616,6 +657,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display); //| :meth:`Vertex2ii` and :meth:`Vertex2f` calls are ignored until the next :meth:`Begin`. //| """ //| ... +//| static mp_obj_t _end(mp_obj_t self) { @@ -629,6 +671,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); //| //| :param int dest: display list address. Range 0-65535""" //| ... +//| static mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { uint32_t dest = mp_obj_get_int_truncated(a0); @@ -642,6 +685,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); //| //| :param int m: macro register to read. Range 0-1""" //| ... +//| static mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { uint32_t m = mp_obj_get_int_truncated(a0); @@ -653,6 +697,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro); //| def Nop(self) -> None: //| """No operation""" //| ... +//| static mp_obj_t _nop(mp_obj_t self) { @@ -669,6 +714,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { uint32_t addr = mp_obj_get_int_truncated(a0); @@ -685,6 +731,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _palettesourceh(mp_obj_t self, mp_obj_t a0) { uint32_t addr = mp_obj_get_int_truncated(a0); @@ -696,6 +743,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(palettesourceh_obj, _palettesourceh); //| def RestoreContext(self) -> None: //| """Restore the current graphics context from the context stack""" //| ... +//| static mp_obj_t _restorecontext(mp_obj_t self) { @@ -707,6 +755,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext); //| def Return(self) -> None: //| """Return from a previous call command""" //| ... +//| static mp_obj_t _return(mp_obj_t self) { @@ -718,6 +767,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return); //| def SaveContext(self) -> None: //| """Push the current graphics context on the context stack""" //| ... +//| static mp_obj_t _savecontext(mp_obj_t self) { @@ -735,6 +785,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t width = mp_obj_get_int_truncated(a0); @@ -753,6 +804,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t x = mp_obj_get_int_truncated(a0); @@ -772,6 +824,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { uint32_t func = mp_obj_get_int_truncated(args[1]); @@ -790,6 +843,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { uint32_t mask = mp_obj_get_int_truncated(a0); @@ -807,6 +861,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); //| These values are part of the graphics context and are saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { uint32_t sfail = mp_obj_get_int_truncated(a0); @@ -824,6 +879,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { uint32_t mask = mp_obj_get_int_truncated(a0); @@ -840,6 +896,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { uint32_t s = mp_obj_get_int_truncated(a0); @@ -863,6 +920,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); //| //| This method is an alternative to :meth:`Vertex2f`.""" //| ... +//| static mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { uint32_t x = mp_obj_get_int_truncated(args[1]); @@ -950,6 +1008,7 @@ static bool is_vector(mp_obj_t a) { //| :param float x: pixel x-coordinate //| :param float y: pixel y-coordinate""" //| ... +//| static mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { #if CIRCUITPY_ULAB if (is_vector(a0) && is_vector(a1)) { @@ -978,6 +1037,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { mp_float_t width = mp_obj_get_float(a0); @@ -994,6 +1054,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { mp_float_t size = mp_obj_get_float(a0); @@ -1010,6 +1071,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { mp_float_t x = mp_obj_get_float(a0); @@ -1026,6 +1088,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| static mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { @@ -1043,6 +1106,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); //| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`. //| """ //| ... +//| // } @@ -1058,6 +1122,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); //| This method is used by the ``eve`` module to efficiently add //| commands to the FIFO.""" //| ... +//| static mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) { uint32_t code = 0xffffff00 | mp_obj_get_int_truncated(n); @@ -1080,6 +1145,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0); //| commands to the FIFO.""" //| ... //| +//| static mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t self = args[0]; mp_obj_t num = args[1]; diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index af10b47ca6..42e7f4d372 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -41,6 +41,7 @@ //| buttons are connected to rows of the matrix).""" //| ... //| +//| static mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_buffer, ARG_rows, ARG_cols, ARG_buttons }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/_pixelmap/PixelMap.c b/shared-bindings/_pixelmap/PixelMap.c index 6bddeaac9c..53f05c1c3b 100644 --- a/shared-bindings/_pixelmap/PixelMap.c +++ b/shared-bindings/_pixelmap/PixelMap.c @@ -15,9 +15,11 @@ //| from adafruit_pixelbuf import PixelBuf, PixelReturnType, PixelSequence, PixelType //| +//| //| class PixelMap: //| def __init__(self, pixelbuf: PixelBuf, indices: Tuple[Union[int, Tuple[int]]]) -> None: //| """Construct a PixelMap object that uses the given indices of the underlying pixelbuf""" +//| static mp_obj_t pixelmap_pixelmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pixelbuf, ARG_indices }; @@ -116,6 +118,7 @@ MP_PROPERTY_GETTER(pixelmap_pixelmap_byteorder_obj, //| //| def fill(self, color: PixelType) -> None: //| """Fill all the pixels in the map with the given color""" +//| static mp_obj_t pixelmap_pixelmap_fill(const mp_obj_t self_in, const mp_obj_t color) { pixelmap_pixelmap_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -127,6 +130,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(pixelmap_pixelmap_fill_obj, pixelmap_pixelmap_fill); //| //| def indices(self, index: int) -> Tuple[int]: //| """Return the PixelBuf indices for a PixelMap index""" +//| static mp_obj_t pixelmap_pixelmap_indices(const mp_obj_t self_in, const mp_obj_t index) { pixelmap_pixelmap_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -156,6 +160,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(pixelmap_pixelmap_indices_obj, pixelmap_pixelmap_indic //| For RGBW byteorders, if given only RGB values either as an int or as a tuple, the white value //| is used instead when the red, green, and blue values are the same.""" //| ... +//| static mp_obj_t pixelmap_pixelmap_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { pixelmap_pixelmap_obj_t *self = MP_OBJ_TO_PTR(self_in); if (value == MP_OBJ_NULL) { @@ -200,6 +205,7 @@ static mp_obj_t pixelmap_pixelmap_subscr(mp_obj_t self_in, mp_obj_t index_in, mp //| def __len__(self) -> int: //| """Length of the map""" +//| static mp_obj_t pixelmap_pixelmap_unary_op(mp_unary_op_t op, mp_obj_t self_in) { pixelmap_pixelmap_obj_t *self = MP_OBJ_TO_PTR(self_in); switch (op) { @@ -217,6 +223,7 @@ static mp_obj_t pixelmap_pixelmap_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| when `auto_write` is True.""" //| ... //| +//| static mp_obj_t pixelmap_pixelmap_show(mp_obj_t self_in) { pixelmap_pixelmap_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index 3958b4c7f1..de4861a70e 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -33,6 +33,7 @@ //| This class is intended for internal use in the ``stage`` library and //| it shouldn't be used on its own.""" //| ... +//| static mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 4, 5, false); @@ -75,6 +76,7 @@ static mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, //| def move(self, x: int, y: int) -> None: //| """Set the offset of the layer to the specified values.""" //| ... +//| static mp_obj_t layer_move(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) { layer_obj_t *self = MP_OBJ_TO_PTR(self_in); self->x = mp_obj_get_int(x_in); @@ -88,6 +90,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(layer_move_obj, layer_move); //| graphic.""" //| ... //| +//| static mp_obj_t layer_frame(mp_obj_t self_in, mp_obj_t frame_in, mp_obj_t rotation_in) { layer_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index 53abf03b77..ecd4f644a7 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -33,6 +33,7 @@ //| This class is intended for internal use in the ``stage`` library and //| it shouldn't be used on its own.""" //| ... +//| static mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 5, 5, false); @@ -70,6 +71,7 @@ static mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, //| """Set the offset of the text to the specified values.""" //| ... //| +//| static mp_obj_t text_move(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) { text_obj_t *self = MP_OBJ_TO_PTR(self_in); self->x = mp_obj_get_int(x_in); diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 06e103e244..7542941a4f 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -19,6 +19,7 @@ //| The `_stage` module contains native code to speed-up the ```stage`` Library //| `_.""" //| +//| //| def render( //| x0: int, //| y0: int, @@ -50,6 +51,7 @@ //| This function is intended for internal use in the ``stage`` library //| and all the necessary checks are performed there.""" //| +//| static mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { uint16_t x0 = mp_obj_get_int(args[0]); uint16_t y0 = mp_obj_get_int(args[1]); diff --git a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c index 737ff419dd..32d418923f 100644 --- a/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c @@ -43,7 +43,9 @@ //| with device: //| device.write(bytes_read) //| """ +//| //| ... +//| static mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { adafruit_bus_device_i2cdevice_obj_t *self = mp_obj_malloc(adafruit_bus_device_i2cdevice_obj_t, &adafruit_bus_device_i2cdevice_type); @@ -69,6 +71,7 @@ static mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type //| def __enter__(self) -> I2CDevice: //| """Context manager entry to lock bus.""" //| ... +//| static mp_obj_t adafruit_bus_device_i2cdevice_obj___enter__(mp_obj_t self_in) { adafruit_bus_device_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_adafruit_bus_device_i2cdevice_lock(self); @@ -79,6 +82,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(adafruit_bus_device_i2cdevice___enter___obj, ad //| def __exit__(self) -> None: //| """Automatically unlocks the bus on exit.""" //| ... +//| static mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const mp_obj_t *args) { common_hal_adafruit_bus_device_i2cdevice_unlock(MP_OBJ_TO_PTR(args[0])); return mp_const_none; @@ -86,6 +90,7 @@ static mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit___obj, 4, 4, adafruit_bus_device_i2cdevice_obj___exit__); //| import sys +//| //| def readinto( //| self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize //| ) -> None: @@ -100,6 +105,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit_ //| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` //| """ //| ... +//| static mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -134,6 +140,7 @@ static mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o static MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 1, adafruit_bus_device_i2cdevice_readinto); //| import sys +//| //| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the bytes from ``buffer`` to the device, then transmit a stop bit. //| @@ -146,6 +153,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 1, //| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` //| """ //| ... +//| static mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -180,6 +188,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 1, adafruit_ //| import sys +//| //| def write_then_readinto( //| self, //| out_buffer: ReadableBuffer, @@ -188,7 +197,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 1, adafruit_ //| out_start: int = 0, //| out_end: int = sys.maxsize, //| in_start: int = 0, -//| in_end: int = sys.maxsize +//| in_end: int = sys.maxsize, //| ) -> None: //| """Write the bytes from ``out_buffer`` to the device, then immediately //| reads into ``in_buffer`` from the device. @@ -210,6 +219,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 1, adafruit_ //| """ //| ... //| +//| static mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c index 6336b0cd12..f62aedc47e 100644 --- a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c @@ -27,7 +27,7 @@ //| baudrate: int = 100000, //| polarity: int = 0, //| phase: int = 0, -//| extra_clocks: int = 0 +//| extra_clocks: int = 0, //| ) -> None: //| """ //| Represents a single SPI device and manages locking the bus and the device address. @@ -55,7 +55,9 @@ //| # A second transaction //| with device as spi: //| spi.write(bytes_read)""" +//| //| ... +//| static mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { adafruit_bus_device_spidevice_obj_t *self = mp_obj_malloc(adafruit_bus_device_spidevice_obj_t, &adafruit_bus_device_spidevice_type); @@ -97,6 +99,7 @@ static mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type //| def __enter__(self) -> busio.SPI: //| """Starts a SPI transaction by configuring the SPI and asserting chip select.""" //| ... +//| static mp_obj_t adafruit_bus_device_spidevice_obj___enter__(mp_obj_t self_in) { adafruit_bus_device_spidevice_obj_t *self = MP_OBJ_TO_PTR(self_in); return common_hal_adafruit_bus_device_spidevice_enter(self); @@ -109,6 +112,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(adafruit_bus_device_spidevice___enter___obj, ad //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... //| +//| static mp_obj_t adafruit_bus_device_spidevice_obj___exit__(size_t n_args, const mp_obj_t *args) { common_hal_adafruit_bus_device_spidevice_exit(MP_OBJ_TO_PTR(args[0])); return mp_const_none; diff --git a/shared-bindings/adafruit_pixelbuf/PixelBuf.c b/shared-bindings/adafruit_pixelbuf/PixelBuf.c index 95b353611f..1499ae9562 100644 --- a/shared-bindings/adafruit_pixelbuf/PixelBuf.c +++ b/shared-bindings/adafruit_pixelbuf/PixelBuf.c @@ -41,7 +41,7 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t //| brightness: float = 0, //| auto_write: bool = False, //| header: ReadableBuffer = b"", -//| trailer: ReadableBuffer = b"" +//| trailer: ReadableBuffer = b"", //| ) -> None: //| """Create a PixelBuf object of the specified size, byteorder, and bits per pixel. //| @@ -61,6 +61,7 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t //| :param ~circuitpython_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, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_size, ARG_byteorder, ARG_brightness, ARG_auto_write, ARG_header, ARG_trailer }; static const mp_arg_t allowed_args[] = { @@ -201,6 +202,7 @@ MP_PROPERTY_GETSET(pixelbuf_pixelbuf_auto_write_obj, //| byteorder: str //| """byteorder string for the buffer (read-only)""" +//| static mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) { return common_hal_adafruit_pixelbuf_pixelbuf_get_byteorder_string(self_in); } @@ -224,6 +226,7 @@ static mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| """Transmits the color data to the pixels so that they are shown. This is done automatically //| when `auto_write` is True.""" //| ... +//| static mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) { common_hal_adafruit_pixelbuf_pixelbuf_show(self_in); @@ -234,6 +237,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_s //| def fill(self, color: PixelType) -> None: //| """Fills the given pixelbuf with the given color.""" //| ... +//| static mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) { common_hal_adafruit_pixelbuf_pixelbuf_fill(self_in, value); @@ -267,6 +271,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_f //| is used instead when the red, green, and blue values are the same.""" //| ... //| +//| static mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index 33f2a33563..c81747d21b 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -19,6 +19,7 @@ //| MODE_CBC: int //| MODE_CTR: int //| +//| //| class AES: //| """Encrypt and decrypt AES streams""" //| @@ -50,6 +51,7 @@ //| cipher.encrypt_into(inp, outp) //| hexlify(outp)""" //| ... +//| static mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { @@ -114,6 +116,7 @@ static mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, //| :param ~circuitpython_typing.ReadableBuffer IV: Initialization vector to use //| for CBC or CTR mode""" //| ... +//| static mp_obj_t aesio_aes_rekey(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { aesio_aes_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); enum { ARG_key, ARG_IV }; @@ -177,6 +180,7 @@ static void validate_length(aesio_aes_obj_t *self, size_t src_length, //| buffers must be a multiple of 16 bytes, and must be equal length. For //| CTR mode, there are no restrictions.""" //| ... +//| static mp_obj_t aesio_aes_encrypt_into(mp_obj_t self_in, mp_obj_t src, mp_obj_t dest) { aesio_aes_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -200,6 +204,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(aesio_aes_encrypt_into_obj, aesio_aes_encrypt_i //| CTR mode, there are no restrictions.""" //| ... //| +//| static mp_obj_t aesio_aes_decrypt_into(mp_obj_t self_in, mp_obj_t src, mp_obj_t dest) { aesio_aes_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/alarm/SleepMemory.c b/shared-bindings/alarm/SleepMemory.c index cf1b211c68..d783983008 100644 --- a/shared-bindings/alarm/SleepMemory.c +++ b/shared-bindings/alarm/SleepMemory.c @@ -43,6 +43,7 @@ //| def __len__(self) -> int: //| """Return the length. This is used by (`len`)""" //| ... +//| static mp_obj_t alarm_sleep_memory_unary_op(mp_unary_op_t op, mp_obj_t self_in) { alarm_sleep_memory_obj_t *self = MP_OBJ_TO_PTR(self_in); uint16_t len = common_hal_alarm_sleep_memory_get_length(self); @@ -75,6 +76,7 @@ static MP_DEFINE_CONST_DICT(alarm_sleep_memory_locals_dict, alarm_sleep_memory_l //| """Set the value at the given index.""" //| ... //| +//| static mp_obj_t alarm_sleep_memory_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index e0ed0b9a39..e9f2db324d 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -44,6 +44,7 @@ //| For more information about working with alarms and light/deep sleep in CircuitPython, //| see `this Learn guide `_. //| """ +//| //| sleep_memory: SleepMemory //| """Memory that persists during deep sleep. @@ -54,6 +55,7 @@ //| If no alarm occurred since the last hard reset or soft restart, value is ``None``. //| """ //| +//| // wake_alarm is implemented as a dictionary entry, so there's no code here. @@ -90,6 +92,7 @@ static void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { //| """ //| ... //| +//| static mp_obj_t alarm_light_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { if (n_args == 0) { return mp_const_none; @@ -172,6 +175,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OB //| """ //| ... //| +//| static mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_preserve_dios }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 9c786766f6..8d93ca8d0d 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -40,6 +40,7 @@ //| pulls it high. //| """ //| ... +//| static mp_obj_t alarm_pin_pinalarm_make_new(const mp_obj_type_t *type, mp_uint_t n_args, size_t n_kw, const mp_obj_t *all_args) { alarm_pin_pinalarm_obj_t *self = mp_obj_malloc(alarm_pin_pinalarm_obj_t, &alarm_pin_pinalarm_type); enum { ARG_pin, ARG_value, ARG_edge, ARG_pull }; @@ -81,6 +82,7 @@ MP_PROPERTY_GETTER(alarm_pin_pinalarm_pin_obj, //| value: bool //| """The value on which to trigger.""" //| +//| static mp_obj_t alarm_pin_pinalarm_obj_get_value(mp_obj_t self_in) { alarm_pin_pinalarm_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_bool(common_hal_alarm_pin_pinalarm_get_value(self)); diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 012ca602a1..a40e8dd08e 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -37,6 +37,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| due to this time alarm. //| """ //| ... +//| static mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { alarm_time_timealarm_obj_t *self = mp_obj_malloc(alarm_time_timealarm_obj_t, &alarm_time_timealarm_type); @@ -96,6 +97,7 @@ static mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, //| by this property only as a `time.monotonic()` time. //| """ //| +//| static mp_obj_t alarm_time_timealarm_obj_get_monotonic_time(mp_obj_t self_in) { alarm_time_timealarm_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_float(common_hal_alarm_time_timealarm_get_monotonic_time(self)); diff --git a/shared-bindings/alarm/touch/TouchAlarm.c b/shared-bindings/alarm/touch/TouchAlarm.c index c4fd595efe..f25e826cff 100644 --- a/shared-bindings/alarm/touch/TouchAlarm.c +++ b/shared-bindings/alarm/touch/TouchAlarm.c @@ -23,6 +23,7 @@ //| **Limitations:** Not available on SAMD, Nordic, or RP2040. //| """ //| ... +//| static mp_obj_t alarm_touch_touchalarm_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { alarm_touch_touchalarm_obj_t *self = mp_obj_malloc(alarm_touch_touchalarm_obj_t, &alarm_touch_touchalarm_type); @@ -45,6 +46,7 @@ static mp_obj_t alarm_touch_touchalarm_make_new(const mp_obj_type_t *type, //| pin: microcontroller.Pin //| """The trigger pin.""" //| +//| static mp_obj_t alarm_touch_touchalarm_obj_get_pin(mp_obj_t self_in) { alarm_touch_touchalarm_obj_t *self = MP_OBJ_TO_PTR(self_in); return MP_OBJ_FROM_PTR(self->pin); diff --git a/shared-bindings/analogbufio/BufferedIn.c b/shared-bindings/analogbufio/BufferedIn.c index e5a5d3600a..971c744c32 100644 --- a/shared-bindings/analogbufio/BufferedIn.c +++ b/shared-bindings/analogbufio/BufferedIn.c @@ -42,6 +42,7 @@ //| :param ~microcontroller.Pin pin: the pin to read from //| :param ~int sample_rate: rate: sampling frequency, in samples per second""" //| ... +//| static mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pin, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -66,6 +67,7 @@ static mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_ //| def deinit(self) -> None: //| """Shut down the `BufferedIn` and release the pin for other use.""" //| ... +//| static mp_obj_t analogbufio_bufferedin_deinit(mp_obj_t self_in) { analogbufio_bufferedin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_analogbufio_bufferedin_deinit(self); @@ -81,12 +83,14 @@ static void check_for_deinit(analogbufio_bufferedin_obj_t *self) { //| def __enter__(self) -> BufferedIn: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t analogbufio_bufferedin___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogbufio_bufferedin_deinit(args[0]); @@ -110,6 +114,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogbufio_bufferedin___exit___obj, //| """ //| ... //| +//| static mp_obj_t analogbufio_bufferedin_obj_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_loop }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index f56ce600c2..b60c58c492 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -46,6 +46,7 @@ MP_WEAK const mcu_pin_obj_t *common_hal_analogio_analogin_validate_pin(mp_obj_t //| when you read a value. You can retry the read. //| """ //| ... +//| static mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, mp_uint_t n_args, size_t n_kw, const mp_obj_t *args) { // check number of arguments @@ -62,6 +63,7 @@ static mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, //| def deinit(self) -> None: //| """Turn off the AnalogIn and release the pin for other use.""" //| ... +//| static mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) { analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_analogio_analogin_deinit(self); @@ -77,12 +79,14 @@ static void check_for_deinit(analogio_analogin_obj_t *self) { //| def __enter__(self) -> AnalogIn: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogio_analogin_deinit(args[0]); @@ -110,6 +114,7 @@ MP_PROPERTY_GETTER(analogio_analogin_value_obj, //| ``float`` in Volts. Note the ADC value may not scale to the actual voltage linearly //| at ends of the analog range.""" //| +//| static mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) { analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index ab0b018a23..dfb6e42bfe 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -36,6 +36,7 @@ //| //| """ //| ... +//| static mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, size_t n_kw, const mp_obj_t *args) { // check arguments mp_arg_check_num(n_args, n_kw, 1, 1, false); @@ -51,6 +52,7 @@ static mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t //| def deinit(self) -> None: //| """Turn off the AnalogOut and release the pin for other use.""" //| ... +//| static mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) { analogio_analogout_obj_t *self = self_in; @@ -63,12 +65,14 @@ static MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogo //| def __enter__(self) -> AnalogOut: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_analogio_analogout_deinit(args[0]); @@ -82,6 +86,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4 //| Even if the underlying digital to analog converter (DAC) is lower //| resolution, the value is 16-bit.""" //| +//| static mp_obj_t analogio_analogout_obj_set_value(mp_obj_t self_in, mp_obj_t value) { analogio_analogout_obj_t *self = MP_OBJ_TO_PTR(self_in); if (common_hal_analogio_analogout_deinited(self)) { diff --git a/shared-bindings/atexit/__init__.c b/shared-bindings/atexit/__init__.c index b18e26f247..11d142bbf3 100644 --- a/shared-bindings/atexit/__init__.c +++ b/shared-bindings/atexit/__init__.c @@ -16,8 +16,10 @@ //| //| |see_cpython_module| :mod:`cpython:atexit`. //| """ +//| //| ... //| +//| //| def register( //| func: Callable[..., Any], *args: Optional[Any], **kwargs: Optional[Any] @@ -38,6 +40,7 @@ //| """ //| ... //| +//| static mp_obj_t atexit_register(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { shared_module_atexit_register(pos_args[0], (n_args - 1), ((n_args > 1) ? &pos_args[1] : NULL), kw_args); return pos_args[0]; @@ -53,6 +56,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(atexit_register_obj, 1, atexit_register); //| """ //| ... //| +//| static mp_obj_t atexit_unregister(const mp_obj_t self_in) { shared_module_atexit_unregister(&self_in); return mp_const_none; diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 7c24e8a9ef..7b7d0b172c 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -24,7 +24,7 @@ //| data: microcontroller.Pin, //| *, //| main_clock: Optional[microcontroller.Pin] = None, -//| left_justified: bool = False +//| left_justified: bool = False, //| ) -> None: //| """Create a I2SOut object associated with the given pins. //| @@ -76,6 +76,7 @@ //| pass //| print("stopped")""" //| ... +//| static mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_I2SOUT mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_I2SOut); @@ -109,6 +110,7 @@ static mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a //| def deinit(self) -> None: //| """Deinitialises the I2SOut and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t audiobusio_i2sout_deinit(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_i2sout_deinit(self); @@ -125,12 +127,14 @@ static void check_for_deinit(audiobusio_i2sout_obj_t *self) { //| def __enter__(self) -> I2SOut: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_i2sout_deinit(args[0]); @@ -147,6 +151,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, //| //| The sample itself should consist of 8 bit or 16 bit samples.""" //| ... +//| static mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -168,6 +173,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audiobusio_i2sout_play_obj, 1, audiobusio_i2sout_obj_ //| def stop(self) -> None: //| """Stops playback.""" //| ... +//| static mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -178,6 +184,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_stop_obj, audiobusio_i2sout_obj_stop //| playing: bool //| """True when the audio sample is being output. (read-only)""" +//| static mp_obj_t audiobusio_i2sout_obj_get_playing(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -191,6 +198,7 @@ MP_PROPERTY_GETTER(audiobusio_i2sout_playing_obj, //| def pause(self) -> None: //| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" //| ... +//| static mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -206,6 +214,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_pause_obj, audiobusio_i2sout_obj_pau //| def resume(self) -> None: //| """Resumes sample playback after :py:func:`pause`.""" //| ... +//| static mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -221,6 +230,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_resume_obj, audiobusio_i2sout_obj_re //| paused: bool //| """True when playback is paused. (read-only)""" //| +//| static mp_obj_t audiobusio_i2sout_obj_get_paused(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 1b275d3650..b681263882 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -27,7 +27,7 @@ //| bit_depth: int = 8, //| mono: bool = True, //| oversample: int = 64, -//| startup_delay: float = 0.11 +//| startup_delay: float = 0.11, //| ) -> None: //| """Create a PDMIn object associated with the given pins. This allows you to //| record audio signals from the given pins. Individual ports may put further @@ -70,7 +70,9 @@ //| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: //| mic.record(b, len(b)) //| """ +//| //| ... +//| static mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_PDMIN mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_PDMIn); @@ -127,6 +129,7 @@ static mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Deinitialises the PDMIn and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t audiobusio_pdmin_deinit(mp_obj_t self_in) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_pdmin_deinit(self); @@ -142,11 +145,13 @@ static void check_for_deinit(audiobusio_pdmin_obj_t *self) { //| def __enter__(self) -> PDMIn: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context.""" //| ... +//| static mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_pdmin_deinit(args[0]); @@ -166,6 +171,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, //| :return: The number of samples recorded. If this is less than ``destination_length``, //| some samples were missed due to processing time.""" //| ... +//| static mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destination, mp_obj_t destination_length) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_obj); check_for_deinit(self); @@ -198,6 +204,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(audiobusio_pdmin_record_obj, audiobusio_pdmin_obj_reco //| """The actual sample_rate of the recording. This may not match the constructed //| sample rate due to internal clock limitations.""" //| +//| static mp_obj_t audiobusio_pdmin_obj_get_sample_rate(mp_obj_t self_in) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 8da693b7c5..137460700b 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -22,7 +22,7 @@ //| *, //| channel_count: int = 1, //| sample_rate: int = 8000, -//| single_buffer: bool = True +//| single_buffer: bool = True, //| ) -> None: //| """Create a RawSample based on the given buffer of values. If channel_count is more than //| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the @@ -77,6 +77,7 @@ //| pwm.stop() //| pwm.deinit()""" //| ... +//| static mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_buffer, ARG_channel_count, ARG_sample_rate, ARG_single_buffer }; static const mp_arg_t allowed_args[] = { @@ -111,6 +112,7 @@ static mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a //| def deinit(self) -> None: //| """Deinitialises the RawSample and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t audioio_rawsample_deinit(mp_obj_t self_in) { audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_rawsample_deinit(self); @@ -127,12 +129,14 @@ static void check_for_deinit(audioio_rawsample_obj_t *self) { //| def __enter__(self) -> RawSample: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_rawsample_deinit(args[0]); @@ -146,6 +150,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4, //| sample. This will not change the sample rate of any active playback. Call ``play`` again to //| change it.""" //| +//| static mp_obj_t audioio_rawsample_obj_get_sample_rate(mp_obj_t self_in) { audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 372330577f..b8c42a791d 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -50,6 +50,7 @@ //| print("stopped") //| """ //| ... +//| static mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 2, false); mp_obj_t arg = args[0]; @@ -79,6 +80,7 @@ static mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Deinitialises the WaveFile and releases all memory resources for reuse.""" //| ... +//| static mp_obj_t audioio_wavefile_deinit(mp_obj_t self_in) { audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_wavefile_deinit(self); @@ -95,12 +97,14 @@ static void check_for_deinit(audioio_wavefile_obj_t *self) { //| def __enter__(self) -> WaveFile: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_wavefile_deinit(args[0]); @@ -145,6 +149,7 @@ MP_PROPERTY_GETTER(audioio_wavefile_bits_per_sample_obj, //| channel_count: int //| """Number of audio channels. (read only)""" //| +//| static mp_obj_t audioio_wavefile_obj_get_channel_count(mp_obj_t self_in) { audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiodelays/Echo.c b/shared-bindings/audiodelays/Echo.c index 32a7061745..8b660cb1c7 100644 --- a/shared-bindings/audiodelays/Echo.c +++ b/shared-bindings/audiodelays/Echo.c @@ -76,6 +76,7 @@ //| synth.release(note) //| time.sleep(5)""" //| ... +//| static mp_obj_t audiodelays_echo_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_max_delay_ms, ARG_delay_ms, ARG_decay, ARG_mix, ARG_buffer_size, ARG_sample_rate, ARG_bits_per_sample, ARG_samples_signed, ARG_channel_count, ARG_freq_shift, }; static const mp_arg_t allowed_args[] = { @@ -112,6 +113,7 @@ static mp_obj_t audiodelays_echo_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Deinitialises the Echo.""" //| ... +//| static mp_obj_t audiodelays_echo_deinit(mp_obj_t self_in) { audiodelays_echo_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiodelays_echo_deinit(self); @@ -128,12 +130,14 @@ static void check_for_deinit(audiodelays_echo_obj_t *self) { //| def __enter__(self) -> Echo: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audiodelays_echo_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiodelays_echo_deinit(args[0]); @@ -224,6 +228,7 @@ MP_PROPERTY_GETSET(audiodelays_echo_freq_shift_obj, //| playing: bool //| """True when the effect is playing a sample. (read-only)""" +//| static mp_obj_t audiodelays_echo_obj_get_playing(mp_obj_t self_in) { audiodelays_echo_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -240,6 +245,7 @@ MP_PROPERTY_GETTER(audiodelays_echo_playing_obj, //| //| The sample must match the encoding settings given in the constructor.""" //| ... +//| static mp_obj_t audiodelays_echo_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -263,6 +269,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audiodelays_echo_play_obj, 1, audiodelays_echo_obj_pl //| """Stops playback of the sample. The echo continues playing.""" //| ... //| +//| static mp_obj_t audiodelays_echo_obj_stop(mp_obj_t self_in) { audiodelays_echo_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audiofilters/Distortion.c b/shared-bindings/audiofilters/Distortion.c index 9fb38306e3..7e61570358 100644 --- a/shared-bindings/audiofilters/Distortion.c +++ b/shared-bindings/audiofilters/Distortion.c @@ -31,6 +31,7 @@ //| WAVESHAPE: DistortionMode //| """Waveshaper distortions are used mainly by electronic musicians to achieve an extra-abrasive sound.""" //| +//| MAKE_ENUM_VALUE(audiofilters_distortion_mode_type, distortion_mode, CLIP, DISTORTION_MODE_CLIP); MAKE_ENUM_VALUE(audiofilters_distortion_mode_type, distortion_mode, LOFI, DISTORTION_MODE_LOFI); @@ -110,6 +111,7 @@ static audiofilters_distortion_mode validate_distortion_mode(mp_obj_t obj, qstr //| synth.release(note) //| time.sleep(5)""" //| ... +//| static mp_obj_t audiofilters_distortion_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_drive, ARG_pre_gain, ARG_post_gain, ARG_mode, ARG_soft_clip, ARG_mix, ARG_buffer_size, ARG_sample_rate, ARG_bits_per_sample, ARG_samples_signed, ARG_channel_count, }; @@ -150,6 +152,7 @@ static mp_obj_t audiofilters_distortion_make_new(const mp_obj_type_t *type, size //| def deinit(self) -> None: //| """Deinitialises the Distortion.""" //| ... +//| static mp_obj_t audiofilters_distortion_deinit(mp_obj_t self_in) { audiofilters_distortion_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiofilters_distortion_deinit(self); @@ -166,12 +169,14 @@ static void check_for_deinit(audiofilters_distortion_obj_t *self) { //| def __enter__(self) -> Distortion: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audiofilters_distortion_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiofilters_distortion_deinit(args[0]); @@ -299,6 +304,7 @@ MP_PROPERTY_GETSET(audiofilters_distortion_mix_obj, //| playing: bool //| """True when the effect is playing a sample. (read-only)""" +//| static mp_obj_t audiofilters_distortion_obj_get_playing(mp_obj_t self_in) { audiofilters_distortion_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -315,6 +321,7 @@ MP_PROPERTY_GETTER(audiofilters_distortion_playing_obj, //| //| The sample must match the encoding settings given in the constructor.""" //| ... +//| static mp_obj_t audiofilters_distortion_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -338,6 +345,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audiofilters_distortion_play_obj, 1, audiofilters_dis //| """Stops playback of the sample.""" //| ... //| +//| static mp_obj_t audiofilters_distortion_obj_stop(mp_obj_t self_in) { audiofilters_distortion_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audiofilters/Filter.c b/shared-bindings/audiofilters/Filter.c index 07a5739dcb..e12f2cc3e6 100644 --- a/shared-bindings/audiofilters/Filter.c +++ b/shared-bindings/audiofilters/Filter.c @@ -68,6 +68,7 @@ //| synth.release(note) //| time.sleep(5)""" //| ... +//| static mp_obj_t audiofilters_filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_filter, ARG_mix, ARG_buffer_size, ARG_sample_rate, ARG_bits_per_sample, ARG_samples_signed, ARG_channel_count, }; static const mp_arg_t allowed_args[] = { @@ -99,6 +100,7 @@ static mp_obj_t audiofilters_filter_make_new(const mp_obj_type_t *type, size_t n //| def deinit(self) -> None: //| """Deinitialises the Filter.""" //| ... +//| static mp_obj_t audiofilters_filter_deinit(mp_obj_t self_in) { audiofilters_filter_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiofilters_filter_deinit(self); @@ -115,12 +117,14 @@ static void check_for_deinit(audiofilters_filter_obj_t *self) { //| def __enter__(self) -> Filter: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audiofilters_filter_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiofilters_filter_deinit(args[0]); @@ -172,6 +176,7 @@ MP_PROPERTY_GETSET(audiofilters_filter_mix_obj, //| playing: bool //| """True when the effect is playing a sample. (read-only)""" +//| static mp_obj_t audiofilters_filter_obj_get_playing(mp_obj_t self_in) { audiofilters_filter_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -188,6 +193,7 @@ MP_PROPERTY_GETTER(audiofilters_filter_playing_obj, //| //| The sample must match the encoding settings given in the constructor.""" //| ... +//| static mp_obj_t audiofilters_filter_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -211,6 +217,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audiofilters_filter_play_obj, 1, audiofilters_filter_ //| """Stops playback of the sample.""" //| ... //| +//| static mp_obj_t audiofilters_filter_obj_stop(mp_obj_t self_in) { audiofilters_filter_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 4d5765aa21..82ad7e6f3e 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -23,7 +23,7 @@ //| left_channel: microcontroller.Pin, //| *, //| right_channel: Optional[microcontroller.Pin] = None, -//| quiescent_value: int = 0x8000 +//| quiescent_value: int = 0x8000, //| ) -> None: //| """Create a AudioOut object associated with the given pin(s). This allows you to //| play audio signals out on the given pin(s). @@ -74,6 +74,7 @@ //| pass //| print("stopped")""" //| ... +//| static mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { @@ -99,6 +100,7 @@ static mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t audioio_audioout_deinit(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_audioout_deinit(self); @@ -114,12 +116,14 @@ static void check_for_deinit(audioio_audioout_obj_t *self) { //| def __enter__(self) -> AudioOut: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_audioout_deinit(args[0]); @@ -138,6 +142,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, //| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit //| DAC that ignores the lowest 6 bits when playing 16 bit samples.""" //| ... +//| static mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -159,6 +164,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audioio_audioout_play_obj, 1, audioio_audioout_obj_pl //| def stop(self) -> None: //| """Stops playback and resets to the start of the sample.""" //| ... +//| static mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -169,6 +175,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_stop_obj, audioio_audioout_obj_stop); //| playing: bool //| """True when an audio sample is being output even if `paused`. (read-only)""" +//| static mp_obj_t audioio_audioout_obj_get_playing(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -182,6 +189,7 @@ MP_PROPERTY_GETTER(audioio_audioout_playing_obj, //| def pause(self) -> None: //| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" //| ... +//| static mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -197,6 +205,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_pause_obj, audioio_audioout_obj_pause //| def resume(self) -> None: //| """Resumes sample playback after :py:func:`pause`.""" //| ... +//| static mp_obj_t audioio_audioout_obj_resume(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -212,6 +221,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_resume_obj, audioio_audioout_obj_resu //| paused: bool //| """True when playback is paused. (read-only)""" //| +//| static mp_obj_t audioio_audioout_obj_get_paused(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 4f38b2b7ba..f5068bb775 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -62,6 +62,7 @@ //| time.sleep(1) //| print("stopped")""" //| ... +//| static mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_voice_count, ARG_buffer_size, ARG_channel_count, ARG_bits_per_sample, ARG_samples_signed, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -98,6 +99,7 @@ static mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Deinitialises the Mixer and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t audiomixer_mixer_deinit(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomixer_mixer_deinit(self); @@ -114,12 +116,14 @@ static void check_for_deinit(audiomixer_mixer_obj_t *self) { //| def __enter__(self) -> Mixer: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomixer_mixer_deinit(args[0]); @@ -158,6 +162,7 @@ MP_PROPERTY_GETTER(audiomixer_mixer_sample_rate_obj, //| //| >>> mixer.voice //| (,)""" +//| static mp_obj_t audiomixer_mixer_obj_get_voice(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -178,6 +183,7 @@ MP_PROPERTY_GETTER(audiomixer_mixer_voice_obj, //| //| The sample must match the Mixer's encoding settings given in the constructor.""" //| ... +//| static mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_voice, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -206,6 +212,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixer_play_obj, 1, audiomixer_mixer_obj_pl //| """Stops playback of the sample on the given voice.""" //| ... //| +//| static mp_obj_t audiomixer_mixer_obj_stop_voice(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index f06f079414..90ee877734 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -25,6 +25,7 @@ //| def __init__(self) -> None: //| """MixerVoice instance object(s) created by `audiomixer.Mixer`.""" //| ... +//| // TODO: support mono or stereo voices static mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 0, 0, false); @@ -44,6 +45,7 @@ static mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t //| The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor. //| """ //| ... +//| static mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -63,6 +65,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_play_obj, 1, audiomixer_mixervo //| def stop(self) -> None: //| """Stops playback of the sample on this voice.""" //| ... +//| static mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { @@ -120,6 +123,7 @@ MP_PROPERTY_GETSET(audiomixer_mixervoice_loop_obj, //| playing: bool //| """True when this voice is being output. (read-only)""" //| +//| static mp_obj_t audiomixer_mixervoice_obj_get_playing(mp_obj_t self_in) { audiomixer_mixervoice_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 8e6df36462..dab1f4dd45 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -80,6 +80,7 @@ //| that the socket closes when the stream ends. //| """ //| ... +//| static mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 2, false); @@ -112,6 +113,7 @@ static mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Deinitialises the MP3 and releases all memory resources for reuse.""" //| ... +//| static mp_obj_t audiomp3_mp3file_deinit(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomp3_mp3file_deinit(self); @@ -128,12 +130,14 @@ static void check_for_deinit(audiomp3_mp3file_obj_t *self) { //| def __enter__(self) -> MP3Decoder: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomp3_mp3file_deinit(args[0]); @@ -143,6 +147,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, //| file: typing.BinaryIO //| """File to play back.""" +//| static mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -166,6 +171,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_file_obj, audiomp3_mp3file_obj_se //| def open(self, filepath: str) -> None: //| """Takes in the name of a mp3 file, opens it, and replaces the old playback file.""" //| ... +//| static mp_obj_t audiomp3_mp3file_obj_open(mp_obj_t self_in, mp_obj_t path) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -245,6 +251,7 @@ MP_PROPERTY_GETTER(audiomp3_mp3file_rms_level_obj, //| samples_decoded: int //| """The number of audio samples decoded from the current file. (read only)""" //| +//| static mp_obj_t audiomp3_mp3file_obj_get_samples_decoded(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index deb60bd420..5078c54e00 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -23,7 +23,7 @@ //| left_channel: microcontroller.Pin, //| *, //| right_channel: Optional[microcontroller.Pin] = None, -//| quiescent_value: int = 0x8000 +//| quiescent_value: int = 0x8000, //| ) -> None: //| """Create a PWMAudioOut object associated with the given pin(s). This allows you to //| play audio signals out on the given pin(s). In contrast to mod:`audioio`, @@ -81,6 +81,7 @@ //| pass //| print("stopped")""" //| ... +//| static mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { @@ -108,6 +109,7 @@ static mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_ //| def deinit(self) -> None: //| """Deinitialises the PWMAudioOut and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t audiopwmio_pwmaudioout_deinit(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiopwmio_pwmaudioout_deinit(self); @@ -123,12 +125,14 @@ static void check_for_deinit(audiopwmio_pwmaudioout_obj_t *self) { //| def __enter__(self) -> PWMAudioOut: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t audiopwmio_pwmaudioout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiopwmio_pwmaudioout_deinit(args[0]); @@ -146,6 +150,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_pwmaudioout___exit___obj, //| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output //| resolution will use the highest order bits to output.""" //| ... +//| static mp_obj_t audiopwmio_pwmaudioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -167,6 +172,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(audiopwmio_pwmaudioout_play_obj, 1, audiopwmio_pwmaud //| def stop(self) -> None: //| """Stops playback and resets to the start of the sample.""" //| ... +//| static mp_obj_t audiopwmio_pwmaudioout_obj_stop(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -177,6 +183,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_stop_obj, audiopwmio_pwmaudioou //| playing: bool //| """True when an audio sample is being output even if `paused`. (read-only)""" +//| static mp_obj_t audiopwmio_pwmaudioout_obj_get_playing(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -190,6 +197,7 @@ MP_PROPERTY_GETTER(audiopwmio_pwmaudioout_playing_obj, //| def pause(self) -> None: //| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" //| ... +//| static mp_obj_t audiopwmio_pwmaudioout_obj_pause(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -205,6 +213,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_pause_obj, audiopwmio_pwmaudioo //| def resume(self) -> None: //| """Resumes sample playback after :py:func:`pause`.""" //| ... +//| static mp_obj_t audiopwmio_pwmaudioout_obj_resume(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -220,6 +229,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_resume_obj, audiopwmio_pwmaudio //| paused: bool //| """True when playback is paused. (read-only)""" //| +//| static mp_obj_t audiopwmio_pwmaudioout_obj_get_paused(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/aurora_epaper/aurora_framebuffer.c b/shared-bindings/aurora_epaper/aurora_framebuffer.c index 0b15d45e7d..f1bb169328 100644 --- a/shared-bindings/aurora_epaper/aurora_framebuffer.c +++ b/shared-bindings/aurora_epaper/aurora_framebuffer.c @@ -77,6 +77,7 @@ //| :param bool free_bus: Determines whether the SPI bus passed in will be freed when the frame buffer is freed (optional). //| """ //| ... +//| static mp_obj_t aurora_epaper_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_spi_bus, ARG_chip_select, ARG_reset, ARG_busy, ARG_discharge, ARG_width, ARG_height, ARG_power, ARG_free_bus, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -124,6 +125,7 @@ static mp_int_t aurora_epaper_framebuffer_get_buffer(mp_obj_t self_in, mp_buffer //| AuroraMemoryFramebuffer instance. After deinitialization, no further operations //| may be performed.""" //| ... +//| static mp_obj_t aurora_epaper_framebuffer_deinit(mp_obj_t self_in) { aurora_epaper_framebuffer_obj_t *self = (aurora_epaper_framebuffer_obj_t *)self_in; common_hal_aurora_epaper_framebuffer_deinit(self); @@ -137,6 +139,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(aurora_epaper_framebuffer_deinit_obj, aurora_ep //| Higher temperature means faster update speed. //| """ //| ... +//| static mp_obj_t aurora_epaper_frambuffer_set_temperature(mp_obj_t self_in, mp_obj_t temperature) { aurora_epaper_framebuffer_obj_t *self = (aurora_epaper_framebuffer_obj_t *)self_in; @@ -151,6 +154,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(aurora_epaper_frambuffer_set_temperature_obj, a //| If you have multiple displays this could be used to keep the other active on soft reset.""" //| ... //| +//| static mp_obj_t aurora_epaper_framebuffer_get_free_bus(mp_obj_t self_in) { aurora_epaper_framebuffer_obj_t *self = (aurora_epaper_framebuffer_obj_t *)self_in; return mp_obj_new_bool(self->free_bus); diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index c1e42511e9..f219144c60 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -26,7 +26,7 @@ //| sda: microcontroller.Pin, //| *, //| frequency: int = 400000, -//| timeout: int = 255 +//| timeout: int = 255, //| ) -> None: //| """I2C is a two-wire protocol for communicating between devices. At the //| physical level it consists of 2 wires: SCL and SDA, the clock and data @@ -45,6 +45,7 @@ //| :param int frequency: The clock frequency of the bus //| :param int timeout: The maximum clock stretching timeout in microseconds""" //| ... +//| static mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_scl, ARG_sda, ARG_frequency, ARG_timeout }; static const mp_arg_t allowed_args[] = { @@ -67,6 +68,7 @@ static mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, //| def deinit(self) -> None: //| """Releases control of the underlying hardware so other classes can use it.""" //| ... +//| static mp_obj_t bitbangio_i2c_obj_deinit(mp_obj_t self_in) { bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); shared_module_bitbangio_i2c_deinit(self); @@ -83,12 +85,14 @@ static void check_for_deinit(bitbangio_i2c_obj_t *self) { //| def __enter__(self) -> I2C: //| """No-op used in Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware on context exit. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t bitbangio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; shared_module_bitbangio_i2c_deinit(args[0]); @@ -109,6 +113,7 @@ static void check_lock(bitbangio_i2c_obj_t *self) { //| :return: ``True`` if a device at ``address`` responds; ``False`` otherwise //| :rtype: bool""" //| ... +//| static mp_obj_t bitbangio_i2c_probe(mp_obj_t self_in, mp_obj_t address_obj) { bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -124,6 +129,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(bitbangio_i2c_probe_obj, bitbangio_i2c_probe); //| 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.""" //| ... +//| static mp_obj_t bitbangio_i2c_scan(mp_obj_t self_in) { bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -143,6 +149,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_scan_obj, bitbangio_i2c_scan); //| def try_lock(self) -> bool: //| """Attempts to grab the I2C lock. Returns True on success.""" //| ... +//| static mp_obj_t bitbangio_i2c_obj_try_lock(mp_obj_t self_in) { bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -153,6 +160,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_try_lock_obj, bitbangio_i2c_obj_try_lock //| def unlock(self) -> None: //| """Releases the I2C lock.""" //| ... +//| static mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) { bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -162,6 +170,7 @@ static mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock); //| import sys +//| //| def readfrom_into( //| self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize //| ) -> None: @@ -178,6 +187,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock); //| :param int start: Index to start writing at //| :param int end: Index to write up to but not include""" //| ... +//| // Shared arg parsing for readfrom_into and writeto_then_readfrom. static void readfrom(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; @@ -219,6 +229,7 @@ static mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 1, bitbangio_i2c_readfrom_into); //| import sys +//| //| def writeto( //| self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize //| ) -> None: @@ -239,6 +250,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 1, bitbangio_i2c_rea //| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` //| """ //| ... +//| // Shared arg parsing for writeto and writeto_then_readfrom. static void writeto(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { // get the buffer to write the data from @@ -284,6 +296,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_wr //| import sys +//| //| def writeto_then_readfrom( //| self, //| address: int, @@ -293,7 +306,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_wr //| out_start: int = 0, //| out_end: int = sys.maxsize, //| in_start: int = 0, -//| in_end: int = sys.maxsize +//| in_end: int = sys.maxsize, //| ) -> 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 @@ -317,6 +330,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_wr //| """ //| ... //| +//| static mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index 62fb1e5a2b..2ea13ad2b7 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -52,6 +52,7 @@ //| :param ~microcontroller.Pin MOSI: the Main Out Selected In pin. //| :param ~microcontroller.Pin MISO: the Main In Selected Out pin.""" //| ... +//| // TODO(tannewt): Support LSB SPI. static mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { @@ -76,6 +77,7 @@ static mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args, //| def deinit(self) -> None: //| """Turn off the SPI bus.""" //| ... +//| static mp_obj_t bitbangio_spi_obj_deinit(mp_obj_t self_in) { bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); shared_module_bitbangio_spi_deinit(self); @@ -92,12 +94,14 @@ static void check_for_deinit(bitbangio_spi_obj_t *self) { //| def __enter__(self) -> SPI: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t bitbangio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; shared_module_bitbangio_spi_deinit(args[0]); @@ -123,6 +127,7 @@ static void check_lock(bitbangio_spi_obj_t *self) { //| or second (1). Rising or falling depends on clock polarity. //| :param int bits: the number of bits per word""" //| ... +//| static mp_obj_t bitbangio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; static const mp_arg_t allowed_args[] = { @@ -153,6 +158,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_configure_obj, 1, bitbangio_spi_configu //| :return: True when lock has been grabbed //| :rtype: bool""" //| ... +//| static mp_obj_t bitbangio_spi_obj_try_lock(mp_obj_t self_in) { bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -163,6 +169,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_try_lock_obj, bitbangio_spi_obj_try_lock //| def unlock(self) -> None: //| """Releases the SPI lock.""" //| ... +//| static mp_obj_t bitbangio_spi_obj_unlock(mp_obj_t self_in) { bitbangio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -172,6 +179,7 @@ static mp_obj_t bitbangio_spi_obj_unlock(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_unlock_obj, bitbangio_spi_obj_unlock); //| import sys +//| //| def write(self, buf: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the data contained in ``buf``. Requires the SPI being locked. //| If the buffer is empty, nothing happens. @@ -185,6 +193,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_unlock_obj, bitbangio_spi_obj_unlock); //| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` //| """ //| ... +//| static mp_obj_t bitbangio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -224,13 +233,14 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_write_obj, 1, bitbangio_spi_write); //| import sys +//| //| def readinto( //| self, //| buffer: WriteableBuffer, //| *, //| start: int = 0, //| end: int = sys.maxsize, -//| write_value: int = 0 +//| write_value: int = 0, //| ) -> None: //| """Read into ``buffer`` while writing ``write_value`` for each byte read. //| The SPI object must be locked. @@ -246,6 +256,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_write_obj, 1, bitbangio_spi_write); //| :param int write_value: value to write while reading //| """ //| ... +//| static mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; static const mp_arg_t allowed_args[] = { @@ -285,6 +296,7 @@ static mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 1, bitbangio_spi_readinto); //| import sys +//| //| def write_readinto( //| self, //| out_buffer: ReadableBuffer, @@ -293,7 +305,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 1, bitbangio_spi_readinto //| out_start: int = 0, //| out_end: int = sys.maxsize, //| in_start: int = 0, -//| in_end: int = sys.maxsize +//| in_end: int = sys.maxsize, //| ) -> None: //| """Write out the data in ``out_buffer`` while simultaneously reading data into ``in_buffer``. //| The SPI object must be locked. @@ -319,6 +331,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 1, bitbangio_spi_readinto //| """ //| ... //| +//| static mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/bitmapfilter/__init__.c b/shared-bindings/bitmapfilter/__init__.c index 9a3c23c6a3..7c5344dde1 100644 --- a/shared-bindings/bitmapfilter/__init__.c +++ b/shared-bindings/bitmapfilter/__init__.c @@ -12,6 +12,7 @@ #include "shared-bindings/displayio/Palette.h" #include "shared-bindings/bitmapfilter/__init__.h" +//| //| //| def morph( //| bitmap: displayio.Bitmap, @@ -79,6 +80,7 @@ //| bitmapfilter.morph(bitmap, kernel_gauss_3, 1/sum(kernel_gauss_3)) //| """ //| +//| static mp_float_t get_m(mp_obj_t mul_obj, int sum) { @@ -165,6 +167,7 @@ static mp_float_t float_subscr(mp_obj_t o, int i) { //| The ``r`` parameter gives the scale factor for the red channel of //| pixels, and so forth.""" //| +//| static const mp_obj_namedtuple_type_t bitmapfilter_channel_scale_type = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_ChannelScale), .n_fields = 3, @@ -198,6 +201,7 @@ static const mp_obj_namedtuple_type_t bitmapfilter_channel_scale_type = { //| ) -> None: //| """Construct a ChannelScaleOffset object""" //| +//| static const mp_obj_namedtuple_type_t bitmapfilter_channel_scale_offset_type = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_ChannelScaleOffset), .n_fields = 6, @@ -253,6 +257,7 @@ static const mp_obj_namedtuple_type_t bitmapfilter_channel_scale_offset_type = { //| ) -> None: //| """Construct a ChannelMixer object""" //| +//| static const mp_obj_namedtuple_type_t bitmapfilter_channel_mixer_type = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_ChannelMixer), .n_fields = 9, @@ -305,6 +310,7 @@ static const mp_obj_namedtuple_type_t bitmapfilter_channel_mixer_type = { //| ) -> None: //| """Construct a ChannelMixerOffset object""" //| +//| static const mp_obj_namedtuple_type_t bitmapfilter_channel_mixer_offset_type = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_ChannelMixerOffset), .n_fields = 12, @@ -351,6 +357,7 @@ static const mp_obj_namedtuple_type_t bitmapfilter_channel_mixer_offset_type = { //| Only pixels set to a non-zero value in the mask are modified. //| """ //| +//| static mp_obj_t bitmapfilter_mix(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_weights, ARG_mask }; static const mp_arg_t allowed_args[] = { @@ -424,6 +431,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_mix_obj, 0, bitmapfilter_mix); //| PIL and ImageMagic both call this "solarize". //| """ //| +//| static mp_obj_t bitmapfilter_solarize(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_threshold, ARG_mask }; static const mp_arg_t allowed_args[] = { @@ -458,6 +466,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_solarize_obj, 0, bitmapfilter_solarize); //| ThreeLookupFunctions = Tuple[LookupFunction, LookupFunction, LookupFunction] //| """Any sequenceof three `LookupFunction` objects""" //| +//| //| def lookup( //| bitmap: displayio.Bitmap, //| lookup: LookupFunction | ThreeLookupFunctions, @@ -487,6 +496,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_solarize_obj, 0, bitmapfilter_solarize); //| Only pixels set to a non-zero value in the mask are modified. //| """ //| +//| static int scaled_lut(int maxval, mp_obj_t func, int i) { mp_obj_t obj = mp_call_function_1(func, mp_obj_new_float(i / (mp_float_t)maxval)); @@ -566,6 +576,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_lookup_obj, 0, bitmapfilter_lookup); //| Only pixels set to a non-zero value in the mask are modified. //| """ //| +//| static mp_obj_t bitmapfilter_false_color(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_palette, ARG_mask }; static const mp_arg_t allowed_args[] = { @@ -612,6 +623,7 @@ static uint8_t *get_blend_table(mp_obj_t lookup, int mode) { //| There is not actually a BlendTable type. The real type is actually any //| buffer 4096 bytes in length.""" //| +//| //| def blend_precompute(lookup: BlendFunction, table: BlendTable | None = None) -> BlendTable: //| """Precompute a BlendTable from a BlendFunction //| @@ -628,6 +640,7 @@ static uint8_t *get_blend_table(mp_obj_t lookup, int mode) { //| return a * .33 + b * .67 //| """ //| +//| static mp_obj_t blend_precompute(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_lookup, ARG_table }; static const mp_arg_t allowed_args[] = { @@ -652,6 +665,7 @@ static mp_obj_t blend_precompute(size_t n_args, const mp_obj_t *pos_args, mp_map } MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_blend_precompute_obj, 0, blend_precompute); +//| //| //| def blend( //| dest: displayio.Bitmap, @@ -673,6 +687,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmapfilter_blend_precompute_obj, 0, blend_precomput //| The destination bitmap is returned. //| """ //| +//| static mp_obj_t bitmapfilter_blend(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_dest, ARG_src1, ARG_src2, ARG_lookup, ARG_mask }; diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index de44b5164b..9d655c3f90 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -52,6 +52,7 @@ bitmaptools_rect_t bitmaptools_validate_coord_range_pair(const mp_arg_val_t in[4 //| for information about using the :py:mod:`displayio` module. //| """ //| +//| static int16_t validate_point(mp_obj_t point, int16_t default_value) { // Checks if point is None and returns default_value, otherwise decodes integer value @@ -141,7 +142,7 @@ static void validate_clip_region(displayio_bitmap_t *bitmap, mp_obj_t clip0_tupl //| source_clip1: Tuple[int, int], //| angle: float, //| scale: float, -//| skip_index: int +//| skip_index: int, //| ) -> None: //| """Inserts the source bitmap region into the destination bitmap with rotation //| (angle), scale and clipping (both on source and destination bitmaps). @@ -176,6 +177,7 @@ static void validate_clip_region(displayio_bitmap_t *bitmap, mp_obj_t clip0_tupl //| set to None to copy all pixels""" //| ... //| +//| static mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_source_bitmap, ARG_ox, ARG_oy, ARG_dest_clip0, ARG_dest_clip1, @@ -284,6 +286,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom //| Screen: BlendMode //| """Blend based on the value in each color channel. The result keeps the lighter colors and discards darker colors.""" //| +//| MAKE_ENUM_VALUE(bitmaptools_blendmode_type, bitmaptools_blendmode, Normal, BITMAPTOOLS_BLENDMODE_NORMAL); MAKE_ENUM_VALUE(bitmaptools_blendmode_type, bitmaptools_blendmode, Screen, BITMAPTOOLS_BLENDMODE_SCREEN); @@ -327,6 +330,7 @@ MAKE_ENUM_TYPE(bitmaptools, BlendMode, bitmaptools_blendmode); //| For the L8 colorspace, the bitmaps must have a bits-per-value of 8. //| For the RGB colorspaces, they must have a bits-per-value of 16.""" //| +//| static mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_source_bitmap_1, ARG_source_bitmap_2, ARG_colorspace, ARG_factor_1, ARG_factor_2, ARG_blendmode, ARG_skip_source1_index, ARG_skip_source2_index}; @@ -429,6 +433,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_alphablend_obj, 0, bitmaptools_alphablend //| fill region in the destination bitmap""" //| ... //| +//| static mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARGS_X1_Y1_X2_Y2, ARG_value}; @@ -477,6 +482,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_fill_region_obj, 0, bitmaptools_obj_fill_ //| value color in the enclosed area in the destination bitmap""" //| ... //| +//| static mp_obj_t bitmaptools_obj_boundary_fill(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_x, ARG_y, ARG_fill_color_value, ARG_replaced_color_value}; @@ -537,6 +543,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_boundary_fill_obj, 0, bitmaptools_obj_bou //| line in the destination bitmap""" //| ... //| +//| static mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value}; @@ -623,6 +630,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_line_obj, 0, bitmaptools_obj_draw_li //| """ //| ... //| +//| static mp_obj_t bitmaptools_obj_draw_polygon(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_xs, ARG_ys, ARG_value, ARG_close}; @@ -705,6 +713,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_polygon_obj, 0, bitmaptools_obj_draw //| """ //| ... //| +//| static mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_data, ARGS_X1_Y1_X2_Y2, ARG_skip_index }; static const mp_arg_t allowed_args[] = { @@ -768,6 +777,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_arrayblit_obj, 0, bitmaptools_arrayblit); //| """ //| ... //| +//| static mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_file, ARG_bits_per_pixel, ARG_element_size, ARG_reverse_pixels_in_element, ARG_swap_bytes_in_element, ARG_reverse_rows }; @@ -830,6 +840,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_readinto_obj, 0, bitmaptools_readinto); //| FloydStenberg: "DitherAlgorithm" //| """The Floyd-Stenberg dither""" //| +//| MAKE_ENUM_VALUE(bitmaptools_dither_algorithm_type, dither_algorithm, Atkinson, DITHER_ALGORITHM_ATKINSON); MAKE_ENUM_VALUE(bitmaptools_dither_algorithm_type, dither_algorithm, FloydStenberg, DITHER_ALGORITHM_FLOYD_STENBERG); @@ -858,6 +869,7 @@ MAKE_ENUM_TYPE(bitmaptools, DitherAlgorithm, bitmaptools_dither_algorithm); //| """ //| ... //| +//| static mp_obj_t bitmaptools_dither(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_dest_bitmap, ARG_source_bitmap, ARG_source_colorspace, ARG_algorithm }; static const mp_arg_t allowed_args[] = { @@ -951,6 +963,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_dither_obj, 0, bitmaptools_dither); //| //| ... //| +//| static mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_x, ARG_y, ARG_radius, ARG_value}; @@ -1000,7 +1013,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_circle_obj, 0, bitmaptools_obj_draw_ //| x2: int | None = None, //| y2: int | None = None, //| skip_source_index: int | None = None, -//| skip_dest_index: int | None = None +//| skip_dest_index: int | None = None, //| ) -> None: //| """Inserts the source_bitmap region defined by rectangular boundaries //| (x1,y1) and (x2,y2) into the bitmap at the specified (x,y) location. @@ -1021,6 +1034,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_circle_obj, 0, bitmaptools_obj_draw_ //| by the pixels from the source""" //| ... //| +//| static mp_obj_t bitmaptools_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_destination, ARG_source, ARG_x, ARG_y, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_source_index, ARG_skip_dest_index}; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/bitops/__init__.c b/shared-bindings/bitops/__init__.c index dc07436866..088aa260e9 100644 --- a/shared-bindings/bitops/__init__.c +++ b/shared-bindings/bitops/__init__.c @@ -11,6 +11,7 @@ //| """Routines for low-level manipulation of binary data""" //| +//| //| def bit_transpose( //| input: ReadableBuffer, output: WriteableBuffer, width: int = 8 @@ -35,6 +36,7 @@ //| Returns the output buffer.""" //| ... //| +//| static mp_obj_t bit_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_input, ARG_output, ARG_width }; diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index 1a2721a91c..c985d85217 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -33,12 +33,14 @@ //| //| .. warning:: The board module varies by board. The APIs documented here may or may not be //| available on a specific board.""" +//| //| board_id: str //| """Board ID string. The unique identifier for the board model in //| circuitpython, as well as on circuitpython.org. //| Example: "hallowing_m0_express".""" //| +//| //| def I2C() -> busio.I2C: //| """Returns the `busio.I2C` object for the board's designated I2C bus(es). @@ -46,6 +48,7 @@ //| """ //| ... //| +//| #if CIRCUITPY_BOARD_I2C static mp_obj_t board_i2c_0(void) { return common_hal_board_create_i2c(0); @@ -64,6 +67,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c_0); //| """ //| ... //| +//| #if CIRCUITPY_BOARD_SPI static mp_obj_t board_spi_0(void) { return common_hal_board_create_spi(0); @@ -82,6 +86,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi_0); //| """ //| ... //| +//| #if CIRCUITPY_BOARD_UART static mp_obj_t board_uart_0(void) { return common_hal_board_create_uart(0); diff --git a/shared-bindings/busdisplay/BusDisplay.c b/shared-bindings/busdisplay/BusDisplay.c index af77f288bc..297a869057 100644 --- a/shared-bindings/busdisplay/BusDisplay.c +++ b/shared-bindings/busdisplay/BusDisplay.c @@ -28,6 +28,7 @@ //| ] //| """:py:class:`fourwire.FourWire`, :py:class:`paralleldisplaybus.ParallelBus` or :py:class:`i2cdisplaybus.I2CDisplayBus`""" //| +//| //| class BusDisplay: //| """Manage updating a display over a display bus @@ -65,7 +66,7 @@ //| auto_refresh: bool = True, //| native_frames_per_second: int = 60, //| backlight_on_high: bool = True, -//| SH1107_addressing: bool = False +//| SH1107_addressing: bool = False, //| ) -> None: //| r"""Create a Display object on the given display bus (`FourWire`, `paralleldisplaybus.ParallelBus` or `I2CDisplayBus`). //| @@ -125,6 +126,7 @@ //| :param int backlight_pwm_frequency: The frequency to use to drive the PWM for backlight brightness control. Default is 50000. //| """ //| ... +//| static mp_obj_t busdisplay_busdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, @@ -236,7 +238,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(busdisplay_busdisplay_show_obj, busdisplay_busdisplay_ //| self, //| *, //| target_frames_per_second: Optional[int] = None, -//| minimum_frames_per_second: int = 0 +//| minimum_frames_per_second: int = 0, //| ) -> bool: //| """When auto_refresh is off, and :py:attr:`target_frames_per_second` is not `None` this waits //| for the target frame rate and then refreshes the display, @@ -258,6 +260,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(busdisplay_busdisplay_show_obj, busdisplay_busdisplay_ //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second. //| """ //| ... +//| static mp_obj_t busdisplay_busdisplay_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second }; static const mp_arg_t allowed_args[] = { @@ -395,6 +398,7 @@ MP_PROPERTY_GETTER(busdisplay_busdisplay_bus_obj, //| If the root group is set to `displayio.CIRCUITPYTHON_TERMINAL`, the default CircuitPython terminal will be shown. //| If the root group is set to ``None``, no output will be shown. //| """ +//| static mp_obj_t busdisplay_busdisplay_obj_get_root_group(mp_obj_t self_in) { busdisplay_busdisplay_obj_t *self = native_display(self_in); return common_hal_busdisplay_busdisplay_get_root_group(self); @@ -426,6 +430,7 @@ MP_PROPERTY_GETSET(busdisplay_busdisplay_root_group_obj, //| """ //| ... //| +//| static mp_obj_t busdisplay_busdisplay_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_y, ARG_buffer }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 1bd5821c8d..12c6ce4cbf 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -25,7 +25,7 @@ //| sda: microcontroller.Pin, //| *, //| frequency: int = 100000, -//| timeout: int = 255 +//| timeout: int = 255, //| ) -> None: //| """I2C is a two-wire protocol for communicating between devices. At the //| physical level it consists of 2 wires: SCL and SDA, the clock and data @@ -46,6 +46,7 @@ //| :class:`bitbangio.I2C`; ignored for :class:`busio.I2C`) //| """ //| ... +//| static mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_BUSIO_I2C enum { ARG_scl, ARG_sda, ARG_frequency, ARG_timeout }; @@ -74,6 +75,7 @@ static mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz //| def deinit(self) -> None: //| """Releases control of the underlying hardware so other classes can use it.""" //| ... +//| static mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_i2c_deinit(self); @@ -90,12 +92,14 @@ static void check_for_deinit(busio_i2c_obj_t *self) { //| def __enter__(self) -> I2C: //| """No-op used in Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware on context exit. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_i2c_deinit(MP_OBJ_TO_PTR(args[0])); @@ -117,6 +121,7 @@ static void check_lock(busio_i2c_obj_t *self) { //| :return: ``True`` if a device at ``address`` responds; ``False`` otherwise //| :rtype: bool""" //| ... +//| static mp_obj_t busio_i2c_probe(mp_obj_t self_in, mp_obj_t address_obj) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -134,6 +139,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(busio_i2c_probe_obj, busio_i2c_probe); //| :return: List of device ids on the I2C bus //| :rtype: list""" //| ... +//| static mp_obj_t busio_i2c_scan(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -156,6 +162,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan); //| :return: True when lock has been grabbed //| :rtype: bool""" //| ... +//| static mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -166,6 +173,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock); //| def unlock(self) -> None: //| """Releases the I2C lock.""" //| ... +//| static mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) { busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -175,6 +183,7 @@ static mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); //| import sys +//| //| def readfrom_into( //| self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize //| ) -> None: @@ -190,6 +199,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); //| :param int start: beginning of buffer slice //| :param int end: end of buffer slice; if not specified, use ``len(buffer)``""" //| ... +//| static mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -231,6 +241,7 @@ static mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_into); //| import sys +//| //| def writeto( //| self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize //| ) -> None: @@ -250,6 +261,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_in //| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` //| """ //| ... +//| static mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -292,6 +304,7 @@ static mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma static MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); //| import sys +//| //| def writeto_then_readfrom( //| self, //| address: int, @@ -301,7 +314,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); //| out_start: int = 0, //| out_end: int = sys.maxsize, //| in_start: int = 0, -//| in_end: int = sys.maxsize +//| in_end: int = sys.maxsize, //| ) -> 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 @@ -325,6 +338,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); //| """ //| ... //| +//| static mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 2e52486cab..375da6fb65 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -80,6 +80,7 @@ //| **Limitations:** ``half_duplex`` is available only on STM; other chips do not have the hardware support. //| """ //| ... +//| // TODO(tannewt): Support LSB SPI. @@ -115,6 +116,7 @@ static mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz //| def deinit(self) -> None: //| """Turn off the SPI bus.""" //| ... +//| static mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busio_spi_deinit(self); @@ -126,11 +128,13 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit); //| """No-op used by Context Managers. //| Provided by context manager helper.""" //| ... +//| //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_spi_deinit(MP_OBJ_TO_PTR(args[0])); @@ -175,6 +179,7 @@ static void check_for_deinit(busio_spi_obj_t *self) { //| Two SPI objects may be created, except on the Circuit Playground Bluefruit, //| which allows only one (to allow for an additional I2C object).""" //| ... +//| static mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits }; @@ -208,6 +213,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure); //| :return: True when lock has been grabbed //| :rtype: bool""" //| ... +//| static mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -218,6 +224,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock); //| def unlock(self) -> None: //| """Releases the SPI lock.""" //| ... +//| static mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -228,6 +235,7 @@ static mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); //| import sys +//| //| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the data contained in ``buffer``. The SPI object must be locked. //| If the buffer is empty, nothing happens. @@ -241,6 +249,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); //| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` //| """ //| ... +//| static mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; @@ -281,13 +290,14 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 1, busio_spi_write); //| import sys +//| //| def readinto( //| self, //| buffer: WriteableBuffer, //| *, //| start: int = 0, //| end: int = sys.maxsize, -//| write_value: int = 0 +//| write_value: int = 0, //| ) -> None: //| """Read into ``buffer`` while writing ``write_value`` for each byte read. //| The SPI object must be locked. @@ -305,6 +315,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 1, busio_spi_write); //| :param int write_value: value to write while reading //| """ //| ... +//| static mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; @@ -345,6 +356,7 @@ static mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 1, busio_spi_readinto); //| import sys +//| //| def write_readinto( //| self, //| out_buffer: ReadableBuffer, @@ -353,7 +365,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 1, busio_spi_readinto); //| out_start: int = 0, //| out_end: int = sys.maxsize, //| in_start: int = 0, -//| in_end: int = sys.maxsize +//| in_end: int = sys.maxsize, //| ) -> None: //| """Write out the data in ``out_buffer`` while simultaneously reading data into ``in_buffer``. //| The SPI object must be locked. @@ -378,6 +390,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 1, busio_spi_readinto); //| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` //| """ //| ... +//| static mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; @@ -438,6 +451,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 1, busio_spi_write_read //| """The actual SPI bus frequency. This may not match the frequency requested //| due to internal limitations.""" //| +//| static mp_obj_t busio_spi_obj_get_frequency(mp_obj_t self_in) { busio_spi_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index eb918fc753..49809abf85 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -54,7 +54,7 @@ //| parity: Optional[Parity] = None, //| stop: int = 1, //| timeout: float = 1, -//| receiver_buffer_size: int = 64 +//| receiver_buffer_size: int = 64, //| ) -> None: //| """A common bidirectional serial protocol that uses an an agreed upon speed //| rather than a shared clock line. @@ -83,6 +83,7 @@ //| RS485 specifications intermittently. //| """ //| ... +//| typedef struct { mp_obj_base_t base; } busio_uart_parity_obj_t; @@ -178,6 +179,7 @@ static busio_uart_obj_t *native_uart(mp_obj_t uart_obj) { //| def deinit(self) -> None: //| """Deinitialises the UART and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) { busio_uart_obj_t *self = native_uart(self_in); common_hal_busio_uart_deinit(self); @@ -194,12 +196,14 @@ static void check_for_deinit(busio_uart_obj_t *self) { //| def __enter__(self) -> UART: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t busio_uart_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_busio_uart_deinit(MP_OBJ_TO_PTR(args[0])); @@ -222,6 +226,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ //| :return: Data read //| :rtype: bytes or None""" //| ... +//| //| def readinto(self, buf: WriteableBuffer) -> Optional[int]: //| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. @@ -231,6 +236,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ //| //| *New in CircuitPython 4.0:* No length parameter is permitted.""" //| ... +//| //| def readline(self) -> bytes: //| """Read a line, ending in a newline character, or @@ -241,6 +247,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ //| :return: the line read //| :rtype: bytes or None""" //| ... +//| //| def write(self, buf: ReadableBuffer) -> Optional[int]: //| """Write the buffer of bytes to the bus. @@ -250,6 +257,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_ //| :return: the number of bytes written //| :rtype: int or None""" //| ... +//| // These three methods are used by the shared stream methods. static mp_uint_t busio_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) { @@ -330,6 +338,7 @@ MP_PROPERTY_GETTER(busio_uart_in_waiting_obj, //| timeout: float //| """The current timeout, in seconds (float).""" +//| static mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) { busio_uart_obj_t *self = native_uart(self_in); check_for_deinit(self); @@ -356,6 +365,7 @@ MP_PROPERTY_GETSET(busio_uart_timeout_obj, //| """Discard any unread characters in the input buffer.""" //| ... //| +//| static mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) { busio_uart_obj_t *self = native_uart(self_in); check_for_deinit(self); @@ -372,6 +382,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_o //| EVEN: int //| """Total number of ones should be even.""" //| +//| const mp_obj_type_t busio_uart_parity_type; const busio_uart_parity_obj_t busio_uart_parity_odd_obj = { diff --git a/shared-bindings/camera/Camera.c b/shared-bindings/camera/Camera.c index a0be953222..6f42fa08bc 100644 --- a/shared-bindings/camera/Camera.c +++ b/shared-bindings/camera/Camera.c @@ -39,6 +39,7 @@ //| def __init__(self) -> None: //| """Initialize camera.""" //| ... +//| static mp_obj_t camera_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { camera_obj_t *self = mp_obj_malloc(camera_obj_t, &camera_type); // No arguments @@ -51,6 +52,7 @@ static mp_obj_t camera_make_new(const mp_obj_type_t *type, size_t n_args, size_t //| def deinit(self) -> None: //| """De-initialize camera.""" //| ... +//| static mp_obj_t camera_obj_deinit(mp_obj_t self_in) { camera_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_camera_deinit(self); @@ -72,6 +74,7 @@ static void check_for_deinit(camera_obj_t *self) { //| :rtype: int""" //| ... //| +//| static mp_obj_t camera_obj_take_picture(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_width, ARG_height, ARG_format }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/camera/ImageFormat.c b/shared-bindings/camera/ImageFormat.c index ad436b4b39..86ea274124 100644 --- a/shared-bindings/camera/ImageFormat.c +++ b/shared-bindings/camera/ImageFormat.c @@ -11,12 +11,14 @@ //| //| def __init__(self) -> None: //| """Enum-like class to define the image format.""" +//| //| JPG: ImageFormat //| """JPG format.""" //| //| RGB565: ImageFormat //| """RGB565 format.""" //| +//| const camera_imageformat_obj_t camera_imageformat_jpg_obj = { { &camera_imageformat_type }, diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index 47ba5d62df..ff46eb26da 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -42,6 +42,7 @@ //| :param bool auto_restart: If True, will restart communications after entering bus-off state //| """ //| ... +//| static mp_obj_t canio_can_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_loopback, ARG_silent, ARG_auto_restart, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -132,6 +133,7 @@ MP_PROPERTY_GETTER(canio_can_receive_error_count_obj, //| state: BusState //| """The current state of the bus. (read-only)""" +//| static mp_obj_t canio_can_state_get(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_can_check_for_deinit(self); @@ -147,6 +149,7 @@ MP_PROPERTY_GETTER(canio_can_state_obj, //| def restart(self) -> None: //| """If the device is in the bus off state, restart it.""" //| ... +//| static mp_obj_t canio_can_restart(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_can_check_for_deinit(self); @@ -193,6 +196,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(canio_can_restart_obj, canio_can_restart); //| either a single address or a mask of addresses, both standard or extended. //| """ //| ... +//| static mp_obj_t canio_can_listen(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { canio_can_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); common_hal_canio_can_check_for_deinit(self); @@ -230,6 +234,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(canio_can_listen_obj, 1, canio_can_listen); //| loopback: bool //| """True if the device was created in loopback mode, False //| otherwise (read-only)""" +//| static mp_obj_t canio_can_loopback_get(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_can_check_for_deinit(self); @@ -246,6 +251,7 @@ MP_PROPERTY_GETTER(canio_can_loopback_obj, //| If the message could not be sent due to a full fifo or a bus error condition, RuntimeError is raised. //| """ //| ... +//| static mp_obj_t canio_can_send(mp_obj_t self_in, mp_obj_t message_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_can_check_for_deinit(self); @@ -263,6 +269,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(canio_can_send_obj, canio_can_send); //| silent: bool //| """True if the device was created in silent mode, False //| otherwise (read-only)""" +//| static mp_obj_t canio_can_silent_get(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_can_check_for_deinit(self); @@ -277,6 +284,7 @@ MP_PROPERTY_GETTER(canio_can_silent_obj, //| def deinit(self) -> None: //| """Deinitialize this object, freeing its hardware resources""" //| ... +//| static mp_obj_t canio_can_deinit(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_can_deinit(self); @@ -287,6 +295,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(canio_can_deinit_obj, canio_can_deinit); //| def __enter__(self) -> CAN: //| """Returns self, to allow the object to be used in a `with` statement for resource control""" //| ... +//| static mp_obj_t canio_can_enter(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_can_check_for_deinit(self); @@ -303,6 +312,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(canio_can_enter_obj, canio_can_enter); //| """Calls deinit()""" //| ... //| +//| static mp_obj_t canio_can_exit(size_t num_args, const mp_obj_t args[]) { canio_can_obj_t *self = MP_OBJ_TO_PTR(args[0]); common_hal_canio_can_deinit(self); diff --git a/shared-bindings/canio/Listener.c b/shared-bindings/canio/Listener.c index 26b5fb2cbb..0fd53eecbe 100644 --- a/shared-bindings/canio/Listener.c +++ b/shared-bindings/canio/Listener.c @@ -29,6 +29,7 @@ //| If no message is received in time, `None` is returned. Otherwise, //| a `Message` or `RemoteTransmissionRequest` is returned.""" //| ... +//| static mp_obj_t canio_listener_receive(mp_obj_t self_in) { canio_listener_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_listener_check_for_deinit(self); @@ -47,6 +48,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(canio_listener_receive_obj, canio_listener_rece //| """Returns the number of messages (including remote //| transmission requests) waiting""" //| ... +//| static mp_obj_t canio_listener_in_waiting(mp_obj_t self_in) { canio_listener_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_listener_check_for_deinit(self); @@ -70,6 +72,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(canio_listener_in_waiting_obj, canio_listener_i //| This method enables the `Listener` to be used as an //| iterable, for instance in a for-loop.""" //| ... +//| static mp_obj_t canio_iternext(mp_obj_t self_in) { mp_obj_t result = canio_listener_receive(self_in); if (result == mp_const_none) { @@ -81,6 +84,7 @@ static mp_obj_t canio_iternext(mp_obj_t self_in) { //| def deinit(self) -> None: //| """Deinitialize this object, freeing its hardware resources""" //| ... +//| static mp_obj_t canio_listener_deinit(mp_obj_t self_in) { canio_listener_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_listener_deinit(self); @@ -91,6 +95,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(canio_listener_deinit_obj, canio_listener_deini //| def __enter__(self) -> CAN: //| """Returns self, to allow the object to be used in a `with` statement for resource control""" //| ... +//| static mp_obj_t canio_listener_enter(mp_obj_t self_in) { canio_listener_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_listener_check_for_deinit(self); @@ -106,6 +111,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(canio_listener_enter_obj, canio_listener_enter) //| ) -> None: //| """Calls deinit()""" //| ... +//| static mp_obj_t canio_listener_exit(size_t num_args, const mp_obj_t args[]) { canio_listener_obj_t *self = MP_OBJ_TO_PTR(args[0]); common_hal_canio_listener_deinit(self); @@ -116,6 +122,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(canio_listener_exit_obj, 4, 4, canio_ //| timeout: float //| +//| static mp_obj_t canio_listener_timeout_get(mp_obj_t self_in) { canio_listener_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_canio_listener_check_for_deinit(self); diff --git a/shared-bindings/canio/Match.c b/shared-bindings/canio/Match.c index 7594b03ee9..5e44a7ce4e 100644 --- a/shared-bindings/canio/Match.c +++ b/shared-bindings/canio/Match.c @@ -19,6 +19,7 @@ //| the nonzero bits in mask. Otherwise, it matches exactly the given id. //| If extended is true then only extended ids are matched, otherwise //| only standard ids are matched.""" +//| static mp_obj_t canio_match_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_id, ARG_mask, ARG_extended, NUM_ARGS }; @@ -76,6 +77,7 @@ MP_PROPERTY_GETTER(canio_match_mask_obj, //| extended: bool //| """True to match extended ids, False to match standard ides""" //| +//| static mp_obj_t canio_match_extended_get(mp_obj_t self_in) { canio_match_obj_t *self = self_in; diff --git a/shared-bindings/canio/Message.c b/shared-bindings/canio/Message.c index 78665f91d2..c40892b5ed 100644 --- a/shared-bindings/canio/Message.c +++ b/shared-bindings/canio/Message.c @@ -21,6 +21,7 @@ //| In CAN, messages can have a length from 0 to 8 bytes. //| """ //| ... +//| static mp_obj_t canio_message_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_id, ARG_data, ARG_extended, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -91,6 +92,7 @@ MP_PROPERTY_GETSET(canio_message_data_obj, //| extended: bool //| """True if the message's id is an extended id""" //| +//| static mp_obj_t canio_message_extended_get(const mp_obj_t self_in) { canio_message_obj_t *self = self_in; return mp_obj_new_bool(common_hal_canio_message_get_extended(self)); diff --git a/shared-bindings/canio/RemoteTransmissionRequest.c b/shared-bindings/canio/RemoteTransmissionRequest.c index ba936b9a94..966fee7121 100644 --- a/shared-bindings/canio/RemoteTransmissionRequest.c +++ b/shared-bindings/canio/RemoteTransmissionRequest.c @@ -21,6 +21,7 @@ //| In CAN, messages can have a length from 0 to 8 bytes. //| """ //| ... +//| static mp_obj_t canio_remote_transmission_request_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_id, ARG_length, ARG_extended, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -87,6 +88,7 @@ MP_PROPERTY_GETSET(canio_remote_transmission_request_extended_obj, //| length: int //| """The length of the requested message.""" //| +//| static mp_obj_t canio_remote_transmission_request_length_get(const mp_obj_t self_in) { canio_remote_transmission_request_obj_t *self = self_in; return MP_OBJ_NEW_SMALL_INT(common_hal_canio_remote_transmission_request_get_length(self)); diff --git a/shared-bindings/canio/__init__.c b/shared-bindings/canio/__init__.c index 991d37c8d2..c65b119ff2 100644 --- a/shared-bindings/canio/__init__.c +++ b/shared-bindings/canio/__init__.c @@ -42,6 +42,7 @@ //| `this Learn Guide on using it `_. //| """ //| +//| #include "py/obj.h" #include "py/enum.h" @@ -81,6 +82,7 @@ MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, BUS_STATE_OFF); //| occurred recently. It must be restarted before it will send or receive //| packets. This device will neither send or acknowledge packets on the bus.""" //| +//| MAKE_ENUM_MAP(canio_bus_state) { MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_ACTIVE), MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_PASSIVE), diff --git a/shared-bindings/codeop/__init__.c b/shared-bindings/codeop/__init__.c index 6defe6b589..dd675f551e 100644 --- a/shared-bindings/codeop/__init__.c +++ b/shared-bindings/codeop/__init__.c @@ -18,6 +18,7 @@ static const char *get_arg_str(mp_obj_t arg, qstr name) { //| //| from types import CodeType //| +//| //| def compile_command( //| source: str, filename: str = "", symbol: str = "single" @@ -29,6 +30,7 @@ static const char *get_arg_str(mp_obj_t arg, qstr name) { //| In particular, it's important that the code not end with a newline character //| or it is likely to be treated as a complete command.""" //| +//| static mp_obj_t compile_command(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_source, ARG_filename, ARG_symbol }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index 7ca09c7df6..2a3c3415a2 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -23,7 +23,7 @@ //| pin: microcontroller.Pin, //| *, //| edge: Edge = Edge.FALL, -//| pull: Optional[digitalio.Pull] = None +//| pull: Optional[digitalio.Pull] = None, //| ) -> None: //| """Create a Counter object associated with the given pin that counts //| rising- and/or falling-edge transitions. At least one of ``rise`` and ``fall`` must be True. @@ -52,6 +52,7 @@ //| See the pin assignments for your board to see which pins can be used. //| """ //| ... +//| static mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pin, ARG_edge, ARG_pull }; static const mp_arg_t allowed_args[] = { @@ -74,6 +75,7 @@ static mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_arg //| def deinit(self) -> None: //| """Deinitializes the Counter and releases any hardware resources for reuse.""" +//| static mp_obj_t countio_counter_deinit(mp_obj_t self_in) { countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_countio_counter_deinit(self); @@ -89,11 +91,13 @@ static void check_for_deinit(countio_counter_obj_t *self) { //| def __enter__(self) -> Counter: //| """No-op used by Context Managers.""" +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" +//| static mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_countio_counter_deinit(args[0]); @@ -104,6 +108,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(countio_counter___exit___obj, 4, 4, c //| count: int //| """The current count in terms of pulses.""" +//| static mp_obj_t countio_counter_obj_get_count(mp_obj_t self_in) { countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -128,6 +133,7 @@ MP_PROPERTY_GETSET(countio_counter_count_obj, //| def reset(self) -> None: //| """Resets the count back to 0.""" //| +//| static mp_obj_t countio_counter_reset(mp_obj_t self_in) { countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/countio/Edge.c b/shared-bindings/countio/Edge.c index b7ec25078a..9ace6a923f 100644 --- a/shared-bindings/countio/Edge.c +++ b/shared-bindings/countio/Edge.c @@ -20,6 +20,7 @@ MAKE_ENUM_VALUE(countio_edge_type, edge, RISE_AND_FALL, EDGE_RISE_AND_FALL); //| def __init__(self) -> None: //| """Enum-like class to define which signal transitions to count.""" //| ... +//| //| RISE: Edge //| """Count the rising edges.""" //| @@ -32,6 +33,7 @@ MAKE_ENUM_VALUE(countio_edge_type, edge, RISE_AND_FALL, EDGE_RISE_AND_FALL); //| **Limitations:** ``RISE_AND_FALL`` is not available to RP2040 due to hardware limitations. //| """ //| +//| MAKE_ENUM_MAP(countio_edge) { MAKE_ENUM_MAP_ENTRY(edge, RISE), MAKE_ENUM_MAP_ENTRY(edge, FALL), diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 6bbdc68be5..43d389ca05 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -65,6 +65,7 @@ MP_WEAK const mcu_pin_obj_t *common_hal_digitalio_validate_pin(mp_obj_t obj) { //| //| :param ~microcontroller.Pin pin: The pin to control""" //| ... +//| static mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); @@ -80,6 +81,7 @@ static mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type, //| def deinit(self) -> None: //| """Turn off the DigitalInOut and release the pin for other use.""" //| ... +//| static mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) { digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_digitalio_digitalinout_deinit(self); @@ -90,12 +92,14 @@ MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_deinit_obj, digitalio_digitalin //| def __enter__(self) -> DigitalInOut: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t digitalio_digitalinout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_digitalio_digitalinout_deinit(MP_OBJ_TO_PTR(args[0])); @@ -119,6 +123,7 @@ static inline void check_for_deinit(digitalio_digitalinout_obj_t *self) { //| :param ~digitalio.DriveMode drive_mode: drive mode for the output //| """ //| ... +//| static mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_value, ARG_drive_mode }; static const mp_arg_t allowed_args[] = { @@ -156,6 +161,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_output_obj, 1, digit //| switch.pull = digitalio.Pull.UP //| print(switch.value)""" //| ... +//| static mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pull }; static const mp_arg_t allowed_args[] = { @@ -288,6 +294,7 @@ MP_PROPERTY_GETSET(digitalio_digitalio_drive_mode_obj, //| //| :raises AttributeError: if `direction` is :py:data:`~digitalio.Direction.OUTPUT`.""" //| +//| static mp_obj_t digitalio_digitalinout_obj_get_pull(mp_obj_t self_in) { digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/digitalio/Direction.c b/shared-bindings/digitalio/Direction.c index 442d2dcd35..35c3660035 100644 --- a/shared-bindings/digitalio/Direction.c +++ b/shared-bindings/digitalio/Direction.c @@ -25,12 +25,14 @@ //| """Enum-like class to define which direction the digital values are //| going.""" //| ... +//| //| INPUT: Direction //| """Read digital data in""" //| //| OUTPUT: Direction //| """Write digital data out""" //| +//| const mp_obj_type_t digitalio_direction_type; const digitalio_direction_obj_t digitalio_direction_input_obj = { diff --git a/shared-bindings/digitalio/DriveMode.c b/shared-bindings/digitalio/DriveMode.c index 78ced01df2..5fbee20526 100644 --- a/shared-bindings/digitalio/DriveMode.c +++ b/shared-bindings/digitalio/DriveMode.c @@ -13,6 +13,7 @@ //| """Enum-like class to define the drive mode used when outputting //| digital values.""" //| ... +//| //| PUSH_PULL: DriveMode //| """Output both high and low digital values""" //| @@ -20,6 +21,7 @@ //| """Output low digital values but go into high z for digital high. This is //| useful for i2c and other protocols that share a digital line.""" //| +//| const mp_obj_type_t digitalio_drive_mode_type; const digitalio_drive_mode_obj_t digitalio_drive_mode_push_pull_obj = { diff --git a/shared-bindings/digitalio/Pull.c b/shared-bindings/digitalio/Pull.c index 7a02564354..6886699d12 100644 --- a/shared-bindings/digitalio/Pull.c +++ b/shared-bindings/digitalio/Pull.c @@ -14,6 +14,7 @@ //| """Enum-like class to define the pull value, if any, used while reading //| digital values in.""" //| ... +//| //| UP: Pull //| """When the input line isn't being driven the pull up can pull the state //| of the line high so it reads as true.""" @@ -22,6 +23,7 @@ //| """When the input line isn't being driven the pull down can pull the //| state of the line low so it reads as false.""" //| +//| const mp_obj_type_t digitalio_pull_type; const digitalio_pull_obj_t digitalio_pull_up_obj = { diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 4c8fc97345..e543687901 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -39,6 +39,7 @@ //| :param int height: The number of values high //| :param int value_count: The number of possible pixel values.""" //| ... +//| static mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 3, 3, false); uint32_t width = mp_arg_validate_int_range(mp_obj_get_int(all_args[0]), 0, 32767, MP_QSTR_width); @@ -96,6 +97,7 @@ MP_PROPERTY_GETTER(displayio_bitmap_height_obj, //| bits_per_value: int //| """Bits per Pixel of the bitmap. (read only)""" +//| static mp_obj_t displayio_bitmap_obj_get_bits_per_value(mp_obj_t self_in) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); @@ -126,6 +128,7 @@ MP_PROPERTY_GETTER(displayio_bitmap_bits_per_value_obj, //| //| bitmap[0,1] = 3""" //| ... +//| static mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { if (value_obj == mp_const_none) { // delete item @@ -183,6 +186,7 @@ static mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val //| def fill(self, value: int) -> None: //| """Fills the bitmap with the supplied palette index value.""" //| ... +//| static mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -213,6 +217,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_bitmap_fill_obj, displayio_bitmap_obj_fill); //| notified of the "dirty rectangle" that encloses all modified //| pixels.""" //| ... +//| static mp_obj_t displayio_bitmap_obj_dirty(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); @@ -244,6 +249,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_dirty_obj, 0, displayio_bitmap_obj_d //| """Release resources allocated by Bitmap.""" //| ... //| +//| static mp_obj_t displayio_bitmap_obj_deinit(mp_obj_t self_in) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); common_hal_displayio_bitmap_deinit(self); diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 1f973b5a42..e2721cfdef 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -26,6 +26,7 @@ //| :param Colorspace colorspace: The source colorspace, one of the Colorspace constants //| :param bool dither: Adds random noise to dither the output image""" //| ... +//| static mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_dither, ARG_input_colorspace }; @@ -47,6 +48,7 @@ static mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz //| def convert(self, color: int) -> int: //| """Converts the given color to RGB565 according to the Colorspace""" //| ... +//| static mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); @@ -60,6 +62,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_convert_obj, displayio_colorc //| dither: bool //| """When `True` the ColorConverter dithers the output by adding random noise when //| truncating to display bitdepth""" +//| static mp_obj_t displayio_colorconverter_obj_get_dither(mp_obj_t self_in) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_bool(common_hal_displayio_colorconverter_get_dither(self)); @@ -84,6 +87,7 @@ MP_PROPERTY_GETSET(displayio_colorconverter_dither_obj, //| raise an Exception if there is already a selected transparent index. //| //| :param int color: The color to be transparent""" +//| static mp_obj_t displayio_colorconverter_make_transparent(mp_obj_t self_in, mp_obj_t transparent_color_obj) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); @@ -98,6 +102,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_make_transparent_obj, display //| //| :param int color: [IGNORED] Use any value""" //| +//| static mp_obj_t displayio_colorconverter_make_opaque(mp_obj_t self_in, mp_obj_t transparent_color_obj) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/displayio/Colorspace.c b/shared-bindings/displayio/Colorspace.c index f4677b25a9..f6592024fa 100644 --- a/shared-bindings/displayio/Colorspace.c +++ b/shared-bindings/displayio/Colorspace.c @@ -39,6 +39,7 @@ MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, L8, DISPLAYIO_C //| RGB555_SWAPPED: Colorspace //| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555""" //| +//| MAKE_ENUM_MAP(displayio_colorspace) { MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888), MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565), diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 73c3d06988..e5f5f03978 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -25,6 +25,7 @@ //| :param int x: Initial x position within the parent. //| :param int y: Initial y position within the parent.""" //| ... +//| static mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_scale, ARG_x, ARG_y }; static const mp_arg_t allowed_args[] = { @@ -120,6 +121,7 @@ MP_PROPERTY_GETSET(displayio_group_x_obj, //| y: int //| """Y position of the Group in the parent.""" +//| static mp_obj_t displayio_group_obj_get_y(mp_obj_t self_in) { displayio_group_t *self = native_group(self_in); return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_group_get_y(self)); @@ -145,6 +147,7 @@ MP_PROPERTY_GETSET(displayio_group_y_obj, //| ) -> None: //| """Append a layer to the group. It will be drawn above other layers.""" //| ... +//| static mp_obj_t displayio_group_obj_append(mp_obj_t self_in, mp_obj_t layer) { displayio_group_t *self = native_group(self_in); common_hal_displayio_group_insert(self, common_hal_displayio_group_get_len(self), layer); @@ -159,6 +162,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_append_obj, displayio_group_obj_append //| ) -> None: //| """Insert a layer into the group.""" //| ... +//| static mp_obj_t displayio_group_obj_insert(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t layer) { displayio_group_t *self = native_group(self_in); if ((size_t)MP_OBJ_SMALL_INT_VALUE(index_obj) == common_hal_displayio_group_get_len(self)) { @@ -177,6 +181,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(displayio_group_insert_obj, displayio_group_obj_insert //| ) -> int: //| """Returns the index of the first copy of layer. Raises ValueError if not found.""" //| ... +//| static mp_obj_t displayio_group_obj_index(mp_obj_t self_in, mp_obj_t layer) { displayio_group_t *self = native_group(self_in); mp_int_t index = common_hal_displayio_group_index(self, layer); @@ -192,6 +197,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_index_obj, displayio_group_obj_index); //| ) -> Union[vectorio.Circle, vectorio.Rectangle, vectorio.Polygon, Group, TileGrid]: //| """Remove the ith item and return it.""" //| ... +//| static mp_obj_t displayio_group_obj_pop(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_i }; static const mp_arg_t allowed_args[] = { @@ -217,6 +223,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(displayio_group_pop_obj, 1, displayio_group_obj_pop); //| ) -> None: //| """Remove the first copy of layer. Raises ValueError if it is not present.""" //| ... +//| static mp_obj_t displayio_group_obj_remove(mp_obj_t self_in, mp_obj_t layer) { mp_obj_t index = displayio_group_obj_index(self_in, layer); displayio_group_t *self = native_group(self_in); @@ -239,6 +246,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_remove_obj, displayio_group_obj_remove //| def __len__(self) -> int: //| """Returns the number of layers in a Group""" //| ... +//| static mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { displayio_group_t *self = native_group(self_in); uint16_t len = common_hal_displayio_group_get_len(self); @@ -281,6 +289,7 @@ static mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| //| del group[0]""" //| ... +//| static mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { displayio_group_t *self = native_group(self_in); @@ -305,6 +314,7 @@ static mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t valu //| """Sort the members of the group.""" //| ... //| +//| static mp_obj_t displayio_group_obj_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { displayio_group_t *self = native_group(pos_args[0]); mp_obj_t *args = m_new(mp_obj_t, n_args); diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index e15ecd45a9..cd2161fd3b 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -58,6 +58,7 @@ //| of CircuitPython will remove the ability to pass in an opened file. //| """ //| ... +//| static mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_obj_t arg = all_args[0]; @@ -106,6 +107,7 @@ MP_PROPERTY_GETTER(displayio_ondiskbitmap_height_obj, //| bitmap's structure. The pixel shader can be modified (e.g., to set the //| transparent pixel or, for palette shaded images, to update the palette.)""" //| +//| static mp_obj_t displayio_ondiskbitmap_obj_get_pixel_shader(mp_obj_t self_in) { displayio_ondiskbitmap_t *self = MP_OBJ_TO_PTR(self_in); return common_hal_displayio_ondiskbitmap_get_pixel_shader(self); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 528df88ec4..c69c8d11f2 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -25,6 +25,7 @@ //| :param bool dither: When true, dither the RGB color before converting to the display's color space //| """ //| ... +//| // TODO(tannewt): Add support for other color formats. // TODO(tannewt): Add support for 8-bit alpha blending. //| @@ -46,6 +47,7 @@ static mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a //| dither: bool //| """When `True` the Palette dithers the output color by adding random //| noise when truncating to display bitdepth""" +//| static mp_obj_t displayio_palette_obj_get_dither(mp_obj_t self_in) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_bool(common_hal_displayio_palette_get_dither(self)); @@ -69,6 +71,7 @@ MP_PROPERTY_GETSET(displayio_palette_dither_obj, //| def __len__(self) -> int: //| """Returns the number of colors in a Palette""" //| ... +//| static mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); switch (op) { @@ -102,6 +105,7 @@ static mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes //| palette[4] = (10, 20, 30) # set using a tuple of 3 integers""" //| ... +//| static mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item @@ -149,7 +153,10 @@ static mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val return mp_const_none; } -//| def make_transparent(self, palette_index: int) -> None: ... +//| def make_transparent(self, palette_index: int) -> None: +//| """Makes the palette index transparent. The color is ignored.""" +//| ... +//| static mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); @@ -161,7 +168,11 @@ static mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_ } MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_transparent_obj, displayio_palette_obj_make_transparent); -//| def make_opaque(self, palette_index: int) -> None: ... +//| +//| def make_opaque(self, palette_index: int) -> None: +//| """Mark the given palette index as opaque.""" +//| ... +//| static mp_obj_t displayio_palette_obj_make_opaque(mp_obj_t self_in, mp_obj_t palette_index_obj) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); @@ -173,10 +184,12 @@ static mp_obj_t displayio_palette_obj_make_opaque(mp_obj_t self_in, mp_obj_t pal } MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_opaque_obj, displayio_palette_obj_make_opaque); +//| //| def is_transparent(self, palette_index: int) -> bool: //| """Returns `True` if the palette index is transparent. Returns `False` if opaque.""" //| ... //| +//| static mp_obj_t displayio_palette_obj_is_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 9800480b22..99f1699fbe 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -37,7 +37,7 @@ //| tile_height: Optional[int] = None, //| default_tile: int = 0, //| x: int = 0, -//| y: int = 0 +//| y: int = 0, //| ) -> None: //| """Create a TileGrid object. The bitmap is source for 2d pixels. The pixel_shader is used to //| convert the value and its location to a display native pixel color. This may be a simple color @@ -56,6 +56,7 @@ //| :param int default_tile: Default tile index to show. //| :param int x: Initial x position of the left edge within the parent. //| :param int y: Initial y position of the top edge within the parent.""" +//| static mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_bitmap, ARG_pixel_shader, ARG_width, ARG_height, ARG_tile_width, ARG_tile_height, ARG_default_tile, ARG_x, ARG_y }; static const mp_arg_t allowed_args[] = { @@ -275,6 +276,7 @@ MP_PROPERTY_GETSET(displayio_tilegrid_flip_y_obj, //| transpose_xy: bool //| """If true, the TileGrid's axis will be swapped. When combined with mirroring, any 90 degree //| rotation can be achieved along with the corresponding mirrored version.""" +//| static mp_obj_t displayio_tilegrid_obj_get_transpose_xy(mp_obj_t self_in) { displayio_tilegrid_t *self = native_tilegrid(self_in); return mp_obj_new_bool(common_hal_displayio_tilegrid_get_transpose_xy(self)); @@ -296,6 +298,7 @@ MP_PROPERTY_GETSET(displayio_tilegrid_transpose_xy_obj, //| def contains(self, touch_tuple: tuple) -> bool: //| """Returns True if the first two values in ``touch_tuple`` represent an x,y coordinate //| inside the tilegrid rectangle bounds.""" +//| static mp_obj_t displayio_tilegrid_obj_contains(mp_obj_t self_in, mp_obj_t touch_tuple) { displayio_tilegrid_t *self = MP_OBJ_TO_PTR(self_in); @@ -336,6 +339,7 @@ MP_PROPERTY_GETSET(displayio_tilegrid_pixel_shader_obj, //| bitmap: Union[Bitmap, OnDiskBitmap] //| """The bitmap of the tilegrid.""" +//| static mp_obj_t displayio_tilegrid_obj_get_bitmap(mp_obj_t self_in) { displayio_tilegrid_t *self = native_tilegrid(self_in); return common_hal_displayio_tilegrid_get_bitmap(self); @@ -403,6 +407,7 @@ MP_PROPERTY_GETSET(displayio_tilegrid_bitmap_obj, //| grid[0,0] = 10""" //| ... //| +//| static mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { displayio_tilegrid_t *self = native_tilegrid(self_in); diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index acd48f5ea3..39d8af37f2 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -43,6 +43,7 @@ //| refer to `this Learn guide //| `_. //| """ +//| //| CIRCUITPYTHON_TERMINAL: Group //| """The `displayio.Group` that is the displayed serial terminal (REPL).""" @@ -53,6 +54,7 @@ //| from fourwire import FourWire //| from i2cdisplaybus import I2CDisplayBus as I2CDisplay //| +//| //| def release_displays() -> None: //| """Releases any actively used displays so their buses and pins can be used again. This will also @@ -63,6 +65,7 @@ //| initialization so the display is active as long as possible.""" //| ... //| +//| static mp_obj_t displayio_release_displays(void) { common_hal_displayio_release_displays(); return mp_const_none; diff --git a/shared-bindings/dotclockframebuffer/DotClockFramebuffer.c b/shared-bindings/dotclockframebuffer/DotClockFramebuffer.c index 6b7aeefcfb..faa0c21b09 100644 --- a/shared-bindings/dotclockframebuffer/DotClockFramebuffer.c +++ b/shared-bindings/dotclockframebuffer/DotClockFramebuffer.c @@ -93,6 +93,7 @@ //| #:param int overscan_right: Allocate additional non-visible columns right of the last display column //| #:param int overscan_bottom: Allocate additional non-visible rows below the last display row //| ... +//| static mp_obj_t dotclockframebuffer_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_de, ARG_vsync, ARG_hsync, ARG_dclk, ARG_red, ARG_green, ARG_blue, ARG_frequency, ARG_width, ARG_height, @@ -176,6 +177,7 @@ static void check_for_deinit(dotclockframebuffer_framebuffer_obj_t *self) { //| If this function is not called, the results are unpredictable; updates may be partially shown. //| """ //| ... +//| static mp_obj_t dotclockframebuffer_framebuffer_refresh(mp_obj_t self_in) { dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in; check_for_deinit(self); @@ -257,6 +259,7 @@ MP_PROPERTY_GETTER(dotclockframebuffer_framebuffer_row_stride_obj, //| //| On Espressif this value is **guaranteed** to be a multiple of the 2 (i.e., it is a whole number of pixels)""" //| +//| static mp_obj_t dotclockframebuffer_framebuffer_get_first_pixel_offset(mp_obj_t self_in) { dotclockframebuffer_framebuffer_obj_t *self = (dotclockframebuffer_framebuffer_obj_t *)self_in; check_for_deinit(self); diff --git a/shared-bindings/dotclockframebuffer/__init__.c b/shared-bindings/dotclockframebuffer/__init__.c index 7c24ff7fc7..b8dbf8c189 100644 --- a/shared-bindings/dotclockframebuffer/__init__.c +++ b/shared-bindings/dotclockframebuffer/__init__.c @@ -17,6 +17,7 @@ //| //| Length = typing.Literal[1, 2] //| +//| //| def ioexpander_send_init_sequence( //| bus: busio.I2C, //| init_sequence: ReadableBuffer, @@ -61,6 +62,7 @@ //| :param Optional[ReadableBuffer] i2c_init_sequence: An initialization sequence to send to the I2C expander //| """ //| +//| static mp_obj_t ioexpander_send_init_sequence(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bus, ARG_init_sequence, ARG_i2c_address, ARG_gpio_address, ARG_gpio_data_len, ARG_gpio_data, ARG_cs_bit, ARG_mosi_bit, ARG_clk_bit, ARG_reset_bit, ARG_i2c_init_sequence, NUM_ARGS }; diff --git a/shared-bindings/dualbank/__init__.c b/shared-bindings/dualbank/__init__.c index 2f7f5776d6..2c00a5b010 100644 --- a/shared-bindings/dualbank/__init__.c +++ b/shared-bindings/dualbank/__init__.c @@ -44,8 +44,10 @@ //| dualbank.flash(buffer, offset) //| dualbank.switch() //| """ +//| //| ... //| +//| #if CIRCUITPY_STORAGE_EXTEND static void raise_error_if_storage_extended(void) { @@ -65,6 +67,7 @@ static void raise_error_if_storage_extended(void) { //| """ //| ... //| +//| static mp_obj_t dualbank_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_offset }; static const mp_arg_t allowed_args[] = { @@ -98,6 +101,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(dualbank_flash_obj, 0, dualbank_flash); //| """ //| ... //| +//| static mp_obj_t dualbank_switch(void) { #if CIRCUITPY_STORAGE_EXTEND raise_error_if_storage_extended(); diff --git a/shared-bindings/epaperdisplay/EPaperDisplay.c b/shared-bindings/epaperdisplay/EPaperDisplay.c index ea7296920e..10291b7d99 100644 --- a/shared-bindings/epaperdisplay/EPaperDisplay.c +++ b/shared-bindings/epaperdisplay/EPaperDisplay.c @@ -20,6 +20,7 @@ //| from busdisplay import _DisplayBus //| +//| //| class EPaperDisplay: //| """Manage updating an epaper display over a display bus //| @@ -62,7 +63,7 @@ //| advanced_color_epaper: bool = False, //| two_byte_sequence_length: bool = False, //| start_up_time: float = 0, -//| address_little_endian: bool = False +//| address_little_endian: bool = False, //| ) -> None: //| """Create a EPaperDisplay object on the given display bus (`fourwire.FourWire` or `paralleldisplaybus.ParallelBus`). //| @@ -107,6 +108,7 @@ //| :param bool address_little_endian: Send the least significant byte (not bit) of multi-byte addresses first. Ignored when ram is addressed with one byte //| """ //| ... +//| static mp_obj_t epaperdisplay_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_display_bus, ARG_start_sequence, ARG_stop_sequence, ARG_width, ARG_height, ARG_ram_width, ARG_ram_height, ARG_colstart, ARG_rowstart, ARG_rotation, @@ -238,6 +240,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(epaperdisplay_epaperdisplay_show_obj, epaperdisplay_ep //| ) -> None: //| """Updates the ``start_sequence`` and ``seconds_per_frame`` parameters to enable //| varying the refresh mode of the display.""" +//| static mp_obj_t epaperdisplay_epaperdisplay_update_refresh_mode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_start_sequence, ARG_seconds_per_frame }; static const mp_arg_t allowed_args[] = { @@ -263,6 +266,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(epaperdisplay_epaperdisplay_update_refresh_mode_obj, //| """Refreshes the display immediately or raises an exception if too soon. Use //| ``time.sleep(display.time_to_refresh)`` to sleep until a refresh can occur.""" //| ... +//| static mp_obj_t epaperdisplay_epaperdisplay_obj_refresh(mp_obj_t self_in) { epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); bool ok = common_hal_epaperdisplay_epaperdisplay_refresh(self); @@ -360,6 +364,7 @@ MP_PROPERTY_GETTER(epaperdisplay_epaperdisplay_bus_obj, //| If the root group is set to ``None``, no output will be shown. //| """ //| +//| static mp_obj_t epaperdisplay_epaperdisplay_obj_get_root_group(mp_obj_t self_in) { epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); return common_hal_epaperdisplay_epaperdisplay_get_root_group(self); diff --git a/shared-bindings/epaperdisplay/__init__.c b/shared-bindings/epaperdisplay/__init__.c index 1b18212a35..eff31cb01b 100644 --- a/shared-bindings/epaperdisplay/__init__.c +++ b/shared-bindings/epaperdisplay/__init__.c @@ -13,9 +13,7 @@ #include "shared-bindings/epaperdisplay/__init__.h" #include "shared-bindings/epaperdisplay/EPaperDisplay.h" -//| """Displays a `displayio` object tree on an e-paper display -//| -//| """ +//| """Displays a `displayio` object tree on an e-paper display""" static const mp_rom_map_elem_t epaperdisplay_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, diff --git a/shared-bindings/floppyio/__init__.c b/shared-bindings/floppyio/__init__.c index 09f2dc0e86..09034b4675 100644 --- a/shared-bindings/floppyio/__init__.c +++ b/shared-bindings/floppyio/__init__.c @@ -40,6 +40,7 @@ //| """ //| ... //| +//| static mp_obj_t floppyio_flux_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { #if CIRCUITPY_DIGITALIO enum { ARG_buffer, ARG_data, ARG_index, ARG_index_wait }; @@ -119,6 +120,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(floppyio_flux_readinto_obj, 0, floppyio_flux_readinto //| """ //| ... //| +//| static mp_obj_t floppyio_mfm_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_flux, ARG_t2_max, ARG_t3_max, ARG_validity, ARG_clear_validity }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index 9d3f30675b..4969aed637 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -17,6 +17,7 @@ //| from typing_extensions import Protocol # for compat with python < 3.8 //| +//| //| class FontProtocol(Protocol): //| """A protocol shared by `BuiltinFont` and classes in ``adafruit_bitmap_font``""" //| @@ -34,6 +35,7 @@ //| If the code point is not present in the font, `None` is returned.""" //| pass //| +//| //| class BuiltinFont: //| """A font built into CircuitPython""" @@ -43,11 +45,13 @@ //| `Adafruit_CircuitPython_Bitmap_Font `_ //| library for dynamically loaded fonts.""" //| ... +//| //| bitmap: displayio.Bitmap //| """Bitmap containing all font glyphs starting with ASCII and followed by unicode. Use //| `get_glyph` in most cases. This is useful for use with `displayio.TileGrid` and //| `terminalio.Terminal`.""" +//| static mp_obj_t fontio_builtinfont_obj_get_bitmap(mp_obj_t self_in) { fontio_builtinfont_t *self = MP_OBJ_TO_PTR(self_in); return common_hal_fontio_builtinfont_get_bitmap(self); @@ -60,6 +64,7 @@ MP_PROPERTY_GETTER(fontio_builtinfont_bitmap_obj, //| def get_bounding_box(self) -> Tuple[int, int]: //| """Returns the maximum bounds of all glyphs in the font in a tuple of two values: width, height.""" //| ... +//| static mp_obj_t fontio_builtinfont_obj_get_bounding_box(mp_obj_t self_in) { fontio_builtinfont_t *self = MP_OBJ_TO_PTR(self_in); @@ -72,6 +77,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(fontio_builtinfont_get_bounding_box_obj, fontio_builti //| """Returns a `fontio.Glyph` for the given codepoint or None if no glyph is available.""" //| ... //| +//| static mp_obj_t fontio_builtinfont_obj_get_glyph(mp_obj_t self_in, mp_obj_t codepoint_obj) { fontio_builtinfont_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/fontio/Glyph.c b/shared-bindings/fontio/Glyph.c index 009fcb0606..5651cb3d0f 100644 --- a/shared-bindings/fontio/Glyph.c +++ b/shared-bindings/fontio/Glyph.c @@ -34,6 +34,7 @@ //| :param shift_y: the y difference to the next glyph""" //| ... //| +//| const mp_obj_namedtuple_type_t fontio_glyph_type = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_Glyph), .n_fields = 8, diff --git a/shared-bindings/fourwire/FourWire.c b/shared-bindings/fourwire/FourWire.c index bddd772c2e..4b08c00566 100644 --- a/shared-bindings/fourwire/FourWire.c +++ b/shared-bindings/fourwire/FourWire.c @@ -31,7 +31,7 @@ //| reset: Optional[microcontroller.Pin] = None, //| baudrate: int = 24000000, //| polarity: int = 0, -//| phase: int = 0 +//| phase: int = 0, //| ) -> None: //| """Create a FourWire object associated with the given pins. //| @@ -54,6 +54,7 @@ //| :param int phase: the edge of the clock that data is captured. First (0) //| or second (1). Rising or falling depends on clock polarity.""" //| ... +//| static mp_obj_t fourwire_fourwire_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_spi_bus, ARG_command, ARG_chip_select, ARG_reset, ARG_baudrate, ARG_polarity, ARG_phase }; static const mp_arg_t allowed_args[] = { @@ -89,6 +90,7 @@ static mp_obj_t fourwire_fourwire_make_new(const mp_obj_type_t *type, size_t n_a //| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin //| is available.""" //| ... +//| static mp_obj_t fourwire_fourwire_obj_reset(mp_obj_t self_in) { fourwire_fourwire_obj_t *self = self_in; @@ -106,6 +108,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(fourwire_fourwire_reset_obj, fourwire_fourwire_obj_res //| vertical scroll, set via ``send`` may or may not be reset once the code is done.""" //| ... //| +//| static mp_obj_t fourwire_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_command, ARG_data, ARG_toggle_every_byte }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/fourwire/__init__.c b/shared-bindings/fourwire/__init__.c index 34542db97a..659d9482cb 100644 --- a/shared-bindings/fourwire/__init__.c +++ b/shared-bindings/fourwire/__init__.c @@ -13,9 +13,7 @@ #include "shared-bindings/fourwire/__init__.h" #include "shared-bindings/fourwire/FourWire.h" -//| """Connects to a BusDisplay over a four wire bus -//| -//| """ +//| """Connects to a BusDisplay over a four wire bus""" static const mp_rom_map_elem_t fourwire_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_fourwire) }, diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 29242d3a63..71ce18a1b4 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -31,7 +31,7 @@ //| framebuffer: circuitpython_typing.FrameBuffer, //| *, //| rotation: int = 0, -//| auto_refresh: bool = True +//| auto_refresh: bool = True, //| ) -> None: //| """Create a Display object with the given framebuffer (a buffer, array, ulab.array, etc) //| @@ -40,6 +40,7 @@ //| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270) //| """ //| ... +//| static mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_framebuffer, ARG_rotation, ARG_auto_refresh, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -89,7 +90,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_show_obj, framebuffer //| self, //| *, //| target_frames_per_second: Optional[int] = None, -//| minimum_frames_per_second: int = 0 +//| minimum_frames_per_second: int = 0, //| ) -> bool: //| """When auto_refresh is off, and :py:attr:`target_frames_per_second` is not `None` this waits //| for the target frame rate and then refreshes the display, @@ -111,6 +112,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_show_obj, framebuffer //| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second. //| """ //| ... +//| static mp_obj_t framebufferio_framebufferdisplay_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second }; static const mp_arg_t allowed_args[] = { @@ -232,6 +234,7 @@ MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_rotation_obj, //| framebuffer: circuitpython_typing.FrameBuffer //| """The framebuffer being used by the display""" +//| static mp_obj_t framebufferio_framebufferdisplay_obj_get_framebuffer(mp_obj_t self_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); return common_hal_framebufferio_framebufferdisplay_get_framebuffer(self); @@ -249,6 +252,7 @@ MP_PROPERTY_GETTER(framebufferio_framebufferframebuffer_obj, //| :param ~circuitpython_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) { enum { ARG_y, ARG_buffer }; static const mp_arg_t allowed_args[] = { @@ -309,6 +313,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_fill_row_obj, 1, fra //| If the root group is set to ``None``, no output will be shown. //| """ //| +//| static mp_obj_t framebufferio_framebufferdisplay_obj_get_root_group(mp_obj_t self_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); return common_hal_framebufferio_framebufferdisplay_get_root_group(self); diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 6d76d00d0f..6ab8966468 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -49,6 +49,7 @@ //| # as the value. //| frequency.clear()""" //| ... +//| static mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_check_num(n_args, n_kw, 1, 1, true); @@ -73,6 +74,7 @@ static mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size //| def deinit(self) -> None: //| """Deinitialises the FrequencyIn and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t frequencyio_frequencyin_deinit(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_frequencyio_frequencyin_deinit(self); @@ -89,12 +91,14 @@ static void check_for_deinit(frequencyio_frequencyin_obj_t *self) { //| def __enter__(self) -> FrequencyIn: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t frequencyio_frequencyin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_frequencyio_frequencyin_deinit(args[0]); @@ -105,6 +109,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(frequencyio_frequencyin___exit___obj, //| def pause(self) -> None: //| """Pause frequency capture.""" //| ... +//| static mp_obj_t frequencyio_frequencyin_obj_pause(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -117,6 +122,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_pause_obj, frequencyio_frequen //| def resume(self) -> None: //| """Resumes frequency capture.""" //| ... +//| static mp_obj_t frequencyio_frequencyin_obj_resume(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -129,6 +135,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_resume_obj, frequencyio_freque //| def clear(self) -> None: //| """Clears the last detected frequency capture value.""" //| ... +//| static mp_obj_t frequencyio_frequencyin_obj_clear(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -146,6 +153,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_clear_obj, frequencyio_frequen //| //| .. note:: When setting a new ``capture_period``, all previous capture information is //| cleared with a call to ``clear()``.""" +//| static mp_obj_t frequencyio_frequencyin_obj_get_capture_period(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -171,6 +179,7 @@ MP_PROPERTY_GETSET(frequencyio_frequencyin_capture_period_obj, //| """Returns the value of the last frequency captured.""" //| ... //| +//| static mp_obj_t frequencyio_frequencyin_obj_get_value(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/getpass/__init__.c b/shared-bindings/getpass/__init__.c index b779311f5f..54a860aa56 100644 --- a/shared-bindings/getpass/__init__.c +++ b/shared-bindings/getpass/__init__.c @@ -12,8 +12,10 @@ //| This module provides a way to get input from user without echoing it. //| //| """ +//| //| ... //| +//| //| def getpass(prompt: Optional[str] = "Password: ", stream: Optional[io.FileIO] = None) -> str: //| """Prompt the user without echoing. @@ -24,6 +26,7 @@ //| """ //| ... //| +//| static mp_obj_t getpass_getpass(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_prompt, ARG_stream }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/gifio/GifWriter.c b/shared-bindings/gifio/GifWriter.c index c1a2c69c59..79f65404cb 100644 --- a/shared-bindings/gifio/GifWriter.c +++ b/shared-bindings/gifio/GifWriter.c @@ -33,6 +33,7 @@ //| :param dither: If True, and the image is in color, a simple ordered dither is applied. //| """ //| ... +//| static mp_obj_t gifio_gifwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_file, ARG_width, ARG_height, ARG_colorspace, ARG_loop, ARG_dither }; static const mp_arg_t allowed_args[] = { @@ -71,12 +72,14 @@ static mp_obj_t gifio_gifwriter_make_new(const mp_obj_type_t *type, size_t n_arg //| def __enter__(self) -> GifWriter: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t gifio_gifwriter___exit__(size_t n_args, const mp_obj_t *args) { gifio_gifwriter_t *self = MP_OBJ_TO_PTR(args[0]); shared_module_gifio_gifwriter_deinit(self); @@ -87,6 +90,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gifio_gifwriter___exit___obj, 4, 4, gifio_gi //| def deinit(self) -> None: //| """Close the underlying file.""" //| ... +//| static mp_obj_t gifio_gifwriter_deinit(mp_obj_t self_in) { gifio_gifwriter_t *self = MP_OBJ_TO_PTR(self_in); shared_module_gifio_gifwriter_deinit(self); @@ -102,6 +106,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(gifio_gifwriter_deinit_obj, gifio_gifwriter_deinit); //| """ //| ... //| +//| static mp_obj_t gifio_gifwriter_add_frame(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_delay }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index 10913233f8..5d2001eec8 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -101,6 +101,7 @@ //| is not limited but images that are too large will cause a memory exception. //| """ //| ... +//| static mp_obj_t gifio_ondiskgif_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_filename, ARG_use_palette, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -135,12 +136,14 @@ static void check_for_deinit(gifio_ondiskgif_t *self) { //| def __enter__(self) -> OnDiskGif: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the GIF when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t gifio_ondiskgif_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_gifio_ondiskgif_deinit(args[0]); @@ -192,6 +195,7 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_bitmap_obj, //| palette: Optional[displayio.Palette] //| """The palette for the current frame if it exists.""" +//| static mp_obj_t gifio_ondiskgif_obj_get_palette(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); @@ -206,6 +210,7 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_palette_obj, //| def next_frame(self) -> float: //| """Loads the next frame. Returns expected delay before the next frame in seconds.""" +//| static mp_obj_t gifio_ondiskgif_obj_next_frame(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); @@ -277,6 +282,7 @@ MP_PROPERTY_GETTER(gifio_ondiskgif_max_delay_obj, //| """Release resources allocated by OnDiskGif.""" //| ... //| +//| static mp_obj_t gifio_ondiskgif_obj_deinit(mp_obj_t self_in) { gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in); common_hal_gifio_ondiskgif_deinit(self); diff --git a/shared-bindings/gifio/__init__.c b/shared-bindings/gifio/__init__.c index 057d18ce82..a8a09dc08d 100644 --- a/shared-bindings/gifio/__init__.c +++ b/shared-bindings/gifio/__init__.c @@ -10,8 +10,7 @@ #include "shared-bindings/gifio/OnDiskGif.h" #include "shared-bindings/util.h" -//| """Access GIF-format images -//| """ +//| """Access GIF-format images""" static const mp_rom_map_elem_t gifio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gifio) }, { MP_OBJ_NEW_QSTR(MP_QSTR_GifWriter), MP_ROM_PTR(&gifio_gifwriter_type)}, diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c index 39d6aba682..95c3ed975d 100644 --- a/shared-bindings/gnss/GNSS.c +++ b/shared-bindings/gnss/GNSS.c @@ -36,6 +36,7 @@ //| //| :param system: satellite system to use""" //| ... +//| static mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { gnss_obj_t *self = mp_obj_malloc(gnss_obj_t, &gnss_type); enum { ARG_system }; @@ -69,6 +70,7 @@ static mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, size_t n //| def deinit(self) -> None: //| """Turn off the GNSS.""" //| ... +//| static mp_obj_t gnss_obj_deinit(mp_obj_t self_in) { gnss_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_gnss_deinit(self); @@ -85,6 +87,7 @@ static void check_for_deinit(gnss_obj_t *self) { //| def update(self) -> None: //| """Update GNSS positioning information.""" //| ... +//| static mp_obj_t gnss_obj_update(mp_obj_t self_in) { gnss_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -147,6 +150,7 @@ MP_PROPERTY_GETTER(gnss_timestamp_obj, //| fix: PositionFix //| """Fix mode.""" //| +//| static mp_obj_t gnss_obj_get_fix(mp_obj_t self_in) { gnss_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/gnss/PositionFix.c b/shared-bindings/gnss/PositionFix.c index cd108a612c..1b85befd89 100644 --- a/shared-bindings/gnss/PositionFix.c +++ b/shared-bindings/gnss/PositionFix.c @@ -9,6 +9,7 @@ //| //| def __init__(self) -> None: //| """Enum-like class to define the position fix mode.""" +//| //| INVALID: PositionFix //| """No measurement.""" //| @@ -18,6 +19,7 @@ //| FIX_3D: PositionFix //| """3D fix.""" //| +//| const mp_obj_type_t gnss_positionfix_type; const gnss_positionfix_obj_t gnss_positionfix_invalid_obj = { diff --git a/shared-bindings/gnss/SatelliteSystem.c b/shared-bindings/gnss/SatelliteSystem.c index 0c870cbf81..1d6168f61f 100644 --- a/shared-bindings/gnss/SatelliteSystem.c +++ b/shared-bindings/gnss/SatelliteSystem.c @@ -9,6 +9,7 @@ //| //| def __init__(self) -> None: //| """Enum-like class to define the satellite system type.""" +//| //| GPS: SatelliteSystem //| """Global Positioning System.""" //| @@ -24,6 +25,7 @@ //| QZSS_L1S: SatelliteSystem //| """Quasi-Zenith Satellite System L1S.""" //| +//| const mp_obj_type_t gnss_satellitesystem_type; const gnss_satellitesystem_obj_t gnss_satellitesystem_gps_obj = { diff --git a/shared-bindings/hashlib/Hash.c b/shared-bindings/hashlib/Hash.c index 68930b137e..a82698432a 100644 --- a/shared-bindings/hashlib/Hash.c +++ b/shared-bindings/hashlib/Hash.c @@ -18,6 +18,7 @@ //| digest_size: int //| """Digest size in bytes""" +//| static mp_obj_t hashlib_hash_digest_size_get(mp_obj_t self_in) { mp_check_self(mp_obj_is_type(self_in, &hashlib_hash_type)); hashlib_hash_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -32,6 +33,7 @@ MP_PROPERTY_GETTER(hashlib_hash_digest_size_obj, (mp_obj_t)&hashlib_hash_digest_ //| :param ~circuitpython_typing.ReadableBuffer data: Update the hash from data in this buffer //| """ //| ... +//| mp_obj_t hashlib_hash_update(mp_obj_t self_in, mp_obj_t buf_in) { mp_check_self(mp_obj_is_type(self_in, &hashlib_hash_type)); hashlib_hash_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -48,6 +50,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(hashlib_hash_update_obj, hashlib_hash_update); //| """Returns the current digest as bytes() with a length of `hashlib.Hash.digest_size`.""" //| ... //| +//| static mp_obj_t hashlib_hash_digest(mp_obj_t self_in) { mp_check_self(mp_obj_is_type(self_in, &hashlib_hash_type)); hashlib_hash_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/hashlib/__init__.c b/shared-bindings/hashlib/__init__.c index fa3b1b1872..bfe19dee10 100644 --- a/shared-bindings/hashlib/__init__.c +++ b/shared-bindings/hashlib/__init__.c @@ -17,6 +17,7 @@ //| |see_cpython_module| :mod:`cpython:hashlib`. //| """ //| +//| //| def new(name: str, data: bytes = b"") -> hashlib.Hash: //| """Returns a Hash object setup for the named algorithm. Raises ValueError when the named //| algorithm is unsupported. @@ -25,6 +26,7 @@ //| :rtype: hashlib.Hash""" //| ... //| +//| static mp_obj_t hashlib_new(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_name, ARG_data }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/i2cdisplaybus/I2CDisplayBus.c b/shared-bindings/i2cdisplaybus/I2CDisplayBus.c index 065baa782f..d6e0763052 100644 --- a/shared-bindings/i2cdisplaybus/I2CDisplayBus.c +++ b/shared-bindings/i2cdisplaybus/I2CDisplayBus.c @@ -26,7 +26,7 @@ //| i2c_bus: busio.I2C, //| *, //| device_address: int, -//| reset: Optional[microcontroller.Pin] = None +//| reset: Optional[microcontroller.Pin] = None, //| ) -> None: //| """Create a I2CDisplayBus object associated with the given I2C bus and reset pin. //| @@ -40,6 +40,7 @@ //| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used //| """ //| ... +//| static mp_obj_t i2cdisplaybus_i2cdisplaybus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_i2c_bus, ARG_device_address, ARG_reset }; static const mp_arg_t allowed_args[] = { @@ -65,6 +66,7 @@ static mp_obj_t i2cdisplaybus_i2cdisplaybus_make_new(const mp_obj_type_t *type, //| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin //| is available.""" //| ... +//| static mp_obj_t i2cdisplaybus_i2cdisplaybus_obj_reset(mp_obj_t self_in) { i2cdisplaybus_i2cdisplaybus_obj_t *self = self_in; @@ -80,6 +82,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(i2cdisplaybus_i2cdisplaybus_reset_obj, i2cdisplaybus_i //| vertical scroll, set via ``send`` may or may not be reset once the code is done.""" //| ... //| +//| static mp_obj_t i2cdisplaybus_i2cdisplaybus_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = mp_obj_get_int(command_obj); mp_arg_validate_int_range(command_int, 0, 255, MP_QSTR_command); diff --git a/shared-bindings/i2cdisplaybus/__init__.c b/shared-bindings/i2cdisplaybus/__init__.c index 45be89668f..dc25571758 100644 --- a/shared-bindings/i2cdisplaybus/__init__.c +++ b/shared-bindings/i2cdisplaybus/__init__.c @@ -13,9 +13,7 @@ #include "shared-bindings/i2cdisplaybus/__init__.h" #include "shared-bindings/i2cdisplaybus/I2CDisplayBus.h" -//| """Communicates to a display IC over I2C -//| -//| """ +//| """Communicates to a display IC over I2C""" static const mp_rom_map_elem_t i2cdisplaybus_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_i2cdisplaybus) }, diff --git a/shared-bindings/i2ctarget/I2CTarget.c b/shared-bindings/i2ctarget/I2CTarget.c index b58ef48832..b2a1ea03f4 100644 --- a/shared-bindings/i2ctarget/I2CTarget.c +++ b/shared-bindings/i2ctarget/I2CTarget.c @@ -48,6 +48,7 @@ static mp_obj_t mp_obj_new_i2ctarget_i2c_target_request(i2ctarget_i2c_target_obj //| :type addresses: list[int] //| :param bool smbus: Use SMBUS timings if the hardware supports it""" //| ... +//| static mp_obj_t i2ctarget_i2c_target_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { i2ctarget_i2c_target_obj_t *self = mp_obj_malloc_with_finaliser(i2ctarget_i2c_target_obj_t, &i2ctarget_i2c_target_type); enum { ARG_scl, ARG_sda, ARG_addresses, ARG_smbus }; @@ -84,6 +85,7 @@ static mp_obj_t i2ctarget_i2c_target_make_new(const mp_obj_type_t *type, size_t //| def deinit(self) -> None: //| """Releases control of the underlying hardware so other classes can use it.""" //| ... +//| static mp_obj_t i2ctarget_i2c_target_obj_deinit(mp_obj_t self_in) { i2ctarget_i2c_target_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_i2ctarget_i2c_target_deinit(self); @@ -100,12 +102,14 @@ static void check_for_deinit(i2ctarget_i2c_target_obj_t *self) { //| def __enter__(self) -> I2CTarget: //| """No-op used in Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware on context exit. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t i2ctarget_i2c_target_obj___exit__(size_t n_args, const mp_obj_t *args) { i2ctarget_i2c_target_obj_t *self = MP_OBJ_TO_PTR(args[0]); common_hal_i2ctarget_i2c_target_deinit(self); @@ -120,6 +124,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(i2ctarget_i2c_target___exit___obj, 4, //| :return: I2CTargetRequest or None if timeout=-1 and there's no request //| :rtype: ~i2ctarget.I2CTargetRequest""" //| +//| static mp_obj_t i2ctarget_i2c_target_request(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { i2ctarget_i2c_target_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); @@ -216,6 +221,7 @@ MP_DEFINE_CONST_OBJ_TYPE( //| :param address: I2C address //| :param is_read: True if the main target is requesting data //| :param is_restart: Repeated Start Condition""" +//| static mp_obj_t i2ctarget_i2c_target_request_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 4, 4, false); return mp_obj_new_i2ctarget_i2c_target_request(args[0], mp_obj_get_int(args[1]), mp_obj_is_true(args[2]), mp_obj_is_true(args[3])); @@ -224,11 +230,13 @@ static mp_obj_t i2ctarget_i2c_target_request_make_new(const mp_obj_type_t *type, //| def __enter__(self) -> I2CTargetRequest: //| """No-op used in Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Close the request.""" //| ... +//| static mp_obj_t i2ctarget_i2c_target_request_obj___exit__(size_t n_args, const mp_obj_t *args) { i2ctarget_i2c_target_request_obj_t *self = MP_OBJ_TO_PTR(args[0]); check_for_deinit(self->target); @@ -260,6 +268,7 @@ MP_DEFINE_CONST_PROP_GET(i2ctarget_i2c_target_request_is_read_obj, i2ctarget_i2c //| is_restart: bool //| """Is Repeated Start Condition.""" +//| static mp_obj_t i2ctarget_i2c_target_request_get_is_restart(mp_obj_t self_in) { i2ctarget_i2c_target_request_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self->target); @@ -276,6 +285,7 @@ MP_DEFINE_CONST_PROP_GET(i2ctarget_i2c_target_request_is_restart_obj, i2ctarget_ //| :param ack: Whether or not to send an ACK after the n'th byte //| :return: Bytes read""" //| ... +//| static mp_obj_t i2ctarget_i2c_target_request_read(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { i2ctarget_i2c_target_request_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self->target); @@ -334,6 +344,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(i2ctarget_i2c_target_request_read_obj, 1, i2ctarget_i //| :param ~circuitpython_typing.ReadableBuffer buffer: Write out the data in this buffer //| :return: Number of bytes written""" //| ... +//| static mp_obj_t i2ctarget_i2c_target_request_write(mp_obj_t self_in, mp_obj_t buf_in) { i2ctarget_i2c_target_request_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self->target); @@ -368,6 +379,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(i2ctarget_i2c_target_request_write_obj, i2ctarg //| :param ack: Whether to send an ACK or NACK""" //| ... //| +//| static mp_obj_t i2ctarget_i2c_target_request_ack(uint n_args, const mp_obj_t *args) { i2ctarget_i2c_target_request_obj_t *self = MP_OBJ_TO_PTR(args[0]); check_for_deinit(self->target); diff --git a/shared-bindings/imagecapture/ParallelImageCapture.c b/shared-bindings/imagecapture/ParallelImageCapture.c index d1964c7175..02c58e8ee9 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.c +++ b/shared-bindings/imagecapture/ParallelImageCapture.c @@ -34,6 +34,7 @@ //| :param microcontroller.Pin href: The horizontal reference input, which is high whenever the camera is transmitting valid pixel information. //| """ //| ... +//| static mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_data_pins, ARG_clock, ARG_vsync, ARG_href, NUM_ARGS }; @@ -68,6 +69,7 @@ static mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t * //| //| This will stop a continuous-mode capture, if one is in progress.""" //| ... +//| static mp_obj_t imagecapture_parallelimagecapture_capture(mp_obj_t self_in, mp_obj_t buffer) { imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; common_hal_imagecapture_parallelimagecapture_singleshot_capture(self, buffer); @@ -88,6 +90,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(imagecapture_parallelimagecapture_capture_obj, //| `ParallelImageCapture` object keeps references to ``buffer1`` and //| ``buffer2``, so the objects will not be garbage collected.""" //| ... +//| static mp_obj_t imagecapture_parallelimagecapture_continuous_capture_start(mp_obj_t self_in, mp_obj_t buffer1, mp_obj_t buffer2) { imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; common_hal_imagecapture_parallelimagecapture_continuous_capture_start(self, buffer1, buffer2); @@ -99,6 +102,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(imagecapture_parallelimagecapture_continuous_ca //| def continuous_capture_get_frame(self) -> WriteableBuffer: //| """Return the next available frame, one of the two buffers passed to `continuous_capture_start`""" //| ... +//| static mp_obj_t imagecapture_parallelimagecapture_continuous_capture_get_frame(mp_obj_t self_in) { imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; return common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(self); @@ -114,6 +118,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_ca //| references to the buffers passed to `continuous_capture_start`, //| potentially allowing the objects to be garbage collected.""" //| ... +//| static mp_obj_t imagecapture_parallelimagecapture_continuous_capture_stop(mp_obj_t self_in) { imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(self); @@ -128,6 +133,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_ca //| def deinit(self) -> None: //| """Deinitialize this instance""" //| ... +//| static mp_obj_t imagecapture_parallelimagecapture_deinit(mp_obj_t self_in) { imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; common_hal_imagecapture_parallelimagecapture_deinit(self); @@ -139,6 +145,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_deinit_obj, i //| def __enter__(self) -> ParallelImageCapture: //| """No-op used in Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: @@ -146,6 +153,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_deinit_obj, i //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... //| +//| static mp_obj_t imagecapture_parallelimagecapture___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_imagecapture_parallelimagecapture_deinit(args[0]); diff --git a/shared-bindings/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index bf18eda0f7..5aab02e9f5 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -24,6 +24,7 @@ //| //| The value itself can either be bytes or a string formatted address.""" //| ... +//| static mp_obj_t ipaddress_ipv4address_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_address }; static const mp_arg_t allowed_args[] = { @@ -78,6 +79,7 @@ MP_PROPERTY_GETTER(ipaddress_ipv4address_packed_obj, //| version: int //| """4 for IPv4, 6 for IPv6""" +//| static mp_obj_t ipaddress_ipv4address_get_version(mp_obj_t self_in) { ipaddress_ipv4address_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_buffer_info_t buf_info; @@ -98,6 +100,7 @@ MP_PROPERTY_GETTER(ipaddress_ipv4address_version_obj, //| def __eq__(self, other: object) -> bool: //| """Two Address objects are equal if their addresses and address types are equal.""" //| ... +//| static mp_obj_t ipaddress_ipv4address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { switch (op) { // Two Addresses are equal if their address bytes and address_type are equal @@ -122,6 +125,7 @@ static mp_obj_t ipaddress_ipv4address_binary_op(mp_binary_op_t op, mp_obj_t lhs_ //| """Returns a hash for the IPv4Address data.""" //| ... //| +//| static mp_obj_t ipaddress_ipv4address_unary_op(mp_unary_op_t op, mp_obj_t self_in) { switch (op) { // Two Addresses are equal if their address bytes and address_type are equal diff --git a/shared-bindings/ipaddress/__init__.c b/shared-bindings/ipaddress/__init__.c index 75892f6f2e..60bc6226ba 100644 --- a/shared-bindings/ipaddress/__init__.c +++ b/shared-bindings/ipaddress/__init__.c @@ -16,6 +16,7 @@ //| module. //| """ //| +//| bool ipaddress_parse_ipv4address(const char *str_data, size_t str_len, uint32_t *ip_out) { @@ -60,6 +61,7 @@ bool ipaddress_parse_ipv4address(const char *str_data, size_t str_len, uint32_t //| """Return a corresponding IP address object or raise ValueError if not possible.""" //| ... //| +//| static mp_obj_t ipaddress_ip_address(mp_obj_t ip_in) { uint32_t value; diff --git a/shared-bindings/is31fl3741/FrameBuffer.c b/shared-bindings/is31fl3741/FrameBuffer.c index b197f4447c..b59c7360f8 100644 --- a/shared-bindings/is31fl3741/FrameBuffer.c +++ b/shared-bindings/is31fl3741/FrameBuffer.c @@ -29,7 +29,7 @@ //| *, //| framebuffer: Optional[WriteableBuffer] = None, //| scale: bool = False, -//| gamma: bool = False +//| gamma: bool = False, //| ) -> None: //| """Create a IS31FL3741_FrameBuffer object with the given attributes. //| @@ -51,6 +51,7 @@ //| :param bool scale: if True display is scaled down by 3 when displayed //| :param bool gamma: if True apply gamma correction to all LEDs""" //| ... +//| static mp_obj_t is31fl3741_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_is31, ARG_width, ARG_height, ARG_mapping, ARG_framebuffer, ARG_scale, ARG_gamma }; static const mp_arg_t allowed_args[] = { @@ -111,6 +112,7 @@ static mp_obj_t is31fl3741_framebuffer_make_new(const mp_obj_type_t *type, size_ //| IS31FL3741 instance. After deinitialization, no further operations //| may be performed.""" //| ... +//| static mp_obj_t is31fl3741_framebuffer_deinit(mp_obj_t self_in) { is31fl3741_framebuffer_obj_t *self = (is31fl3741_framebuffer_obj_t *)self_in; common_hal_is31fl3741_framebuffer_deinit(self); @@ -127,6 +129,7 @@ static void check_for_deinit(is31fl3741_framebuffer_obj_t *self) { //| brightness: float //| """In the current implementation, 0.0 turns the display off entirely //| and any other value up to 1.0 turns the display on fully.""" +//| static mp_obj_t is31fl3741_framebuffer_get_brightness(mp_obj_t self_in) { is31fl3741_framebuffer_obj_t *self = (is31fl3741_framebuffer_obj_t *)self_in; check_for_deinit(self); @@ -160,6 +163,7 @@ MP_PROPERTY_GETSET(is31fl3741_framebuffer_brightness_obj, //| """Transmits the color data in the buffer to the pixels so that //| they are shown.""" //| ... +//| static mp_obj_t is31fl3741_framebuffer_refresh(mp_obj_t self_in) { is31fl3741_framebuffer_obj_t *self = (is31fl3741_framebuffer_obj_t *)self_in; check_for_deinit(self); @@ -182,6 +186,7 @@ MP_PROPERTY_GETTER(is31fl3741_framebuffer_width_obj, //| height: int //| """The height of the display, in pixels""" //| +//| static mp_obj_t is31fl3741_framebuffer_get_height(mp_obj_t self_in) { is31fl3741_framebuffer_obj_t *self = (is31fl3741_framebuffer_obj_t *)self_in; check_for_deinit(self); diff --git a/shared-bindings/is31fl3741/IS31FL3741.c b/shared-bindings/is31fl3741/IS31FL3741.c index 7815a2ac80..235763bae0 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.c +++ b/shared-bindings/is31fl3741/IS31FL3741.c @@ -25,6 +25,7 @@ //| :param ~busio.I2C i2c: I2C bus the IS31FL3741 is on //| :param int addr: device address""" //| ... +//| static mp_obj_t is31fl3741_IS31FL3741_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_i2c, ARG_addr }; static const mp_arg_t allowed_args[] = { @@ -52,6 +53,7 @@ static mp_obj_t is31fl3741_IS31FL3741_make_new(const mp_obj_type_t *type, size_t //| may be performed.""" //| ... //| +//| static mp_obj_t is31fl3741_IS31FL3741_deinit(mp_obj_t self_in) { is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; common_hal_is31fl3741_IS31FL3741_deinit(self); @@ -63,6 +65,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_deinit_obj, is31fl3741_IS //| """Resets the IS31FL3741 chip.""" //| ... //| +//| static mp_obj_t is31fl3741_IS31FL3741_reset(mp_obj_t self_in) { is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_is31fl3741_send_reset(self); @@ -74,6 +77,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_reset_obj, is31fl3741_IS31FL3741 //| """Enables the IS31FL3741 chip.""" //| ... //| +//| static mp_obj_t is31fl3741_IS31FL3741_enable(mp_obj_t self_in) { is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_is31fl3741_send_enable(self); @@ -87,6 +91,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_enable_obj, is31fl3741_IS31FL374 //| :param int current: global current value 0x00 to 0xFF""" //| ... //| +//| static mp_obj_t is31fl3741_IS31FL3741_set_global_current(mp_obj_t self_in, mp_obj_t value) { is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_int_t current = mp_obj_get_int(value); @@ -105,6 +110,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_IS31FL3741_set_global_current_obj, is31fl37 //| of 0 or 2)""" //| ... //| +//| static mp_obj_t is31fl3741_IS31FL3741_set_led(size_t n_args, const mp_obj_t *args) { is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(args[0]); mp_int_t led = mp_obj_get_int(args[1]); @@ -123,6 +129,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(is31fl3741_IS31FL3741_set_led_obj, 4, 4, is3 //| """ //| ... //| +//| static mp_obj_t is31fl3741_IS31FL3741_write(mp_obj_t self_in, mp_obj_t mapping, mp_obj_t buffer) { is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); if (!mp_obj_is_tuple_compatible(mapping)) { diff --git a/shared-bindings/jpegio/JpegDecoder.c b/shared-bindings/jpegio/JpegDecoder.c index d045e178bd..13287a2365 100644 --- a/shared-bindings/jpegio/JpegDecoder.c +++ b/shared-bindings/jpegio/JpegDecoder.c @@ -32,7 +32,9 @@ //| # .. do something with bitmap //| """ //| -//| def __init__(self) -> None: ... +//| def __init__(self) -> None: +//| """Create a JpegDecoder""" +//| ... //| static mp_obj_t jpegio_jpegdecoder_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { static const mp_arg_t allowed_args[] = { @@ -47,6 +49,7 @@ static mp_obj_t jpegio_jpegdecoder_make_new(const mp_obj_type_t *type, size_t n_ return MP_OBJ_FROM_PTR(self); } +//| //| @overload //| def open(self, filename: str) -> Tuple[int, int]: ... //| @overload @@ -62,6 +65,7 @@ static mp_obj_t jpegio_jpegdecoder_make_new(const mp_obj_type_t *type, size_t n_ //| not shown in the function signature in the documentation. //| //| Returns the image size as the tuple ``(width, height)``.""" +//| static mp_obj_t jpegio_jpegdecoder_open(mp_obj_t self_in, mp_obj_t arg) { jpegio_jpegdecoder_obj_t *self = MP_OBJ_TO_PTR(self_in); if (mp_obj_is_str(arg)) { @@ -132,6 +136,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(jpegio_jpegdecoder_open_obj, jpegio_jpegdecoder_open); //| by the pixels from the source //| """ //| +//| static mp_obj_t jpegio_jpegdecoder_decode(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { jpegio_jpegdecoder_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); diff --git a/shared-bindings/keypad/Event.c b/shared-bindings/keypad/Event.c index 53c36a76df..51e446e836 100644 --- a/shared-bindings/keypad/Event.c +++ b/shared-bindings/keypad/Event.c @@ -24,6 +24,7 @@ //| :param int timestamp: The time in milliseconds that the keypress occurred in the `supervisor.ticks_ms` time system. If specified as None, the current value of `supervisor.ticks_ms` is used. //| """ //| ... +//| static mp_obj_t keypad_event_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { keypad_event_obj_t *self = mp_obj_malloc(keypad_event_obj_t, &keypad_event_type); enum { ARG_key_number, ARG_pressed, ARG_timestamp }; @@ -87,6 +88,7 @@ MP_PROPERTY_GETTER(keypad_event_released_obj, //| timestamp: int //| """The timestamp.""" +//| static mp_obj_t keypad_event_get_timestamp(mp_obj_t self_in) { keypad_event_obj_t *self = MP_OBJ_TO_PTR(self_in); return common_hal_keypad_event_get_timestamp(self); @@ -103,6 +105,7 @@ MP_PROPERTY_GETTER(keypad_event_timestamp_obj, //| Note that this does not compare the event timestamps. //| """ //| ... +//| static mp_obj_t keypad_event_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { switch (op) { case MP_BINARY_OP_EQUAL: @@ -131,6 +134,7 @@ static mp_obj_t keypad_event_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_ob //| """ //| ... //| +//| static mp_obj_t keypad_event_unary_op(mp_unary_op_t op, mp_obj_t self_in) { keypad_event_obj_t *self = MP_OBJ_TO_PTR(self_in); switch (op) { diff --git a/shared-bindings/keypad/EventQueue.c b/shared-bindings/keypad/EventQueue.c index e15b19df3b..67d742c3dc 100644 --- a/shared-bindings/keypad/EventQueue.c +++ b/shared-bindings/keypad/EventQueue.c @@ -20,6 +20,7 @@ //| """ //| //| ... +//| //| def get(self) -> Optional[Event]: //| """Return the next key transition event. Return ``None`` if no events are pending. @@ -33,6 +34,7 @@ //| :rtype: Optional[Event] //| """ //| ... +//| static mp_obj_t keypad_eventqueue_get(mp_obj_t self_in) { keypad_eventqueue_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -55,6 +57,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(keypad_eventqueue_get_obj, keypad_eventqueue_get); //| :rtype: bool //| """ //| ... +//| static mp_obj_t keypad_eventqueue_get_into(mp_obj_t self_in, mp_obj_t event_in) { keypad_eventqueue_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -67,6 +70,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(keypad_eventqueue_get_into_obj, keypad_eventqueue_get_ //| def clear(self) -> None: //| """Clear any queued key transition events. Also sets `overflowed` to ``False``.""" //| ... +//| static mp_obj_t keypad_eventqueue_clear(mp_obj_t self_in) { keypad_eventqueue_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -84,6 +88,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(keypad_eventqueue_clear_obj, keypad_eventqueue_clear); //| def __len__(self) -> int: //| """Return the number of events currently in the queue. Used to implement ``len()``.""" //| ... +//| static mp_obj_t keypad_eventqueue_unary_op(mp_unary_op_t op, mp_obj_t self_in) { keypad_eventqueue_obj_t *self = MP_OBJ_TO_PTR(self_in); uint16_t len = common_hal_keypad_eventqueue_get_length(self); @@ -102,6 +107,7 @@ static mp_obj_t keypad_eventqueue_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| Set to ``False`` by `clear()`. //| """ //| +//| static mp_obj_t keypad_eventqueue_get_overflowed(mp_obj_t self_in) { keypad_eventqueue_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_bool(common_hal_keypad_eventqueue_get_overflowed(self)); diff --git a/shared-bindings/keypad/KeyMatrix.c b/shared-bindings/keypad/KeyMatrix.c index b832d74bde..d105cc6255 100644 --- a/shared-bindings/keypad/KeyMatrix.c +++ b/shared-bindings/keypad/KeyMatrix.c @@ -69,6 +69,7 @@ //| The default is 1, which resolves immediately. The maximum is 127. //| """ //| ... +//| static mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_KEYPAD_KEYMATRIX @@ -126,6 +127,7 @@ static mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Stop scanning and release the pins.""" //| ... +//| static mp_obj_t keypad_keymatrix_deinit(mp_obj_t self_in) { keypad_keymatrix_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_keypad_keymatrix_deinit(self); @@ -136,12 +138,14 @@ MP_DEFINE_CONST_FUN_OBJ_1(keypad_keymatrix_deinit_obj, keypad_keymatrix_deinit); //| def __enter__(self) -> KeyMatrix: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t keypad_keymatrix___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_keypad_keymatrix_deinit(args[0]); @@ -164,10 +168,12 @@ static void check_for_deinit(keypad_keymatrix_obj_t *self) { //| were being held down at program start. //| """ //| ... +//| //| key_count: int //| """The number of keys that are being scanned. (read-only) //| """ +//| //| def key_number_to_row_column(self, key_number: int) -> Tuple[int]: //| """Return the row and column for the given key number. @@ -178,6 +184,7 @@ static void check_for_deinit(keypad_keymatrix_obj_t *self) { //| :rtype: Tuple[int] //| """ //| ... +//| static mp_obj_t keypad_keymatrix_key_number_to_row_column(mp_obj_t self_in, mp_obj_t key_number_in) { keypad_keymatrix_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -204,6 +211,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(keypad_keymatrix_key_number_to_row_column_obj, keypad_ //| The key number is ``row * len(column_pins) + column``. //| """ //| ... +//| static mp_obj_t keypad_keymatrix_row_column_to_key_number(mp_obj_t self_in, mp_obj_t row_in, mp_obj_t column_in) { keypad_keymatrix_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -223,6 +231,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(keypad_keymatrix_row_column_to_key_number_obj, keypad_ //| """The `EventQueue` associated with this `Keys` object. (read-only) //| """ //| +//| static const mp_rom_map_elem_t keypad_keymatrix_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&keypad_keymatrix_deinit_obj) }, diff --git a/shared-bindings/keypad/Keys.c b/shared-bindings/keypad/Keys.c index 996f13d8a1..8e1a4af873 100644 --- a/shared-bindings/keypad/Keys.c +++ b/shared-bindings/keypad/Keys.c @@ -71,6 +71,7 @@ //| The default is 1, which resolves immediately. The maximum is 127. //| """ //| ... +//| static mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_KEYPAD_KEYS @@ -118,6 +119,7 @@ static mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, s //| def deinit(self) -> None: //| """Stop scanning and release the pins.""" //| ... +//| static mp_obj_t keypad_keys_deinit(mp_obj_t self_in) { keypad_keys_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -129,12 +131,14 @@ MP_DEFINE_CONST_FUN_OBJ_1(keypad_keys_deinit_obj, keypad_keys_deinit); //| def __enter__(self) -> Keys: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t keypad_keys___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_keypad_keys_deinit(args[0]); @@ -152,6 +156,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(keypad_keys___exit___obj, 4, 4, keypa //| were being held down at program start. //| """ //| ... +//| //| key_count: int //| """The number of keys that are being scanned. (read-only) @@ -161,6 +166,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(keypad_keys___exit___obj, 4, 4, keypa //| """The `EventQueue` associated with this `Keys` object. (read-only) //| """ //| +//| static const mp_rom_map_elem_t keypad_keys_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&keypad_keys_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index 8508619d98..070730d4b1 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -84,6 +84,7 @@ //| The default is 1, which resolves immediately. The maximum is 127. //| """ //| ... +//| static mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS @@ -173,6 +174,7 @@ static mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, siz //| def deinit(self) -> None: //| """Stop scanning and release the pins.""" //| ... +//| static mp_obj_t keypad_shiftregisterkeys_deinit(mp_obj_t self_in) { keypad_shiftregisterkeys_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -184,12 +186,14 @@ MP_DEFINE_CONST_FUN_OBJ_1(keypad_shiftregisterkeys_deinit_obj, keypad_shiftregis //| def __enter__(self) -> Keys: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t keypad_shiftregisterkeys___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_keypad_shiftregisterkeys_deinit(args[0]); @@ -206,6 +210,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(keypad_shiftregisterkeys___exit___obj //| were being held down at program start. //| """ //| ... +//| //| key_count: int //| """The total number of keys that are being scanned. (read-only) @@ -215,6 +220,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(keypad_shiftregisterkeys___exit___obj //| """The `EventQueue` associated with this `Keys` object. (read-only) //| """ //| +//| static const mp_rom_map_elem_t keypad_shiftregisterkeys_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&keypad_shiftregisterkeys_deinit_obj) }, diff --git a/shared-bindings/keypad_demux/DemuxKeyMatrix.c b/shared-bindings/keypad_demux/DemuxKeyMatrix.c index 9572a64790..376b76e271 100644 --- a/shared-bindings/keypad_demux/DemuxKeyMatrix.c +++ b/shared-bindings/keypad_demux/DemuxKeyMatrix.c @@ -77,6 +77,7 @@ //| The default is 1, which resolves immediately. The maximum is 127. //| """ //| ... +//| static mp_obj_t keypad_demux_demuxkeymatrix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { keypad_demux_demuxkeymatrix_obj_t *self = mp_obj_malloc(keypad_demux_demuxkeymatrix_obj_t, &keypad_demux_demuxkeymatrix_type); @@ -129,6 +130,7 @@ static mp_obj_t keypad_demux_demuxkeymatrix_make_new(const mp_obj_type_t *type, //| def deinit(self) -> None: //| """Stop scanning and release the pins.""" //| ... +//| static mp_obj_t keypad_demux_demuxkeymatrix_deinit(mp_obj_t self_in) { keypad_demux_demuxkeymatrix_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_keypad_demux_demuxkeymatrix_deinit(self); @@ -139,12 +141,14 @@ MP_DEFINE_CONST_FUN_OBJ_1(keypad_demux_demuxkeymatrix_deinit_obj, keypad_demux_d //| def __enter__(self) -> DemuxKeyMatrix: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t keypad_demux_demuxkeymatrix___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_keypad_demux_demuxkeymatrix_deinit(args[0]); @@ -167,10 +171,12 @@ static void check_for_deinit(keypad_demux_demuxkeymatrix_obj_t *self) { //| were being held down at program start. //| """ //| ... +//| //| key_count: int //| """The number of keys that are being scanned. (read-only) //| """ +//| //| def key_number_to_row_column(self, key_number: int) -> Tuple[int]: //| """Return the row and column for the given key number. @@ -181,6 +187,7 @@ static void check_for_deinit(keypad_demux_demuxkeymatrix_obj_t *self) { //| :rtype: Tuple[int] //| """ //| ... +//| static mp_obj_t keypad_demux_demuxkeymatrix_key_number_to_row_column(mp_obj_t self_in, mp_obj_t key_number_in) { keypad_demux_demuxkeymatrix_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -207,6 +214,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(keypad_demux_demuxkeymatrix_key_number_to_row_column_o //| The key number is ``row * len(column_pins) + column``. //| """ //| ... +//| static mp_obj_t keypad_demux_demuxkeymatrix_row_column_to_key_number(mp_obj_t self_in, mp_obj_t row_in, mp_obj_t column_in) { keypad_demux_demuxkeymatrix_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -226,6 +234,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(keypad_demux_demuxkeymatrix_row_column_to_key_number_o //| """The `keypad.EventQueue` associated with this `keypad.Keys` object. (read-only) //| """ //| +//| static const mp_rom_map_elem_t keypad_demux_demuxkeymatrix_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&keypad_demux_demuxkeymatrix_deinit_obj) }, diff --git a/shared-bindings/locale/__init__.c b/shared-bindings/locale/__init__.c index e3201c13a1..66b9e9762a 100644 --- a/shared-bindings/locale/__init__.c +++ b/shared-bindings/locale/__init__.c @@ -9,6 +9,7 @@ //| """Locale support module""" //| +//| //| def getlocale() -> None: //| """Returns the current locale setting as a tuple ``(language code, "utf-8")`` //| @@ -18,6 +19,7 @@ //| Differences from CPython: No ``LC_*`` argument is permitted. //| """ //| +//| static mp_obj_t getlocale(void) { mp_rom_error_text_t locale_msg = MP_ERROR_TEXT("en_US"); diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 6a2dd1b3e1..54fe53280c 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -24,6 +24,7 @@ //| //| |see_cpython_module| :mod:`cpython:math`. //| """ +//| static NORETURN void math_error(void) { mp_raise_ValueError(MP_ERROR_TEXT("math domain error")); @@ -66,55 +67,68 @@ static NORETURN void math_error(void) { //| pi: float //| """the ratio of a circle's circumference to its diameter""" //| +//| //| def acos(x: float) -> float: //| """Return the inverse cosine of ``x``.""" //| ... //| +//| //| def asin(x: float) -> float: //| """Return the inverse sine of ``x``.""" //| ... //| +//| //| def atan(x: float) -> float: //| """Return the inverse tangent of ``x``.""" //| ... //| +//| //| def atan2(y: float, x: float) -> float: //| """Return the principal value of the inverse tangent of ``y/x``.""" //| ... //| +//| //| def ceil(x: float) -> int: //| """Return an integer, being ``x`` rounded towards positive infinity.""" //| ... //| +//| //| def copysign(x: float, y: float) -> float: //| """Return ``x`` with the sign of ``y``.""" //| ... //| +//| //| def cos(x: float) -> float: //| """Return the cosine of ``x``.""" //| ... //| +//| //| def degrees(x: float) -> float: //| """Return radians ``x`` converted to degrees.""" //| ... //| +//| //| def exp(x: float) -> float: //| """Return the exponential of ``x``.""" //| ... //| +//| //| def fabs(x: float) -> float: //| """Return the absolute value of ``x``.""" //| ... //| +//| //| def floor(x: float) -> int: //| """Return an integer, being ``x`` rounded towards negative infinity.""" //| ... //| +//| //| def fmod(x: float, y: float) -> int: //| """Return the remainder of ``x/y``.""" //| ... //| +//| //| def frexp(x: float) -> Tuple[int, int]: //| """Decomposes a floating-point number into its mantissa and exponent. //| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e`` @@ -122,54 +136,67 @@ static NORETURN void math_error(void) { //| the relation ``0.5 <= abs(m) < 1`` holds.""" //| ... //| +//| //| def isfinite(x: float) -> bool: //| """Return ``True`` if ``x`` is finite.""" //| ... //| +//| //| def isinf(x: float) -> bool: //| """Return ``True`` if ``x`` is infinite.""" //| ... //| +//| //| def isnan(x: float) -> bool: //| """Return ``True`` if ``x`` is not-a-number""" //| ... //| +//| //| def ldexp(x: float, exp: float) -> float: //| """Return ``x * (2**exp)``.""" //| ... //| +//| //| def log(x: float, base: float = e) -> float: //| """Return the logarithm of x to the given base. If base is not specified, //| returns the natural logarithm (base e) of x""" //| ... //| +//| //| def modf(x: float) -> Tuple[float, float]: //| """Return a tuple of two floats, being the fractional and integral parts of //| ``x``. Both return values have the same sign as ``x``.""" //| ... //| +//| //| def pow(x: float, y: float) -> float: //| """Returns ``x`` to the power of ``y``.""" //| +//| //| def radians(x: float) -> float: //| """Return degrees ``x`` converted to radians.""" //| +//| //| def sin(x: float) -> float: //| """Return the sine of ``x``.""" //| ... //| +//| //| def sqrt(x: float) -> float: //| """Returns the square root of ``x``.""" //| ... //| +//| //| def tan(x: float) -> float: //| """Return the tangent of ``x``.""" //| ... //| +//| //| def trunc(x: float) -> int: //| """Return an integer, being ``x`` rounded towards 0.""" //| ... //| +//| MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0)) MATH_FUN_2(pow, pow) @@ -183,6 +210,7 @@ MATH_FUN_1(exp, exp) //| """ //| ... //| +//| MATH_FUN_1(expm1, expm1) //| def log2(x: float) -> float: @@ -192,6 +220,7 @@ MATH_FUN_1(expm1, expm1) //| """ //| ... //| +//| MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0)) //| def log10(x: float) -> float: @@ -201,6 +230,7 @@ MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0)) //| """ //| ... //| +//| MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0)) //| def cosh(x: float) -> float: @@ -210,6 +240,7 @@ MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0)) //| """ //| ... //| +//| MATH_FUN_1(cosh, cosh) //| def sinh(x: float) -> float: @@ -219,6 +250,7 @@ MATH_FUN_1(cosh, cosh) //| """ //| ... //| +//| MATH_FUN_1(sinh, sinh) //| def tanh(x: float) -> float: @@ -228,6 +260,7 @@ MATH_FUN_1(sinh, sinh) //| """ //| ... //| +//| MATH_FUN_1(tanh, tanh) //| def acosh(x: float) -> float: @@ -237,6 +270,7 @@ MATH_FUN_1(tanh, tanh) //| """ //| ... //| +//| MATH_FUN_1(acosh, acosh) //| def asinh(x: float) -> float: @@ -246,6 +280,7 @@ MATH_FUN_1(acosh, acosh) //| """ //| ... //| +//| MATH_FUN_1(asinh, asinh) //| def atanh(x: float) -> float: @@ -255,6 +290,7 @@ MATH_FUN_1(asinh, asinh) //| """ //| ... //| +//| MATH_FUN_1(atanh, atanh) #endif @@ -300,6 +336,7 @@ MATH_FUN_2(ldexp, ldexp) //| """ //| ... //| +//| MATH_FUN_1(erf, erf) //| def erfc(x: float) -> float: @@ -309,6 +346,7 @@ MATH_FUN_1(erf, erf) //| """ //| ... //| +//| MATH_FUN_1(erfc, erfc) //| def gamma(x: float) -> float: @@ -318,6 +356,7 @@ MATH_FUN_1(erfc, erfc) //| """ //| ... //| +//| MATH_FUN_1(gamma, tgamma) //| def lgamma(x: float) -> float: @@ -327,6 +366,7 @@ MATH_FUN_1(gamma, tgamma) //| """ //| ... //| +//| MATH_FUN_1(lgamma, lgamma) //| def dist(p: tuple, q: tuple) -> float: @@ -336,6 +376,7 @@ MATH_FUN_1(lgamma, lgamma) //| """ //| ... //| +//| static mp_obj_t mp_math_dist(mp_obj_t p_obj, mp_obj_t q_obj) { mp_obj_t *p_items; mp_obj_get_array_fixed_n(p_obj, 2, &p_items); diff --git a/shared-bindings/max3421e/Max3421E.c b/shared-bindings/max3421e/Max3421E.c index e5c2963fa0..ed3453efeb 100644 --- a/shared-bindings/max3421e/Max3421E.c +++ b/shared-bindings/max3421e/Max3421E.c @@ -19,7 +19,7 @@ //| *, //| chip_select: microcontroller.Pin, //| irq: microcontroller.Pin, -//| baudrate: int = 26000000 +//| baudrate: int = 26000000, //| ) -> None: //| """Create a Max3421E object associated with the given pins. //| @@ -31,6 +31,7 @@ //| :param microcontroller.Pin irq: Interrupt pin //| :param int baudrate: Maximum baudrate to talk to the Max chip in Hz""" //| ... +//| static mp_obj_t max3421e_max3421e_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_spi_bus, ARG_chip_select, ARG_irq, ARG_baudrate }; static const mp_arg_t allowed_args[] = { @@ -57,6 +58,7 @@ static mp_obj_t max3421e_max3421e_make_new(const mp_obj_type_t *type, size_t n_a //| """Shuts down USB host functionality and releases chip_select and irq pins.""" //| ... //| +//| static mp_obj_t max3421e_max3421e_obj_deinit(mp_obj_t self_in) { max3421e_max3421e_obj_t *self = self_in; if (common_hal_max3421e_max3421e_deinited(self)) { diff --git a/shared-bindings/mdns/RemoteService.c b/shared-bindings/mdns/RemoteService.c index d1eddc6961..b3ee3d7f7b 100644 --- a/shared-bindings/mdns/RemoteService.c +++ b/shared-bindings/mdns/RemoteService.c @@ -20,6 +20,7 @@ //| def __init__(self) -> None: //| """Cannot be instantiated directly. Use `mdns.Server.find`.""" //| ... +//| //| hostname: str //| """The hostname of the device (read-only),.""" @@ -82,6 +83,7 @@ MP_PROPERTY_GETTER(mdns_remoteservice_port_obj, //| ipv4_address: Optional[ipaddress.IPv4Address] //| """IP v4 Address of the remote service. None if no A records are found.""" +//| static mp_obj_t _mdns_remoteservice_get_ipv4_address(mp_obj_t self) { return common_hal_mdns_remoteservice_get_ipv4_address(self); @@ -95,6 +97,7 @@ MP_PROPERTY_GETTER(mdns_remoteservice_ipv4_address_obj, //| """Deletes the RemoteService object.""" //| ... //| +//| static mp_obj_t mdns_remoteservice_obj_deinit(mp_obj_t self_in) { mdns_remoteservice_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_mdns_remoteservice_deinit(self); diff --git a/shared-bindings/mdns/Server.c b/shared-bindings/mdns/Server.c index c4670fccc2..86fb2eb6d7 100644 --- a/shared-bindings/mdns/Server.c +++ b/shared-bindings/mdns/Server.c @@ -30,6 +30,7 @@ //| may already be using it.) Only native interfaces are currently supported. //| """ //| ... +//| static mp_obj_t mdns_server_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_network_interface }; static const mp_arg_t allowed_args[] = { @@ -55,6 +56,7 @@ static mp_obj_t mdns_server_make_new(const mp_obj_type_t *type, size_t n_args, s //| def deinit(self) -> None: //| """Stops the server""" //| ... +//| static mp_obj_t mdns_server_obj_deinit(mp_obj_t self_in) { mdns_server_obj_t *self = (mdns_server_obj_t *)self_in; common_hal_mdns_server_deinit(self); @@ -93,6 +95,7 @@ MP_PROPERTY_GETSET(mdns_server_hostname_obj, //| instance_name: str //| """Human readable name to describe the device.""" +//| static mp_obj_t mdns_server_get_instance_name(mp_obj_t self) { check_for_deinit(self); const char *instance_name = common_hal_mdns_server_get_instance_name(self); @@ -124,6 +127,7 @@ MP_PROPERTY_GETSET(mdns_server_instance_name_obj, //| :param str protocol: The service protocol such as "_tcp" //| :param float/int timeout: Time to wait for responses""" //| ... +//| static mp_obj_t _mdns_server_find(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mdns_server_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); @@ -164,6 +168,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(mdns_server_find_obj, 1, _mdns_server_find); //| """ //| ... //| +//| static mp_obj_t mdns_server_advertise_service(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mdns_server_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); diff --git a/shared-bindings/memorymap/AddressRange.c b/shared-bindings/memorymap/AddressRange.c index 821609bb93..9f15f86016 100644 --- a/shared-bindings/memorymap/AddressRange.c +++ b/shared-bindings/memorymap/AddressRange.c @@ -63,6 +63,7 @@ //| ``start + length``. An exception will be raised if any of the //| addresses are invalid or protected.""" //| ... +//| static mp_obj_t memorymap_addressrange_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_start, ARG_length }; static const mp_arg_t allowed_args[] = { @@ -101,6 +102,7 @@ static mp_obj_t memorymap_addressrange_make_new(const mp_obj_type_t *type, size_ //| def __len__(self) -> int: //| """Return the length. This is used by (`len`)""" //| ... +//| static mp_obj_t memorymap_addressrange_unary_op(mp_unary_op_t op, mp_obj_t self_in) { memorymap_addressrange_obj_t *self = MP_OBJ_TO_PTR(self_in); uint16_t len = common_hal_memorymap_addressrange_get_length(self); @@ -141,6 +143,7 @@ static MP_DEFINE_CONST_DICT(memorymap_addressrange_locals_dict, memorymap_addres //| All others may use multiple transactions.""" //| ... //| +//| static mp_obj_t memorymap_addressrange_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item diff --git a/shared-bindings/memorymonitor/AllocationAlarm.c b/shared-bindings/memorymonitor/AllocationAlarm.c index 9fa07376b2..5475e2d7db 100644 --- a/shared-bindings/memorymonitor/AllocationAlarm.c +++ b/shared-bindings/memorymonitor/AllocationAlarm.c @@ -33,6 +33,7 @@ //| //| """ //| ... +//| static mp_obj_t memorymonitor_allocationalarm_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) { enum { ARG_minimum_block_count }; static const mp_arg_t allowed_args[] = { @@ -64,6 +65,7 @@ static mp_obj_t memorymonitor_allocationalarm_make_new(const mp_obj_type_t *type //| x = bytearray(20) //| """ //| ... +//| static mp_obj_t memorymonitor_allocationalarm_obj_ignore(mp_obj_t self_in, mp_obj_t count_obj) { mp_int_t count = mp_obj_get_int(count_obj); mp_arg_validate_int_min(count, 0, MP_QSTR_count); @@ -76,6 +78,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(memorymonitor_allocationalarm_ignore_obj, memorymonito //| def __enter__(self) -> AllocationAlarm: //| """Enables the alarm.""" //| ... +//| static mp_obj_t memorymonitor_allocationalarm_obj___enter__(mp_obj_t self_in) { common_hal_memorymonitor_allocationalarm_resume(self_in); return self_in; @@ -87,6 +90,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationalarm___enter___obj, memorymon //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... //| +//| static mp_obj_t memorymonitor_allocationalarm_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_memorymonitor_allocationalarm_set_ignore(args[0], 0); diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index 34f1d3e3f3..3113d6ed19 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -40,6 +40,7 @@ //| //| """ //| ... +//| static mp_obj_t memorymonitor_allocationsize_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) { memorymonitor_allocationsize_obj_t *self = m_new_obj(memorymonitor_allocationsize_obj_t, &memorymonitor_allocationsize_type); @@ -52,6 +53,7 @@ static mp_obj_t memorymonitor_allocationsize_make_new(const mp_obj_type_t *type, //| def __enter__(self) -> AllocationSize: //| """Clears counts and resumes tracking.""" //| ... +//| static mp_obj_t memorymonitor_allocationsize_obj___enter__(mp_obj_t self_in) { common_hal_memorymonitor_allocationsize_clear(self_in); common_hal_memorymonitor_allocationsize_resume(self_in); @@ -63,6 +65,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationsize___enter___obj, memorymoni //| """Automatically pauses allocation tracking when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t memorymonitor_allocationsize_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_memorymonitor_allocationsize_pause(args[0]); @@ -72,6 +75,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(memorymonitor_allocationsize___exit__ //| bytes_per_block: int //| """Number of bytes per block""" +//| static mp_obj_t memorymonitor_allocationsize_obj_get_bytes_per_block(mp_obj_t self_in) { memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -90,6 +94,7 @@ MP_PROPERTY_GETTER(memorymonitor_allocationsize_bytes_per_block_obj, //| mm = memorymonitor.AllocationSize() //| print(len(mm))""" //| ... +//| static mp_obj_t memorymonitor_allocationsize_unary_op(mp_unary_op_t op, mp_obj_t self_in) { memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in); uint16_t len = common_hal_memorymonitor_allocationsize_get_len(self); @@ -112,6 +117,7 @@ static mp_obj_t memorymonitor_allocationsize_unary_op(mp_unary_op_t op, mp_obj_t //| print(mm[0])""" //| ... //| +//| static mp_obj_t memorymonitor_allocationsize_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { // delete item diff --git a/shared-bindings/memorymonitor/__init__.c b/shared-bindings/memorymonitor/__init__.c index e925eb54e7..64d0140ff7 100644 --- a/shared-bindings/memorymonitor/__init__.c +++ b/shared-bindings/memorymonitor/__init__.c @@ -15,12 +15,14 @@ //| """Memory monitoring helpers""" //| +//| //| class AllocationError(Exception): //| """Catchall exception for allocation related errors.""" //| //| ... //| +//| MP_DEFINE_MEMORYMONITOR_EXCEPTION(AllocationError, Exception) NORETURN void mp_raise_memorymonitor_AllocationError(mp_rom_error_text_t fmt, ...) { diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index b0260a2295..e74d54b077 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -20,11 +20,13 @@ //| hardware so they cannot be constructed on demand. Instead, use //| :mod:`board` or :mod:`microcontroller.pin` to reference the desired pin.""" //| ... +//| //| def __hash__(self) -> int: //| """Returns a hash for the Pin.""" //| ... //| +//| // Provided inherently. // See https://github.com/micropython/micropython/pull/10348. diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index 0a14059783..a3518ab754 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -42,6 +42,7 @@ //| """You cannot create an instance of `microcontroller.Processor`. //| Use `microcontroller.cpu` to access the sole instance available.""" //| ... +//| //| frequency: int //| """The CPU operating frequency in Hertz. @@ -130,6 +131,7 @@ MP_PROPERTY_GETTER(mcu_processor_uid_obj, //| //| Is `None` if the voltage is not available.""" //| +//| static mp_obj_t mcu_processor_get_voltage(mp_obj_t self) { float voltage = common_hal_mcu_processor_get_voltage(); return isnan(voltage) ? mp_const_none : mp_obj_new_float(voltage); diff --git a/shared-bindings/microcontroller/ResetReason.c b/shared-bindings/microcontroller/ResetReason.c index 301205d84f..e16e8a056f 100644 --- a/shared-bindings/microcontroller/ResetReason.c +++ b/shared-bindings/microcontroller/ResetReason.c @@ -45,6 +45,7 @@ MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, RESCUE_DEBUG, RESET_REASON_ //| RESCUE_DEBUG: object //| """The microcontroller was reset by the rescue debug port.""" //| +//| MAKE_ENUM_MAP(mcu_reset_reason) { MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_ON), MAKE_ENUM_MAP_ENTRY(reset_reason, BROWNOUT), diff --git a/shared-bindings/microcontroller/RunMode.c b/shared-bindings/microcontroller/RunMode.c index 95979e5533..ac5ffd6213 100644 --- a/shared-bindings/microcontroller/RunMode.c +++ b/shared-bindings/microcontroller/RunMode.c @@ -12,6 +12,7 @@ //| def __init__(self) -> None: //| """Enum-like class to define the run mode of the microcontroller and //| CircuitPython.""" +//| //| NORMAL: RunMode //| """Run CircuitPython as normal. //| @@ -33,6 +34,7 @@ //| //| :type microcontroller.RunMode:""" //| +//| const mp_obj_type_t mcu_runmode_type; const mcu_runmode_obj_t mcu_runmode_uf2_obj = { diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index eb2fc79ec3..55e36356a5 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -39,6 +39,7 @@ //| (clock frequency) on chips with more than 1 cpu. The index selects which cpu. //| This object is an instance of `microcontroller.Processor`.""" //| +//| //| def delay_us(delay: int) -> None: //| """Dedicated delay method used for very short delays. **Do not** do long delays @@ -49,6 +50,7 @@ //| `time.sleep()`.""" //| ... //| +//| static mp_obj_t mcu_delay_us(mp_obj_t delay_obj) { uint32_t delay = mp_obj_get_int(delay_obj); @@ -62,6 +64,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(mcu_delay_us_obj, mcu_delay_us); //| """Disable all interrupts. Be very careful, this can stall everything.""" //| ... //| +//| static mp_obj_t mcu_disable_interrupts(void) { common_hal_mcu_disable_interrupts(); return mp_const_none; @@ -72,6 +75,7 @@ static MP_DEFINE_CONST_FUN_OBJ_0(mcu_disable_interrupts_obj, mcu_disable_interru //| """Enable the interrupts that were enabled at the last disable.""" //| ... //| +//| static mp_obj_t mcu_enable_interrupts(void) { common_hal_mcu_enable_interrupts(); return mp_const_none; @@ -85,6 +89,7 @@ static MP_DEFINE_CONST_FUN_OBJ_0(mcu_enable_interrupts_obj, mcu_enable_interrupt //| :param ~microcontroller.RunMode run_mode: The next run mode""" //| ... //| +//| static mp_obj_t mcu_on_next_reset(mp_obj_t run_mode_obj) { mcu_runmode_t run_mode; if (run_mode_obj == MP_OBJ_FROM_PTR(&mcu_runmode_uf2_obj)) { @@ -112,6 +117,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(mcu_on_next_reset_obj, mcu_on_next_reset); //| "Safely removed" on Windows or "ejected" on Mac OSX and Linux.""" //| ... //| +//| static mp_obj_t mcu_reset(void) { common_hal_mcu_reset(); // We won't actually get here because we're resetting. diff --git a/shared-bindings/msgpack/ExtType.c b/shared-bindings/msgpack/ExtType.c index 7cee4b9b0d..f66abda8fa 100644 --- a/shared-bindings/msgpack/ExtType.c +++ b/shared-bindings/msgpack/ExtType.c @@ -16,6 +16,7 @@ //| """Constructor //| :param int code: type code in range 0~127. //| :param bytes data: representation.""" +//| static mp_obj_t mod_msgpack_exttype_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mod_msgpack_extype_obj_t *self = mp_obj_malloc(mod_msgpack_extype_obj_t, &mod_msgpack_exttype_type); enum { ARG_code, ARG_data }; @@ -64,6 +65,7 @@ MP_PROPERTY_GETSET(mod_msgpack_exttype_code_obj, //| """Data.""" //| ... //| +//| static mp_obj_t mod_msgpack_exttype_get_data(mp_obj_t self_in) { mod_msgpack_extype_obj_t *self = MP_OBJ_TO_PTR(self_in); return self->data; diff --git a/shared-bindings/msgpack/__init__.c b/shared-bindings/msgpack/__init__.c index eaa1cfb98b..a3e31f23ca 100644 --- a/shared-bindings/msgpack/__init__.c +++ b/shared-bindings/msgpack/__init__.c @@ -65,12 +65,13 @@ //| //| """ //| +//| //| def pack( //| obj: object, //| stream: circuitpython_typing.ByteStream, //| *, -//| default: Union[Callable[[object], None], None] = None +//| default: Union[Callable[[object], None], None] = None, //| ) -> None: //| """Output object to stream in msgpack format. //| @@ -82,6 +83,7 @@ //| """ //| ... //| +//| static mp_obj_t mod_msgpack_pack(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_obj, ARG_buffer, ARG_default }; static const mp_arg_t allowed_args[] = { @@ -107,7 +109,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 0, mod_msgpack_pack); //| stream: circuitpython_typing.ByteStream, //| *, //| ext_hook: Union[Callable[[int, bytes], object], None] = None, -//| use_list: bool = True +//| use_list: bool = True, //| ) -> object: //| """Unpack and return one object from stream. //| @@ -120,6 +122,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 0, mod_msgpack_pack); //| """ //| ... //| +//| static mp_obj_t mod_msgpack_unpack(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_ext_hook, ARG_use_list }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index 9f221ddd5a..e23054cd66 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -84,6 +84,7 @@ static void check_for_deinit(digitalio_digitalinout_obj_t *self) { //| //| """ //| +//| //| def neopixel_write(digitalinout: digitalio.DigitalInOut, buf: ReadableBuffer) -> None: //| """Write buf out on the given DigitalInOut. //| @@ -92,6 +93,7 @@ static void check_for_deinit(digitalio_digitalinout_obj_t *self) { //| """ //| ... //| +//| static mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj_t buf) { const digitalio_digitalinout_obj_t *digitalinout = mp_arg_validate_type(digitalinout_obj, &digitalio_digitalinout_type, MP_QSTR_digitalinout); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 7549023247..be01c1f706 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -26,11 +26,13 @@ //| def __init__(self) -> None: //| """Not currently dynamically supported. Access the sole instance through `microcontroller.nvm`.""" //| ... +//| //| def __bool__(self) -> bool: ... //| def __len__(self) -> int: //| """Return the length. This is used by (`len`)""" //| ... +//| static mp_obj_t nvm_bytearray_unary_op(mp_unary_op_t op, mp_obj_t self_in) { nvm_bytearray_obj_t *self = MP_OBJ_TO_PTR(self_in); uint16_t len = common_hal_nvm_bytearray_get_length(self); @@ -63,6 +65,7 @@ static MP_DEFINE_CONST_DICT(nvm_bytearray_locals_dict, nvm_bytearray_locals_dict //| """Set the value at the given index.""" //| ... //| +//| static mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item diff --git a/shared-bindings/onewireio/OneWire.c b/shared-bindings/onewireio/OneWire.c index d2cb379ab4..ff18ee2f74 100644 --- a/shared-bindings/onewireio/OneWire.c +++ b/shared-bindings/onewireio/OneWire.c @@ -32,6 +32,7 @@ //| onewire.write_bit(False) //| print(onewire.read_bit())""" //| ... +//| static mp_obj_t onewireio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pin }; static const mp_arg_t allowed_args[] = { @@ -50,6 +51,7 @@ static mp_obj_t onewireio_onewire_make_new(const mp_obj_type_t *type, size_t n_a //| def deinit(self) -> None: //| """Deinitialize the OneWire bus and release any hardware resources for reuse.""" //| ... +//| static mp_obj_t onewireio_onewire_deinit(mp_obj_t self_in) { onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_onewireio_onewire_deinit(self); @@ -66,12 +68,14 @@ static void check_for_deinit(onewireio_onewire_obj_t *self) { //| def __enter__(self) -> OneWire: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t onewireio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_onewireio_onewire_deinit(args[0]); @@ -85,6 +89,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(onewireio_onewire___exit___obj, 4, 4, //| :returns: False when at least one device is present //| :rtype: bool""" //| ... +//| static mp_obj_t onewireio_onewire_obj_reset(mp_obj_t self_in) { onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -99,6 +104,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(onewireio_onewire_reset_obj, onewireio_onewire_obj_res //| :returns: bit state read //| :rtype: bool""" //| ... +//| static mp_obj_t onewireio_onewire_obj_read_bit(mp_obj_t self_in) { onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -111,6 +117,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(onewireio_onewire_read_bit_obj, onewireio_onewire_obj_ //| """Write out a bit based on value.""" //| ... //| +//| static mp_obj_t onewireio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) { onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/onewireio/__init__.c b/shared-bindings/onewireio/__init__.c index bce56326b1..9af86ae821 100644 --- a/shared-bindings/onewireio/__init__.c +++ b/shared-bindings/onewireio/__init__.c @@ -17,7 +17,7 @@ //| """Low-level bit primitives for Maxim (formerly Dallas Semi) one-wire protocol. //| -//| Protocol definition is here: https://www.analog.com/en/technical-articles/1wire-communication-through-software.html""" +//| Protocol definition is here: https://www.analog.com/en/technical-articles/1wire-communication-through-software.html""" static const mp_rom_map_elem_t onewireio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_onewireio) }, diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index 37dea42907..e6f6d4896d 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -26,12 +26,14 @@ //| //| import typing //| +//| //| 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""" //| @@ -41,6 +43,7 @@ //| version: str //| machine: str //| +//| static mp_obj_t os_uname(void) { return common_hal_os_uname(); } @@ -50,6 +53,7 @@ static MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname); //| """Change current directory.""" //| ... //| +//| static mp_obj_t os_chdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_chdir(path); @@ -61,6 +65,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_chdir_obj, os_chdir); //| """Get the current directory.""" //| ... //| +//| static mp_obj_t os_getcwd(void) { return common_hal_os_getcwd(); } @@ -89,6 +94,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd); //| """ //| ... //| +//| static mp_obj_t os_getenv(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { #if CIRCUITPY_OS_GETENV enum { ARG_key, ARG_default }; @@ -110,6 +116,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(os_getenv_obj, 1, os_getenv); //| """With no argument, list the current directory. Otherwise list the given directory.""" //| ... //| +//| static mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) { const char *path; if (n_args == 1) { @@ -125,6 +132,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_listdir_obj, 0, 1, os_listdir); //| """Create a new directory.""" //| ... //| +//| static mp_obj_t os_mkdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_mkdir(path); @@ -136,6 +144,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir); //| """Remove a file.""" //| ... //| +//| static mp_obj_t os_remove(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_remove(path); @@ -147,6 +156,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_remove_obj, os_remove); //| """Remove a directory.""" //| ... //| +//| static mp_obj_t os_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) { const char *old_path = mp_obj_str_get_str(old_path_in); const char *new_path = mp_obj_str_get_str(new_path_in); @@ -159,6 +169,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(os_rename_obj, os_rename); //| """Rename a file.""" //| ... //| +//| static mp_obj_t os_rmdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_rmdir(path); @@ -189,6 +200,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir); //| which is the number of seconds corresponding to 1999-12-31.""" //| ... //| +//| static mp_obj_t os_stat(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); return common_hal_os_stat(path); @@ -216,6 +228,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_stat_obj, os_stat); //| in a port-specific implementation.""" //| ... //| +//| static mp_obj_t os_statvfs(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); return common_hal_os_statvfs(path); @@ -226,6 +239,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_statvfs_obj, os_statvfs); //| """Sync all filesystems.""" //| ... //| +//| static mp_obj_t os_sync(void) { for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { // this assumes that vfs->obj is fs_user_mount_t with block device functions @@ -243,6 +257,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync); //| """ //| ... //| +//| static mp_obj_t os_urandom(mp_obj_t size_in) { mp_int_t size = mp_obj_get_int(size_in); mp_obj_str_t *result = MP_OBJ_TO_PTR(mp_obj_new_bytes_of_zeros(size)); @@ -257,6 +272,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_urandom_obj, os_urandom); //| """Change the timestamp of a file.""" //| ... //| +//| static mp_obj_t os_utime(mp_obj_t path_in, mp_obj_t times_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_utime(path, times_in); diff --git a/shared-bindings/paralleldisplaybus/ParallelBus.c b/shared-bindings/paralleldisplaybus/ParallelBus.c index 0a674920a0..1e0bd63674 100644 --- a/shared-bindings/paralleldisplaybus/ParallelBus.c +++ b/shared-bindings/paralleldisplaybus/ParallelBus.c @@ -49,6 +49,7 @@ //| :param microcontroller.Pin reset: Reset pin, optional //| :param int frequency: The communication frequency in Hz for the display on the bus""" //| ... +//| static mp_obj_t paralleldisplaybus_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_data0, ARG_data_pins, ARG_command, ARG_chip_select, ARG_write, ARG_read, ARG_reset, ARG_frequency }; static const mp_arg_t allowed_args[] = { @@ -96,6 +97,7 @@ static mp_obj_t paralleldisplaybus_parallelbus_make_new(const mp_obj_type_t *typ //| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin //| is available.""" //| ... +//| static mp_obj_t paralleldisplaybus_parallelbus_obj_reset(mp_obj_t self_in) { paralleldisplaybus_parallelbus_obj_t *self = self_in; @@ -112,6 +114,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(paralleldisplaybus_parallelbus_reset_obj, paralleldisp //| vertical scroll, set via ``send`` may or may not be reset once the code is done.""" //| ... //| +//| static mp_obj_t paralleldisplaybus_parallelbus_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) { mp_int_t command_int = mp_arg_validate_int_range(mp_obj_get_int(command_obj), 0, 255, MP_QSTR_command); diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index f92d5f0dd8..82174420ff 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -44,6 +44,7 @@ //| print(kbd.sendcmd(0xed)) //| print(kbd.sendcmd(0x01))""" //| ... +//| static mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_data_pin, ARG_clock_pin }; static const mp_arg_t allowed_args[] = { @@ -66,6 +67,7 @@ static mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, siz //| def deinit(self) -> None: //| """Deinitialises the Ps2 and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t ps2io_ps2_deinit(mp_obj_t self_in) { ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_ps2io_ps2_deinit(self); @@ -82,12 +84,14 @@ static void check_for_deinit(ps2io_ps2_obj_t *self) { //| def __enter__(self) -> Ps2: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t ps2io_ps2_obj___exit__(size_t n_args, const mp_obj_t *args) { mp_check_self(mp_obj_is_type(args[0], &ps2io_ps2_type)); ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(args[0]); @@ -100,6 +104,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ps2io_ps2___exit___obj, 4, 4, ps2io_p //| """Removes and returns the oldest received byte. When buffer //| is empty, raises an IndexError exception.""" //| ... +//| static mp_obj_t ps2io_ps2_obj_popleft(mp_obj_t self_in) { ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -124,6 +129,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_popleft_obj, ps2io_ps2_obj_popleft); //| //| :param int byte: byte value of the command""" //| ... +//| static mp_obj_t ps2io_ps2_obj_sendcmd(mp_obj_t self_in, mp_obj_t ob) { ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -165,6 +171,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(ps2io_ps2_sendcmd_obj, ps2io_ps2_obj_sendcmd); //| //| 0x2000: device didn't send a response byte in time""" //| ... +//| static mp_obj_t ps2io_ps2_obj_clear_errors(mp_obj_t self_in) { ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -179,6 +186,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_clear_errors_obj, ps2io_ps2_obj_clear_errors //| to :py:func:`popleft()`.""" //| ... //| +//| static mp_obj_t ps2_unary_op(mp_unary_op_t op, mp_obj_t self_in) { ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index e44c2b273c..9d663cbe0d 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -56,6 +56,7 @@ //| # Resume with an 80 microsecond active pulse //| pulses.resume(80)""" //| ... +//| static mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pin, ARG_maxlen, ARG_idle_state }; static const mp_arg_t allowed_args[] = { @@ -78,6 +79,7 @@ static mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg //| def deinit(self) -> None: //| """Deinitialises the PulseIn and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t pulseio_pulsein_deinit(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_pulseio_pulsein_deinit(self); @@ -94,12 +96,14 @@ static void check_for_deinit(pulseio_pulsein_obj_t *self) { //| def __enter__(self) -> PulseIn: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t pulseio_pulsein_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_pulseio_pulsein_deinit(args[0]); @@ -110,6 +114,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulsein___exit___obj, 4, 4, p //| def pause(self) -> None: //| """Pause pulse capture""" //| ... +//| static mp_obj_t pulseio_pulsein_obj_pause(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -129,6 +134,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_pause_obj, pulseio_pulsein_obj_pause); //| //| :param int trigger_duration: trigger pulse duration in microseconds""" //| ... +//| static mp_obj_t pulseio_pulsein_obj_resume(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_trigger_duration }; static const mp_arg_t allowed_args[] = { @@ -148,6 +154,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(pulseio_pulsein_resume_obj, 1, pulseio_pulsein_obj_re //| def clear(self) -> None: //| """Clears all captured pulses""" //| ... +//| static mp_obj_t pulseio_pulsein_obj_clear(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -160,6 +167,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_clear_obj, pulseio_pulsein_obj_clear); //| def popleft(self) -> int: //| """Removes and returns the oldest read pulse duration in microseconds.""" //| ... +//| static mp_obj_t pulseio_pulsein_obj_popleft(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -185,6 +193,7 @@ MP_PROPERTY_GETTER(pulseio_pulsein_maxlen_obj, //| paused: bool //| """True when pulse capture is paused as a result of :py:func:`pause` or an error during capture //| such as a signal that is too fast.""" +//| static mp_obj_t pulseio_pulsein_obj_get_paused(mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -205,6 +214,7 @@ MP_PROPERTY_GETTER(pulseio_pulsein_paused_obj, //| pulses = pulseio.PulseIn(pin) //| print(len(pulses))""" //| ... +//| static mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -228,6 +238,7 @@ static mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { //| print(pulses[0])""" //| ... //| +//| static mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { // delete item diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 92775ff59f..042515a713 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -44,6 +44,7 @@ //| pulses[0] = 200 //| pulse.send(pulses)""" //| ... +//| static mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_PULSEIO_PULSEOUT enum { ARG_pin, ARG_frequency, ARG_duty_cycle}; @@ -71,6 +72,7 @@ static mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar //| def deinit(self) -> None: //| """Deinitialises the PulseOut and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t pulseio_pulseout_deinit(mp_obj_t self_in) { pulseio_pulseout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_pulseio_pulseout_deinit(self); @@ -81,12 +83,14 @@ static MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulseout_deinit_obj, pulseio_pulseout_d //| def __enter__(self) -> PulseOut: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t pulseio_pulseout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_pulseio_pulseout_deinit(args[0]); @@ -105,6 +109,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulseout___exit___obj, 4, 4, //| :param array.array pulses: pulse durations in microseconds""" //| ... //| +//| static mp_obj_t pulseio_pulseout_obj_send(mp_obj_t self_in, mp_obj_t pulses) { pulseio_pulseout_obj_t *self = MP_OBJ_TO_PTR(self_in); if (common_hal_pulseio_pulseout_deinited(self)) { diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index 0504454bd4..6665ee082f 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -70,7 +70,7 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { //| *, //| duty_cycle: int = 0, //| frequency: int = 500, -//| variable_frequency: bool = False +//| variable_frequency: bool = False, //| ) -> None: //| """Create a PWM object associated with the given pin. This allows you to //| write PWM signals out on the given pin. Frequency is fixed after init @@ -131,6 +131,7 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { //| //| """ //| ... +//| static mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { enum { ARG_pin, ARG_duty_cycle, ARG_frequency, ARG_variable_frequency }; static const mp_arg_t allowed_args[] = { @@ -159,6 +160,7 @@ static mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, //| def deinit(self) -> None: //| """Deinitialises the PWMOut and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t pwmio_pwmout_deinit(mp_obj_t self_in) { pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_pwmio_pwmout_deinit(self); @@ -175,12 +177,14 @@ static void check_for_deinit(pwmio_pwmout_obj_t *self) { //| def __enter__(self) -> PWMOut: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t pwmio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_pwmio_pwmout_deinit(args[0]); @@ -231,6 +235,7 @@ MP_PROPERTY_GETSET(pwmio_pwmout_duty_cycle_obj, //| to manually re-set the duty cycle. However, an output glitch may occur during the adjustment. //| """ //| +//| static mp_obj_t pwmio_pwmout_obj_get_frequency(mp_obj_t self_in) { pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/qrio/PixelPolicy.c b/shared-bindings/qrio/PixelPolicy.c index b8a422c40f..6acce4984a 100644 --- a/shared-bindings/qrio/PixelPolicy.c +++ b/shared-bindings/qrio/PixelPolicy.c @@ -25,6 +25,7 @@ //| RGB565: PixelPolicy //| """The input buffer to `QRDecoder.decode` consists of RGB565 values in native order. The green component is used.""" //| +//| MAKE_ENUM_VALUE(qrio_pixel_policy_type, qrio_pixel_policy, EVERY_BYTE, QRIO_EVERY_BYTE); MAKE_ENUM_VALUE(qrio_pixel_policy_type, qrio_pixel_policy, RGB565, QRIO_RGB565); diff --git a/shared-bindings/qrio/QRDecoder.c b/shared-bindings/qrio/QRDecoder.c index d9a7b31708..6a36d8b026 100644 --- a/shared-bindings/qrio/QRDecoder.c +++ b/shared-bindings/qrio/QRDecoder.c @@ -20,6 +20,7 @@ //| :param int height: The pixel height of the image to decode //| """ //| ... +//| static mp_obj_t qrio_qrdecoder_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args_in) { enum { ARG_width, ARG_height }; @@ -53,6 +54,7 @@ static void verify_buffer_size(qrio_qrdecoder_obj_t *self, mp_obj_t *buffer, siz //| self, buffer: ReadableBuffer, pixel_policy: PixelPolicy = PixelPolicy.EVERY_BYTE //| ) -> List[QRInfo]: //| """Decode zero or more QR codes from the given image. The size of the buffer must be at least ``length``×``width`` bytes for `EVERY_BYTE`, and 2×``length``×``width`` bytes for `EVEN_BYTES` or `ODD_BYTES`.""" +//| static mp_obj_t qrio_qrdecoder_decode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { qrio_qrdecoder_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -78,6 +80,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(qrio_qrdecoder_decode_obj, 1, qrio_qrdecoder_decode); //| self, buffer: ReadableBuffer, pixel_policy: PixelPolicy = PixelPolicy.EVERY_BYTE //| ) -> List[QRPosition]: //| """Find all visible QR codes from the given image. The size of the buffer must be at least ``length``×``width`` bytes for `EVERY_BYTE`, and 2×``length``×``width`` bytes for `EVEN_BYTES` or `ODD_BYTES`.""" +//| static mp_obj_t qrio_qrdecoder_find(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { qrio_qrdecoder_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -122,6 +125,7 @@ MP_PROPERTY_GETSET(qrio_qrdecoder_width_obj, //| height: int //| """The height of image the decoder expects""" //| +//| static mp_obj_t qrio_qrdecoder_get_height(mp_obj_t self_in) { qrio_qrdecoder_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_int(shared_module_qrio_qrdecoder_get_height(self)); diff --git a/shared-bindings/qrio/QRInfo.c b/shared-bindings/qrio/QRInfo.c index 3f63c21e3c..351ee32210 100644 --- a/shared-bindings/qrio/QRInfo.c +++ b/shared-bindings/qrio/QRInfo.c @@ -18,6 +18,7 @@ //| data_type: Union[str, int] //| """The encoding of the payload as a string (if a standard encoding) or int (if not standard)""" //| +//| const mp_obj_namedtuple_type_t qrio_qrinfo_type_obj = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_QRInfo), @@ -58,6 +59,7 @@ const mp_obj_namedtuple_type_t qrio_qrinfo_type_obj = { //| size: int //| """The number of bits the code contains""" //| +//| const mp_obj_namedtuple_type_t qrio_qrposition_type_obj = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS(MP_QSTR_QRPosition), diff --git a/shared-bindings/rainbowio/__init__.c b/shared-bindings/rainbowio/__init__.c index a5a941e2a7..a085669d7f 100644 --- a/shared-bindings/rainbowio/__init__.c +++ b/shared-bindings/rainbowio/__init__.c @@ -13,12 +13,14 @@ //| //| Provides the `colorwheel()` function.""" //| +//| //| def colorwheel(n: float) -> int: //| """C implementation of the common colorwheel() function found in many examples. //| Returns the colorwheel RGB value as an integer value for n (usable in neopixel and dotstar). //| """ //| ... //| +//| static mp_obj_t rainbowio_colorwheel(mp_obj_t n) { mp_float_t f = mp_obj_get_float(n); return MP_OBJ_NEW_SMALL_INT(colorwheel(f)); diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index e255174fc1..81201e6f8a 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -27,12 +27,14 @@ //| //| _T = TypeVar("_T") //| +//| //| def seed(seed: int) -> None: //| """Sets the starting seed of the random number generation. Further calls to //| `random` will return deterministic results afterwards.""" //| ... //| +//| static mp_obj_t random_seed(mp_obj_t seed_in) { mp_uint_t seed = mp_obj_get_int_truncated(seed_in); shared_modules_random_seed(seed); @@ -44,6 +46,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(random_seed_obj, random_seed); //| """Returns an integer with *k* random bits.""" //| ... //| +//| static mp_obj_t random_getrandbits(mp_obj_t num_in) { mp_int_t n = mp_obj_get_int(num_in); if (n > 32 || n < 0) { @@ -62,6 +65,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(random_getrandbits_obj, random_getrandbits); //| """Returns a randomly selected integer from ``range(start[, stop[, step]])``.""" //| ... //| +//| static mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { mp_int_t start = 0; mp_int_t stop = mp_obj_get_int(args[0]); @@ -105,6 +109,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(random_randrange_obj, 1, 3, random_ra //| to ``randrange(a, b + 1, 1)``""" //| ... //| +//| static mp_obj_t random_randint(mp_obj_t a_in, mp_obj_t b_in) { mp_int_t a = mp_obj_get_int(a_in); mp_int_t b = mp_obj_get_int(b_in); @@ -120,6 +125,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(random_randint_obj, random_randint); //| IndexError when the sequence is empty.""" //| ... //| +//| static mp_obj_t random_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len == 0) { @@ -133,6 +139,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(random_choice_obj, random_choice); //| """Returns a random float between 0 and 1.0.""" //| ... //| +//| static mp_obj_t random_random(void) { return mp_obj_new_float(shared_modules_random_random()); } @@ -143,6 +150,7 @@ static MP_DEFINE_CONST_FUN_OBJ_0(random_random_obj, random_random); //| depending on float rounding.""" //| ... //| +//| static mp_obj_t random_uniform(mp_obj_t a_in, mp_obj_t b_in) { mp_float_t a = mp_obj_get_float(a_in); mp_float_t b = mp_obj_get_float(b_in); diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index bb4b509333..6242f981fd 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -130,7 +130,7 @@ static void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ //| framebuffer: Optional[WriteableBuffer] = None, //| height: int = 0, //| tile: int = 1, -//| serpentine: bool = True +//| serpentine: bool = True, //| ) -> None: //| """Create a RGBMatrix object with the given attributes. The height of //| the display is determined by the number of rgb and address pins and the number of tiles: @@ -193,6 +193,7 @@ static void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ //| :param Optional[WriteableBuffer] framebuffer: A pre-allocated framebuffer to use. If unspecified, a framebuffer is allocated //| :param int height: The optional overall height of the whole matrix in pixels. This value is not required because it can be calculated as described above. //| """ +//| static mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_width, ARG_bit_depth, ARG_rgb_list, ARG_addr_list, @@ -269,6 +270,7 @@ static mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n //| rgbmatrix instance. After deinitialization, no further operations //| may be performed.""" //| ... +//| static mp_obj_t rgbmatrix_rgbmatrix_deinit(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; common_hal_rgbmatrix_rgbmatrix_deinit(self); @@ -286,6 +288,7 @@ static void check_for_deinit(rgbmatrix_rgbmatrix_obj_t *self) { //| brightness: float //| """In the current implementation, 0.0 turns the display off entirely //| and any other value up to 1.0 turns the display on fully.""" +//| static mp_obj_t rgbmatrix_rgbmatrix_get_brightness(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); @@ -314,6 +317,7 @@ MP_PROPERTY_GETSET(rgbmatrix_rgbmatrix_brightness_obj, //| """Transmits the color data in the buffer to the pixels so that //| they are shown.""" //| ... +//| static mp_obj_t rgbmatrix_rgbmatrix_refresh(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); @@ -336,6 +340,7 @@ MP_PROPERTY_GETTER(rgbmatrix_rgbmatrix_width_obj, //| height: int //| """The height of the display, in pixels""" //| +//| static mp_obj_t rgbmatrix_rgbmatrix_get_height(mp_obj_t self_in) { rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index 6cd137dd71..0dd702d2c8 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -44,6 +44,7 @@ //| print(position) //| last_position = position""" //| ... +//| static mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pin_a, ARG_pin_b, ARG_divisor }; static const mp_arg_t allowed_args[] = { @@ -68,6 +69,7 @@ static mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, //| def deinit(self) -> None: //| """Deinitializes the IncrementalEncoder and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t rotaryio_incrementalencoder_deinit(mp_obj_t self_in) { rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_rotaryio_incrementalencoder_deinit(self); @@ -84,12 +86,14 @@ static void check_for_deinit(rotaryio_incrementalencoder_obj_t *self) { //| def __enter__(self) -> IncrementalEncoder: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t rotaryio_incrementalencoder_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_rotaryio_incrementalencoder_deinit(args[0]); @@ -127,6 +131,7 @@ MP_PROPERTY_GETSET(rotaryio_incrementalencoder_divisor_obj, //| """The current position in terms of pulses. The number of pulses per rotation is defined by the //| specific hardware and by the divisor.""" //| +//| static mp_obj_t rotaryio_incrementalencoder_obj_get_position(mp_obj_t self_in) { rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index 3a236e0701..d732ee94d7 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -23,6 +23,7 @@ const rtc_rtc_obj_t rtc_rtc_obj = {{&rtc_rtc_type}}; //| def __init__(self) -> None: //| """This class represents the onboard Real Time Clock. It is a singleton and will always return the same instance.""" //| ... +//| static mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // No arguments mp_arg_check_num(n_args, n_kw, 0, 0, false); @@ -83,6 +84,7 @@ MP_PROPERTY_GETSET(rtc_rtc_datetime_obj, //| r = rtc.RTC() //| r.calibration = 1""" //| +//| static mp_obj_t rtc_rtc_obj_get_calibration(mp_obj_t self_in) { int calibration = common_hal_rtc_get_calibration(); return mp_obj_new_int(calibration); diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c index 16158413d1..d719ec8441 100644 --- a/shared-bindings/rtc/__init__.c +++ b/shared-bindings/rtc/__init__.c @@ -17,6 +17,7 @@ //| RTC using :class:`rtc.RTC`. It also backs the :func:`time.time` and :func:`time.localtime` //| functions using the onboard RTC if present.""" //| +//| void rtc_reset(void) { MP_STATE_VM(rtc_time_source) = (mp_obj_t)&rtc_rtc_obj; @@ -47,6 +48,7 @@ mp_obj_t rtc_get_time_source_time(void) { //| rtc.set_time_source(r)""" //| ... //| +//| static mp_obj_t rtc_set_time_source(mp_obj_t time_source) { MP_STATE_VM(rtc_time_source) = time_source; diff --git a/shared-bindings/sdcardio/SDCard.c b/shared-bindings/sdcardio/SDCard.c index 97bd51c001..e6d8453eae 100644 --- a/shared-bindings/sdcardio/SDCard.c +++ b/shared-bindings/sdcardio/SDCard.c @@ -56,6 +56,7 @@ //| vfs = storage.VfsFat(sd) //| storage.mount(vfs, '/sd') //| os.listdir('/sd')""" +//| static mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_spi, ARG_cs, ARG_baudrate, NUM_ARGS }; @@ -85,6 +86,7 @@ static mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_arg //| Due to technical limitations, this is a function and not a property. //| //| :return: The number of 512-byte blocks, as a number""" +//| static mp_obj_t sdcardio_sdcard_count(mp_obj_t self_in) { sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; return mp_obj_new_int_from_ull(common_hal_sdcardio_sdcard_get_blockcount(self)); @@ -95,6 +97,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_count_obj, sdcardio_sdcard_count); //| """Disable permanently. //| //| :return: None""" +//| static mp_obj_t sdcardio_sdcard_deinit(mp_obj_t self_in) { sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; common_hal_sdcardio_sdcard_deinit(self); @@ -110,6 +113,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_deinit_obj, sdcardio_sdcard_deinit); //| :param ~circuitpython_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512. //| //| :return: None""" +//| static mp_obj_t _sdcardio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { uint32_t start_block = mp_obj_get_int(start_block_in); @@ -130,6 +134,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(sdcardio_sdcard_readblocks_obj, _sdcardio_sdcard_readb //| //| :return: None""" //| ... +//| static mp_obj_t sdcardio_sdcard_sync(mp_obj_t self_in) { sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; int result = common_hal_sdcardio_sdcard_sync(self); @@ -150,6 +155,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_sync_obj, sdcardio_sdcard_sync); //| //| :return: None""" //| +//| static mp_obj_t _sdcardio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { uint32_t start_block = mp_obj_get_int(start_block_in); diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index 98a9ef6c85..9b616eba2e 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -61,6 +61,7 @@ //| storage.mount(vfs, '/sd') //| os.listdir('/sd')""" //| ... +//| static mp_obj_t sdioio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { sdioio_sdcard_obj_t *self = mp_obj_malloc(sdioio_sdcard_obj_t, &sdioio_SDCard_type); @@ -99,6 +100,7 @@ static void check_for_deinit(sdioio_sdcard_obj_t *self) { //| :param int width: the number of data lines to use. Must be 1 or 4 and must also not exceed the number of data lines at construction //| //| .. note:: Leaving a value unspecified or 0 means the current setting is kept""" +//| static mp_obj_t sdioio_sdcard_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_frequency, ARG_width, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -130,6 +132,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(sdioio_sdcard_configure_obj, 1, sdioio_sdcard_configu //| Due to technical limitations, this is a function and not a property. //| //| :return: The number of 512-byte blocks, as a number""" +//| static mp_obj_t sdioio_sdcard_count(mp_obj_t self_in) { sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -144,6 +147,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_count_obj, sdioio_sdcard_count); //| :param ~circuitpython_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512. //| //| :return: None""" +//| static mp_obj_t _sdioio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; @@ -165,6 +169,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(sdioio_sdcard_readblocks_obj, _sdioio_sdcard_readblock //| :param ~circuitpython_typing.ReadableBuffer buf: The buffer to read from. Length must be multiple of 512. //| //| :return: None""" +//| static mp_obj_t _sdioio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; @@ -194,6 +199,7 @@ MP_PROPERTY_GETTER(sdioio_sdcard_frequency_obj, //| width: int //| """The actual SDIO bus width, in bits""" +//| static mp_obj_t sdioio_sdcard_obj_get_width(mp_obj_t self_in) { sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -208,6 +214,7 @@ MP_PROPERTY_GETTER(sdioio_sdcard_width_obj, //| """Disable permanently. //| //| :return: None""" +//| static mp_obj_t sdioio_sdcard_obj_deinit(mp_obj_t self_in) { sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_sdioio_sdcard_deinit(self); @@ -219,12 +226,14 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_deinit_obj, sdioio_sdcard_obj_deinit); //| """No-op used by Context Managers. //| Provided by context manager helper.""" //| ... +//| //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... //| +//| static mp_obj_t sdioio_sdcard_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_sdioio_sdcard_deinit(args[0]); diff --git a/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c b/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c index 3dd4e2717e..e1e2469e36 100644 --- a/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c @@ -40,6 +40,7 @@ //| :param bool jdi_display: When True, work with an 8-color JDI display. Otherwise, a monochrome Sharp display. //| """ //| ... +//| static mp_obj_t sharpdisplay_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_spi_bus, ARG_chip_select, ARG_width, ARG_height, ARG_baudrate, ARG_jdi_display, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -83,6 +84,7 @@ static mp_int_t sharpdisplay_framebuffer_get_buffer(mp_obj_t self_in, mp_buffer_ //| may be performed.""" //| ... //| +//| static mp_obj_t sharpdisplay_framebuffer_deinit(mp_obj_t self_in) { sharpdisplay_framebuffer_obj_t *self = (sharpdisplay_framebuffer_obj_t *)self_in; common_hal_sharpdisplay_framebuffer_deinit(self); diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index 25d10c2948..5dac9d150e 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -32,18 +32,21 @@ //| def __hash__(self) -> int: //| """Returns a hash for the Socket.""" //| ... +//| // Provided inherently. // See https://github.com/micropython/micropython/pull/10348. //| def __enter__(self) -> Socket: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically closes the Socket when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t socketpool_socket___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_socketpool_socket_close(args[0]); @@ -55,6 +58,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket___exit___obj, 4, 4, //| """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)""" +//| static mp_obj_t _socketpool_socket_accept(mp_obj_t self_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -70,6 +74,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(socketpool_socket_accept_obj, _socketpool_socke //| //| :param ~tuple address: tuple of (remote_address, remote_port)""" //| ... +//| static mp_obj_t socketpool_socket_bind(mp_obj_t self_in, mp_obj_t addr_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -94,6 +99,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_bind_obj, socketpool_socket_b //| def close(self) -> None: //| """Closes this Socket and makes its resources available to its SocketPool.""" +//| static mp_obj_t _socketpool_socket_close(mp_obj_t self_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_socketpool_socket_close(self); @@ -106,6 +112,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(socketpool_socket_close_obj, _socketpool_socket //| //| :param ~tuple address: tuple of (remote_address, remote_port)""" //| ... +//| static mp_obj_t socketpool_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -130,6 +137,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_connect_obj, socketpool_socke //| //| :param ~int backlog: length of backlog queue for waiting connections""" //| ... +//| static mp_obj_t socketpool_socket_listen(mp_obj_t self_in, mp_obj_t backlog_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -149,6 +157,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_listen_obj, socketpool_socket //| //| :param object buffer: buffer to read into""" //| ... +//| static mp_obj_t socketpool_socket_recvfrom_into(mp_obj_t self_in, mp_obj_t data_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_buffer_info_t bufinfo; @@ -174,6 +183,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_recvfrom_into_obj, socketpool //| :param bytearray buffer: buffer to receive into //| :param int bufsize: optionally, a maximum number of bytes to read.""" //| ... +//| static mp_obj_t _socketpool_socket_recv_into(size_t n_args, const mp_obj_t *args) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(args[0]); if (common_hal_socketpool_socket_get_closed(self)) { @@ -212,6 +222,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket_recv_into_obj, 2, 3 //| //| :param ~bytes bytes: some bytes to send""" //| ... +//| static mp_obj_t _socketpool_socket_send(mp_obj_t self_in, mp_obj_t buf_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); if (common_hal_socketpool_socket_get_closed(self)) { @@ -241,6 +252,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_send_obj, _socketpool_socket_ //| //| :param ~bytes bytes: some bytes to send""" //| ... +//| static mp_obj_t _socketpool_socket_sendall(mp_obj_t self_in, mp_obj_t buf_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); if (common_hal_socketpool_socket_get_closed(self)) { @@ -278,6 +290,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_sendall_obj, _socketpool_sock //| :param ~bytes bytes: some bytes to send //| :param ~tuple address: tuple of (remote_address, remote_port)""" //| ... +//| static mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -306,6 +319,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(socketpool_socket_sendto_obj, socketpool_socket //| //| :param ~bool flag: False means non-blocking, True means block indefinitely.""" //| ... +//| // method socket.setblocking(flag) static mp_obj_t socketpool_socket_setblocking(mp_obj_t self_in, mp_obj_t blocking) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -321,6 +335,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_setblocking_obj, socketpool_s //| def setsockopt(self, level: int, optname: int, value: int) -> None: //| """Sets socket options""" //| ... +//| static mp_obj_t socketpool_socket_setsockopt(size_t n_args, const mp_obj_t *args) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(args[0]); mp_int_t level = mp_obj_get_int(args[1]); @@ -356,6 +371,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket_setsockopt_obj, 4, //| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely. //| """ //| ... +//| static mp_obj_t socketpool_socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_uint_t timeout_ms; @@ -376,6 +392,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_settimeout_obj, socketpool_so //| type: int //| """Read-only access to the socket type""" //| +//| static mp_obj_t socketpool_socket_obj_get_type(mp_obj_t self_in) { socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); return MP_OBJ_NEW_SMALL_INT(common_hal_socketpool_socket_get_type(self)); diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index b37d02dc57..e58b75ba92 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -86,6 +86,7 @@ MP_DEFINE_EXCEPTION(gaierror, OSError) //| in CPython is not supported. //| """ //| ... +//| static mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_family, ARG_type, ARG_proto }; static const mp_arg_t allowed_args[] = { @@ -126,6 +127,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socke //| as a tuple.""" //| ... //| +//| static mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_host, ARG_port, ARG_family, ARG_type, ARG_proto, ARG_flags }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 9c7f098cc4..078a716cdb 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -40,6 +40,7 @@ static mp_obj_t ssl_sslcontext_make_new(const mp_obj_type_t *type, size_t n_args //| needed to establish the certificate's authenticity. The keyfile string //| must point to a file containing the private key. //| """ +//| static void get_file_contents(mp_obj_t name_obj, mp_buffer_info_t *bufinfo) { mp_obj_t file = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), name_obj, MP_OBJ_NEW_QSTR(MP_QSTR_rb)); @@ -88,6 +89,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_load_cert_chain_obj, 1, ssl_ssl //| :param str cadata: A single CA certificate in PEM format. **Limitation**: CPython allows one //| or more certificates, but this implementation is limited to one. //| """ +//| static mp_obj_t ssl_sslcontext_load_verify_locations(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_cafile, ARG_capath, ARG_cadata }; static const mp_arg_t allowed_args[] = { @@ -117,6 +119,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_load_verify_locations_obj, 1, s //| def set_default_verify_paths(self) -> None: //| """Load a set of default certification authority (CA) certificates.""" +//| static mp_obj_t ssl_sslcontext_set_default_verify_paths(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { ssl_sslcontext_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -128,6 +131,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_set_default_verify_paths_obj, 1 //| check_hostname: bool //| """Whether to match the peer certificate's hostname.""" +//| static mp_obj_t ssl_sslcontext_get_check_hostname(mp_obj_t self_in) { ssl_sslcontext_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -153,11 +157,12 @@ MP_PROPERTY_GETSET(ssl_sslcontext_check_hostname_obj, //| sock: socketpool.Socket, //| *, //| server_side: bool = False, -//| server_hostname: Optional[str] = None +//| server_hostname: Optional[str] = None, //| ) -> ssl.SSLSocket: //| """Wraps the socket into a socket-compatible class that handles SSL negotiation. //| The socket must be of type SOCK_STREAM.""" //| +//| static mp_obj_t ssl_sslcontext_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sock, ARG_server_side, ARG_server_hostname }; diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c index 3ed4fa3662..92440f9ea3 100644 --- a/shared-bindings/ssl/SSLSocket.c +++ b/shared-bindings/ssl/SSLSocket.c @@ -29,18 +29,21 @@ //| def __hash__(self) -> int: //| """Returns a hash for the Socket.""" //| ... +//| // Provided by automatic inclusion of hash() // https://github.com/micropython/micropython/pull/10348 //| def __enter__(self) -> SSLSocket: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically closes the Socket when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t ssl_sslsocket___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_ssl_sslsocket_close(args[0]); @@ -52,6 +55,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ssl_sslsocket___exit___obj, 4, 4, ssl //| """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)""" +//| static mp_obj_t ssl_sslsocket_accept(mp_obj_t self_in) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); return common_hal_ssl_sslsocket_accept(self); @@ -63,6 +67,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(ssl_sslsocket_accept_obj, ssl_sslsocket_accept) //| //| :param ~tuple address: tuple of (remote_address, remote_port)""" //| ... +//| static mp_obj_t ssl_sslsocket_bind(mp_obj_t self_in, mp_obj_t addr_in) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -76,6 +81,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_bind_obj, ssl_sslsocket_bind); //| def close(self) -> None: //| """Closes this Socket""" +//| static mp_obj_t ssl_sslsocket_close(mp_obj_t self_in) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_ssl_sslsocket_close(self); @@ -88,6 +94,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(ssl_sslsocket_close_obj, ssl_sslsocket_close); //| //| :param ~tuple address: tuple of (remote_address, remote_port)""" //| ... +//| static mp_obj_t ssl_sslsocket_connect(mp_obj_t self_in, mp_obj_t addr_in) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_ssl_sslsocket_connect(self, addr_in); @@ -101,6 +108,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_connect_obj, ssl_sslsocket_connec //| //| :param ~int backlog: length of backlog queue for waiting connetions""" //| ... +//| static mp_obj_t ssl_sslsocket_listen(mp_obj_t self_in, mp_obj_t backlog_in) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -124,6 +132,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_listen_obj, ssl_sslsocket_listen) //| :param bytearray buffer: buffer to receive into //| :param int bufsize: optionally, a maximum number of bytes to read.""" //| ... +//| static mp_obj_t ssl_sslsocket_recv_into(size_t n_args, const mp_obj_t *args) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(args[0]); if (common_hal_ssl_sslsocket_get_closed(self)) { @@ -162,6 +171,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ssl_sslsocket_recv_into_obj, 2, 3, ss //| //| :param ~bytes bytes: some bytes to send""" //| ... +//| static mp_obj_t ssl_sslsocket_send(mp_obj_t self_in, mp_obj_t buf_in) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); if (common_hal_ssl_sslsocket_get_closed(self)) { @@ -204,6 +214,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ssl_sslsocket_setsockopt_obj, 4, 4, s //| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely. //| """ //| ... +//| static mp_obj_t ssl_sslsocket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_ssl_sslsocket_settimeout(self, timeout_in); @@ -217,6 +228,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslsocket_settimeout_obj, ssl_sslsocket_set //| :param ~bool flag: False means non-blocking, True means block indefinitely.""" //| ... //| +//| // method socket.setblocking(flag) static mp_obj_t ssl_sslsocket_setblocking(mp_obj_t self_in, mp_obj_t blocking) { ssl_sslsocket_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/ssl/__init__.c b/shared-bindings/ssl/__init__.c index 9a5f94636a..0d10090e9c 100644 --- a/shared-bindings/ssl/__init__.c +++ b/shared-bindings/ssl/__init__.c @@ -17,11 +17,13 @@ //| |see_cpython_module| :mod:`cpython:ssl`. //| """ //| +//| //| def create_default_context() -> ssl.SSLContext: //| """Return the default SSLContext.""" //| ... //| +//| static mp_obj_t ssl_create_default_context(void) { ssl_sslcontext_obj_t *s = mp_obj_malloc(ssl_sslcontext_obj_t, &ssl_sslcontext_type); diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index e046c11879..002acaa8f2 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -27,6 +27,7 @@ //| `_. //| """ //| +//| //| def mount(filesystem: VfsFat, mount_path: str, *, readonly: bool = False) -> None: //| """Mounts the given filesystem object at the given path. //| @@ -38,6 +39,7 @@ //| """ //| ... //| +//| static mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_filesystem, ARG_mount_path, ARG_readonly }; static const mp_arg_t allowed_args[] = { @@ -75,6 +77,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 0, storage_mount); //| This is the CircuitPython analog to the UNIX ``umount`` command.""" //| ... //| +//| static mp_obj_t storage_umount(mp_obj_t mnt_in) { if (mp_obj_is_str(mnt_in)) { common_hal_storage_umount_path(mp_obj_str_get_str(mnt_in)); @@ -90,7 +93,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount); //| mount_path: str, //| readonly: bool = False, //| *, -//| disable_concurrent_write_protection: bool = False +//| disable_concurrent_write_protection: bool = False, //| ) -> None: //| """Remounts the given path with new parameters. //| @@ -102,6 +105,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount); //| filesystem will be corrupted.""" //| ... //| +//| static mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_mount_path, ARG_readonly, ARG_disable_concurrent_write_protection }; static const mp_arg_t allowed_args[] = { @@ -125,6 +129,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 0, storage_remount); //| """Retrieves the mount object associated with the mount path""" //| ... //| +//| static mp_obj_t storage_getmount(const mp_obj_t mnt_in) { return common_hal_storage_getmount(mp_obj_str_get_str(mnt_in)); } @@ -152,6 +157,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount); //| CircuitPython will restart on certain boards.""" //| ... //| +//| static mp_obj_t storage_erase_filesystem(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_extended }; @@ -182,6 +188,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(storage_erase_filesystem_obj, 0, storage_erase_filesy //| Can be called in ``boot.py``, before USB is connected.""" //| ... //| +//| static mp_obj_t storage_disable_usb_drive(void) { #if CIRCUITPY_USB_DEVICE && CIRCUITPY_USB_MSC if (!common_hal_storage_disable_usb_drive()) { @@ -207,6 +214,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(storage_disable_usb_drive_obj, storage_disable_usb_dri //| """ //| ... //| +//| static mp_obj_t storage_enable_usb_drive(void) { #if CIRCUITPY_USB_DEVICE && CIRCUITPY_USB_MSC if (!common_hal_storage_enable_usb_drive()) { @@ -235,6 +243,7 @@ static const mp_rom_map_elem_t storage_module_globals_table[] = { //| """Create a new VfsFat filesystem around the given block device. //| //| :param block_device: Block device the the filesystem lives on""" +//| //| label: str //| """The filesystem label, up to 11 case-insensitive bytes. Note that //| this property can only be set when the device is writable by the @@ -290,6 +299,7 @@ static const mp_rom_map_elem_t storage_module_globals_table[] = { //| def umount(self) -> None: //| """Don't call this directly, call `storage.umount`.""" //| ... +//| //| { MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) }, }; diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c index eded8b1a3d..3f9fd40895 100644 --- a/shared-bindings/struct/__init__.c +++ b/shared-bindings/struct/__init__.c @@ -26,12 +26,14 @@ //| Supported format codes: *b*, *B*, *x*, *h*, *H*, *i*, *I*, *l*, *L*, *q*, *Q*, //| *s*, *P*, *f*, *d* (the latter 2 depending on the floating-point support).""" //| +//| //| def calcsize(fmt: str) -> int: //| """Return the number of bytes needed to store the given fmt.""" //| ... //| +//| static mp_obj_t struct_calcsize(mp_obj_t fmt_in) { @@ -44,6 +46,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize); //| The return value is a bytes object encoding the values.""" //| ... //| +//| static mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) { mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); @@ -62,6 +65,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, str //| starting at offset. offset may be negative to count from the end of buffer.""" //| ... //| +//| static mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { mp_buffer_info_t bufinfo; @@ -89,6 +93,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX //| required by the format.""" //| ... //| +//| static mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) { mp_buffer_info_t bufinfo; @@ -108,6 +113,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_obj, 2, 3, struct_unpack); //| as the size required by the form.""" //| ... //| +//| static mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_format, ARG_buffer, ARG_offset }; diff --git a/shared-bindings/supervisor/RunReason.c b/shared-bindings/supervisor/RunReason.c index 5fc29fa27b..3a0005a3dd 100644 --- a/shared-bindings/supervisor/RunReason.c +++ b/shared-bindings/supervisor/RunReason.c @@ -29,6 +29,7 @@ MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_ //| REPL_RELOAD: object //| """CircuitPython started due to the user typing CTRL-D in the REPL.""" //| +//| MAKE_ENUM_MAP(supervisor_run_reason) { MAKE_ENUM_MAP_ENTRY(run_reason, STARTUP), MAKE_ENUM_MAP_ENTRY(run_reason, AUTO_RELOAD), diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 5c4754b85f..9332cacb3e 100644 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -42,6 +42,7 @@ static supervisor_run_reason_t _run_reason; //| """You cannot create an instance of `supervisor.Runtime`. //| Use `supervisor.runtime` to access the sole instance available.""" //| ... +//| //| usb_connected: bool //| """Returns the USB enumeration status (read-only).""" @@ -182,6 +183,7 @@ MP_PROPERTY_GETSET(supervisor_runtime_ble_workflow_obj, //| after the current code finishes and the status LED is used to show //| the finish state.""" //| +//| static mp_obj_t supervisor_runtime_get_rgb_status_brightness(mp_obj_t self) { return MP_OBJ_NEW_SMALL_INT(get_status_brightness()); } diff --git a/shared-bindings/supervisor/SafeModeReason.c b/shared-bindings/supervisor/SafeModeReason.c index e2cbac3b9a..ff85d8a3d5 100644 --- a/shared-bindings/supervisor/SafeModeReason.c +++ b/shared-bindings/supervisor/SafeModeReason.c @@ -127,6 +127,7 @@ MAKE_ENUM_MAP(supervisor_safe_mode_reason) { //| WATCHDOG: object //| """An internal watchdog timer expired.""" +//| //| MAKE_ENUM_MAP_ENTRY(safe_mode_reason, WATCHDOG), }; diff --git a/shared-bindings/supervisor/StatusBar.c b/shared-bindings/supervisor/StatusBar.c index 46e7962cf0..be109a6e22 100644 --- a/shared-bindings/supervisor/StatusBar.c +++ b/shared-bindings/supervisor/StatusBar.c @@ -26,6 +26,7 @@ //| """You cannot create an instance of `supervisor.StatusBar`. //| Use `supervisor.status_bar` to access the sole instance available.""" //| ... +//| //| console: bool //| """Whether status bar information is sent over the console (REPL) serial connection, @@ -65,6 +66,7 @@ MP_PROPERTY_GETSET(supervisor_status_bar_console_obj, //| Not available if `terminalio` is not available. //| """ //| +//| static mp_obj_t supervisor_status_bar_get_display(mp_obj_t self_in) { #if CIRCUITPY_STATUS_BAR && CIRCUITPY_TERMINALIO supervisor_status_bar_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index e09094ff88..7b1eac7c2a 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -27,6 +27,7 @@ #include "shared-bindings/supervisor/StatusBar.h" //| """Supervisor settings""" +//| //| runtime: Runtime //| """Runtime information, such as ``runtime.serial_connected`` @@ -40,11 +41,13 @@ //| the last exception name and location, and firmware version information. //| This object is the sole instance of `supervisor.StatusBar`.""" //| +//| //| def reload() -> None: //| """Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL).""" //| ... //| +//| static mp_obj_t supervisor_reload(void) { reload_initiate(RUN_REASON_SUPERVISOR_RELOAD); return mp_const_none; @@ -58,7 +61,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload); //| reload_on_error: bool = False, //| sticky_on_success: bool = False, //| sticky_on_error: bool = False, -//| sticky_on_reload: bool = False +//| sticky_on_reload: bool = False, //| ) -> None: //| """Set what file to run on the next vm run. //| @@ -92,6 +95,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload); //| reset to the standard search sequence.""" //| ... //| +//| static mp_obj_t supervisor_set_next_code_file(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { static const mp_arg_t allowed_args[] = { { MP_QSTR_filename, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_rom_obj = mp_const_none} }, @@ -194,6 +198,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(supervisor_set_next_code_file_obj, 0, supervisor_set_ //| """ //| ... //| +//| mp_obj_t supervisor_ticks_ms(void) { uint64_t ticks_ms = common_hal_time_monotonic_ms(); return mp_obj_new_int((ticks_ms + 0x1fff0000) % (1 << 29)); @@ -210,6 +215,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(supervisor_ticks_ms_obj, supervisor_ticks_ms); //| Only code (main or boot) runs are considered, not REPL runs.""" //| ... //| +//| static mp_obj_t supervisor_get_previous_traceback(void) { if (prev_traceback_string) { size_t len = strlen(prev_traceback_string); @@ -230,6 +236,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(supervisor_get_previous_traceback_obj, supervisor_get_ //| """Reset the CircuitPython serial terminal with new dimensions.""" //| ... //| +//| static mp_obj_t supervisor_reset_terminal(mp_obj_t x_pixels, mp_obj_t y_pixels) { #if CIRCUITPY_DISPLAYIO supervisor_stop_terminal(); @@ -258,6 +265,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(supervisor_reset_terminal_obj, supervisor_reset_termin //| """ //| ... //| +//| static mp_obj_t supervisor_set_usb_identification(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { #if CIRCUITPY_USB_DEVICE && CIRCUITPY_USB_IDENTIFICATION static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/synthio/Biquad.c b/shared-bindings/synthio/Biquad.c index 79a9fa4593..bb828b7537 100644 --- a/shared-bindings/synthio/Biquad.c +++ b/shared-bindings/synthio/Biquad.c @@ -49,6 +49,7 @@ static const mp_arg_t biquad_properties[] = { //| https://github.com/WebAudio/Audio-EQ-Cookbook/blob/main/Audio-EQ-Cookbook.txt //| """ //| +//| static mp_obj_t synthio_biquad_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_val_t args[MP_ARRAY_SIZE(biquad_properties)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(biquad_properties), biquad_properties, args); diff --git a/shared-bindings/synthio/BlockBiquad.c b/shared-bindings/synthio/BlockBiquad.c index 055bd3bd26..a0209d6417 100644 --- a/shared-bindings/synthio/BlockBiquad.c +++ b/shared-bindings/synthio/BlockBiquad.c @@ -22,6 +22,7 @@ //| NOTCH: FilterMode //| """A notch filter""" //| +//| MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, LOW_PASS, SYNTHIO_LOW_PASS); MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, HIGH_PASS, SYNTHIO_HIGH_PASS); @@ -63,6 +64,7 @@ static synthio_filter_mode validate_synthio_filter_mode(mp_obj_t obj, qstr arg_n //| this should result in a stable filter output. However, in practice, //| slowly varying the filter's characteristic frequency and sharpness //| appears to work as you'd expect.""" +//| static const mp_arg_t block_biquad_properties[] = { { MP_QSTR_mode, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL } }, @@ -120,6 +122,7 @@ MP_PROPERTY_GETSET(synthio_block_biquad_frequency_obj, //| Q: BlockInput //| """The sharpness (Q) of the filter""" //| +//| static mp_obj_t synthio_block_biquad_get_Q(mp_obj_t self_in) { synthio_block_biquad_t *self = MP_OBJ_TO_PTR(self_in); return common_hal_synthio_block_biquad_get_Q(self); diff --git a/shared-bindings/synthio/LFO.c b/shared-bindings/synthio/LFO.c index 9bf4ae9010..af4252f69d 100644 --- a/shared-bindings/synthio/LFO.c +++ b/shared-bindings/synthio/LFO.c @@ -78,6 +78,7 @@ static const uint16_t triangle[] = {0, 32767, 0, -32767}; //| interpolate: bool = True, //| ) -> None: //| pass +//| static const mp_arg_t lfo_properties[] = { { MP_QSTR_waveform, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE } }, { MP_QSTR_rate, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_INT(1) } }, @@ -271,6 +272,7 @@ MP_PROPERTY_GETTER(synthio_lfo_value_obj, //| def retrigger(self) -> None: //| """Reset the LFO's internal index to the start of the waveform. Most useful when it its `once` property is `True`.""" //| +//| static mp_obj_t synthio_lfo_retrigger(mp_obj_t self_in) { synthio_lfo_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_synthio_lfo_retrigger(self); diff --git a/shared-bindings/synthio/Math.c b/shared-bindings/synthio/Math.c index 14f9b59de6..db82ad3942 100644 --- a/shared-bindings/synthio/Math.c +++ b/shared-bindings/synthio/Math.c @@ -36,6 +36,7 @@ MAKE_ENUM_VALUE(synthio_math_operation_type, math_op, ABS, OP_ABS); //| //| def __call__(self, a: BlockInput, b: BlockInput = 0.0, c: BlockInput = 1.0) -> Math: //| """A MathOperation enumeration value can be called to construct a Math block that performs that operation""" +//| //| SUM: "MathOperation" //| """Computes ``a+b+c``. For 2-input sum, set one argument to ``0.0``. To hold a control value for multiple subscribers, set two arguments to ``0.0``.""" //| @@ -78,6 +79,7 @@ MAKE_ENUM_VALUE(synthio_math_operation_type, math_op, ABS, OP_ABS); //| ABS: "MathOperation" //| """Returns the absolute value of ``a``.""" //| +//| MAKE_ENUM_MAP(synthio_math_operation) { MAKE_ENUM_MAP_ENTRY(math_op, SUM), MAKE_ENUM_MAP_ENTRY(math_op, ADD_SUB), @@ -135,6 +137,7 @@ MAKE_ENUM_TYPE(synthio, MathOperation, synthio_math_operation, //| c: BlockInput = 1.0, //| ) -> None: //| pass +//| static const mp_arg_t math_properties[] = { { MP_QSTR_operation, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL } }, { MP_QSTR_a, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL } }, @@ -241,6 +244,7 @@ MP_PROPERTY_GETSET(synthio_math_operation_obj, //| value: float //| """The value of the oscillator (read-only)""" //| +//| static mp_obj_t synthio_math_get_value(mp_obj_t self_in) { synthio_math_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_float(common_hal_synthio_math_get_value(self)); diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index dee4277063..2178d758d4 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -52,6 +52,7 @@ //| pass //| print("stopped")""" //| ... +//| static mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_buffer, ARG_tempo, ARG_sample_rate, ARG_waveform, ARG_envelope }; static const mp_arg_t allowed_args[] = { @@ -84,6 +85,7 @@ static mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_a //| def deinit(self) -> None: //| """Deinitialises the MidiTrack and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t synthio_miditrack_deinit(mp_obj_t self_in) { synthio_miditrack_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_synthio_miditrack_deinit(self); @@ -100,12 +102,14 @@ static void check_for_deinit(synthio_miditrack_obj_t *self) { //| def __enter__(self) -> MidiTrack: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t synthio_miditrack_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_synthio_miditrack_deinit(args[0]); @@ -129,6 +133,7 @@ MP_PROPERTY_GETTER(synthio_miditrack_sample_rate_obj, //| error_location: Optional[int] //| """Offset, in bytes within the midi data, of a decoding error""" //| +//| static mp_obj_t synthio_miditrack_obj_get_error_location(mp_obj_t self_in) { synthio_miditrack_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/synthio/Note.c b/shared-bindings/synthio/Note.c index 9e588edefd..95dd51fe6b 100644 --- a/shared-bindings/synthio/Note.c +++ b/shared-bindings/synthio/Note.c @@ -55,6 +55,7 @@ static const mp_arg_t note_properties[] = { //| //| If the same Note object is played on multiple Synthesizer objects, the result is undefined. //| """ +//| static mp_obj_t synthio_note_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_val_t args[MP_ARRAY_SIZE(note_properties)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(note_properties), note_properties, args); @@ -356,6 +357,7 @@ MP_PROPERTY_GETSET(synthio_note_ring_waveform_loop_start_obj, //| //| Use the `synthio.waveform_max_length` constant to set the loop point at the end of the wave form, no matter its length.""" //| +//| static mp_obj_t synthio_note_get_ring_waveform_loop_end(mp_obj_t self_in) { synthio_note_obj_t *self = MP_OBJ_TO_PTR(self_in); return common_hal_synthio_note_get_ring_waveform_loop_end(self); diff --git a/shared-bindings/synthio/Synthesizer.c b/shared-bindings/synthio/Synthesizer.c index 94595013b4..a354dcc874 100644 --- a/shared-bindings/synthio/Synthesizer.c +++ b/shared-bindings/synthio/Synthesizer.c @@ -25,6 +25,7 @@ //| LFOOrLFOSequence = Union["LFO", Sequence["LFO"]] //| """An LFO or a sequence of LFOs""" //| +//| //| class Synthesizer: //| def __init__( //| self, @@ -47,6 +48,7 @@ //| :param ReadableBuffer waveform: A single-cycle waveform. Default is a 50% duty cycle square wave. If specified, must be a ReadableBuffer of type 'h' (signed 16 bit) //| :param Optional[Envelope] envelope: An object that defines the loudness of a note over time. The default envelope, `None` provides no ramping, voices turn instantly on and off. //| """ +//| static mp_obj_t synthio_synthesizer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_sample_rate, ARG_channel_count, ARG_waveform, ARG_envelope }; static const mp_arg_t allowed_args[] = { @@ -81,6 +83,7 @@ static void check_for_deinit(synthio_synthesizer_obj_t *self) { //| Pressing a note that was already pressed has no effect. //| //| :param NoteOrNoteSequence press: Any sequence of notes.""" +//| static mp_obj_t synthio_synthesizer_press(mp_obj_t self_in, mp_obj_t press) { synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -94,6 +97,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(synthio_synthesizer_press_obj, synthio_synthesi //| Releasing a note that was already released has no effect. //| //| :param NoteOrNoteSequence release: Any sequence of notes.""" +//| static mp_obj_t synthio_synthesizer_release(mp_obj_t self_in, mp_obj_t release) { synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -127,6 +131,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(synthio_synthesizer_release_obj, synthio_synthe //| //| Note: for compatibility, ``release_then_press`` may be used as an alias //| for this function. This compatibility name will be removed in 9.0.""" +//| static mp_obj_t synthio_synthesizer_change(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_release, ARG_press, ARG_retrigger }; static const mp_arg_t allowed_args[] = { @@ -155,6 +160,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(synthio_synthesizer_change_obj, 1, synthio_syn //| attack phase with an initial amplitude of 0. //| //| :param NoteOrNoteSequence press: Any sequence of notes.""" +//| static mp_obj_t synthio_synthesizer_release_all_then_press(mp_obj_t self_in, mp_obj_t press) { synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -167,6 +173,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(synthio_synthesizer_release_all_then_press_obj, // //| def release_all(self) -> None: //| """Turn any currently-playing notes off""" +//| static mp_obj_t synthio_synthesizer_release_all(mp_obj_t self_in) { synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -178,6 +185,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(synthio_synthesizer_release_all_obj, synthio_sy //| def deinit(self) -> None: //| """Deinitialises the object and releases any memory resources for reuse.""" //| ... +//| static mp_obj_t synthio_synthesizer_deinit(mp_obj_t self_in) { synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_synthio_synthesizer_deinit(self); @@ -188,12 +196,14 @@ static MP_DEFINE_CONST_FUN_OBJ_1(synthio_synthesizer_deinit_obj, synthio_synthes //| def __enter__(self) -> Synthesizer: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t synthio_synthesizer_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_synthio_synthesizer_deinit(args[0]); @@ -255,6 +265,7 @@ MP_PROPERTY_GETTER(synthio_synthesizer_pressed_obj, //| If the note is currently playing (including in the release phase), the returned value gives the current envelope state and the current envelope value. //| //| If the note is not playing on this synthesizer, returns the tuple ``(None, 0.0)``.""" +//| static mp_obj_t synthio_synthesizer_obj_note_info(mp_obj_t self_in, mp_obj_t note) { synthio_synthesizer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -295,6 +306,7 @@ MP_PROPERTY_GETTER(synthio_synthesizer_blocks_obj, //| //| ``Q`` controls how peaked the response will be at the cutoff frequency. A large value makes the response more peaked. //| """ +//| enum passfilter_arg_e { ARG_f0, ARG_Q }; @@ -336,6 +348,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(synthio_synthesizer_lpf_fun_obj, 1, synthio_synthesiz //| //| ``Q`` controls how peaked the response will be at the cutoff frequency. A large value makes the response more peaked. //| """ +//| static mp_obj_t synthio_synthesizer_hpf(size_t n_pos, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_val_t args[MP_ARRAY_SIZE(passfilter_properties)]; @@ -367,6 +380,7 @@ static mp_obj_t synthio_synthesizer_hpf(size_t n_pos, const mp_obj_t *pos_args, //| The coefficients are scaled such that the filter has a 0dB peak gain. //| """ //| +//| MP_DEFINE_CONST_FUN_OBJ_KW(synthio_synthesizer_hpf_fun_obj, 1, synthio_synthesizer_hpf); diff --git a/shared-bindings/synthio/__init__.c b/shared-bindings/synthio/__init__.c index 71b5a8ee73..cf3d463155 100644 --- a/shared-bindings/synthio/__init__.c +++ b/shared-bindings/synthio/__init__.c @@ -32,6 +32,7 @@ //| At least 2 simultaneous notes are supported. samd5x, mimxrt10xx and rp2040 platforms support up to 12 notes. //| """ //| +//| //| class EnvelopeState: //| ATTACK: EnvelopeState @@ -43,6 +44,7 @@ //| RELEASE: EnvelopeState //| """The note is in its release phase""" //| +//| MAKE_ENUM_VALUE(synthio_note_state_type, note_state, ATTACK, SYNTHIO_ENVELOPE_STATE_ATTACK); MAKE_ENUM_VALUE(synthio_note_state_type, note_state, DECAY, SYNTHIO_ENVELOPE_STATE_DECAY); MAKE_ENUM_VALUE(synthio_note_state_type, note_state, SUSTAIN, SYNTHIO_ENVELOPE_STATE_SUSTAIN); @@ -79,6 +81,7 @@ static const mp_arg_t envelope_properties[] = { //| A BlockInput can be any of the following types: `Math`, `LFO`, `builtins.float`, `None` (treated same as 0). //| """ //| +//| //| class Envelope: //| def __init__( //| self, @@ -103,6 +106,7 @@ static const mp_arg_t envelope_properties[] = { //| :param float attack_level: The level, in the range ``0.0`` to ``1.0`` of the peak volume of the attack phase //| :param float sustain_level: The level, in the range ``0.0`` to ``1.0`` of the volume of the sustain phase relative to the attack level //| """ +//| //| attack_time: float //| """The time in seconds it takes to ramp from 0 volume to attack_volume""" //| @@ -118,6 +122,7 @@ static const mp_arg_t envelope_properties[] = { //| sustain_level: float //| """The level, in the range ``0.0`` to ``1.0`` of the volume of the sustain phase relative to the attack level""" //| +//| static mp_obj_t synthio_envelope_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_val_t args[MP_ARRAY_SIZE(envelope_properties)]; @@ -195,6 +200,7 @@ const mp_obj_namedtuple_type_t synthio_envelope_type_obj = { //| print("stopped")""" //| ... //| +//| static mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_file, ARG_sample_rate, ARG_waveform, ARG_envelope }; static const mp_arg_t allowed_args[] = { @@ -266,6 +272,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(synthio_from_file_obj, 1, synthio_from_file); //| def midi_to_hz(midi_note: float) -> float: //| """Converts the given midi note (60 = middle C, 69 = concert A) to Hz""" //| +//| static mp_obj_t midi_to_hz(mp_obj_t arg) { mp_float_t note = mp_arg_validate_type_float(arg, MP_QSTR_note); @@ -278,6 +285,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(synthio_midi_to_hz_obj, midi_to_hz); //| //| 24/12 (2.0) corresponds to middle C, 33/12 (2.75) is concert A.""" //| +//| static mp_obj_t voct_to_hz(mp_obj_t arg) { mp_float_t note = mp_arg_validate_obj_float_range(arg, -11, 11, MP_QSTR_ctrl); diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index 1173cbbe24..8ab4ac838c 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -40,11 +40,12 @@ //| scroll_area: displayio.TileGrid, //| font: fontio.BuiltinFont, //| *, -//| status_bar: Optional[displayio.TileGrid] = None +//| status_bar: Optional[displayio.TileGrid] = None, //| ) -> None: //| """Terminal manages tile indices and cursor position based on VT100 commands. The font should be //| a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap.""" //| ... +//| static mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_scroll_area, ARG_font, ARG_status_bar }; @@ -82,6 +83,7 @@ static mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n //| :rtype: int or None""" //| ... //| +//| static mp_uint_t terminalio_terminal_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) { terminalio_terminal_obj_t *self = MP_OBJ_TO_PTR(self_in); const byte *buf = buf_in; diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index dbf6261803..504cd07d90 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -20,6 +20,7 @@ //| |see_cpython_module| :mod:`cpython:time`. //| """ //| +//| //| def monotonic() -> float: //| """Returns an always increasing value of time with an unknown reference //| point. Only use it to compare against other values from `time.monotonic()` @@ -43,6 +44,7 @@ //| :rtype: float""" //| ... //| +//| static mp_obj_t time_monotonic(void) { uint64_t ticks_ms = common_hal_time_monotonic_ms(); return mp_obj_new_float(uint64_to_float(ticks_ms) / MICROPY_FLOAT_CONST(1000.0)); @@ -55,6 +57,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_obj, time_monotonic); //| :param float seconds: the time to sleep in fractional seconds""" //| ... //| +//| static mp_obj_t time_sleep(mp_obj_t seconds_o) { #if MICROPY_PY_BUILTINS_FLOAT mp_float_t seconds = mp_obj_get_float(seconds_o); @@ -96,6 +99,7 @@ static mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, s //| * ``tm_isdst``: 1 when in daylight savings, 0 when not, -1 if unknown.""" //| ... //| +//| const mp_obj_namedtuple_type_t struct_time_type_obj = { NAMEDTUPLE_TYPE_BASE_AND_SLOTS_MAKE_NEW(MP_QSTR_struct_time, struct_time_make_new), .n_fields = 9, @@ -179,6 +183,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| :rtype: int""" //| ... //| +//| static mp_obj_t time_time(void) { timeutils_struct_time_t tm; struct_time_to_tm(rtc_get_time_source_time(), &tm); @@ -198,6 +203,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); //| :rtype: int""" //| ... //| +//| static mp_obj_t time_monotonic_ns(void) { uint64_t time64 = common_hal_time_monotonic_ns(); return mp_obj_new_int_from_ll((long long)time64); @@ -214,6 +220,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns); //| :rtype: time.struct_time""" //| ... //| +//| static mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { if (n_args == 0 || args[0] == mp_const_none) { return rtc_get_time_source_time(); @@ -251,6 +258,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime); //| :rtype: int""" //| ... //| +//| static mp_obj_t time_mktime(mp_obj_t t) { mp_obj_t *elem; size_t len; diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index d435ae250c..8dae515546 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -36,6 +36,7 @@ //| //| :param ~microcontroller.Pin pin: the pin to read from""" //| ... +//| static mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // check number of arguments @@ -53,6 +54,7 @@ static mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type, //| def deinit(self) -> None: //| """Deinitialises the TouchIn and releases any hardware resources for reuse.""" //| ... +//| static mp_obj_t touchio_touchin_deinit(mp_obj_t self_in) { touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_touchio_touchin_deinit(self); @@ -69,12 +71,14 @@ static void check_for_deinit(touchio_touchin_obj_t *self) { //| def __enter__(self) -> TouchIn: //| """No-op used by Context Managers.""" //| ... +//| // Provided by context manager helper. //| def __exit__(self) -> None: //| """Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info.""" //| ... +//| static mp_obj_t touchio_touchin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_touchio_touchin_deinit(args[0]); @@ -125,6 +129,7 @@ MP_PROPERTY_GETTER(touchio_touchin_raw_value_obj, //| touch = touchio.TouchIn(board.A1) //| touch.threshold = 7300""" //| +//| static mp_obj_t touchio_touchin_obj_get_threshold(mp_obj_t self_in) { touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/traceback/__init__.c b/shared-bindings/traceback/__init__.c index d1cf330705..ca1e6fe976 100644 --- a/shared-bindings/traceback/__init__.c +++ b/shared-bindings/traceback/__init__.c @@ -16,8 +16,10 @@ //| //| |see_cpython_module| :mod:`cpython:traceback`. //| """ +//| //| ... //| +//| static void traceback_exception_common(bool is_print_exception, mp_print_t *print, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_exc, ARG_value, ARG_tb, ARG_limit, ARG_file, ARG_chain }; @@ -133,6 +135,7 @@ static void traceback_exception_common(bool is_print_exception, mp_print_t *prin //| :param bool chain: If `True` then chained exceptions will be printed. //| """ //| +//| static mp_obj_t traceback_format_exception(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_print_t print; vstr_t vstr; @@ -176,6 +179,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 0, traceback_f //| """ //| ... //| +//| static mp_obj_t traceback_print_exception(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_print_t print = mp_plat_print; diff --git a/shared-bindings/uheap/__init__.c b/shared-bindings/uheap/__init__.c index 0170c56c04..a46ff76259 100644 --- a/shared-bindings/uheap/__init__.c +++ b/shared-bindings/uheap/__init__.c @@ -13,12 +13,14 @@ //| """Heap size analysis""" //| +//| //| def info(object: object) -> int: //| """Prints memory debugging info for the given object and returns the //| estimated size.""" //| ... //| +//| static mp_obj_t uheap_info(mp_obj_t obj) { uint32_t size = shared_module_uheap_info(obj); diff --git a/shared-bindings/usb/core/Device.c b/shared-bindings/usb/core/Device.c index 07795f003d..33d22eef75 100644 --- a/shared-bindings/usb/core/Device.c +++ b/shared-bindings/usb/core/Device.c @@ -47,6 +47,7 @@ //| `usb.core.find`. //| """ //| ... +//| //| idVendor: int //| """The USB vendor ID of the device""" @@ -94,6 +95,7 @@ MP_PROPERTY_GETTER(usb_core_device_product_obj, //| manufacturer: str //| """The USB device's manufacturer string.""" +//| static mp_obj_t usb_core_device_obj_get_manufacturer(mp_obj_t self_in) { usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); return common_hal_usb_core_device_get_manufacturer(self); @@ -113,6 +115,7 @@ MP_PROPERTY_GETTER(usb_core_device_manufacturer_obj, //| without arguments is enough to get the device ready. //| """ //| ... +//| static mp_obj_t usb_core_device_set_configuration(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_configuration }; static const mp_arg_t allowed_args[] = { @@ -136,6 +139,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(usb_core_device_set_configuration_obj, 1, usb_core_de //| :returns: the number of bytes written //| """ //| ... +//| static mp_obj_t usb_core_device_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_endpoint, ARG_data, ARG_timeout }; static const mp_arg_t allowed_args[] = { @@ -166,6 +170,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(usb_core_device_write_obj, 2, usb_core_device_write); //| :returns: the number of bytes read //| """ //| ... +//| static mp_obj_t usb_core_device_read(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_endpoint, ARG_size_or_buffer, ARG_timeout }; static const mp_arg_t allowed_args[] = { @@ -211,6 +216,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(usb_core_device_read_obj, 2, usb_core_device_read); //| number of bytes read. //| """ //| ... +//| static mp_obj_t usb_core_device_ctrl_transfer(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bmRequestType, ARG_bRequest, ARG_wValue, ARG_wIndex, ARG_data_or_wLength, ARG_timeout }; static const mp_arg_t allowed_args[] = { @@ -252,6 +258,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(usb_core_device_ctrl_transfer_obj, 2, usb_core_device //| :param int interface: the device interface number to check //| """ //| ... +//| static mp_obj_t usb_core_device_is_kernel_driver_active(mp_obj_t self_in, mp_obj_t interface_in) { usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_int_t interface = mp_obj_get_int(interface_in); @@ -268,6 +275,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(usb_core_device_is_kernel_driver_active_obj, usb_core_ //| :param int interface: the device interface number to stop CircuitPython on //| """ //| ... +//| static mp_obj_t usb_core_device_detach_kernel_driver(mp_obj_t self_in, mp_obj_t interface_in) { usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_int_t interface = mp_obj_get_int(interface_in); @@ -283,6 +291,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(usb_core_device_detach_kernel_driver_obj, usb_core_dev //| """ //| ... //| +//| static mp_obj_t usb_core_device_attach_kernel_driver(mp_obj_t self_in, mp_obj_t interface_in) { usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_int_t interface = mp_obj_get_int(interface_in); diff --git a/shared-bindings/usb/core/__init__.c b/shared-bindings/usb/core/__init__.c index 99be3888bf..545e182ea9 100644 --- a/shared-bindings/usb/core/__init__.c +++ b/shared-bindings/usb/core/__init__.c @@ -21,12 +21,14 @@ //| This is a subset of the PyUSB core module. //| """ //| +//| //| class USBError(OSError): //| """Catchall exception for USB related errors.""" //| //| ... //| +//| MP_DEFINE_USB_CORE_EXCEPTION(USBError, OSError) NORETURN void mp_raise_usb_core_USBError(mp_rom_error_text_t fmt, ...) { mp_obj_t exception; @@ -46,6 +48,7 @@ NORETURN void mp_raise_usb_core_USBError(mp_rom_error_text_t fmt, ...) { //| //| ... //| +//| MP_DEFINE_USB_CORE_EXCEPTION(USBTimeoutError, usb_core_USBError) NORETURN void mp_raise_usb_core_USBTimeoutError(void) { mp_raise_type(&mp_type_usb_core_USBTimeoutError); @@ -61,6 +64,7 @@ NORETURN void mp_raise_usb_core_USBTimeoutError(void) { //| Returns None if no device matches. //| """ //| +//| typedef struct { mp_obj_base_t base; mp_int_t vid; diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index 1fd5ed4afc..78e73d03dd 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -78,6 +78,7 @@ //| def flush(self) -> None: //| """Force out any unwritten bytes, waiting until they are written.""" //| ... +//| // These three methods are used by the shared stream methods. static mp_uint_t usb_cdc_serial_read_stream(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) { @@ -155,6 +156,7 @@ MP_PROPERTY_GETTER(usb_cdc_serial_in_waiting_obj, //| out_waiting: int //| """Returns the number of bytes waiting to be written on the USB serial output. (read-only)""" +//| static mp_obj_t usb_cdc_serial_get_out_waiting(mp_obj_t self_in) { usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in); return mp_obj_new_int(common_hal_usb_cdc_serial_get_out_waiting(self)); @@ -167,6 +169,7 @@ MP_PROPERTY_GETTER(usb_cdc_serial_out_waiting_obj, //| def reset_input_buffer(self) -> None: //| """Clears any unread bytes.""" //| ... +//| static mp_obj_t usb_cdc_serial_reset_input_buffer(mp_obj_t self_in) { usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_usb_cdc_serial_reset_input_buffer(self); @@ -177,6 +180,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(usb_cdc_serial_reset_input_buffer_obj, usb_cdc_serial_ //| def reset_output_buffer(self) -> None: //| """Clears any unwritten bytes.""" //| ... +//| static mp_obj_t usb_cdc_serial_reset_output_buffer(mp_obj_t self_in) { usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_usb_cdc_serial_reset_output_buffer(self); @@ -211,6 +215,7 @@ MP_PROPERTY_GETSET(usb_cdc_serial_timeout_obj, //| writing all the bytes passed to ``write()``.If 0, do not wait. //| If > 0, wait only ``write_timeout`` seconds.""" //| +//| static mp_obj_t usb_cdc_serial_get_write_timeout(mp_obj_t self_in) { usb_cdc_serial_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_float_t write_timeout = common_hal_usb_cdc_serial_get_write_timeout(self); diff --git a/shared-bindings/usb_cdc/__init__.c b/shared-bindings/usb_cdc/__init__.c index 3a2c43c3e9..65d343b035 100644 --- a/shared-bindings/usb_cdc/__init__.c +++ b/shared-bindings/usb_cdc/__init__.c @@ -40,6 +40,7 @@ //| the host. //| Note that `data` is *disabled* by default. ``data`` is ``None`` if disabled.""" //| +//| //| def disable() -> None: //| """Do not present any USB CDC device to the host. @@ -47,6 +48,7 @@ //| Equivalent to ``usb_cdc.enable(console=False, data=False)``.""" //| ... //| +//| static mp_obj_t usb_cdc_disable(void) { if (!common_hal_usb_cdc_disable()) { mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); @@ -70,6 +72,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_cdc_disable_obj, usb_cdc_disable); //| """ //| ... //| +//| static mp_obj_t usb_cdc_enable(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_console, ARG_data }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index 1afdda509f..7c9c354e4d 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -19,7 +19,7 @@ //| usage: int, //| report_ids: Sequence[int], //| in_report_lengths: Sequence[int], -//| out_report_lengths: Sequence[int] +//| out_report_lengths: Sequence[int], //| ) -> None: //| """Create a description of a USB HID device. The actual device is created when you //| pass a `Device` to `usb_hid.enable()`. @@ -57,6 +57,7 @@ //| See `send_report()` for details. //| """ //| ... +//| //| KEYBOARD: Device //| """Standard keyboard device supporting keycodes 0x00-0xDD, modifiers 0xE-0xE7, and five LED indicators. //| Uses Report ID 1 for its IN and OUT reports. @@ -71,6 +72,7 @@ //| CONSUMER_CONTROL: Device //| """Consumer Control device supporting sent values from 1-652, with no rollover. //| Uses Report ID 3 for its IN report.""" +//| static mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { usb_hid_device_obj_t *self = mp_obj_malloc(usb_hid_device_obj_t, &usb_hid_device_type); @@ -161,6 +163,7 @@ static mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args //| In addition, there may be USB wakeup settings in the host computer BIOS/UEFI. //| """ //| ... +//| static mp_obj_t usb_hid_device_send_report(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -195,6 +198,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_device_send_report_obj, 1, usb_hid_device_sen //| will return `None` until next report is received. //| """ //| ... +//| static mp_obj_t usb_hid_device_get_last_received_report(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -233,6 +237,7 @@ MP_PROPERTY_GETTER(usb_hid_device_usage_page_obj, //| For example, Keyboard is 0x06 within the generic desktop usage page 0x01. //| Mouse is 0x02 within the same usage page.""" //| +//| static mp_obj_t usb_hid_device_obj_get_usage(mp_obj_t self_in) { usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(self_in); return MP_OBJ_NEW_SMALL_INT(common_hal_usb_hid_device_get_usage(self)); diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index ae70005bbe..47f7f03c49 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -14,6 +14,7 @@ //| """USB Human Interface Device //| //| The `usb_hid` module allows you to output data as a HID device.""" +//| //| devices: Tuple[Device, ...] //| """Tuple of all active HID device interfaces. @@ -26,6 +27,7 @@ //| The request for a boot device overrides any other HID devices. //| """ //| +//| //| def disable() -> None: //| """Do not present any USB HID devices to the host computer. @@ -36,6 +38,7 @@ //| as `usb_cdc` or `storage` to free up endpoints for use by `usb_hid`. //| """ //| +//| static mp_obj_t usb_hid_disable(void) { if (!common_hal_usb_hid_disable()) { mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); @@ -89,6 +92,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_disable_obj, usb_hid_disable); //| """ //| ... //| +//| static mp_obj_t usb_hid_enable(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_devices, ARG_boot_device }; static const mp_arg_t allowed_args[] = { @@ -131,6 +135,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_enable_obj, 1, usb_hid_enable); //| :rtype int: //| """ //| +//| static mp_obj_t usb_hid_get_boot_device(void) { return MP_OBJ_NEW_SMALL_INT(common_hal_usb_hid_get_boot_device()); } @@ -148,6 +153,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_get_boot_device_obj, usb_hid_get_boot_device); //| """ //| ... //| +//| static mp_obj_t usb_hid_set_interface_name(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { static const mp_arg_t allowed_args[] = { { MP_QSTR_interface_name, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = mp_const_none} } diff --git a/shared-bindings/usb_host/Port.c b/shared-bindings/usb_host/Port.c index 10e38c8f3a..41e8513a1e 100644 --- a/shared-bindings/usb_host/Port.c +++ b/shared-bindings/usb_host/Port.c @@ -28,6 +28,7 @@ //| """ //| ... //| +//| static mp_obj_t usb_host_port_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // check number of arguments diff --git a/shared-bindings/usb_host/__init__.c b/shared-bindings/usb_host/__init__.c index d71231aef1..a42c688b6a 100644 --- a/shared-bindings/usb_host/__init__.c +++ b/shared-bindings/usb_host/__init__.c @@ -18,6 +18,7 @@ //| with devices use the `usb` module that is a subset of PyUSB's API. //| """ //| +//| //| def set_user_keymap(keymap: ReadableBuffer, /) -> None: //| """Set the keymap used by a USB HID keyboard in kernel mode //| @@ -40,6 +41,7 @@ //| This function is a CircuitPython extension not present in PyUSB //| """ //| +//| static mp_obj_t usb_set_user_keymap(mp_obj_t buf_in) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c index 38662a4468..63605a863b 100644 --- a/shared-bindings/usb_midi/PortIn.c +++ b/shared-bindings/usb_midi/PortIn.c @@ -23,6 +23,7 @@ //| PortIn objects are constructed for every corresponding entry in the USB //| descriptor and added to the ``usb_midi.ports`` tuple.""" //| ... +//| // These are standard stream methods. Code is in py/stream.c. // @@ -44,6 +45,7 @@ //| :rtype: bytes or None""" //| ... //| +//| // These three methods are used by the shared stream methods. static mp_uint_t usb_midi_portin_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) { diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c index c39683c3f0..b5581a9f34 100644 --- a/shared-bindings/usb_midi/PortOut.c +++ b/shared-bindings/usb_midi/PortOut.c @@ -22,6 +22,7 @@ //| //| PortOut objects are constructed for every corresponding entry in the USB //| descriptor and added to the ``usb_midi.ports`` tuple.""" +//| // These are standard stream methods. Code is in py/stream.c. // @@ -32,6 +33,7 @@ //| :rtype: int or None""" //| ... //| +//| static mp_uint_t usb_midi_portout_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) { usb_midi_portout_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/usb_midi/__init__.c b/shared-bindings/usb_midi/__init__.c index cb26474130..fc10f89c31 100644 --- a/shared-bindings/usb_midi/__init__.c +++ b/shared-bindings/usb_midi/__init__.c @@ -22,6 +22,7 @@ //| ports: Tuple[Union[PortIn, PortOut], ...] //| """Tuple of all MIDI ports. Each item is ether `PortIn` or `PortOut`.""" //| +//| //| def disable() -> None: //| """Disable presenting a USB MIDI device to the host. @@ -30,6 +31,7 @@ //| Can be called in ``boot.py``, before USB is connected.""" //| ... //| +//| static mp_obj_t usb_midi_disable(void) { if (!common_hal_usb_midi_disable()) { mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); @@ -50,6 +52,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_midi_disable_obj, usb_midi_disable); //| """ //| ... //| +//| static mp_obj_t usb_midi_enable(void) { if (!common_hal_usb_midi_enable()) { mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); @@ -81,7 +84,7 @@ static void set_name(mp_obj_t name_obj, qstr arg_name_qstr, char **custom_name_p //| streaming_interface_name: Optional[str] = None, //| audio_control_interface_name: Optional[str] = None, //| in_jack_name: Optional[str] = None, -//| out_jack_name: Optional[str] = None +//| out_jack_name: Optional[str] = None, //| ) -> None: //| """Override the MIDI interface names in the USB Interface Descriptor. //| @@ -99,6 +102,7 @@ static void set_name(mp_obj_t name_obj, qstr arg_name_qstr, char **custom_name_p //| """ //| ... //| +//| static mp_obj_t usb_midi_set_names(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_streaming_interface_name, ARG_audio_control_interface_name, ARG_in_jack_name, ARG_out_jack_name }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/usb_video/USBFramebuffer.c b/shared-bindings/usb_video/USBFramebuffer.c index c980784c85..25151809df 100644 --- a/shared-bindings/usb_video/USBFramebuffer.c +++ b/shared-bindings/usb_video/USBFramebuffer.c @@ -33,6 +33,7 @@ static void check_for_deinit(usb_video_uvcframebuffer_obj_t *self) { //| //| def __init__(self) -> None: //| """Returns the singleton framebuffer object, if USB video is enabled""" +//| static mp_obj_t usb_video_uvcframebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { static const mp_arg_t allowed_args[] = {}; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -45,6 +46,7 @@ static mp_obj_t usb_video_uvcframebuffer_make_new(const mp_obj_type_t *type, siz //| """Transmits the color data in the buffer to the pixels so that //| they are shown.""" //| ... +//| static mp_obj_t usb_video_uvcframebuffer_refresh(mp_obj_t self_in) { usb_video_uvcframebuffer_obj_t *self = (usb_video_uvcframebuffer_obj_t *)self_in; check_for_deinit(self); @@ -67,6 +69,7 @@ MP_PROPERTY_GETTER(usb_video_uvcframebuffer_width_obj, //| height: int //| """The height of the display, in pixels""" //| +//| static mp_obj_t usb_video_uvcframebuffer_get_height(mp_obj_t self_in) { usb_video_uvcframebuffer_obj_t *self = (usb_video_uvcframebuffer_obj_t *)self_in; check_for_deinit(self); diff --git a/shared-bindings/usb_video/__init__.c b/shared-bindings/usb_video/__init__.c index 189acd9109..06050188d6 100644 --- a/shared-bindings/usb_video/__init__.c +++ b/shared-bindings/usb_video/__init__.c @@ -46,6 +46,7 @@ //| This interface is experimental and may change without notice even in stable //| versions of CircuitPython.""" //| +//| //| def enable_framebuffer(width: int, height: int) -> None: //| """Enable a USB video framebuffer, setting the given width & height @@ -59,6 +60,7 @@ //| for Python objects. If the allocation fails, a MemoryError is raised. //| This message can be seen in ``boot_out.txt``.""" //| +//| static mp_obj_t usb_video_enable_framebuffer(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_width, ARG_height }; diff --git a/shared-bindings/ustack/__init__.c b/shared-bindings/ustack/__init__.c index 3002254db2..9676c517a6 100644 --- a/shared-bindings/ustack/__init__.c +++ b/shared-bindings/ustack/__init__.c @@ -16,12 +16,14 @@ //| """Stack information and analysis""" //| +//| #if MICROPY_MAX_STACK_USAGE //| def max_stack_usage() -> int: //| """Return the maximum excursion of the stack so far.""" //| ... //| +//| static mp_obj_t max_stack_usage(void) { return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_max_stack_usage()); } @@ -35,6 +37,7 @@ static MP_DEFINE_CONST_FUN_OBJ_0(max_stack_usage_obj, max_stack_usage); //| of just printing it.""" //| ... //| +//| static mp_obj_t stack_size(void) { return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_stack_size()); } @@ -45,6 +48,7 @@ static MP_DEFINE_CONST_FUN_OBJ_0(stack_size_obj, stack_size); //| Same as micropython.stack_use(); duplicated here for convenience.""" //| ... //| +//| static mp_obj_t stack_usage(void) { return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_stack_usage()); } diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 2b7337439a..7fb20b59b4 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -31,6 +31,7 @@ //| :param int y: Initial y position of the axis. //| :param int color_index: Initial color_index to use when selecting color from the palette. //| """ +//| static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pixel_shader, ARG_radius, ARG_x, ARG_y, ARG_color_index }; static const mp_arg_t allowed_args[] = { @@ -123,6 +124,7 @@ MP_PROPERTY_GETSET(vectorio_circle_color_index_obj, //| pixel_shader: Union[displayio.ColorConverter, displayio.Palette] //| """The pixel shader of the circle.""" //| +//| static const mp_rom_map_elem_t vectorio_circle_locals_dict_table[] = { // Functions diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index cb76ccbb14..0f45da21e6 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -39,6 +39,7 @@ //| :param int y: Initial screen y position of the 0,0 origin in the points list. //| :param int color_index: Initial color_index to use when selecting color from the palette. //| """ +//| static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pixel_shader, ARG_points_list, ARG_x, ARG_y, ARG_color_index }; static const mp_arg_t allowed_args[] = { @@ -132,6 +133,7 @@ MP_PROPERTY_GETSET(vectorio_polygon_color_index_obj, //| pixel_shader: Union[displayio.ColorConverter, displayio.Palette] //| """The pixel shader of the polygon.""" //| +//| static const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = { // Functions diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 6421059975..3582b01014 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -32,6 +32,7 @@ //| :param int y: Initial y position of the top left corner. //| :param int color_index: Initial color_index to use when selecting color from the palette. //| """ +//| static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pixel_shader, ARG_width, ARG_height, ARG_x, ARG_y, ARG_color_index }; static const mp_arg_t allowed_args[] = { @@ -144,6 +145,7 @@ MP_PROPERTY_GETSET(vectorio_rectangle_color_index_obj, //| pixel_shader: Union[displayio.ColorConverter, displayio.Palette] //| """The pixel shader of the rectangle.""" //| +//| static const mp_rom_map_elem_t vectorio_rectangle_locals_dict_table[] = { // Functions diff --git a/shared-bindings/warnings/__init__.c b/shared-bindings/warnings/__init__.c index 1d726bc61a..3984bb3175 100644 --- a/shared-bindings/warnings/__init__.c +++ b/shared-bindings/warnings/__init__.c @@ -25,6 +25,7 @@ //| //| import typing //| +//| //| def warn(message: str, category: type = Warning) -> None: //| """Issue a warning with an optional category. Use `simplefilter()` to @@ -33,6 +34,7 @@ //| """ //| ... //| +//| static mp_obj_t warnings_warn(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_message, ARG_category }; static const mp_arg_t allowed_args[] = { @@ -58,6 +60,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(warnings_warn_obj, 1, warnings_warn); //| behavior because it allows for per-category changes.""" //| ... //| +//| static mp_obj_t warnings_simplefilter(mp_obj_t action_in) { const char *action_str = mp_obj_str_get_str(action_in); warnings_action_t action; diff --git a/shared-bindings/watchdog/WatchDogMode.c b/shared-bindings/watchdog/WatchDogMode.c index 3aee1203d3..c049c05170 100644 --- a/shared-bindings/watchdog/WatchDogMode.c +++ b/shared-bindings/watchdog/WatchDogMode.c @@ -20,6 +20,7 @@ MAKE_ENUM_VALUE(watchdog_watchdogmode_type, watchdogmode, RESET, WATCHDOGMODE_RE //| RESET: WatchDogMode //| """Reset the system when the `WatchDogTimer` expires.""" //| +//| MAKE_ENUM_MAP(watchdog_watchdogmode) { MAKE_ENUM_MAP_ENTRY(watchdogmode, RAISE), MAKE_ENUM_MAP_ENTRY(watchdogmode, RESET), diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index 8ff8ba2f9c..19e931d0dc 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -32,11 +32,13 @@ //| def __init__(self) -> None: //| """Access the sole instance through `microcontroller.watchdog`.""" //| ... +//| //| def feed(self) -> None: //| """Feed the watchdog timer. This must be called regularly, otherwise //| the timer will expire. Silently does nothing if the watchdog isn't active.""" //| ... +//| static mp_obj_t watchdog_watchdogtimer_feed(mp_obj_t self_in) { watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in); if (common_hal_watchdog_get_mode(self) != WATCHDOGMODE_NONE) { @@ -56,6 +58,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_feed_obj, watchdog_watch //| //| """ //| ... +//| static mp_obj_t watchdog_watchdogtimer_deinit(mp_obj_t self_in) { watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_watchdog_deinit(self); @@ -102,6 +105,7 @@ MP_PROPERTY_GETSET(watchdog_watchdogtimer_timeout_obj, //| //| Once set, the `WatchDogTimer` will perform the specified action if the timer expires.""" //| +//| static mp_obj_t watchdog_watchdogtimer_obj_get_mode(mp_obj_t self_in) { watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in); return cp_enum_find(&watchdog_watchdogmode_type, common_hal_watchdog_get_mode(self)); diff --git a/shared-bindings/watchdog/__init__.c b/shared-bindings/watchdog/__init__.c index 4e338844a0..8ae7633f1f 100644 --- a/shared-bindings/watchdog/__init__.c +++ b/shared-bindings/watchdog/__init__.c @@ -30,6 +30,7 @@ //| w.mode = WatchDogMode.RAISE //| w.feed()""" //| +//| //| class WatchDogTimeout(Exception): //| """Exception raised when the watchdog timer is set to @@ -58,6 +59,7 @@ //| print("Exited loop") //| """ //| +//| MP_DEFINE_CONST_OBJ_TYPE( mp_type_WatchDogTimeout, diff --git a/shared-bindings/wifi/AuthMode.c b/shared-bindings/wifi/AuthMode.c index c2c653727d..d7f3af80be 100644 --- a/shared-bindings/wifi/AuthMode.c +++ b/shared-bindings/wifi/AuthMode.c @@ -40,6 +40,7 @@ MAKE_ENUM_VALUE(wifi_authmode_type, authmode, ENTERPRISE, AUTHMODE_ENTERPRISE); //| ENTERPRISE: object //| """Each user has a unique credential.""" //| +//| MAKE_ENUM_MAP(wifi_authmode) { MAKE_ENUM_MAP_ENTRY(authmode, OPEN), MAKE_ENUM_MAP_ENTRY(authmode, WEP), diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index a2e91dca4b..fb09c4b4f7 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -24,6 +24,7 @@ //| //| """ //| ... +//| static mp_obj_t wifi_monitor_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_channel, ARG_queue }; static const mp_arg_t allowed_args[] = { @@ -70,6 +71,7 @@ MP_PROPERTY_GETSET(wifi_monitor_channel_obj, //| queue: int //| """The queue size for buffering the packet.""" +//| static mp_obj_t wifi_monitor_obj_get_queue(mp_obj_t self_in) { return common_hal_wifi_monitor_get_queue(self_in); } @@ -81,6 +83,7 @@ MP_PROPERTY_GETTER(wifi_monitor_queue_obj, //| def deinit(self) -> None: //| """De-initialize `wifi.Monitor` singleton.""" //| ... +//| static mp_obj_t wifi_monitor_obj_deinit(mp_obj_t self_in) { common_hal_wifi_monitor_deinit(self_in); return mp_const_none; @@ -90,6 +93,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_deinit_obj, wifi_monitor_obj_deini //| def lost(self) -> int: //| """Returns the packet loss count. The counter resets after each poll.""" //| ... +//| static mp_obj_t wifi_monitor_obj_get_lost(mp_obj_t self_in) { return common_hal_wifi_monitor_get_lost(self_in); } @@ -98,6 +102,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_lost_obj, wifi_monitor_obj_get_lost); //| def queued(self) -> int: //| """Returns the packet queued count.""" //| ... +//| static mp_obj_t wifi_monitor_obj_get_queued(mp_obj_t self_in) { if (common_hal_wifi_monitor_deinited()) { return mp_obj_new_int_from_uint(0); @@ -110,6 +115,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_queued_obj, wifi_monitor_obj_get_queued); //| """Returns the monitor packet.""" //| ... //| +//| static mp_obj_t wifi_monitor_obj_get_packet(mp_obj_t self_in) { if (common_hal_wifi_monitor_deinited()) { raise_deinited_error(); diff --git a/shared-bindings/wifi/Network.c b/shared-bindings/wifi/Network.c index 1b5b3aac14..93a483930e 100644 --- a/shared-bindings/wifi/Network.c +++ b/shared-bindings/wifi/Network.c @@ -17,6 +17,7 @@ //| def __init__(self) -> None: //| """You cannot create an instance of `wifi.Network`. They are returned by `wifi.Radio.start_scanning_networks`.""" //| ... +//| //| ssid: str //| """String id of the network""" @@ -79,6 +80,7 @@ MP_PROPERTY_GETTER(wifi_network_country_obj, //| authmode: Sequence[wifi.AuthMode] //| """List of authmodes (wifi.AuthMode) used by the network """ //| +//| static mp_obj_t wifi_network_get_authmode(mp_obj_t self) { return common_hal_wifi_network_get_authmode(self); diff --git a/shared-bindings/wifi/Packet.c b/shared-bindings/wifi/Packet.c index 9d7befa7a8..85dd8cc25b 100644 --- a/shared-bindings/wifi/Packet.c +++ b/shared-bindings/wifi/Packet.c @@ -28,6 +28,7 @@ MAKE_ENUM_VALUE(wifi_packet_type, packet, RSSI, PACKET_RSSI); //| RSSI: object //| """The packet's rssi.""" //| +//| MAKE_ENUM_MAP(wifi_packet) { MAKE_ENUM_MAP_ENTRY(packet, CH), MAKE_ENUM_MAP_ENTRY(packet, LEN), diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 97d09febcc..57faa7065d 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -73,6 +73,7 @@ static void validate_hex_password(const uint8_t *buf, size_t len) { //| """You cannot create an instance of `wifi.Radio`. //| Use `wifi.radio` to access the sole instance available.""" //| ... +//| //| enabled: bool //| """``True`` when the wifi radio is enabled. @@ -220,6 +221,7 @@ MP_PROPERTY_GETSET(wifi_radio_listen_interval_obj, //| //| **Limitations:** Not settable on RP2040 CYW43 boards, such as Pi Pico W. //| """ +//| static mp_obj_t wifi_radio_get_mac_address_ap(mp_obj_t self_in) { wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); return MP_OBJ_FROM_PTR(common_hal_wifi_radio_get_mac_address_ap(self)); @@ -262,6 +264,7 @@ MP_PROPERTY_GETTER(wifi_radio_mac_address_ap_obj, //| In the raspberrypi port (RP2040 CYW43), ``start_channel`` and ``stop_channel`` are ignored. //| """ //| ... +//| static mp_obj_t wifi_radio_start_scanning_networks(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_start_channel, ARG_stop_channel }; static const mp_arg_t allowed_args[] = { @@ -291,6 +294,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_start_scanning_networks_obj, 1, wif //| def stop_scanning_networks(self) -> None: //| """Stop scanning for Wifi networks and free any resources used to do it.""" //| ... +//| static mp_obj_t wifi_radio_stop_scanning_networks(mp_obj_t self_in) { wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -303,6 +307,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_scanning_networks_obj, wifi_rad //| def start_station(self) -> None: //| """Starts a Station.""" //| ... +//| static mp_obj_t wifi_radio_start_station(mp_obj_t self) { common_hal_wifi_radio_start_station(self); return mp_const_none; @@ -312,6 +317,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_start_station_obj, wifi_radio_start_station //| def stop_station(self) -> None: //| """Stops the Station.""" //| ... +//| static mp_obj_t wifi_radio_stop_station(mp_obj_t self) { common_hal_wifi_radio_stop_station(self); return mp_const_none; @@ -355,6 +361,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_station_obj, wifi_radio_stop_station); //| In the raspberrypi port (RP2040 CYW43), ``max_connections`` is ignored. //| """ //| ... +//| static mp_obj_t wifi_radio_start_ap(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_ssid, ARG_password, ARG_channel, ARG_authmode, ARG_max_connections }; static const mp_arg_t allowed_args[] = { @@ -412,6 +419,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_start_ap_obj, 1, wifi_radio_start_a //| def stop_ap(self) -> None: //| """Stops the access point.""" //| ... +//| static mp_obj_t wifi_radio_stop_ap(mp_obj_t self) { common_hal_wifi_radio_stop_ap(self); return mp_const_none; @@ -420,6 +428,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_ap_obj, wifi_radio_stop_ap); //| ap_active: bool //| """True if running as an access point. (read-only)""" +//| static mp_obj_t wifi_radio_get_ap_active(mp_obj_t self) { return mp_obj_new_bool(common_hal_wifi_radio_get_ap_active(self)); } @@ -453,6 +462,7 @@ MP_PROPERTY_GETTER(wifi_radio_ap_active_obj, //| If ``bssid`` is given and not None, the scan will start at the first channel or the one given and //| connect to the AP with the given ``bssid`` and ``ssid``.""" //| ... +//| static mp_obj_t wifi_radio_connect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_ssid, ARG_password, ARG_channel, ARG_bssid, ARG_timeout }; static const mp_arg_t allowed_args[] = { @@ -556,6 +566,7 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_subnet_obj, //| ipv4_subnet_ap: Optional[ipaddress.IPv4Address] //| """IP v4 Address of the access point subnet, when enabled. None otherwise. (read-only)""" +//| static mp_obj_t wifi_radio_get_ipv4_subnet_ap(mp_obj_t self) { return common_hal_wifi_radio_get_ipv4_subnet_ap(self); } @@ -580,6 +591,7 @@ MP_PROPERTY_GETTER(wifi_radio_ipv4_subnet_ap_obj, //| In the raspberrypi port (RP2040 CYW43), the access point needs to be started before the IP v4 address can be set. //| """ //| ... +//| static mp_obj_t wifi_radio_set_ipv4_address(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_ipv4, ARG_netmask, ARG_gateway, ARG_ipv4_dns }; static const mp_arg_t allowed_args[] = { @@ -607,6 +619,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_set_ipv4_address_obj, 1, wifi_radio //| ) -> None: //| """Sets the IP v4 address of the access point. Must include the netmask and gateway.""" //| ... +//| static mp_obj_t wifi_radio_set_ipv4_address_ap(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_ipv4, ARG_netmask, ARG_gateway }; static const mp_arg_t allowed_args[] = { @@ -712,6 +725,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_info_obj, wifi_radio_get_ap_info); //| mac: bytearray (read-only) //| rssi: int (read-only, None on Raspberry Pi Pico W) //| ipv4_address: ipv4_address (read-only, None if station connected but no address assigned yet or self-assigned address)""" +//| static mp_obj_t wifi_radio_get_stations_ap(mp_obj_t self) { return common_hal_wifi_radio_get_stations_ap(self); } @@ -729,6 +743,7 @@ MP_PROPERTY_GETTER(wifi_radio_stations_ap_obj, //| then the corresponding DHCP client is stopped if it was active. //| """ //| ... +//| static mp_obj_t wifi_radio_start_dhcp_client(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_ipv4, ARG_ipv6 }; static const mp_arg_t allowed_args[] = { @@ -748,6 +763,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_start_dhcp_client_obj, 1, wifi_radi //| def stop_dhcp(self) -> None: //| """Stops the station DHCP client. Needed to assign a static IP address.""" //| ... +//| static mp_obj_t wifi_radio_stop_dhcp_client(mp_obj_t self) { common_hal_wifi_radio_stop_dhcp_client(self); return mp_const_none; @@ -757,6 +773,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_dhcp_client_obj, wifi_radio_stop_dhcp_ //| def start_dhcp_ap(self) -> None: //| """Starts the access point DHCP server.""" //| ... +//| static mp_obj_t wifi_radio_start_dhcp_server(mp_obj_t self) { common_hal_wifi_radio_start_dhcp_server(self); return mp_const_none; @@ -766,6 +783,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_start_dhcp_server_obj, wifi_radio_start_dhc //| def stop_dhcp_ap(self) -> None: //| """Stops the access point DHCP server. Needed to assign a static IP address.""" //| ... +//| static mp_obj_t wifi_radio_stop_dhcp_server(mp_obj_t self) { common_hal_wifi_radio_stop_dhcp_server(self); return mp_const_none; @@ -787,6 +805,7 @@ MP_PROPERTY_GETTER(wifi_radio_ap_info_obj, //| """ //| ... //| +//| static mp_obj_t wifi_radio_ping(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_ip, ARG_timeout }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/wifi/ScannedNetworks.c b/shared-bindings/wifi/ScannedNetworks.c index dea3474d42..2fb5c2a578 100644 --- a/shared-bindings/wifi/ScannedNetworks.c +++ b/shared-bindings/wifi/ScannedNetworks.c @@ -40,6 +40,7 @@ static mp_obj_t scannednetworks_iternext(mp_obj_t self_in) { //| Raises `StopIteration` if scanning is finished and no other results are available.""" //| ... //| +//| MP_DEFINE_CONST_OBJ_TYPE( wifi_scannednetworks_type, diff --git a/shared-bindings/wifi/__init__.c b/shared-bindings/wifi/__init__.c index 3b09255052..91d317ebd1 100644 --- a/shared-bindings/wifi/__init__.c +++ b/shared-bindings/wifi/__init__.c @@ -15,6 +15,7 @@ //| The `wifi` module provides necessary low-level functionality for managing //| wifi connections. Use `socketpool` for communicating over the network. //| """ +//| //| radio: Radio //| """Wifi radio used to manage both station and AP modes. diff --git a/shared-bindings/zlib/__init__.c b/shared-bindings/zlib/__init__.c index f9db723c4f..a17694d8a2 100644 --- a/shared-bindings/zlib/__init__.c +++ b/shared-bindings/zlib/__init__.c @@ -25,6 +25,7 @@ //| This module allows to decompress binary data compressed with DEFLATE algorithm //| (commonly used in zlib library and gzip archiver). Compression is not yet implemented.""" //| +//| //| def decompress(data: bytes, wbits: Optional[int] = 0, bufsize: Optional[int] = 0) -> bytes: //| """Return decompressed *data* as bytes. *wbits* is DEFLATE dictionary window @@ -48,6 +49,7 @@ //| """ //| ... //| +//| static mp_obj_t zlib_decompress(size_t n_args, const mp_obj_t *args) { mp_int_t wbits = 0; if (n_args > 1) { diff --git a/tests/circuitpython-manual/pwmio/code_extremes.py b/tests/circuitpython-manual/pwmio/code_extremes.py index 13dd5c90ad..4ca8b2f70f 100644 --- a/tests/circuitpython-manual/pwmio/code_extremes.py +++ b/tests/circuitpython-manual/pwmio/code_extremes.py @@ -80,7 +80,7 @@ while True: if time.monotonic() > freq_time: break t0 = freq_time - print(f"({freq}, {i/freq_duration:.0f}), ", end="") + print(f"({freq}, {i / freq_duration:.0f}), ", end="") print(")") print("done.") pwm.deinit() diff --git a/tests/circuitpython-manual/pwmio/code_ramps.py b/tests/circuitpython-manual/pwmio/code_ramps.py index 6a06e4eff6..e0d4901894 100644 --- a/tests/circuitpython-manual/pwmio/code_ramps.py +++ b/tests/circuitpython-manual/pwmio/code_ramps.py @@ -96,7 +96,7 @@ while True: if time.monotonic() > freq_time: break t0 = freq_time - print(f"({freq}, {i/freq_duration:.0f}), ", end="") + print(f"({freq}, {i / freq_duration:.0f}), ", end="") print(")") print("done.") pwm.deinit() diff --git a/tests/circuitpython-manual/pwmio/duty.py b/tests/circuitpython-manual/pwmio/duty.py index 0673f96c2b..f5c3abd471 100644 --- a/tests/circuitpython-manual/pwmio/duty.py +++ b/tests/circuitpython-manual/pwmio/duty.py @@ -107,7 +107,7 @@ def read( for duty in duty_labels: draw.text( (left - 10, y0 + (y1 - y0) * (1 - duty)), - f"{int(100*duty):d}%", + f"{int(100 * duty):d}%", duty_color, anchor="rm", ) diff --git a/tests/circuitpython/aes.py b/tests/circuitpython/aes.py index b47c4279d3..7e614118e5 100644 --- a/tests/circuitpython/aes.py +++ b/tests/circuitpython/aes.py @@ -100,7 +100,10 @@ print() print("truncated-CTR-1") ## Truncated CTR test case -plaintext = unhexlify("6bc1bee22e409f96e93d7e117393172a" "ae2d") +plaintext = unhexlify( + "6bc1bee22e409f96e93d7e117393172a" + "ae2d" +) # fmt: skip key = unhexlify("2b7e151628aed2a6abf7158809cf4f3c") counter = unhexlify("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff") @@ -122,7 +125,10 @@ print() print("truncated-CTR-2") ## Truncated CTR test case #2 -plaintext = unhexlify("6bc1bee22e409f96e93d7e117393172a" "ae") +plaintext = unhexlify( + "6bc1bee22e409f96e93d7e117393172a" + "ae" +) # fmt: skip key = unhexlify("2b7e151628aed2a6abf7158809cf4f3c") counter = unhexlify("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff") diff --git a/tests/circuitpython/audiofilter_filter.py b/tests/circuitpython/audiofilter_filter.py index 3267ded439..8081c8a6fb 100644 --- a/tests/circuitpython/audiofilter_filter.py +++ b/tests/circuitpython/audiofilter_filter.py @@ -1,6 +1,7 @@ from audiofilters import Filter from audiofilterhelper import synth_test, sine8k + @synth_test def basic_filter(): effect = Filter( diff --git a/tests/circuitpython/getenv.py b/tests/circuitpython/getenv.py index 941674d114..37819dd6f5 100644 --- a/tests/circuitpython/getenv.py +++ b/tests/circuitpython/getenv.py @@ -58,7 +58,7 @@ content_bad = [ b'key = """\n', b"key =\n", b'key="', - b'key = strings must be quoted\n', + b"key = strings must be quoted\n", ] diff --git a/tests/circuitpython/issue9705.py b/tests/circuitpython/issue9705.py index 90ebdc9375..7a59ed46f2 100644 --- a/tests/circuitpython/issue9705.py +++ b/tests/circuitpython/issue9705.py @@ -1,7 +1,11 @@ import audiomp3, audiocore import ulab.numpy as np -TEST_FILE = __file__.rsplit("/", 1)[0] + "/../circuitpython-manual/audiocore/jeplayer-splash-44100-stereo.mp3" +TEST_FILE = ( + __file__.rsplit("/", 1)[0] + + "/../circuitpython-manual/audiocore/jeplayer-splash-44100-stereo.mp3" +) + def normalized_rms_ulab(values): values = np.frombuffer(values, dtype=np.int16) @@ -9,7 +13,8 @@ def normalized_rms_ulab(values): minbuf = np.mean(values) values = values - minbuf samples_sum = np.sum(values * values) - return (samples_sum / len(values))**.5 + return (samples_sum / len(values)) ** 0.5 + def print_frame_loudness(decoder, n): for i in range(n): @@ -17,6 +22,7 @@ def print_frame_loudness(decoder, n): print(f"{i} {result} {normalized_rms_ulab(buf):5.0f}") print() + # First frames decoder = audiomp3.MP3Decoder(TEST_FILE) print_frame_loudness(decoder, 8) diff --git a/tests/circuitpython/mfm.py b/tests/circuitpython/mfm.py index 9839b5c756..fd2745bc11 100644 --- a/tests/circuitpython/mfm.py +++ b/tests/circuitpython/mfm.py @@ -1,76 +1,76 @@ import floppyio mfm_content = ( - b'HHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHH' - b'H00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH0' - b'0HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00H' - b'HHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHH' - b'H00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH0' - b'0HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00H' - b'HHH00HHHH00HHHH00HHHH00HHHH00HHHH00H00000000000000000000000000' - b'00000000000000000000000000000000000000000000000000000000000000' - b'0000000H0H`H`0H`H`0H`H`00000H0HHH00HHHH00HHHH00HHHH00HHHH00HHH' - b'H00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH0' - b'0HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00H' - b'HHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHH' - b'H00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH0' - b'0HHHH00HHHH00HHHH00H000000000000000000000000000000000000000000' - b'00000000000000000000000000000000000000000000000000000H`H`H0`H`' - b'H0`H`H0000000H0000000000000000000000HH0000H`0HH`HH0`000`HH00HH' - b'HH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH' - b'00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00' - b'H0000000000000000000000000000000000000000000000000000000000000' - b'0000000000000000000000000000000000H`H`H0`H`H0`H`H00000`0`0H00H' - b'`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0' - b'HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HH' - b'H0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0H' - b'H0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0' - b'H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H0' - b'0H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H' - b'`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0' - b'HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH' - b'0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0' - b'H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0' - b'H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H0' - b'0H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H' - b'`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0' - b'HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HH' - b'H0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0H' - b'H0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0' - b'H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H0' - b'0H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H' - b'`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0' - b'HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH' - b'0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0' - b'H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0' - b'H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H0' - b'0H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H' - b'`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0' - b'HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HH' - b'H0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0H' - b'H0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0' - b'H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H0' - b'0H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H' - b'`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0' - b'HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH' - b'0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0' - b'H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0' - b'H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H0' - b'0H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H' - b'`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0' - b'HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HH' - b'H0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0H' - b'H0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0' - b'H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H0' - b'0H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H' - b'`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0' - b'HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH' - b'0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0' - b'H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0' - b'H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H0' - b'0H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H' - b'`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0' - b'HH0HH0H00H`0HHH0H0H00H`0HH0``HHHH0`0000hhhhhhhhhhhhhhhhhhhhhhh' + b"HHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHH" + b"H00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH0" + b"0HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00H" + b"HHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHH" + b"H00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH0" + b"0HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00H" + b"HHH00HHHH00HHHH00HHHH00HHHH00HHHH00H00000000000000000000000000" + b"00000000000000000000000000000000000000000000000000000000000000" + b"0000000H0H`H`0H`H`0H`H`00000H0HHH00HHHH00HHHH00HHHH00HHHH00HHH" + b"H00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH0" + b"0HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00H" + b"HHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHH" + b"H00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH0" + b"0HHHH00HHHH00HHHH00H000000000000000000000000000000000000000000" + b"00000000000000000000000000000000000000000000000000000H`H`H0`H`" + b"H0`H`H0000000H0000000000000000000000HH0000H`0HH`HH0`000`HH00HH" + b"HH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH" + b"00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00HHHH00" + b"H0000000000000000000000000000000000000000000000000000000000000" + b"0000000000000000000000000000000000H`H`H0`H`H0`H`H00000`0`0H00H" + b"`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0" + b"HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HH" + b"H0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0H" + b"H0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0" + b"H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H0" + b"0H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H" + b"`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0" + b"HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH" + b"0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0" + b"H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0" + b"H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H0" + b"0H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H" + b"`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0" + b"HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HH" + b"H0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0H" + b"H0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0" + b"H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H0" + b"0H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H" + b"`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0" + b"HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH" + b"0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0" + b"H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0" + b"H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H0" + b"0H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H" + b"`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0" + b"HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HH" + b"H0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0H" + b"H0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0" + b"H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H0" + b"0H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H" + b"`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0" + b"HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH" + b"0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0" + b"H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0" + b"H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H0" + b"0H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H" + b"`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0" + b"HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HH" + b"H0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0H" + b"H0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0" + b"H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H0" + b"0H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H" + b"`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0" + b"HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH" + b"0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0" + b"H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0" + b"H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H0" + b"0H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H" + b"`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0HH0HH0H00H`0HHH0H0H00H`0" + b"HH0HH0H00H`0HHH0H0H00H`0HH0``HHHH0`0000hhhhhhhhhhhhhhhhhhhhhhh" ) b = bytearray(512) diff --git a/tests/circuitpython/synthio_block_biquad.py b/tests/circuitpython/synthio_block_biquad.py index db7cddd987..e7f6e85dba 100644 --- a/tests/circuitpython/synthio_block_biquad.py +++ b/tests/circuitpython/synthio_block_biquad.py @@ -4,13 +4,14 @@ import random random.seed(41) -white_noise = array.array('h', [random.randint(-32000, 32000) for i in range(600)]) +white_noise = array.array("h", [random.randint(-32000, 32000) for i in range(600)]) + @synth_test_rms def gen(synth): - l = LFO(sweep, offset=1440, scale=2880, rate=.025, once=True) + l = LFO(sweep, offset=1440, scale=2880, rate=0.025, once=True) yield [l] - b = BlockBiquad(FilterMode.LOW_PASS, l, Q=.5**.5) + b = BlockBiquad(FilterMode.LOW_PASS, l, Q=0.5**0.5) n = Note(100, filter=b, waveform=white_noise) synth.press(n) yield 20 diff --git a/tests/circuitpython/traceback_test_chained.py b/tests/circuitpython/traceback_test_chained.py index 3b96eb7a3c..46adfdb841 100644 --- a/tests/circuitpython/traceback_test_chained.py +++ b/tests/circuitpython/traceback_test_chained.py @@ -73,9 +73,11 @@ except Exception as e: print_exc_info(e) print() + class SomeException(RuntimeError): pass + try: try: raise Exception("inner") diff --git a/tests/circuitpython/traceback_test_chained.py.exp b/tests/circuitpython/traceback_test_chained.py.exp index 498be1f0b7..9105ac1d98 100644 --- a/tests/circuitpython/traceback_test_chained.py.exp +++ b/tests/circuitpython/traceback_test_chained.py.exp @@ -76,75 +76,75 @@ ZeroDivisionError: division by zero ------------------------------------------------------------------------ Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 81, in + File "circuitpython/traceback_test_chained.py", line 83, in Exception: inner During handling of the above exception, another exception occurred: Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 83, in + File "circuitpython/traceback_test_chained.py", line 85, in SomeException: outer ------------------------------------------------------------------------ ------------------------------------------------------------------------ Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 89, in + File "circuitpython/traceback_test_chained.py", line 91, in Exception: inner The above exception was the direct cause of the following exception: Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 92, in + File "circuitpython/traceback_test_chained.py", line 94, in SomeException: outer ------------------------------------------------------------------------ ------------------------------------------------------------------------ -Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 99, in -RuntimeError: inner - -The above exception was the direct cause of the following exception: - Traceback (most recent call last): File "circuitpython/traceback_test_chained.py", line 101, in -Exception: outer ------------------------------------------------------------------------- - ------------------------------------------------------------------------- -Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 107, in RuntimeError: inner The above exception was the direct cause of the following exception: Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 110, in + File "circuitpython/traceback_test_chained.py", line 103, in +Exception: outer +------------------------------------------------------------------------ + +------------------------------------------------------------------------ +Traceback (most recent call last): + File "circuitpython/traceback_test_chained.py", line 109, in +RuntimeError: inner + +The above exception was the direct cause of the following exception: + +Traceback (most recent call last): + File "circuitpython/traceback_test_chained.py", line 112, in Exception: outer ------------------------------------------------------------------------ ------------------------------------------------------------------------ Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 117, in + File "circuitpython/traceback_test_chained.py", line 119, in RuntimeError: inner During handling of the above exception, another exception occurred: Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 119, in + File "circuitpython/traceback_test_chained.py", line 121, in SomeException: outer ------------------------------------------------------------------------ ------------------------------------------------------------------------ Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 125, in + File "circuitpython/traceback_test_chained.py", line 127, in RuntimeError: inner The above exception was the direct cause of the following exception: Traceback (most recent call last): - File "circuitpython/traceback_test_chained.py", line 128, in + File "circuitpython/traceback_test_chained.py", line 130, in SomeException: outer ------------------------------------------------------------------------ diff --git a/tests/cpydiff/builtin_next_arg2.py b/tests/cpydiff/builtin_next_arg2.py index 5df2d6e70f..ed9565fe0f 100644 --- a/tests/cpydiff/builtin_next_arg2.py +++ b/tests/cpydiff/builtin_next_arg2.py @@ -9,4 +9,5 @@ workaround: Instead of ``val = next(it, deflt)`` use:: except StopIteration: val = deflt """ + print(next(iter(range(0)), 42)) diff --git a/tests/cpydiff/core_class_delnotimpl.py b/tests/cpydiff/core_class_delnotimpl.py index 18c176e9bb..6fac764ac9 100644 --- a/tests/cpydiff/core_class_delnotimpl.py +++ b/tests/cpydiff/core_class_delnotimpl.py @@ -4,6 +4,7 @@ description: Special method __del__ not implemented for user-defined classes cause: Unknown workaround: Unknown """ + import gc diff --git a/tests/cpydiff/core_fstring_concat.py b/tests/cpydiff/core_fstring_concat.py index c2bdb4e666..63e40da5bd 100644 --- a/tests/cpydiff/core_fstring_concat.py +++ b/tests/cpydiff/core_fstring_concat.py @@ -6,8 +6,9 @@ workaround: Use the + operator between literal strings when either or both are f """ x, y = 1, 2 -print("aa" f"{x}") # works -print(f"{x}" "ab") # works -print("a{}a" f"{x}") # fails -print(f"{x}" "a{}b") # fails -print(f"{x}" f"{y}") # fails +# fmt: off +print(f"aa{x}") # works +print(f"{x}ab") # works +print(f"a{{}}a{x}") # fails +print(f"{x}a{{}}b") # fails +print(f"{x}{y}") # fails diff --git a/tests/cpydiff/core_fstring_parser.py b/tests/cpydiff/core_fstring_parser.py index 22bbc5866e..dbbe5b3d08 100644 --- a/tests/cpydiff/core_fstring_parser.py +++ b/tests/cpydiff/core_fstring_parser.py @@ -5,5 +5,6 @@ cause: MicroPython is optimised for code space. workaround: Always use balanced braces and brackets in expressions inside f-strings """ -print(f'{"hello { world"}') -print(f'{"hello ] world"}') +# fmt: off +print(f"{'hello { world'}") +print(f"{'hello ] world'}") diff --git a/tests/cpydiff/core_function_argcount.py b/tests/cpydiff/core_function_argcount.py index 5f3dca4dcd..c257def726 100644 --- a/tests/cpydiff/core_function_argcount.py +++ b/tests/cpydiff/core_function_argcount.py @@ -4,6 +4,7 @@ description: Error messages for methods may display unexpected argument counts cause: MicroPython counts "self" as an argument. workaround: Interpret error messages with the information above in mind. """ + try: [].append() except Exception as e: diff --git a/tests/cpydiff/core_import_all.py b/tests/cpydiff/core_import_all.py index 5adf9ae3eb..0fbe9d4d4e 100644 --- a/tests/cpydiff/core_import_all.py +++ b/tests/cpydiff/core_import_all.py @@ -4,6 +4,7 @@ description: __all__ is unsupported in __init__.py in MicroPython. cause: Not implemented. workaround: Manually import the sub-modules directly in __init__.py using ``from . import foo, bar``. """ + from modules3 import * foo.hello() diff --git a/tests/cpydiff/core_import_path.py b/tests/cpydiff/core_import_path.py index 959fd571f5..2028386be8 100644 --- a/tests/cpydiff/core_import_path.py +++ b/tests/cpydiff/core_import_path.py @@ -4,6 +4,7 @@ description: __path__ attribute of a package has a different type (single string cause: MicroPython doesn't support namespace packages split across filesystem. Beyond that, MicroPython's import system is highly optimized for minimal memory usage. workaround: Details of import handling is inherently implementation dependent. Don't rely on such details in portable applications. """ + import modules print(modules.__path__) diff --git a/tests/cpydiff/core_import_split_ns_pkgs.py b/tests/cpydiff/core_import_split_ns_pkgs.py index 5c92b63124..a1cfd84893 100644 --- a/tests/cpydiff/core_import_split_ns_pkgs.py +++ b/tests/cpydiff/core_import_split_ns_pkgs.py @@ -4,6 +4,7 @@ description: MicroPython doesn't support namespace packages split across filesys cause: MicroPython's import system is highly optimized for simplicity, minimal memory usage, and minimal filesystem search overhead. workaround: Don't install modules belonging to the same namespace package in different directories. For MicroPython, it's recommended to have at most 3-component module search paths: for your current application, per-user (writable), system-wide (non-writable). """ + import sys sys.path.append(sys.path[1] + "/modules") diff --git a/tests/cpydiff/core_locals_eval.py b/tests/cpydiff/core_locals_eval.py index 025d226372..3f6ad2a1db 100644 --- a/tests/cpydiff/core_locals_eval.py +++ b/tests/cpydiff/core_locals_eval.py @@ -4,6 +4,7 @@ description: Code running in eval() function doesn't have access to local variab cause: MicroPython doesn't maintain symbolic local environment, it is optimized to an array of slots. Thus, local variables can't be accessed by a name. Effectively, ``eval(expr)`` in MicroPython is equivalent to ``eval(expr, globals(), globals())``. workaround: Unknown """ + val = 1 diff --git a/tests/cpydiff/module_array_comparison.py b/tests/cpydiff/module_array_comparison.py index a442af3f5b..4929b1e590 100644 --- a/tests/cpydiff/module_array_comparison.py +++ b/tests/cpydiff/module_array_comparison.py @@ -4,6 +4,7 @@ description: Comparison between different typecodes not supported cause: Code size workaround: Compare individual elements """ + import array array.array("b", [1, 2]) == array.array("i", [1, 2]) diff --git a/tests/cpydiff/module_array_constructor.py b/tests/cpydiff/module_array_constructor.py index 08cf2ef2d1..a53589d22a 100644 --- a/tests/cpydiff/module_array_constructor.py +++ b/tests/cpydiff/module_array_constructor.py @@ -4,6 +4,7 @@ description: Overflow checking is not implemented cause: MicroPython implements implicit truncation in order to reduce code size and execution time workaround: If CPython compatibility is needed then mask the value explicitly """ + import array a = array.array("b", [257]) diff --git a/tests/cpydiff/modules_array_containment.py b/tests/cpydiff/modules_array_containment.py index 8f25b0d491..b29895aa75 100644 --- a/tests/cpydiff/modules_array_containment.py +++ b/tests/cpydiff/modules_array_containment.py @@ -4,6 +4,7 @@ description: Looking for integer not implemented cause: Unknown workaround: Unknown """ + import array print(1 in array.array("B", b"12")) diff --git a/tests/cpydiff/modules_array_deletion.py b/tests/cpydiff/modules_array_deletion.py index 3376527373..2e7c31124b 100644 --- a/tests/cpydiff/modules_array_deletion.py +++ b/tests/cpydiff/modules_array_deletion.py @@ -4,6 +4,7 @@ description: Array deletion not implemented cause: Unknown workaround: Unknown """ + import array a = array.array("b", (1, 2, 3)) diff --git a/tests/cpydiff/modules_array_subscrstep.py b/tests/cpydiff/modules_array_subscrstep.py index 24308bd904..65b12332f5 100644 --- a/tests/cpydiff/modules_array_subscrstep.py +++ b/tests/cpydiff/modules_array_subscrstep.py @@ -4,6 +4,7 @@ description: Subscript with step != 1 is not yet implemented cause: Unknown workaround: Unknown """ + import array a = array.array("b", (1, 2, 3)) diff --git a/tests/cpydiff/modules_deque.py b/tests/cpydiff/modules_deque.py index 4d2746d1f8..9eb9edbda6 100644 --- a/tests/cpydiff/modules_deque.py +++ b/tests/cpydiff/modules_deque.py @@ -4,6 +4,7 @@ description: Deque not implemented cause: Unknown workaround: Use regular lists. micropython-lib has implementation of collections.deque. """ + import collections D = collections.deque() diff --git a/tests/cpydiff/modules_json_nonserializable.py b/tests/cpydiff/modules_json_nonserializable.py index ffe523786f..1adc13b26b 100644 --- a/tests/cpydiff/modules_json_nonserializable.py +++ b/tests/cpydiff/modules_json_nonserializable.py @@ -4,6 +4,7 @@ description: JSON module does not throw exception when object is not serialisabl cause: Unknown workaround: Unknown """ + import json a = bytes(x for x in range(256)) diff --git a/tests/cpydiff/modules_os_environ.py b/tests/cpydiff/modules_os_environ.py index 491d8a3101..4edde16656 100644 --- a/tests/cpydiff/modules_os_environ.py +++ b/tests/cpydiff/modules_os_environ.py @@ -4,6 +4,7 @@ description: ``environ`` attribute is not implemented cause: Unknown workaround: Use ``getenv``, ``putenv`` and ``unsetenv`` """ + import os try: diff --git a/tests/cpydiff/modules_os_getenv.py b/tests/cpydiff/modules_os_getenv.py index d1e828438e..d5acd414eb 100644 --- a/tests/cpydiff/modules_os_getenv.py +++ b/tests/cpydiff/modules_os_getenv.py @@ -4,6 +4,7 @@ description: ``getenv`` returns actual value instead of cached value cause: The ``environ`` attribute is not implemented workaround: Unknown """ + import os print(os.getenv("NEW_VARIABLE")) diff --git a/tests/cpydiff/modules_struct_fewargs.py b/tests/cpydiff/modules_struct_fewargs.py index cb6b0fd874..49b2a3213c 100644 --- a/tests/cpydiff/modules_struct_fewargs.py +++ b/tests/cpydiff/modules_struct_fewargs.py @@ -4,6 +4,7 @@ description: Struct pack with too few args, not checked by uPy cause: Unknown workaround: Unknown """ + import struct try: diff --git a/tests/cpydiff/modules_struct_manyargs.py b/tests/cpydiff/modules_struct_manyargs.py index 03395baad3..e3b78930f2 100644 --- a/tests/cpydiff/modules_struct_manyargs.py +++ b/tests/cpydiff/modules_struct_manyargs.py @@ -4,6 +4,7 @@ description: Struct pack with too many args, not checked by uPy cause: Unknown workaround: Unknown """ + import struct try: diff --git a/tests/cpydiff/modules_struct_whitespace_in_format.py b/tests/cpydiff/modules_struct_whitespace_in_format.py index a882b38569..a7a1d2facd 100644 --- a/tests/cpydiff/modules_struct_whitespace_in_format.py +++ b/tests/cpydiff/modules_struct_whitespace_in_format.py @@ -4,6 +4,7 @@ description: Struct pack with whitespace in format, whitespace ignored by CPytho cause: MicroPython is optimised for code size. workaround: Don't use spaces in format strings. """ + import struct try: diff --git a/tests/cpydiff/modules_sys_stdassign.py b/tests/cpydiff/modules_sys_stdassign.py index 7d086078a9..29afe1b120 100644 --- a/tests/cpydiff/modules_sys_stdassign.py +++ b/tests/cpydiff/modules_sys_stdassign.py @@ -4,6 +4,7 @@ description: Overriding sys.stdin, sys.stdout and sys.stderr not possible cause: They are stored in read-only memory. workaround: Unknown """ + import sys sys.stdin = None diff --git a/tests/cpydiff/syntax_assign_expr.py b/tests/cpydiff/syntax_assign_expr.py index d4ed063b39..58f57ca1fb 100644 --- a/tests/cpydiff/syntax_assign_expr.py +++ b/tests/cpydiff/syntax_assign_expr.py @@ -4,4 +4,5 @@ description: MicroPython allows using := to assign to the variable of a comprehe cause: MicroPython is optimised for code size and doesn't check this case. workaround: Do not rely on this behaviour if writing CPython compatible code. """ + print([i := -1 for i in range(4)]) diff --git a/tests/cpydiff/syntax_spaces.py b/tests/cpydiff/syntax_spaces.py index c308240a78..03d25d5619 100644 --- a/tests/cpydiff/syntax_spaces.py +++ b/tests/cpydiff/syntax_spaces.py @@ -4,6 +4,7 @@ description: uPy requires spaces between literal numbers and keywords, CPy doesn cause: Unknown workaround: Unknown """ + try: print(eval("1and 0")) except SyntaxError: diff --git a/tests/cpydiff/syntax_unicode_nameesc.py b/tests/cpydiff/syntax_unicode_nameesc.py index 21628c974d..838394b6eb 100644 --- a/tests/cpydiff/syntax_unicode_nameesc.py +++ b/tests/cpydiff/syntax_unicode_nameesc.py @@ -4,4 +4,5 @@ description: Unicode name escapes are not implemented cause: Unknown workaround: Unknown """ + print("\N{LATIN SMALL LETTER A}") diff --git a/tests/cpydiff/types_bytearray_sliceassign.py b/tests/cpydiff/types_bytearray_sliceassign.py index e4068b04b9..353f61988f 100644 --- a/tests/cpydiff/types_bytearray_sliceassign.py +++ b/tests/cpydiff/types_bytearray_sliceassign.py @@ -4,6 +4,7 @@ description: Array slice assignment with unsupported RHS cause: Unknown workaround: Unknown """ + b = bytearray(4) b[0:1] = [1, 2] print(b) diff --git a/tests/cpydiff/types_bytes_format.py b/tests/cpydiff/types_bytes_format.py index ad04987711..1a15e572c8 100644 --- a/tests/cpydiff/types_bytes_format.py +++ b/tests/cpydiff/types_bytes_format.py @@ -4,4 +4,5 @@ description: bytes objects support .format() method cause: MicroPython strives to be a more regular implementation, so if both `str` and `bytes` support ``__mod__()`` (the % operator), it makes sense to support ``format()`` for both too. Support for ``__mod__`` can also be compiled out, which leaves only ``format()`` for bytes formatting. workaround: If you are interested in CPython compatibility, don't use ``.format()`` on bytes objects. """ + print(b"{}".format(1)) diff --git a/tests/cpydiff/types_bytes_keywords.py b/tests/cpydiff/types_bytes_keywords.py index ade83d0a70..a459c94b41 100644 --- a/tests/cpydiff/types_bytes_keywords.py +++ b/tests/cpydiff/types_bytes_keywords.py @@ -4,4 +4,5 @@ description: bytes() with keywords not implemented cause: Unknown workaround: Pass the encoding as a positional parameter, e.g. ``print(bytes('abc', 'utf-8'))`` """ + print(bytes("abc", encoding="utf8")) diff --git a/tests/cpydiff/types_bytes_subscrstep.py b/tests/cpydiff/types_bytes_subscrstep.py index 51b94cb710..c566cbdb63 100644 --- a/tests/cpydiff/types_bytes_subscrstep.py +++ b/tests/cpydiff/types_bytes_subscrstep.py @@ -4,4 +4,5 @@ description: Bytes subscription with step != 1 not implemented cause: MicroPython is highly optimized for memory usage. workaround: Use explicit loop for this very rare operation. """ + print(b"123"[0:3:2]) diff --git a/tests/cpydiff/types_dict_keys_set.py b/tests/cpydiff/types_dict_keys_set.py index 3a0849a355..a5f127962e 100644 --- a/tests/cpydiff/types_dict_keys_set.py +++ b/tests/cpydiff/types_dict_keys_set.py @@ -4,4 +4,5 @@ description: Dictionary keys view does not behave as a set. cause: Not implemented. workaround: Explicitly convert keys to a set before using set operations. """ + print({1: 2, 3: 4}.keys() & {1}) diff --git a/tests/cpydiff/types_exception_attrs.py b/tests/cpydiff/types_exception_attrs.py index ad72b62a61..5fed45451d 100644 --- a/tests/cpydiff/types_exception_attrs.py +++ b/tests/cpydiff/types_exception_attrs.py @@ -4,6 +4,7 @@ description: All exceptions have readable ``value`` and ``errno`` attributes, no cause: MicroPython is optimised to reduce code size. workaround: Only use ``value`` on ``StopIteration`` exceptions, and ``errno`` on ``OSError`` exceptions. Do not use or rely on these attributes on other exceptions. """ + e = Exception(1) print(e.value) print(e.errno) diff --git a/tests/cpydiff/types_exception_chaining.py b/tests/cpydiff/types_exception_chaining.py index 836c4eb3e7..cff68d4124 100644 --- a/tests/cpydiff/types_exception_chaining.py +++ b/tests/cpydiff/types_exception_chaining.py @@ -4,6 +4,7 @@ description: Exception chaining not implemented cause: Unknown workaround: Unknown """ + try: raise TypeError except TypeError: diff --git a/tests/cpydiff/types_exception_instancevar.py b/tests/cpydiff/types_exception_instancevar.py index adc353361f..fb67771baf 100644 --- a/tests/cpydiff/types_exception_instancevar.py +++ b/tests/cpydiff/types_exception_instancevar.py @@ -4,6 +4,7 @@ description: User-defined attributes for builtin exceptions are not supported cause: MicroPython is highly optimized for memory usage. workaround: Use user-defined exception subclasses. """ + e = Exception() e.x = 0 print(e.x) diff --git a/tests/cpydiff/types_exception_loops.py b/tests/cpydiff/types_exception_loops.py index 8d326cbbbb..549f1dd0a5 100644 --- a/tests/cpydiff/types_exception_loops.py +++ b/tests/cpydiff/types_exception_loops.py @@ -4,6 +4,7 @@ description: Exception in while loop condition may have unexpected line number cause: Condition checks are optimized to happen at the end of loop body, and that line number is reported. workaround: Unknown """ + l = ["-foo", "-bar"] i = 0 diff --git a/tests/cpydiff/types_float_rounding.py b/tests/cpydiff/types_float_rounding.py index a5b591966b..206e359ed9 100644 --- a/tests/cpydiff/types_float_rounding.py +++ b/tests/cpydiff/types_float_rounding.py @@ -4,4 +4,5 @@ description: uPy and CPython outputs formats may differ cause: Unknown workaround: Unknown """ + print("%.1g" % -9.9) diff --git a/tests/cpydiff/types_list_delete_subscrstep.py b/tests/cpydiff/types_list_delete_subscrstep.py index 36e6f526b3..3c801d8494 100644 --- a/tests/cpydiff/types_list_delete_subscrstep.py +++ b/tests/cpydiff/types_list_delete_subscrstep.py @@ -4,6 +4,7 @@ description: List delete with step != 1 not implemented cause: Unknown workaround: Use explicit loop for this rare operation. """ + l = [1, 2, 3, 4] del l[0:4:2] print(l) diff --git a/tests/cpydiff/types_list_store_noniter.py b/tests/cpydiff/types_list_store_noniter.py index 1d69b4a823..581b136980 100644 --- a/tests/cpydiff/types_list_store_noniter.py +++ b/tests/cpydiff/types_list_store_noniter.py @@ -4,6 +4,7 @@ description: List slice-store with non-iterable on RHS is not implemented cause: RHS is restricted to be a tuple or list workaround: Use ``list()`` on RHS to convert the iterable to a list """ + l = [10, 20] l[0:1] = range(4) print(l) diff --git a/tests/cpydiff/types_list_store_subscrstep.py b/tests/cpydiff/types_list_store_subscrstep.py index 1460372bb1..97590267f4 100644 --- a/tests/cpydiff/types_list_store_subscrstep.py +++ b/tests/cpydiff/types_list_store_subscrstep.py @@ -4,6 +4,7 @@ description: List store with step != 1 not implemented cause: Unknown workaround: Use explicit loop for this rare operation. """ + l = [1, 2, 3, 4] l[0:4:2] = [5, 6] print(l) diff --git a/tests/cpydiff/types_memoryview_invalid.py b/tests/cpydiff/types_memoryview_invalid.py index c995a2e899..f288c50ab5 100644 --- a/tests/cpydiff/types_memoryview_invalid.py +++ b/tests/cpydiff/types_memoryview_invalid.py @@ -6,6 +6,7 @@ cause: CPython prevents a ``bytearray`` or ``io.bytesIO`` object from changing s In the worst case scenario, resizing an object which is the target of a memoryview can cause the memoryview(s) to reference invalid freed memory (a use-after-free bug) and corrupt the MicroPython runtime. workaround: Do not change the size of any ``bytearray`` or ``io.bytesIO`` object that has a ``memoryview`` assigned to it. """ + b = bytearray(b"abcdefg") m = memoryview(b) b.extend(b"hijklmnop") diff --git a/tests/cpydiff/types_str_endswith.py b/tests/cpydiff/types_str_endswith.py index f222ac1cd3..890c7ba5ef 100644 --- a/tests/cpydiff/types_str_endswith.py +++ b/tests/cpydiff/types_str_endswith.py @@ -4,4 +4,5 @@ description: Start/end indices such as str.endswith(s, start) not implemented cause: Unknown workaround: Unknown """ + print("abc".endswith("c", 1)) diff --git a/tests/cpydiff/types_str_formatsubscr.py b/tests/cpydiff/types_str_formatsubscr.py index 1b83cfff6c..5c59a1d200 100644 --- a/tests/cpydiff/types_str_formatsubscr.py +++ b/tests/cpydiff/types_str_formatsubscr.py @@ -4,4 +4,5 @@ description: Attributes/subscr not implemented cause: Unknown workaround: Unknown """ + print("{a[0]}".format(a=[1, 2])) diff --git a/tests/cpydiff/types_str_keywords.py b/tests/cpydiff/types_str_keywords.py index 77a4eac1c1..640dfa6c39 100644 --- a/tests/cpydiff/types_str_keywords.py +++ b/tests/cpydiff/types_str_keywords.py @@ -4,4 +4,5 @@ description: str(...) with keywords not implemented cause: Unknown workaround: Input the encoding format directly. eg ``print(bytes('abc', 'utf-8'))`` """ + print(str(b"abc", encoding="utf8")) diff --git a/tests/cpydiff/types_str_ljust_rjust.py b/tests/cpydiff/types_str_ljust_rjust.py index 72e5105e02..7f91c137e9 100644 --- a/tests/cpydiff/types_str_ljust_rjust.py +++ b/tests/cpydiff/types_str_ljust_rjust.py @@ -4,4 +4,5 @@ description: str.ljust() and str.rjust() not implemented cause: MicroPython is highly optimized for memory usage. Easy workarounds available. workaround: Instead of ``s.ljust(10)`` use ``"%-10s" % s``, instead of ``s.rjust(10)`` use ``"% 10s" % s``. Alternatively, ``"{:<10}".format(s)`` or ``"{:>10}".format(s)``. """ + print("abc".ljust(10)) diff --git a/tests/cpydiff/types_str_rsplitnone.py b/tests/cpydiff/types_str_rsplitnone.py index 5d334fea2f..ae524620a0 100644 --- a/tests/cpydiff/types_str_rsplitnone.py +++ b/tests/cpydiff/types_str_rsplitnone.py @@ -4,4 +4,5 @@ description: None as first argument for rsplit such as str.rsplit(None, n) not i cause: Unknown workaround: Unknown """ + print("a a a".rsplit(None, 1)) diff --git a/tests/cpydiff/types_str_subscrstep.py b/tests/cpydiff/types_str_subscrstep.py index 2d3245e558..cd57f18ccb 100644 --- a/tests/cpydiff/types_str_subscrstep.py +++ b/tests/cpydiff/types_str_subscrstep.py @@ -4,4 +4,5 @@ description: Subscript with step != 1 is not yet implemented cause: Unknown workaround: Unknown """ + print("abcdefghi"[0:9:2]) diff --git a/tests/cpydiff/types_tuple_subscrstep.py b/tests/cpydiff/types_tuple_subscrstep.py index f90f3c5bf4..60ba31af4c 100644 --- a/tests/cpydiff/types_tuple_subscrstep.py +++ b/tests/cpydiff/types_tuple_subscrstep.py @@ -4,4 +4,5 @@ description: Tuple load with step != 1 not implemented cause: Unknown workaround: Unknown """ + print((1, 2, 3, 4)[0:4:2]) diff --git a/tests/extmod/asyncio_event_fair.py b/tests/extmod/asyncio_event_fair.py index ebbf322211..b878cabfe1 100644 --- a/tests/extmod/asyncio_event_fair.py +++ b/tests/extmod/asyncio_event_fair.py @@ -12,6 +12,7 @@ except ImportError: async def foo(): return 42 + try: fooc = foo() fooc.__await__ diff --git a/tests/micropython/import_mpy_native_gc.py b/tests/micropython/import_mpy_native_gc.py index 1901dc669a..2f21e417d3 100644 --- a/tests/micropython/import_mpy_native_gc.py +++ b/tests/micropython/import_mpy_native_gc.py @@ -55,8 +55,7 @@ features0_file_contents = { # -march=x64 0x806: b'C\x06\n\x1f\x02\x004build/features0.native.mpy\x00\x12factorial\x00\x8a\x02\xe93\x00\x00\x00\xf3\x0f\x1e\xfaSH\x8b\x1d\x7f\x00\x00\x00\xbe\x02\x00\x00\x00\xffS\x18\xbf\x01\x00\x00\x00H\x85\xc0u\x0cH\x8bC \xbe\x02\x00\x00\x00[\xff\xe0H\x0f\xaf\xf8H\xff\xc8\xeb\xe6\xf3\x0f\x1e\xfaATUSH\x8b\x1dI\x00\x00\x00H\x8bG\x08L\x8bc(H\x8bx\x08A\xff\xd4H\x8d5#\x00\x00\x00H\x89\xc5H\x8b\x051\x00\x00\x00\x0f\xb7x\x02\xffShH\x89\xefA\xff\xd4H\x8b\x03[]A\\\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x11$\r&\xa5 \x01"\xff', # -march=armv6m - 0x1006: b'C\x06\x12\x1f\x02\x004build/features0.native.mpy\x00\x12factorial\x00\x88\x02\x18\xe0\x00\x00\x10\xb5\tK\tJ{D\x9cX\x02!\xe3h\x98G\x03\x00\x01 \x00+\x02\xd0XC\x01;\xfa\xe7\x02!#i\x98G\x10\xbd\xc0Fj\x00\x00\x00\x00\x00\x00\x00\xf8\xb5\nN\nK~D\xf4XChgiXh\xb8G\x05\x00\x07K\x08I\xf3XyDX\x88ck\x98G(\x00\xb8G h\xf8\xbd\xc0F:\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x11<\r>\xa58\x01:\xff' -, + 0x1006: b"C\x06\x12\x1f\x02\x004build/features0.native.mpy\x00\x12factorial\x00\x88\x02\x18\xe0\x00\x00\x10\xb5\tK\tJ{D\x9cX\x02!\xe3h\x98G\x03\x00\x01 \x00+\x02\xd0XC\x01;\xfa\xe7\x02!#i\x98G\x10\xbd\xc0Fj\x00\x00\x00\x00\x00\x00\x00\xf8\xb5\nN\nK~D\xf4XChgiXh\xb8G\x05\x00\x07K\x08I\xf3XyDX\x88ck\x98G(\x00\xb8G h\xf8\xbd\xc0F:\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x11<\r>\xa58\x01:\xff", } # Populate armv7m-derived archs based on armv6m. diff --git a/tests/pyboard.py b/tests/pyboard.py deleted file mode 120000 index 582a1f894f..0000000000 --- a/tests/pyboard.py +++ /dev/null @@ -1 +0,0 @@ -../tools/cpboard.py diff --git a/tests/run-natmodtests.py b/tests/run-natmodtests.py index 24acd327c0..f1ff120c1a 100755 --- a/tests/run-natmodtests.py +++ b/tests/run-natmodtests.py @@ -9,7 +9,7 @@ import subprocess import sys import argparse -#CIRCUITPY-CHANGE: no pyboard +# CIRCUITPY-CHANGE: no pyboard # Paths for host executables CPYTHON3 = os.getenv("MICROPY_CPYTHON3", "python3") @@ -17,7 +17,7 @@ MICROPYTHON = os.getenv("MICROPY_MICROPYTHON", "../ports/unix/build-coverage/mic NATMOD_EXAMPLE_DIR = "../examples/natmod/" -#CIRCUITPY-CHANGE: different TEST_MAPPINGS +# CIRCUITPY-CHANGE: different TEST_MAPPINGS # Supported tests and their corresponding mpy module TEST_MAPPINGS = { "heapq": "heapq/heapq_$(ARCH).mpy", diff --git a/tests/testlib/audiofilterhelper.py b/tests/testlib/audiofilterhelper.py index 15862dc398..d8a4b57ffd 100644 --- a/tests/testlib/audiofilterhelper.py +++ b/tests/testlib/audiofilterhelper.py @@ -7,7 +7,8 @@ from synthio import Note, LFO, MathOperation, Synthesizer sinedata = array.array("h", [int(32767 * sin(i * 2 * pi / 600)) for i in range(600)]) sine8k = RawSample(sinedata, sample_rate=8000) -def synth_test(_gen=None, dtype=np.int16, divisor = 32768, channel_count=1): + +def synth_test(_gen=None, dtype=np.int16, divisor=32768, channel_count=1): def func(gen): g = gen() synth, blocks = next(g) diff --git a/tests/unicode/unicode.py b/tests/unicode/unicode.py index 072e049fde..58d406e63e 100644 --- a/tests/unicode/unicode.py +++ b/tests/unicode/unicode.py @@ -5,7 +5,7 @@ for i in range(len(s)): # Test all three forms of Unicode escape, and # all blocks of UTF-8 byte patterns -s = "a\xA9\xFF\u0123\u0800\uFFEE\U0001F44C" +s = "a\xa9\xff\u0123\u0800\uffee\U0001f44c" for i in range(-len(s), len(s)): print("s[%d]: %s %X" % (i, s[i], ord(s[i]))) print("s[:%d]: %d chars, '%s'" % (i, len(s[:i]), s[:i])) diff --git a/tools/analyze_heap_dump.py b/tools/analyze_heap_dump.py index a5e5e1d48e..ac1bb0c8ce 100755 --- a/tools/analyze_heap_dump.py +++ b/tools/analyze_heap_dump.py @@ -82,7 +82,7 @@ SKIP_SYMBOLS = [ help="Draw the ownership graph of blocks on the heap", ) @click.option("--analyze-snapshots", default="last", type=click.Choice(["all", "last"])) -def do_all_the_things( +def do_all_the_things( # noqa: C901: too complex ram_filename, bin_filename, map_filename, diff --git a/tools/analyze_mpy.py b/tools/analyze_mpy.py index 3f212e2679..f8da7a85f9 100755 --- a/tools/analyze_mpy.py +++ b/tools/analyze_mpy.py @@ -229,7 +229,7 @@ class RawCode: while bc.peek(1)[0] == 0xFF: bc.read(1) bc = bytearray(bc.read()) - # print(encoded_code_info, bc) + print(encoded_code_info, bc) self.qstrs = [] diff --git a/tools/board_stubs/build_board_specific_stubs/board_stub_builder.py b/tools/board_stubs/build_board_specific_stubs/board_stub_builder.py index 63c4dd9c2f..fb6219f373 100644 --- a/tools/board_stubs/build_board_specific_stubs/board_stub_builder.py +++ b/tools/board_stubs/build_board_specific_stubs/board_stub_builder.py @@ -157,10 +157,10 @@ def create_board_stubs(board_id, records, mappings, board_filename): boards_file.write("#\n") boards_file.write("# SPDX-License-Identifier: MIT\n") boards_file.write('"""\n') - boards_file.write(f'Board stub for {mappings["board_name"]}\n') - boards_file.write(f' - port: {mappings["port"]}\n') + boards_file.write(f"Board stub for {mappings['board_name']}\n") + boards_file.write(f" - port: {mappings['port']}\n") boards_file.write(f" - board_id: {board_id}\n") - boards_file.write(f' - NVM size: {mappings["nvm_size"]}\n') + boards_file.write(f" - NVM size: {mappings['nvm_size']}\n") boards_file.write(f" - Included modules: {included_modules}\n") boards_file.write(f" - Frozen libraries: {frozen_libraries}\n") boards_file.write('"""\n\n') @@ -297,7 +297,7 @@ def build_stubs(circuitpython_dir, circuitpython_org_dir, export_dir, version="8 else: lookup = board - port_path = f'{circuitpython_dir}ports/{board_data["port"]}/' + port_path = f"{circuitpython_dir}ports/{board_data['port']}/" board_path = f"{port_path}boards/{lookup}/" pins_path = f"{board_path}pins.c" if not os.path.isfile(pins_path): diff --git a/tools/board_summaries.py b/tools/board_summaries.py index 08ddc644af..3ea87e68d5 100644 --- a/tools/board_summaries.py +++ b/tools/board_summaries.py @@ -61,7 +61,7 @@ def frozen_incidence_matrix_csvs(support_matrix, rows=1000, present="1", absent= all_frozen = set() for info in support_matrix.values(): frozen = info["frozen_libraries"] - frozen = [f[0] if type(f) == tuple else f for f in frozen] + frozen = [f[0] if isinstance(f, tuple) else f for f in frozen] all_frozen.update(frozen) all_frozen = sorted(all_frozen) csvs = [] @@ -75,7 +75,7 @@ def frozen_incidence_matrix_csvs(support_matrix, rows=1000, present="1", absent= chip_pin_set = set([chip_pin for _, chip_pin in info["pins"]]) n_chip_pins = len(chip_pin_set) - frozen = [f[0] if type(f) == tuple else f for f in frozen] + frozen = [f[0] if isinstance(f, tuple) else f for f in frozen] frozen_incidence = [present if f in frozen else absent for f in all_frozen] line = ( f"{board},{info.get('branded_name')},{info.get('mcu')}," @@ -150,8 +150,7 @@ def board_pins_matrix_csvs(support_matrix, rows=1000): for board, info in support_matrix.items(): if (row % rows) == 0: csv = [ - "board,branded_name,mcu,flash,port,n_board_pins," - "board_pins,n_chip_pins,chip_pins\n" + "board,branded_name,mcu,flash,port,n_board_pins,board_pins,n_chip_pins,chip_pins\n" ] board_pins = [board_pin for board_pin, _ in info["pins"]] chip_pins = [chip_pin for _, chip_pin in info["pins"]] @@ -186,12 +185,12 @@ def write_csvs(rows=1000, present="1", absent="0"): "frozen": frozen_incidence_matrix_csvs(s, rows=rows, present=present, absent=absent), "pins": board_pins_matrix_csvs(s, rows=rows), } - for key in csvs: - for i in range(len(csvs[key])): + for key, values in csvs: + for i in range(len(values)): filename = f"{key}_{i}.csv" print(f"writing {filename}") with open(filename, "w") as f: - f.writelines(csvs[key][i]) + f.writelines(values[i]) if __name__ == "__main__": diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 44f2f4759d..cd9a2a5756 100755 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -216,9 +216,6 @@ def print_active_user(): def generate_download_info(): - boards = {} - errors = [] - new_tag = os.environ["RELEASE_TAG"] changes = {"new_release": new_tag, "new_boards": [], "new_languages": []} @@ -255,7 +252,6 @@ def generate_download_info(): board_path = os.path.join("../ports", port, "boards") for board_path in os.scandir(board_path): if board_path.is_dir(): - board_files = os.listdir(board_path.path) board_id = board_path.name board_info = board_mapping[board_id] for alias in [board_id] + board_info["aliases"]: diff --git a/tools/build_memory_info.py b/tools/build_memory_info.py index 09d2e72a64..ff5bbfad71 100755 --- a/tools/build_memory_info.py +++ b/tools/build_memory_info.py @@ -38,8 +38,7 @@ with open(sys.argv[1], "r") as f: if line.startswith(("FLASH_FIRMWARE", "RAM")): regions[line.split()[0]] = line.split("=")[-1] -for region in regions: - space = regions[region] +for region, space in regions.items(): if "/*" in space: space = space.split("/*")[0] space = K_PATTERN.sub(K_REPLACE, space) diff --git a/tools/chart_code_size.py b/tools/chart_code_size.py index cefe3b8094..cd62074fd0 100644 --- a/tools/chart_code_size.py +++ b/tools/chart_code_size.py @@ -24,7 +24,7 @@ SPECIAL_NODE_COLORS = {"main": "pink", "exception_table": "green"} @click.command() @click.argument("elf_filename") -def do_all_the_things(elf_filename): +def do_all_the_things(elf_filename): # noqa: C901: too complex symbol = None last_address = 0 all_symbols = {} @@ -124,7 +124,7 @@ def do_all_the_things(elf_filename): if not symbol_stack[-1]["subtype"]: symbol_stack[-1]["subtype"] = symbol elif symbol_stack[-1]["subtype"]["type"] == symbol["type"]: - second_subtype = True + pass else: raise RuntimeError() elif tag == "DW_AT_upper_bound": @@ -164,7 +164,6 @@ def do_all_the_things(elf_filename): # print(line) pass - MEMORY_NONE = 0 MEMORY_POINTER = 1 MEMORY_PY_OBJECT = 2 @@ -214,15 +213,14 @@ def do_all_the_things(elf_filename): return {} # Do a second pass to dereference the types - for symbol_address in symbols_by_memory_address: - symbol = symbols_by_memory_address[symbol_address] + for symbol_address, symbol in symbols_by_memory_address.items(): if "type" in symbol: if symbol["debug_type"] == "DW_TAG_variable": symbol["pointer_map"] = get_pointer_map(symbols_by_debug_address[symbol["type"]]) type_string = [] t = symbol["type"] offset = [] - while t != None: + while t is not None: t_symbol = symbols_by_debug_address[t] t = t_symbol.get("type", None) if "name" in t_symbol: @@ -252,7 +250,6 @@ def do_all_the_things(elf_filename): text_dump_lines = text_dump.stdout.decode("utf-8").split("\n") section = None symbol = None - symbol_type = None for line in text_dump_lines[4:]: if line.startswith("Disassembly of section"): section = line.split()[-1].strip(":") @@ -267,7 +264,6 @@ def do_all_the_things(elf_filename): symbol_address = parse_hex(symbol_address) symbol_name = symbol_name.strip("<>:") if symbol_name in symbols_by_linkage_name: - linked_name = symbol_name symbol = symbols_by_linkage_name[symbol_name] if "name" in symbol: non_linkage = symbol["name"] @@ -303,10 +299,8 @@ def do_all_the_things(elf_filename): if symbol["debug_type"] == "DW_TAG_subprogram": symbol["outgoing_jumps"] = set() symbol["incoming_jumps"] = set() - symbol_type = None elif symbol["debug_type"] == "DW_TAG_variable": symbol["outgoing_pointers"] = set() - symbol_type = symbols_by_debug_address[symbol["type"]] all_symbols[symbol_name] = symbol elif line[0] == " ": @@ -360,8 +354,7 @@ def do_all_the_things(elf_filename): print("converting outgoing pointers to names") # Convert outgoing pointers to names from addresses - for symbol_name in all_symbols: - symbol = all_symbols[symbol_name] + for symbol_name, symbol in all_symbols.items(): if "outgoing_pointers" not in symbol: continue converted = set() @@ -378,8 +371,7 @@ def do_all_the_things(elf_filename): print("linking back") # Link back - for symbol_name in all_symbols: - symbol = all_symbols[symbol_name] + for symbol_name, symbol in all_symbols.items(): if "outgoing_jumps" in symbol: for outgoing in symbol["outgoing_jumps"]: if outgoing not in all_symbols: diff --git a/tools/ci_check_duplicate_usb_vid_pid.py b/tools/ci_check_duplicate_usb_vid_pid.py index 76bb7afea4..65b33a127e 100644 --- a/tools/ci_check_duplicate_usb_vid_pid.py +++ b/tools/ci_check_duplicate_usb_vid_pid.py @@ -138,9 +138,9 @@ def check_vid_pid(files, clusterlist): cluster = set(clusterlist.get(key, [])) if cluster != boards: if key == "": - duplicates.append(f"- Non-USB:\n" f" Boards: {', '.join(sorted(boards))}") + duplicates.append(f"- Non-USB:\n Boards: {', '.join(sorted(boards))}") else: - duplicates.append(f"- VID/PID: {key}\n" f" Boards: {', '.join(sorted(boards))}") + duplicates.append(f"- VID/PID: {key}\n Boards: {', '.join(sorted(boards))}") if duplicates: duplicates = "\n".join(duplicates) diff --git a/tools/ci_fetch_deps.py b/tools/ci_fetch_deps.py index 0cb02eaf3e..be190ad660 100644 --- a/tools/ci_fetch_deps.py +++ b/tools/ci_fetch_deps.py @@ -35,14 +35,6 @@ def _all_submodules(): all_submodules = _all_submodules() -def matching_submodules(s): - if s.endswith("/"): - return [m for m in all_submodules if m.startswith(s)] - elif s not in all_submodules: - raise ValueError(f"{s!r} is not a submodule") - return [s] - - # Submodules needed by port builds outside of their ports directory. # Should we try and detect these? PORT_DEPS = { diff --git a/tools/circuitpy_header_change.py b/tools/circuitpy_header_change.py index 8d55348749..aa931f6560 100755 --- a/tools/circuitpy_header_change.py +++ b/tools/circuitpy_header_change.py @@ -48,18 +48,16 @@ def find_related_copyrights(filename): def fix_file(filename, change): copyrights = [] mit_license = False - empty_file = False first_line = "" no_existing_header = False with open(filename, "r") as f: lines = f.readlines() if not lines: - empty_file = True no_existing_header = True mit_license = True copyrights.append( - f"// SPDX-FileCopyrightText: Copyright (c) 2024 Adafruit Industries LLC" + "// SPDX-FileCopyrightText: Copyright (c) 2024 Adafruit Industries LLC" ) else: first_line = lines.pop(0) @@ -111,7 +109,7 @@ def fix_file(filename, change): copyrights = find_related_copyrights(filename) if not copyrights: copyrights.append( - f"// SPDX-FileCopyrightText: Copyright (c) 2024 Adafruit Industries LLC" + "// SPDX-FileCopyrightText: Copyright (c) 2024 Adafruit Industries LLC" ) if change: diff --git a/tools/codeformat.py b/tools/codeformat.py index 5f5a5f7409..a648d401ec 100644 --- a/tools/codeformat.py +++ b/tools/codeformat.py @@ -39,7 +39,6 @@ import subprocess # Relative to top-level repo dir. # CIRCUITPY-CHANGE: different directory trees PATHS = [ - # C "main.c", "devices/**/*.[ch]", "extmod/*.[ch]", @@ -52,26 +51,14 @@ PATHS = [ "shared-bindings/**/*.[ch]", "shared-module/**/*.[ch]", "supervisor/**/*.[ch]", - # Python - "extmod/*.py", - "ports/**/*.py", - "py/**/*.py", - "tools/**/*.py", - "tests/circuitpython-*/**/*.py", ] # CIRCUITPY-CHANGE: different exclusions EXCLUSIONS = [ # STM32 build includes generated Python code. "ports/*/build*", - # gitignore in ports/unix ignores *.py, so also do it here. - "ports/unix/**/*.py", - # not real python files - "tests/**/repl_*.py", # don't reindent this third-party code we vendored in "ports/raspberrypi/lwip_src", - # line breaks - "tools/mpy-tool.py", ] @@ -119,12 +106,6 @@ path_rx = re.compile(path_re) TOP = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) UNCRUSTIFY_CFG = os.path.join(TOP, "tools/uncrustify.cfg") -# CIRCUITPY-CHANGE -C_EXTS = ( - ".c", - ".h", -) -PY_EXTS = (".py",) def check_uncrustify_version(): @@ -217,14 +198,8 @@ def main(): # Expand the arguments passed on the command line, subject to the PATHS and EXCLUSIONS files = list_files(args.files) - # Extract files matching a specific language. - def lang_files(exts): - for file in files: - if os.path.splitext(file)[1].lower() in exts: - yield file - def bindings_files(): - for file in lang_files(C_EXTS): + for file in files: if file.startswith("shared-bindings/") or "/bindings/" in file: yield file @@ -248,22 +223,23 @@ def main(): command = ["uncrustify", "-c", UNCRUSTIFY_CFG, "-lC", "--no-backup"] if not args.v: command.append("-q") - batch(command, lang_files(C_EXTS)) - for file in lang_files(C_EXTS): + batch(command, iter(files)) + for file in files: fixup_c(file) - # Format bindings with black_bindings + # Format bindings with ruff_bindings if format_py: - command = ["python3", "tools/black_bindings.py"] + command = ["python3", "tools/ruff_bindings.py"] batch(command, bindings_files(), check=True) # Format Python files with black. if format_py: - command = ["black", "--fast", "--line-length=99"] + command = ["ruff", "format"] if args.v: command.append("-v") else: command.append("-q") - batch(command, lang_files(PY_EXTS)) + command.append(".") + subprocess.check_call(command, cwd=TOP) if __name__ == "__main__": diff --git a/tools/cortex-m-fault-gdb.py b/tools/cortex-m-fault-gdb.py index 8de754ed26..dd8838c44f 100644 --- a/tools/cortex-m-fault-gdb.py +++ b/tools/cortex-m-fault-gdb.py @@ -1,5 +1,7 @@ """Source this file into gdb `source ../../tools/cortex-m-fault-gdb.py` then run - `cortex-m-fault` to print basic info about the fault registers.""" +`cortex-m-fault` to print basic info about the fault registers.""" + +import gdb SCS = 0xE000E000 SCB = SCS + 0x0D00 @@ -180,7 +182,7 @@ class CortexMFault(gdb.Command): architecture = (cpuid >> 16) & 0xF revision = cpuid & 0xF part_no = (cpuid >> 4) & 0xFFF - print(PARTS[part_no]) + print(PARTS[part_no], variant, revision) if part_no == 0xD21: self._armv8m_fault() diff --git a/tools/cpboard.py b/tools/cpboard.py index 12d7d374a3..d72d14a240 100644 --- a/tools/cpboard.py +++ b/tools/cpboard.py @@ -343,7 +343,6 @@ class CPboard: dev = usb.core.find(**kwargs) if not dev: - s = "Can't find USB device: " args = [] for x in kwargs.items(): try: diff --git a/tools/diff_nm_sizes.py b/tools/diff_nm_sizes.py index 241355ea18..fdfcdaad49 100644 --- a/tools/diff_nm_sizes.py +++ b/tools/diff_nm_sizes.py @@ -44,8 +44,7 @@ for line in new.read_text().split("\n"): continue print(f"{name:<{longest_symbol}}{size - old_size:>+6}") -for name in old_symbols: - old_size = old_symbols[name] +for name, old_size in old_symbols.items(): print(f"{name:<{longest_symbol}}{-old_size:>+6}") print() diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index e6bc703c02..e340712d18 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -62,7 +62,7 @@ def is_typed(node, allow_any=False): return False elif ( isinstance(node, ast.Attribute) - and type(node.value) == ast.Name + and type(node.value) is ast.Name and node.value.id == "typing" and node.attr == "Any" ): diff --git a/tools/fixup_translations.py b/tools/fixup_translations.py index 4c6f89b26f..21a5812da9 100644 --- a/tools/fixup_translations.py +++ b/tools/fixup_translations.py @@ -84,8 +84,7 @@ for po_filename in po_filenames: first_translations.save(po_filename) print() -for commit in bad_commits: - files = bad_commits[commit] +for commit, files in bad_commits.items(): print(commit) for file in files: print("\t", file) diff --git a/tools/gdb-stack-size.py b/tools/gdb-stack-size.py index 4d3fc9fe08..6426cf4295 100644 --- a/tools/gdb-stack-size.py +++ b/tools/gdb-stack-size.py @@ -1,5 +1,7 @@ """Source this file into gdb `source ../../tools/gdb-stack-size.py` then run - `stack-size` to print a backtrace with each frame size next to it.""" +`stack-size` to print a backtrace with each frame size next to it.""" + +import gdb class StackSize(gdb.Command): diff --git a/tools/gen_display_resources.py b/tools/gen_display_resources.py index dbf3f9a994..2219b4e86d 100644 --- a/tools/gen_display_resources.py +++ b/tools/gen_display_resources.py @@ -234,9 +234,7 @@ displayio_tilegrid_t supervisor_blinka_sprite = {{ .in_group = true }}; #endif -""".format( - blinka_size - ) +""".format(blinka_size) ) c_file.write( @@ -285,9 +283,7 @@ displayio_tilegrid_t supervisor_terminal_scroll_area_text_grid = {{ .inline_tiles = false, .in_group = true }}; -""".format( - len(all_characters), tile_x, tile_y - ) +""".format(len(all_characters), tile_x, tile_y) ) c_file.write( @@ -315,17 +311,13 @@ displayio_tilegrid_t supervisor_terminal_status_bar_text_grid = {{ .inline_tiles = false, .in_group = true }}; -""".format( - len(all_characters), tile_x, tile_y - ) +""".format(len(all_characters), tile_x, tile_y) ) c_file.write( """\ const uint32_t font_bitmap_data[{}] = {{ -""".format( - bytes_per_row * tile_y // 4 - ) +""".format(bytes_per_row * tile_y // 4) ) for i, word in enumerate(struct.iter_unpack("\n\n") +c_file.write("// Autogenerated by tools/gen_web_workflow_static.py\n") +c_file.write("#include \n\n") for f in args.files: path = pathlib.Path(f.name) diff --git a/tools/msgfmt.py b/tools/msgfmt.py index 1ed594b84f..428a0fbc5c 100644 --- a/tools/msgfmt.py +++ b/tools/msgfmt.py @@ -1,5 +1,8 @@ #! /usr/bin/env python3 -# Written by Martin v. Löwis + +# From: https://github.com/python/cpython/blob/main/Tools/i18n/msgfmt.py +# SPDX-License-Identifier: PSF-2.0 +# SPDX-FileCopyrightText: Written by Martin v. Löwis """Generate binary message catalog from textual translation description. This program converts a textual Uniforum-style message catalog (.po file) into diff --git a/tools/pyboard.py b/tools/pyboard.py index 87b3851ead..0921d5feae 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -509,7 +509,7 @@ class Pyboard: def repr_consumer(b): buf.extend(b.replace(b"\x04", b"")) - cmd = "import os\nfor f in os.ilistdir(%s):\n" " print(repr(f), end=',')" % ( + cmd = "import os\nfor f in os.ilistdir(%s):\n print(repr(f), end=',')" % ( ("'%s'" % src) if src else "" ) try: diff --git a/tools/pydfu.py b/tools/pydfu.py index e1e4074a6b..cd7354818c 100755 --- a/tools/pydfu.py +++ b/tools/pydfu.py @@ -344,8 +344,7 @@ def read_dfu_file(filename): # B uint8_t targets Number of targets dfu_prefix, data = consume("<5sBIB", data, "signature version size targets") print( - " %(signature)s v%(version)d, image size: %(size)d, " - "targets: %(targets)d" % dfu_prefix + " %(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d" % dfu_prefix ) for target_idx in range(dfu_prefix["targets"]): # Decode the Image Prefix @@ -359,7 +358,7 @@ def read_dfu_file(filename): # I uint32_t size Size of image (without prefix) # I uint32_t elements Number of elements in the image img_prefix, data = consume( - "<6sBI255s2I", data, "signature altsetting named name " "size elements" + "<6sBI255s2I", data, "signature altsetting named name size elements" ) img_prefix["num"] = target_idx if img_prefix["named"]: diff --git a/tools/black_bindings.py b/tools/ruff_bindings.py similarity index 95% rename from tools/black_bindings.py rename to tools/ruff_bindings.py index 1c6fa3cfe8..a8367ea0df 100755 --- a/tools/black_bindings.py +++ b/tools/ruff_bindings.py @@ -88,7 +88,7 @@ def process_one_file(fn): with open(fn, "r", encoding="utf-8") as f: c_content = f.read() - if not "\n//| " in c_content: + if "\n//| " not in c_content: return py_content = swap_comment_markers(c_content, Mode.C) @@ -96,13 +96,13 @@ def process_one_file(fn): try: # Line length is 95 so that with "//| " the max is 99 result = subprocess.run( - ["black", "--pyi", "-l95", "-q", "-"], + ["ruff", "format", "--line-length", "95", "-q", "-"], input=py_content, check=True, stdout=subprocess.PIPE, encoding="utf-8", ) - except subprocess.CalledProcessError as e: + except subprocess.CalledProcessError: print(f"{fn}:0: Failed to process file ") raise diff --git a/tools/stack-loc-to-pc.py b/tools/stack-loc-to-pc.py index a1ce788f2b..d4287f3a5d 100644 --- a/tools/stack-loc-to-pc.py +++ b/tools/stack-loc-to-pc.py @@ -1,10 +1,10 @@ """Prints the pcs that access each stack location in a function. Useful for finding - infrequently used stack space. +infrequently used stack space. - Pipe in disassembly like so: +Pipe in disassembly like so: - arm-none-eabi-objdump --disassemble=mp_execute_bytecode build-metro_m0_express/firmware.elf | python ../../tools/stack-loc-to-pc.py - """ +arm-none-eabi-objdump --disassemble=mp_execute_bytecode build-metro_m0_express/firmware.elf | python ../../tools/stack-loc-to-pc.py +""" import sys import re