From c951d8eeaa55dca3d0d1f13195b8483fd24bd8a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 22:00:13 +0100 Subject: [PATCH 1/8] Initial plan From 98c9e4f8017c38957fe2f9b6ca5843a3be85fcfe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 22:00:14 +0100 Subject: [PATCH 2/8] Improve test_stub_quality CI with normalized pass_rate scoring and stable-only gating Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com> --- .github/workflows/compare_score.py | 77 ++++++++++++++++++++----- .github/workflows/test_stub_quality.yml | 55 +++++++++++++++++- tests/quality_tests/conftest.py | 16 ++++- tests/quality_tests/test_snippets.py | 8 ++- 4 files changed, 136 insertions(+), 20 deletions(-) diff --git a/.github/workflows/compare_score.py b/.github/workflows/compare_score.py index ca658251d0..108014320e 100644 --- a/.github/workflows/compare_score.py +++ b/.github/workflows/compare_score.py @@ -11,6 +11,12 @@ except: pass +# Thresholds for pass_rate comparison +PASS_RATE_TOLERANCE = 0.05 # allow up to 5% drop in pass_rate before failing +# 50%: enough to detect mass-skip scenarios (e.g. all stubs unavailable) while allowing +# natural variation as the stable version set changes over time +MIN_EXECUTED_FRACTION = 0.50 # require at least 50% of baseline executed count + # has been propagated from repo vars to env vars try: current_scores = json.loads(os.getenv("SNIPPET_SCORE", '{"snippet_score": 0}')) @@ -57,21 +63,66 @@ def update_var(var_name: str, value: str): response.raise_for_status() -if new_scores["snippet_score"] < current_scores["snippet_score"]: - msg = f"The snippet_score has decreased from {current_scores['snippet_score']} to {new_scores['snippet_score']}" - print(msg) - add_summary(msg, current_scores, new_scores) - exit(1) # Fail the test -elif new_scores["snippet_score"] == current_scores["snippet_score"]: - msg = f"The snippet_score has not changed from {current_scores['snippet_score']}" - print(msg) - add_summary(msg, current_scores, new_scores) -elif new_scores["snippet_score"] > current_scores["snippet_score"]: - msg = f"The snippet_score has improved to {new_scores['snippet_score']}" +# Compute new metrics - use pass_rate/executed when available, fall back to snippet_score +new_executed = new_scores.get("executed", new_scores.get("passed", 0) + new_scores.get("failed", 0)) +current_executed = current_scores.get("executed", 0) +new_pass_rate = new_scores.get("pass_rate", None) +current_pass_rate = current_scores.get("pass_rate", None) + +# Check minimum executed threshold (50% of baseline) - only when baseline has data +if current_executed > 0 and new_executed < current_executed * MIN_EXECUTED_FRACTION: + msg = ( + f"Too few tests executed: {new_executed} is less than " + f"{MIN_EXECUTED_FRACTION:.0%} of baseline ({current_executed}). " + f"Possible mass-skip or environment issue." + ) print(msg) add_summary(msg, current_scores, new_scores) - if os.getenv("GITHUB_REF_NAME", "main") == "main": - update_var(var_name="SNIPPET_SCORE", value=json.dumps(new_scores, skipkeys=True, indent=4)) + exit(1) + +# Compare using pass_rate when both baseline and current have it +if new_pass_rate is not None and current_pass_rate is not None: + rate_delta = new_pass_rate - current_pass_rate + if new_pass_rate < current_pass_rate - PASS_RATE_TOLERANCE: + msg = ( + f"pass_rate dropped by more than {PASS_RATE_TOLERANCE:.0%}: " + f"{current_pass_rate:.2%} -> {new_pass_rate:.2%} " + f"(executed: {new_executed})" + ) + print(msg) + add_summary(msg, current_scores, new_scores) + exit(1) + elif rate_delta >= 0: + msg = f"pass_rate improved or unchanged: {current_pass_rate:.2%} -> {new_pass_rate:.2%} (executed: {new_executed})" + print(msg) + add_summary(msg, current_scores, new_scores) + if os.getenv("GITHUB_REF_NAME", "main") == "main": + update_var(var_name="SNIPPET_SCORE", value=json.dumps(new_scores, skipkeys=True, indent=4)) + else: + msg = ( + f"pass_rate decreased within tolerance: " + f"{current_pass_rate:.2%} -> {new_pass_rate:.2%} " + f"(delta: {rate_delta:.2%}, executed: {new_executed})" + ) + print(msg) + add_summary(msg, current_scores, new_scores) +else: + # Fall back to legacy snippet_score comparison + if new_scores["snippet_score"] < current_scores["snippet_score"]: + msg = f"The snippet_score has decreased from {current_scores['snippet_score']} to {new_scores['snippet_score']}" + print(msg) + add_summary(msg, current_scores, new_scores) + exit(1) + elif new_scores["snippet_score"] == current_scores["snippet_score"]: + msg = f"The snippet_score has not changed from {current_scores['snippet_score']}" + print(msg) + add_summary(msg, current_scores, new_scores) + elif new_scores["snippet_score"] > current_scores["snippet_score"]: + msg = f"The snippet_score has improved to {new_scores['snippet_score']}" + print(msg) + add_summary(msg, current_scores, new_scores) + if os.getenv("GITHUB_REF_NAME", "main") == "main": + update_var(var_name="SNIPPET_SCORE", value=json.dumps(new_scores, skipkeys=True, indent=4)) print("Done") exit(0) diff --git a/.github/workflows/test_stub_quality.yml b/.github/workflows/test_stub_quality.yml index 044fa3c2e8..5ce04b0a83 100644 --- a/.github/workflows/test_stub_quality.yml +++ b/.github/workflows/test_stub_quality.yml @@ -12,6 +12,8 @@ env: jobs: test_snippets: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v4 #---------------------------------------------- @@ -53,12 +55,61 @@ jobs: # source .venv/bin/activate # pwsh -file ./update-stubs.ps1 - - name: Test the snippets + - name: Test the snippets (stable only) continue-on-error: true run: | - uv run pytest -m 'snippets' --cache-clear --junitxml=./results/results.xml + uv run pytest -m 'snippets' --stable-only --cache-clear --junitxml=./results/results.xml - name: compare and update run: | uv run .github/workflows/compare_score.py + + - name: Upload results artifact + uses: actions/upload-artifact@v4 + if: always() + with: + name: snippet-results-stable-${{ github.run_id }} + path: results/ + + test_snippets_preview: + runs-on: ubuntu-latest + continue-on-error: true + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v6 + + - name: Install poetry + run: uv tool install poetry + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install Python dependencies + working-directory: ${{github.workspace}} + run: | + uv venv + uv pip install -U -r pyproject.toml --extra stubber --extra test + + - name: stubber clone + run: | + uv run stubber clone + + - name: Test the snippets (preview versions, non-blocking) + continue-on-error: true + run: | + uv run pytest -m 'snippets' --cache-clear --junitxml=./results/results_preview.xml + + - name: Upload preview results artifact + uses: actions/upload-artifact@v4 + if: always() + with: + name: snippet-results-preview-${{ github.run_id }} + path: results/ + diff --git a/tests/quality_tests/conftest.py b/tests/quality_tests/conftest.py index 21fed16975..896367733a 100644 --- a/tests/quality_tests/conftest.py +++ b/tests/quality_tests/conftest.py @@ -33,6 +33,15 @@ MAX_CACHE_AGE = 24 * 60 * 60 # 24 hours +def pytest_addoption(parser: pytest.Parser): + parser.addoption( + "--stable-only", + action="store_true", + default=False, + help="Only run tests for the current stable MicroPython release, skipping preview versions.", + ) + + def flat_version(version): """Converts a version string to a flat version string. (simplified)""" return version.replace(".", "_").replace("-", "_") @@ -252,9 +261,12 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config: pytest.Config) stats = {} for status in ["passed", "failed", "xfailed", "skipped"]: stats[status] = snipcount(terminalreporter, status) - # simple straigth forward scoring + executed = stats["passed"] + stats["failed"] + stats["executed"] = executed + stats["pass_rate"] = round(stats["passed"] / executed, 4) if executed > 0 else 0.0 + # keep for backward compatibility stats["snippet_score"] = int(stats["passed"] - stats["failed"]) - if stats["snippet_score"] > 0: + if executed > 0: # Write stats to file (config.rootpath / "results").mkdir(exist_ok=True) with open(config.rootpath / "results" / "snippet_score.json", "w") as f: diff --git a/tests/quality_tests/test_snippets.py b/tests/quality_tests/test_snippets.py index b17d38d707..4944c147cc 100644 --- a/tests/quality_tests/test_snippets.py +++ b/tests/quality_tests/test_snippets.py @@ -96,21 +96,23 @@ def major_minor(versions): sys.path.append(str(HERE.parent.parent / ".github/workflows")) # only the recent versions -VERSIONS = sorted(major_minor(micropython_versions(minver="v1.24.0")), reverse=True)[:3] +ALL_VERSIONS = sorted(major_minor(micropython_versions(minver="v1.24.0")), reverse=True)[:3] def pytest_generate_tests(metafunc: pytest.Metafunc): """ Generates a test parameterization for each portboard, version and feature defined in: - SOURCES - - VERSIONS + - VERSIONS (filtered by --stable-only if requested) - PORTBOARD_FEATURES """ + stable_only = metafunc.config.getoption("--stable-only", default=False) + versions = [v for v in ALL_VERSIONS if not v.endswith("-preview")] if stable_only else ALL_VERSIONS argnames = "stub_source, version, portboard, feature" args_lst = [] copy_config_files() for src in SOURCES: - for version in VERSIONS: + for version in versions: # skip latest for pypi if src == "pypi" and version in {"preview", "latest"}: continue From 63ec8a284e32414ab43c073abe4072bf1f6e7aaa Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Tue, 24 Feb 2026 22:16:57 +0100 Subject: [PATCH 3/8] Refactor test version handling to support dynamic version selection based on --stable-only flag Signed-off-by: Jos Verlinde --- tests/quality_tests/conftest.py | 35 +++++++++++++++++++++++++++- tests/quality_tests/test_mypy.py | 24 +++++++++++-------- tests/quality_tests/test_ruff.py | 24 +++++++++++-------- tests/quality_tests/test_snippets.py | 23 ++---------------- 4 files changed, 64 insertions(+), 42 deletions(-) diff --git a/tests/quality_tests/conftest.py b/tests/quality_tests/conftest.py index 896367733a..03e08cf05f 100644 --- a/tests/quality_tests/conftest.py +++ b/tests/quality_tests/conftest.py @@ -27,7 +27,8 @@ import fasteners import pytest from loguru import logger as log -from mpflash.versions import get_preview_mp_version, get_stable_mp_version +from mpflash.versions import get_preview_mp_version, get_stable_mp_version, micropython_versions +from packaging.version import Version SNIPPETS_PREFIX = "tests/quality_tests/" MAX_CACHE_AGE = 24 * 60 * 60 # 24 hours @@ -42,6 +43,38 @@ def pytest_addoption(parser: pytest.Parser): ) +def major_minor(versions): + """Create a list of the most recent version for each major.minor.""" + mm_groups = {} + for v in versions: + if v.endswith("-preview"): + mm_groups["preview"] = [v] + continue + major_minor = f"{Version(v).major}.{Version(v).minor}" + if major_minor not in mm_groups or "-preview" in v: + mm_groups[major_minor] = [v] + else: + mm_groups[major_minor].append(v) + return [max(v) for v in mm_groups.values()] + + +def get_test_versions(config: pytest.Config) -> list[str]: + """Get the list of MicroPython versions to test based on --stable-only flag. + + Args: + config: The pytest Config object. + + Returns: + List of version strings to test (e.g., ['v1.27.0'] or ['v1.27.0', 'v1.26.0', 'v1.25.0']). + """ + stable_only = config.getoption("--stable-only", default=False) + if stable_only: + return [get_stable_mp_version()] + else: + # Only the recent versions (last 3 major.minor releases) + return sorted(major_minor(micropython_versions(minver="v1.24.0")), reverse=True)[:3] + + def flat_version(version): """Converts a version string to a flat version string. (simplified)""" return version.replace(".", "_").replace("-", "_") diff --git a/tests/quality_tests/test_mypy.py b/tests/quality_tests/test_mypy.py index 92e15fba5d..0c5be8786f 100644 --- a/tests/quality_tests/test_mypy.py +++ b/tests/quality_tests/test_mypy.py @@ -2,6 +2,7 @@ from pathlib import Path import pytest +from conftest import get_test_versions from test_snippets import SOURCES, run_typechecker # only snippets tests @@ -11,16 +12,19 @@ HERE = Path(__file__).parent.absolute() -# running test for all issues , so need to test with boards that have as much functionality as possible -@pytest.mark.parametrize("portboard", ["esp32","rp2-rpi_pico_w"], scope="session") -@pytest.mark.parametrize("version", ["v1.24.1", "v1.25.0", "v1.26.0"], scope="session") -@pytest.mark.parametrize("feature", ["stdlib"], scope="session") -@pytest.mark.parametrize("stub_source", SOURCES, scope="session") -@pytest.mark.parametrize("snip_path", [HERE / "feat_mypy"], scope="session") -@pytest.mark.parametrize( - "linter", - ["mypy"], -) + +def pytest_generate_tests(metafunc: pytest.Metafunc): + """Generate test parameters dynamically, respecting --stable-only flag.""" + if "test_mypy" in metafunc.function.__name__: + versions = get_test_versions(metafunc.config) + metafunc.parametrize("portboard", ["esp32", "rp2-rpi_pico_w"], scope="session") + metafunc.parametrize("version", versions, scope="session") + metafunc.parametrize("feature", ["stdlib"], scope="session") + metafunc.parametrize("stub_source", SOURCES, scope="session") + metafunc.parametrize("snip_path", [HERE / "feat_mypy"], scope="session") + metafunc.parametrize("linter", ["mypy"]) + + def test_mypy( stub_source: str, portboard: str, diff --git a/tests/quality_tests/test_ruff.py b/tests/quality_tests/test_ruff.py index f10f4a27db..1d86e296c4 100644 --- a/tests/quality_tests/test_ruff.py +++ b/tests/quality_tests/test_ruff.py @@ -2,6 +2,7 @@ from pathlib import Path import pytest +from conftest import get_test_versions from test_snippets import SOURCES, run_typechecker # only snippets tests @@ -11,16 +12,19 @@ HERE = Path(__file__).parent.absolute() -# running test for all issues , so need to test with boards that have as much functionality as possible -@pytest.mark.parametrize("portboard", ["esp32","rp2-rpi_pico_w"], scope="session") -@pytest.mark.parametrize("version", ["v1.24.1", "v1.25.0", "v1.26.0"], scope="session") -@pytest.mark.parametrize("feature", ["stdlib"], scope="session") -@pytest.mark.parametrize("stub_source", SOURCES, scope="session") -@pytest.mark.parametrize("snip_path", [HERE / "feat_ruff"], scope="session") -@pytest.mark.parametrize( - "linter", - ["ruff"], -) + +def pytest_generate_tests(metafunc: pytest.Metafunc): + """Generate test parameters dynamically, respecting --stable-only flag.""" + if "test_ruff" in metafunc.function.__name__: + versions = get_test_versions(metafunc.config) + metafunc.parametrize("portboard", ["esp32", "rp2-rpi_pico_w"], scope="session") + metafunc.parametrize("version", versions, scope="session") + metafunc.parametrize("feature", ["stdlib"], scope="session") + metafunc.parametrize("stub_source", SOURCES, scope="session") + metafunc.parametrize("snip_path", [HERE / "feat_ruff"], scope="session") + metafunc.parametrize("linter", ["ruff"]) + + def test_ruff( stub_source: str, portboard: str, diff --git a/tests/quality_tests/test_snippets.py b/tests/quality_tests/test_snippets.py index 4944c147cc..25eced5028 100644 --- a/tests/quality_tests/test_snippets.py +++ b/tests/quality_tests/test_snippets.py @@ -9,26 +9,11 @@ import fasteners import pytest -from mpflash.versions import micropython_versions +from conftest import get_test_versions from packaging.version import Version from typecheck import copy_config_files, port_and_board, run_typechecker -def major_minor(versions): - """create a list of the most recent version for each major.minor""" - mm_groups = {} - for v in versions: - if v.endswith("-preview"): - mm_groups["preview"] = [v] - continue - major_minor = f"{Version(v).major}.{Version(v).minor}" - if major_minor not in mm_groups or "-preview" in v: - mm_groups[major_minor] = [v] - else: - mm_groups[major_minor].append(v) - return [max(v) for v in mm_groups.values()] - - # only snippets tests pytestmark = [pytest.mark.snippets] @@ -95,9 +80,6 @@ def major_minor(versions): HERE = (Path(__file__).parent).resolve() sys.path.append(str(HERE.parent.parent / ".github/workflows")) -# only the recent versions -ALL_VERSIONS = sorted(major_minor(micropython_versions(minver="v1.24.0")), reverse=True)[:3] - def pytest_generate_tests(metafunc: pytest.Metafunc): """ @@ -106,8 +88,7 @@ def pytest_generate_tests(metafunc: pytest.Metafunc): - VERSIONS (filtered by --stable-only if requested) - PORTBOARD_FEATURES """ - stable_only = metafunc.config.getoption("--stable-only", default=False) - versions = [v for v in ALL_VERSIONS if not v.endswith("-preview")] if stable_only else ALL_VERSIONS + versions = get_test_versions(metafunc.config) argnames = "stub_source, version, portboard, feature" args_lst = [] copy_config_files() From 0d89a4c05a59f9ab801d2569334408475485ab0c Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Tue, 24 Feb 2026 22:48:53 +0100 Subject: [PATCH 4/8] Implement multi-version support for snippet score tracking and comparison in CI workflow Signed-off-by: Jos Verlinde --- .github/workflows/SNIPPET_SCORE_STRUCTURE.md | 229 ++++++++++++++++ .github/workflows/compare_score_v2.py | 268 +++++++++++++++++++ .github/workflows/test_stub_quality.yml | 86 +++++- tests/quality_tests/conftest.py | 51 +++- 4 files changed, 625 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/SNIPPET_SCORE_STRUCTURE.md create mode 100644 .github/workflows/compare_score_v2.py diff --git a/.github/workflows/SNIPPET_SCORE_STRUCTURE.md b/.github/workflows/SNIPPET_SCORE_STRUCTURE.md new file mode 100644 index 0000000000..1e15738ad4 --- /dev/null +++ b/.github/workflows/SNIPPET_SCORE_STRUCTURE.md @@ -0,0 +1,229 @@ +# Multi-Version Snippet Score Tracking + +## Overview + +The snippet quality testing framework now supports tracking scores across multiple MicroPython versions with historical trend data. + +## SNIPPET_SCORE Structure + +The `SNIPPET_SCORE` GitHub repository variable now uses a structured format: + +```json +{ + "stable": { + "v1.27.0": { + "pass_rate": 0.95, + "executed": 100, + "passed": 95, + "failed": 5, + "timestamp": "2026-02-24T12:34:56Z", + "commit": "abc123", + "snippet_score": 90 + } + }, + "preview": { + "pass_rate": 0.92, + "executed": 100, + "passed": 92, + "failed": 8, + "timestamp": "2026-02-24T12:34:56Z", + "version": "v1.28.0-preview", + "commit": "abc123", + "snippet_score": 84 + }, + "recent_majors": { + "pass_rate": 0.93, + "executed": 300, + "passed": 279, + "failed": 21, + "timestamp": "2026-02-24T12:34:56Z", + "versions": ["v1.27.0", "v1.26.1", "v1.25.0"], + "commit": "abc123", + "snippet_score": 258 + }, + "history": { + "v1.27.0": [ + { + "pass_rate": 0.95, + "executed": 100, + "passed": 95, + "failed": 5, + "timestamp": "2026-02-24T12:34:56Z", + "commit": "abc123" + }, + // ... up to 10 most recent records + ], + "preview": [ + // ... historical preview results + ], + "recent_majors": [ + // ... historical recent_majors results + ] + } +} +``` + +## Version Types + +### 1. Stable (`--stable-only`) +- **Purpose**: Gate for PR merges +- **Versions Tested**: Current stable release only (e.g., v1.27.0) +- **Behavior**: **FAILS workflow** on quality drop +- **Storage**: Stored under `stable[version_number]` +- **Usage**: Quality gate that must pass + +### 2. Preview (`--preview-only`) +- **Purpose**: Early warning for preview releases +- **Versions Tested**: Most recent preview (e.g., v1.28.0-preview) +- **Behavior**: Non-blocking, logs warnings +- **Storage**: Stored under `preview` (latest only) +- **Usage**: Monitor upcoming release quality + +### 3. Recent Majors (`--recent-majors`) +- **Purpose**: Broader compatibility testing +- **Versions Tested**: Last 3 stable major.minor releases (e.g., v1.27.0, v1.26.1, v1.25.0) +- **Behavior**: Non-blocking, logs warnings +- **Storage**: Stored under `recent_majors` (aggregated) +- **Usage**: Detect regressions across supported versions + +## Historical Tracking + +Each version type maintains up to 10 historical records under the `history` key: +- Stable: Per-version history (e.g., `history["v1.27.0"]`) +- Preview: Aggregated preview history (`history["preview"]`) +- Recent Majors: Aggregated history (`history["recent_majors"]`) + +Each history entry includes: +- `pass_rate`: Percentage of tests passed +- `executed`: Number of tests run +- `passed`: Number of passed tests +- `failed`: Number of failed tests +- `timestamp`: ISO 8601 timestamp +- `commit`: Short commit SHA (7 chars) + +## Workflow Integration + +### Environment Variables + +The workflow sets these environment variables for each job: + +**Stable Job:** +```yaml +VERSION_TYPE: stable +TEST_VERSION: v1.27.0 # Dynamically determined +``` + +**Preview Job:** +```yaml +VERSION_TYPE: preview +TEST_VERSION: v1.28.0-preview # Dynamically determined +``` + +**Recent Majors Job:** +```yaml +VERSION_TYPE: recent_majors +# TEST_VERSION not set (tests multiple versions) +``` + +### Comparison Logic + +The `compare_score_v2.py` script: + +1. Loads baseline from `$SNIPPET_SCORE` environment variable +2. Loads new results from `results/snippet_score.json` +3. Compares based on version type: + - **Stable**: Compares against `stable[version]` baseline + - **Preview**: Compares against `preview` baseline + - **Recent Majors**: Compares against `recent_majors` baseline +4. Updates baseline and history if: + - Pass rate improves or stays within tolerance + - No mass-skip detected (>50% of baseline executed) + - Running on `main` branch +5. Returns exit code: + - `0`: Success or acceptable drop + - `1`: Unacceptable quality drop (only for stable with `fail_on_drop=True`) + +### Thresholds + +```python +PASS_RATE_TOLERANCE = 0.05 # 5% drop allowed +MIN_EXECUTED_FRACTION = 0.50 # 50% of baseline required +MAX_HISTORY_RECORDS = 10 # Keep last 10 records +``` + +## Usage Examples + +### Running Tests Locally + +```bash +# Test stable version only +pytest -m 'snippets' --stable-only + +# Test preview version only +pytest -m 'snippets' --preview-only + +# Test recent major.minor releases (no preview) +pytest -m 'snippets' --recent-majors + +# Test all (default - last 3 major.minor including preview if present) +pytest -m 'snippets' +``` + +### Manual Score Comparison + +```bash +# Set environment variables +export VERSION_TYPE=stable +export TEST_VERSION=v1.27.0 +export SNIPPET_SCORE='{"stable": {"v1.27.0": {"pass_rate": 0.95, ...}}, ...}' + +# Run comparison +python .github/workflows/compare_score_v2.py +``` + +## Migration from Old Format + +The script automatically migrates old `SNIPPET_SCORE` formats: + +**Old Format:** +```json +{ + "snippet_score": 90, + "pass_rate": 0.95, + "executed": 100, + "passed": 95, + "failed": 5 +} +``` + +**Migrated To:** +```json +{ + "stable": {}, + "preview": {}, + "recent_majors": {}, + "history": {} +} +``` + +First run with new format will establish new baselines. + +## Artifacts + +Each job uploads test results as artifacts: +- `snippet-results-stable-{run_id}` +- `snippet-results-preview-{run_id}` +- `snippet-results-recent-{run_id}` + +These contain: +- `results.xml` / `results_preview.xml` / `results_recent.xml` (JUnit format) +- `snippet_score.json` (detailed metrics) + +## Benefits + +1. **Version-Specific Tracking**: Track quality for each stable version independently +2. **Historical Trends**: Analyze quality trends over time +3. **Flexible Gating**: Only stable tests block PRs +4. **Early Warnings**: Preview and recent_majors provide advance notice +5. **Comprehensive Testing**: Cover multiple version ranges without blocking workflow +6. **Audit Trail**: Full history with timestamps and commits diff --git a/.github/workflows/compare_score_v2.py b/.github/workflows/compare_score_v2.py new file mode 100644 index 0000000000..93f9167662 --- /dev/null +++ b/.github/workflows/compare_score_v2.py @@ -0,0 +1,268 @@ +#!/usr/bin/env python3 +"""Enhanced snippet score comparison with multi-version support and history tracking. + +Structure of SNIPPET_SCORE: +{ + "stable": { + "v1.27.0": { + "pass_rate": 0.95, + "executed": 100, + "passed": 95, + "failed": 5, + "timestamp": "2026-02-24T12:34:56Z", + "commit": "abc123" + } + }, + "preview": { + "pass_rate": 0.92, + "executed": 100, + "passed": 92, + "failed": 8, + "timestamp": "2026-02-24T12:34:56Z", + "version": "v1.28.0-preview" + }, + "recent_majors": { + "pass_rate": 0.93, + "executed": 300, + "passed": 279, + "failed": 21, + "timestamp": "2026-02-24T12:34:56Z", + "versions": ["v1.27.0", "v1.26.1", "v1.25.0"] + }, + "history": { + "v1.27.0": [ + {"pass_rate": 0.95, "executed": 100, "timestamp": "...", "commit": "..."}, + ... # up to last 10 records + ], + "preview": [...], + "recent_majors": [...] + } +} +""" +import json +import os +import sys +from datetime import datetime, timezone +from typing import Optional + +import requests +from dotenv import load_dotenv + +try: + load_dotenv() + load_dotenv(".secrets") +except: + pass + +# Thresholds +PASS_RATE_TOLERANCE = 0.05 # 5% drop tolerance +MIN_EXECUTED_FRACTION = 0.50 # require 50% of baseline executed +MAX_HISTORY_RECORDS = 10 # keep last 10 records per version + + +def get_version_type() -> str: + """Get version type from environment variable.""" + return os.getenv("VERSION_TYPE", "stable") # stable, preview, or recent_majors + + +def get_current_version() -> Optional[str]: + """Get the specific version being tested (for stable).""" + return os.getenv("TEST_VERSION", None) + + +def load_baseline_scores() -> dict: + """Load baseline scores from environment variable.""" + try: + scores = json.loads(os.getenv("SNIPPET_SCORE", "{}")) + if not scores or "stable" not in scores: + # Migrate old format + return { + "stable": {}, + "preview": {}, + "recent_majors": {}, + "history": {} + } + return scores + except json.decoder.JSONDecodeError: + return { + "stable": {}, + "preview": {}, + "recent_majors": {}, + "history": {} + } + + +def load_new_scores() -> dict: + """Load new test results.""" + with open("results/snippet_score.json", "r") as f: + return json.load(f) + + +def add_summary(msg: str, version_type: str, new_scores: dict, baseline: dict): + """Add summary to GitHub Actions step summary.""" + summary_file = os.getenv("GITHUB_STEP_SUMMARY") + if not summary_file: + print("GITHUB_STEP_SUMMARY not available") + return + + with open(summary_file, "a") as f: + f.write(f"# Snippet Test Results ({version_type})\n\n") + f.write(f"{msg}\n\n") + f.write("## New Results\n```json\n") + json.dump(new_scores, f, indent=2) + f.write("\n```\n\n") + f.write("## Baseline\n```json\n") + json.dump(baseline, f, indent=2) + f.write("\n```\n") + + +def update_var(var_name: str, value: str): + """Update GitHub repository variable.""" + repo = os.getenv("GITHUB_REPOSITORY", "Josverl/micropython-stubs") + gh_token_vars = os.getenv("GH_TOKEN_VARS", os.getenv("GH_TOKEN", "-")) + + if gh_token_vars == "-": + print("No token available to update repository variable") + return False + + url = f"https://api.github.com/repos/{repo}/actions/variables/{var_name}" + headers = { + "Authorization": f"token {gh_token_vars}", + "Content-Type": "application/json", + "User-Agent": "josverl", + } + data = {"name": var_name, "value": value} + + try: + response = requests.patch(url, headers=headers, json=data) + response.raise_for_status() + return True + except Exception as e: + print(f"Failed to update variable: {e}") + return False + + +def add_to_history(all_scores: dict, version_type: str, version_key: str, new_scores: dict): + """Add current results to history, keeping last MAX_HISTORY_RECORDS.""" + if "history" not in all_scores: + all_scores["history"] = {} + + if version_key not in all_scores["history"]: + all_scores["history"][version_key] = [] + + history_entry = { + "pass_rate": new_scores.get("pass_rate", 0), + "executed": new_scores.get("executed", 0), + "passed": new_scores.get("passed", 0), + "failed": new_scores.get("failed", 0), + "timestamp": datetime.now(timezone.utc).isoformat(), + "commit": os.getenv("GITHUB_SHA", "unknown")[:7] + } + + all_scores["history"][version_key].append(history_entry) + # Keep only last MAX_HISTORY_RECORDS + all_scores["history"][version_key] = all_scores["history"][version_key][-MAX_HISTORY_RECORDS:] + + +def compare_and_update(version_type: str, fail_on_drop: bool = False) -> int: + """ + Compare new scores with baseline and update if appropriate. + + Args: + version_type: "stable", "preview", or "recent_majors" + fail_on_drop: If True, exit with error code 1 on quality drop + + Returns: + 0 for success, 1 for failure + """ + all_scores = load_baseline_scores() + new_scores = load_new_scores() + + # Add metadata + new_scores["timestamp"] = datetime.now(timezone.utc).isoformat() + new_scores["commit"] = os.getenv("GITHUB_SHA", "unknown")[:7] + + # Determine the key to store under + if version_type == "stable": + version = get_current_version() + if not version: + print("ERROR: TEST_VERSION not set for stable tests") + return 1 + storage_key = version + baseline = all_scores["stable"].get(version, {}) + elif version_type == "preview": + storage_key = "preview" + new_scores["version"] = get_current_version() or "unknown" + baseline = all_scores.get("preview", {}) + elif version_type == "recent_majors": + storage_key = "recent_majors" + # Extract tested versions from new_scores if available + baseline = all_scores.get("recent_majors", {}) + else: + print(f"ERROR: Unknown version_type: {version_type}") + return 1 + + # Extract metrics + new_executed = new_scores.get("executed", 0) + baseline_executed = baseline.get("executed", 0) + new_pass_rate = new_scores.get("pass_rate", 0) + baseline_pass_rate = baseline.get("pass_rate", 0) + + # Check minimum executed threshold + if baseline_executed > 0 and new_executed < baseline_executed * MIN_EXECUTED_FRACTION: + msg = ( + f"⚠️ Too few tests executed: {new_executed} < " + f"{MIN_EXECUTED_FRACTION:.0%} of baseline ({baseline_executed}). " + f"Possible mass-skip or environment issue." + ) + print(msg) + add_summary(msg, version_type, new_scores, baseline) + return 1 if fail_on_drop else 0 + + # Compare pass rates + rate_delta = new_pass_rate - baseline_pass_rate + + if baseline_pass_rate > 0 and new_pass_rate < baseline_pass_rate - PASS_RATE_TOLERANCE: + msg = ( + f"❌ pass_rate dropped by more than {PASS_RATE_TOLERANCE:.0%}: " + f"{baseline_pass_rate:.2%} → {new_pass_rate:.2%} " + f"(Δ {rate_delta:.2%}, executed: {new_executed})" + ) + print(msg) + add_summary(msg, version_type, new_scores, baseline) + return 1 if fail_on_drop else 0 + elif rate_delta >= 0 or baseline_pass_rate == 0: + if baseline_pass_rate == 0: + msg = f"✨ New baseline established: {new_pass_rate:.2%} (executed: {new_executed})" + else: + msg = f"✅ pass_rate: {baseline_pass_rate:.2%} → {new_pass_rate:.2%} (Δ {rate_delta:+.2%}, executed: {new_executed})" + print(msg) + add_summary(msg, version_type, new_scores, baseline) + + # Update scores + all_scores[version_type][storage_key] = new_scores + add_to_history(all_scores, version_type, storage_key, new_scores) + + # Only update on main branch + if os.getenv("GITHUB_REF_NAME", "main") == "main": + update_var("SNIPPET_SCORE", json.dumps(all_scores, indent=2)) + + return 0 + else: + msg = ( + f"⚠️ pass_rate decreased within tolerance: " + f"{baseline_pass_rate:.2%} → {new_pass_rate:.2%} " + f"(Δ {rate_delta:.2%}, executed: {new_executed})" + ) + print(msg) + add_summary(msg, version_type, new_scores, baseline) + return 0 + + +if __name__ == "__main__": + version_type = get_version_type() + fail_on_drop = (version_type == "stable") # Only fail on stable drops + + print(f"Comparing {version_type} scores (fail_on_drop={fail_on_drop})") + exit_code = compare_and_update(version_type, fail_on_drop) + sys.exit(exit_code) diff --git a/.github/workflows/test_stub_quality.yml b/.github/workflows/test_stub_quality.yml index 5ce04b0a83..ed85cb042c 100644 --- a/.github/workflows/test_stub_quality.yml +++ b/.github/workflows/test_stub_quality.yml @@ -10,6 +10,7 @@ env: jobs: + # Test with --stable-only: current stable release (BLOCKING - will fail workflow) test_snippets: runs-on: ubuntu-latest permissions: @@ -48,6 +49,12 @@ jobs: run: | uv run stubber clone + - name: Get stable version + id: get_version + run: | + STABLE_VERSION=$(uv run python -c "from mpflash.versions import get_stable_mp_version; print(get_stable_mp_version())") + echo "stable_version=$STABLE_VERSION" >> $GITHUB_OUTPUT + echo "Testing stable version: $STABLE_VERSION" # - name: update the stubs (not pushed) # continue-on-error: true @@ -55,15 +62,17 @@ jobs: # source .venv/bin/activate # pwsh -file ./update-stubs.ps1 - - name: Test the snippets (stable only) - continue-on-error: true + - name: Test the snippets (stable only - blocking) run: | uv run pytest -m 'snippets' --stable-only --cache-clear --junitxml=./results/results.xml - - name: compare and update + - name: Compare and update (stable - will fail on drop) + env: + VERSION_TYPE: stable + TEST_VERSION: ${{ steps.get_version.outputs.stable_version }} run: | - uv run .github/workflows/compare_score.py + uv run python .github/workflows/compare_score_v2.py - name: Upload results artifact uses: actions/upload-artifact@v4 @@ -72,6 +81,7 @@ jobs: name: snippet-results-stable-${{ github.run_id }} path: results/ + # Test with --preview-only: most recent preview version (NON-BLOCKING - warnings only) test_snippets_preview: runs-on: ubuntu-latest continue-on-error: true @@ -101,10 +111,25 @@ jobs: run: | uv run stubber clone - - name: Test the snippets (preview versions, non-blocking) + - name: Get preview version + id: get_version + run: | + PREVIEW_VERSION=$(uv run python -c "from mpflash.versions import get_preview_mp_version; print(get_preview_mp_version())") + echo "preview_version=$PREVIEW_VERSION" >> $GITHUB_OUTPUT + echo "Testing preview version: $PREVIEW_VERSION" + + - name: Test the snippets (preview only - non-blocking) + continue-on-error: true + run: | + uv run pytest -m 'snippets' --preview-only --cache-clear --junitxml=./results/results_preview.xml + + - name: Compare and log (preview - non-blocking) continue-on-error: true + env: + VERSION_TYPE: preview + TEST_VERSION: ${{ steps.get_version.outputs.preview_version }} run: | - uv run pytest -m 'snippets' --cache-clear --junitxml=./results/results_preview.xml + uv run python .github/workflows/compare_score_v2.py - name: Upload preview results artifact uses: actions/upload-artifact@v4 @@ -113,3 +138,52 @@ jobs: name: snippet-results-preview-${{ github.run_id }} path: results/ + # Test with --recent-majors: last 3 stable major.minor releases (NON-BLOCKING - warnings only) + test_snippets_recent: + runs-on: ubuntu-latest + continue-on-error: true + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v6 + + - name: Install poetry + run: uv tool install poetry + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install Python dependencies + working-directory: ${{github.workspace}} + run: | + uv venv + uv pip install -U -r pyproject.toml --extra stubber --extra test + + - name: stubber clone + run: | + uv run stubber clone + + - name: Test the snippets (recent majors - non-blocking) + continue-on-error: true + run: | + uv run pytest -m 'snippets' --recent-majors --cache-clear --junitxml=./results/results_recent.xml + + - name: Compare and log (recent majors - non-blocking) + continue-on-error: true + env: + VERSION_TYPE: recent_majors + run: | + uv run python .github/workflows/compare_score_v2.py + + - name: Upload recent majors results artifact + uses: actions/upload-artifact@v4 + if: always() + with: + name: snippet-results-recent-${{ github.run_id }} + path: results/ + diff --git a/tests/quality_tests/conftest.py b/tests/quality_tests/conftest.py index 03e08cf05f..4eb4ac4b40 100644 --- a/tests/quality_tests/conftest.py +++ b/tests/quality_tests/conftest.py @@ -41,6 +41,18 @@ def pytest_addoption(parser: pytest.Parser): default=False, help="Only run tests for the current stable MicroPython release, skipping preview versions.", ) + parser.addoption( + "--preview-only", + action="store_true", + default=False, + help="Only run tests for the most recent preview MicroPython version.", + ) + parser.addoption( + "--recent-majors", + action="store_true", + default=False, + help="Only run tests for the last 3 stable major.minor MicroPython releases (excludes preview).", + ) def major_minor(versions): @@ -59,20 +71,33 @@ def major_minor(versions): def get_test_versions(config: pytest.Config) -> list[str]: - """Get the list of MicroPython versions to test based on --stable-only flag. + """Get the list of MicroPython versions to test based on version selection flags. Args: config: The pytest Config object. Returns: List of version strings to test (e.g., ['v1.27.0'] or ['v1.27.0', 'v1.26.0', 'v1.25.0']). + + Priority: + --stable-only: Only the current stable release + --preview-only: Only the most recent preview version + --recent-majors: Last 3 major.minor stable releases (no preview) [default] """ stable_only = config.getoption("--stable-only", default=False) + preview_only = config.getoption("--preview-only", default=False) + recent_majors = config.getoption("--recent-majors", default=False) + if stable_only: return [get_stable_mp_version()] + elif preview_only: + return [get_preview_mp_version()] else: - # Only the recent versions (last 3 major.minor releases) - return sorted(major_minor(micropython_versions(minver="v1.24.0")), reverse=True)[:3] + # Last 3 major.minor stable releases (exclude preview) + all_versions = major_minor(micropython_versions(minver="v1.24.0")) + stable_versions = [v for v in all_versions if not v.endswith("-preview")] + return sorted(stable_versions, reverse=True)[:3] + def flat_version(version): @@ -299,6 +324,26 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config: pytest.Config) stats["pass_rate"] = round(stats["passed"] / executed, 4) if executed > 0 else 0.0 # keep for backward compatibility stats["snippet_score"] = int(stats["passed"] - stats["failed"]) + + # Add version information from command-line options + stable_only = config.getoption("--stable-only", default=False) + preview_only = config.getoption("--preview-only", default=False) + recent_majors = config.getoption("--recent-majors", default=False) + + # Determine version type and get tested versions + if stable_only: + stats["version_type"] = "stable" + stats["versions"] = get_test_versions(config) + elif preview_only: + stats["version_type"] = "preview" + stats["versions"] = get_test_versions(config) + elif recent_majors: + stats["version_type"] = "recent_majors" + stats["versions"] = get_test_versions(config) + else: + stats["version_type"] = "default" + stats["versions"] = get_test_versions(config) + if executed > 0: # Write stats to file (config.rootpath / "results").mkdir(exist_ok=True) From c33b30065a90f78c59d45b8cbb327bc10d78c71c Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Tue, 24 Feb 2026 23:11:14 +0100 Subject: [PATCH 5/8] Add RPI_PICO_W v1.27.0 Signed-off-by: Jos Verlinde --- .../LICENSE.md | 22 + .../README.md | 38 + .../__builtins__.pyi | 28 + .../_boot.pyi | 4 + .../_boot_fat.pyi | 3 + .../_onewire.pyi | 15 + .../_thread.pyi | 33 + .../aioble/__init__.pyi | 9 + .../aioble/central.pyi | 70 + .../aioble/client.pyi | 101 + .../aioble/core.pyi | 23 + .../aioble/device.pyi | 66 + .../aioble/l2cap.pyi | 40 + .../aioble/peripheral.pyi | 44 + .../aioble/security.pyi | 27 + .../aioble/server.pyi | 101 + .../binascii.pyi | 61 + .../bluetooth.pyi | 871 +++++ .../cmath.pyi | 84 + .../cryptolib.pyi | 165 + .../deflate.pyi | 88 + .../dht.pyi | 15 + .../ds18x20.pyi | 16 + .../errno.pyi | 97 + .../framebuf.pyi | 247 ++ .../gc.pyi | 112 + .../hashlib.pyi | 116 + .../heapq.pyi | 46 + .../lwip.pyi | 51 + .../machine.pyi | 3206 +++++++++++++++++ .../math.pyi | 269 ++ .../micropython.pyi | 346 ++ .../mip/__init__.pyi | 15 + .../neopixel.pyi | 86 + .../network.pyi | 577 +++ .../ntptime.pyi | 5 + .../onewire.pyi | 21 + .../platform.pyi | 51 + .../pyproject.toml | 125 + .../random.pyi | 115 + .../requests/__init__.pyi | 21 + .../rp2/__init__.pyi | 993 +++++ .../rp2/asm_pio.pyi | 459 +++ .../select.pyi | 118 + .../socket.pyi | 426 +++ .../time.pyi | 306 ++ .../tls.pyi | 26 + .../uarray.pyi | 2 + .../uasyncio.pyi | 2 + .../ubinascii.pyi | 2 + .../ubluetooth.pyi | 2 + .../ucollections.pyi | 15 + .../ucryptolib.pyi | 2 + .../uctypes.pyi | 164 + .../uerrno.pyi | 2 + .../uhashlib.pyi | 2 + .../uheapq.pyi | 2 + .../uio.pyi | 2 + .../ujson.pyi | 2 + .../umachine.pyi | 2 + .../uos.pyi | 2 + .../uplatform.pyi | 2 + .../urandom.pyi | 2 + .../ure.pyi | 2 + .../urequests.pyi | 1 + .../uselect.pyi | 2 + .../usocket.pyi | 2 + .../ussl.pyi | 2 + .../ustruct.pyi | 2 + .../usys.pyi | 2 + .../utime.pyi | 2 + .../uwebsocket.pyi | 2 + .../uzlib.pyi | 2 + .../vfs.pyi | 240 ++ .../webrepl.pyi | 16 + .../webrepl_setup.pyi | 10 + .../websocket.pyi | 17 + .../_boot_fat.pyi | 8 + .../_onewire.pyi | 15 + .../_thread.pyi | 33 + .../aioble/__init__.pyi | 191 + .../aioble/central.pyi | 81 + .../aioble/client.pyi | 120 + .../aioble/core.pyi | 25 + .../aioble/device.pyi | 53 + .../aioble/l2cap.pyi | 66 + .../aioble/peripheral.pyi | 62 + .../aioble/security.pyi | 54 + .../aioble/server.pyi | 133 + .../binascii.pyi | 61 + .../bluetooth.pyi | 871 +++++ .../cmath.pyi | 84 + .../cryptolib.pyi | 165 + .../deflate.pyi | 88 + .../dht.pyi | 26 + .../doc_stubs.json | 480 +++ .../ds18x20.pyi | 18 + .../errno.pyi | 97 + .../firmware_stubs.json | 95 + .../framebuf.pyi | 247 ++ .../gc.pyi | 112 + .../hashlib.pyi | 116 + .../heapq.pyi | 46 + .../lwip.pyi | 51 + .../machine.pyi | 3206 +++++++++++++++++ .../math.pyi | 269 ++ .../micropython.pyi | 346 ++ .../mip/__init__.pyi | 36 + .../neopixel.pyi | 73 + .../network.pyi | 577 +++ .../ntptime.pyi | 15 + .../onewire.pyi | 28 + .../platform.pyi | 51 + .../random.pyi | 115 + .../requests/__init__.pyi | 42 + .../rp2/__init__.pyi | 993 +++++ .../rp2/asm_pio.pyi | 459 +++ .../select.pyi | 118 + .../socket.pyi | 426 +++ .../time.pyi | 306 ++ .../tls.pyi | 26 + .../uarray.pyi | 2 + .../uasyncio.pyi | 2 + .../ubinascii.pyi | 2 + .../ubluetooth.pyi | 2 + .../ucollections.pyi | 153 + .../ucryptolib.pyi | 2 + .../uctypes.pyi | 164 + .../uerrno.pyi | 2 + .../uhashlib.pyi | 2 + .../uheapq.pyi | 2 + .../uio.pyi | 2 + .../ujson.pyi | 2 + .../umachine.pyi | 2 + .../uos.pyi | 2 + .../uplatform.pyi | 2 + .../urandom.pyi | 2 + .../ure.pyi | 2 + .../urequests.pyi | 25 + .../uselect.pyi | 2 + .../usocket.pyi | 2 + .../ussl.pyi | 2 + .../ustruct.pyi | 2 + .../usys.pyi | 2 + .../utime.pyi | 2 + .../uwebsocket.pyi | 2 + .../uzlib.pyi | 2 + .../vfs.pyi | 240 ++ .../websocket.pyi | 17 + .../_asyncio.pyi | 18 + .../_boot_fat.pyi | 8 + .../_onewire.pyi | 15 + .../_rp2.pyi | 59 + .../_thread.pyi | 20 + .../aioble/__init__.pyi | 191 + .../aioble/central.pyi | 81 + .../aioble/client.pyi | 120 + .../aioble/core.pyi | 25 + .../aioble/device.pyi | 53 + .../aioble/l2cap.pyi | 66 + .../aioble/peripheral.pyi | 62 + .../aioble/security.pyi | 54 + .../aioble/server.pyi | 133 + .../array.pyi | 13 + .../asyncio/__init__.pyi | 278 ++ .../asyncio/core.pyi | 73 + .../asyncio/event.pyi | 25 + .../asyncio/funcs.pyi | 22 + .../asyncio/lock.pyi | 16 + .../asyncio/stream.pyi | 96 + .../binascii.pyi | 14 + .../bluetooth.pyi | 40 + .../builtins.pyi | 305 ++ .../cmath.pyi | 21 + .../collections.pyi | 33 + .../cryptolib.pyi | 13 + .../deflate.pyi | 21 + .../dht.pyi | 26 + .../ds18x20.pyi | 18 + .../errno.pyi | 33 + .../framebuf.pyi | 35 + .../micropython-v1_27_0-rp2-RPI_PICO_W/gc.pyi | 16 + .../hashlib.pyi | 23 + .../heapq.pyi | 12 + .../micropython-v1_27_0-rp2-RPI_PICO_W/io.pyi | 37 + .../json.pyi | 13 + .../lwip.pyi | 51 + .../machine.pyi | 297 ++ .../math.pyi | 55 + .../micropython.pyi | 28 + .../mip.pyi | 20 + .../mip/__init__.pyi | 36 + .../modules.json | 95 + .../neopixel.pyi | 16 + .../network.pyi | 47 + .../ntptime.pyi | 15 + .../onewire.pyi | 28 + .../micropython-v1_27_0-rp2-RPI_PICO_W/os.pyi | 61 + .../platform.pyi | 12 + .../random.pyi | 16 + .../requests.pyi | 24 + .../requests/__init__.pyi | 42 + .../rp2.pyi | 88 + .../select.pyi | 17 + .../socket.pyi | 51 + .../ssl.pyi | 28 + .../struct.pyi | 14 + .../sys.pyi | 27 + .../time.pyi | 22 + .../tls.pyi | 26 + .../uarray.pyi | 14 + .../uasyncio/__init__.pyi | 278 ++ .../uasyncio/core.pyi | 73 + .../uasyncio/event.pyi | 25 + .../uasyncio/funcs.pyi | 22 + .../uasyncio/lock.pyi | 16 + .../uasyncio/stream.pyi | 96 + .../ubinascii.pyi | 15 + .../ubluetooth.pyi | 40 + .../ucollections.pyi | 34 + .../ucryptolib.pyi | 14 + .../uctypes.pyi | 50 + .../uerrno.pyi | 33 + .../uhashlib.pyi | 24 + .../uheapq.pyi | 13 + .../uio.pyi | 38 + .../ujson.pyi | 14 + .../umachine.pyi | 297 ++ .../uos.pyi | 62 + .../uplatform.pyi | 13 + .../urandom.pyi | 17 + .../ure.pyi | 14 + .../urequests.pyi | 25 + .../uselect.pyi | 17 + .../usocket.pyi | 51 + .../ustruct.pyi | 15 + .../usys.pyi | 28 + .../utime.pyi | 23 + .../uwebsocket.pyi | 18 + .../vfs.pyi | 43 + .../websocket.pyi | 17 + 241 files changed, 26039 insertions(+) create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/LICENSE.md create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/README.md create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/__builtins__.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_boot.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_boot_fat.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_onewire.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_thread.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/__init__.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/central.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/client.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/core.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/device.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/l2cap.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/peripheral.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/security.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/server.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/binascii.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/bluetooth.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/cmath.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/cryptolib.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/deflate.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/dht.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ds18x20.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/errno.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/framebuf.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/gc.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/hashlib.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/heapq.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/lwip.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/machine.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/math.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/micropython.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/mip/__init__.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/neopixel.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/network.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ntptime.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/onewire.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/platform.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/pyproject.toml create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/random.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/requests/__init__.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/rp2/__init__.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/rp2/asm_pio.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/select.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/socket.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/time.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/tls.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uarray.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uasyncio.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ubinascii.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ubluetooth.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ucollections.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ucryptolib.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uctypes.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uerrno.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uhashlib.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uheapq.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uio.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ujson.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/umachine.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uos.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uplatform.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/urandom.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ure.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/urequests.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uselect.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/usocket.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ussl.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ustruct.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/usys.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/utime.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uwebsocket.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uzlib.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/vfs.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/webrepl.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/webrepl_setup.pyi create mode 100644 publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/websocket.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_boot_fat.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_onewire.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_thread.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/central.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/client.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/core.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/device.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/l2cap.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/peripheral.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/security.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/server.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/binascii.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/bluetooth.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/cmath.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/cryptolib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/deflate.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/dht.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/doc_stubs.json create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ds18x20.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/errno.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/firmware_stubs.json create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/framebuf.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/gc.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/hashlib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/heapq.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/lwip.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/machine.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/math.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/micropython.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/mip/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/neopixel.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/network.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ntptime.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/onewire.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/platform.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/random.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/requests/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/rp2/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/rp2/asm_pio.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/select.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/socket.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/time.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/tls.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uarray.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uasyncio.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ubinascii.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ubluetooth.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ucollections.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ucryptolib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uctypes.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uerrno.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uhashlib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uheapq.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uio.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ujson.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/umachine.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uos.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uplatform.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/urandom.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ure.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/urequests.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uselect.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/usocket.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ussl.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ustruct.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/usys.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/utime.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uwebsocket.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uzlib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/vfs.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/websocket.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_asyncio.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_boot_fat.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_onewire.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_rp2.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_thread.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/central.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/client.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/core.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/device.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/l2cap.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/peripheral.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/security.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/server.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/array.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/core.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/event.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/funcs.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/lock.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/stream.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/binascii.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/bluetooth.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/builtins.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cmath.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/collections.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cryptolib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/deflate.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/dht.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ds18x20.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/errno.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/framebuf.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/gc.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/hashlib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/heapq.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/io.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/json.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/lwip.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/machine.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/math.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/micropython.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/modules.json create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/neopixel.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/network.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ntptime.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/onewire.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/os.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/platform.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/random.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/rp2.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/select.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/socket.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ssl.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/struct.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/sys.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/time.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/tls.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uarray.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/__init__.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/core.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/event.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/funcs.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/lock.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/stream.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubinascii.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubluetooth.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucollections.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucryptolib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uctypes.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uerrno.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uhashlib.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uheapq.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uio.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ujson.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/umachine.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uos.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uplatform.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urandom.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ure.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urequests.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uselect.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usocket.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ustruct.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usys.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/utime.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uwebsocket.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/vfs.pyi create mode 100644 stubs/micropython-v1_27_0-rp2-RPI_PICO_W/websocket.pyi diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/LICENSE.md b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/LICENSE.md new file mode 100644 index 0000000000..15d4b46932 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/LICENSE.md @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2022 Jos Verlinde + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/README.md b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/README.md new file mode 100644 index 0000000000..50ee08716f --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/README.md @@ -0,0 +1,38 @@ +# micropython-rp2-rpi_pico_w-stubs + + +This is a stub-only package for MicroPython. +It is intended to be installed in a projects virtual environment to allow static type checkers and intellisense features to be used while writing Micropython code. + +The version of this package is alligned the the version of the MicroPython firmware. + - Major, Minor and Patch levels are alligned to the same version as the firmware. + - The post release level is used to publish new releases of the stubs. + +For `Micropython 1.17` the stubs are published as `1.17.post1` ... `1.17.post2` +for `Micropython 1.18` the stubs are published as `1.18.post1` ... `1.18.post2` + +To install the latest stubs: +`pip install -I micropython--stubs` where port is the port of the MicroPython firmware. + +To install the stubs for an older version, such as MicroPython 1.17: +`pip install micropython-stm32-stubs==1.17.*` which will install the last post release of the stubs for MicroPython 1.17. + + +As the creation of the stubs, and merging of the different types is still going though improvements, the stub packages are marked as Beta. +To upgrade stubs to the latest stubs for a specific version use `pip install micropython-stm32-stubs==1.17.* --upgrade` + +If you have suggestions or find any issues with the stubs, please report them in the [MicroPython-stubs Discussions](https://github.com/Josverl/micropython-stubs/discussions) + +For an overview of Micropython Stubs please see: https://micropython-stubs.readthedocs.io/en/main/ + * List of all stubs : https://micropython-stubs.readthedocs.io/en/main/firmware_grp.html + + + +Included stubs: +* Merged stubs from `stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged` +* Frozen stubs from `stubs/micropython-v1_27_0-frozen/rp2/RPI_PICO_W` +* Core stubs from `stubs/micropython-core` + + +origin | Family | Port | Board | Version +-------|--------|------|-------|-------- diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/__builtins__.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/__builtins__.pyi new file mode 100644 index 0000000000..5d9ece1dfa --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/__builtins__.pyi @@ -0,0 +1,28 @@ +"""Allows for type checking of Micropython specific builtins by pyright and pylance. +""" + +from typing import Tuple, TypeVar + +Const_T = TypeVar("Const_T", int, float, str, bytes, Tuple) # constant + +def const(expr: Const_T) -> Const_T: + """ + Used to declare that the expression is a constant so that the compiler can + optimise it. The use of this function should be as follows:: + + from micropython import const + + CONST_X = const(123) + CONST_Y = const(2 * CONST_X + 1) + + Constants declared this way are still accessible as global variables from + outside the module they are declared in. On the other hand, if a constant + begins with an underscore then it is hidden, it is not available as a global + variable, and does not take up any memory during execution. + + This `const` function is recognised directly by the MicroPython parser and is + provided as part of the :mod:`micropython` module mainly so that scripts can be + written which run under both CPython and MicroPython, by following the above + pattern. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_boot.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_boot.pyi new file mode 100644 index 0000000000..20aca68635 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_boot.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +bdev: Incomplete +fs: Incomplete diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_boot_fat.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_boot_fat.pyi new file mode 100644 index 0000000000..e939f892fa --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_boot_fat.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +bdev: Incomplete diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_onewire.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_onewire.pyi new file mode 100644 index 0000000000..49f6f067b2 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_onewire.pyi @@ -0,0 +1,15 @@ +""" +Module: '_onewire' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def reset(*args, **kwargs) -> Incomplete: ... +def writebyte(*args, **kwargs) -> Incomplete: ... +def writebit(*args, **kwargs) -> Incomplete: ... +def crc8(*args, **kwargs) -> Incomplete: ... +def readbyte(*args, **kwargs) -> Incomplete: ... +def readbit(*args, **kwargs) -> Incomplete: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_thread.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_thread.pyi new file mode 100644 index 0000000000..de3c141663 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/_thread.pyi @@ -0,0 +1,33 @@ +""" +Multithreading support. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/_thread.html + +CPython module: :mod:`python:_thread` https://docs.python.org/3/library/_thread.html . + +This module implements multithreading support. + +This module is highly experimental and its API is not yet fully settled +and not yet described in this documentation. + +--- +Module: '_thread' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def get_ident(*args, **kwargs) -> Incomplete: ... +def start_new_thread(*args, **kwargs) -> Incomplete: ... +def stack_size(*args, **kwargs) -> Incomplete: ... +def exit(*args, **kwargs) -> Incomplete: ... +def allocate_lock(*args, **kwargs) -> Incomplete: ... + +class LockType: + def locked(self, *args, **kwargs) -> Incomplete: ... + def release(self, *args, **kwargs) -> Incomplete: ... + def acquire(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/__init__.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/__init__.pyi new file mode 100644 index 0000000000..ddce380e0b --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/__init__.pyi @@ -0,0 +1,9 @@ +from .central import scan as scan +from .core import GattError as GattError, config as config, log_error as log_error, log_warn as log_warn, stop as stop +from .device import Device as Device, DeviceDisconnectedError as DeviceDisconnectedError +from .peripheral import advertise as advertise +from .server import BufferedCharacteristic as BufferedCharacteristic, Characteristic as Characteristic, Descriptor as Descriptor, Service as Service, register_services as register_services +from micropython import const as const + +ADDR_PUBLIC: int +ADDR_RANDOM: int diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/central.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/central.pyi new file mode 100644 index 0000000000..f79c068227 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/central.pyi @@ -0,0 +1,70 @@ +from .core import ( + ble as ble, + ensure_active as ensure_active, + log_error as log_error, + log_info as log_info, + log_warn as log_warn, + register_irq_handler as register_irq_handler, +) +from .device import Device as Device, DeviceConnection as DeviceConnection, DeviceTimeout as DeviceTimeout +from _typeshed import Incomplete +from collections.abc import Generator +from micropython import const as const + +_IRQ_SCAN_RESULT: int +_IRQ_SCAN_DONE: int +_IRQ_PERIPHERAL_CONNECT: int +_IRQ_PERIPHERAL_DISCONNECT: int +_ADV_IND: int +_ADV_DIRECT_IND: int +_ADV_SCAN_IND: int +_ADV_NONCONN_IND: int +_SCAN_RSP: int +_ADV_TYPE_FLAGS: int +_ADV_TYPE_NAME: int +_ADV_TYPE_SHORT_NAME: int +_ADV_TYPE_UUID16_INCOMPLETE: int +_ADV_TYPE_UUID16_COMPLETE: int +_ADV_TYPE_UUID32_INCOMPLETE: int +_ADV_TYPE_UUID32_COMPLETE: int +_ADV_TYPE_UUID128_INCOMPLETE: int +_ADV_TYPE_UUID128_COMPLETE: int +_ADV_TYPE_APPEARANCE: int +_ADV_TYPE_MANUFACTURER: int +_active_scanner: Incomplete +_connecting: Incomplete + +def _central_irq(event, data) -> None: ... +def _central_shutdown() -> None: ... +async def _cancel_pending() -> None: ... +async def _connect(connection, timeout_ms, scan_duration_ms, min_conn_interval_us, max_conn_interval_us) -> None: ... + +class ScanResult: + device: Incomplete + adv_data: Incomplete + resp_data: Incomplete + rssi: Incomplete + connectable: bool + def __init__(self, device) -> None: ... + def _update(self, adv_type, rssi, adv_data): ... + def __str__(self) -> str: ... + def _decode_field(self, *adv_type) -> Generator[Incomplete]: ... + def name(self): ... + def services(self) -> Generator[Incomplete]: ... + def manufacturer(self, filter=None) -> Generator[Incomplete]: ... + +class scan: + _queue: Incomplete + _event: Incomplete + _done: bool + _results: Incomplete + _duration_ms: Incomplete + _interval_us: Incomplete + _window_us: Incomplete + _active: Incomplete + def __init__(self, duration_ms, interval_us=None, window_us=None, active: bool = False) -> None: ... + async def __aenter__(self): ... + async def __aexit__(self, exc_type, exc_val, exc_traceback) -> None: ... + def __aiter__(self): ... + async def __anext__(self): ... + async def cancel(self) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/client.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/client.pyi new file mode 100644 index 0000000000..a3875cd3e5 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/client.pyi @@ -0,0 +1,101 @@ +from .core import GattError as GattError, ble as ble, register_irq_handler as register_irq_handler +from .device import DeviceConnection as DeviceConnection +from _typeshed import Incomplete +from micropython import const as const + +_IRQ_GATTC_SERVICE_RESULT: int +_IRQ_GATTC_SERVICE_DONE: int +_IRQ_GATTC_CHARACTERISTIC_RESULT: int +_IRQ_GATTC_CHARACTERISTIC_DONE: int +_IRQ_GATTC_DESCRIPTOR_RESULT: int +_IRQ_GATTC_DESCRIPTOR_DONE: int +_IRQ_GATTC_READ_RESULT: int +_IRQ_GATTC_READ_DONE: int +_IRQ_GATTC_WRITE_DONE: int +_IRQ_GATTC_NOTIFY: int +_IRQ_GATTC_INDICATE: int +_CCCD_UUID: int +_CCCD_NOTIFY: int +_CCCD_INDICATE: int +_FLAG_READ: int +_FLAG_WRITE_NO_RESPONSE: int +_FLAG_WRITE: int +_FLAG_NOTIFY: int +_FLAG_INDICATE: int + +def _client_irq(event, data) -> None: ... + +class ClientDiscover: + _connection: Incomplete + _queue: Incomplete + _status: Incomplete + _event: Incomplete + _disc_type: Incomplete + _parent: Incomplete + _timeout_ms: Incomplete + _args: Incomplete + def __init__(self, connection, disc_type, parent, timeout_ms, *args) -> None: ... + async def _start(self) -> None: ... + def __aiter__(self): ... + async def __anext__(self): ... + def _discover_result(conn_handle, *args) -> None: ... + def _discover_done(conn_handle, status) -> None: ... + +class ClientService: + connection: Incomplete + _start_handle: Incomplete + _end_handle: Incomplete + uuid: Incomplete + def __init__(self, connection, start_handle, end_handle, uuid) -> None: ... + def __str__(self) -> str: ... + async def characteristic(self, uuid, timeout_ms: int = 2000): ... + def characteristics(self, uuid=None, timeout_ms: int = 2000): ... + def _start_discovery(connection, uuid=None) -> None: ... + +class BaseClientCharacteristic: + _value_handle: Incomplete + properties: Incomplete + uuid: Incomplete + _read_event: Incomplete + _read_data: Incomplete + _read_status: Incomplete + _write_event: Incomplete + _write_status: Incomplete + def __init__(self, value_handle, properties, uuid) -> None: ... + def _register_with_connection(self) -> None: ... + def _find(conn_handle, value_handle): ... + def _check(self, flag) -> None: ... + async def read(self, timeout_ms: int = 1000): ... + def _read_result(conn_handle, value_handle, data) -> None: ... + def _read_done(conn_handle, value_handle, status) -> None: ... + async def write(self, data, response=None, timeout_ms: int = 1000) -> None: ... + def _write_done(conn_handle, value_handle, status) -> None: ... + +class ClientCharacteristic(BaseClientCharacteristic): + service: Incomplete + connection: Incomplete + _end_handle: Incomplete + _notify_event: Incomplete + _notify_queue: Incomplete + _indicate_event: Incomplete + _indicate_queue: Incomplete + def __init__(self, service, end_handle, value_handle, properties, uuid) -> None: ... + def __str__(self) -> str: ... + def _connection(self): ... + async def descriptor(self, uuid, timeout_ms: int = 2000): ... + def descriptors(self, timeout_ms: int = 2000): ... + def _start_discovery(service, uuid=None) -> None: ... + async def _notified_indicated(self, queue, event, timeout_ms): ... + async def notified(self, timeout_ms=None): ... + def _on_notify_indicate(self, queue, event, data) -> None: ... + def _on_notify(conn_handle, value_handle, notify_data) -> None: ... + async def indicated(self, timeout_ms=None): ... + def _on_indicate(conn_handle, value_handle, indicate_data) -> None: ... + async def subscribe(self, notify: bool = True, indicate: bool = False) -> None: ... + +class ClientDescriptor(BaseClientCharacteristic): + characteristic: Incomplete + def __init__(self, characteristic, dsc_handle, uuid) -> None: ... + def __str__(self) -> str: ... + def _connection(self): ... + def _start_discovery(characteristic, uuid=None) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/core.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/core.pyi new file mode 100644 index 0000000000..51440ac6e6 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/core.pyi @@ -0,0 +1,23 @@ +from _typeshed import Incomplete + +log_level: int + +def log_error(*args) -> None: ... +def log_warn(*args) -> None: ... +def log_info(*args) -> None: ... + +class GattError(Exception): + _status: Incomplete + def __init__(self, status) -> None: ... + +def ensure_active() -> None: ... +def config(*args, **kwargs): ... + +_irq_handlers: Incomplete +_shutdown_handlers: Incomplete + +def register_irq_handler(irq, shutdown) -> None: ... +def stop() -> None: ... +def ble_irq(event, data): ... + +ble: Incomplete diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/device.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/device.pyi new file mode 100644 index 0000000000..3afbc709f8 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/device.pyi @@ -0,0 +1,66 @@ +import types +from .core import ble as ble, log_error as log_error, register_irq_handler as register_irq_handler +from _typeshed import Incomplete +from micropython import const as const + +_IRQ_MTU_EXCHANGED: int + +class DeviceDisconnectedError(Exception): ... + +def _device_irq(event, data) -> None: ... + +class DeviceTimeout: + _connection: Incomplete + _timeout_ms: Incomplete + _timeout_task: Incomplete + _task: Incomplete + def __init__(self, connection, timeout_ms) -> None: ... + async def _timeout_sleep(self) -> None: ... + def __enter__(self) -> None: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_traceback: types.TracebackType | None + ) -> None: ... + +class Device: + addr_type: Incomplete + addr: Incomplete + _connection: Incomplete + def __init__(self, addr_type, addr) -> None: ... + def __eq__(self, rhs): ... + def __hash__(self): ... + def __str__(self) -> str: ... + def addr_hex(self): ... + async def connect(self, timeout_ms: int = 10000, scan_duration_ms=None, min_conn_interval_us=None, max_conn_interval_us=None): ... + +class DeviceConnection: + _connected: Incomplete + device: Incomplete + encrypted: bool + authenticated: bool + bonded: bool + key_size: bool + mtu: Incomplete + _conn_handle: Incomplete + _event: Incomplete + _mtu_event: Incomplete + _discover: Incomplete + _characteristics: Incomplete + _task: Incomplete + _timeouts: Incomplete + _pair_event: Incomplete + _l2cap_channel: Incomplete + def __init__(self, device) -> None: ... + async def device_task(self) -> None: ... + def _run_task(self) -> None: ... + async def disconnect(self, timeout_ms: int = 2000) -> None: ... + async def disconnected(self, timeout_ms=None, disconnect: bool = False) -> None: ... + async def service(self, uuid, timeout_ms: int = 2000): ... + def services(self, uuid=None, timeout_ms: int = 2000): ... + async def pair(self, *args, **kwargs) -> None: ... + def is_connected(self): ... + def timeout(self, timeout_ms): ... + async def exchange_mtu(self, mtu=None, timeout_ms: int = 1000): ... + async def l2cap_accept(self, psm, mtu, timeout_ms=None): ... + async def l2cap_connect(self, psm, mtu, timeout_ms: int = 1000): ... + async def __aenter__(self): ... + async def __aexit__(self, exc_type, exc_val, exc_traceback) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/l2cap.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/l2cap.pyi new file mode 100644 index 0000000000..b98177752e --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/l2cap.pyi @@ -0,0 +1,40 @@ +from .core import ble as ble, log_error as log_error, register_irq_handler as register_irq_handler +from .device import DeviceConnection as DeviceConnection +from _typeshed import Incomplete +from micropython import const as const + +_IRQ_L2CAP_ACCEPT: int +_IRQ_L2CAP_CONNECT: int +_IRQ_L2CAP_DISCONNECT: int +_IRQ_L2CAP_RECV: int +_IRQ_L2CAP_SEND_READY: int +_listening: bool + +def _l2cap_irq(event, data) -> None: ... +def _l2cap_shutdown() -> None: ... + +class L2CAPDisconnectedError(Exception): ... +class L2CAPConnectionError(Exception): ... + +class L2CAPChannel: + _connection: Incomplete + our_mtu: int + peer_mtu: int + _cid: Incomplete + _status: int + _stalled: bool + _data_ready: bool + _event: Incomplete + def __init__(self, connection) -> None: ... + def _assert_connected(self) -> None: ... + async def recvinto(self, buf, timeout_ms=None): ... + def available(self): ... + async def send(self, buf, timeout_ms=None, chunk_size=None) -> None: ... + async def flush(self, timeout_ms=None) -> None: ... + async def disconnect(self, timeout_ms: int = 1000) -> None: ... + async def disconnected(self, timeout_ms: int = 1000) -> None: ... + async def __aenter__(self): ... + async def __aexit__(self, exc_type, exc_val, exc_traceback) -> None: ... + +async def accept(connection, psm, mtu, timeout_ms): ... +async def connect(connection, psm, mtu, timeout_ms): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/peripheral.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/peripheral.pyi new file mode 100644 index 0000000000..c5705bb118 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/peripheral.pyi @@ -0,0 +1,44 @@ +from .core import ( + ble as ble, + ensure_active as ensure_active, + log_error as log_error, + log_info as log_info, + log_warn as log_warn, + register_irq_handler as register_irq_handler, +) +from .device import Device as Device, DeviceConnection as DeviceConnection, DeviceTimeout as DeviceTimeout +from _typeshed import Incomplete +from micropython import const as const + +_IRQ_CENTRAL_CONNECT: int +_IRQ_CENTRAL_DISCONNECT: int +_ADV_TYPE_FLAGS: int +_ADV_TYPE_NAME: int +_ADV_TYPE_UUID16_COMPLETE: int +_ADV_TYPE_UUID32_COMPLETE: int +_ADV_TYPE_UUID128_COMPLETE: int +_ADV_TYPE_UUID16_MORE: int +_ADV_TYPE_UUID32_MORE: int +_ADV_TYPE_UUID128_MORE: int +_ADV_TYPE_APPEARANCE: int +_ADV_TYPE_MANUFACTURER: int +_ADV_PAYLOAD_MAX_LEN: int +_incoming_connection: Incomplete +_connect_event: Incomplete + +def _peripheral_irq(event, data) -> None: ... +def _peripheral_shutdown() -> None: ... +def _append(adv_data, resp_data, adv_type, value): ... +async def advertise( + interval_us, + adv_data=None, + resp_data=None, + connectable: bool = True, + limited_disc: bool = False, + br_edr: bool = False, + name=None, + services=None, + appearance: int = 0, + manufacturer=None, + timeout_ms=None, +): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/security.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/security.pyi new file mode 100644 index 0000000000..63f4a75825 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/security.pyi @@ -0,0 +1,27 @@ +from .core import ble as ble, log_info as log_info, log_warn as log_warn, register_irq_handler as register_irq_handler +from .device import DeviceConnection as DeviceConnection +from _typeshed import Incomplete +from micropython import const as const + +_IRQ_ENCRYPTION_UPDATE: int +_IRQ_GET_SECRET: int +_IRQ_SET_SECRET: int +_IRQ_PASSKEY_ACTION: int +_IO_CAPABILITY_DISPLAY_ONLY: int +_IO_CAPABILITY_DISPLAY_YESNO: int +_IO_CAPABILITY_KEYBOARD_ONLY: int +_IO_CAPABILITY_NO_INPUT_OUTPUT: int +_IO_CAPABILITY_KEYBOARD_DISPLAY: int +_PASSKEY_ACTION_INPUT: int +_PASSKEY_ACTION_DISP: int +_PASSKEY_ACTION_NUMCMP: int +_DEFAULT_PATH: str +_secrets: Incomplete +_modified: bool +_path: Incomplete + +def load_secrets(path=None) -> None: ... +def _save_secrets(arg=None) -> None: ... +def _security_irq(event, data): ... +def _security_shutdown() -> None: ... +async def pair(connection, bond: bool = True, le_secure: bool = True, mitm: bool = False, io=..., timeout_ms: int = 20000) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/server.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/server.pyi new file mode 100644 index 0000000000..a03184b1a8 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/aioble/server.pyi @@ -0,0 +1,101 @@ +from .core import ( + GattError as GattError, + ble as ble, + ensure_active as ensure_active, + log_error as log_error, + log_info as log_info, + log_warn as log_warn, + register_irq_handler as register_irq_handler, +) +from .device import DeviceConnection as DeviceConnection, DeviceTimeout as DeviceTimeout +from _typeshed import Incomplete +from micropython import const as const + +_registered_characteristics: Incomplete +_IRQ_GATTS_WRITE: int +_IRQ_GATTS_READ_REQUEST: int +_IRQ_GATTS_INDICATE_DONE: int +_FLAG_READ: int +_FLAG_WRITE_NO_RESPONSE: int +_FLAG_WRITE: int +_FLAG_NOTIFY: int +_FLAG_INDICATE: int +_FLAG_READ_ENCRYPTED: int +_FLAG_READ_AUTHENTICATED: int +_FLAG_READ_AUTHORIZED: int +_FLAG_WRITE_ENCRYPTED: int +_FLAG_WRITE_AUTHENTICATED: int +_FLAG_WRITE_AUTHORIZED: int +_FLAG_WRITE_CAPTURE: int +_WRITE_CAPTURE_QUEUE_LIMIT: int + +def _server_irq(event, data): ... +def _server_shutdown() -> None: ... + +class Service: + uuid: Incomplete + characteristics: Incomplete + def __init__(self, uuid) -> None: ... + def _tuple(self): ... + +class BaseCharacteristic: + _value_handle: Incomplete + _initial: Incomplete + def _register(self, value_handle) -> None: ... + def read(self): ... + def write(self, data, send_update: bool = False) -> None: ... + @staticmethod + def _init_capture() -> None: ... + @staticmethod + async def _run_capture_task() -> None: ... + _write_data: Incomplete + async def written(self, timeout_ms=None): ... + def on_read(self, connection): ... + def _remote_write(conn_handle, value_handle) -> None: ... + def _remote_read(conn_handle, value_handle): ... + +class Characteristic(BaseCharacteristic): + descriptors: Incomplete + _write_event: Incomplete + _write_data: Incomplete + _indicate_connection: Incomplete + _indicate_event: Incomplete + _indicate_status: Incomplete + uuid: Incomplete + flags: Incomplete + _value_handle: Incomplete + _initial: Incomplete + def __init__( + self, + service, + uuid, + read: bool = False, + write: bool = False, + write_no_response: bool = False, + notify: bool = False, + indicate: bool = False, + initial=None, + capture: bool = False, + ) -> None: ... + def _tuple(self): ... + def notify(self, connection, data=None) -> None: ... + async def indicate(self, connection, data=None, timeout_ms: int = 1000) -> None: ... + def _indicate_done(conn_handle, value_handle, status) -> None: ... + +class BufferedCharacteristic(Characteristic): + _max_len: Incomplete + _append: Incomplete + def __init__(self, *args, max_len: int = 20, append: bool = False, **kwargs) -> None: ... + def _register(self, value_handle) -> None: ... + +class Descriptor(BaseCharacteristic): + _write_event: Incomplete + _write_data: Incomplete + uuid: Incomplete + flags: Incomplete + _value_handle: Incomplete + _initial: Incomplete + def __init__(self, characteristic, uuid, read: bool = False, write: bool = False, initial=None) -> None: ... + def _tuple(self): ... + +def register_services(*services) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/binascii.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/binascii.pyi new file mode 100644 index 0000000000..37fbee885b --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/binascii.pyi @@ -0,0 +1,61 @@ +""" +Binary/ASCII conversions. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/binascii.html + +CPython module: :mod:`python:binascii` https://docs.python.org/3/library/binascii.html . + +This module implements conversions between binary data and various +encodings of it in ASCII form (in both directions). + +--- +Module: 'binascii' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import Any, Optional +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def crc32(data, value: Optional[Any] = None) -> Incomplete: + """ + Compute CRC-32, the 32-bit checksum of *data*, starting with an initial CRC + of *value*. The default initial CRC is zero. The algorithm is consistent + with the ZIP file checksum. + """ + ... + +def hexlify(data: bytes, sep: str | bytes = ..., /) -> bytes: + """ + Convert the bytes in the *data* object to a hexadecimal representation. + Returns a bytes object. + + If the additional argument *sep* is supplied it is used as a separator + between hexadecimal values. + """ + ... + +def unhexlify(data: str | bytes, /) -> bytes: + """ + Convert hexadecimal data to binary representation. Returns bytes string. + (i.e. inverse of hexlify) + """ + ... + +def b2a_base64(data: bytes, /) -> bytes: + """ + Encode binary data in base64 format, as in `RFC 3548 + `_. Returns the encoded data + followed by a newline character if newline is true, as a bytes object. + """ + ... + +def a2b_base64(data: str | bytes, /) -> bytes: + """ + Decode base64-encoded data, ignoring invalid characters in the input. + Conforms to `RFC 2045 s.6.8 `_. + Returns a bytes object. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/bluetooth.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/bluetooth.pyi new file mode 100644 index 0000000000..39b8a07fe3 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/bluetooth.pyi @@ -0,0 +1,871 @@ +""" +Low-level Bluetooth radio functionality. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/bluetooth.html + +This module provides an interface to a Bluetooth controller on a board. +Currently this supports Bluetooth Low Energy (BLE) in Central, Peripheral, +Broadcaster, and Observer roles, as well as GATT Server and Client and L2CAP +connection-oriented-channels. A device may operate in multiple roles +concurrently. Pairing (and bonding) is supported on some ports. + +This API is intended to match the low-level Bluetooth protocol and provide +building-blocks for higher-level abstractions such as specific device types. + +``Note:`` For most applications, we recommend using the higher-level + `aioble library `_. + +``Note:`` This module is still under development and its classes, functions, + methods and constants are subject to change. + +--- +Module: 'bluetooth' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Callable, overload, Final +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf, _IRQ +from typing_extensions import Awaitable, TypeAlias, TypeVar + +FLAG_NOTIFY: Final[int] = 16 +FLAG_READ: Final[int] = 2 +FLAG_WRITE: Final[int] = 8 +FLAG_INDICATE: Final[int] = 32 +FLAG_WRITE_NO_RESPONSE: Final[int] = 4 +_Flag: TypeAlias = int +_Descriptor: TypeAlias = tuple["UUID", _Flag] +_Characteristic: TypeAlias = tuple["UUID", _Flag] | tuple["UUID", _Flag, tuple[_Descriptor, ...]] +_Service: TypeAlias = tuple["UUID", tuple[_Characteristic, ...]] + +class UUID: + """ + class UUID + ---------- + """ + def __init__(self, value: int | str, /) -> None: + """ + Creates a UUID instance with the specified **value**. + + The **value** can be either: + + - A 16-bit integer. e.g. ``0x2908``. + - A 128-bit UUID string. e.g. ``'6E400001-B5A3-F393-E0A9-E50E24DCCA9E'``. + """ + ... + +class BLE: + """ + class BLE + --------- + """ + def gatts_notify(self, value_handle: memoryview, data: bytes, /) -> None: + """ + Sends a notification request to a connected client. + + If *data* is ``None`` (the default), then the current local value (as set + with :meth:`gatts_write `) will be sent. + + Otherwise, if *data* is not ``None``, then that value is sent to the client + as part of the notification. The local value will not be modified. + + **Note:** The notification will be sent regardless of the subscription + status of the client to this characteristic. + """ + ... + def gatts_indicate(self, conn_handle: memoryview, value_handle: memoryview, /) -> None: + """ + Sends a indication request to a connected client. + + If *data* is ``None`` (the default), then the current local value (as set + with :meth:`gatts_write `) will be sent. + + Otherwise, if *data* is not ``None``, then that value is sent to the client + as part of the indication. The local value will not be modified. + + On acknowledgment (or failure, e.g. timeout), the + ``_IRQ_GATTS_INDICATE_DONE`` event will be raised. + + **Note:** The indication will be sent regardless of the subscription + status of the client to this characteristic. + """ + ... + def gattc_write( + self, + conn_handle: memoryview, + value_handle: memoryview, + data: bytes, + mode: int = 0, + /, + ) -> None: + """ + Issue a remote write to a connected server for the specified + characteristic or descriptor handle. + + The argument *mode* specifies the write behaviour, with the currently + supported values being: + + * ``mode=0`` (default) is a write-without-response: the write will + be sent to the remote server but no confirmation will be + returned, and no event will be raised. + * ``mode=1`` is a write-with-response: the remote server is + requested to send a response/acknowledgement that it received the + data. + + If a response is received from the remote server the + ``_IRQ_GATTC_WRITE_DONE`` event will be raised. + """ + ... + def gattc_read(self, conn_handle: memoryview, value_handle: memoryview, /) -> None: + """ + Issue a remote read to a connected server for the specified + characteristic or descriptor handle. + + When a value is available, the ``_IRQ_GATTC_READ_RESULT`` event will be + raised. Additionally, the ``_IRQ_GATTC_READ_DONE`` will be raised. + """ + ... + def gattc_exchange_mtu(self, conn_handle: memoryview, /) -> None: + """ + Initiate MTU exchange with a connected server, using the preferred MTU + set using ``BLE.config(mtu=value)``. + + The ``_IRQ_MTU_EXCHANGED`` event will be raised when MTU exchange + completes. + + **Note:** MTU exchange is typically initiated by the central. When using + the BlueKitchen stack in the central role, it does not support a remote + peripheral initiating the MTU exchange. NimBLE works for both roles. + """ + ... + def gatts_read(self, value_handle: memoryview, /) -> bytes: + """ + Reads the local value for this handle (which has either been written by + :meth:`gatts_write ` or by a remote client). + """ + ... + def gatts_write(self, value_handle: memoryview, data: bytes, send_update: bool = False, /) -> None: + """ + Writes the local value for this handle, which can be read by a client. + + If *send_update* is ``True``, then any subscribed clients will be notified + (or indicated, depending on what they're subscribed to and which operations + the characteristic supports) about this write. + """ + ... + def gatts_set_buffer(self, conn_handle: memoryview, len: int, append: bool = False, /) -> None: + """ + Sets the internal buffer size for a value in bytes. This will limit the + largest possible write that can be received. The default is 20. + + Setting *append* to ``True`` will make all remote writes append to, rather + than replace, the current value. At most *len* bytes can be buffered in + this way. When you use :meth:`gatts_read `, the value will + be cleared after reading. This feature is useful when implementing something + like the Nordic UART Service. + """ + ... + def gatts_register_services(self, services_definition: tuple[_Service, ...], /) -> tuple[tuple[memoryview, ...], ...]: + """ + Configures the server with the specified services, replacing any + existing services. + + *services_definition* is a list of **services**, where each **service** is a + two-element tuple containing a UUID and a list of **characteristics**. + + Each **characteristic** is a two-or-three-element tuple containing a UUID, a + **flags** value, and optionally a list of *descriptors*. + + Each **descriptor** is a two-element tuple containing a UUID and a **flags** + value. + + The **flags** are a bitwise-OR combination of the flags defined below. These + set both the behaviour of the characteristic (or descriptor) as well as the + security and privacy requirements. + + The return value is a list (one element per service) of tuples (each element + is a value handle). Characteristics and descriptor handles are flattened + into the same tuple, in the order that they are defined. + + The following example registers two services (Heart Rate, and Nordic UART):: + + HR_UUID = bluetooth.UUID(0x180D) + HR_CHAR = (bluetooth.UUID(0x2A37), bluetooth.FLAG_READ | bluetooth.FLAG_NOTIFY,) + HR_SERVICE = (HR_UUID, (HR_CHAR,),) + UART_UUID = bluetooth.UUID('6E400001-B5A3-F393-E0A9-E50E24DCCA9E') + UART_TX = (bluetooth.UUID('6E400003-B5A3-F393-E0A9-E50E24DCCA9E'), bluetooth.FLAG_READ | bluetooth.FLAG_NOTIFY,) + UART_RX = (bluetooth.UUID('6E400002-B5A3-F393-E0A9-E50E24DCCA9E'), bluetooth.FLAG_WRITE,) + UART_SERVICE = (UART_UUID, (UART_TX, UART_RX,),) + SERVICES = (HR_SERVICE, UART_SERVICE,) + ( (hr,), (tx, rx,), ) = bt.gatts_register_services(SERVICES) + + The three value handles (``hr``, ``tx``, ``rx``) can be used with + :meth:`gatts_read `, :meth:`gatts_write `, :meth:`gatts_notify `, and + :meth:`gatts_indicate `. + + **Note:** Advertising must be stopped before registering services. + + Available flags for characteristics and descriptors are:: + + from micropython import const + _FLAG_BROADCAST = const(0x0001) + _FLAG_READ = const(0x0002) + _FLAG_WRITE_NO_RESPONSE = const(0x0004) + _FLAG_WRITE = const(0x0008) + _FLAG_NOTIFY = const(0x0010) + _FLAG_INDICATE = const(0x0020) + _FLAG_AUTHENTICATED_SIGNED_WRITE = const(0x0040) + + _FLAG_AUX_WRITE = const(0x0100) + _FLAG_READ_ENCRYPTED = const(0x0200) + _FLAG_READ_AUTHENTICATED = const(0x0400) + _FLAG_READ_AUTHORIZED = const(0x0800) + _FLAG_WRITE_ENCRYPTED = const(0x1000) + _FLAG_WRITE_AUTHENTICATED = const(0x2000) + _FLAG_WRITE_AUTHORIZED = const(0x4000) + + As for the IRQs above, any required constants should be added to your Python code. + """ + ... + def irq(self, handler: Callable[[int, tuple[memoryview, ...]], Any], /) -> _IRQ: + """ + Registers a callback for events from the BLE stack. The *handler* takes two + arguments, ``event`` (which will be one of the codes below) and ``data`` + (which is an event-specific tuple of values). + + **Note:** As an optimisation to prevent unnecessary allocations, the ``addr``, + ``adv_data``, ``char_data``, ``notify_data``, and ``uuid`` entries in the + tuples are read-only memoryview instances pointing to :mod:`bluetooth`'s internal + ringbuffer, and are only valid during the invocation of the IRQ handler + function. If your program needs to save one of these values to access after + the IRQ handler has returned (e.g. by saving it in a class instance or global + variable), then it needs to take a copy of the data, either by using ``bytes()`` + or ``bluetooth.UUID()``, like this:: + + connected_addr = bytes(addr) # equivalently: adv_data, char_data, or notify_data + matched_uuid = bluetooth.UUID(uuid) + + For example, the IRQ handler for a scan result might inspect the ``adv_data`` + to decide if it's the correct device, and only then copy the address data to be + used elsewhere in the program. And to print data from within the IRQ handler, + ``print(bytes(addr))`` will be needed. + + An event handler showing all possible events:: + + def bt_irq(event, data): + if event == _IRQ_CENTRAL_CONNECT: + # A central has connected to this peripheral. + conn_handle, addr_type, addr = data + elif event == _IRQ_CENTRAL_DISCONNECT: + # A central has disconnected from this peripheral. + conn_handle, addr_type, addr = data + elif event == _IRQ_GATTS_WRITE: + # A client has written to this characteristic or descriptor. + conn_handle, attr_handle = data + elif event == _IRQ_GATTS_READ_REQUEST: + # A client has issued a read. Note: this is only supported on STM32. + # Return a non-zero integer to deny the read (see below), or zero (or None) + # to accept the read. + conn_handle, attr_handle = data + elif event == _IRQ_SCAN_RESULT: + # A single scan result. + addr_type, addr, adv_type, rssi, adv_data = data + elif event == _IRQ_SCAN_DONE: + # Scan duration finished or manually stopped. + pass + elif event == _IRQ_PERIPHERAL_CONNECT: + # A successful gap_connect(). + conn_handle, addr_type, addr = data + elif event == _IRQ_PERIPHERAL_DISCONNECT: + # Connected peripheral has disconnected. + conn_handle, addr_type, addr = data + elif event == _IRQ_GATTC_SERVICE_RESULT: + # Called for each service found by gattc_discover_services(). + conn_handle, start_handle, end_handle, uuid = data + elif event == _IRQ_GATTC_SERVICE_DONE: + # Called once service discovery is complete. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, status = data + elif event == _IRQ_GATTC_CHARACTERISTIC_RESULT: + # Called for each characteristic found by gattc_discover_services(). + conn_handle, end_handle, value_handle, properties, uuid = data + elif event == _IRQ_GATTC_CHARACTERISTIC_DONE: + # Called once service discovery is complete. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, status = data + elif event == _IRQ_GATTC_DESCRIPTOR_RESULT: + # Called for each descriptor found by gattc_discover_descriptors(). + conn_handle, dsc_handle, uuid = data + elif event == _IRQ_GATTC_DESCRIPTOR_DONE: + # Called once service discovery is complete. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, status = data + elif event == _IRQ_GATTC_READ_RESULT: + # A gattc_read() has completed. + conn_handle, value_handle, char_data = data + elif event == _IRQ_GATTC_READ_DONE: + # A gattc_read() has completed. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, value_handle, status = data + elif event == _IRQ_GATTC_WRITE_DONE: + # A gattc_write() has completed. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, value_handle, status = data + elif event == _IRQ_GATTC_NOTIFY: + # A server has sent a notify request. + conn_handle, value_handle, notify_data = data + elif event == _IRQ_GATTC_INDICATE: + # A server has sent an indicate request. + conn_handle, value_handle, notify_data = data + elif event == _IRQ_GATTS_INDICATE_DONE: + # A client has acknowledged the indication. + # Note: Status will be zero on successful acknowledgment, implementation-specific value otherwise. + conn_handle, value_handle, status = data + elif event == _IRQ_MTU_EXCHANGED: + # ATT MTU exchange complete (either initiated by us or the remote device). + conn_handle, mtu = data + elif event == _IRQ_L2CAP_ACCEPT: + # A new channel has been accepted. + # Return a non-zero integer to reject the connection, or zero (or None) to accept. + conn_handle, cid, psm, our_mtu, peer_mtu = data + elif event == _IRQ_L2CAP_CONNECT: + # A new channel is now connected (either as a result of connecting or accepting). + conn_handle, cid, psm, our_mtu, peer_mtu = data + elif event == _IRQ_L2CAP_DISCONNECT: + # Existing channel has disconnected (status is zero), or a connection attempt failed (non-zero status). + conn_handle, cid, psm, status = data + elif event == _IRQ_L2CAP_RECV: + # New data is available on the channel. Use l2cap_recvinto to read. + conn_handle, cid = data + elif event == _IRQ_L2CAP_SEND_READY: + # A previous l2cap_send that returned False has now completed and the channel is ready to send again. + # If status is non-zero, then the transmit buffer overflowed and the application should re-send the data. + conn_handle, cid, status = data + elif event == _IRQ_CONNECTION_UPDATE: + # The remote device has updated connection parameters. + conn_handle, conn_interval, conn_latency, supervision_timeout, status = data + elif event == _IRQ_ENCRYPTION_UPDATE: + # The encryption state has changed (likely as a result of pairing or bonding). + conn_handle, encrypted, authenticated, bonded, key_size = data + elif event == _IRQ_GET_SECRET: + # Return a stored secret. + # If key is None, return the index'th value of this sec_type. + # Otherwise return the corresponding value for this sec_type and key. + sec_type, index, key = data + return value + elif event == _IRQ_SET_SECRET: + # Save a secret to the store for this sec_type and key. + sec_type, key, value = data + return True + elif event == _IRQ_PASSKEY_ACTION: + # Respond to a passkey request during pairing. + # See gap_passkey() for details. + # action will be an action that is compatible with the configured "io" config. + # passkey will be non-zero if action is "numeric comparison". + conn_handle, action, passkey = data + + + The event codes are:: + + from micropython import const + _IRQ_CENTRAL_CONNECT = const(1) + _IRQ_CENTRAL_DISCONNECT = const(2) + _IRQ_GATTS_WRITE = const(3) + _IRQ_GATTS_READ_REQUEST = const(4) + _IRQ_SCAN_RESULT = const(5) + _IRQ_SCAN_DONE = const(6) + _IRQ_PERIPHERAL_CONNECT = const(7) + _IRQ_PERIPHERAL_DISCONNECT = const(8) + _IRQ_GATTC_SERVICE_RESULT = const(9) + _IRQ_GATTC_SERVICE_DONE = const(10) + _IRQ_GATTC_CHARACTERISTIC_RESULT = const(11) + _IRQ_GATTC_CHARACTERISTIC_DONE = const(12) + _IRQ_GATTC_DESCRIPTOR_RESULT = const(13) + _IRQ_GATTC_DESCRIPTOR_DONE = const(14) + _IRQ_GATTC_READ_RESULT = const(15) + _IRQ_GATTC_READ_DONE = const(16) + _IRQ_GATTC_WRITE_DONE = const(17) + _IRQ_GATTC_NOTIFY = const(18) + _IRQ_GATTC_INDICATE = const(19) + _IRQ_GATTS_INDICATE_DONE = const(20) + _IRQ_MTU_EXCHANGED = const(21) + _IRQ_L2CAP_ACCEPT = const(22) + _IRQ_L2CAP_CONNECT = const(23) + _IRQ_L2CAP_DISCONNECT = const(24) + _IRQ_L2CAP_RECV = const(25) + _IRQ_L2CAP_SEND_READY = const(26) + _IRQ_CONNECTION_UPDATE = const(27) + _IRQ_ENCRYPTION_UPDATE = const(28) + _IRQ_GET_SECRET = const(29) + _IRQ_SET_SECRET = const(30) + + For the ``_IRQ_GATTS_READ_REQUEST`` event, the available return codes are:: + + _GATTS_NO_ERROR = const(0x00) + _GATTS_ERROR_READ_NOT_PERMITTED = const(0x02) + _GATTS_ERROR_WRITE_NOT_PERMITTED = const(0x03) + _GATTS_ERROR_INSUFFICIENT_AUTHENTICATION = const(0x05) + _GATTS_ERROR_INSUFFICIENT_AUTHORIZATION = const(0x08) + _GATTS_ERROR_INSUFFICIENT_ENCRYPTION = const(0x0f) + + For the ``_IRQ_PASSKEY_ACTION`` event, the available actions are:: + + _PASSKEY_ACTION_NONE = const(0) + _PASSKEY_ACTION_INPUT = const(2) + _PASSKEY_ACTION_DISPLAY = const(3) + _PASSKEY_ACTION_NUMERIC_COMPARISON = const(4) + + In order to save space in the firmware, these constants are not included on the + :mod:`bluetooth` module. Add the ones that you need from the list above to your + program. + """ + ... + def gap_connect( + self, + addr_type: int, + addr: bytes, + scan_duration_ms: int = 2000, + min_conn_interval_us: int | None = None, + max_conn_interval_us: int | None = None, + /, + ) -> None: + """ + Connect to a peripheral. + + See :meth:`gap_scan ` for details about address types. + + To cancel an outstanding connection attempt early, call + ``gap_connect(None)``. + + On success, the ``_IRQ_PERIPHERAL_CONNECT`` event will be raised. If + cancelling a connection attempt, the ``_IRQ_PERIPHERAL_DISCONNECT`` event + will be raised. + + The device will wait up to *scan_duration_ms* to receive an advertising + payload from the device. + + The connection interval can be configured in **micro** seconds using either + or both of *min_conn_interval_us* and *max_conn_interval_us*. Otherwise a + default interval will be chosen, typically between 30000 and 50000 + microseconds. A shorter interval will increase throughput, at the expense + of power usage. + """ + ... + def gap_advertise( + self, + interval_us: int, + adv_data: AnyReadableBuf | None = None, + /, + *, + resp_data: AnyReadableBuf | None = None, + connectable: bool = True, + ) -> None: + """ + Starts advertising at the specified interval (in **micro** seconds). This + interval will be rounded down to the nearest 625us. To stop advertising, set + *interval_us* to ``None``. + + *adv_data* and *resp_data* can be any type that implements the buffer + protocol (e.g. ``bytes``, ``bytearray``, ``str``). *adv_data* is included + in all broadcasts, and *resp_data* is send in reply to an active scan. + + **Note:** if *adv_data* (or *resp_data*) is ``None``, then the data passed + to the previous call to ``gap_advertise`` will be reused. This allows a + broadcaster to resume advertising with just ``gap_advertise(interval_us)``. + To clear the advertising payload pass an empty ``bytes``, i.e. ``b''``. + """ + ... + + @overload + def config(self, param: str, /) -> Any: + """ + Get or set configuration values of the BLE interface. To get a value the + parameter name should be quoted as a string, and just one parameter is + queried at a time. To set values use the keyword syntax, and one or more + parameter can be set at a time. + + Currently supported values are: + + - ``'mac'``: The current address in use, depending on the current address mode. + This returns a tuple of ``(addr_type, addr)``. + + See :meth:`gatts_write ` for details about address type. + + This may only be queried while the interface is currently active. + + - ``'addr_mode'``: Sets the address mode. Values can be: + + * 0x00 - PUBLIC - Use the controller's public address. + * 0x01 - RANDOM - Use a generated static address. + * 0x02 - RPA - Use resolvable private addresses. + * 0x03 - NRPA - Use non-resolvable private addresses. + + By default the interface mode will use a PUBLIC address if available, otherwise + it will use a RANDOM address. + + - ``'gap_name'``: Get/set the GAP device name used by service 0x1800, + characteristic 0x2a00. This can be set at any time and changed multiple + times. + + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store + incoming events. This buffer is global to the entire BLE driver and so + handles incoming data for all events, including all characteristics. + Increasing this allows better handling of bursty incoming data (for + example scan results) and the ability to receive larger characteristic values. + + - ``'mtu'``: Get/set the MTU that will be used during a ATT MTU exchange. The + resulting MTU will be the minimum of this and the remote device's MTU. + ATT MTU exchange will not happen automatically (unless the remote device initiates + it), and must be manually initiated with + :meth:`gattc_exchange_mtu`. + Use the ``_IRQ_MTU_EXCHANGED`` event to discover the MTU for a given connection. + + - ``'bond'``: Sets whether bonding will be enabled during pairing. When + enabled, pairing requests will set the "bond" flag and the keys will be stored + by both devices. + + - ``'mitm'``: Sets whether MITM-protection is required for pairing. + + - ``'io'``: Sets the I/O capabilities of this device. + + Available options are:: + + _IO_CAPABILITY_DISPLAY_ONLY = const(0) + _IO_CAPABILITY_DISPLAY_YESNO = const(1) + _IO_CAPABILITY_KEYBOARD_ONLY = const(2) + _IO_CAPABILITY_NO_INPUT_OUTPUT = const(3) + _IO_CAPABILITY_KEYBOARD_DISPLAY = const(4) + + - ``'le_secure'``: Sets whether "LE Secure" pairing is required. Default is + false (i.e. allow "Legacy Pairing"). + """ + + @overload + def config(self, **kwargs) -> None: + """ + Get or set configuration values of the BLE interface. To get a value the + parameter name should be quoted as a string, and just one parameter is + queried at a time. To set values use the keyword syntax, and one or more + parameter can be set at a time. + + Currently supported values are: + + - ``'mac'``: The current address in use, depending on the current address mode. + This returns a tuple of ``(addr_type, addr)``. + + See :meth:`gatts_write ` for details about address type. + + This may only be queried while the interface is currently active. + + - ``'addr_mode'``: Sets the address mode. Values can be: + + * 0x00 - PUBLIC - Use the controller's public address. + * 0x01 - RANDOM - Use a generated static address. + * 0x02 - RPA - Use resolvable private addresses. + * 0x03 - NRPA - Use non-resolvable private addresses. + + By default the interface mode will use a PUBLIC address if available, otherwise + it will use a RANDOM address. + + - ``'gap_name'``: Get/set the GAP device name used by service 0x1800, + characteristic 0x2a00. This can be set at any time and changed multiple + times. + + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store + incoming events. This buffer is global to the entire BLE driver and so + handles incoming data for all events, including all characteristics. + Increasing this allows better handling of bursty incoming data (for + example scan results) and the ability to receive larger characteristic values. + + - ``'mtu'``: Get/set the MTU that will be used during a ATT MTU exchange. The + resulting MTU will be the minimum of this and the remote device's MTU. + ATT MTU exchange will not happen automatically (unless the remote device initiates + it), and must be manually initiated with + :meth:`gattc_exchange_mtu`. + Use the ``_IRQ_MTU_EXCHANGED`` event to discover the MTU for a given connection. + + - ``'bond'``: Sets whether bonding will be enabled during pairing. When + enabled, pairing requests will set the "bond" flag and the keys will be stored + by both devices. + + - ``'mitm'``: Sets whether MITM-protection is required for pairing. + + - ``'io'``: Sets the I/O capabilities of this device. + + Available options are:: + + _IO_CAPABILITY_DISPLAY_ONLY = const(0) + _IO_CAPABILITY_DISPLAY_YESNO = const(1) + _IO_CAPABILITY_KEYBOARD_ONLY = const(2) + _IO_CAPABILITY_NO_INPUT_OUTPUT = const(3) + _IO_CAPABILITY_KEYBOARD_DISPLAY = const(4) + + - ``'le_secure'``: Sets whether "LE Secure" pairing is required. Default is + false (i.e. allow "Legacy Pairing"). + """ + + @overload + def config(self, param: str, /) -> Any: + """ + Get or set configuration values of the BLE interface. To get a value the + parameter name should be quoted as a string, and just one parameter is + queried at a time. To set values use the keyword syntax, and one or more + parameter can be set at a time. + + Currently supported values are: + + - ``'mac'``: The current address in use, depending on the current address mode. + This returns a tuple of ``(addr_type, addr)``. + + See :meth:`gatts_write ` for details about address type. + + This may only be queried while the interface is currently active. + + - ``'addr_mode'``: Sets the address mode. Values can be: + + * 0x00 - PUBLIC - Use the controller's public address. + * 0x01 - RANDOM - Use a generated static address. + * 0x02 - RPA - Use resolvable private addresses. + * 0x03 - NRPA - Use non-resolvable private addresses. + + By default the interface mode will use a PUBLIC address if available, otherwise + it will use a RANDOM address. + + - ``'gap_name'``: Get/set the GAP device name used by service 0x1800, + characteristic 0x2a00. This can be set at any time and changed multiple + times. + + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store + incoming events. This buffer is global to the entire BLE driver and so + handles incoming data for all events, including all characteristics. + Increasing this allows better handling of bursty incoming data (for + example scan results) and the ability to receive larger characteristic values. + + - ``'mtu'``: Get/set the MTU that will be used during a ATT MTU exchange. The + resulting MTU will be the minimum of this and the remote device's MTU. + ATT MTU exchange will not happen automatically (unless the remote device initiates + it), and must be manually initiated with + :meth:`gattc_exchange_mtu`. + Use the ``_IRQ_MTU_EXCHANGED`` event to discover the MTU for a given connection. + + - ``'bond'``: Sets whether bonding will be enabled during pairing. When + enabled, pairing requests will set the "bond" flag and the keys will be stored + by both devices. + + - ``'mitm'``: Sets whether MITM-protection is required for pairing. + + - ``'io'``: Sets the I/O capabilities of this device. + + Available options are:: + + _IO_CAPABILITY_DISPLAY_ONLY = const(0) + _IO_CAPABILITY_DISPLAY_YESNO = const(1) + _IO_CAPABILITY_KEYBOARD_ONLY = const(2) + _IO_CAPABILITY_NO_INPUT_OUTPUT = const(3) + _IO_CAPABILITY_KEYBOARD_DISPLAY = const(4) + + - ``'le_secure'``: Sets whether "LE Secure" pairing is required. Default is + false (i.e. allow "Legacy Pairing"). + """ + + @overload + def config(self, **kwargs) -> None: + """ + Get or set configuration values of the BLE interface. To get a value the + parameter name should be quoted as a string, and just one parameter is + queried at a time. To set values use the keyword syntax, and one or more + parameter can be set at a time. + + Currently supported values are: + + - ``'mac'``: The current address in use, depending on the current address mode. + This returns a tuple of ``(addr_type, addr)``. + + See :meth:`gatts_write ` for details about address type. + + This may only be queried while the interface is currently active. + + - ``'addr_mode'``: Sets the address mode. Values can be: + + * 0x00 - PUBLIC - Use the controller's public address. + * 0x01 - RANDOM - Use a generated static address. + * 0x02 - RPA - Use resolvable private addresses. + * 0x03 - NRPA - Use non-resolvable private addresses. + + By default the interface mode will use a PUBLIC address if available, otherwise + it will use a RANDOM address. + + - ``'gap_name'``: Get/set the GAP device name used by service 0x1800, + characteristic 0x2a00. This can be set at any time and changed multiple + times. + + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store + incoming events. This buffer is global to the entire BLE driver and so + handles incoming data for all events, including all characteristics. + Increasing this allows better handling of bursty incoming data (for + example scan results) and the ability to receive larger characteristic values. + + - ``'mtu'``: Get/set the MTU that will be used during a ATT MTU exchange. The + resulting MTU will be the minimum of this and the remote device's MTU. + ATT MTU exchange will not happen automatically (unless the remote device initiates + it), and must be manually initiated with + :meth:`gattc_exchange_mtu`. + Use the ``_IRQ_MTU_EXCHANGED`` event to discover the MTU for a given connection. + + - ``'bond'``: Sets whether bonding will be enabled during pairing. When + enabled, pairing requests will set the "bond" flag and the keys will be stored + by both devices. + + - ``'mitm'``: Sets whether MITM-protection is required for pairing. + + - ``'io'``: Sets the I/O capabilities of this device. + + Available options are:: + + _IO_CAPABILITY_DISPLAY_ONLY = const(0) + _IO_CAPABILITY_DISPLAY_YESNO = const(1) + _IO_CAPABILITY_KEYBOARD_ONLY = const(2) + _IO_CAPABILITY_NO_INPUT_OUTPUT = const(3) + _IO_CAPABILITY_KEYBOARD_DISPLAY = const(4) + + - ``'le_secure'``: Sets whether "LE Secure" pairing is required. Default is + false (i.e. allow "Legacy Pairing"). + """ + + @overload + def active(self) -> bool: + """ + Optionally changes the active state of the BLE radio, and returns the + current state. + + The radio must be made active before using any other methods on this class. + """ + + @overload + def active(self, active: bool, /) -> None: + """ + Optionally changes the active state of the BLE radio, and returns the + current state. + + The radio must be made active before using any other methods on this class. + """ + + @overload + def active(self) -> bool: + """ + Optionally changes the active state of the BLE radio, and returns the + current state. + + The radio must be made active before using any other methods on this class. + """ + + @overload + def active(self, active: bool, /) -> None: + """ + Optionally changes the active state of the BLE radio, and returns the + current state. + + The radio must be made active before using any other methods on this class. + """ + def gattc_discover_services(self, conn_handle: memoryview, uuid: UUID | None = None, /) -> None: + """ + Query a connected server for its services. + + Optionally specify a service *uuid* to query for that service only. + + For each service discovered, the ``_IRQ_GATTC_SERVICE_RESULT`` event will + be raised, followed by ``_IRQ_GATTC_SERVICE_DONE`` on completion. + """ + ... + def gap_disconnect(self, conn_handle: memoryview, /) -> bool: + """ + Disconnect the specified connection handle. This can either be a + central that has connected to this device (if acting as a peripheral) + or a peripheral that was previously connected to by this device (if acting + as a central). + + On success, the ``_IRQ_PERIPHERAL_DISCONNECT`` or ``_IRQ_CENTRAL_DISCONNECT`` + event will be raised. + + Returns ``False`` if the connection handle wasn't connected, and ``True`` + otherwise. + """ + ... + def gattc_discover_descriptors(self, conn_handle: memoryview, start_handle: int, end_handle: int, /) -> None: + """ + Query a connected server for descriptors in the specified range. + + For each descriptor discovered, the ``_IRQ_GATTC_DESCRIPTOR_RESULT`` event + will be raised, followed by ``_IRQ_GATTC_DESCRIPTOR_DONE`` on completion. + """ + ... + def gattc_discover_characteristics( + self, + conn_handle: memoryview, + start_handle: int, + end_handle: int, + uuid: UUID | None = None, + /, + ) -> None: + """ + Query a connected server for characteristics in the specified range. + + Optionally specify a characteristic *uuid* to query for that + characteristic only. + + You can use ``start_handle=1``, ``end_handle=0xffff`` to search for a + characteristic in any service. + + For each characteristic discovered, the ``_IRQ_GATTC_CHARACTERISTIC_RESULT`` + event will be raised, followed by ``_IRQ_GATTC_CHARACTERISTIC_DONE`` on completion. + """ + ... + def gap_scan( + self, + duration_ms: int, + interval_us: int = 1280000, + window_us: int = 11250, + active: bool = False, + /, + ) -> None: + """ + Run a scan operation lasting for the specified duration (in **milli** seconds). + + To scan indefinitely, set *duration_ms* to ``0``. + + To stop scanning, set *duration_ms* to ``None``. + + Use *interval_us* and *window_us* to optionally configure the duty cycle. + The scanner will run for *window_us* **micro** seconds every *interval_us* + **micro** seconds for a total of *duration_ms* **milli** seconds. The default + interval and window are 1.28 seconds and 11.25 milliseconds respectively + (background scanning). + + For each scan result the ``_IRQ_SCAN_RESULT`` event will be raised, with event + data ``(addr_type, addr, adv_type, rssi, adv_data)``. + + ``addr_type`` values indicate public or random addresses: + * 0x00 - PUBLIC + * 0x01 - RANDOM (either static, RPA, or NRPA, the type is encoded in the address itself) + + ``adv_type`` values correspond to the Bluetooth Specification: + + * 0x00 - ADV_IND - connectable and scannable undirected advertising + * 0x01 - ADV_DIRECT_IND - connectable directed advertising + * 0x02 - ADV_SCAN_IND - scannable undirected advertising + * 0x03 - ADV_NONCONN_IND - non-connectable undirected advertising + * 0x04 - SCAN_RSP - scan response + + ``active`` can be set ``True`` if you want to receive scan responses in the results. + + When scanning is stopped (either due to the duration finishing or when + explicitly stopped), the ``_IRQ_SCAN_DONE`` event will be raised. + """ + ... + def __init__(self) -> None: + """ + Returns the singleton BLE object. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/cmath.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/cmath.pyi new file mode 100644 index 0000000000..150affd8cf --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/cmath.pyi @@ -0,0 +1,84 @@ +""" +Mathematical functions for complex numbers. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/cmath.html + +CPython module: :mod:`python:cmath` https://docs.python.org/3/library/cmath.html . + +The ``cmath`` module provides some basic mathematical functions for +working with complex numbers. + +Availability: not available on WiPy and ESP8266. Floating point support +required for this module. + +--- +Module: 'cmath' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import SupportsComplex, SupportsFloat, SupportsIndex, Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_C: TypeAlias = SupportsFloat | SupportsComplex | SupportsIndex | complex + +e: float = 2.7182818 +"""base of the natural logarithm""" +pi: float = 3.1415928 +"""the ratio of a circle's circumference to its diameter""" + +def polar(z: _C, /) -> Tuple: + """ + Returns, as a tuple, the polar form of ``z``. + """ + ... + +def sqrt(z: _C, /) -> complex: + """ + Return the square-root of ``z``. + """ + ... + +def rect(r: float, phi: float, /) -> float: + """ + Returns the complex number with modulus ``r`` and phase ``phi``. + """ + ... + +def sin(z: _C, /) -> float: + """ + Return the sine of ``z``. + """ + ... + +def exp(z: _C, /) -> float: + """ + Return the exponential of ``z``. + """ + ... + +def cos(z: _C, /) -> float: + """ + Return the cosine of ``z``. + """ + ... + +def phase(z: _C, /) -> float: + """ + Returns the phase of the number ``z``, in the range (-pi, +pi]. + """ + ... + +def log(z: _C, /) -> float: + """ + Return the natural logarithm of ``z``. The branch cut is along the negative real axis. + """ + ... + +def log10(z: _C, /) -> float: + """ + Return the base-10 logarithm of ``z``. The branch cut is along the negative real axis. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/cryptolib.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/cryptolib.pyi new file mode 100644 index 0000000000..a8d1e5c469 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/cryptolib.pyi @@ -0,0 +1,165 @@ +""" +Cryptographic ciphers. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/cryptolib.html + +--- +Module: 'cryptolib' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf +from typing import overload +from typing_extensions import Awaitable, TypeAlias, TypeVar + +class aes: + """ + .. class:: aes + """ + + @overload + def encrypt(self, in_buf: AnyReadableBuf, /) -> bytes: + """ + Encrypt *in_buf*. If no *out_buf* is given result is returned as a + newly allocated `bytes` object. Otherwise, result is written into + mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer + to the same mutable buffer, in which case data is encrypted in-place. + """ + + @overload + def encrypt(self, in_buf: AnyReadableBuf, out_buf: AnyWritableBuf, /) -> None: + """ + Encrypt *in_buf*. If no *out_buf* is given result is returned as a + newly allocated `bytes` object. Otherwise, result is written into + mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer + to the same mutable buffer, in which case data is encrypted in-place. + """ + + @overload + def encrypt(self, in_buf: AnyReadableBuf, /) -> bytes: + """ + Encrypt *in_buf*. If no *out_buf* is given result is returned as a + newly allocated `bytes` object. Otherwise, result is written into + mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer + to the same mutable buffer, in which case data is encrypted in-place. + """ + + @overload + def encrypt(self, in_buf: AnyReadableBuf, out_buf: AnyWritableBuf, /) -> None: + """ + Encrypt *in_buf*. If no *out_buf* is given result is returned as a + newly allocated `bytes` object. Otherwise, result is written into + mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer + to the same mutable buffer, in which case data is encrypted in-place. + """ + + @overload + def decrypt(self, in_buf: AnyReadableBuf, /) -> bytes: + """ + Like `encrypt()`, but for decryption. + """ + + @overload + def decrypt(self, in_buf: AnyReadableBuf, out_buf: AnyWritableBuf, /) -> None: + """ + Like `encrypt()`, but for decryption. + """ + + @overload + def decrypt(self, in_buf: AnyReadableBuf, /) -> bytes: + """ + Like `encrypt()`, but for decryption. + """ + + @overload + def decrypt(self, in_buf: AnyReadableBuf, out_buf: AnyWritableBuf, /) -> None: + """ + Like `encrypt()`, but for decryption. + """ + + @overload + def __init__(self, key: AnyReadableBuf, mode: int, /): + """ + Initialize cipher object, suitable for encryption/decryption. Note: + after initialization, cipher object can be use only either for + encryption or decryption. Running decrypt() operation after encrypt() + or vice versa is not supported. + + Parameters are: + + * *key* is an encryption/decryption key (bytes-like). + * *mode* is: + + * ``1`` (or ``cryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB). + * ``2`` (or ``cryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC). + * ``6`` (or ``cryptolib.MODE_CTR`` if it exists) for Counter mode (CTR). + + * *IV* is an initialization vector for CBC mode. + * For Counter mode, *IV* is the initial value for the counter. + """ + + @overload + def __init__(self, key: AnyReadableBuf, mode: int, IV: AnyReadableBuf, /): + """ + Initialize cipher object, suitable for encryption/decryption. Note: + after initialization, cipher object can be use only either for + encryption or decryption. Running decrypt() operation after encrypt() + or vice versa is not supported. + + Parameters are: + + * *key* is an encryption/decryption key (bytes-like). + * *mode* is: + + * ``1`` (or ``cryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB). + * ``2`` (or ``cryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC). + * ``6`` (or ``cryptolib.MODE_CTR`` if it exists) for Counter mode (CTR). + + * *IV* is an initialization vector for CBC mode. + * For Counter mode, *IV* is the initial value for the counter. + """ + + @overload + def __init__(self, key: AnyReadableBuf, mode: int, /): + """ + Initialize cipher object, suitable for encryption/decryption. Note: + after initialization, cipher object can be use only either for + encryption or decryption. Running decrypt() operation after encrypt() + or vice versa is not supported. + + Parameters are: + + * *key* is an encryption/decryption key (bytes-like). + * *mode* is: + + * ``1`` (or ``cryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB). + * ``2`` (or ``cryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC). + * ``6`` (or ``cryptolib.MODE_CTR`` if it exists) for Counter mode (CTR). + + * *IV* is an initialization vector for CBC mode. + * For Counter mode, *IV* is the initial value for the counter. + """ + + @overload + def __init__(self, key: AnyReadableBuf, mode: int, IV: AnyReadableBuf, /): + """ + Initialize cipher object, suitable for encryption/decryption. Note: + after initialization, cipher object can be use only either for + encryption or decryption. Running decrypt() operation after encrypt() + or vice versa is not supported. + + Parameters are: + + * *key* is an encryption/decryption key (bytes-like). + * *mode* is: + + * ``1`` (or ``cryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB). + * ``2`` (or ``cryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC). + * ``6`` (or ``cryptolib.MODE_CTR`` if it exists) for Counter mode (CTR). + + * *IV* is an initialization vector for CBC mode. + * For Counter mode, *IV* is the initial value for the counter. + """ diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/deflate.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/deflate.pyi new file mode 100644 index 0000000000..803f8dcf3a --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/deflate.pyi @@ -0,0 +1,88 @@ +""" +Deflate compression & decompression. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/deflate.html + +This module allows compression and decompression of binary data with the +`DEFLATE algorithm `_ +(commonly used in the zlib library and gzip archiver). + +**Availability:** + +* Added in MicroPython v1.21. + +* Decompression: Enabled via the ``MICROPY_PY_DEFLATE`` build option, on by default + on ports with the "extra features" level or higher (which is most boards). + +* Compression: Enabled via the ``MICROPY_PY_DEFLATE_COMPRESS`` build option, on + by default on ports with the "full features" level or higher (generally this means + you need to build your own firmware to enable this). + +--- +Module: 'deflate' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar + +GZIP: Final[int] = 3 +"""Supported values for the *format* parameter.""" +RAW: Final[int] = 1 +"""Supported values for the *format* parameter.""" +ZLIB: Final[int] = 2 +"""Supported values for the *format* parameter.""" +AUTO: Final[int] = 0 +"""Supported values for the *format* parameter.""" + +class DeflateIO: + """ + This class can be used to wrap a *stream* which is any + :term:`stream-like ` object such as a file, socket, or stream + (including :class:`io.BytesIO`). It is itself a stream and implements the + standard read/readinto/write/close methods. + + The *stream* must be a blocking stream. Non-blocking streams are currently + not supported. + + The *format* can be set to any of the constants defined below, and defaults + to ``AUTO`` which for decompressing will auto-detect gzip or zlib streams, + and for compressing it will generate a raw stream. + + The *wbits* parameter sets the base-2 logarithm of the DEFLATE dictionary + window size. So for example, setting *wbits* to ``10`` sets the window size + to 1024 bytes. Valid values are ``5`` to ``15`` inclusive (corresponding to + window sizes of 32 to 32k bytes). + + If *wbits* is set to ``0`` (the default), then for compression a window size + of 256 bytes will be used (as if *wbits* was set to 8). For decompression, it + depends on the format: + + * ``RAW`` will use 256 bytes (corresponding to *wbits* set to 8). + * ``ZLIB`` (or ``AUTO`` with zlib detected) will use the value from the zlib + header. + * ``GZIP`` (or ``AUTO`` with gzip detected) will use 32 kilobytes + (corresponding to *wbits* set to 15). + + See the :ref:`window size ` notes below for more information + about the window size, zlib, and gzip streams. + + If *close* is set to ``True`` then the underlying stream will be closed + automatically when the :class:`deflate.DeflateIO` stream is closed. This is + useful if you want to return a :class:`deflate.DeflateIO` stream that wraps + another stream and not have the caller need to know about managing the + underlying stream. + + If compression is enabled, a given :class:`deflate.DeflateIO` instance + supports both reading and writing. For example, a bidirectional stream like + a socket can be wrapped, which allows for compression/decompression in both + directions. + """ + def readline(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, stream, format=AUTO, wbits=0, close=False, /) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/dht.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/dht.pyi new file mode 100644 index 0000000000..7ac764e6b8 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/dht.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete + +class DHTBase: + pin: Incomplete + buf: Incomplete + def __init__(self, pin) -> None: ... + def measure(self) -> None: ... + +class DHT11(DHTBase): + def humidity(self): ... + def temperature(self): ... + +class DHT22(DHTBase): + def humidity(self): ... + def temperature(self): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ds18x20.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ds18x20.pyi new file mode 100644 index 0000000000..ed17bc1b78 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ds18x20.pyi @@ -0,0 +1,16 @@ +from _typeshed import Incomplete +from micropython import const as const + +_CONVERT: int +_RD_SCRATCH: int +_WR_SCRATCH: int + +class DS18X20: + ow: Incomplete + buf: Incomplete + def __init__(self, onewire) -> None: ... + def scan(self): ... + def convert_temp(self) -> None: ... + def read_scratch(self, rom): ... + def write_scratch(self, rom, buf) -> None: ... + def read_temp(self, rom): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/errno.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/errno.pyi new file mode 100644 index 0000000000..1910b435fe --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/errno.pyi @@ -0,0 +1,97 @@ +""" +System error codes. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/errno.html + +CPython module: :mod:`python:errno` https://docs.python.org/3/library/errno.html . + +This module provides access to symbolic error codes for `OSError` exception. +A particular inventory of codes depends on :term:`MicroPython port`. + +--- +Module: 'errno' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Dict, Final +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar + +ENOBUFS: Final[int] = 105 +"""No buffer space available""" +ENODEV: Final[int] = 19 +"""No such device""" +ENOENT: Final[int] = 2 +"""No such file or directory""" +EISDIR: Final[int] = 21 +"""Is a directory""" +EIO: Final[int] = 5 +"""I/O error""" +EINVAL: Final[int] = 22 +"""Invalid argument""" +EPERM: Final[int] = 1 +"""Operation not permitted""" +ETIMEDOUT: Final[int] = 110 +"""Connection timed out""" +ENOMEM: Final[int] = 12 +"""Out of memory""" +EOPNOTSUPP: Final[int] = 95 +"""Operation not supported""" +ENOTCONN: Final[int] = 107 +"""Transport endpoint is not connected""" +errorcode: dict = {} +"""\ +Dictionary mapping numeric error codes to strings with symbolic error +code (see above):: + +>>> print(errno.errorcode[errno.EEXIST]) +EEXIST +""" +EAGAIN: Final[int] = 11 +"""\ +Error codes, based on ANSI C/POSIX standard. All error codes start with +"E". As mentioned above, inventory of the codes depends on +:term:`MicroPython port`. Errors are usually accessible as ``exc.errno`` +where ``exc`` is an instance of `OSError`. Usage example:: + +try: +os.mkdir("my_dir") +except OSError as exc: +if exc.errno == errno.EEXIST: +print("Directory already exists") +""" +EALREADY: Final[int] = 114 +"""Operation already in progress""" +EBADF: Final[int] = 9 +"""Bad file descriptor""" +EADDRINUSE: Final[int] = 98 +"""Address already in use""" +EACCES: Final[int] = 13 +"""Permission denied""" +EINPROGRESS: Final[int] = 115 +"""Operation now in progress""" +EEXIST: Final[int] = 17 +"""\ +Error codes, based on ANSI C/POSIX standard. All error codes start with +"E". As mentioned above, inventory of the codes depends on +:term:`MicroPython port`. Errors are usually accessible as ``exc.errno`` +where ``exc`` is an instance of `OSError`. Usage example:: + +try: +os.mkdir("my_dir") +except OSError as exc: +if exc.errno == errno.EEXIST: +print("Directory already exists") +""" +EHOSTUNREACH: Final[int] = 113 +"""Host is unreachable""" +ECONNABORTED: Final[int] = 103 +"""Connection aborted""" +ECONNRESET: Final[int] = 104 +"""Connection reset by peer""" +ECONNREFUSED: Final[int] = 111 +"""Connection refused""" +ENOTSUP: Final[int] = ... +"""Operation not supported""" diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/framebuf.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/framebuf.pyi new file mode 100644 index 0000000000..50b24ec360 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/framebuf.pyi @@ -0,0 +1,247 @@ +""" +Frame buffer manipulation. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/framebuf.html + +This module provides a general frame buffer which can be used to create +bitmap images, which can then be sent to a display. + +--- +Module: 'framebuf' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Optional, Union, overload, Final +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf +from typing_extensions import Awaitable, TypeAlias, TypeVar + +MONO_HMSB: Final[int] = 4 +"""\ +Monochrome (1-bit) color format +This defines a mapping where the bits in a byte are horizontally mapped. +Each byte occupies 8 horizontal pixels with bit 0 being the leftmost. +Subsequent bytes appear at successive horizontal locations until the +rightmost edge is reached. Further bytes are rendered on the next row, one +pixel lower. +""" +MONO_HLSB: Final[int] = 3 +"""\ +Monochrome (1-bit) color format +This defines a mapping where the bits in a byte are horizontally mapped. +Each byte occupies 8 horizontal pixels with bit 7 being the leftmost. +Subsequent bytes appear at successive horizontal locations until the +rightmost edge is reached. Further bytes are rendered on the next row, one +pixel lower. +""" +RGB565: Final[int] = 1 +"""Red Green Blue (16-bit, 5+6+5) color format""" +MONO_VLSB: Final[int] = 0 +"""\ +Monochrome (1-bit) color format +This defines a mapping where the bits in a byte are vertically mapped with +bit 0 being nearest the top of the screen. Consequently each byte occupies +8 vertical pixels. Subsequent bytes appear at successive horizontal +locations until the rightmost edge is reached. Further bytes are rendered +at locations starting at the leftmost edge, 8 pixels lower. +""" +MVLSB: Final[int] = 0 +GS2_HMSB: Final[int] = 5 +"""Grayscale (2-bit) color format""" +GS8: Final[int] = 6 +"""Grayscale (8-bit) color format""" +GS4_HMSB: Final[int] = 2 +"""Grayscale (4-bit) color format""" + +def FrameBuffer1(*args, **kwargs) -> Incomplete: ... + +class FrameBuffer: + """ + The FrameBuffer class provides a pixel buffer which can be drawn upon with + pixels, lines, rectangles, text and even other FrameBuffer's. It is useful + when generating output for displays. + + For example:: + + import framebuf + + # FrameBuffer needs 2 bytes for every RGB565 pixel + fbuf = framebuf.FrameBuffer(bytearray(100 * 10 * 2), 100, 10, framebuf.RGB565) + + fbuf.fill(0) + fbuf.text('MicroPython!', 0, 0, 0xffff) + fbuf.hline(0, 9, 96, 0xffff) + """ + def poly(self, x, y, coords, c, f: Union[bool, int] = False, /) -> Incomplete: + """ + Given a list of coordinates, draw an arbitrary (convex or concave) closed + polygon at the given x, y location using the given color. + + The *coords* must be specified as a :mod:`array` of integers, e.g. + ``array('h', [x0, y0, x1, y1, ... xn, yn])``. + + The optional *f* parameter can be set to ``True`` to fill the polygon. + Otherwise just a one pixel outline is drawn. + """ + ... + def vline(self, x: int, y: int, h: int, c: int, /) -> None: + """ + Draw a line from a set of coordinates using the given color and + a thickness of 1 pixel. The `line` method draws the line up to + a second set of coordinates whereas the `hline` and `vline` + methods draw horizontal and vertical lines respectively up to + a given length. + """ + ... + + @overload + def pixel(self, x: int, y: int, /) -> int: + """ + If *c* is not given, get the color value of the specified pixel. + If *c* is given, set the specified pixel to the given color. + """ + + @overload + def pixel(self, x: int, y: int, c: int, /) -> None: + """ + If *c* is not given, get the color value of the specified pixel. + If *c* is given, set the specified pixel to the given color. + """ + def text(self, s: str, x: int, y: int, c: int = 1, /) -> None: + """ + Write text to the FrameBuffer using the coordinates as the upper-left + corner of the text. The color of the text can be defined by the optional + argument but is otherwise a default value of 1. All characters have + dimensions of 8x8 pixels and there is currently no way to change the font. + """ + ... + def rect(self, x: int, y: int, w: int, h: int, c: int, f: Union[bool, int] = False, /) -> None: + """ + Draw a rectangle at the given location, size and color. + + The optional *f* parameter can be set to ``True`` to fill the rectangle. + Otherwise just a one pixel outline is drawn. + """ + ... + def scroll(self, xstep: int, ystep: int, /) -> None: + """ + Shift the contents of the FrameBuffer by the given vector. This may + leave a footprint of the previous colors in the FrameBuffer. + """ + ... + def ellipse(self, x, y, xr, yr, c, f: Union[bool, int] = False, m: Optional[int] = None) -> None: + """ + Draw an ellipse at the given location. Radii *xr* and *yr* define the + geometry; equal values cause a circle to be drawn. The *c* parameter + defines the color. + + The optional *f* parameter can be set to ``True`` to fill the ellipse. + Otherwise just a one pixel outline is drawn. + + The optional *m* parameter enables drawing to be restricted to certain + quadrants of the ellipse. The LS four bits determine which quadrants are + to be drawn, with bit 0 specifying Q1, b1 Q2, b2 Q3 and b3 Q4. Quadrants + are numbered counterclockwise with Q1 being top right. + """ + ... + def line(self, x1: int, y1: int, x2: int, y2: int, c: int, /) -> None: + """ + Draw a line from a set of coordinates using the given color and + a thickness of 1 pixel. The `line` method draws the line up to + a second set of coordinates whereas the `hline` and `vline` + methods draw horizontal and vertical lines respectively up to + a given length. + """ + ... + def blit( + self, + fbuf: FrameBuffer, + x: int, + y: int, + key: int = -1, + palette: Optional[bytes] = None, + /, + ) -> None: + """ + Draw another FrameBuffer on top of the current one at the given coordinates. + If *key* is specified then it should be a color integer and the + corresponding color will be considered transparent: all pixels with that + color value will not be drawn. (If the *palette* is specified then the *key* + is compared to the value from *palette*, not to the value directly from + *fbuf*.) + + *fbuf* can be another FrameBuffer instance, or a tuple or list of the form:: + + (buffer, width, height, format) + + or:: + + (buffer, width, height, format, stride) + + This matches the signature of the FrameBuffer constructor, and the elements + of the tuple/list are the same as the arguments to the constructor except that + the *buffer* here can be read-only. + + The *palette* argument enables blitting between FrameBuffers with differing + formats. Typical usage is to render a monochrome or grayscale glyph/icon to + a color display. The *palette* is a FrameBuffer instance whose format is + that of the current FrameBuffer. The *palette* height is one pixel and its + pixel width is the number of colors in the source FrameBuffer. The *palette* + for an N-bit source needs 2**N pixels; the *palette* for a monochrome source + would have 2 pixels representing background and foreground colors. The + application assigns a color to each pixel in the *palette*. The color of the + current pixel will be that of that *palette* pixel whose x position is the + color of the corresponding source pixel. + """ + ... + def hline(self, x: int, y: int, w: int, c: int, /) -> None: + """ + Draw a line from a set of coordinates using the given color and + a thickness of 1 pixel. The `line` method draws the line up to + a second set of coordinates whereas the `hline` and `vline` + methods draw horizontal and vertical lines respectively up to + a given length. + """ + ... + def fill(self, c: int, /) -> None: + """ + Fill the entire FrameBuffer with the specified color. + """ + ... + def fill_rect(self, *args, **kwargs) -> Incomplete: ... + def __init__( + self, + buffer: AnyWritableBuf, + width: int, + height: int, + format: int, + stride: int = ..., + /, + ) -> None: + """ + Construct a FrameBuffer object. The parameters are: + + - *buffer* is an object with a buffer protocol which must be large + enough to contain every pixel defined by the width, height and + format of the FrameBuffer. + - *width* is the width of the FrameBuffer in pixels + - *height* is the height of the FrameBuffer in pixels + - *format* specifies the type of pixel used in the FrameBuffer; + permissible values are listed under Constants below. These set the + number of bits used to encode a color value and the layout of these + bits in *buffer*. + Where a color value c is passed to a method, c is a small integer + with an encoding that is dependent on the format of the FrameBuffer. + - *stride* is the number of pixels between each horizontal line + of pixels in the FrameBuffer. This defaults to *width* but may + need adjustments when implementing a FrameBuffer within another + larger FrameBuffer or screen. The *buffer* size must accommodate + an increased step size. + + One must specify valid *buffer*, *width*, *height*, *format* and + optionally *stride*. Invalid *buffer* size or dimensions may lead to + unexpected errors. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/gc.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/gc.pyi new file mode 100644 index 0000000000..d1a11bbe1e --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/gc.pyi @@ -0,0 +1,112 @@ +""" +Control the garbage collector. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/gc.html + +CPython module: :mod:`python:gc` https://docs.python.org/3/library/gc.html . + +--- +Module: 'gc' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import overload +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def mem_alloc() -> int: + """ + Return the number of bytes of heap RAM that are allocated by Python code. + + Admonition:Difference to CPython + :class: attention + + This function is MicroPython extension. + """ + ... + +def isenabled(*args, **kwargs) -> Incomplete: ... +def mem_free() -> int: + """ + Return the number of bytes of heap RAM that is available for Python + code to allocate, or -1 if this amount is not known. + + Admonition:Difference to CPython + :class: attention + + This function is MicroPython extension. + """ + ... + +@overload +def threshold() -> int: + """ + Set or query the additional GC allocation threshold. Normally, a collection + is triggered only when a new allocation cannot be satisfied, i.e. on an + out-of-memory (OOM) condition. If this function is called, in addition to + OOM, a collection will be triggered each time after *amount* bytes have been + allocated (in total, since the previous time such an amount of bytes + have been allocated). *amount* is usually specified as less than the + full heap size, with the intention to trigger a collection earlier than when the + heap becomes exhausted, and in the hope that an early collection will prevent + excessive memory fragmentation. This is a heuristic measure, the effect + of which will vary from application to application, as well as + the optimal value of the *amount* parameter. + + Calling the function without argument will return the current value of + the threshold. A value of -1 means a disabled allocation threshold. + + Admonition:Difference to CPython + :class: attention + + This function is a MicroPython extension. CPython has a similar + function - ``set_threshold()``, but due to different GC + implementations, its signature and semantics are different. + """ + +@overload +def threshold(amount: int) -> None: + """ + Set or query the additional GC allocation threshold. Normally, a collection + is triggered only when a new allocation cannot be satisfied, i.e. on an + out-of-memory (OOM) condition. If this function is called, in addition to + OOM, a collection will be triggered each time after *amount* bytes have been + allocated (in total, since the previous time such an amount of bytes + have been allocated). *amount* is usually specified as less than the + full heap size, with the intention to trigger a collection earlier than when the + heap becomes exhausted, and in the hope that an early collection will prevent + excessive memory fragmentation. This is a heuristic measure, the effect + of which will vary from application to application, as well as + the optimal value of the *amount* parameter. + + Calling the function without argument will return the current value of + the threshold. A value of -1 means a disabled allocation threshold. + + Admonition:Difference to CPython + :class: attention + + This function is a MicroPython extension. CPython has a similar + function - ``set_threshold()``, but due to different GC + implementations, its signature and semantics are different. + """ + +def collect() -> None: + """ + Run a garbage collection. + """ + ... + +def enable() -> None: + """ + Enable automatic garbage collection. + """ + ... + +def disable() -> None: + """ + Disable automatic garbage collection. Heap memory can still be allocated, + and garbage collection can still be initiated manually using :meth:`gc.collect`. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/hashlib.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/hashlib.pyi new file mode 100644 index 0000000000..b1736a430c --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/hashlib.pyi @@ -0,0 +1,116 @@ +""" +Hashing algorithms. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/hashlib.html + +CPython module: :mod:`python:hashlib` https://docs.python.org/3/library/hashlib.html . + +This module implements binary data hashing algorithms. The exact inventory +of available algorithms depends on a board. Among the algorithms which may +be implemented: + +* SHA256 - The current generation, modern hashing algorithm (of SHA2 series). + It is suitable for cryptographically-secure purposes. Included in the + MicroPython core and any board is recommended to provide this, unless + it has particular code size constraints. + +* SHA1 - A previous generation algorithm. Not recommended for new usages, + but SHA1 is a part of number of Internet standards and existing + applications, so boards targeting network connectivity and + interoperability will try to provide this. + +* MD5 - A legacy algorithm, not considered cryptographically secure. Only + selected boards, targeting interoperability with legacy applications, + will offer this. + +--- +Module: 'hashlib' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf, _Hash +from typing import NoReturn, overload +from typing_extensions import Awaitable, TypeAlias, TypeVar, deprecated + +class sha1(_Hash): + """ + A previous generation algorithm. Not recommended for new usages, + but SHA1 is a part of number of Internet standards and existing + applications, so boards targeting network connectivity and + interoperability will try to provide this. + """ + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + @overload + def __init__(self): + """ + Create an SHA1 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self, data: AnyReadableBuf): + """ + Create an SHA1 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self): + """ + Create an SHA1 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self, data: AnyReadableBuf): + """ + Create an SHA1 hasher object and optionally feed ``data`` into it. + """ + +class sha256(_Hash): + """ + The current generation, modern hashing algorithm (of SHA2 series). + It is suitable for cryptographically-secure purposes. Included in the + MicroPython core and any board is recommended to provide this, unless + it has particular code size constraints. + """ + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + @overload + def __init__(self): + """ + Create an SHA256 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self, data: AnyReadableBuf): + """ + Create an SHA256 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self): + """ + Create an SHA256 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self, data: AnyReadableBuf): + """ + Create an SHA256 hasher object and optionally feed ``data`` into it. + """ + +class md5(_Hash): + """ + A legacy algorithm, not considered cryptographically secure. Only + selected boards, targeting interoperability with legacy applications, + will offer this. + """ + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, data: AnyReadableBuf = ..., /) -> None: + """ + Create an MD5 hasher object and optionally feed ``data`` into it. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/heapq.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/heapq.pyi new file mode 100644 index 0000000000..e405e4d2e1 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/heapq.pyi @@ -0,0 +1,46 @@ +""" +Heap queue algorithm. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/heapq.html + +CPython module: :mod:`python:heapq` https://docs.python.org/3/library/heapq.html . + +This module implements the +`min heap queue algorithm `_. + +A heap queue is essentially a list that has its elements stored in such a way +that the first item of the list is always the smallest. + +--- +Module: 'heapq' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import Any +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_T = TypeVar("_T") + +def heappop(heap: list[_T], /) -> _T: + """ + Pop the first item from the ``heap``, and return it. Raise ``IndexError`` if + ``heap`` is empty. + + The returned item will be the smallest item in the ``heap``. + """ + ... + +def heappush(heap: list[_T], item: _T, /) -> None: + """ + Push the ``item`` onto the ``heap``. + """ + ... + +def heapify(x: list[Any], /) -> None: + """ + Convert the list ``x`` into a heap. This is an in-place operation. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/lwip.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/lwip.pyi new file mode 100644 index 0000000000..b98a8fcb8a --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/lwip.pyi @@ -0,0 +1,51 @@ +""" +Module: 'lwip' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +SOCK_RAW: Final[int] = 3 +SOCK_STREAM: Final[int] = 1 +SOCK_DGRAM: Final[int] = 2 +MSG_PEEK: Final[int] = 1 +SO_REUSEADDR: Final[int] = 4 +SOL_SOCKET: Final[int] = 1 +SO_BROADCAST: Final[int] = 32 +TCP_NODELAY: Final[int] = 64 +AF_INET6: Final[int] = 10 +IPPROTO_IP: Final[int] = 0 +AF_INET: Final[int] = 2 +MSG_DONTWAIT: Final[int] = 2 +IP_DROP_MEMBERSHIP: Final[int] = 1025 +IPPROTO_TCP: Final[int] = 6 +IP_ADD_MEMBERSHIP: Final[int] = 1024 + +def reset(*args, **kwargs) -> Incomplete: ... +def print_pcbs(*args, **kwargs) -> Incomplete: ... +def getaddrinfo(*args, **kwargs) -> Incomplete: ... +def callback(*args, **kwargs) -> Incomplete: ... + +class socket: + def recvfrom(self, *args, **kwargs) -> Incomplete: ... + def recv(self, *args, **kwargs) -> Incomplete: ... + def makefile(self, *args, **kwargs) -> Incomplete: ... + def listen(self, *args, **kwargs) -> Incomplete: ... + def settimeout(self, *args, **kwargs) -> Incomplete: ... + def sendall(self, *args, **kwargs) -> Incomplete: ... + def setsockopt(self, *args, **kwargs) -> Incomplete: ... + def setblocking(self, *args, **kwargs) -> Incomplete: ... + def sendto(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def connect(self, *args, **kwargs) -> Incomplete: ... + def send(self, *args, **kwargs) -> Incomplete: ... + def bind(self, *args, **kwargs) -> Incomplete: ... + def accept(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/machine.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/machine.pyi new file mode 100644 index 0000000000..bf569c1c80 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/machine.pyi @@ -0,0 +1,3206 @@ +""" +Functions related to the hardware. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/machine.html + +The ``machine`` module contains specific functions related to the hardware +on a particular board. Most functions in this module allow to achieve direct +and unrestricted access to and control of hardware blocks on a system +(like CPU, timers, buses, etc.). Used incorrectly, this can lead to +malfunction, lockups, crashes of your board, and in extreme cases, hardware +damage. + +--- +Module: 'machine' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import NoReturn, Union, Tuple, Callable, List, Sequence, Any, Optional, overload, Final +from _typeshed import Incomplete +from _mpy_shed import _IRQ, AnyReadableBuf, AnyWritableBuf, mp_available +from typing_extensions import Awaitable, TypeAlias, TypeVar, deprecated +from vfs import AbstractBlockDev + +PWRON_RESET: Final[int] = 1 +"""Reset causes.""" +WDT_RESET: Final[int] = 3 +"""Reset causes.""" +ATTN_0DB: int = ... +ID_T: TypeAlias = int | str +PinLike: TypeAlias = Pin | int | str +IDLE: Incomplete +"""IRQ wake values.""" +SLEEP: Incomplete +"""IRQ wake values.""" +DEEPSLEEP: Incomplete +"""IRQ wake values.""" +HARD_RESET: Incomplete +"""Reset causes.""" +DEEPSLEEP_RESET: Incomplete +"""Reset causes.""" +SOFT_RESET: Incomplete +"""Reset causes.""" +WLAN_WAKE: Incomplete +"""Wake-up reasons.""" +PIN_WAKE: Incomplete +"""Wake-up reasons.""" +RTC_WAKE: Incomplete +"""Wake-up reasons.""" +_IRQ_STATE: TypeAlias = int + +def dht_readinto(*args, **kwargs) -> Incomplete: ... +def disable_irq() -> _IRQ_STATE: + """ + Disable interrupt requests. + Returns the previous IRQ state which should be considered an opaque value. + This return value should be passed to the `enable_irq()` function to restore + interrupts to their original state, before `disable_irq()` was called. + """ + ... + +def enable_irq(state: _IRQ_STATE, /) -> None: + """ + Re-enable interrupt requests. + The *state* parameter should be the value that was returned from the most + recent call to the `disable_irq()` function. + """ + ... + +def bitstream(pin, encoding, timing, data, /) -> Incomplete: + """ + Transmits *data* by bit-banging the specified *pin*. The *encoding* argument + specifies how the bits are encoded, and *timing* is an encoding-specific timing + specification. + + The supported encodings are: + + - ``0`` for "high low" pulse duration modulation. This will transmit 0 and + 1 bits as timed pulses, starting with the most significant bit. + The *timing* must be a four-tuple of nanoseconds in the format + ``(high_time_0, low_time_0, high_time_1, low_time_1)``. For example, + ``(400, 850, 800, 450)`` is the timing specification for WS2812 RGB LEDs + at 800kHz. + + The accuracy of the timing varies between ports. On Cortex M0 at 48MHz, it is + at best +/- 120ns, however on faster MCUs (ESP8266, ESP32, STM32, Pyboard), it + will be closer to +/-30ns. + + ``Note:`` For controlling WS2812 / NeoPixel strips, see the :mod:`neopixel` + module for a higher-level API. + """ + ... + +@overload +def deepsleep() -> NoReturn: + """ + Stops execution in an attempt to enter a low power state. + + If *time_ms* is specified then this will be the maximum time in milliseconds that + the sleep will last for. Otherwise the sleep can last indefinitely. + + With or without a timeout, execution may resume at any time if there are events + that require processing. Such events, or wake sources, should be configured before + sleeping, like `Pin` change or `RTC` timeout. + + The precise behaviour and power-saving capabilities of lightsleep and deepsleep is + highly dependent on the underlying hardware, but the general properties are: + + * A lightsleep has full RAM and state retention. Upon wake execution is resumed + from the point where the sleep was requested, with all subsystems operational. + + * A deepsleep may not retain RAM or any other state of the system (for example + peripherals or network interfaces). Upon wake execution is resumed from the main + script, similar to a hard or power-on reset. The `reset_cause()` function will + return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake + from other resets. + """ + +@overload +def deepsleep(time_ms: int, /) -> NoReturn: + """ + Stops execution in an attempt to enter a low power state. + + If *time_ms* is specified then this will be the maximum time in milliseconds that + the sleep will last for. Otherwise the sleep can last indefinitely. + + With or without a timeout, execution may resume at any time if there are events + that require processing. Such events, or wake sources, should be configured before + sleeping, like `Pin` change or `RTC` timeout. + + The precise behaviour and power-saving capabilities of lightsleep and deepsleep is + highly dependent on the underlying hardware, but the general properties are: + + * A lightsleep has full RAM and state retention. Upon wake execution is resumed + from the point where the sleep was requested, with all subsystems operational. + + * A deepsleep may not retain RAM or any other state of the system (for example + peripherals or network interfaces). Upon wake execution is resumed from the main + script, similar to a hard or power-on reset. The `reset_cause()` function will + return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake + from other resets. + """ + +def bootloader(value: Optional[Any] = None) -> None: + """ + Reset the device and enter its bootloader. This is typically used to put the + device into a state where it can be programmed with new firmware. + + Some ports support passing in an optional *value* argument which can control + which bootloader to enter, what to pass to it, or other things. + """ + ... + +def unique_id() -> bytes: + """ + Returns a byte string with a unique identifier of a board/SoC. It will vary + from a board/SoC instance to another, if underlying hardware allows. Length + varies by hardware (so use substring of a full value if you expect a short + ID). In some MicroPython ports, ID corresponds to the network MAC address. + """ + ... + +def soft_reset() -> NoReturn: + """ + Performs a :ref:`soft reset ` of the interpreter, deleting all + Python objects and resetting the Python heap. + """ + ... + +def reset_cause() -> int: + """ + Get the reset cause. See :ref:`constants ` for the possible return values. + """ + ... + +def time_pulse_us(pin: Pin, pulse_level: int, timeout_us: int = 1_000_000, /) -> int: + """ + Time a pulse on the given *pin*, and return the duration of the pulse in + microseconds. The *pulse_level* argument should be 0 to time a low pulse + or 1 to time a high pulse. + + If the current input value of the pin is different to *pulse_level*, + the function first (*) waits until the pin input becomes equal to *pulse_level*, + then (**) times the duration that the pin is equal to *pulse_level*. + If the pin is already equal to *pulse_level* then timing starts straight away. + + The function will return -2 if there was timeout waiting for condition marked + (*) above, and -1 if there was timeout during the main measurement, marked (**) + above. The timeout is the same for both cases and given by *timeout_us* (which + is in microseconds). + """ + ... + +@overload +def freq() -> int: + """ + Returns the CPU frequency in hertz. + + On some ports this can also be used to set the CPU frequency by passing in *hz*. + """ + +@overload +def freq(hz: int, /) -> None: + """ + Returns the CPU frequency in hertz. + + On some ports this can also be used to set the CPU frequency by passing in *hz*. + """ + +@overload +def freq(self) -> int: + """ + Returns the CPU frequency in hertz. + + On some ports this can also be used to set the CPU frequency by passing in *hz*. + """ + +@overload +def freq( + self, + value: int, + /, +) -> None: + """ + Returns the CPU frequency in hertz. + + On some ports this can also be used to set the CPU frequency by passing in *hz*. + """ + +def idle() -> None: + """ + Gates the clock to the CPU, useful to reduce power consumption at any time + during short or long periods. Peripherals continue working and execution + resumes as soon as any interrupt is triggered, or at most one millisecond + after the CPU was paused. + + It is recommended to call this function inside any tight loop that is + continuously checking for an external change (i.e. polling). This will reduce + power consumption without significantly impacting performance. To reduce + power consumption further then see the :func:`lightsleep`, + :func:`time.sleep()` and :func:`time.sleep_ms()` functions. + """ + ... + +def reset() -> NoReturn: + """ + :ref:`Hard resets ` the device in a manner similar to pushing the + external RESET button. + """ + ... + +@overload +def lightsleep() -> None: + """ + Stops execution in an attempt to enter a low power state. + + If *time_ms* is specified then this will be the maximum time in milliseconds that + the sleep will last for. Otherwise the sleep can last indefinitely. + + With or without a timeout, execution may resume at any time if there are events + that require processing. Such events, or wake sources, should be configured before + sleeping, like `Pin` change or `RTC` timeout. + + The precise behaviour and power-saving capabilities of lightsleep and deepsleep is + highly dependent on the underlying hardware, but the general properties are: + + * A lightsleep has full RAM and state retention. Upon wake execution is resumed + from the point where the sleep was requested, with all subsystems operational. + + * A deepsleep may not retain RAM or any other state of the system (for example + peripherals or network interfaces). Upon wake execution is resumed from the main + script, similar to a hard or power-on reset. The `reset_cause()` function will + return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake + from other resets. + """ + +@overload +def lightsleep(time_ms: int, /) -> None: + """ + Stops execution in an attempt to enter a low power state. + + If *time_ms* is specified then this will be the maximum time in milliseconds that + the sleep will last for. Otherwise the sleep can last indefinitely. + + With or without a timeout, execution may resume at any time if there are events + that require processing. Such events, or wake sources, should be configured before + sleeping, like `Pin` change or `RTC` timeout. + + The precise behaviour and power-saving capabilities of lightsleep and deepsleep is + highly dependent on the underlying hardware, but the general properties are: + + * A lightsleep has full RAM and state retention. Upon wake execution is resumed + from the point where the sleep was requested, with all subsystems operational. + + * A deepsleep may not retain RAM or any other state of the system (for example + peripherals or network interfaces). Upon wake execution is resumed from the main + script, similar to a hard or power-on reset. The `reset_cause()` function will + return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake + from other resets. + """ + +mem8: Incomplete ## = <8-bit memory> +"""Read/write 8 bits of memory.""" +mem32: Incomplete ## = <32-bit memory> +"""\ +Read/write 32 bits of memory. + +Use subscript notation ``[...]`` to index these objects with the address of +interest. Note that the address is the byte address, regardless of the size of +memory being accessed. + +Example use (registers are specific to an stm32 microcontroller): +""" +mem16: Incomplete ## = <16-bit memory> +"""Read/write 16 bits of memory.""" + +class PWM: + """ + This class provides pulse width modulation output. + + Example usage:: + + from machine import PWM + + pwm = PWM(pin) # create a PWM object on a pin + pwm.duty_u16(32768) # set duty to 50% + + # reinitialise with a period of 200us, duty of 5us + pwm.init(freq=5000, duty_ns=5000) + + pwm.duty_ns(3000) # set pulse width to 3us + + pwm.deinit() + + + Limitations of PWM + ------------------ + + * Not all frequencies can be generated with absolute accuracy due to + the discrete nature of the computing hardware. Typically the PWM frequency + is obtained by dividing some integer base frequency by an integer divider. + For example, if the base frequency is 80MHz and the required PWM frequency is + 300kHz the divider must be a non-integer number 80000000 / 300000 = 266.67. + After rounding the divider is set to 267 and the PWM frequency will be + 80000000 / 267 = 299625.5 Hz, not 300kHz. If the divider is set to 266 then + the PWM frequency will be 80000000 / 266 = 300751.9 Hz, but again not 300kHz. + + * The duty cycle has the same discrete nature and its absolute accuracy is not + achievable. On most hardware platforms the duty will be applied at the next + frequency period. Therefore, you should wait more than "1/frequency" before + measuring the duty. + + * The frequency and the duty cycle resolution are usually interdependent. + The higher the PWM frequency the lower the duty resolution which is available, + and vice versa. For example, a 300kHz PWM frequency can have a duty cycle + resolution of 8 bit, not 16-bit as may be expected. In this case, the lowest + 8 bits of *duty_u16* are insignificant. So:: + + pwm=PWM(Pin(13), freq=300_000, duty_u16=2**16//2) + + and:: + + pwm=PWM(Pin(13), freq=300_000, duty_u16=2**16//2 + 255) + + will generate PWM with the same 50% duty cycle. + """ + + @overload + def duty_u16(self) -> int: + """ + Get or set the current duty cycle of the PWM output, as an unsigned 16-bit + value in the range 0 to 65535 inclusive. + + With no arguments the duty cycle is returned. + + With a single *value* argument the duty cycle is set to that value, measured + as the ratio ``value / 65535``. + """ + + @overload + def duty_u16( + self, + value: int, + /, + ) -> None: + """ + Get or set the current duty cycle of the PWM output, as an unsigned 16-bit + value in the range 0 to 65535 inclusive. + + With no arguments the duty cycle is returned. + + With a single *value* argument the duty cycle is set to that value, measured + as the ratio ``value / 65535``. + """ + + @overload + def freq(self) -> int: + """ + Get or set the current frequency of the PWM output. + + With no arguments the frequency in Hz is returned. + + With a single *value* argument the frequency is set to that value in Hz. The + method may raise a ``ValueError`` if the frequency is outside the valid range. + """ + + @overload + def freq( + self, + value: int, + /, + ) -> None: + """ + Get or set the current frequency of the PWM output. + + With no arguments the frequency in Hz is returned. + + With a single *value* argument the frequency is set to that value in Hz. The + method may raise a ``ValueError`` if the frequency is outside the valid range. + """ + def init(self, *, freq: int = ..., duty_u16: int = ..., duty_ns: int = ...) -> None: + """ + Modify settings for the PWM object. See the above constructor for details + about the parameters. + """ + ... + + @overload + def duty_ns(self) -> int: + """ + Get or set the current pulse width of the PWM output, as a value in nanoseconds. + + With no arguments the pulse width in nanoseconds is returned. + + With a single *value* argument the pulse width is set to that value. + """ + + @overload + def duty_ns( + self, + value: int, + /, + ) -> None: + """ + Get or set the current pulse width of the PWM output, as a value in nanoseconds. + + With no arguments the pulse width in nanoseconds is returned. + + With a single *value* argument the pulse width is set to that value. + """ + def deinit(self) -> None: + """ + Disable the PWM output. + """ + ... + def __init__( + self, + dest: PinLike, + /, + *, + freq: int = ..., + duty_u16: int = ..., + duty_ns: int = ..., + ) -> None: + """ + Construct and return a new PWM object using the following parameters: + + - *dest* is the entity on which the PWM is output, which is usually a + :ref:`machine.Pin ` object, but a port may allow other values, + like integers. + - *freq* should be an integer which sets the frequency in Hz for the + PWM cycle. + - *duty_u16* sets the duty cycle as a ratio ``duty_u16 / 65535``. + - *duty_ns* sets the pulse width in nanoseconds. + + Setting *freq* may affect other PWM objects if the objects share the same + underlying PWM generator (this is hardware specific). + Only one of *duty_u16* and *duty_ns* should be specified at a time. + """ + +class WDT: + """ + The WDT is used to restart the system when the application crashes and ends + up into a non recoverable state. Once started it cannot be stopped or + reconfigured in any way. After enabling, the application must "feed" the + watchdog periodically to prevent it from expiring and resetting the system. + + Example usage:: + + from machine import WDT + wdt = WDT(timeout=2000) # enable it with a timeout of 2s + wdt.feed() + + Availability of this class: pyboard, WiPy, esp8266, esp32. + """ + def feed(self) -> None: + """ + Feed the WDT to prevent it from resetting the system. The application + should place this call in a sensible place ensuring that the WDT is + only fed after verifying that everything is functioning correctly. + """ + ... + def __init__(self, *, id: int = 0, timeout: int = 5000) -> None: + """ + Create a WDT object and start it. The timeout must be given in milliseconds. + Once it is running the timeout cannot be changed and the WDT cannot be stopped either. + + Notes: On the esp32 the minimum timeout is 1 second. On the esp8266 a timeout + cannot be specified, it is determined by the underlying system. + """ + +class I2S: + """ + I2S is a synchronous serial protocol used to connect digital audio devices. + At the physical level, a bus consists of 3 lines: SCK, WS, SD. + The I2S class supports controller operation. Peripheral operation is not supported. + + The I2S class is currently available as a Technical Preview. During the preview period, feedback from + users is encouraged. Based on this feedback, the I2S class API and implementation may be changed. + + I2S objects can be created and initialized using:: + + from machine import I2S + from machine import Pin + + # ESP32 + sck_pin = Pin(14) # Serial clock output + ws_pin = Pin(13) # Word clock output + sd_pin = Pin(12) # Serial data output + + or + + # PyBoards + sck_pin = Pin("Y6") # Serial clock output + ws_pin = Pin("Y5") # Word clock output + sd_pin = Pin("Y8") # Serial data output + + audio_out = I2S(2, + sck=sck_pin, ws=ws_pin, sd=sd_pin, + mode=I2S.TX, + bits=16, + format=I2S.MONO, + rate=44100, + ibuf=20000) + + audio_in = I2S(2, + sck=sck_pin, ws=ws_pin, sd=sd_pin, + mode=I2S.RX, + bits=32, + format=I2S.STEREO, + rate=22050, + ibuf=20000) + + 3 modes of operation are supported: + - blocking + - non-blocking + - uasyncio + + blocking:: + + num_written = audio_out.write(buf) # blocks until buf emptied + + num_read = audio_in.readinto(buf) # blocks until buf filled + + non-blocking:: + + audio_out.irq(i2s_callback) # i2s_callback is called when buf is emptied + num_written = audio_out.write(buf) # returns immediately + + audio_in.irq(i2s_callback) # i2s_callback is called when buf is filled + num_read = audio_in.readinto(buf) # returns immediately + + uasyncio:: + + swriter = uasyncio.StreamWriter(audio_out) + swriter.write(buf) + await swriter.drain() + + sreader = uasyncio.StreamReader(audio_in) + num_read = await sreader.readinto(buf) + """ + + RX: Final[int] = 0 + """for initialising the I2S bus ``mode`` to receive""" + MONO: Final[int] = 0 + """for initialising the I2S bus ``format`` to mono""" + STEREO: Final[int] = 1 + """for initialising the I2S bus ``format`` to stereo""" + TX: Final[int] = 1 + """for initialising the I2S bus ``mode`` to transmit""" + @staticmethod + def shift( + buf: AnyWritableBuf, + bits: int, + shift: int, + /, + ) -> None: + """ + bitwise shift of all samples contained in ``buf``. ``bits`` specifies sample size in bits. ``shift`` specifies the number of bits to shift each sample. + Positive for left shift, negative for right shift. + Typically used for volume control. Each bit shift changes sample volume by 6dB. + """ + ... + def init( + self, + *, + sck: PinLike, + ws: PinLike, + sd: PinLike, + mode: int, + bits: int, + format: int, + rate: int, + ibuf: int, + ) -> None: + """ + see Constructor for argument descriptions + """ + ... + def irq( + self, + handler: Callable[[Any], None], + /, + ) -> None: + """ + Set a callback. ``handler`` is called when ``buf`` is emptied (``write`` method) or becomes full (``readinto`` method). + Setting a callback changes the ``write`` and ``readinto`` methods to non-blocking operation. + ``handler`` is called in the context of the MicroPython scheduler. + """ + ... + def readinto( + self, + buf: AnyWritableBuf, + /, + ) -> int: + """ + Read audio samples into the buffer specified by ``buf``. ``buf`` must support the buffer protocol, such as bytearray or array. + "buf" byte ordering is little-endian. For Stereo format, left channel sample precedes right channel sample. For Mono format, + the left channel sample data is used. + Returns number of bytes read + """ + ... + def deinit(self) -> None: + """ + Deinitialize the I2S bus + """ + ... + def write( + self, + buf: AnyReadableBuf, + /, + ) -> int: + """ + Write audio samples contained in ``buf``. ``buf`` must support the buffer protocol, such as bytearray or array. + "buf" byte ordering is little-endian. For Stereo format, left channel sample precedes right channel sample. For Mono format, + the sample data is written to both the right and left channels. + Returns number of bytes written + """ + ... + def __init__( + self, + id: ID_T, + /, + *, + sck: PinLike, + ws: PinLike, + sd: PinLike, + mode: int, + bits: int, + format: int, + rate: int, + ibuf: int, + ) -> None: + """ + Construct an I2S object of the given id: + + - ``id`` identifies a particular I2S bus. + + ``id`` is board and port specific: + + - PYBv1.0/v1.1: has one I2S bus with id=2. + - PYBD-SFxW: has two I2S buses with id=1 and id=2. + - ESP32: has two I2S buses with id=0 and id=1. + + Keyword-only parameters that are supported on all ports: + + - ``sck`` is a pin object for the serial clock line + - ``ws`` is a pin object for the word select line + - ``sd`` is a pin object for the serial data line + - ``mode`` specifies receive or transmit + - ``bits`` specifies sample size (bits), 16 or 32 + - ``format`` specifies channel format, STEREO or MONO + - ``rate`` specifies audio sampling rate (samples/s) + - ``ibuf`` specifies internal buffer length (bytes) + + For all ports, DMA runs continuously in the background and allows user applications to perform other operations while + sample data is transfered between the internal buffer and the I2S peripheral unit. + Increasing the size of the internal buffer has the potential to increase the time that user applications can perform non-I2S operations + before underflow (e.g. ``write`` method) or overflow (e.g. ``readinto`` method). + """ + +class ADC: + """ + The ADC class provides an interface to analog-to-digital convertors, and + represents a single endpoint that can sample a continuous voltage and + convert it to a discretised value. + + Example usage:: + + import machine + + adc = machine.ADC(pin) # create an ADC object acting on a pin + val = adc.read_u16() # read a raw analog value in the range 0-65535 + """ + + CORE_TEMP: Final[int] = 4 + VREF: int = ... + CORE_VREF: int = ... + CORE_VBAT: int = ... + ATTN_0DB: int = 0 + ATTN_2_5DB: int = 1 + ATTN_6DB: int = 2 + ATTN_11DB: int = 3 + WIDTH_9BIT: int = 9 + WIDTH_10BIT: int = 10 + WIDTH_11BIT: int = 11 + WIDTH_12BIT: int = 12 + def read_u16(self) -> int: + """ + Take an analog reading and return an integer in the range 0-65535. + The return value represents the raw reading taken by the ADC, scaled + such that the minimum value is 0 and the maximum value is 65535. + """ + ... + def __init__(self, pin: PinLike, *, atten=ATTN_0DB) -> None: + """ + Access the ADC associated with a source identified by *id*. This + *id* may be an integer (usually specifying a channel number), a + :ref:`Pin ` object, or other value supported by the + underlying machine. + .. note:: + + WiPy has a custom implementation of ADC, see ADCWiPy for details. + + on ESP32 : `atten` specifies the attenuation level for the ADC input. + """ + + # ESP32 specific + @mp_available(port="esp32") + @deprecated("Use ADC.block().init(bits=bits) instead.") + def width(self, bits: int) -> None: + """ + Equivalent to ADC.block().init(bits=bits). + The only chip that can switch resolution to a lower one is the normal esp32. The C2 & S3 are stuck at 12 bits, while the S2 is at 13 bits. + + For compatibility, the ADC object also provides constants matching the supported ADC resolutions, per chip: + + ESP32: + ADC.WIDTH_9BIT = 9 + ADC.WIDTH_10BIT = 10 + ADC.WIDTH_11BIT = 11 + ADC.WIDTH_12BIT = 12 + + ESP32 C3 & S3: + ADC.WIDTH_12BIT = 12 + + ESP32 S2: + ADC.WIDTH_13BIT = 13 + + Available : ESP32 + """ + ... + + @mp_available(port="esp32") + @deprecated("Use read_u16() instead.") + def read(self) -> int: + """ + Take an analog reading and return an integer in the range 0-4095. + The return value represents the raw reading taken by the ADC, scaled + such that the minimum value is 0 and the maximum value is 4095. + + This method is deprecated, use `read_u16()` instead. + + Available : ESP32 + """ + ... + + @mp_available(port="esp32") + @deprecated("Use ADC.init(atten=atten) instead.") + def atten(self, atten: int) -> None: + """ + Set the attenuation level for the ADC input. + + Available : ESP32 + """ + ... + +class I2C: + """ + 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 lines respectively. + + I2C objects are created attached to a specific bus. They can be initialised + when created, or initialised later on. + + Printing the I2C object gives you information about its configuration. + + Both hardware and software I2C implementations exist via the + :ref:`machine.I2C ` and `machine.SoftI2C` classes. Hardware I2C uses + underlying hardware support of the system to perform the reads/writes and is + usually efficient and fast but may have restrictions on which pins can be used. + Software I2C is implemented by bit-banging and can be used on any pin but is not + as efficient. These classes have the same methods available and differ primarily + in the way they are constructed. + + Example usage:: + + from machine import I2C + + i2c = I2C(freq=400000) # create I2C peripheral at frequency of 400kHz + # depending on the port, extra parameters may be required + # to select the peripheral and/or pins to use + + i2c.scan() # scan for peripherals, returning a list of 7-bit addresses + + i2c.writeto(42, b'123') # write 3 bytes to peripheral with 7-bit address 42 + i2c.readfrom(42, 4) # read 4 bytes from peripheral with 7-bit address 42 + + i2c.readfrom_mem(42, 8, 3) # read 3 bytes from memory of peripheral 42, + # starting at memory-address 8 in the peripheral + i2c.writeto_mem(42, 2, b'\x10') # write 1 byte to memory of peripheral 42 + # starting at address 2 in the peripheral + """ + def readfrom_mem_into(self, addr: int, memaddr: int, buf: AnyWritableBuf, /, *, addrsize: int = 8) -> None: + """ + Read into *buf* from the peripheral specified by *addr* starting from the + memory address specified by *memaddr*. The number of bytes read is the + length of *buf*. + The argument *addrsize* specifies the address size in bits (on ESP8266 + this argument is not recognised and the address size is always 8 bits). + + The method returns ``None``. + """ + ... + def readfrom_into(self, addr: int, buf: AnyWritableBuf, stop: bool = True, /) -> None: + """ + Read into *buf* from the peripheral specified by *addr*. + The number of bytes read will be the length of *buf*. + If *stop* is true then a STOP condition is generated at the end of the transfer. + + The method returns ``None``. + """ + ... + def readfrom_mem(self, addr: int, memaddr: int, nbytes: int, /, *, addrsize: int = 8) -> bytes: + """ + Read *nbytes* from the peripheral specified by *addr* starting from the memory + address specified by *memaddr*. + The argument *addrsize* specifies the address size in bits. + Returns a `bytes` object with the data read. + """ + ... + def writeto_mem(self, addr: int, memaddr: int, buf: AnyReadableBuf, /, *, addrsize: int = 8) -> None: + """ + Write *buf* to the peripheral specified by *addr* starting from the + memory address specified by *memaddr*. + The argument *addrsize* specifies the address size in bits (on ESP8266 + this argument is not recognised and the address size is always 8 bits). + + The method returns ``None``. + """ + ... + def scan(self) -> List: + """ + Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of + those that respond. A device responds if it pulls the SDA line low after + its address (including a write bit) is sent on the bus. + """ + ... + def writeto(self, addr: int, buf: AnyReadableBuf, stop: bool = True, /) -> int: + """ + Write the bytes from *buf* to the peripheral specified by *addr*. If a + NACK is received following the write of a byte from *buf* then the + remaining bytes are not sent. If *stop* is true then a STOP condition is + generated at the end of the transfer, even if a NACK is received. + The function returns the number of ACKs that were received. + """ + ... + def writevto(self, addr: int, vector: Sequence[AnyReadableBuf], stop: bool = True, /) -> int: + """ + Write the bytes contained in *vector* to the peripheral specified by *addr*. + *vector* should be a tuple or list of objects with the buffer protocol. + The *addr* is sent once and then the bytes from each object in *vector* + are written out sequentially. The objects in *vector* may be zero bytes + in length in which case they don't contribute to the output. + + If a NACK is received following the write of a byte from one of the + objects in *vector* then the remaining bytes, and any remaining objects, + are not sent. If *stop* is true then a STOP condition is generated at + the end of the transfer, even if a NACK is received. The function + returns the number of ACKs that were received. + """ + ... + def start(self) -> None: + """ + Generate a START condition on the bus (SDA transitions to low while SCL is high). + """ + ... + def readfrom(self, addr: int, nbytes: int, stop: bool = True, /) -> bytes: + """ + Read *nbytes* from the peripheral specified by *addr*. + If *stop* is true then a STOP condition is generated at the end of the transfer. + Returns a `bytes` object with the data read. + """ + ... + def readinto(self, buf: AnyWritableBuf, nack: bool = True, /) -> None: + """ + Reads bytes from the bus and stores them into *buf*. The number of bytes + read is the length of *buf*. An ACK will be sent on the bus after + receiving all but the last byte. After the last byte is received, if *nack* + is true then a NACK will be sent, otherwise an ACK will be sent (and in this + case the peripheral assumes more bytes are going to be read in a later call). + """ + ... + + @overload + def init(self, *, freq: int = 400_000) -> None: + """ + Initialise the I2C bus with the given arguments: + + - *scl* is a pin object for the SCL line + - *sda* is a pin object for the SDA line + - *freq* is the SCL clock rate + + In the case of hardware I2C the actual clock frequency may be lower than the + requested frequency. This is dependent on the platform hardware. The actual + rate may be determined by printing the I2C object. + """ + + @overload + def init(self, *, scl: PinLike, sda: PinLike, freq: int = 400_000) -> None: + """ + Initialise the I2C bus with the given arguments: + + - *scl* is a pin object for the SCL line + - *sda* is a pin object for the SDA line + - *freq* is the SCL clock rate + + In the case of hardware I2C the actual clock frequency may be lower than the + requested frequency. This is dependent on the platform hardware. The actual + rate may be determined by printing the I2C object. + """ + def stop(self) -> None: + """ + Generate a STOP condition on the bus (SDA transitions to high while SCL is high). + """ + ... + def write(self, buf: AnyReadableBuf, /) -> int: + """ + Write the bytes from *buf* to the bus. Checks that an ACK is received + after each byte and stops transmitting the remaining bytes if a NACK is + received. The function returns the number of ACKs that were received. + """ + ... + + @overload + def __init__(self, id: ID_T, /, *, freq: int = 400_000): + """ + Construct and return a new I2C object using the following parameters: + + - *id* identifies a particular I2C peripheral. Allowed values for + depend on the particular port/board + - *scl* should be a pin object specifying the pin to use for SCL. + - *sda* should be a pin object specifying the pin to use for SDA. + - *freq* should be an integer which sets the maximum frequency + for SCL. + + Note that some ports/boards will have default values of *scl* and *sda* + that can be changed in this constructor. Others will have fixed values + of *scl* and *sda* that cannot be changed. + """ + + @overload + def __init__(self, id: ID_T, /, *, scl: PinLike, sda: PinLike, freq: int = 400_000): + """ + Construct and return a new I2C object using the following parameters: + + - *id* identifies a particular I2C peripheral. Allowed values for + depend on the particular port/board + - *scl* should be a pin object specifying the pin to use for SCL. + - *sda* should be a pin object specifying the pin to use for SDA. + - *freq* should be an integer which sets the maximum frequency + for SCL. + + Note that some ports/boards will have default values of *scl* and *sda* + that can be changed in this constructor. Others will have fixed values + of *scl* and *sda* that cannot be changed. + """ + + @overload + def __init__(self, *, scl: PinLike, sda: PinLike, freq: int = 400_000) -> None: + """ + Initialise the I2C bus with the given arguments: + + - *scl* is a pin object for the SCL line + - *sda* is a pin object for the SDA line + - *freq* is the SCL clock rate + + In the case of hardware I2C the actual clock frequency may be lower than the + requested frequency. This is dependent on the platform hardware. The actual + rate may be determined by printing the I2C object. + """ + +class I2CTarget: + """ + Construct and return a new I2CTarget object using the following parameters: + + - *id* identifies a particular I2C peripheral. Allowed values depend on the + particular port/board. Some ports have a default in which case this parameter + can be omitted. + - *addr* is the I2C address of the target. + - *addrsize* is the number of bits in the I2C target address. Valid values + are 7 and 10. + - *mem* is an object with the buffer protocol that is writable. If not + specified then there is no backing memory and data must be read/written + using the :meth:`I2CTarget.readinto` and :meth:`I2CTarget.write` methods. + - *mem_addrsize* is the number of bits in the memory address. Valid values + are 0, 8, 16, 24 and 32. + - *scl* is a pin object specifying the pin to use for SCL. + - *sda* is a pin object specifying the pin to use for SDA. + + Note that some ports/boards will have default values of *scl* and *sda* + that can be changed in this constructor. Others will have fixed values + of *scl* and *sda* that cannot be changed. + """ + + IRQ_END_READ: Final[int] = 16 + """IRQ trigger sources.""" + IRQ_ADDR_MATCH_WRITE: Final[int] = 2 + """IRQ trigger sources.""" + IRQ_END_WRITE: Final[int] = 32 + """IRQ trigger sources.""" + IRQ_READ_REQ: Final[int] = 4 + """IRQ trigger sources.""" + IRQ_ADDR_MATCH_READ: Final[int] = 1 + """IRQ trigger sources.""" + IRQ_WRITE_REQ: Final[int] = 8 + """IRQ trigger sources.""" + def deinit(self) -> Incomplete: + """ + Deinitialise the I2C target. After this method is called the hardware will no + longer respond to requests on the I2C bus, and no other methods can be called. + """ + ... + def irq(self, handler=None, trigger=IRQ_END_READ | IRQ_END_WRITE, hard=False) -> Incomplete: + """ + Configure an IRQ *handler* to be called when an event occurs. The possible events are + given by the following constants, which can be or'd together and passed to the *trigger* + argument: + + - ``IRQ_ADDR_MATCH_READ`` indicates that the target was addressed by a + controller for a read transaction. + - ``IRQ_ADDR_MATCH_WRITE`` indicates that the target was addressed by a + controller for a write transaction. + - ``IRQ_READ_REQ`` indicates that the controller is requesting data, and this + request must be satisfied by calling `I2CTarget.write` with the data to be + passed back to the controller. + - ``IRQ_WRITE_REQ`` indicates that the controller has written data, and the + data must be read by calling `I2CTarget.readinto`. + - ``IRQ_END_READ`` indicates that the controller has finished a read transaction. + - ``IRQ_END_WRITE`` indicates that the controller has finished a write transaction. + + Not all triggers are available on all ports. If a port has the constant then that + event is available. + + Note the following restrictions: + + - ``IRQ_ADDR_MATCH_READ``, ``IRQ_ADDR_MATCH_WRITE``, ``IRQ_READ_REQ`` and + ``IRQ_WRITE_REQ`` must be handled by a hard IRQ callback (with the *hard* argument + set to ``True``). This is because these events have very strict timing requirements + and must usually be satisfied synchronously with the hardware event. + + - ``IRQ_END_READ`` and ``IRQ_END_WRITE`` may be handled by either a soft or hard + IRQ callback (although note that all events must be registered with the same handler, + so if any events need a hard callback then all events must be hard). + + - If a memory buffer has been supplied in the constructor then ``IRQ_END_WRITE`` + is not emitted for the transaction that writes the memory address. This is to + allow ``IRQ_END_READ`` and ``IRQ_END_WRITE`` to function correctly as soft IRQ + callbacks, where the IRQ handler may be called quite some time after the actual + hardware event. + """ + ... + def write(self, buf) -> int: + """ + Write out the bytes from the given buffer, to be passed to the I2C controller + after it sends a read request. Returns the number of bytes written. Most ports + only accept one byte at a time to this method. + """ + ... + def readinto(self, buf) -> int: + """ + Read into the given buffer any pending bytes written by the I2C controller. + Returns the number of bytes read. + """ + ... + def __init__(self, id, addr, *, addrsize=7, mem=None, mem_addrsize=8, scl=None, sda=None) -> None: ... + +class SoftSPI(SPI): + """ + Construct a new software SPI object. Additional parameters must be + given, usually at least *sck*, *mosi* and *miso*, and these are used + to initialise the bus. See `SPI.init` for a description of the parameters. + """ + + LSB: Final[int] = 0 + """set the first bit to be the least significant bit""" + MSB: Final[int] = 1 + """set the first bit to be the most significant bit""" + def deinit(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def write_readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__( + self, + baudrate=500000, + *, + polarity=0, + phase=0, + bits=8, + firstbit=MSB, + sck: PinLike | None = None, + mosi: PinLike | None = None, + miso: PinLike | None = None, + ) -> None: ... + +class Timer: + """ + Hardware timers deal with timing of periods and events. Timers are perhaps + the most flexible and heterogeneous kind of hardware in MCUs and SoCs, + differently greatly from a model to a model. MicroPython's Timer class + defines a baseline operation of executing a callback with a given period + (or once after some delay), and allow specific boards to define more + non-standard behaviour (which thus won't be portable to other boards). + + See discussion of :ref:`important constraints ` on + Timer callbacks. + + .. note:: + + Memory can't be allocated inside irq handlers (an interrupt) and so + exceptions raised within a handler don't give much information. See + :func:`micropython.alloc_emergency_exception_buf` for how to get around this + limitation. + + If you are using a WiPy board please refer to :ref:`machine.TimerWiPy ` + instead of this class. + """ + + PERIODIC: Final[int] = 1 + """Timer operating mode.""" + ONE_SHOT: Final[int] = 0 + """Timer operating mode.""" + + @overload + def init( + self, + *, + mode: int = PERIODIC, + period: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ) -> None: ... + @overload + def init( + self, + *, + mode: int = PERIODIC, + freq: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ) -> None: ... + @overload + def init( + self, + *, + mode: int = PERIODIC, + tick_hz: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ) -> None: + """ + Initialise the timer. Example:: + + def mycallback(t): + pass + + # periodic at 1kHz + tim.init(mode=Timer.PERIODIC, freq=1000, callback=mycallback) + + # periodic with 100ms period + tim.init(period=100, callback=mycallback) + + # one shot firing after 1000ms + tim.init(mode=Timer.ONE_SHOT, period=1000, callback=mycallback) + + Keyword arguments: + + - ``mode`` can be one of: + + - ``Timer.ONE_SHOT`` - The timer runs once until the configured + period of the channel expires. + - ``Timer.PERIODIC`` - The timer runs periodically at the configured + frequency of the channel. + + - ``freq`` - The timer frequency, in units of Hz. The upper bound of + the frequency is dependent on the port. When both the ``freq`` and + ``period`` arguments are given, ``freq`` has a higher priority and + ``period`` is ignored. + + - ``period`` - The timer period, in milliseconds. + + - ``callback`` - The callable to call upon expiration of the timer period. + The callback must take one argument, which is passed the Timer object. + + The ``callback`` argument shall be specified. Otherwise an exception + will occur upon timer expiration: + ``TypeError: 'NoneType' object isn't callable`` + + - ``hard`` can be one of: + + - ``True`` - The callback will be executed in hard interrupt context, + which minimises delay and jitter but is subject to the limitations + described in :ref:`isr_rules`. Not all ports support hard interrupts, + see the port documentation for more information. + - ``False`` - The callback will be scheduled as a soft interrupt, + allowing it to allocate but possibly also introducing + garbage-collection delays and jitter. + + The default value of this parameter is port-specific for historical reasons. + """ + ... + def deinit(self) -> None: + """ + Deinitialises the timer. Stops the timer, and disables the timer peripheral. + """ + ... + @overload + def __init__(self, id: int, /): + """ + Construct a new timer object of the given ``id``. ``id`` of -1 constructs a + virtual timer (if supported by a board). + ``id`` shall not be passed as a keyword argument. + + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + *, + mode: int = PERIODIC, + period: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ): + """ + Construct a new timer object of the given ``id``. ``id`` of -1 constructs a + virtual timer (if supported by a board). + ``id`` shall not be passed as a keyword argument. + + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + *, + mode: int = PERIODIC, + freq: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ): + """ + Construct a new timer object of the given ``id``. ``id`` of -1 constructs a + virtual timer (if supported by a board). + ``id`` shall not be passed as a keyword argument. + + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + *, + mode: int = PERIODIC, + tick_hz: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ): + """ + Construct a new timer object of the given ``id``. ``id`` of -1 constructs a + virtual timer (if supported by a board). + ``id`` shall not be passed as a keyword argument. + + See ``init`` for parameters of initialisation. + """ + +class UART: + """ + UART implements the standard UART/USART duplex serial communications protocol. At + the physical level it consists of 2 lines: RX and TX. The unit of communication + is a character (not to be confused with a string character) which can be 8 or 9 + bits wide. + + UART objects can be created and initialised using:: + + from machine import UART + + uart = UART(1, 9600) # init with given baudrate + uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters + + Supported parameters differ on a board: + + Pyboard: Bits can be 7, 8 or 9. Stop can be 1 or 2. With *parity=None*, + only 8 and 9 bits are supported. With parity enabled, only 7 and 8 bits + are supported. + + WiPy/CC3200: Bits can be 5, 6, 7, 8. Stop can be 1 or 2. + + A UART object acts like a `stream` object and reading and writing is done + using the standard stream methods:: + + uart.read(10) # read 10 characters, returns a bytes object + uart.read() # read all available characters + uart.readline() # read a line + uart.readinto(buf) # read and store into the given buffer + uart.write('abc') # write the 3 characters + """ + + INV_TX: Final[int] = 1 + RTS: Final[int] = 2 + """\ + Flow control options. + + Availability: esp32, mimxrt, renesas-ra, rp2, stm32. + """ + INV_RX: Final[int] = 2 + IRQ_TXIDLE: Final[int] = 32 + """\ + IRQ trigger sources. + + Availability: renesas-ra, stm32, esp32, rp2040, mimxrt, samd, cc3200. + """ + IRQ_BREAK: Final[int] = 512 + """\ + IRQ trigger sources. + + Availability: renesas-ra, stm32, esp32, rp2040, mimxrt, samd, cc3200. + """ + IRQ_RXIDLE: Final[int] = 64 + """\ + IRQ trigger sources. + + Availability: renesas-ra, stm32, esp32, rp2040, mimxrt, samd, cc3200. + """ + CTS: Final[int] = 1 + """\ + Flow control options. + + Availability: esp32, mimxrt, renesas-ra, rp2, stm32. + """ + IRQ_RX: Incomplete + IDLE: int = ... + def irq( + self, + handler: Callable[[UART], None] | None = None, + trigger: int = 0, + hard: bool = False, + /, + ) -> _IRQ: + """ + Configure an interrupt handler to be called when a UART event occurs. + + The arguments are: + + - *handler* is an optional function to be called when the interrupt event + triggers. The handler must take exactly one argument which is the + ``UART`` instance. + + - *trigger* configures the event(s) which can generate an interrupt. + Possible values are a mask of one or more of the following: + + - ``UART.IRQ_RXIDLE`` interrupt after receiving at least one character + and then the RX line goes idle. + - ``UART.IRQ_RX`` interrupt after each received character. + - ``UART.IRQ_TXIDLE`` interrupt after or while the last character(s) of + a message are or have been sent. + - ``UART.IRQ_BREAK`` interrupt when a break state is detected at RX + + - *hard* if true a hardware interrupt is used. This reduces the delay + between the pin change and the handler being called. Hard interrupt + handlers may not allocate memory; see :ref:`isr_rules`. + + Returns an irq object. + + Due to limitations of the hardware not all trigger events are available on all ports. + """ + ... + def sendbreak(self) -> None: + """ + Send a break condition on the bus. This drives the bus low for a duration + longer than required for a normal transmission of a character. + """ + ... + def deinit(self) -> None: + """ + Turn off the UART bus. + + .. note:: + You will not be able to call ``init()`` on the object after ``deinit()``. + A new instance needs to be created in that case. + """ + ... + + @overload + def init( + self, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + tx: PinLike | None = None, + rx: PinLike | None = None, + txbuf: int | None = None, + rxbuf: int | None = None, + timeout: int | None = None, + timeout_char: int | None = None, + invert: int | None = None, + ) -> None: + """ + Initialise the UART bus with the given parameters: + + - *baudrate* is the clock rate. + - *bits* is the number of bits per character, 7, 8 or 9. + - *parity* is the parity, ``None``, 0 (even) or 1 (odd). + - *stop* is the number of stop bits, 1 or 2. + + Additional keyword-only parameters that may be supported by a port are: + + - *tx* specifies the TX pin to use. + - *rx* specifies the RX pin to use. + - *rts* specifies the RTS (output) pin to use for hardware receive flow control. + - *cts* specifies the CTS (input) pin to use for hardware transmit flow control. + - *txbuf* specifies the length in characters of the TX buffer. + - *rxbuf* specifies the length in characters of the RX buffer. + - *timeout* specifies the time to wait for the first character (in ms). + - *timeout_char* specifies the time to wait between characters (in ms). + - *invert* specifies which lines to invert. + + - ``0`` will not invert lines (idle state of both lines is logic high). + - ``UART.INV_TX`` will invert TX line (idle state of TX line now logic low). + - ``UART.INV_RX`` will invert RX line (idle state of RX line now logic low). + - ``UART.INV_TX | UART.INV_RX`` will invert both lines (idle state at logic low). + + - *flow* specifies which hardware flow control signals to use. The value + is a bitmask. + + - ``0`` will ignore hardware flow control signals. + - ``UART.RTS`` will enable receive flow control by using the RTS output pin to + signal if the receive FIFO has sufficient space to accept more data. + - ``UART.CTS`` will enable transmit flow control by pausing transmission when the + CTS input pin signals that the receiver is running low on buffer space. + - ``UART.RTS | UART.CTS`` will enable both, for full hardware flow control. + + On the WiPy only the following keyword-only parameter is supported: + + - *pins* is a 4 or 2 item list indicating the TX, RX, RTS and CTS pins (in that order). + Any of the pins can be None if one wants the UART to operate with limited functionality. + If the RTS pin is given the RX pin must be given as well. The same applies to CTS. + When no pins are given, then the default set of TX and RX pins is taken, and hardware + flow control will be disabled. If *pins* is ``None``, no pin assignment will be made. + + .. note:: + It is possible to call ``init()`` multiple times on the same object in + order to reconfigure UART on the fly. That allows using single UART + peripheral to serve different devices attached to different GPIO pins. + Only one device can be served at a time in that case. + Also do not call ``deinit()`` as it will prevent calling ``init()`` + again. + """ + + @overload + def init( + self, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + pins: tuple[PinLike, PinLike] | None = None, + ) -> None: + """ + Initialise the UART bus with the given parameters: + + - *baudrate* is the clock rate. + - *bits* is the number of bits per character, 7, 8 or 9. + - *parity* is the parity, ``None``, 0 (even) or 1 (odd). + - *stop* is the number of stop bits, 1 or 2. + + Additional keyword-only parameters that may be supported by a port are: + + - *tx* specifies the TX pin to use. + - *rx* specifies the RX pin to use. + - *rts* specifies the RTS (output) pin to use for hardware receive flow control. + - *cts* specifies the CTS (input) pin to use for hardware transmit flow control. + - *txbuf* specifies the length in characters of the TX buffer. + - *rxbuf* specifies the length in characters of the RX buffer. + - *timeout* specifies the time to wait for the first character (in ms). + - *timeout_char* specifies the time to wait between characters (in ms). + - *invert* specifies which lines to invert. + + - ``0`` will not invert lines (idle state of both lines is logic high). + - ``UART.INV_TX`` will invert TX line (idle state of TX line now logic low). + - ``UART.INV_RX`` will invert RX line (idle state of RX line now logic low). + - ``UART.INV_TX | UART.INV_RX`` will invert both lines (idle state at logic low). + + - *flow* specifies which hardware flow control signals to use. The value + is a bitmask. + + - ``0`` will ignore hardware flow control signals. + - ``UART.RTS`` will enable receive flow control by using the RTS output pin to + signal if the receive FIFO has sufficient space to accept more data. + - ``UART.CTS`` will enable transmit flow control by pausing transmission when the + CTS input pin signals that the receiver is running low on buffer space. + - ``UART.RTS | UART.CTS`` will enable both, for full hardware flow control. + + On the WiPy only the following keyword-only parameter is supported: + + - *pins* is a 4 or 2 item list indicating the TX, RX, RTS and CTS pins (in that order). + Any of the pins can be None if one wants the UART to operate with limited functionality. + If the RTS pin is given the RX pin must be given as well. The same applies to CTS. + When no pins are given, then the default set of TX and RX pins is taken, and hardware + flow control will be disabled. If *pins* is ``None``, no pin assignment will be made. + + .. note:: + It is possible to call ``init()`` multiple times on the same object in + order to reconfigure UART on the fly. That allows using single UART + peripheral to serve different devices attached to different GPIO pins. + Only one device can be served at a time in that case. + Also do not call ``deinit()`` as it will prevent calling ``init()`` + again. + """ + + @overload + def init( + self, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + pins: tuple[PinLike, PinLike, PinLike, PinLike] | None = None, + ) -> None: + """ + Initialise the UART bus with the given parameters: + + - *baudrate* is the clock rate. + - *bits* is the number of bits per character, 7, 8 or 9. + - *parity* is the parity, ``None``, 0 (even) or 1 (odd). + - *stop* is the number of stop bits, 1 or 2. + + Additional keyword-only parameters that may be supported by a port are: + + - *tx* specifies the TX pin to use. + - *rx* specifies the RX pin to use. + - *rts* specifies the RTS (output) pin to use for hardware receive flow control. + - *cts* specifies the CTS (input) pin to use for hardware transmit flow control. + - *txbuf* specifies the length in characters of the TX buffer. + - *rxbuf* specifies the length in characters of the RX buffer. + - *timeout* specifies the time to wait for the first character (in ms). + - *timeout_char* specifies the time to wait between characters (in ms). + - *invert* specifies which lines to invert. + + - ``0`` will not invert lines (idle state of both lines is logic high). + - ``UART.INV_TX`` will invert TX line (idle state of TX line now logic low). + - ``UART.INV_RX`` will invert RX line (idle state of RX line now logic low). + - ``UART.INV_TX | UART.INV_RX`` will invert both lines (idle state at logic low). + + - *flow* specifies which hardware flow control signals to use. The value + is a bitmask. + + - ``0`` will ignore hardware flow control signals. + - ``UART.RTS`` will enable receive flow control by using the RTS output pin to + signal if the receive FIFO has sufficient space to accept more data. + - ``UART.CTS`` will enable transmit flow control by pausing transmission when the + CTS input pin signals that the receiver is running low on buffer space. + - ``UART.RTS | UART.CTS`` will enable both, for full hardware flow control. + + On the WiPy only the following keyword-only parameter is supported: + + - *pins* is a 4 or 2 item list indicating the TX, RX, RTS and CTS pins (in that order). + Any of the pins can be None if one wants the UART to operate with limited functionality. + If the RTS pin is given the RX pin must be given as well. The same applies to CTS. + When no pins are given, then the default set of TX and RX pins is taken, and hardware + flow control will be disabled. If *pins* is ``None``, no pin assignment will be made. + + .. note:: + It is possible to call ``init()`` multiple times on the same object in + order to reconfigure UART on the fly. That allows using single UART + peripheral to serve different devices attached to different GPIO pins. + Only one device can be served at a time in that case. + Also do not call ``deinit()`` as it will prevent calling ``init()`` + again. + """ + def flush(self) -> Incomplete: + """ + Waits until all data has been sent. In case of a timeout, an exception is raised. The timeout + duration depends on the tx buffer size and the baud rate. Unless flow control is enabled, a timeout + should not occur. + + .. note:: + + For the esp8266 and nrf ports the call returns while the last byte is sent. + If required, a one character wait time has to be added in the calling script. + + Availability: rp2, esp32, esp8266, mimxrt, cc3200, stm32, nrf ports, renesas-ra + """ + ... + def txdone(self) -> bool: + """ + Tells whether all data has been sent or no data transfer is happening. In this case, + it returns ``True``. If a data transmission is ongoing it returns ``False``. + + .. note:: + + For the esp8266 and nrf ports the call may return ``True`` even if the last byte + of a transfer is still being sent. If required, a one character wait time has to be + added in the calling script. + + Availability: rp2, esp32, esp8266, mimxrt, cc3200, stm32, nrf ports, renesas-ra + """ + ... + + @overload + def read(self) -> bytes | None: + """ + Read characters. If ``nbytes`` is specified then read at most that many bytes, + otherwise read as much data as possible. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: a bytes object containing the bytes read in. Returns ``None`` + on timeout. + """ + + @overload + def read(self, nbytes: int, /) -> bytes | None: + """ + Read characters. If ``nbytes`` is specified then read at most that many bytes, + otherwise read as much data as possible. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: a bytes object containing the bytes read in. Returns ``None`` + on timeout. + """ + def any(self) -> int: + """ + Returns an integer counting the number of characters that can be read without + blocking. It will return 0 if there are no characters available and a positive + number if there are characters. The method may return 1 even if there is more + than one character available for reading. + + For more sophisticated querying of available characters use select.poll:: + + poll = select.poll() + poll.register(uart, select.POLLIN) + poll.poll(timeout) + """ + ... + def write(self, buf: AnyReadableBuf, /) -> Union[int, None]: + """ + Write the buffer of bytes to the bus. + + Return value: number of bytes written or ``None`` on timeout. + """ + ... + + @overload + def readinto(self, buf: AnyWritableBuf, /) -> int | None: + """ + Read bytes into the ``buf``. If ``nbytes`` is specified then read at most + that many bytes. Otherwise, read at most ``len(buf)`` bytes. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: number of bytes read and stored into ``buf`` or ``None`` on + timeout. + """ + + @overload + def readinto(self, buf: AnyWritableBuf, nbytes: int, /) -> int | None: + """ + Read bytes into the ``buf``. If ``nbytes`` is specified then read at most + that many bytes. Otherwise, read at most ``len(buf)`` bytes. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: number of bytes read and stored into ``buf`` or ``None`` on + timeout. + """ + def readline(self) -> Union[str, None]: + """ + Read a line, ending in a newline character. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: the line read or ``None`` on timeout. + """ + ... + @overload + def __init__( + self, + id: ID_T, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + tx: PinLike | None = None, + rx: PinLike | None = None, + txbuf: int | None = None, + rxbuf: int | None = None, + timeout: int | None = None, + timeout_char: int | None = None, + invert: int | None = None, + ): + """ + Construct a UART object of the given id. + """ + + @overload + def __init__( + self, + id: ID_T, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + pins: tuple[PinLike, PinLike] | None = None, + ): + """ + Construct a UART object of the given id from a tuple of two pins. + """ + + @overload + def __init__( + self, + id: ID_T, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + pins: tuple[PinLike, PinLike, PinLike, PinLike] | None = None, + ): + """ + Construct a UART object of the given id from a tuple of four pins. + """ + +class USBDevice: + """ + Construct a USBDevice object. + + ``Note:`` This object is a singleton, each call to this constructor + returns the same object reference. + """ + + BUILTIN_NONE: Incomplete + BUILTIN_DEFAULT: Incomplete + BUILTIN_CDC: Incomplete + BUILTIN_MSC: Incomplete + BUILTIN_CDC_MSC: int + def submit_xfer(self, ep, buffer, /) -> bool: + """ + Submit a USB transfer on endpoint number ``ep``. ``buffer`` must be + an object implementing the buffer interface, with read access for + ``IN`` endpoints and write access for ``OUT`` endpoints. + + ``Note:`` ``ep`` cannot be the control Endpoint number 0. Control + transfers are built up through successive executions of + ``control_xfer_cb``, see above. + + Returns ``True`` if successful, ``False`` if the transfer could not + be queued (as USB device is not configured by host, or because + another transfer is queued on this endpoint.) + + When the USB host completes the transfer, the ``xfer_cb`` callback + is called (see above). + + Raises ``OSError`` with reason ``MP_EINVAL`` If the USB device is not + active. + """ + ... + def config( + self, + desc_dev, + desc_cfg, + desc_strs=None, + open_itf_cb=None, + reset_cb=None, + control_xfer_cb=None, + xfer_cb=None, + ) -> None: + """ + Configures the ``USBDevice`` singleton object with the USB runtime device + state and callback functions: + + - ``desc_dev`` - A bytes-like object containing + the new USB device descriptor. + + - ``desc_cfg`` - A bytes-like object containing the + new USB configuration descriptor. + + - ``desc_strs`` - Optional object holding strings or bytes objects + containing USB string descriptor values. Can be a list, a dict, or any + object which supports subscript indexing with integer keys (USB string + descriptor index). + + Strings are an optional USB feature, and this parameter can be unset + (default) if no strings are referenced in the device and configuration + descriptors, or if only built-in strings should be used. + + Apart from index 0, all the string values should be plain ASCII. Index 0 + is the special "languages" USB descriptor, represented as a bytes object + with a custom format defined in the USB standard. ``None`` can be + returned at index 0 in order to use a default "English" language + descriptor. + + To fall back to providing a built-in string value for a given index, a + subscript lookup can return ``None``, raise ``KeyError``, or raise + ``IndexError``. + + - ``open_itf_cb`` - This callback is called once for each interface + or Interface Association Descriptor in response to a Set + Configuration request from the USB Host (the final stage before + the USB device is available to the host). + + The callback takes a single argument, which is a memoryview of the + interface or IAD descriptor that the host is accepting (including + all associated descriptors). It is a view into the same + ``desc_cfg`` object that was provided as a separate + argument to this function. The memoryview is only valid until the + callback function returns. + + - ``reset_cb`` - This callback is called when the USB host performs + a bus reset. The callback takes no arguments. Any in-progress + transfers will never complete. The USB host will most likely + proceed to re-enumerate the USB device by calling the descriptor + callbacks and then ``open_itf_cb()``. + + - ``control_xfer_cb`` - This callback is called one or more times + for each USB control transfer (device Endpoint 0). It takes two + arguments. + + The first argument is the control transfer stage. It is one of: + + - ``1`` for SETUP stage. + - ``2`` for DATA stage. + - ``3`` for ACK stage. + + Second argument is a memoryview to read the USB control request + data for this stage. The memoryview is only valid until the + callback function returns. Data in this memoryview will be the same + across each of the three stages of a single transfer. + + A successful transfer consists of this callback being called in sequence + for the three stages. Generally speaking, if a device wants to do + something in response to a control request then it's best to wait until + the ACK stage to confirm the host controller completed the transfer as + expected. + + The callback should return one of the following values: + + - ``False`` to stall the endpoint and reject the transfer. It won't + proceed to any remaining stages. + - ``True`` to continue the transfer to the next stage. + - A buffer object can be returned at the SETUP stage when the transfer + will send or receive additional data. Typically this is the case when + the ``wLength`` field in the request has a non-zero value. This should + be a writable buffer for an ``OUT`` direction transfer, or a readable + buffer with data for an ``IN`` direction transfer. + + - ``xfer_cb`` - This callback is called whenever a non-control + transfer submitted by calling :func:`USBDevice.submit_xfer` completes. + + The callback has three arguments: + + 1. The Endpoint number for the completed transfer. + 2. Result value: ``True`` if the transfer succeeded, ``False`` + otherwise. + 3. Number of bytes successfully transferred. In the case of a + "short" transfer, The result is ``True`` and ``xferred_bytes`` + will be smaller than the length of the buffer submitted for the + transfer. + + ``Note:`` If a bus reset occurs (see :func:`USBDevice.reset`), + ``xfer_cb`` is not called for any transfers that have not + already completed. + """ + ... + def remote_wakeup(self) -> bool: + """ + Wake up host if we are in suspend mode and the REMOTE_WAKEUP feature + is enabled by the host. This has to be enabled in the USB attributes, + and on the host. Returns ``True`` if remote wakeup was enabled and + active and the host was woken up. + """ + ... + def stall(self, ep, stall: bool | None = None, /) -> bool: + """ + Calling this function gets or sets the STALL state of a device endpoint. + + ``ep`` is the number of the endpoint. + + If the optional ``stall`` parameter is set, this is a boolean flag + for the STALL state. + + The return value is the current stall state of the endpoint (before + any change made by this function). + + An endpoint that is set to STALL may remain stalled until this + function is called again, or STALL may be cleared automatically by + the USB host. + + Raises ``OSError`` with reason ``MP_EINVAL`` If the USB device is not + active. + """ + ... + def active(self, value: Any | None = None, /) -> bool: + """ + Returns the current active state of this runtime USB device as a + boolean. The runtime USB device is "active" when it is available to + interact with the host, it doesn't mean that a USB Host is actually + present. + + If the optional ``value`` argument is set to a truthy value, then + the USB device will be activated. + + If the optional ``value`` argument is set to a falsey value, then + the USB device is deactivated. While the USB device is deactivated, + it will not be detected by the USB Host. + + To simulate a disconnect and a reconnect of the USB device, call + ``active(False)`` followed by ``active(True)``. This may be + necessary if the runtime device configuration has changed, so that + the host sees the new device. + """ + ... + + class BUILTIN_CDC: + ep_max: int = 3 + itf_max: int = 2 + str_max: int = 5 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"\t\x02K\x00\x02\x01\x00\x80}\x08\x0b\x00\x02\x02\x02\x00\x00\t\x04\x00\x00\x01\x02\x02\x00\x04\x05$\x00 \x01\x05$\x01\x00\x01\x04$\x02\x06\x05$\x06\x00\x01\x07\x05\x81\x03\x08\x00\x01\t\x04\x01\x00\x02\n\x00\x00\x00\x07\x05\x02\x02@\x00\x00\x07\x05\x82\x02@\x00\x00" + def __init__(self, *argv, **kwargs) -> None: ... + + class BUILTIN_NONE: + ep_max: int = 0 + itf_max: int = 0 + str_max: int = 1 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"" + def __init__(self, *argv, **kwargs) -> None: ... + + class BUILTIN_DEFAULT: + ep_max: int = 3 + itf_max: int = 2 + str_max: int = 5 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"\t\x02K\x00\x02\x01\x00\x80}\x08\x0b\x00\x02\x02\x02\x00\x00\t\x04\x00\x00\x01\x02\x02\x00\x04\x05$\x00 \x01\x05$\x01\x00\x01\x04$\x02\x06\x05$\x06\x00\x01\x07\x05\x81\x03\x08\x00\x01\t\x04\x01\x00\x02\n\x00\x00\x00\x07\x05\x02\x02@\x00\x00\x07\x05\x82\x02@\x00\x00" + def __init__(self, *argv, **kwargs) -> None: ... + + def __init__(self) -> None: ... + +class Pin: + """ + A pin object is used to control I/O pins (also known as GPIO - general-purpose + input/output). Pin objects are commonly associated with a physical pin that can + drive an output voltage and read input voltages. The pin class has methods to set the mode of + the pin (IN, OUT, etc) and methods to get and set the digital logic level. + For analog control of a pin, see the :class:`ADC` class. + + A pin object is constructed by using an identifier which unambiguously + specifies a certain I/O pin. The allowed forms of the identifier and the + physical pin that the identifier maps to are port-specific. Possibilities + for the identifier are an integer, a string or a tuple with port and pin + number. + + Usage Model:: + + from machine import Pin + + # create an output pin on pin #0 + p0 = Pin(0, Pin.OUT) + + # set the value low then high + p0.value(0) + p0.value(1) + + # create an input pin on pin #2, with a pull up resistor + p2 = Pin(2, Pin.IN, Pin.PULL_UP) + + # read and print the pin value + print(p2.value()) + + # reconfigure pin #0 in input mode with a pull down resistor + p0.init(p0.IN, p0.PULL_DOWN) + + # configure an irq callback + p0.irq(lambda p:print(p)) + """ + + ALT_SPI: Final[int] = 1 + IN: Final[int] = 0 + """Selects the pin mode.""" + ALT_USB: Final[int] = 9 + ALT_UART: Final[int] = 2 + IRQ_FALLING: Final[int] = 4 + """Selects the IRQ trigger type.""" + OUT: Final[int] = 1 + """Selects the pin mode.""" + OPEN_DRAIN: Final[int] = 2 + """Selects the pin mode.""" + IRQ_RISING: Final[int] = 8 + """Selects the IRQ trigger type.""" + PULL_DOWN: Final[int] = 2 + """\ + Selects whether there is a pull up/down resistor. Use the value + ``None`` for no pull. + """ + ALT_SIO: Final[int] = 5 + ALT_GPCK: Final[int] = 8 + ALT: Final[int] = 3 + """Selects the pin mode.""" + PULL_UP: Final[int] = 1 + """\ + Selects whether there is a pull up/down resistor. Use the value + ``None`` for no pull. + """ + ALT_I2C: Final[int] = 3 + ALT_PWM: Final[int] = 4 + ALT_PIO1: Final[int] = 7 + ALT_PIO0: Final[int] = 6 + ALT_OPEN_DRAIN: Incomplete + ANALOG: Incomplete + PULL_HOLD: Incomplete + DRIVE_0: int + DRIVE_1: int + DRIVE_2: int + IRQ_LOW_LEVEL: Incomplete + IRQ_HIGH_LEVEL: Incomplete + def low(self) -> None: + """ + Set pin to "0" output level. + + Availability: mimxrt, nrf, renesas-ra, rp2, samd, stm32 ports. + """ + ... + def irq( + self, + /, + handler: Callable[[Pin], None] | None = None, + trigger: int = (IRQ_FALLING | IRQ_RISING), + *, + priority: int = 1, + wake: int | None = None, + hard: bool = False, + ) -> Callable[..., Incomplete]: + """ + Configure an interrupt handler to be called when the trigger source of the + pin is active. If the pin mode is ``Pin.IN`` then the trigger source is + the external value on the pin. If the pin mode is ``Pin.OUT`` then the + trigger source is the output buffer of the pin. Otherwise, if the pin mode + is ``Pin.OPEN_DRAIN`` then the trigger source is the output buffer for + state '0' and the external pin value for state '1'. + + The arguments are: + + - ``handler`` is an optional function to be called when the interrupt + triggers. The handler must take exactly one argument which is the + ``Pin`` instance. + + - ``trigger`` configures the event which can generate an interrupt. + Possible values are: + + - ``Pin.IRQ_FALLING`` interrupt on falling edge. + - ``Pin.IRQ_RISING`` interrupt on rising edge. + - ``Pin.IRQ_LOW_LEVEL`` interrupt on low level. + - ``Pin.IRQ_HIGH_LEVEL`` interrupt on high level. + + These values can be OR'ed together to trigger on multiple events. + + - ``priority`` sets the priority level of the interrupt. The values it + can take are port-specific, but higher values always represent higher + priorities. + + - ``wake`` selects the power mode in which this interrupt can wake up the + system. It can be ``machine.IDLE``, ``machine.SLEEP`` or ``machine.DEEPSLEEP``. + These values can also be OR'ed together to make a pin generate interrupts in + more than one power mode. + + - ``hard`` if true a hardware interrupt is used. This reduces the delay + between the pin change and the handler being called. Hard interrupt + handlers may not allocate memory; see :ref:`isr_rules`. + Not all ports support this argument. + + This method returns a callback object. + + The following methods are not part of the core Pin API and only implemented on certain ports. + """ + ... + def toggle(self) -> Incomplete: + """ + Toggle output pin from "0" to "1" or vice-versa. + + Availability: cc3200, esp32, esp8266, mimxrt, rp2, samd ports. + """ + ... + def off(self) -> None: + """ + Set pin to "0" output level. + """ + ... + def on(self) -> None: + """ + Set pin to "1" output level. + """ + ... + def init( + self, + mode: int = -1, + pull: int = -1, + *, + value: Any = None, + drive: int | None = None, + alt: int | None = None, + ) -> None: + """ + Re-initialise the pin using the given parameters. Only those arguments that + are specified will be set. The rest of the pin peripheral state will remain + unchanged. See the constructor documentation for details of the arguments. + + Returns ``None``. + """ + ... + + @overload + def value(self) -> int: + """ + This method allows to set and get the value of the pin, depending on whether + the argument ``x`` is supplied or not. + + If the argument is omitted then this method gets the digital logic level of + the pin, returning 0 or 1 corresponding to low and high voltage signals + respectively. The behaviour of this method depends on the mode of the pin: + + - ``Pin.IN`` - The method returns the actual input value currently present + on the pin. + - ``Pin.OUT`` - The behaviour and return value of the method is undefined. + - ``Pin.OPEN_DRAIN`` - If the pin is in state '0' then the behaviour and + return value of the method is undefined. Otherwise, if the pin is in + state '1', the method returns the actual input value currently present + on the pin. + + If the argument is supplied then this method sets the digital logic level of + the pin. The argument ``x`` can be anything that converts to a boolean. + If it converts to ``True``, the pin is set to state '1', otherwise it is set + to state '0'. The behaviour of this method depends on the mode of the pin: + + - ``Pin.IN`` - The value is stored in the output buffer for the pin. The + pin state does not change, it remains in the high-impedance state. The + stored value will become active on the pin as soon as it is changed to + ``Pin.OUT`` or ``Pin.OPEN_DRAIN`` mode. + - ``Pin.OUT`` - The output buffer is set to the given value immediately. + - ``Pin.OPEN_DRAIN`` - If the value is '0' the pin is set to a low voltage + state. Otherwise the pin is set to high-impedance state. + + When setting the value this method returns ``None``. + """ + + @overload + def value(self, x: Any, /) -> None: + """ + This method allows to set and get the value of the pin, depending on whether + the argument ``x`` is supplied or not. + + If the argument is omitted then this method gets the digital logic level of + the pin, returning 0 or 1 corresponding to low and high voltage signals + respectively. The behaviour of this method depends on the mode of the pin: + + - ``Pin.IN`` - The method returns the actual input value currently present + on the pin. + - ``Pin.OUT`` - The behaviour and return value of the method is undefined. + - ``Pin.OPEN_DRAIN`` - If the pin is in state '0' then the behaviour and + return value of the method is undefined. Otherwise, if the pin is in + state '1', the method returns the actual input value currently present + on the pin. + + If the argument is supplied then this method sets the digital logic level of + the pin. The argument ``x`` can be anything that converts to a boolean. + If it converts to ``True``, the pin is set to state '1', otherwise it is set + to state '0'. The behaviour of this method depends on the mode of the pin: + + - ``Pin.IN`` - The value is stored in the output buffer for the pin. The + pin state does not change, it remains in the high-impedance state. The + stored value will become active on the pin as soon as it is changed to + ``Pin.OUT`` or ``Pin.OPEN_DRAIN`` mode. + - ``Pin.OUT`` - The output buffer is set to the given value immediately. + - ``Pin.OPEN_DRAIN`` - If the value is '0' the pin is set to a low voltage + state. Otherwise the pin is set to high-impedance state. + + When setting the value this method returns ``None``. + """ + def high(self) -> None: + """ + Set pin to "1" output level. + + Availability: mimxrt, nrf, renesas-ra, rp2, samd, stm32 ports. + """ + ... + + class cpu: + GPIO20: Pin ## = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO25: Pin ## = Pin(GPIO25, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO26: Pin ## = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO27: Pin ## = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO24: Pin ## = Pin(GPIO24, mode=ALT, alt=31) + GPIO21: Pin ## = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO22: Pin ## = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO23: Pin ## = Pin(GPIO23, mode=ALT, alt=31) + GPIO28: Pin ## = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO6: Pin ## = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO7: Pin ## = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO8: Pin ## = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO5: Pin ## = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO29: Pin ## = Pin(GPIO29, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO3: Pin ## = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO4: Pin ## = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO9: Pin ## = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO2: Pin ## = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO1: Pin ## = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO10: Pin ## = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO11: Pin ## = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO0: Pin ## = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) + EXT_GPIO0: Pin ## = Pin(EXT_GPIO0, mode=IN) + EXT_GPIO1: Pin ## = Pin(EXT_GPIO1, mode=IN) + EXT_GPIO2: Pin ## = Pin(EXT_GPIO2, mode=IN) + GPIO12: Pin ## = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO17: Pin ## = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO18: Pin ## = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO19: Pin ## = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO16: Pin ## = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO13: Pin ## = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO14: Pin ## = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO15: Pin ## = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) + def __init__(self, *argv, **kwargs) -> None: ... + + class board: + GP3: Pin ## = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) + GP28: Pin ## = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) + GP4: Pin ## = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) + GP5: Pin ## = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) + GP22: Pin ## = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) + GP27: Pin ## = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) + GP26: Pin ## = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) + WL_GPIO2: Pin ## = Pin(EXT_GPIO2, mode=IN) + WL_GPIO0: Pin ## = Pin(EXT_GPIO0, mode=IN) + LED: Pin ## = Pin(EXT_GPIO0, mode=IN) + WL_GPIO1: Pin ## = Pin(EXT_GPIO1, mode=IN) + GP6: Pin ## = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) + GP7: Pin ## = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) + GP9: Pin ## = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) + GP8: Pin ## = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) + GP12: Pin ## = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) + GP11: Pin ## = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) + GP13: Pin ## = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) + GP14: Pin ## = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) + GP0: Pin ## = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) + GP10: Pin ## = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) + GP1: Pin ## = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) + GP21: Pin ## = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) + GP2: Pin ## = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) + GP19: Pin ## = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) + GP20: Pin ## = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) + GP15: Pin ## = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) + GP16: Pin ## = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) + GP18: Pin ## = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) + GP17: Pin ## = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) + def __init__(self, *argv, **kwargs) -> None: ... + + def __init__( + self, + id: Any, + /, + mode: int = -1, + pull: int = -1, + *, + value: Any = None, + drive: int | None = None, + alt: int | None = None, + ) -> None: + """ + Access the pin peripheral (GPIO pin) associated with the given ``id``. If + additional arguments are given in the constructor then they are used to initialise + the pin. Any settings that are not specified will remain in their previous state. + + The arguments are: + + - ``id`` is mandatory and can be an arbitrary object. Among possible value + types are: int (an internal Pin identifier), str (a Pin name), and tuple + (pair of [port, pin]). + + - ``mode`` specifies the pin mode, which can be one of: + + - ``Pin.IN`` - Pin is configured for input. If viewed as an output the pin + is in high-impedance state. + + - ``Pin.OUT`` - Pin is configured for (normal) output. + + - ``Pin.OPEN_DRAIN`` - Pin is configured for open-drain output. Open-drain + output works in the following way: if the output value is set to 0 the pin + is active at a low level; if the output value is 1 the pin is in a high-impedance + state. Not all ports implement this mode, or some might only on certain pins. + + - ``Pin.ALT`` - Pin is configured to perform an alternative function, which is + port specific. For a pin configured in such a way any other Pin methods + (except :meth:`Pin.init`) are not applicable (calling them will lead to undefined, + or a hardware-specific, result). Not all ports implement this mode. + + - ``Pin.ALT_OPEN_DRAIN`` - The Same as ``Pin.ALT``, but the pin is configured as + open-drain. Not all ports implement this mode. + + - ``Pin.ANALOG`` - Pin is configured for analog input, see the :class:`ADC` class. + + - ``pull`` specifies if the pin has a (weak) pull resistor attached, and can be + one of: + + - ``None`` - No pull up or down resistor. + - ``Pin.PULL_UP`` - Pull up resistor enabled. + - ``Pin.PULL_DOWN`` - Pull down resistor enabled. + + - ``value`` is valid only for Pin.OUT and Pin.OPEN_DRAIN modes and specifies initial + output pin value if given, otherwise the state of the pin peripheral remains + unchanged. + + - ``drive`` specifies the output power of the pin and can be one of: ``Pin.LOW_POWER``, + ``Pin.MED_POWER`` or ``Pin.HIGH_POWER``. The actual current driving capabilities + are port dependent. Not all ports implement this argument. + + - ``alt`` specifies an alternate function for the pin and the values it can take are + port dependent. This argument is valid only for ``Pin.ALT`` and ``Pin.ALT_OPEN_DRAIN`` + modes. It may be used when a pin supports more than one alternate function. If only + one pin alternate function is supported the this argument is not required. Not all + ports implement this argument. + + As specified above, the Pin class allows to set an alternate function for a particular + pin, but it does not specify any further operations on such a pin. Pins configured in + alternate-function mode are usually not used as GPIO but are instead driven by other + hardware peripherals. The only operation supported on such a pin is re-initialising, + by calling the constructor or :meth:`Pin.init` method. If a pin that is configured in + alternate-function mode is re-initialised with ``Pin.IN``, ``Pin.OUT``, or + ``Pin.OPEN_DRAIN``, the alternate function will be removed from the pin. + """ + + @overload + def __call__(self) -> int: + """ + Pin objects are callable. The call method provides a (fast) shortcut to set + and get the value of the pin. It is equivalent to Pin.value([x]). + See :meth:`Pin.value` for more details. + """ + + @overload + def __call__(self, x: Any, /) -> None: + """ + Pin objects are callable. The call method provides a (fast) shortcut to set + and get the value of the pin. It is equivalent to Pin.value([x]). + See :meth:`Pin.value` for more details. + """ + + @overload + def mode(self) -> int: + """ + Get or set the pin mode. + See the constructor documentation for details of the ``mode`` argument. + + Availability: cc3200, stm32 ports. + """ + + @overload + def mode(self, mode: int, /) -> None: + """ + Get or set the pin mode. + See the constructor documentation for details of the ``mode`` argument. + + Availability: cc3200, stm32 ports. + """ + + @overload + def pull(self) -> int: + """ + Get or set the pin pull state. + See the constructor documentation for details of the ``pull`` argument. + + Availability: cc3200, stm32 ports. + """ + + @overload + def pull(self, pull: int, /) -> None: + """ + Get or set the pin pull state. + See the constructor documentation for details of the ``pull`` argument. + + Availability: cc3200, stm32 ports. + """ + + @overload + def drive(self, drive: int, /) -> None: + """ + Get or set the pin drive strength. + See the constructor documentation for details of the ``drive`` argument. + + Availability: cc3200 port. + """ + ... + + @overload + def drive(self, /) -> int: + """ + Get or set the pin drive strength. + See the constructor documentation for details of the ``drive`` argument. + + Availability: cc3200 port. + """ + +class SoftI2C(I2C): + """ + Construct a new software I2C object. The parameters are: + + - *scl* should be a pin object specifying the pin to use for SCL. + - *sda* should be a pin object specifying the pin to use for SDA. + - *freq* should be an integer which sets the maximum frequency + for SCL. + - *timeout* is the maximum time in microseconds to wait for clock + stretching (SCL held low by another device on the bus), after + which an ``OSError(ETIMEDOUT)`` exception is raised. + """ + def readfrom_mem_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_mem(self, *args, **kwargs) -> Incomplete: ... + def writeto_mem(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def writeto(self, *args, **kwargs) -> Incomplete: ... + def writevto(self, *args, **kwargs) -> Incomplete: ... + def start(self, *args, **kwargs) -> Incomplete: ... + def readfrom(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def stop(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, scl, sda, *, freq=400000, timeout=50000) -> None: ... + +class RTC: + """ + The RTC is an independent clock that keeps track of the date + and time. + + Example usage:: + + rtc = machine.RTC() + rtc.datetime((2020, 1, 21, 2, 10, 32, 36, 0)) + print(rtc.datetime()) + + + + The documentation for RTC is in a poor state;1 + """ + + ALARM0: Incomplete + def datetime(self, datetimetuple: Any | None = None) -> Tuple: + """ + Get or set the date and time of the RTC. + + With no arguments, this method returns an 8-tuple with the current + date and time. With 1 argument (being an 8-tuple) it sets the date + and time. + + The 8-tuple has the following format: + + (year, month, day, weekday, hours, minutes, seconds, subseconds) + + The meaning of the ``subseconds`` field is hardware dependent. + """ + ... + @overload + def __init__(self, id: int = 0): + """ + Create an RTC object. See init for parameters of initialization. + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int, int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def init(self) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int, int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def alarm(self, id: int, time: int, /, *, repeat: bool = False) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int, int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + +class SPI: + """ + SPI is a synchronous serial protocol that is driven by a controller. At the + physical level, a bus consists of 3 lines: SCK, MOSI, MISO. Multiple devices + can share the same bus. Each device should have a separate, 4th signal, + CS (Chip Select), to select a particular device on a bus with which + communication takes place. Management of a CS signal should happen in + user code (via machine.Pin class). + + Both hardware and software SPI implementations exist via the + :ref:`machine.SPI ` and `machine.SoftSPI` classes. Hardware SPI uses underlying + hardware support of the system to perform the reads/writes and is usually + efficient and fast but may have restrictions on which pins can be used. + Software SPI is implemented by bit-banging and can be used on any pin but + is not as efficient. These classes have the same methods available and + differ primarily in the way they are constructed. + + Example usage:: + + from machine import SPI, Pin + + spi = SPI(0, baudrate=400000) # Create SPI peripheral 0 at frequency of 400kHz. + # Depending on the use case, extra parameters may be required + # to select the bus characteristics and/or pins to use. + cs = Pin(4, mode=Pin.OUT, value=1) # Create chip-select on pin 4. + + try: + cs(0) # Select peripheral. + spi.write(b"12345678") # Write 8 bytes, and don't care about received data. + finally: + cs(1) # Deselect peripheral. + + try: + cs(0) # Select peripheral. + rxdata = spi.read(8, 0x42) # Read 8 bytes while writing 0x42 for each byte. + finally: + cs(1) # Deselect peripheral. + + rxdata = bytearray(8) + try: + cs(0) # Select peripheral. + spi.readinto(rxdata, 0x42) # Read 8 bytes inplace while writing 0x42 for each byte. + finally: + cs(1) # Deselect peripheral. + + txdata = b"12345678" + rxdata = bytearray(len(txdata)) + try: + cs(0) # Select peripheral. + spi.write_readinto(txdata, rxdata) # Simultaneously write and read bytes. + finally: + cs(1) # Deselect peripheral. + """ + + LSB: Final[int] = 0 + """set the first bit to be the least significant bit""" + MSB: Final[int] = 1 + """set the first bit to be the most significant bit""" + CONTROLLER: Incomplete + def deinit(self) -> None: + """ + Turn off the SPI bus. + """ + ... + + @overload + def init( + self, + baudrate: int = 1_000_000, + *, + polarity: int = 0, + phase: int = 0, + bits: int = 8, + firstbit: int = MSB, + sck: PinLike | None = None, + mosi: PinLike | None = None, + miso: PinLike | None = None, + ) -> None: + """ + Initialise the SPI bus with the given parameters: + + - ``baudrate`` is the SCK clock rate. + - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. + - ``phase`` can be 0 or 1 to sample data on the first or second clock edge + respectively. + - ``bits`` is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware. + - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. + - ``sck``, ``mosi``, ``miso`` are pins (machine.Pin) objects to use for bus signals. For most + hardware SPI blocks (as selected by ``id`` parameter to the constructor), pins are fixed + and cannot be changed. In some cases, hardware blocks allow 2-3 alternative pin sets for + a hardware SPI block. Arbitrary pin assignments are possible only for a bitbanging SPI driver + (``id`` = -1). + - ``pins`` - WiPy port doesn't ``sck``, ``mosi``, ``miso`` arguments, and instead allows to + specify them as a tuple of ``pins`` parameter. + + In the case of hardware SPI the actual clock frequency may be lower than the + requested baudrate. This is dependent on the platform hardware. The actual + rate may be determined by printing the SPI object. + """ + + @overload + def init( + self, + baudrate: int = 1_000_000, + *, + polarity: int = 0, + phase: int = 0, + bits: int = 8, + firstbit: int = MSB, + pins: tuple[PinLike, PinLike, PinLike] | None = None, + ) -> None: + """ + Initialise the SPI bus with the given parameters: + + - ``baudrate`` is the SCK clock rate. + - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. + - ``phase`` can be 0 or 1 to sample data on the first or second clock edge + respectively. + - ``bits`` is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware. + - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. + - ``sck``, ``mosi``, ``miso`` are pins (machine.Pin) objects to use for bus signals. For most + hardware SPI blocks (as selected by ``id`` parameter to the constructor), pins are fixed + and cannot be changed. In some cases, hardware blocks allow 2-3 alternative pin sets for + a hardware SPI block. Arbitrary pin assignments are possible only for a bitbanging SPI driver + (``id`` = -1). + - ``pins`` - WiPy port doesn't ``sck``, ``mosi``, ``miso`` arguments, and instead allows to + specify them as a tuple of ``pins`` parameter. + + In the case of hardware SPI the actual clock frequency may be lower than the + requested baudrate. This is dependent on the platform hardware. The actual + rate may be determined by printing the SPI object. + """ + def write_readinto(self, write_buf: AnyReadableBuf, read_buf: AnyWritableBuf, /) -> int: + """ + Write the bytes from ``write_buf`` while reading into ``read_buf``. The + buffers can be the same or different, but both buffers must have the + same length. + Returns ``None``. + + Note: on WiPy this function returns the number of bytes written. + """ + ... + def read(self, nbytes: int, write: int = 0x00, /) -> bytes: + """ + Read a number of bytes specified by ``nbytes`` while continuously writing + the single byte given by ``write``. + Returns a ``bytes`` object with the data that was read. + """ + ... + def write(self, buf: AnyReadableBuf, /) -> int: + """ + Write the bytes contained in ``buf``. + Returns ``None``. + + Note: on WiPy this function returns the number of bytes written. + """ + ... + def readinto(self, buf: AnyWritableBuf, write: int = 0x00, /) -> int: + """ + Read into the buffer specified by ``buf`` while continuously writing the + single byte given by ``write``. + Returns ``None``. + + Note: on WiPy this function returns the number of bytes read. + """ + ... + @overload + def __init__(self, id: int, /): + """ + Construct an SPI object on the given bus, *id*. Values of *id* depend + on a particular port and its hardware. Values 0, 1, etc. are commonly used + to select hardware SPI block #0, #1, etc. + + With no additional parameters, the SPI object is created but not + initialised (it has the settings from the last initialisation of + the bus, if any). If extra arguments are given, the bus is initialised. + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + baudrate: int = 1_000_000, + *, + polarity: int = 0, + phase: int = 0, + bits: int = 8, + firstbit: int = MSB, + sck: PinLike | None = None, + mosi: PinLike | None = None, + miso: PinLike | None = None, + ): + """ + Construct an SPI object on the given bus, *id*. Values of *id* depend + on a particular port and its hardware. Values 0, 1, etc. are commonly used + to select hardware SPI block #0, #1, etc. + + With no additional parameters, the SPI object is created but not + initialised (it has the settings from the last initialisation of + the bus, if any). If extra arguments are given, the bus is initialised. + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + baudrate: int = 1_000_000, + *, + polarity: int = 0, + phase: int = 0, + bits: int = 8, + firstbit: int = MSB, + pins: tuple[PinLike, PinLike, PinLike] | None = None, + ): + """ + Construct an SPI object on the given bus, *id*. Values of *id* depend + on a particular port and its hardware. Values 0, 1, etc. are commonly used + to select hardware SPI block #0, #1, etc. + + With no additional parameters, the SPI object is created but not + initialised (it has the settings from the last initialisation of + the bus, if any). If extra arguments are given, the bus is initialised. + See ``init`` for parameters of initialisation. + """ + +class Signal(Pin): + """ + The Signal class is a simple extension of the `Pin` class. Unlike Pin, which + can be only in "absolute" 0 and 1 states, a Signal can be in "asserted" + (on) or "deasserted" (off) states, while being inverted (active-low) or + not. In other words, it adds logical inversion support to Pin functionality. + While this may seem a simple addition, it is exactly what is needed to + support wide array of simple digital devices in a way portable across + different boards, which is one of the major MicroPython goals. Regardless + of whether different users have an active-high or active-low LED, a normally + open or normally closed relay - you can develop a single, nicely looking + application which works with each of them, and capture hardware + configuration differences in few lines in the config file of your app. + + Example:: + + from machine import Pin, Signal + + # Suppose you have an active-high LED on pin 0 + led1_pin = Pin(0, Pin.OUT) + # ... and active-low LED on pin 1 + led2_pin = Pin(1, Pin.OUT) + + # Now to light up both of them using Pin class, you'll need to set + # them to different values + led1_pin.value(1) + led2_pin.value(0) + + # Signal class allows to abstract away active-high/active-low + # difference + led1 = Signal(led1_pin, invert=False) + led2 = Signal(led2_pin, invert=True) + + # Now lighting up them looks the same + led1.value(1) + led2.value(1) + + # Even better: + led1.on() + led2.on() + + Following is the guide when Signal vs Pin should be used: + + * Use Signal: If you want to control a simple on/off (including software + PWM!) devices like LEDs, multi-segment indicators, relays, buzzers, or + read simple binary sensors, like normally open or normally closed buttons, + pulled high or low, Reed switches, moisture/flame detectors, etc. etc. + Summing up, if you have a real physical device/sensor requiring GPIO + access, you likely should use a Signal. + + * Use Pin: If you implement a higher-level protocol or bus to communicate + with more complex devices. + + The split between Pin and Signal come from the use cases above and the + architecture of MicroPython: Pin offers the lowest overhead, which may + be important when bit-banging protocols. But Signal adds additional + flexibility on top of Pin, at the cost of minor overhead (much smaller + than if you implemented active-high vs active-low device differences in + Python manually!). Also, Pin is a low-level object which needs to be + implemented for each support board, while Signal is a high-level object + which comes for free once Pin is implemented. + + If in doubt, give the Signal a try! Once again, it is offered to save + developers from the need to handle unexciting differences like active-low + vs active-high signals, and allow other users to share and enjoy your + application, instead of being frustrated by the fact that it doesn't + work for them simply because their LEDs or relays are wired in a slightly + different way. + """ + def off(self) -> None: + """ + Deactivate signal. + """ + ... + def on(self) -> None: + """ + Activate signal. + """ + ... + + @overload + def value(self) -> int: + """ + This method allows to set and get the value of the signal, depending on whether + the argument ``x`` is supplied or not. + + If the argument is omitted then this method gets the signal level, 1 meaning + signal is asserted (active) and 0 - signal inactive. + + If the argument is supplied then this method sets the signal level. The + argument ``x`` can be anything that converts to a boolean. If it converts + to ``True``, the signal is active, otherwise it is inactive. + + Correspondence between signal being active and actual logic level on the + underlying pin depends on whether signal is inverted (active-low) or not. + For non-inverted signal, active status corresponds to logical 1, inactive - + to logical 0. For inverted/active-low signal, active status corresponds + to logical 0, while inactive - to logical 1. + """ + + @overload + def value(self, x: Any, /) -> None: + """ + This method allows to set and get the value of the signal, depending on whether + the argument ``x`` is supplied or not. + + If the argument is omitted then this method gets the signal level, 1 meaning + signal is asserted (active) and 0 - signal inactive. + + If the argument is supplied then this method sets the signal level. The + argument ``x`` can be anything that converts to a boolean. If it converts + to ``True``, the signal is active, otherwise it is inactive. + + Correspondence between signal being active and actual logic level on the + underlying pin depends on whether signal is inverted (active-low) or not. + For non-inverted signal, active status corresponds to logical 1, inactive - + to logical 0. For inverted/active-low signal, active status corresponds + to logical 0, while inactive - to logical 1. + """ + + @overload + def __init__(self, pin_obj: PinLike, invert: bool = False, /): + """ + Create a Signal object. There're two ways to create it: + + * By wrapping existing Pin object - universal method which works for + any board. + * By passing required Pin parameters directly to Signal constructor, + skipping the need to create intermediate Pin object. Available on + many, but not all boards. + + The arguments are: + + - ``pin_obj`` is existing Pin object. + + - ``pin_arguments`` are the same arguments as can be passed to Pin constructor. + + - ``invert`` - if True, the signal will be inverted (active low). + """ + + @overload + def __init__( + self, + id: PinLike, + /, + mode: int = -1, + pull: int = -1, + *, + value: Any = None, + drive: int | None = None, + alt: int | None = None, + invert: bool = False, + ): + """ + Create a Signal object. There're two ways to create it: + + * By wrapping existing Pin object - universal method which works for + any board. + * By passing required Pin parameters directly to Signal constructor, + skipping the need to create intermediate Pin object. Available on + many, but not all boards. + + The arguments are: + + - ``pin_obj`` is existing Pin object. + + - ``pin_arguments`` are the same arguments as can be passed to Pin constructor. + + - ``invert`` - if True, the signal will be inverted (active low). + """ + +class ADCBlock: + @overload + def connect(self, channel: int, **kwargs) -> ADC: ... + @overload + def connect(self, source: PinLike, **kwargs) -> ADC: ... + @overload + def connect(self, channel: int, source: PinLike, **kwargs) -> ADC: + """ + Connect up a channel on the ADC peripheral so it is ready for sampling, + and return an :ref:`ADC ` object that represents that connection. + + The *channel* argument must be an integer, and *source* must be an object + (for example a :ref:`Pin `) which can be connected up for sampling. + + If only *channel* is given then it is configured for sampling. + + If only *source* is given then that object is connected to a default + channel ready for sampling. + + If both *channel* and *source* are given then they are connected together + and made ready for sampling. + + Any additional keyword arguments are used to configure the returned ADC object, + via its :meth:`init ` method. + """ + ... + +class SDCard: + @overload + def readblocks(self, block_num: int, buf: bytearray) -> bool: + """ + The first form reads aligned, multiples of blocks. + Starting at the block given by the index *block_num*, read blocks from + the device into *buf* (an array of bytes). + The number of blocks to read is given by the length of *buf*, + which will be a multiple of the block size. + """ + + @overload + def readblocks(self, block_num: int, buf: bytearray, offset: int) -> bool: + """ + The second form allows reading at arbitrary locations within a block, + and arbitrary lengths. + Starting at block index *block_num*, and byte offset within that block + of *offset*, read bytes from the device into *buf* (an array of bytes). + The number of bytes to read is given by the length of *buf*. + """ + + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, /) -> None: + """ + The first form writes aligned, multiples of blocks, and requires that the + blocks that are written to be first erased (if necessary) by this method. + Starting at the block given by the index *block_num*, write blocks from + *buf* (an array of bytes) to the device. + The number of blocks to write is given by the length of *buf*, + which will be a multiple of the block size. + """ + + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, offset: int, /) -> None: + """ + The second form allows writing at arbitrary locations within a block, + and arbitrary lengths. Only the bytes being written should be changed, + and the caller of this method must ensure that the relevant blocks are + erased via a prior ``ioctl`` call. + Starting at block index *block_num*, and byte offset within that block + of *offset*, write bytes from *buf* (an array of bytes) to the device. + The number of bytes to write is given by the length of *buf*. + + Note that implementations must never implicitly erase blocks if the offset + argument is specified, even if it is zero. + """ diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/math.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/math.pyi new file mode 100644 index 0000000000..1d5f007d33 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/math.pyi @@ -0,0 +1,269 @@ +""" +Mathematical functions. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/math.html + +CPython module: :mod:`python:math` https://docs.python.org/3/library/math.html . + +The ``math`` module provides some basic mathematical functions for +working with floating-point numbers. + +*Note:* On the pyboard, floating-point numbers have 32-bit precision. + +Availability: not available on WiPy. Floating point support required +for this module. + +--- +Module: 'math' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import SupportsFloat, Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +inf: float = inf +nan: float = nan +pi: float = 3.1415928 +"""the ratio of a circle's circumference to its diameter""" +e: float = 2.7182818 +"""base of the natural logarithm""" +tau: float = 6.2831856 + +def ldexp(x: SupportsFloat, exp: int, /) -> float: + """ + Return ``x * (2**exp)``. + """ + ... + +def lgamma(x: SupportsFloat, /) -> float: + """ + Return the natural logarithm of the gamma function of ``x``. + """ + ... + +def trunc(x: SupportsFloat, /) -> int: + """ + Return an integer, being ``x`` rounded towards 0. + """ + ... + +def isclose(*args, **kwargs) -> Incomplete: ... +def gamma(x: SupportsFloat, /) -> float: + """ + Return the gamma function of ``x``. + """ + ... + +def isnan(x: SupportsFloat, /) -> bool: + """ + Return ``True`` if ``x`` is not-a-number + """ + ... + +def isfinite(x: SupportsFloat, /) -> bool: + """ + Return ``True`` if ``x`` is finite. + """ + ... + +def isinf(x: SupportsFloat, /) -> bool: + """ + Return ``True`` if ``x`` is infinite. + """ + ... + +def sqrt(x: SupportsFloat, /) -> float: + """ + Return the square root of ``x``. + """ + ... + +def sinh(x: SupportsFloat, /) -> float: + """ + Return the hyperbolic sine of ``x``. + """ + ... + +def log(x: SupportsFloat, /) -> float: + """ + With one argument, return the natural logarithm of *x*. + + With two arguments, return the logarithm of *x* to the given *base*. + """ + ... + +def tan(x: SupportsFloat, /) -> float: + """ + Return the tangent of ``x``. + """ + ... + +def tanh(x: SupportsFloat, /) -> float: + """ + Return the hyperbolic tangent of ``x``. + """ + ... + +def log2(x: SupportsFloat, /) -> float: + """ + Return the base-2 logarithm of ``x``. + """ + ... + +def log10(x: SupportsFloat, /) -> float: + """ + Return the base-10 logarithm of ``x``. + """ + ... + +def sin(x: SupportsFloat, /) -> float: + """ + Return the sine of ``x``. + """ + ... + +def modf(x: SupportsFloat, /) -> Tuple: + """ + Return a tuple of two floats, being the fractional and integral parts of + ``x``. Both return values have the same sign as ``x``. + """ + ... + +def radians(x: SupportsFloat, /) -> float: + """ + Return degrees ``x`` converted to radians. + """ + ... + +def atanh(x: SupportsFloat, /) -> float: + """ + Return the inverse hyperbolic tangent of ``x``. + """ + ... + +def atan2(y: SupportsFloat, x: SupportsFloat, /) -> float: + """ + Return the principal value of the inverse tangent of ``y/x``. + """ + ... + +def atan(x: SupportsFloat, /) -> float: + """ + Return the inverse tangent of ``x``. + """ + ... + +def ceil(x: SupportsFloat, /) -> int: + """ + Return an integer, being ``x`` rounded towards positive infinity. + """ + ... + +def copysign(x: SupportsFloat, y: SupportsFloat, /) -> float: + """ + Return ``x`` with the sign of ``y``. + """ + ... + +def frexp(x: SupportsFloat, /) -> tuple[float, 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`` + exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise + the relation ``0.5 <= abs(m) < 1`` holds. + """ + ... + +def acos(x: SupportsFloat, /) -> float: + """ + Return the inverse cosine of ``x``. + """ + ... + +def pow(x: SupportsFloat, y: SupportsFloat, /) -> float: + """ + Returns ``x`` to the power of ``y``. + """ + ... + +def asinh(x: SupportsFloat, /) -> float: + """ + Return the inverse hyperbolic sine of ``x``. + """ + ... + +def acosh(x: SupportsFloat, /) -> float: + """ + Return the inverse hyperbolic cosine of ``x``. + """ + ... + +def asin(x: SupportsFloat, /) -> float: + """ + Return the inverse sine of ``x``. + """ + ... + +def factorial(*args, **kwargs) -> Incomplete: ... +def fabs(x: SupportsFloat, /) -> float: + """ + Return the absolute value of ``x``. + """ + ... + +def expm1(x: SupportsFloat, /) -> float: + """ + Return ``exp(x) - 1``. + """ + ... + +def floor(x: SupportsFloat, /) -> int: + """ + Return an integer, being ``x`` rounded towards negative infinity. + """ + ... + +def fmod(x: SupportsFloat, y: SupportsFloat, /) -> float: + """ + Return the remainder of ``x/y``. + """ + ... + +def cos(x: SupportsFloat, /) -> float: + """ + Return the cosine of ``x``. + """ + ... + +def degrees(x: SupportsFloat, /) -> float: + """ + Return radians ``x`` converted to degrees. + """ + ... + +def cosh(x: SupportsFloat, /) -> float: + """ + Return the hyperbolic cosine of ``x``. + """ + ... + +def exp(x: SupportsFloat, /) -> float: + """ + Return the exponential of ``x``. + """ + ... + +def erf(x: SupportsFloat, /) -> float: + """ + Return the error function of ``x``. + """ + ... + +def erfc(x: SupportsFloat, /) -> float: + """ + Return the complementary error function of ``x``. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/micropython.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/micropython.pyi new file mode 100644 index 0000000000..4c83f10c9f --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/micropython.pyi @@ -0,0 +1,346 @@ +""" +Access and control MicroPython internals. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/micropython.html + +--- +Module: 'micropython' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import mp_available +from typing import Any, Callable, Optional, Tuple, overload +from typing_extensions import Awaitable, ParamSpec, TypeAlias, TypeVar + +_T = TypeVar("_T") +_F = TypeVar("_F", bound=Callable[..., Any]) +Const_T = TypeVar("Const_T", int, float, str, bytes, Tuple) +_Param = ParamSpec("_Param") +_Ret = TypeVar("_Ret") + +@overload +def opt_level() -> int: + """ + If *level* is given then this function sets the optimisation level for subsequent + compilation of scripts, and returns ``None``. Otherwise it returns the current + optimisation level. + + The optimisation level controls the following compilation features: + + - Assertions: at level 0 assertion statements are enabled and compiled into the + bytecode; at levels 1 and higher assertions are not compiled. + - Built-in ``__debug__`` variable: at level 0 this variable expands to ``True``; + at levels 1 and higher it expands to ``False``. + - Source-code line numbers: at levels 0, 1 and 2 source-code line number are + stored along with the bytecode so that exceptions can report the line number + they occurred at; at levels 3 and higher line numbers are not stored. + + The default optimisation level is usually level 0. + """ + +@overload +def opt_level(level: int, /) -> None: + """ + If *level* is given then this function sets the optimisation level for subsequent + compilation of scripts, and returns ``None``. Otherwise it returns the current + optimisation level. + + The optimisation level controls the following compilation features: + + - Assertions: at level 0 assertion statements are enabled and compiled into the + bytecode; at levels 1 and higher assertions are not compiled. + - Built-in ``__debug__`` variable: at level 0 this variable expands to ``True``; + at levels 1 and higher it expands to ``False``. + - Source-code line numbers: at levels 0, 1 and 2 source-code line number are + stored along with the bytecode so that exceptions can report the line number + they occurred at; at levels 3 and higher line numbers are not stored. + + The default optimisation level is usually level 0. + """ + +@overload +def mem_info() -> None: + """ + Print information about currently used memory. If the *verbose* argument + is given then extra information is printed. + + The information that is printed is implementation dependent, but currently + includes the amount of stack and heap used. In verbose mode it prints out + the entire heap indicating which blocks are used and which are free. + """ + +@overload +def mem_info(verbose: Any, /) -> None: + """ + Print information about currently used memory. If the *verbose* argument + is given then extra information is printed. + + The information that is printed is implementation dependent, but currently + includes the amount of stack and heap used. In verbose mode it prints out + the entire heap indicating which blocks are used and which are free. + """ + +def kbd_intr(chr: int) -> None: + """ + Set the character that will raise a `KeyboardInterrupt` exception. By + default this is set to 3 during script execution, corresponding to Ctrl-C. + Passing -1 to this function will disable capture of Ctrl-C, and passing 3 + will restore it. + + This function can be used to prevent the capturing of Ctrl-C on the + incoming stream of characters that is usually used for the REPL, in case + that stream is used for other purposes. + """ + ... + +@overload +def qstr_info() -> None: + """ + Print information about currently interned strings. If the *verbose* + argument is given then extra information is printed. + + The information that is printed is implementation dependent, but currently + includes the number of interned strings and the amount of RAM they use. In + verbose mode it prints out the names of all RAM-interned strings. + """ + +@overload +def qstr_info(verbose: bool, /) -> None: + """ + Print information about currently interned strings. If the *verbose* + argument is given then extra information is printed. + + The information that is printed is implementation dependent, but currently + includes the number of interned strings and the amount of RAM they use. In + verbose mode it prints out the names of all RAM-interned strings. + """ + +def schedule(func: Callable[[_T], None], arg: _T, /) -> None: + """ + Schedule the function *func* to be executed "very soon". The function + is passed the value *arg* as its single argument. "Very soon" means that + the MicroPython runtime will do its best to execute the function at the + earliest possible time, given that it is also trying to be efficient, and + that the following conditions hold: + + - A scheduled function will never preempt another scheduled function. + - Scheduled functions are always executed "between opcodes" which means + that all fundamental Python operations (such as appending to a list) + are guaranteed to be atomic. + - A given port may define "critical regions" within which scheduled + functions will never be executed. Functions may be scheduled within + a critical region but they will not be executed until that region + is exited. An example of a critical region is a preempting interrupt + handler (an IRQ). + + A use for this function is to schedule a callback from a preempting IRQ. + Such an IRQ puts restrictions on the code that runs in the IRQ (for example + the heap may be locked) and scheduling a function to call later will lift + those restrictions. + + On multi-threaded ports, the scheduled function's behaviour depends on + whether the Global Interpreter Lock (GIL) is enabled for the specific port: + + - If GIL is enabled, the function can preempt any thread and run in its + context. + - If GIL is disabled, the function will only preempt the main thread and run + in its context. + + Note: If `schedule()` is called from a preempting IRQ, when memory + allocation is not allowed and the callback to be passed to `schedule()` is + a bound method, passing this directly will fail. This is because creating a + reference to a bound method causes memory allocation. A solution is to + create a reference to the method in the class constructor and to pass that + reference to `schedule()`. This is discussed in detail here + :ref:`reference documentation ` under "Creation of Python + objects". + + There is a finite queue to hold the scheduled functions and `schedule()` + will raise a `RuntimeError` if the queue is full. + """ + ... + +def stack_use() -> int: + """ + Return an integer representing the current amount of stack that is being + used. The absolute value of this is not particularly useful, rather it + should be used to compute differences in stack usage at different points. + """ + ... + +def heap_unlock() -> int: + """ + Lock or unlock the heap. When locked no memory allocation can occur and a + `MemoryError` will be raised if any heap allocation is attempted. + `heap_locked()` returns a true value if the heap is currently locked. + + These functions can be nested, ie `heap_lock()` can be called multiple times + in a row and the lock-depth will increase, and then `heap_unlock()` must be + called the same number of times to make the heap available again. + + Both `heap_unlock()` and `heap_locked()` return the current lock depth + (after unlocking for the former) as a non-negative integer, with 0 meaning + the heap is not locked. + + If the REPL becomes active with the heap locked then it will be forcefully + unlocked. + + Note: `heap_locked()` is not enabled on most ports by default, + requires ``MICROPY_PY_MICROPYTHON_HEAP_LOCKED``. + """ + ... + +def const(expr: Const_T, /) -> Const_T: + """ + Used to declare that the expression is a constant so that the compiler can + optimise it. The use of this function should be as follows:: + + from micropython import const + + CONST_X = const(123) + CONST_Y = const(2 * CONST_X + 1) + + Constants declared this way are still accessible as global variables from + outside the module they are declared in. On the other hand, if a constant + begins with an underscore then it is hidden, it is not available as a global + variable, and does not take up any memory during execution. + + This `const` function is recognised directly by the MicroPython parser and is + provided as part of the :mod:`micropython` module mainly so that scripts can be + written which run under both CPython and MicroPython, by following the above + pattern. + """ + ... + +def heap_lock() -> int: + """ + Lock or unlock the heap. When locked no memory allocation can occur and a + `MemoryError` will be raised if any heap allocation is attempted. + `heap_locked()` returns a true value if the heap is currently locked. + + These functions can be nested, ie `heap_lock()` can be called multiple times + in a row and the lock-depth will increase, and then `heap_unlock()` must be + called the same number of times to make the heap available again. + + Both `heap_unlock()` and `heap_locked()` return the current lock depth + (after unlocking for the former) as a non-negative integer, with 0 meaning + the heap is not locked. + + If the REPL becomes active with the heap locked then it will be forcefully + unlocked. + + Note: `heap_locked()` is not enabled on most ports by default, + requires ``MICROPY_PY_MICROPYTHON_HEAP_LOCKED``. + """ + ... + +def alloc_emergency_exception_buf(size: int, /) -> None: + """ + Allocate *size* bytes of RAM for the emergency exception buffer (a good + size is around 100 bytes). The buffer is used to create exceptions in cases + when normal RAM allocation would fail (eg within an interrupt handler) and + therefore give useful traceback information in these situations. + + A good way to use this function is to put it at the start of your main script + (eg ``boot.py`` or ``main.py``) and then the emergency exception buffer will be active + for all the code following it. + """ + ... + +class RingIO: + def readinto(self, buf, nbytes: Optional[Any] = None) -> int: + """ + Read available bytes into the provided ``buf``. If ``nbytes`` is + specified then read at most that many bytes. Otherwise, read at + most ``len(buf)`` bytes. + + Return value: Integer count of the number of bytes read into ``buf``. + """ + ... + def write(self, buf) -> int: + """ + Non-blocking write of bytes from ``buf`` into the ringbuffer, limited + by the available space in the ringbuffer. + + Return value: Integer count of bytes written. + """ + ... + def readline(self, nbytes: Optional[Any] = None) -> bytes: + """ + Read a line, ending in a newline character or return if one exists in + the buffer, else return available bytes in buffer. If ``nbytes`` is + specified then read at most that many bytes. + + Return value: a bytes object containing the line read. + """ + ... + def any(self) -> int: + """ + Returns an integer counting the number of characters that can be read. + """ + ... + def read(self, nbytes: Optional[Any] = None) -> bytes: + """ + Read available characters. This is a non-blocking function. If ``nbytes`` + is specified then read at most that many bytes, otherwise read as much + data as possible. + + Return value: a bytes object containing the bytes read. Will be + zero-length bytes object if no data is available. + """ + ... + def close(self) -> Incomplete: + """ + No-op provided as part of standard `stream` interface. Has no effect + on data in the ringbuffer. + """ + ... + def __init__(self, size) -> None: ... + +# decorators +@mp_available() # force merge +def viper(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]: + """ + The Viper code emitter is not fully compliant. It supports special Viper native data types in pursuit of performance. + Integer processing is non-compliant because it uses machine words: arithmetic on 32 bit hardware is performed modulo 2**32. + Like the Native emitter Viper produces machine instructions but further optimisations are performed, substantially increasing + performance especially for integer arithmetic and bit manipulations. + See: https://docs.micropython.org/en/latest/reference/speed_python.html?highlight=viper#the-native-code-emitter + """ + ... + +@mp_available() # force merge +def native(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]: + """ + This causes the MicroPython compiler to emit native CPU opcodes rather than bytecode. + It covers the bulk of the MicroPython functionality, so most functions will require no adaptation. + See: https://docs.micropython.org/en/latest/reference/speed_python.html#the-native-code-emitter + """ + ... + +@mp_available(macro="MICROPY_EMIT_INLINE_THUMB") # force merge +def asm_thumb(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]: + """ + This decorator is used to mark a function as containing inline assembler code. + The assembler code is written is a subset of the ARM Thumb-2 instruction set, and is executed on the target CPU. + + Availability: Only on specific boards where MICROPY_EMIT_INLINE_THUMB is defined. + See: https://docs.micropython.org/en/latest/reference/asm_thumb2_index.html + """ + ... + +@mp_available(port="esp8266") # force merge +def asm_xtensa(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]: + """ + This decorator is used to mark a function as containing inline assembler code for the esp8266. + The assembler code is written in the Xtensa instruction set, and is executed on the target CPU. + + Availability: Only on eps8266 boards. + """ + ... + # See : + # - https://github.com/orgs/micropython/discussions/12965 + # - https://github.com/micropython/micropython/pull/16731 diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/mip/__init__.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/mip/__init__.pyi new file mode 100644 index 0000000000..773af6948c --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/mip/__init__.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete +from micropython import const as const + +_PACKAGE_INDEX: str +_CHUNK_SIZE: int +allowed_mip_url_prefixes: Incomplete + +def _ensure_path_exists(path) -> None: ... +def _chunk(src, dest) -> None: ... +def _check_exists(path, short_hash): ... +def _rewrite_url(url, branch=None): ... +def _download_file(url, dest): ... +def _install_json(package_json_url, index, target, version, mpy): ... +def _install_package(package, index, target, version, mpy): ... +def install(package, index=None, target=None, version=None, mpy: bool = True) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/neopixel.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/neopixel.pyi new file mode 100644 index 0000000000..deffae3b37 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/neopixel.pyi @@ -0,0 +1,86 @@ +""" +Control of WS2812 / NeoPixel LEDs. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/neopixel.html + +This module provides a driver for WS2818 / NeoPixel LEDs. + +``Note:`` This module is only included by default on the ESP8266, ESP32 and RP2 + ports. On STM32 / Pyboard and others, you can either install the + ``neopixel`` package using :term:`mip`, or you can download the module + directly from :term:`micropython-lib` and copy it to the filesystem. +""" + +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import _NeoPixelBase +from machine import Pin +from typing import Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_Color: TypeAlias = tuple[int, int, int] | tuple[int, int, int, int] + +class NeoPixel(_NeoPixelBase): + """ + This class stores pixel data for a WS2812 LED strip connected to a pin. The + application should set pixel data and then call :meth:`NeoPixel.write` + when it is ready to update the strip. + + For example:: + + import neopixel + + # 32 LED strip connected to X8. + p = machine.Pin.board.X8 + n = neopixel.NeoPixel(p, 32) + + # Draw a red gradient. + for i in range(32): + n[i] = (i * 8, 0, 0) + + # Update the strip. + n.write() + """ + + ORDER: Incomplete + pin: Incomplete + n: Incomplete + bpp: Incomplete + buf: Incomplete + timing: Incomplete + def __init__(self, pin, n, bpp: int = 3, timing: int = 1) -> None: + """ + Construct an NeoPixel object. The parameters are: + + - *pin* is a machine.Pin instance. + - *n* is the number of LEDs in the strip. + - *bpp* is 3 for RGB LEDs, and 4 for RGBW LEDs. + - *timing* is 0 for 400KHz, and 1 for 800kHz LEDs (most are 800kHz). + """ + ... + def __len__(self) -> int: + """ + Returns the number of LEDs in the strip. + """ + ... + def __setitem__(self, i, v) -> None: + """ + Set the pixel at *index* to the value, which is an RGB/RGBW tuple. + """ + ... + def __getitem__(self, i) -> Tuple: + """ + Returns the pixel at *index* as an RGB/RGBW tuple. + """ + ... + def fill(self, v) -> None: + """ + Sets the value of all pixels to the specified *pixel* value (i.e. an + RGB/RGBW tuple). + """ + ... + def write(self) -> None: + """ + Writes the current pixel data to the strip. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/network.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/network.pyi new file mode 100644 index 0000000000..f586ebd422 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/network.pyi @@ -0,0 +1,577 @@ +""" +Network configuration. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/network.html + +This module provides network drivers and routing configuration. To use this +module, a MicroPython variant/build with network capabilities must be installed. +Network drivers for specific hardware are available within this module and are +used to configure hardware network interface(s). Network services provided +by configured interfaces are then available for use via the :mod:`socket` +module. + +For example:: + + # connect/ show IP config a specific network interface + # see below for examples of specific drivers + import network + import time + nic = network.Driver(...) + if not nic.isconnected(): + nic.connect() + print("Waiting for connection...") + while not nic.isconnected(): + time.sleep(1) + print(nic.ipconfig("addr4")) + + # now use socket as usual + import socket + addr = socket.getaddrinfo('micropython.org', 80)[0][-1] + s = socket.socket() + s.connect(addr) + s.send(b'GET / HTTP/1.1 + +Host: micropython.org + + + +') + data = s.recv(1000) + s.close() + +--- +Module: 'network' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Protocol, Callable, List, Optional, Any, Tuple, overload, Final +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar +from machine import Pin, SPI +from abc import abstractmethod + +STA_IF: Final[int] = 0 +STAT_IDLE: Final[int] = 0 +STAT_NO_AP_FOUND: Final[int] = -2 +STAT_WRONG_PASSWORD: Final[int] = -3 +STAT_GOT_IP: Final[int] = 3 +AP_IF: Final[int] = 1 +STAT_CONNECTING: Final[int] = 1 +STAT_CONNECT_FAIL: Final[int] = -1 + +def hostname(name: Optional[Any] = None) -> Incomplete: + """ + Get or set the hostname that will identify this device on the network. It will + be used by all interfaces. + + This hostname is used for: + * Sending to the DHCP server in the client request. (If using DHCP) + * Broadcasting via mDNS. (If enabled) + + If the *name* parameter is provided, the hostname will be set to this value. + If the function is called without parameters, it returns the current + hostname. + + A change in hostname is typically only applied during connection. For DHCP + this is because the hostname is part of the DHCP client request, and the + implementation of mDNS in most ports only initialises the hostname once + during connection. For this reason, you must set the hostname before + activating/connecting your network interfaces. + + The length of the hostname is limited to 32 characters. + :term:`MicroPython ports ` may choose to set a lower + limit for memory reasons. If the given name does not fit, a `ValueError` + is raised. + + The default hostname is typically the name of the board. + """ + ... + +def ipconfig(param: Optional[str] = None, *args, **kwargs) -> str: + """ + Get or set global IP-configuration parameters. + Supported parameters are the following (availability of a particular + parameter depends on the port and the specific network interface): + + * ``dns`` Get/set DNS server. This method can support both, IPv4 and + IPv6 addresses. + * ``prefer`` (``4/6``) Specify which address type to return, if a domain + name has both A and AAAA records. Note, that this does not clear the + local DNS cache, so that any previously obtained addresses might not + change. + """ + ... + +def route(*args, **kwargs) -> Incomplete: ... +def country(code: Optional[Any] = None) -> Incomplete: + """ + Get or set the two-letter ISO 3166-1 Alpha-2 country code to be used for + radio compliance. + + If the *code* parameter is provided, the country will be set to this value. + If the function is called without parameters, it returns the current + country. + + The default code ``"XX"`` represents the "worldwide" region. + """ + ... + +class WLAN: + """ + Create a WLAN network interface object. Supported interfaces are + ``network.WLAN.IF_STA`` (station aka client, connects to upstream WiFi access + points) and ``network.WLAN.IF_AP`` (access point, allows other WiFi clients to + connect). Availability of the methods below depends on interface type. + For example, only STA interface may `WLAN.connect()` to an access point. + """ + + PM_POWERSAVE: Final[int] = 17 + SEC_OPEN: Final[int] = 0 + SEC_WPA2_WPA3: Final[int] = 20971524 + SEC_WPA3: Final[int] = 16777220 + SEC_WPA_WPA2: Final[int] = 4194310 + PM_PERFORMANCE: Final[int] = 10555714 + """\ + WLAN.PM_POWERSAVE + WLAN.PM_NONE + + Allowed values for the ``WLAN.config(pm=...)`` network interface parameter: + + * ``PM_PERFORMANCE``: enable WiFi power management to balance power + savings and WiFi performance + * ``PM_POWERSAVE``: enable WiFi power management with additional power + savings and reduced WiFi performance + * ``PM_NONE``: disable wifi power management + """ + IF_AP: Final[int] = 1 + IF_STA: Final[int] = 0 + PM_NONE: Final[int] = 16 + PROTOCOL_DEFAULTS: Incomplete + PROTOCOL_LR: Incomplete + def ipconfig(self, *args, **kwargs) -> Incomplete: ... + def status(self, param: Optional[Any] = None) -> List[int]: + """ + Return the current status of the wireless connection. + + When called with no argument the return value describes the network link status. + The possible statuses are defined as constants in the :mod:`network` module: + + * ``STAT_IDLE`` -- no connection and no activity, + * ``STAT_CONNECTING`` -- connecting in progress, + * ``STAT_WRONG_PASSWORD`` -- failed due to incorrect password, + * ``STAT_NO_AP_FOUND`` -- failed because no access point replied, + * ``STAT_CONNECT_FAIL`` -- failed due to other problems, + * ``STAT_GOT_IP`` -- connection successful. + + When called with one argument *param* should be a string naming the status + parameter to retrieve, and different parameters are supported depending on the + mode the WiFi is in. + + In STA mode, passing ``'rssi'`` returns a signal strength indicator value, whose + format varies depending on the port (this is available on all ports that support + WiFi network interfaces, except for CC3200). + + In AP mode, passing ``'stations'`` returns a list of connected WiFi stations + (this is available on all ports that support WiFi network interfaces, except for + CC3200). The format of the station information entries varies across ports, + providing either the raw BSSID of the connected station, the IP address of the + connected station, or both. + """ + ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def send_ethernet(self, *args, **kwargs) -> Incomplete: ... + def isconnected(self) -> bool: + """ + In case of STA mode, returns ``True`` if connected to a WiFi access + point and has a valid IP address. In AP mode returns ``True`` when a + station is connected. Returns ``False`` otherwise. + """ + ... + def scan(self) -> List[Tuple]: + """ + Scan for the available wireless networks. + Hidden networks -- where the SSID is not broadcast -- will also be scanned + if the WLAN interface allows it. + + Scanning is only possible on STA interface. Returns list of tuples with + the information about WiFi access points: + + (ssid, bssid, channel, RSSI, security, hidden) + + *bssid* is hardware address of an access point, in binary form, returned as + bytes object. You can use `binascii.hexlify()` to convert it to ASCII form. + + There are five values for security: + + * 0 -- open + * 1 -- WEP + * 2 -- WPA-PSK + * 3 -- WPA2-PSK + * 4 -- WPA/WPA2-PSK + + and two for hidden: + + * 0 -- visible + * 1 -- hidden + """ + ... + def config(self, *args, **kwargs) -> Incomplete: + """ + Get or set general network interface parameters. These methods allow to work + with additional parameters beyond standard IP configuration (as dealt with by + `AbstractNIC.ipconfig()`). These include network-specific and hardware-specific + parameters. For setting parameters, keyword argument syntax should be used, + multiple parameters can be set at once. For querying, parameters name should + be quoted as a string, and only one parameter can be queries at time:: + + # Set WiFi access point name (formally known as SSID) and WiFi channel + ap.config(ssid='My AP', channel=11) + # Query params one by one + print(ap.config('ssid')) + print(ap.config('channel')) + + Following are commonly supported parameters (availability of a specific parameter + depends on network technology type, driver, and :term:`MicroPython port`). + + ============= =========== + Parameter Description + ============= =========== + mac MAC address (bytes) + ssid WiFi access point name (string) + channel WiFi channel (integer). Depending on the port this may only be supported on the AP interface. + hidden Whether SSID is hidden (boolean) + security Security protocol supported (enumeration, see module constants) + key Access key (string) + hostname The hostname that will be sent to DHCP (STA interfaces) and mDNS (if supported, both STA and AP). (Deprecated, use :func:`network.hostname` instead) + reconnects Number of reconnect attempts to make (integer, 0=none, -1=unlimited) + txpower Maximum transmit power in dBm (integer or float) + pm WiFi Power Management setting (see below for allowed values) + protocol (ESP32 Only.) WiFi Low level 802.11 protocol. See `WLAN.PROTOCOL_DEFAULTS`. + ============= =========== + """ + ... + def ifconfig(self, configtuple: Optional[Any] = None) -> Tuple: + """ + Get/set IP-level network interface parameters: IP address, subnet mask, + gateway and DNS server. When called with no arguments, this method returns + a 4-tuple with the above information. To set the above values, pass a + 4-tuple with the required information. For example:: + + nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) + """ + ... + def active(self, is_active: Optional[Any] = None) -> None: + """ + Activate ("up") or deactivate ("down") network interface, if boolean + argument is passed. Otherwise, query current state if no argument is + provided. Most other methods require active interface. + """ + ... + def disconnect(self) -> None: + """ + Disconnect from the currently connected wireless network. + """ + ... + def connect(self, ssid=None, key=None, *, bssid=None) -> None: + """ + Connect to the specified wireless network, using the specified key. + If *bssid* is given then the connection will be restricted to the + access-point with that MAC address (the *ssid* must also be specified + in this case). + """ + ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, interface_id) -> None: ... + +class LAN: + @overload + def active(self, /) -> bool: + """ + With a parameter, it sets the interface active if *state* is true, otherwise it + sets it inactive. + Without a parameter, it returns the state. + """ + + @overload + def active(self, is_active: bool | int, /) -> None: + """ + With a parameter, it sets the interface active if *state* is true, otherwise it + sets it inactive. + Without a parameter, it returns the state. + """ + +class WLANWiPy: + @overload + def __init__(self, id: int = 0, /): + """ + Create a WLAN object, and optionally configure it. See `init()` for params of configuration. + + .. note:: + + The ``WLAN`` constructor is special in the sense that if no arguments besides the id are given, + it will return the already existing ``WLAN`` instance without re-configuring it. This is + because ``WLAN`` is a system feature of the WiPy. If the already existing instance is not + initialized it will do the same as the other constructors an will initialize it with default + values. + """ + + @overload + def __init__( + self, + id: int, + /, + *, + mode: int, + ssid: str, + auth: tuple[str, str], + channel: int, + antenna: int, + ): + """ + Create a WLAN object, and optionally configure it. See `init()` for params of configuration. + + .. note:: + + The ``WLAN`` constructor is special in the sense that if no arguments besides the id are given, + it will return the already existing ``WLAN`` instance without re-configuring it. This is + because ``WLAN`` is a system feature of the WiPy. If the already existing instance is not + initialized it will do the same as the other constructors an will initialize it with default + values. + """ + + @overload + def mode(self) -> int: + """ + Get or set the WLAN mode. + """ + + @overload + def mode(self, mode: int, /) -> None: + """ + Get or set the WLAN mode. + """ + + @overload + def ssid(self) -> str: + """ + Get or set the SSID when in AP mode. + """ + + @overload + def ssid(self, ssid: str, /) -> None: + """ + Get or set the SSID when in AP mode. + """ + + @overload + def auth(self) -> int: + """ + Get or set the authentication type when in AP mode. + """ + + @overload + def auth(self, auth: int, /) -> None: + """ + Get or set the authentication type when in AP mode. + """ + + @overload + def channel(self) -> int: + """ + Get or set the channel (only applicable in AP mode). + """ + + @overload + def channel(self, channel: int, /) -> None: + """ + Get or set the channel (only applicable in AP mode). + """ + + @overload + def antenna(self) -> int: + """ + Get or set the antenna type (external or internal). + """ + + @overload + def antenna(self, antenna: int, /) -> None: + """ + Get or set the antenna type (external or internal). + """ + + @overload + def mac(self) -> bytes: + """ + Get or set a 6-byte long bytes object with the MAC address. + """ + + @overload + def mac(self, mac: bytes, /) -> None: + """ + Get or set a 6-byte long bytes object with the MAC address. + """ + +class AbstractNIC: + @overload + @abstractmethod + def active(self, /) -> bool: + """ + Activate ("up") or deactivate ("down") the network interface, if + a boolean argument is passed. Otherwise, query current state if + no argument is provided. Most other methods require an active + interface (behaviour of calling them on inactive interface is + undefined). + """ + + @overload + @abstractmethod + def active(self, is_active: bool | int, /) -> None: + """ + Activate ("up") or deactivate ("down") the network interface, if + a boolean argument is passed. Otherwise, query current state if + no argument is provided. Most other methods require an active + interface (behaviour of calling them on inactive interface is + undefined). + """ + + @overload + @abstractmethod + def connect(self, key: str | None = None, /, **kwargs: Any) -> None: + """ + Connect the interface to a network. This method is optional, and + available only for interfaces which are not "always connected". + If no parameters are given, connect to the default (or the only) + service. If a single parameter is given, it is the primary identifier + of a service to connect to. It may be accompanied by a key + (password) required to access said service. There can be further + arbitrary keyword-only parameters, depending on the networking medium + type and/or particular device. Parameters can be used to: a) + specify alternative service identifier types; b) provide additional + connection parameters. For various medium types, there are different + sets of predefined/recommended parameters, among them: + + * WiFi: *bssid* keyword to connect to a specific BSSID (MAC address) + """ + + @overload + @abstractmethod + def connect(self, service_id: Any, key: str | None = None, /, **kwargs: Any) -> None: + """ + Connect the interface to a network. This method is optional, and + available only for interfaces which are not "always connected". + If no parameters are given, connect to the default (or the only) + service. If a single parameter is given, it is the primary identifier + of a service to connect to. It may be accompanied by a key + (password) required to access said service. There can be further + arbitrary keyword-only parameters, depending on the networking medium + type and/or particular device. Parameters can be used to: a) + specify alternative service identifier types; b) provide additional + connection parameters. For various medium types, there are different + sets of predefined/recommended parameters, among them: + + * WiFi: *bssid* keyword to connect to a specific BSSID (MAC address) + """ + + @overload + @abstractmethod + def status(self) -> Any: + """ + Query dynamic status information of the interface. When called with no + argument the return value describes the network link status. Otherwise + *param* should be a string naming the particular status parameter to + retrieve. + + The return types and values are dependent on the network + medium/technology. Some of the parameters that may be supported are: + + * WiFi STA: use ``'rssi'`` to retrieve the RSSI of the AP signal + * WiFi AP: use ``'stations'`` to retrieve a list of all the STAs + connected to the AP. The list contains tuples of the form + (MAC, RSSI). + """ + + @overload + @abstractmethod + def status(self, param: str, /) -> Any: + """ + Query dynamic status information of the interface. When called with no + argument the return value describes the network link status. Otherwise + *param* should be a string naming the particular status parameter to + retrieve. + + The return types and values are dependent on the network + medium/technology. Some of the parameters that may be supported are: + + * WiFi STA: use ``'rssi'`` to retrieve the RSSI of the AP signal + * WiFi AP: use ``'stations'`` to retrieve a list of all the STAs + connected to the AP. The list contains tuples of the form + (MAC, RSSI). + """ + + @overload + @abstractmethod + def ifconfig(self) -> tuple[str, str, str, str]: + """ + ``Note:`` This function is deprecated, use `ipconfig()` instead. + + Get/set IP-level network interface parameters: IP address, subnet mask, + gateway and DNS server. When called with no arguments, this method returns + a 4-tuple with the above information. To set the above values, pass a + 4-tuple with the required information. For example:: + + nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) + """ + + @overload + @abstractmethod + def ifconfig(self, ip_mask_gateway_dns: tuple[str, str, str, str], /) -> None: + """ + ``Note:`` This function is deprecated, use `ipconfig()` instead. + + Get/set IP-level network interface parameters: IP address, subnet mask, + gateway and DNS server. When called with no arguments, this method returns + a 4-tuple with the above information. To set the above values, pass a + 4-tuple with the required information. For example:: + + nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) + """ + + @overload + @abstractmethod + def config(self, param: str, /) -> Any: + """ + Get or set general network interface parameters. These methods allow to work + with additional parameters beyond standard IP configuration (as dealt with by + `ipconfig()`). These include network-specific and hardware-specific + parameters. For setting parameters, the keyword argument + syntax should be used, and multiple parameters can be set at once. For + querying, a parameter name should be quoted as a string, and only one + parameter can be queried at a time:: + + # Set WiFi access point name (formally known as SSID) and WiFi channel + ap.config(ssid='My AP', channel=11) + # Query params one by one + print(ap.config('ssid')) + print(ap.config('channel')) + """ + + @overload + @abstractmethod + def config(self, **kwargs: Any) -> None: + """ + Get or set general network interface parameters. These methods allow to work + with additional parameters beyond standard IP configuration (as dealt with by + `ipconfig()`). These include network-specific and hardware-specific + parameters. For setting parameters, the keyword argument + syntax should be used, and multiple parameters can be set at once. For + querying, a parameter name should be quoted as a string, and only one + parameter can be queried at a time:: + + # Set WiFi access point name (formally known as SSID) and WiFi channel + ap.config(ssid='My AP', channel=11) + # Query params one by one + print(ap.config('ssid')) + print(ap.config('channel')) + """ diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ntptime.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ntptime.pyi new file mode 100644 index 0000000000..3b374f65d0 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ntptime.pyi @@ -0,0 +1,5 @@ +host: str +timeout: int + +def time(): ... +def settime() -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/onewire.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/onewire.pyi new file mode 100644 index 0000000000..2a07804f29 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/onewire.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete + +class OneWireError(Exception): ... + +class OneWire: + SEARCH_ROM: int + MATCH_ROM: int + SKIP_ROM: int + pin: Incomplete + def __init__(self, pin) -> None: ... + def reset(self, required: bool = False): ... + def readbit(self): ... + def readbyte(self): ... + def readinto(self, buf) -> None: ... + def writebit(self, value): ... + def writebyte(self, value): ... + def write(self, buf) -> None: ... + def select_rom(self, rom) -> None: ... + def scan(self): ... + def _search_rom(self, l_rom, diff): ... + def crc8(self, data): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/platform.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/platform.pyi new file mode 100644 index 0000000000..e2d5aa460a --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/platform.pyi @@ -0,0 +1,51 @@ +""" +Access to underlying platform’s identifying data. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/platform.html + +CPython module: :mod:`python:platform` https://docs.python.org/3/library/platform.html . + +This module tries to retrieve as much platform-identifying data as possible. It +makes this information available via function APIs. + +--- +Module: 'platform' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def platform() -> str: + """ + Returns a string identifying the underlying platform. This string is composed + of several substrings in the following order, delimited by dashes (``-``): + + - the name of the platform system (e.g. Unix, Windows or MicroPython) + - the MicroPython version + - the architecture of the platform + - the version of the underlying platform + - the concatenation of the name of the libc that MicroPython is linked to + and its corresponding version. + + For example, this could be + ``"MicroPython-1.20.0-xtensa-IDFv4.2.4-with-newlib3.0.0"``. + """ + ... + +def python_compiler() -> str: + """ + Returns a string identifying the compiler used for compiling MicroPython. + """ + ... + +def libc_ver() -> Tuple: + """ + Returns a tuple of strings *(lib, version)*, where *lib* is the name of the + libc that MicroPython is linked to, and *version* the corresponding version + of this libc. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/pyproject.toml b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/pyproject.toml new file mode 100644 index 0000000000..481135855f --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/pyproject.toml @@ -0,0 +1,125 @@ +[project] +name = "micropython-rp2-rpi_pico_w-stubs" +description = "MicroPython stubs" +version = "1.27.0.post1" +readme = "README.md" +license = "MIT" +authors = [ + { name = "Jos Verlinde", email = "josverl@users.noreply.github.com" }, +] +classifiers = [ + "Typing :: Stubs Only", + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: Implementation :: MicroPython", + "Operating System :: OS Independent", + "Topic :: Text Editors :: Integrated Development Environments (IDE)", + "Topic :: Software Development :: Documentation", + "Topic :: Software Development :: Embedded Systems", + "Topic :: Software Development :: Testing", + "Natural Language :: English", +] +dependencies = [ + "micropython-stdlib-stubs ~=1.27.0", +] + +[project.urls] +homepage = "https://github.com/josverl/micropython-stubs#micropython-stubs" +documentation = "https://micropython-stubs.readthedocs.io/" +repository = "https://github.com/josverl/micropython-stubs" + +[tool.poetry] +exclude = [ + "*.ps1", + "*.py", + "**/__pycache__", + "**/dist", +] +include = [ + "**/*.py", + "**/*.pyi", +] +packages = [ + { include = "__builtins__.pyi" }, + { include = "_boot.pyi" }, + { include = "_boot_fat.pyi" }, + { include = "_onewire.pyi" }, + { include = "_thread.pyi" }, + { include = "aioble/__init__.pyi" }, + { include = "aioble/central.pyi" }, + { include = "aioble/client.pyi" }, + { include = "aioble/core.pyi" }, + { include = "aioble/device.pyi" }, + { include = "aioble/l2cap.pyi" }, + { include = "aioble/peripheral.pyi" }, + { include = "aioble/security.pyi" }, + { include = "aioble/server.pyi" }, + { include = "binascii.pyi" }, + { include = "bluetooth.pyi" }, + { include = "cmath.pyi" }, + { include = "cryptolib.pyi" }, + { include = "deflate.pyi" }, + { include = "dht.pyi" }, + { include = "ds18x20.pyi" }, + { include = "errno.pyi" }, + { include = "framebuf.pyi" }, + { include = "gc.pyi" }, + { include = "hashlib.pyi" }, + { include = "heapq.pyi" }, + { include = "lwip.pyi" }, + { include = "machine.pyi" }, + { include = "math.pyi" }, + { include = "micropython.pyi" }, + { include = "mip/__init__.pyi" }, + { include = "neopixel.pyi" }, + { include = "network.pyi" }, + { include = "ntptime.pyi" }, + { include = "onewire.pyi" }, + { include = "platform.pyi" }, + { include = "random.pyi" }, + { include = "requests/__init__.pyi" }, + { include = "rp2/__init__.pyi" }, + { include = "rp2/asm_pio.pyi" }, + { include = "select.pyi" }, + { include = "socket.pyi" }, + { include = "time.pyi" }, + { include = "tls.pyi" }, + { include = "uarray.pyi" }, + { include = "uasyncio.pyi" }, + { include = "ubinascii.pyi" }, + { include = "ubluetooth.pyi" }, + { include = "ucollections.pyi" }, + { include = "ucryptolib.pyi" }, + { include = "uctypes.pyi" }, + { include = "uerrno.pyi" }, + { include = "uhashlib.pyi" }, + { include = "uheapq.pyi" }, + { include = "uio.pyi" }, + { include = "ujson.pyi" }, + { include = "umachine.pyi" }, + { include = "uos.pyi" }, + { include = "uplatform.pyi" }, + { include = "urandom.pyi" }, + { include = "ure.pyi" }, + { include = "urequests.pyi" }, + { include = "uselect.pyi" }, + { include = "usocket.pyi" }, + { include = "ussl.pyi" }, + { include = "ustruct.pyi" }, + { include = "usys.pyi" }, + { include = "utime.pyi" }, + { include = "uwebsocket.pyi" }, + { include = "uzlib.pyi" }, + { include = "vfs.pyi" }, + { include = "webrepl.pyi" }, + { include = "webrepl_setup.pyi" }, + { include = "websocket.pyi" }, +] + +[build-system] +requires = [ + "poetry-core>=1.0.0", +] +build-backend = "poetry.core.masonry.api" diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/random.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/random.pyi new file mode 100644 index 0000000000..f62e718b0a --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/random.pyi @@ -0,0 +1,115 @@ +""" +Random numbers. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/random.html + +This module implements a pseudo-random number generator (PRNG). + +CPython module: :mod:`python:random` https://docs.python.org/3/library/random.html . . + +.. note:: + + The following notation is used for intervals: + + - () are open interval brackets and do not include their endpoints. + For example, (0, 1) means greater than 0 and less than 1. + In set notation: (0, 1) = {x | 0 < x < 1}. + + - [] are closed interval brackets which include all their limit points. + For example, [0, 1] means greater than or equal to 0 and less than + or equal to 1. + In set notation: [0, 1] = {x | 0 <= x <= 1}. + +.. note:: + + The :func:`randrange`, :func:`randint` and :func:`choice` functions are only + available if the ``MICROPY_PY_RANDOM_EXTRA_FUNCS`` configuration option is + enabled. + +--- +Module: 'random' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import Subscriptable +from typing import overload +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_T = TypeVar("_T") + +@overload +def randrange(stop: int, /) -> int: + """ + The first form returns a random integer from the range [0, *stop*). + The second form returns a random integer from the range [*start*, *stop*). + The third form returns a random integer from the range [*start*, *stop*) in + steps of *step*. For instance, calling ``randrange(1, 10, 2)`` will + return odd numbers between 1 and 9 inclusive. + """ + +@overload +def randrange(start: int, stop: int, /) -> int: + """ + The first form returns a random integer from the range [0, *stop*). + The second form returns a random integer from the range [*start*, *stop*). + The third form returns a random integer from the range [*start*, *stop*) in + steps of *step*. For instance, calling ``randrange(1, 10, 2)`` will + return odd numbers between 1 and 9 inclusive. + """ + +@overload +def randrange(start: int, stop: int, step: int, /) -> int: + """ + The first form returns a random integer from the range [0, *stop*). + The second form returns a random integer from the range [*start*, *stop*). + The third form returns a random integer from the range [*start*, *stop*) in + steps of *step*. For instance, calling ``randrange(1, 10, 2)`` will + return odd numbers between 1 and 9 inclusive. + """ + +def random() -> int: + """ + Return a random floating point number in the range [0.0, 1.0). + """ + ... + +def seed(n: int | None = None, /) -> None: + """ + Initialise the random number generator module with the seed *n* which should + be an integer. When no argument (or ``None``) is passed in it will (if + supported by the port) initialise the PRNG with a true random number + (usually a hardware generated random number). + + The ``None`` case only works if ``MICROPY_PY_RANDOM_SEED_INIT_FUNC`` is + enabled by the port, otherwise it raises ``ValueError``. + """ + ... + +def uniform(a: float, b: float) -> int: + """ + Return a random floating point number N such that *a* <= N <= *b* for *a* <= *b*, + and *b* <= N <= *a* for *b* < *a*. + """ + ... + +def choice(sequence: Subscriptable, /) -> None: + """ + Chooses and returns one item at random from *sequence* (tuple, list or + any object that supports the subscript operation). + """ + ... + +def randint(a: int, b: int, /) -> int: + """ + Return a random integer in the range [*a*, *b*]. + """ + ... + +def getrandbits(n: int, /) -> int: + """ + Return an integer with *n* random bits (0 <= n <= 32). + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/requests/__init__.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/requests/__init__.pyi new file mode 100644 index 0000000000..74386f89ba --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/requests/__init__.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete + +class Response: + raw: Incomplete + encoding: str + _cached: Incomplete + def __init__(self, f) -> None: ... + def close(self) -> None: ... + @property + def content(self): ... + @property + def text(self): ... + def json(self): ... + +def request(method, url, data=None, json=None, headers=None, stream=None, auth=None, timeout=None, parse_headers: bool = True): ... +def head(url, **kw): ... +def get(url, **kw): ... +def post(url, **kw): ... +def put(url, **kw): ... +def patch(url, **kw): ... +def delete(url, **kw): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/rp2/__init__.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/rp2/__init__.pyi new file mode 100644 index 0000000000..3aa5dce1e3 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/rp2/__init__.pyi @@ -0,0 +1,993 @@ +""" +Functionality specific to the RP2. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/rp2.html + +The ``rp2`` module contains functions and classes specific to the RP2040, as +used in the Raspberry Pi Pico. + +See the `RP2040 Python datasheet +`_ +for more information, and `pico-micropython-examples +`_ +for example code. + +--- +Module: 'rp2.PIOASMEmit' + +--- +This module provides type hints for the `rp2.asm_pio` module in the Raspberry Pi Pico Python SDK. +It includes definitions for constants, functions, and directives used in PIO assembly programming. + +The module includes docstrings for each function and directive, providing information on their usage and parameters. + +Note: This module is intended for use with type checking and does not contain actual implementations of the functions. + +For more information on PIO assembly programming and the Raspberry Pi Pico Python SDK, refer to the following documents: +- raspberry-pi-pico-python-sdk.pdf: https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf +- raspberry-pi-pico-c-sdk.pdf: https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf + +For a simpler and clearer reference on PIO assembly, you can also visit: https://dernulleffekt.de/doku.php?id=raspberrypipico:pico_pio + + +rp2.PIO type hints have to be loaded manually. Add the following lines to the top of the file with the PIO assembler code: + +```py +# ----------------------------------------------- +# add type hints for the rp2.PIO Instructions +try: + from typing_extensions import TYPE_CHECKING # type: ignore +except ImportError: + TYPE_CHECKING = False +if TYPE_CHECKING: + from rp2.asm_pio import * +# ----------------------------------------------- +``` + +--- +Module: 'rp2' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Union, Dict, List, Literal, overload, Any, Callable, Optional, Final +from _typeshed import Incomplete +from micropython import const +from typing_extensions import Awaitable, TypeAlias, TypeVar, TYPE_CHECKING +from _mpy_shed import AnyReadableBuf, AnyWritableBuf, _IRQ +from vfs import AbstractBlockDev +from machine import Pin + +_PIO_ASM_Program: TypeAlias = Callable +_IRQ_TRIGGERS: TypeAlias = Literal[256, 512, 1024, 2048] + +_pio_funcs: dict = {} +_pio_directives: tuple = () +_pio_instructions: tuple = () + +def bootsel_button() -> int: + """ + Temporarily turns the QSPI_SS pin into an input and reads its value, + returning 1 for low and 0 for high. + On a typical RP2040 board with a BOOTSEL button, a return value of 1 + indicates that the button is pressed. + + Since this function temporarily disables access to the external flash + memory, it also temporarily disables interrupts and the other core to + prevent them from trying to execute code from flash. + """ + ... + +def asm_pio( + *, + out_init: Union[Pin, List[Pin], int, List[int], None] = None, + set_init: Union[Pin, List[Pin], int, List[int], None] = None, + sideset_init: Union[Pin, List[Pin], int, List[int], None] = None, + side_pindir: bool = False, + in_shiftdir=0, + out_shiftdir=0, + autopush=False, + autopull=False, + push_thresh=32, + pull_thresh=32, + fifo_join=PIO.JOIN_NONE, +) -> Callable[..., _PIO_ASM_Program]: + """ + Assemble a PIO program. + + The following parameters control the initial state of the GPIO pins, as one + of `PIO.IN_LOW`, `PIO.IN_HIGH`, `PIO.OUT_LOW` or `PIO.OUT_HIGH`. If the + program uses more than one pin, provide a tuple, e.g. + ``out_init=(PIO.OUT_LOW, PIO.OUT_LOW)``. + + - *out_init* configures the pins used for ``out()`` instructions. + - *set_init* configures the pins used for ``set()`` instructions. There can + be at most 5. + - *sideset_init* configures the pins used for ``.side()`` modifiers. There + can be at most 5. + - *side_pindir* when set to ``True`` configures ``.side()`` modifiers to be + used for pin directions, instead of pin values (the default, when ``False``). + + The following parameters are used by default, but can be overridden in + `StateMachine.init()`: + + - *in_shiftdir* is the default direction the ISR will shift, either + `PIO.SHIFT_LEFT` or `PIO.SHIFT_RIGHT`. + - *out_shiftdir* is the default direction the OSR will shift, either + `PIO.SHIFT_LEFT` or `PIO.SHIFT_RIGHT`. + - *push_thresh* is the threshold in bits before auto-push or conditional + re-pushing is triggered. + - *pull_thresh* is the threshold in bits before auto-pull or conditional + re-pulling is triggered. + + The remaining parameters are: + + - *autopush* configures whether auto-push is enabled. + - *autopull* configures whether auto-pull is enabled. + - *fifo_join* configures whether the 4-word TX and RX FIFOs should be + combined into a single 8-word FIFO for one direction only. The options + are `PIO.JOIN_NONE`, `PIO.JOIN_RX` and `PIO.JOIN_TX`. + """ + ... + +def country(*args, **kwargs) -> Incomplete: ... +def asm_pio_encode(instr, sideset_count, sideset_opt=False) -> int: + """ + Assemble a single PIO instruction. You usually want to use `asm_pio()` + instead. + + >>> rp2.asm_pio_encode("set(0, 1)", 0) + 57345 + """ + ... + +def const(*args, **kwargs) -> Incomplete: ... + +class DMA: + """ + Claim one of the DMA controller channels for exclusive use. + """ + def irq(self, handler: Optional[Callable] = None, hard: bool = False) -> _IRQ: + """ + Returns the IRQ object for this DMA channel and optionally configures it. + """ + ... + def unpack_ctrl(self, value: int) -> dict: + """ + Unpack a value for a DMA channel control register into a dictionary with key/value pairs + for each of the fields in the control register. *value* is the ``ctrl`` register value + to unpack. + + This method will return values for all the keys that can be passed to ``DMA.pack_ctrl``. + In addition, it will also return the read-only flags in the control register: ``busy``, + which goes high when a transfer starts and low when it ends, and ``ahb_err``, which is + the logical OR of the ``read_err`` and ``write_err`` flags. These values will be ignored + when packing, so that the dictionary created by unpacking a control register can be used + directly as the keyword arguments for packing. + """ + ... + def pack_ctrl( + self, + *, + enable: bool = True, + high_pri: bool = False, + size: int = 2, + inc_read: bool = True, + inc_write: bool = True, + # RP2350-only fields: + inc_read_rev: Optional[bool] = None, # RP2350 only + inc_write_rev: Optional[bool] = None, # RP2350 only + **kwargs, + ) -> int: + """ + Pack the values provided in the keyword arguments into the named fields of a new control + register value. Any field that is not provided will be set to a default value. The + default will either be taken from the provided ``default`` value, or if that is not + given, a default suitable for the current channel; setting this to the current value + of the `DMA.ctrl` attribute provides an easy way to override a subset of the fields. + + The keys for the keyword arguments can be any key returned by the :meth:`DMA.unpack_ctrl()` + method. The writable values are: + + - *enable*: ``bool`` Set to enable the channel (default: ``True``). + + - *high_pri*: ``bool`` Make this channel's bus traffic high priority (default: ``False``). + + - *size*: ``int`` Transfer size: 0=byte, 1=half word, 2=word (default: 2). + + - *inc_read*: ``bool`` Increment the read address after each transfer (default: ``True``). + + - *inc_write*: ``bool`` Increment the write address after each transfer (default: ``True``). + + - *ring_size*: ``int`` If non-zero, only the bottom ``ring_size`` bits of one + address register will change when an address is incremented, causing the + address to wrap at the next ``1 << ring_size`` byte boundary. Which + address is wrapped is controlled by the ``ring_sel`` flag. A zero value + disables address wrapping. + + - *ring_sel*: ``bool`` Set to ``False`` to have the ``ring_size`` apply to the read address + or ``True`` to apply to the write address. + + - *chain_to*: ``int`` The channel number for a channel to trigger after this transfer + completes. Setting this value to this DMA object's own channel number + disables chaining (this is the default). + + - *treq_sel*: ``int`` Select a Transfer Request signal. See section 2.5.3 in the RP2040 + datasheet for details. + + - *irq_quiet*: ``bool`` Do not generate interrupt at the end of each transfer. Interrupts + will instead be generated when a zero value is written to the trigger + register, which will halt a sequence of chained transfers (default: + ``True``). + + - *bswap*: ``bool`` If set to true, bytes in words or half-words will be reversed before + writing (default: ``True``). + + - *sniff_en*: ``bool`` Set to ``True`` to allow data to be accessed by the chips sniff + hardware (default: ``False``). + + - *write_err*: ``bool`` Setting this to ``True`` will clear a previously reported write + error. + + - *read_err*: ``bool`` Setting this to ``True`` will clear a previously reported read + error. + + See the description of the ``CH0_CTRL_TRIG`` register in section 2.5.7 of the RP2040 + datasheet for details of all of these fields. + """ + ... + def close(self) -> None: + """ + Release the claim on the underlying DMA channel and free the interrupt + handler. The :class:`DMA` object can not be used after this operation. + """ + ... + def config( + self, + read: int | AnyReadableBuf | None = None, + write: int | AnyWritableBuf | None = None, + count: int = -1, + ctrl: int = -1, + trigger: bool = False, + ) -> None: + """ + Configure the DMA registers for the channel and optionally start the transfer. + Parameters are: + + - *read*: The address from which the DMA controller will start reading data or + an object that will provide data to be read. It can be an integer or any + object that supports the buffer protocol. + - *write*: The address to which the DMA controller will start writing or an + object into which data will be written. It can be an integer or any object + that supports the buffer protocol. + - *count*: The number of bus transfers that will execute before this channel + stops. Note that this is the number of transfers, not the number of bytes. + If the transfers are 2 or 4 bytes wide then the total amount of data moved + (and thus the size of required buffer) needs to be multiplied accordingly. + - *ctrl*: The value for the DMA control register. This is an integer value + that is typically packed using the :meth:`DMA.pack_ctrl()`. + - *trigger*: Optionally commence the transfer immediately. + """ + ... + def active(self, value: Any | None = None) -> bool: + """ + Gets or sets whether the DMA channel is currently running. + + >>> sm.active() + 0 + >>> sm.active(1) + >>> while sm.active(): + """ + ... + def __init__( + self, + read: int | AnyReadableBuf | None = None, + write: int | AnyWritableBuf | None = None, + count: int = -1, + ctrl: int = -1, + trigger: bool = False, + ) -> None: ... + +class PIO: + """ + Gets the PIO instance numbered *id*. The RP2040 has two PIO instances, + numbered 0 and 1. + + Raises a ``ValueError`` if any other argument is provided. + """ + + JOIN_TX: Final[int] = 1 + """These constants are used for the *fifo_join* argument to `asm_pio`.""" + JOIN_NONE: Final[int] = 0 + """These constants are used for the *fifo_join* argument to `asm_pio`.""" + JOIN_RX: Final[int] = 2 + """These constants are used for the *fifo_join* argument to `asm_pio`.""" + SHIFT_LEFT: Final[int] = 0 + """\ + These constants are used for the *in_shiftdir* and *out_shiftdir* arguments + to `asm_pio` or `StateMachine.init`. + """ + OUT_HIGH: Final[int] = 3 + """\ + These constants are used for the *out_init*, *set_init*, and *sideset_init* + arguments to `asm_pio`. + """ + OUT_LOW: Final[int] = 2 + """\ + These constants are used for the *out_init*, *set_init*, and *sideset_init* + arguments to `asm_pio`. + """ + SHIFT_RIGHT: Final[int] = 1 + """\ + These constants are used for the *in_shiftdir* and *out_shiftdir* arguments + to `asm_pio` or `StateMachine.init`. + """ + IN_LOW: Final[int] = 0 + """\ + These constants are used for the *out_init*, *set_init*, and *sideset_init* + arguments to `asm_pio`. + """ + IRQ_SM3: Final[int] = 2048 + """These constants are used for the *trigger* argument to `PIO.irq`.""" + IN_HIGH: Final[int] = 1 + """\ + These constants are used for the *out_init*, *set_init*, and *sideset_init* + arguments to `asm_pio`. + """ + IRQ_SM2: Final[int] = 1024 + """These constants are used for the *trigger* argument to `PIO.irq`.""" + IRQ_SM0: Final[int] = 256 + """These constants are used for the *trigger* argument to `PIO.irq`.""" + IRQ_SM1: Final[int] = 512 + """These constants are used for the *trigger* argument to `PIO.irq`.""" + def state_machine(self, id: int, program: _PIO_ASM_Program, **kwargs) -> StateMachine: + """ + Gets the state machine numbered *id*. On the RP2040, each PIO instance has + four state machines, numbered 0 to 3. + + Optionally initialize it with a *program*: see `StateMachine.init`. + + >>> rp2.PIO(1).state_machine(3) + StateMachine(7) + """ + ... + def remove_program(self, program: Optional[_PIO_ASM_Program] = None) -> None: + """ + Remove *program* from the instruction memory of this PIO instance. + + If no program is provided, it removes all programs. + + It is not an error to remove a program which has already been removed. + """ + ... + def irq( + self, + handler: Optional[Callable[[PIO], None]] = None, + trigger: _IRQ_TRIGGERS | None = None, + hard: bool = False, + ) -> _IRQ: + """ + Returns the IRQ object for this PIO instance. + + MicroPython only uses IRQ 0 on each PIO instance. IRQ 1 is not available. + + Optionally configure it. + """ + ... + def add_program(self, program: _PIO_ASM_Program) -> None: + """ + Add the *program* to the instruction memory of this PIO instance. + + The amount of memory available for programs on each PIO instance is + limited. If there isn't enough space left in the PIO's program memory + this method will raise ``OSError(ENOMEM)``. + """ + ... + def __init__(self, id: int) -> None: ... + +class StateMachine: + """ + Get the state machine numbered *id*. The RP2040 has two identical PIO + instances, each with 4 state machines: so there are 8 state machines in + total, numbered 0 to 7. + + Optionally initialize it with the given program *program*: see + `StateMachine.init`. + """ + def irq(self, handler: Optional[Callable] = None, trigger: int = 0 | 1, hard: bool = False) -> _IRQ: + """ + Returns the IRQ object for the given StateMachine. + + Optionally configure it. + """ + ... + def put(self, value: Union[int, bytes, bytearray], shift: int = 0): + """ + Push words onto the state machine's TX FIFO. + + *value* can be an integer, an array of type ``B``, ``H`` or ``I``, or a + `bytearray`. + + This method will block until all words have been written to the FIFO. If + the FIFO is, or becomes, full, the method will block until the state machine + pulls enough words to complete the write. + + Each word is first shifted left by *shift* bits, i.e. the state machine + receives ``word << shift``. + """ + ... + def restart(self) -> None: + """ + Restarts the state machine and jumps to the beginning of the program. + + This method clears the state machine's internal state using the RP2040's + ``SM_RESTART`` register. This includes: + + - input and output shift counters + - the contents of the input shift register + - the delay counter + - the waiting-on-IRQ state + - a stalled instruction run using `StateMachine.exec()` + """ + ... + def rx_fifo(self) -> int: + """ + Returns the number of words in the state machine's RX FIFO. A value of 0 + indicates the FIFO is empty. + + Useful for checking if data is waiting to be read, before calling + `StateMachine.get()`. + """ + ... + def tx_fifo(self) -> int: + """ + Returns the number of words in the state machine's TX FIFO. A value of 0 + indicates the FIFO is empty. + + Useful for checking if there is space to push another word using + `StateMachine.put()`. + """ + ... + def init( + self, + program: _PIO_ASM_Program, + *, + freq: int = 1, + in_base: Pin | None = None, + out_base: Pin | None = None, + set_base: Pin | None = None, + jmp_pin: Pin | None = None, + sideset_base: Pin | None = None, + in_shiftdir: int | None = None, + out_shiftdir: int | None = None, + push_thresh: int | None = None, + pull_thresh: int | None = None, + **kwargs, + ) -> None: + """ + Configure the state machine instance to run the given *program*. + + The program is added to the instruction memory of this PIO instance. If the + instruction memory already contains this program, then its offset is + reused so as to save on instruction memory. + + - *freq* is the frequency in Hz to run the state machine at. Defaults to + the system clock frequency. + + The clock divider is computed as ``system clock frequency / freq``, so + there can be slight rounding errors. + + The minimum possible clock divider is one 65536th of the system clock: so + at the default system clock frequency of 125MHz, the minimum value of + *freq* is ``1908``. To run state machines at slower frequencies, you'll + need to reduce the system clock speed with `machine.freq()`. + - *in_base* is the first pin to use for ``in()`` instructions. + - *out_base* is the first pin to use for ``out()`` instructions. + - *set_base* is the first pin to use for ``set()`` instructions. + - *jmp_pin* is the first pin to use for ``jmp(pin, ...)`` instructions. + - *sideset_base* is the first pin to use for side-setting. + - *in_shiftdir* is the direction the ISR will shift, either + `PIO.SHIFT_LEFT` or `PIO.SHIFT_RIGHT`. + - *out_shiftdir* is the direction the OSR will shift, either + `PIO.SHIFT_LEFT` or `PIO.SHIFT_RIGHT`. + - *push_thresh* is the threshold in bits before auto-push or conditional + re-pushing is triggered. + - *pull_thresh* is the threshold in bits before auto-pull or conditional + re-pulling is triggered. + + Note: pins used for *in_base* need to be configured manually for input (or + otherwise) so that the PIO can see the desired signal (they could be input + pins, output pins, or connected to a different peripheral). The *jmp_pin* + can also be configured manually, but by default will be an input pin. + """ + ... + def exec(self, instr: Union[int, str]) -> None: + """ + Execute a single PIO instruction. + + If *instr* is a string then uses `asm_pio_encode` to encode the instruction + from the given string. + + >>> sm.exec("set(0, 1)") + + If *instr* is an integer then it is treated as an already encoded PIO + machine code instruction to be executed. + + >>> sm.exec(rp2.asm_pio_encode("out(y, 8)", 0)) + """ + ... + def get(self, buf: Optional[bytearray] = None, shift: int = 0) -> Union[int, None]: + """ + Pull a word from the state machine's RX FIFO. + + If the FIFO is empty, it blocks until data arrives (i.e. the state machine + pushes a word). + + The value is shifted right by *shift* bits before returning, i.e. the + return value is ``word >> shift``. + """ + ... + + @overload + def active(self, value: None) -> bool: ... + @overload + def active(self, value: Union[bool, int]) -> None: + """ + Gets or sets whether the state machine is currently running. + + >>> sm.active() + True + >>> sm.active(0) + False + """ + ... + def __init__( + self, + id: int, + program: _PIO_ASM_Program, + *, + freq: int = 1, + in_base: Pin | None = None, + out_base: Pin | None = None, + set_base: Pin | None = None, + jmp_pin: Pin | None = None, + sideset_base: Pin | None = None, + in_shiftdir: int | None = None, + out_shiftdir: int | None = None, + push_thresh: int | None = None, + pull_thresh: int | None = None, + **kwargs, + ) -> None: ... + +class PIOASMEmit: + """ + The PIOASMEmit class provides a comprehensive interface for constructing PIO programs, + handling the intricacies of instruction encoding, label management, and program state. + This allows users to build complex PIO programs in pythone, leveraging the flexibility + and power of the PIO state machine. + + The class should not be instantiated directly, but used via the `@asm_pio` decorator. + """ + def in_(self, src: int, data) -> _PIO_ASM_Program: + """rp2.PIO IN instruction. + + Shift Bit count bits from Source into the Input Shift Register (ISR). + Shift direction is configured for each state machine by SHIFTCTRL_IN_SHIFTDIR. + Additionally, increase the input shift count by Bit count, saturating at 32. + + * Source: + 000: PINS + 001: X (scratch register X) + 010: Y (scratch register Y) + 011: NULL (all zeroes) + 100: Reserved + 101: Reserved + 110: ISR + 111: OSR + * Bit count: How many bits to shift into the ISR. 1…32 bits, 32 is encoded as 00000. + + If automatic push is enabled, IN will also push the ISR contents to the RX FIFO if the push threshold is reached + (SHIFTCTRL_PUSH_THRESH). IN still executes in one cycle, whether an automatic push takes place or not. The state machine + will stall if the RX FIFO is full when an automatic push occurs. An automatic push clears the ISR contents to all-zeroes, + and clears the input shift count. + IN always uses the least significant Bit count bits of the source data. For example, if PINCTRL_IN_BASE is set to 5, the + instruction IN PINS, 3 will take the values of pins 5, 6 and 7, and shift these into the ISR. First the ISR is shifted to the left + or right to make room for the new input data, then the input data is copied into the gap this leaves. The bit order of the + input data is not dependent on the shift direction. + NULL can be used for shifting the ISR’s contents. For example, UARTs receive the LSB first, so must shift to the right. + After 8 IN PINS, 1 instructions, the input serial data will occupy bits 31…24 of the ISR. An IN NULL, 24 instruction will shift + in 24 zero bits, aligning the input data at ISR bits 7…0. Alternatively, the processor or DMA could perform a byte read + from FIFO address + 3, which would take bits 31…24 of the FIFO contents. + """ + ... + def side(self, value: int): + """rp2.PIO side modifier. + This is a modifier which can be applied to any instruction, and is used to control side-set pin values. + value: the value (bits) to output on the side-set pins + + When an instruction has side 0 next to it, the corresponding output is set LOW, + and when it has side 1 next to it, the corresponding output is set HIGH. + There can be up to 5 side-set pins, in which case side N is interpreted as a binary number. + + `side(0b00011)` sets the first and the second side-set pin HIGH, and the others LOW. + """ + ... + def out(self, destination: int, bit_count: int) -> _PIO_ASM_Program: + """rp2.PIO OUT instruction. + + Shift Bit count bits out of the Output Shift Register (OSR), and write those bits to Destination. + Additionally, increase the output shift count by Bit count, saturating at 32. + + Destination: (use lowercase in MicroPython) + - 000: PINS + - 001: X (scratch register X) + - 010: Y (scratch register Y) + - 011: NULL (discard data) + - 100: PINDIRS + - 101: PC + - 110: ISR (also sets ISR shift counter to Bit count) + - 111: EXEC (Execute OSR shift data as instruction) + + Bit_count: + how many bits to shift out of the OSR. 1…32 bits, 32 is encoded as 00000. + + A 32-bit value is written to Destination: the lower Bit count bits come from the OSR, and the remainder are zeroes. This + value is the least significant Bit count bits of the OSR if SHIFTCTRL_OUT_SHIFTDIR is to the right, otherwise it is the most + significant bits. + + PINS and PINDIRS use the OUT pin mapping. + + If automatic pull is enabled, the OSR is automatically refilled from the TX FIFO if the pull threshold, SHIFTCTRL_PULL_THRESH, + is reached. The output shift count is simultaneously cleared to 0. In this case, the OUT will stall if the TX FIFO is empty, + but otherwise still executes in one cycle. + + OUT EXEC allows instructions to be included inline in the FIFO datastream. The OUT itself executes on one cycle, and the + instruction from the OSR is executed on the next cycle. There are no restrictions on the types of instructions which can + be executed by this mechanism. Delay cycles on the initial OUT are ignored, but the executee may insert delay cycles as + normal. + + OUT PC behaves as an unconditional jump to an address shifted out from the OSR. + """ + ... + def jmp(self, condition, label: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO JMP instruction. + + Set program counter to Address if Condition is true, otherwise no operation. + Delay cycles on a JMP always take effect, whether Condition is true or false, and they take place after Condition is + evaluated and the program counter is updated. + + Parameters: + + `condition`: + - `None` : (no condition): Always + - `not_x` : !X: scratch X zero + - `x_dec` : X--: scratch X non-zero, prior to decrement + - `not_y` : !Y: scratch Y zero + - `y_dec` : Y--: scratch Y non-zero, prior to decrement + - `x_not_y` : X!=Y: scratch X not equal scratch Y + - `pin` : PIN: branch on input pin + - `not_osre` : !OSRE: output shift register not empty + + `label`: Instruction address to jump to. In the instruction encoding, this is an absolute address within the PIO + instruction memory. + + `JMP PIN` branches on the GPIO selected by EXECCTRL_JMP_PIN, a configuration field which selects one out of the maximum + of 32 GPIO inputs visible to a state machine, independently of the state machine’s other input mapping. The branch is + taken if the GPIO is high. + + `!OSRE` compares the bits shifted out since the last PULL with the shift count threshold configured by SHIFTCTRL_PULL_THRESH. + This is the same threshold used by autopull. + + `JMP X--` and `JMP Y--` always decrement scratch register X or Y, respectively. The decrement is not conditional on the + current value of the scratch register. The branch is conditioned on the initial value of the register, i.e. before the + decrement took place: if the register is initially nonzero, the branch is taken. + """ + ... + def start_pass(self, pass_) -> None: + """The start_pass method is used to start a pass over the instructions, + setting up the necessary state for the pass. It handles wrapping instructions + if needed and adjusts the delay maximum based on the number of side-set bits. + """ + ... + def wrap(self) -> None: + """rp2.PIO WRAP directive. + + Placed after an instruction, this directive specifies the instruction after which, + in normal control flow (i.e. jmp with false condition, or no jmp), the program + wraps (to .wrap_target instruction). This directive is invalid outside of a + program, may only be used once within a program, and if not specified + defaults to after the last program instruction. + """ + ... + def word(self, instr, label: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO instruction. + + Stores a raw 16-bit value as an instruction in the program. This directive is + invalid outside of a program. + """ + ... + def wait(self, polarity: int, src: int, index: int, /) -> _PIO_ASM_Program: + """rp2.PIO WAIT instruction. + + Stall until some condition is met. + Like all stalling instructions, delay cycles begin after the instruction completes. That is, if any delay cycles are present, + they do not begin counting until after the wait condition is met. + + Parameters: + + Polarity: + 1: wait for a 1. + 0: wait for a 0. + + Source: what to wait on. Values are: + 00: GPIO: System GPIO input selected by Index. This is an absolute GPIO index, and is not affected by the state machine’s input IO mapping. + 01: PIN: Input pin selected by Index. This state machine’s input IO mapping is applied first, and then Index + selects which of the mapped bits to wait on. In other words, the pin is selected by adding Index to the + PINCTRL_IN_BASE configuration, modulo 32. + 10: IRQ: PIO IRQ flag selected by Index + 11: Reserved + + Index: which pin or bit to check. + + WAIT x IRQ behaves slightly differently from other WAIT sources: + * If Polarity is 1, the selected IRQ flag is cleared by the state machine upon the wait condition being met. + * The flag index is decoded in the same way as the IRQ index field: if the MSB is set, the state machine ID (0…3) is + added to the IRQ index, by way of modulo-4 addition on the two LSBs. For example, state machine 2 with a flag + value of '0x11' will wait on flag 3, and a flag value of '0x13' will wait on flag 1. This allows multiple state machines + running the same program to synchronise with each other. + CAUTION + WAIT 1 IRQ x should not be used with IRQ flags presented to the interrupt controller, to avoid a race condition with a + system interrupt handler + """ + ... + def wrap_target(self) -> None: + """rp2.PIO WRAP_TARGET directive. + + This directive specifies the instruction where + execution continues due to program wrapping. This directive is invalid outside + of a program, may only be used once within a program, and if not specified + defaults to the start of the program + """ + def delay(self, delay: int): + """rp2.PIO delay modifier. + + The delay method allows setting a delay for the current instruction, + ensuring it does not exceed the maximum allowed delay. + """ + def label(self, label: str) -> None: + """rp2.PIO instruction. + + Labels are of the form: + + : + + or + + PUBLIC : + + at the start of a line + """ + ... + def irq(self, mod, index: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO instruction. + + Set or clear the IRQ flag selected by Index argument. + * Clear: if 1, clear the flag selected by Index, instead of raising it. If Clear is set, the Wait bit has no effect. + * Wait: if 1, halt until the raised flag is lowered again, e.g. if a system interrupt handler has acknowledged the flag. + * Index: + + The 3 LSBs specify an IRQ index from 0-7. This IRQ flag will be set/cleared depending on the Clear bit. + + If the MSB is set, the state machine ID (0…3) is added to the IRQ index, by way of modulo-4 addition on the + two LSBs. For example, state machine 2 with a flag value of 0x11 will raise flag 3, and a flag value of 0x13 will raise flag 1. + + IRQ flags 4-7 are visible only to the state machines; IRQ flags 0-3 can be routed out to system level interrupts, on either + of the PIO’s two external interrupt request lines, configured by IRQ0_INTE and IRQ1_INTE. + The modulo addition bit allows relative addressing of 'IRQ' and 'WAIT' instructions, for synchronising state machines + which are running the same program. Bit 2 (the third LSB) is unaffected by this addition. + If Wait is set, Delay cycles do not begin until after the wait period elapses.""" + def set(self, destination: int, data) -> _PIO_ASM_Program: + """rp2.PIO SET instruction. + + Write immediate value Data to Destination. + + • Destination: + 000: PINS + 001: X (scratch register X) 5 LSBs are set to Data, all others cleared to 0. + 010: Y (scratch register Y) 5 LSBs are set to Data, all others cleared to 0. + 011: Reserved + 100: PINDIRS + 101: Reserved + 110: Reserved + 111: Reserved + • Data: 5-bit immediate value to drive to pins or register. + + This can be used to assert control signals such as a clock or chip select, or to initialise loop counters. As Data is 5 bits in + size, scratch registers can be SET to values from 0-31, which is sufficient for a 32-iteration loop. + The mapping of SET and OUT onto pins is configured independently. They may be mapped to distinct locations, for + example if one pin is to be used as a clock signal, and another for data. They may also be overlapping ranges of pins: a + UART transmitter might use SET to assert start and stop bits, and OUT instructions to shift out FIFO data to the same pins. + """ + ... + def mov(self, dest, src, operation: int | None = None) -> _PIO_ASM_Program: + """rp2.PIO MOV instruction. + + Copy data from Source to Destination. + + Destination: + - 000: PINS (Uses same pin mapping as OUT) + - 001: X (Scratch register X) + - 010: Y (Scratch register Y) + - 011: Reserved + - 100: EXEC (Execute data as instruction) + - 101: PC + - 110: ISR (Input shift counter is reset to 0 by this operation, i.e. empty) + - 111: OSR (Output shift counter is reset to 0 by this operation, i.e. full) + + Operation: + - 00: None + - 01: Invert (bitwise complement) + - 10: Bit-reverse + - 11: Reserved + + Source: + - 000: PINS (Uses same pin mapping as IN) + - 001: X + - 010: Y + - 011: NULL + - 100: Reserved + - 101: STATUS + - 110: ISR + - 111: OSR + + MOV PC causes an unconditional jump. MOV EXEC has the same behaviour as OUT EXEC (Section 3.4.5), and allows register + contents to be executed as an instruction. The MOV itself executes in 1 cycle, and the instruction in Source on the next + cycle. Delay cycles on MOV EXEC are ignored, but the executee may insert delay cycles as normal. + The STATUS source has a value of all-ones or all-zeroes, depending on some state machine status such as FIFO + full/empty, configured by EXECCTRL_STATUS_SEL. + + MOV can manipulate the transferred data in limited ways, specified by the Operation argument. Invert sets each bit in + Destination to the logical NOT of the corresponding bit in Source, i.e. 1 bits become 0 bits, and vice versa. Bit reverse sets + each bit n in Destination to bit 31 - n in Source, assuming the bits are numbered 0 to 31. + MOV dst, PINS reads pins using the IN pin mapping, and writes the full 32-bit value to the destination without masking. + The LSB of the read value is the pin indicated by PINCTRL_IN_BASE, and each successive bit comes from a higher numbered pin, wrapping after 31. + + """ + ... + def push(self, value: int = ..., value2: int = ...) -> _PIO_ASM_Program: + """rp2.PIO PUSH instruction. + + Push the contents of the ISR into the RX FIFO, as a single 32-bit word. Clear ISR to all-zeroes. + * IfFull: If 1, do nothing unless the total input shift count has reached its threshold, SHIFTCTRL_PUSH_THRESH (the same + as for autopush). + * Block: If 1, stall execution if RX FIFO is full. + + PUSH IFFULL helps to make programs more compact, like autopush. It is useful in cases where the IN would stall at an + inappropriate time if autopush were enabled, e.g. if the state machine is asserting some external control signal at this + point. + The PIO assembler sets the Block bit by default. If the Block bit is not set, the PUSH does not stall on a full RX FIFO, instead + continuing immediately to the next instruction. The FIFO state and contents are unchanged when this happens. The ISR + is still cleared to all-zeroes, and the FDEBUG_RXSTALL flag is set (the same as a blocking PUSH or autopush to a full RX FIFO) + to indicate data was lost. + + """ + ... + def pull(self, block: int = block, timeout: int = 0) -> _PIO_ASM_Program: + """rp2.PIO PULL instruction. + + Load a 32-bit word from the TX FIFO into the OSR. + * IfEmpty: If 1, do nothing unless the total output shift count has reached its threshold, SHIFTCTRL_PULL_THRESH (the + same as for autopull). + * Block: If 1, stall if TX FIFO is empty. If 0, pulling from an empty FIFO copies scratch X to OSR. + + Some peripherals (UART, SPI…) should halt when no data is available, and pick it up as it comes in; others (I2S) should + clock continuously, and it is better to output placeholder or repeated data than to stop clocking. This can be achieved + with the Block parameter. + A nonblocking PULL on an empty FIFO has the same effect as MOV OSR, X. The program can either preload scratch register + X with a suitable default, or execute a MOV X, OSR after each PULL NOBLOCK, so that the last valid FIFO word will be recycled + until new data is available. + + PULL IFEMPTY is useful if an OUT with autopull would stall in an inappropriate location when the TX FIFO is empty. For + example, a UART transmitter should not stall immediately after asserting the start bit. IfEmpty permits some of the same + program simplifications as autopull, but the stall occurs at a controlled point in the program. + + NOTE: + When autopull is enabled, any PULL instruction is a no-op when the OSR is full, so that the PULL instruction behaves as + a barrier. OUT NULL, 32 can be used to explicitly discard the OSR contents. See the RP2040 Datasheet for more detail + on autopull + """ + ... + def nop(self) -> _PIO_ASM_Program: + """rp2.PIO NOP instruction. + + Assembles to mov y, y. "No operation", has no particular side effect, but a useful vehicle for a side-set + operation or an extra delay. + """ + ... + def __init__( + self, + *, + out_init: int | List | None = ..., + set_init: int | List | None = ..., + sideset_init: int | List | None = ..., + in_shiftdir: int = ..., + out_shiftdir: int = ..., + autopush: bool = ..., + autopull: bool = ..., + push_thresh: int = ..., + pull_thresh: int = ..., + fifo_join: int = ..., + ) -> None: ... + @overload + def __getitem__(self, key): ... + @overload + def __getitem__(self, key: int): ... + @overload + def __getitem__(self, key): ... + @overload + def __getitem__(self, key: int): ... + +class Flash(AbstractBlockDev): + """ + Gets the singleton object for accessing the SPI flash memory. + """ + @overload + def readblocks(self, block_num: int, buf: bytearray) -> bool: + """ + The first form reads aligned, multiples of blocks. + Starting at the block given by the index *block_num*, read blocks from + the device into *buf* (an array of bytes). + The number of blocks to read is given by the length of *buf*, + which will be a multiple of the block size. + """ + + @overload + def readblocks(self, block_num: int, buf: bytearray, offset: int) -> bool: + """ + The second form allows reading at arbitrary locations within a block, + and arbitrary lengths. + Starting at block index *block_num*, and byte offset within that block + of *offset*, read bytes from the device into *buf* (an array of bytes). + The number of bytes to read is given by the length of *buf*. + """ + + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, /) -> None: + """ + The first form writes aligned, multiples of blocks, and requires that the + blocks that are written to be first erased (if necessary) by this method. + Starting at the block given by the index *block_num*, write blocks from + *buf* (an array of bytes) to the device. + The number of blocks to write is given by the length of *buf*, + which will be a multiple of the block size. + """ + + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, offset: int, /) -> None: + """ + The second form allows writing at arbitrary locations within a block, + and arbitrary lengths. Only the bytes being written should be changed, + and the caller of this method must ensure that the relevant blocks are + erased via a prior ``ioctl`` call. + Starting at block index *block_num*, and byte offset within that block + of *offset*, write bytes from *buf* (an array of bytes) to the device. + The number of bytes to write is given by the length of *buf*. + + Note that implementations must never implicitly erase blocks if the offset + argument is specified, even if it is zero. + """ + + @overload + def ioctl(self, op: int, arg) -> int | None: ... + # + @overload + def ioctl(self, op: int) -> int | None: + """ + These methods implement the simple and extended + :ref:`block protocol ` defined by + :class:`vfs.AbstractBlockDev`. + """ + def __init__(self) -> None: ... + +class PIOASMError(Exception): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/rp2/asm_pio.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/rp2/asm_pio.pyi new file mode 100644 index 0000000000..4346014d1c --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/rp2/asm_pio.pyi @@ -0,0 +1,459 @@ +""" +This module provides type hints for the `rp2.asm_pio` module in the Raspberry Pi Pico Python SDK. +It includes definitions for constants, functions, and directives used in PIO assembly programming. + +The module includes docstrings for each function and directive, providing information on their usage and parameters. + +Note: This module is intended for use with type checking and does not contain actual implementations of the functions. + +For more information on PIO assembly programming and the Raspberry Pi Pico Python SDK, refer to the following documents: +- raspberry-pi-pico-python-sdk.pdf: https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf +- raspberry-pi-pico-c-sdk.pdf: https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf + +For a simpler and clearer reference on PIO assembly, you can also visit: https://dernulleffekt.de/doku.php?id=raspberrypipico:pico_pio + + +rp2.PIO type hints have to be loaded manually. Add the following lines to the top of the file with the PIO assembler code: + +```py +# ----------------------------------------------- +# add type hints for the rp2.PIO Instructions +try: + from typing_extensions import TYPE_CHECKING # type: ignore +except ImportError: + TYPE_CHECKING = False +if TYPE_CHECKING: + from rp2.asm_pio import * +# ----------------------------------------------- +``` +""" + +from typing import Final, Optional + +from _typeshed import Incomplete +from typing_extensions import TYPE_CHECKING + +from micropython import const # type: ignore + +# ref: https://github.com/Josverl/PIO_ASM_typing + +# The decorator has limited type information, to improve this it may be needed to depend on Pyton 3.10 or later to allow for a better support for type hints +# The type hints are not complete, also some of the methods currently need to be duplicated to allow for the fluent style of programming. e.g. out().side(0) +# The text for the docstrings originates from multiple locations, and is not always consistent. - Micropython RP2 Documentation - not fully complete on all methods and classes - RP2 python and C datasheets - sometime the language does not make sense in a python context. +# The defined methods and functions are also avaiable to the type checkers after/outside the scope where the @rp2.asm_pio decorator is used, this is not needed and should be removed. This can/will be confusing when the same names are used in the PIO assembler code and in the python code. + +if TYPE_CHECKING: + # defined functions are all methods of the (frozen) class PIOASMEmit: + # but also have a self method + from rp2 import PIOASMEmit, _PIO_ASM_Program + + # constants defined for PIO assembly + # TODO: Make Final - or make const always return Final + + gpio = const(0) + # "pin": see below, translated to 1 + # "irq": see below function, translated to 2 + # source/dest constants for in_, out, mov, set + pins = 0 + x = 1 + y = 2 + null = 3 + pindirs = 4 + pc = 5 + status = 5 + isr = 6 + osr = 7 + exec = (8,) # translated to 4 for mov, 7 for ou + # operation functions for mov's src + def invert(x: int) -> int: + return x | 8 + + def reverse(x: int) -> int: + return x | 16 + # jmp condition constants + not_x = 1 + x_dec = 2 + not_y = 3 + y_dec = 4 + x_not_y = 5 + pin = 6 + not_osre = 7 + # constants and modifiers for irq + # constants for push, pull + noblock = 0x01 + block = 0x21 + clear = 0x40 + + iffull = 0x40 + ifempty = 0x40 + + # rel = lambda x: x | 0x10 + def rel(x: int) -> int: + """Relative IRQ number""" + return x | 0x10 + #################################################################################### + # missing + # .define ( PUBLIC ) + # Define an integer symbol named with the value (see Section # 3.3.3). + # If this .define appears before the first program in the input file, then the + # define is global to all programs, otherwise it is local to the program in which it + # occurs. If PUBLIC is specified the symbol will be emitted into the assembled + # output for use by user code. For the SDK this takes the form of: + # #define _ value for program symbols or #define + # value for global symbols + + # .origin + # Optional directive to specify the PIO instruction memory offset at which the + # program must load. Most commonly this is used for programs that must load + # at offset 0, because they use data based JMPs with the (absolute) jmp target + # being stored in only a few bits. This directive is invalid outside of a program + + #################################################################################### + def delay(delay: int) -> _PIO_ASM_Program: + """rp2.PIO delay modifier. + + The delay method allows setting a delay for the current instruction, + ensuring it does not exceed the maximum allowed delay. + """ + ... + + def side(value: int) -> _PIO_ASM_Program: + """rp2.PIO WRAP modifier. + This is a modifier which can be applied to any instruction, and is used to control side-set pin values. + value: the value (bits) to output on the side-set pins + + When an instruction has side 0 next to it, the corresponding output is set LOW, + and when it has side 1 next to it, the corresponding output is set HIGH. + There can be up to 5 side-set pins, in which case side N is interpreted as a binary number. + + `side(0b00011)` sets the first and the second side-set pin HIGH, and the others LOW. + """ + ... + + def wrap_target() -> None: + """rp2.PIO WRAP_TARGET directive. + + This directive specifies the instruction where + execution continues due to program wrapping. This directive is invalid outside + of a program, may only be used once within a program, and if not specified + defaults to the start of the program + """ + ... + + def wrap() -> None: + """rp2.PIO WRAP directive. + + Placed after an instruction, this directive specifies the instruction after which, + in normal control flow (i.e. jmp with false condition, or no jmp), the program + wraps (to .wrap_target instruction). This directive is invalid outside of a + program, may only be used once within a program, and if not specified + defaults to after the last program instruction. + """ + ... + + def label(label: str) -> None: + """rp2.PIO LABEL directive. + + Labels are of the form: + + : + + or + + PUBLIC : + + at the start of a line + """ + ... + + def word(instr, label: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO instruction. + + Stores a raw 16-bit value as an instruction in the program. This directive is + invalid outside of a program. + """ + ... + + def nop() -> _PIO_ASM_Program: + """rp2.PIO NOP instruction. + + Assembles to mov y, y. "No operation", has no particular side effect, but a useful vehicle for a side-set + operation or an extra delay. + """ + ... + + def jmp(condition, label: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO JMP instruction. + + Set program counter to Address if Condition is true, otherwise no operation. + Delay cycles on a JMP always take effect, whether Condition is true or false, and they take place after Condition is + evaluated and the program counter is updated. + + Parameters: + + `condition`: + - `None` : (no condition): Always + - `not_x` : !X: scratch X zero + - `x_dec` : X--: scratch X non-zero, prior to decrement + - `not_y` : !Y: scratch Y zero + - `y_dec` : Y--: scratch Y non-zero, prior to decrement + - `x_not_y` : X!=Y: scratch X not equal scratch Y + - `pin` : PIN: branch on input pin + - `not_osre` : !OSRE: output shift register not empty + + `label`: Instruction address to jump to. In the instruction encoding, this is an absolute address within the PIO + instruction memory. + + `JMP PIN` branches on the GPIO selected by EXECCTRL_JMP_PIN, a configuration field which selects one out of the maximum + of 32 GPIO inputs visible to a state machine, independently of the state machine’s other input mapping. The branch is + taken if the GPIO is high. + + `!OSRE` compares the bits shifted out since the last PULL with the shift count threshold configured by SHIFTCTRL_PULL_THRESH. + This is the same threshold used by autopull. + + `JMP X--` and `JMP Y--` always decrement scratch register X or Y, respectively. The decrement is not conditional on the + current value of the scratch register. The branch is conditioned on the initial value of the register, i.e. before the + decrement took place: if the register is initially nonzero, the branch is taken. + """ + ... + + def wait(polarity: int, src: int, index: int, /) -> _PIO_ASM_Program: + """rp2.PIO WAIT instruction. + + Stall until some condition is met. + Like all stalling instructions, delay cycles begin after the instruction completes. That is, if any delay cycles are present, + they do not begin counting until after the wait condition is met. + + Parameters: + + Polarity: + 1: wait for a 1. + 0: wait for a 0. + + Source: what to wait on. Values are: + 00: GPIO: System GPIO input selected by Index. This is an absolute GPIO index, and is not affected by the state machine’s input IO mapping. + 01: PIN: Input pin selected by Index. This state machine’s input IO mapping is applied first, and then Index + selects which of the mapped bits to wait on. In other words, the pin is selected by adding Index to the + PINCTRL_IN_BASE configuration, modulo 32. + 10: IRQ: PIO IRQ flag selected by Index + 11: Reserved + + Index: which pin or bit to check. + + WAIT x IRQ behaves slightly differently from other WAIT sources: + * If Polarity is 1, the selected IRQ flag is cleared by the state machine upon the wait condition being met. + * The flag index is decoded in the same way as the IRQ index field: if the MSB is set, the state machine ID (0…3) is + added to the IRQ index, by way of modulo-4 addition on the two LSBs. For example, state machine 2 with a flag + value of '0x11' will wait on flag 3, and a flag value of '0x13' will wait on flag 1. This allows multiple state machines + running the same program to synchronise with each other. + CAUTION + WAIT 1 IRQ x should not be used with IRQ flags presented to the interrupt controller, to avoid a race condition with a + system interrupt handler + """ + ... + + def in_(src, data) -> _PIO_ASM_Program: + """rp2.PIO IN instruction. + + Shift Bit count bits from Source into the Input Shift Register (ISR). + Shift direction is configured for each state machine by SHIFTCTRL_IN_SHIFTDIR. + Additionally, increase the input shift count by Bit count, saturating at 32. + + * Source: + 000: PINS + 001: X (scratch register X) + 010: Y (scratch register Y) + 011: NULL (all zeroes) + 100: Reserved + 101: Reserved + 110: ISR + 111: OSR + * Bit count: How many bits to shift into the ISR. 1…32 bits, 32 is encoded as 00000. + + If automatic push is enabled, IN will also push the ISR contents to the RX FIFO if the push threshold is reached + (SHIFTCTRL_PUSH_THRESH). IN still executes in one cycle, whether an automatic push takes place or not. The state machine + will stall if the RX FIFO is full when an automatic push occurs. An automatic push clears the ISR contents to all-zeroes, + and clears the input shift count. + IN always uses the least significant Bit count bits of the source data. For example, if PINCTRL_IN_BASE is set to 5, the + instruction IN PINS, 3 will take the values of pins 5, 6 and 7, and shift these into the ISR. First the ISR is shifted to the left + or right to make room for the new input data, then the input data is copied into the gap this leaves. The bit order of the + input data is not dependent on the shift direction. + NULL can be used for shifting the ISR’s contents. For example, UARTs receive the LSB first, so must shift to the right. + After 8 IN PINS, 1 instructions, the input serial data will occupy bits 31…24 of the ISR. An IN NULL, 24 instruction will shift + in 24 zero bits, aligning the input data at ISR bits 7…0. Alternatively, the processor or DMA could perform a byte read + from FIFO address + 3, which would take bits 31…24 of the FIFO contents. + """ + ... + + def out(destination: int, bit_count: int) -> _PIO_ASM_Program: + """rp2.PIO OUT instruction. + + Shift Bit count bits out of the Output Shift Register (OSR), and write those bits to Destination. + Additionally, increase the output shift count by Bit count, saturating at 32. + + Destination: (use lowercase in MicroPython) + - 000: PINS + - 001: X (scratch register X) + - 010: Y (scratch register Y) + - 011: NULL (discard data) + - 100: PINDIRS + - 101: PC + - 110: ISR (also sets ISR shift counter to Bit count) + - 111: EXEC (Execute OSR shift data as instruction) + + Bit_count: + how many bits to shift out of the OSR. 1…32 bits, 32 is encoded as 00000. + + A 32-bit value is written to Destination: the lower Bit count bits come from the OSR, and the remainder are zeroes. This + value is the least significant Bit count bits of the OSR if SHIFTCTRL_OUT_SHIFTDIR is to the right, otherwise it is the most + significant bits. + + PINS and PINDIRS use the OUT pin mapping. + + If automatic pull is enabled, the OSR is automatically refilled from the TX FIFO if the pull threshold, SHIFTCTRL_PULL_THRESH, + is reached. The output shift count is simultaneously cleared to 0. In this case, the OUT will stall if the TX FIFO is empty, + but otherwise still executes in one cycle. + + OUT EXEC allows instructions to be included inline in the FIFO datastream. The OUT itself executes on one cycle, and the + instruction from the OSR is executed on the next cycle. There are no restrictions on the types of instructions which can + be executed by this mechanism. Delay cycles on the initial OUT are ignored, but the executee may insert delay cycles as + normal. + + OUT PC behaves as an unconditional jump to an address shifted out from the OSR. + """ + ... + + def push(value: int = ..., value2: int = ...) -> _PIO_ASM_Program: + """rp2.PIO PUSH instruction.. + + Push the contents of the ISR into the RX FIFO, as a single 32-bit word. Clear ISR to all-zeroes. + * IfFull: If 1, do nothing unless the total input shift count has reached its threshold, SHIFTCTRL_PUSH_THRESH (the same + as for autopush). + * Block: If 1, stall execution if RX FIFO is full. + + PUSH IFFULL helps to make programs more compact, like autopush. It is useful in cases where the IN would stall at an + inappropriate time if autopush were enabled, e.g. if the state machine is asserting some external control signal at this + point. + The PIO assembler sets the Block bit by default. If the Block bit is not set, the PUSH does not stall on a full RX FIFO, instead + continuing immediately to the next instruction. The FIFO state and contents are unchanged when this happens. The ISR + is still cleared to all-zeroes, and the FDEBUG_RXSTALL flag is set (the same as a blocking PUSH or autopush to a full RX FIFO) + to indicate data was lost. + + """ + ... + + def pull(block: int = block, timeout: int = 0) -> _PIO_ASM_Program: + """rp2.PIO PULL instruction.. + + Load a 32-bit word from the TX FIFO into the OSR. + * IfEmpty: If 1, do nothing unless the total output shift count has reached its threshold, SHIFTCTRL_PULL_THRESH (the + same as for autopull). + * Block: If 1, stall if TX FIFO is empty. If 0, pulling from an empty FIFO copies scratch X to OSR. + + Some peripherals (UART, SPI…) should halt when no data is available, and pick it up as it comes in; others (I2S) should + clock continuously, and it is better to output placeholder or repeated data than to stop clocking. This can be achieved + with the Block parameter. + A nonblocking PULL on an empty FIFO has the same effect as MOV OSR, X. The program can either preload scratch register + X with a suitable default, or execute a MOV X, OSR after each PULL NOBLOCK, so that the last valid FIFO word will be recycled + until new data is available. + + PULL IFEMPTY is useful if an OUT with autopull would stall in an inappropriate location when the TX FIFO is empty. For + example, a UART transmitter should not stall immediately after asserting the start bit. IfEmpty permits some of the same + program simplifications as autopull, but the stall occurs at a controlled point in the program. + + NOTE: + When autopull is enabled, any PULL instruction is a no-op when the OSR is full, so that the PULL instruction behaves as + a barrier. OUT NULL, 32 can be used to explicitly discard the OSR contents. See the RP2040 Datasheet for more detail + on autopull + """ + ... + + def mov(dest, src, operation: Optional[int] = None) -> _PIO_ASM_Program: + """rp2.PIO MOV instruction.. + + Copy data from Source to Destination. + + Destination: + - 000: PINS (Uses same pin mapping as OUT) + - 001: X (Scratch register X) + - 010: Y (Scratch register Y) + - 011: Reserved + - 100: EXEC (Execute data as instruction) + - 101: PC + - 110: ISR (Input shift counter is reset to 0 by this operation, i.e. empty) + - 111: OSR (Output shift counter is reset to 0 by this operation, i.e. full) + + Operation: + - 00: None + - 01: Invert (bitwise complement) + - 10: Bit-reverse + - 11: Reserved + + Source: + - 000: PINS (Uses same pin mapping as IN) + - 001: X + - 010: Y + - 011: NULL + - 100: Reserved + - 101: STATUS + - 110: ISR + - 111: OSR + + MOV PC causes an unconditional jump. MOV EXEC has the same behaviour as OUT EXEC (Section 3.4.5), and allows register + contents to be executed as an instruction. The MOV itself executes in 1 cycle, and the instruction in Source on the next + cycle. Delay cycles on MOV EXEC are ignored, but the executee may insert delay cycles as normal. + The STATUS source has a value of all-ones or all-zeroes, depending on some state machine status such as FIFO + full/empty, configured by EXECCTRL_STATUS_SEL. + + MOV can manipulate the transferred data in limited ways, specified by the Operation argument. Invert sets each bit in + Destination to the logical NOT of the corresponding bit in Source, i.e. 1 bits become 0 bits, and vice versa. Bit reverse sets + each bit n in Destination to bit 31 - n in Source, assuming the bits are numbered 0 to 31. + MOV dst, PINS reads pins using the IN pin mapping, and writes the full 32-bit value to the destination without masking. + The LSB of the read value is the pin indicated by PINCTRL_IN_BASE, and each successive bit comes from a higher numbered pin, wrapping after 31. + + """ + ... + + def irq(mod, index: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO instruction. + + Set or clear the IRQ flag selected by Index argument. + * Clear: if 1, clear the flag selected by Index, instead of raising it. If Clear is set, the Wait bit has no effect. + * Wait: if 1, halt until the raised flag is lowered again, e.g. if a system interrupt handler has acknowledged the flag. + * Index: + + The 3 LSBs specify an IRQ index from 0-7. This IRQ flag will be set/cleared depending on the Clear bit. + + If the MSB is set, the state machine ID (0…3) is added to the IRQ index, by way of modulo-4 addition on the + two LSBs. For example, state machine 2 with a flag value of 0x11 will raise flag 3, and a flag value of 0x13 will raise flag 1. + + IRQ flags 4-7 are visible only to the state machines; IRQ flags 0-3 can be routed out to system level interrupts, on either + of the PIO’s two external interrupt request lines, configured by IRQ0_INTE and IRQ1_INTE. + The modulo addition bit allows relative addressing of 'IRQ' and 'WAIT' instructions, for synchronising state machines + which are running the same program. Bit 2 (the third LSB) is unaffected by this addition. + If Wait is set, Delay cycles do not begin until after the wait period elapses.""" + ... + + def set(destination, data) -> _PIO_ASM_Program: + """rp2.PIO SET instruction.. + + Write immediate value Data to Destination. + + • Destination: + 000: PINS + 001: X (scratch register X) 5 LSBs are set to Data, all others cleared to 0. + 010: Y (scratch register Y) 5 LSBs are set to Data, all others cleared to 0. + 011: Reserved + 100: PINDIRS + 101: Reserved + 110: Reserved + 111: Reserved + • Data: 5-bit immediate value to drive to pins or register. + + This can be used to assert control signals such as a clock or chip select, or to initialise loop counters. As Data is 5 bits in + size, scratch registers can be SET to values from 0-31, which is sufficient for a 32-iteration loop. + The mapping of SET and OUT onto pins is configured independently. They may be mapped to distinct locations, for + example if one pin is to be used as a clock signal, and another for data. They may also be overlapping ranges of pins: a + UART transmitter might use SET to assert start and stop bits, and OUT instructions to shift out FIFO data to the same pins. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/select.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/select.pyi new file mode 100644 index 0000000000..845fc36bcb --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/select.pyi @@ -0,0 +1,118 @@ +""" +Wait for events on a set of streams. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/select.html + +CPython module: :mod:`python:select` https://docs.python.org/3/library/select.html . + +This module provides functions to efficiently wait for events on multiple +`streams ` (select streams which are ready for operations). + +--- +Module: 'select' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Iterable, Iterator, List, Optional, Tuple, Final +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar + +POLLOUT: Final[int] = 4 +POLLIN: Final[int] = 1 +POLLHUP: Final[int] = 16 +POLLERR: Final[int] = 8 + +def select( + rlist: Iterable[Any], + wlist: Iterable[Any], + xlist: Iterable[Any], + timeout: int = -1, + /, +) -> None: + """ + Wait for activity on a set of objects. + + This function is provided by some MicroPython ports for compatibility + and is not efficient. Usage of :class:`Poll` is recommended instead. + """ + ... + +class poll: + """ + Create an instance of the Poll class. + """ + def __init__(self) -> None: ... + def register(self, obj, eventmask: Optional[Any] = None) -> None: + """ + Register `stream` *obj* for polling. *eventmask* is logical OR of: + + * ``select.POLLIN`` - data available for reading + * ``select.POLLOUT`` - more data can be written + + Note that flags like ``select.POLLHUP`` and ``select.POLLERR`` are + *not* valid as input eventmask (these are unsolicited events which + will be returned from `poll()` regardless of whether they are asked + for). This semantics is per POSIX. + + *eventmask* defaults to ``select.POLLIN | select.POLLOUT``. + + It is OK to call this function multiple times for the same *obj*. + Successive calls will update *obj*'s eventmask to the value of + *eventmask* (i.e. will behave as `modify()`). + """ + ... + def unregister(self, obj) -> Incomplete: + """ + Unregister *obj* from polling. + """ + ... + def modify(self, obj, eventmask) -> None: + """ + Modify the *eventmask* for *obj*. If *obj* is not registered, `OSError` + is raised with error of ENOENT. + """ + ... + def poll(self, timeout=-1, /) -> List: + """ + Wait for at least one of the registered objects to become ready or have an + exceptional condition, with optional timeout in milliseconds (if *timeout* + arg is not specified or -1, there is no timeout). + + Returns list of (``obj``, ``event``, ...) tuples. There may be other elements in + tuple, depending on a platform and version, so don't assume that its size is 2. + The ``event`` element specifies which events happened with a stream and + is a combination of ``select.POLL*`` constants described above. Note that + flags ``select.POLLHUP`` and ``select.POLLERR`` can be returned at any time + (even if were not asked for), and must be acted on accordingly (the + corresponding stream unregistered from poll and likely closed), because + otherwise all further invocations of `poll()` may return immediately with + these flags set for this stream again. + + In case of timeout, an empty list is returned. + + Admonition:Difference to CPython + :class: attention + + Tuples returned may contain more than 2 elements as described above. + """ + ... + def ipoll(self, timeout=-1, flags=0, /) -> Iterator[Tuple]: + """ + Like :meth:`poll.poll`, but instead returns an iterator which yields a + `callee-owned tuple`. This function provides an efficient, allocation-free + way to poll on streams. + + If *flags* is 1, one-shot behaviour for events is employed: streams for + which events happened will have their event masks automatically reset + (equivalent to ``poll.modify(obj, 0)``), so new events for such a stream + won't be processed until new mask is set with `poll.modify()`. This + behaviour is useful for asynchronous I/O schedulers. + + Admonition:Difference to CPython + :class: attention + + This function is a MicroPython extension. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/socket.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/socket.pyi new file mode 100644 index 0000000000..8fa90e45e6 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/socket.pyi @@ -0,0 +1,426 @@ +""" +Socket module. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/socket.html + +CPython module: :mod:`python:socket` https://docs.python.org/3/library/socket.html . + +This module provides access to the BSD socket interface. + +Admonition:Difference to CPython + :class: attention + + For efficiency and consistency, socket objects in MicroPython implement a `stream` + (file-like) interface directly. In CPython, you need to convert a socket to + a file-like object using `makefile()` method. This method is still supported + by MicroPython (but is a no-op), so where compatibility with CPython matters, + be sure to use it. + +Socket address format(s) +------------------------ + +The native socket address format of the ``socket`` module is an opaque data type +returned by `getaddrinfo` function, which must be used to resolve textual address +(including numeric addresses):: + + sockaddr = socket.getaddrinfo('www.micropython.org', 80)[0][-1] + # You must use getaddrinfo() even for numeric addresses + sockaddr = socket.getaddrinfo('127.0.0.1', 80)[0][-1] + # Now you can use that address + sock.connect(sockaddr) + +Using `getaddrinfo` is the most efficient (both in terms of memory and processing +power) and portable way to work with addresses. + +However, ``socket`` module (note the difference with native MicroPython +``socket`` module described here) provides CPython-compatible way to specify +addresses using tuples, as described below. Note that depending on a +:term:`MicroPython port`, ``socket`` module can be builtin or need to be +installed from `micropython-lib` (as in the case of :term:`MicroPython Unix port`), +and some ports still accept only numeric addresses in the tuple format, +and require to use `getaddrinfo` function to resolve domain names. + +Summing up: + +* Always use `getaddrinfo` when writing portable applications. +* Tuple addresses described below can be used as a shortcut for + quick hacks and interactive use, if your port supports them. + +Tuple address format for ``socket`` module: + +* IPv4: *(ipv4_address, port)*, where *ipv4_address* is a string with + dot-notation numeric IPv4 address, e.g. ``"8.8.8.8"``, and *port* is and + integer port number in the range 1-65535. Note the domain names are not + accepted as *ipv4_address*, they should be resolved first using + `socket.getaddrinfo()`. +* IPv6: *(ipv6_address, port, flowinfo, scopeid)*, where *ipv6_address* + is a string with colon-notation numeric IPv6 address, e.g. ``"2001:db8::1"``, + and *port* is an integer port number in the range 1-65535. *flowinfo* + must be 0. *scopeid* is the interface scope identifier for link-local + addresses. Note the domain names are not accepted as *ipv6_address*, + they should be resolved first using `socket.getaddrinfo()`. Availability + of IPv6 support depends on a :term:`MicroPython port`. + +--- +Module: 'socket' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Literal, Tuple, overload, Final +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf +from typing_extensions import Awaitable, TypeAlias, TypeVar + +SOCK_RAW: Final[int] = 3 +SOCK_STREAM: Final[int] = 1 +"""Socket types.""" +SOCK_DGRAM: Final[int] = 2 +"""Socket types.""" +MSG_PEEK: Final[int] = 1 +SO_REUSEADDR: Final[int] = 4 +SOL_SOCKET: Final[int] = 1 +SO_BROADCAST: Final[int] = 32 +TCP_NODELAY: Final[int] = 64 +AF_INET6: Final[int] = 10 +"""Address family types. Availability depends on a particular :term:`MicroPython port`.""" +IPPROTO_IP: Final[int] = 0 +AF_INET: Final[int] = 2 +"""Address family types. Availability depends on a particular :term:`MicroPython port`.""" +MSG_DONTWAIT: Final[int] = 2 +IP_DROP_MEMBERSHIP: Final[int] = 1025 +IPPROTO_TCP: Final[int] = 6 +"""\ +IP protocol numbers. Availability depends on a particular :term:`MicroPython port`. +Note that you don't need to specify these in a call to `socket.socket()`, +because `SOCK_STREAM` socket type automatically selects `IPPROTO_TCP`, and +`SOCK_DGRAM` - `IPPROTO_UDP`. Thus, the only real use of these constants +is as an argument to `setsockopt()`. +""" +IP_ADD_MEMBERSHIP: Final[int] = 1024 +IPPROTO_UDP: Incomplete +"""\ +IP protocol numbers. Availability depends on a particular :term:`MicroPython port`. +Note that you don't need to specify these in a call to `socket.socket()`, +because `SOCK_STREAM` socket type automatically selects `IPPROTO_TCP`, and +`SOCK_DGRAM` - `IPPROTO_UDP`. Thus, the only real use of these constants +is as an argument to `setsockopt()`. +""" +IPPROTO_SEC: Incomplete +"""Special protocol value to create SSL-compatible socket.""" +_Address: TypeAlias = tuple[str, int] | tuple[str, int, int, int] | str +Socket: TypeAlias = socket + +def reset(*args, **kwargs) -> Incomplete: ... +def print_pcbs(*args, **kwargs) -> Incomplete: ... +def getaddrinfo( + host: str, + port: int, + af: int = 0, + type: int = 0, + proto: int = 0, + flags: int = 0, + /, +) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int]]]: + """ + Translate the host/port argument into a sequence of 5-tuples that contain all the + necessary arguments for creating a socket connected to that service. Arguments + *af*, *type*, and *proto* (which have the same meaning as for the `socket()` function) + can be used to filter which kind of addresses are returned. If a parameter is not + specified or zero, all combinations of addresses can be returned (requiring + filtering on the user side). + + The resulting list of 5-tuples has the following structure:: + + (family, type, proto, canonname, sockaddr) + + The following example shows how to connect to a given url:: + + s = socket.socket() + # This assumes that if "type" is not specified, an address for + # SOCK_STREAM will be returned, which may be not true + s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1]) + + Recommended use of filtering params:: + + s = socket.socket() + # Guaranteed to return an address which can be connect'ed to for + # stream operation. + s.connect(socket.getaddrinfo('www.micropython.org', 80, 0, SOCK_STREAM)[0][-1]) + + Admonition:Difference to CPython + :class: attention + + CPython raises a ``socket.gaierror`` exception (`OSError` subclass) in case + of error in this function. MicroPython doesn't have ``socket.gaierror`` + and raises OSError directly. Note that error numbers of `getaddrinfo()` + form a separate namespace and may not match error numbers from + the :mod:`errno` module. To distinguish `getaddrinfo()` errors, they are + represented by negative numbers, whereas standard system errors are + positive numbers (error numbers are accessible using ``e.args[0]`` property + from an exception object). The use of negative values is a provisional + detail which may change in the future. + """ + ... + +def callback(*args, **kwargs) -> Incomplete: ... + +class socket: + """ + A unix like socket, for more information see module ``socket``'s description. + + The name, `Socket`, used for typing is not the same as the runtime name, `socket` (note lowercase `s`). + The reason for this difference is that the runtime uses `socket` as both a class name and as a method name and + this is not possible within code written entirely in Python and therefore not possible within typing code. + """ + def recvfrom(self, bufsize: int, /) -> Tuple: + """ + Receive data from the socket. The return value is a pair *(bytes, address)* where *bytes* is a + bytes object representing the data received and *address* is the address of the socket sending + the data. + + See the `recv` function for an explanation of the optional *flags* argument. + """ + ... + def recv(self, bufsize: int, /) -> bytes: + """ + Receive data from the socket. The return value is a bytes object representing the data + received. The maximum amount of data to be received at once is specified by bufsize. + + Most ports support the optional *flags* argument. Available *flags* are defined as constants + in the socket module and have the same meaning as in CPython. ``MSG_PEEK`` and ``MSG_DONTWAIT`` + are supported on all ports which accept the *flags* argument. + """ + ... + + @overload + def makefile(self, mode: Literal["rb", "wb", "rwb"] = "rb", buffering: int = 0, /) -> Socket: + """ + Return a file object associated with the socket. The exact returned type depends on the arguments + given to makefile(). The support is limited to binary modes only ('rb', 'wb', and 'rwb'). + CPython's arguments: *encoding*, *errors* and *newline* are not supported. + + Admonition:Difference to CPython + :class: attention + + As MicroPython doesn't support buffered streams, values of *buffering* + parameter is ignored and treated as if it was 0 (unbuffered). + + Admonition:Difference to CPython + :class: attention + + Closing the file object returned by makefile() WILL close the + original socket as well. + """ + + @overload + def makefile(self, mode: str, buffering: int = 0, /) -> Socket: + """ + Return a file object associated with the socket. The exact returned type depends on the arguments + given to makefile(). The support is limited to binary modes only ('rb', 'wb', and 'rwb'). + CPython's arguments: *encoding*, *errors* and *newline* are not supported. + + Admonition:Difference to CPython + :class: attention + + As MicroPython doesn't support buffered streams, values of *buffering* + parameter is ignored and treated as if it was 0 (unbuffered). + + Admonition:Difference to CPython + :class: attention + + Closing the file object returned by makefile() WILL close the + original socket as well. + """ + def listen(self, backlog: int = ..., /) -> None: + """ + Enable a server to accept connections. If *backlog* is specified, it must be at least 0 + (if it's lower, it will be set to 0); and specifies the number of unaccepted connections + that the system will allow before refusing new connections. If not specified, a default + reasonable value is chosen. + """ + ... + def settimeout(self, value: float | None, /) -> None: + """ + **Note**: Not every port supports this method, see below. + + Set a timeout on blocking socket operations. The value argument can be a nonnegative floating + point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations + will raise an `OSError` exception if the timeout period value has elapsed before the operation has + completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket + is put in blocking mode. + + Not every :term:`MicroPython port` supports this method. A more portable and + generic solution is to use `select.poll` object. This allows to wait on + multiple objects at the same time (and not just on sockets, but on generic + `stream` objects which support polling). Example:: + + # Instead of: + s.settimeout(1.0) # time in seconds + s.read(10) # may timeout + + # Use: + poller = select.poll() + poller.register(s, select.POLLIN) + res = poller.poll(1000) # time in milliseconds + if not res: + # s is still not ready for input, i.e. operation timed out + + Admonition:Difference to CPython + :class: attention + + CPython raises a ``socket.timeout`` exception in case of timeout, + which is an `OSError` subclass. MicroPython raises an OSError directly + instead. If you use ``except OSError:`` to catch the exception, + your code will work both in MicroPython and CPython. + """ + ... + def sendall(self, bytes: AnyReadableBuf, /) -> int: + """ + Send all data to the socket. The socket must be connected to a remote socket. + Unlike `send()`, this method will try to send all of data, by sending data + chunk by chunk consecutively. + + The behaviour of this method on non-blocking sockets is undefined. Due to this, + on MicroPython, it's recommended to use `write()` method instead, which + has the same "no short writes" policy for blocking sockets, and will return + number of bytes sent on non-blocking sockets. + """ + ... + def setsockopt(self, level: int, optname: int, value: AnyReadableBuf | int, /) -> None: + """ + Set the value of the given socket option. The needed symbolic constants are defined in the + socket module (SO_* etc.). The *value* can be an integer or a bytes-like object representing + a buffer. + """ + ... + def setblocking(self, value: bool, /) -> None: + """ + Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking, + else to blocking mode. + + This method is a shorthand for certain `settimeout()` calls: + + * ``sock.setblocking(True)`` is equivalent to ``sock.settimeout(None)`` + * ``sock.setblocking(False)`` is equivalent to ``sock.settimeout(0)`` + """ + ... + def sendto(self, bytes: AnyReadableBuf, address: _Address, /) -> None: + """ + Send data to the socket. The socket should not be connected to a remote socket, since the + destination socket is specified by *address*. + """ + ... + def readline(self) -> bytes: + """ + Read a line, ending in a newline character. + + Return value: the line read. + """ + ... + + @overload + def readinto(self, buf: AnyWritableBuf, /) -> int | None: + """ + Read bytes into the *buf*. If *nbytes* is specified then read at most + that many bytes. Otherwise, read at most *len(buf)* bytes. Just as + `read()`, this method follows "no short reads" policy. + + Return value: number of bytes read and stored into *buf*. + """ + + @overload + def readinto(self, buf: AnyWritableBuf, nbytes: int, /) -> int | None: + """ + Read bytes into the *buf*. If *nbytes* is specified then read at most + that many bytes. Otherwise, read at most *len(buf)* bytes. Just as + `read()`, this method follows "no short reads" policy. + + Return value: number of bytes read and stored into *buf*. + """ + + @overload + def read(self) -> bytes: + """ + Read up to size bytes from the socket. Return a bytes object. If *size* is not given, it + reads all data available from the socket until EOF; as such the method will not return until + the socket is closed. This function tries to read as much data as + requested (no "short reads"). This may be not possible with + non-blocking socket though, and then less data will be returned. + """ + + @overload + def read(self, size: int, /) -> bytes: + """ + Read up to size bytes from the socket. Return a bytes object. If *size* is not given, it + reads all data available from the socket until EOF; as such the method will not return until + the socket is closed. This function tries to read as much data as + requested (no "short reads"). This may be not possible with + non-blocking socket though, and then less data will be returned. + """ + def close(self) -> None: + """ + Mark the socket closed and release all resources. Once that happens, all future operations + on the socket object will fail. The remote end will receive EOF indication if + supported by protocol. + + Sockets are automatically closed when they are garbage-collected, but it is recommended + to `close()` them explicitly as soon you finished working with them. + """ + ... + def connect(self, address: _Address | bytes, /) -> None: + """ + Connect to a remote socket at *address*. + """ + ... + def send(self, bytes: AnyReadableBuf, /) -> int: + """ + Send data to the socket. The socket must be connected to a remote socket. + Returns number of bytes sent, which may be smaller than the length of data + ("short write"). + """ + ... + def bind(self, address: _Address | bytes, /) -> None: + """ + Bind the socket to *address*. The socket must not already be bound. + """ + ... + def accept(self) -> Tuple: + """ + Accept a connection. The socket must be bound to an address and listening for connections. + The return value is a pair (conn, address) where conn is a new socket object usable to send + and receive data on the connection, and address is the address bound to the socket on the + other end of the connection. + """ + ... + def write(self, buf: AnyReadableBuf, /) -> int: + """ + Write the buffer of bytes to the socket. This function will try to + write all data to a socket (no "short writes"). This may be not possible + with a non-blocking socket though, and returned value will be less than + the length of *buf*. + + Return value: number of bytes written. + """ + ... + def __init__( + self, + af: int = AF_INET, + type: int = SOCK_STREAM, + proto: int = IPPROTO_TCP, + /, + ) -> None: + """ + Create a new socket using the given address family, socket type and + protocol number. Note that specifying *proto* in most cases is not + required (and not recommended, as some MicroPython ports may omit + ``IPPROTO_*`` constants). Instead, *type* argument will select needed + protocol automatically:: + + # Create STREAM TCP socket + socket(AF_INET, SOCK_STREAM) + # Create DGRAM UDP socket + socket(AF_INET, SOCK_DGRAM) + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/time.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/time.pyi new file mode 100644 index 0000000000..c5a9c409e8 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/time.pyi @@ -0,0 +1,306 @@ +""" +Time related functions. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/time.html + +CPython module: :mod:`python:time` https://docs.python.org/3/library/time.html . + +The ``time`` module provides functions for getting the current time and date, +measuring time intervals, and for delays. + +**Time Epoch**: The unix, windows, webassembly, alif, mimxrt and rp2 ports +use the standard for POSIX systems epoch of 1970-01-01 00:00:00 UTC. +The other embedded ports use an epoch of 2000-01-01 00:00:00 UTC. +Epoch year may be determined with ``gmtime(0)[0]``. + +**Maintaining actual calendar date/time**: This requires a +Real Time Clock (RTC). On systems with underlying OS (including some +RTOS), an RTC may be implicit. Setting and maintaining actual calendar +time is responsibility of OS/RTOS and is done outside of MicroPython, +it just uses OS API to query date/time. On baremetal ports however +system time depends on ``machine.RTC()`` object. The current calendar time +may be set using ``machine.RTC().datetime(tuple)`` function, and maintained +by following means: + +* By a backup battery (which may be an additional, optional component for + a particular board). +* Using networked time protocol (requires setup by a port/user). +* Set manually by a user on each power-up (many boards then maintain + RTC time across hard resets, though some may require setting it again + in such case). + +If actual calendar time is not maintained with a system/MicroPython RTC, +functions below which require reference to current absolute time may +behave not as expected. + +--- +Module: 'time' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import _TimeTuple +from typing import Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_TicksMs: TypeAlias = int +_TicksUs: TypeAlias = int +_TicksCPU: TypeAlias = int +_Ticks = TypeVar("_Ticks", _TicksMs, _TicksUs, _TicksCPU, int) + +def ticks_diff(ticks1: _Ticks, ticks2: _Ticks, /) -> int: + """ + Measure ticks difference between values returned from `ticks_ms()`, `ticks_us()`, + or `ticks_cpu()` functions, as a signed value which may wrap around. + + The argument order is the same as for subtraction + operator, ``ticks_diff(ticks1, ticks2)`` has the same meaning as ``ticks1 - ticks2``. + However, values returned by `ticks_ms()`, etc. functions may wrap around, so + directly using subtraction on them will produce incorrect result. That is why + `ticks_diff()` is needed, it implements modular (or more specifically, ring) + arithmetic to produce correct result even for wrap-around values (as long as they not + too distant in between, see below). The function returns **signed** value in the range + [*-TICKS_PERIOD/2* .. *TICKS_PERIOD/2-1*] (that's a typical range definition for + two's-complement signed binary integers). If the result is negative, it means that + *ticks1* occurred earlier in time than *ticks2*. Otherwise, it means that + *ticks1* occurred after *ticks2*. This holds **only** if *ticks1* and *ticks2* + are apart from each other for no more than *TICKS_PERIOD/2-1* ticks. If that does + not hold, incorrect result will be returned. Specifically, if two tick values are + apart for *TICKS_PERIOD/2-1* ticks, that value will be returned by the function. + However, if *TICKS_PERIOD/2* of real-time ticks has passed between them, the + function will return *-TICKS_PERIOD/2* instead, i.e. result value will wrap around + to the negative range of possible values. + + Informal rationale of the constraints above: Suppose you are locked in a room with no + means to monitor passing of time except a standard 12-notch clock. Then if you look at + dial-plate now, and don't look again for another 13 hours (e.g., if you fall for a + long sleep), then once you finally look again, it may seem to you that only 1 hour + has passed. To avoid this mistake, just look at the clock regularly. Your application + should do the same. "Too long sleep" metaphor also maps directly to application + behaviour: don't let your application run any single task for too long. Run tasks + in steps, and do time-keeping in between. + + `ticks_diff()` is designed to accommodate various usage patterns, among them: + + * Polling with timeout. In this case, the order of events is known, and you will deal + only with positive results of `ticks_diff()`:: + + # Wait for GPIO pin to be asserted, but at most 500us + start = time.ticks_us() + while pin.value() == 0: + if time.ticks_diff(time.ticks_us(), start) > 500: + raise TimeoutError + + * Scheduling events. In this case, `ticks_diff()` result may be negative + if an event is overdue:: + + # This code snippet is not optimized + now = time.ticks_ms() + scheduled_time = task.scheduled_time() + if ticks_diff(scheduled_time, now) > 0: + print("Too early, let's nap") + sleep_ms(ticks_diff(scheduled_time, now)) + task.run() + elif ticks_diff(scheduled_time, now) == 0: + print("Right at time!") + task.run() + elif ticks_diff(scheduled_time, now) < 0: + print("Oops, running late, tell task to run faster!") + task.run(run_faster=true) + + Note: Do not pass `time()` values to `ticks_diff()`, you should use + normal mathematical operations on them. But note that `time()` may (and will) + also overflow. This is known as https://en.wikipedia.org/wiki/Year_2038_problem . + """ + ... + +def ticks_add(ticks: _Ticks, delta: int, /) -> _Ticks: + """ + Offset ticks value by a given number, which can be either positive or negative. + Given a *ticks* value, this function allows to calculate ticks value *delta* + ticks before or after it, following modular-arithmetic definition of tick values + (see `ticks_ms()` above). *ticks* parameter must be a direct result of call + to `ticks_ms()`, `ticks_us()`, or `ticks_cpu()` functions (or from previous + call to `ticks_add()`). However, *delta* can be an arbitrary integer number + or numeric expression. `ticks_add()` is useful for calculating deadlines for + events/tasks. (Note: you must use `ticks_diff()` function to work with + deadlines.) + + Examples:: + + # Find out what ticks value there was 100ms ago + print(ticks_add(time.ticks_ms(), -100)) + + # Calculate deadline for operation and test for it + deadline = ticks_add(time.ticks_ms(), 200) + while ticks_diff(deadline, time.ticks_ms()) > 0: + do_a_little_of_something() + + # Find out TICKS_MAX used by this port + print(ticks_add(0, -1)) + """ + ... + +def ticks_cpu() -> _TicksCPU: + """ + Similar to `ticks_ms()` and `ticks_us()`, but with the highest possible resolution + in the system. This is usually CPU clocks, and that's why the function is named that + way. But it doesn't have to be a CPU clock, some other timing source available in a + system (e.g. high-resolution timer) can be used instead. The exact timing unit + (resolution) of this function is not specified on ``time`` module level, but + documentation for a specific port may provide more specific information. This + function is intended for very fine benchmarking or very tight real-time loops. + Avoid using it in portable code. + + Availability: Not every port implements this function. + """ + ... + +def time() -> int: + """ + Returns the number of seconds, as an integer, since the Epoch, assuming that + underlying RTC is set and maintained as described above. If an RTC is not set, this + function returns number of seconds since a port-specific reference point in time (for + embedded boards without a battery-backed RTC, usually since power up or reset). If you + want to develop portable MicroPython application, you should not rely on this function + to provide higher than second precision. If you need higher precision, absolute + timestamps, use `time_ns()`. If relative times are acceptable then use the + `ticks_ms()` and `ticks_us()` functions. If you need calendar time, `gmtime()` or + `localtime()` without an argument is a better choice. + + Admonition:Difference to CPython + :class: attention + + In CPython, this function returns number of + seconds since Unix epoch, 1970-01-01 00:00 UTC, as a floating-point, + usually having microsecond precision. With MicroPython, only Unix port + uses the same Epoch, and if floating-point precision allows, + returns sub-second precision. Embedded hardware usually doesn't have + floating-point precision to represent both long time ranges and subsecond + precision, so they use integer value with second precision. Some embedded + hardware also lacks battery-powered RTC, so returns number of seconds + since last power-up or from other relative, hardware-specific point + (e.g. reset). + """ + ... + +def ticks_ms() -> int: + """ + Returns an increasing millisecond counter with an arbitrary reference point, that + wraps around after some value. + + The wrap-around value is not explicitly exposed, but we will + refer to it as *TICKS_MAX* to simplify discussion. Period of the values is + *TICKS_PERIOD = TICKS_MAX + 1*. *TICKS_PERIOD* is guaranteed to be a power of + two, but otherwise may differ from port to port. The same period value is used + for all of `ticks_ms()`, `ticks_us()`, `ticks_cpu()` functions (for + simplicity). Thus, these functions will return a value in range [*0* .. + *TICKS_MAX*], inclusive, total *TICKS_PERIOD* values. Note that only + non-negative values are used. For the most part, you should treat values returned + by these functions as opaque. The only operations available for them are + `ticks_diff()` and `ticks_add()` functions described below. + + Note: Performing standard mathematical operations (+, -) or relational + operators (<, <=, >, >=) directly on these value will lead to invalid + result. Performing mathematical operations and then passing their results + as arguments to `ticks_diff()` or `ticks_add()` will also lead to + invalid results from the latter functions. + """ + ... + +def ticks_us() -> _TicksUs: + """ + Just like `ticks_ms()` above, but in microseconds. + """ + ... + +def time_ns() -> int: + """ + Similar to `time()` but returns nanoseconds since the Epoch, as an integer (usually + a big integer, so will allocate on the heap). + """ + ... + +def localtime(secs: int | None = None, /) -> Tuple: + """ + Convert the time *secs* expressed in seconds since the Epoch (see above) into an + 8-tuple which contains: ``(year, month, mday, hour, minute, second, weekday, yearday)`` + If *secs* is not provided or None, then the current time from the RTC is used. + + The `gmtime()` function returns a date-time tuple in UTC, and `localtime()` returns a + date-time tuple in local time. + + The format of the entries in the 8-tuple are: + + * year includes the century (for example 2014). + * month is 1-12 + * mday is 1-31 + * hour is 0-23 + * minute is 0-59 + * second is 0-59 + * weekday is 0-6 for Mon-Sun + * yearday is 1-366 + """ + ... + +def sleep_us(us: int, /) -> None: + """ + Delay for given number of microseconds, should be positive or 0. + + This function attempts to provide an accurate delay of at least *us* + microseconds, but it may take longer if the system has other higher priority + processing to perform. + """ + ... + +def gmtime(secs: int | None = None, /) -> Tuple: + """ + Convert the time *secs* expressed in seconds since the Epoch (see above) into an + 8-tuple which contains: ``(year, month, mday, hour, minute, second, weekday, yearday)`` + If *secs* is not provided or None, then the current time from the RTC is used. + + The `gmtime()` function returns a date-time tuple in UTC, and `localtime()` returns a + date-time tuple in local time. + + The format of the entries in the 8-tuple are: + + * year includes the century (for example 2014). + * month is 1-12 + * mday is 1-31 + * hour is 0-23 + * minute is 0-59 + * second is 0-59 + * weekday is 0-6 for Mon-Sun + * yearday is 1-366 + """ + ... + +def sleep_ms(ms: int, /) -> None: + """ + Delay for given number of milliseconds, should be positive or 0. + + This function will delay for at least the given number of milliseconds, but + may take longer than that if other processing must take place, for example + interrupt handlers or other threads. Passing in 0 for *ms* will still allow + this other processing to occur. Use `sleep_us()` for more precise delays. + """ + ... + +def mktime(local_time: _TimeTuple, /) -> int: + """ + This is inverse function of localtime. It's argument is a full 8-tuple + which expresses a time as per localtime. It returns an integer which is + the number of seconds since the time epoch. + """ + ... + +def sleep(seconds: float, /) -> None: + """ + Sleep for the given number of seconds. Some boards may accept *seconds* as a + floating-point number to sleep for a fractional number of seconds. Note that + other boards may not accept a floating-point argument, for compatibility with + them use `sleep_ms()` and `sleep_us()` functions. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/tls.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/tls.pyi new file mode 100644 index 0000000000..ad252fcbe9 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/tls.pyi @@ -0,0 +1,26 @@ +""" +Module: 'tls' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +PROTOCOL_TLS_SERVER: Final[int] = 1 +PROTOCOL_DTLS_CLIENT: Final[int] = 2 +PROTOCOL_DTLS_SERVER: Final[int] = 3 +PROTOCOL_TLS_CLIENT: Final[int] = 0 +MBEDTLS_VERSION: Final[str] = "Mbed TLS 3.6.2" +CERT_NONE: Final[int] = 0 +CERT_OPTIONAL: Final[int] = 1 +CERT_REQUIRED: Final[int] = 2 + +class SSLContext: + def load_verify_locations(self, *args, **kwargs) -> Incomplete: ... + def set_ciphers(self, *args, **kwargs) -> Incomplete: ... + def wrap_socket(self, *args, **kwargs) -> Incomplete: ... + def load_cert_chain(self, *args, **kwargs) -> Incomplete: ... + def get_ciphers(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uarray.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uarray.pyi new file mode 100644 index 0000000000..e5c0fe438f --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uarray.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to array +from array import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uasyncio.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uasyncio.pyi new file mode 100644 index 0000000000..3d69c52f24 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uasyncio.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to asyncio +from asyncio import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ubinascii.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ubinascii.pyi new file mode 100644 index 0000000000..3a77380ad5 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ubinascii.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to binascii +from binascii import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ubluetooth.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ubluetooth.pyi new file mode 100644 index 0000000000..4046c2c755 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ubluetooth.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to bluetooth +from bluetooth import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ucollections.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ucollections.pyi new file mode 100644 index 0000000000..a47ef8e6bb --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ucollections.pyi @@ -0,0 +1,15 @@ +""" +Collection and container types. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/collections.html + +CPython module: :mod:`python:collections` https://docs.python.org/3/library/collections.html . + +This module implements advanced collection and container types to +hold/accumulate various objects. + +--- +Module: 'ucollections' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# import module from stdlib/module +from collections import * \ No newline at end of file diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ucryptolib.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ucryptolib.pyi new file mode 100644 index 0000000000..6b8b56a685 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ucryptolib.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to cryptolib +from cryptolib import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uctypes.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uctypes.pyi new file mode 100644 index 0000000000..ba2458b265 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uctypes.pyi @@ -0,0 +1,164 @@ +""" +Access binary data in a structured way. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/uctypes.html + +This module implements "foreign data interface" for MicroPython. The idea +behind it is similar to CPython's ``ctypes`` modules, but the actual API is +different, streamlined and optimized for small size. The basic idea of the +module is to define data structure layout with about the same power as the +C language allows, and then access it using familiar dot-syntax to reference +sub-fields. + +--- +Module: 'uctypes' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Dict, Tuple, Any, Final, Generator +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf, mp_available +from typing_extensions import Awaitable, TypeAlias, TypeVar + +VOID: Final[int] = 0 +"""\ +``VOID`` is an alias for ``UINT8``, and is provided to conveniently define +C's void pointers: ``(uctypes.PTR, uctypes.VOID)``. +""" +NATIVE: Final[int] = 2 +"""\ +Layout type for a native structure - with data endianness and alignment +conforming to the ABI of the system on which MicroPython runs. +""" +PTR: Final[int] = 536870912 +"""\ +Type constants for pointers and arrays. Note that there is no explicit +constant for structures, it's implicit: an aggregate type without ``PTR`` +or ``ARRAY`` flags is a structure. +""" +SHORT: Final[int] = 402653184 +LONGLONG: Final[int] = 939524096 +INT8: Final[int] = 134217728 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +LITTLE_ENDIAN: Final[int] = 0 +"""\ +Layout type for a little-endian packed structure. (Packed means that every +field occupies exactly as many bytes as defined in the descriptor, i.e. +the alignment is 1). +""" +LONG: Final[int] = 671088640 +UINT: Final[int] = 536870912 +ULONG: Final[int] = 536870912 +ULONGLONG: Final[int] = 805306368 +USHORT: Final[int] = 268435456 +UINT8: Final[int] = 0 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +UINT16: Final[int] = 268435456 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +UINT32: Final[int] = 536870912 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +UINT64: Final[int] = 805306368 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +INT64: Final[int] = 939524096 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +BFUINT16: Final[int] = -805306368 +BFUINT32: Final[int] = -536870912 +BFUINT8: Final[int] = -1073741824 +BFINT8: Final[int] = -939524096 +ARRAY: Final[int] = -1073741824 +"""\ +Type constants for pointers and arrays. Note that there is no explicit +constant for structures, it's implicit: an aggregate type without ``PTR`` +or ``ARRAY`` flags is a structure. +""" +BFINT16: Final[int] = -671088640 +BFINT32: Final[int] = -402653184 +BF_LEN: Final[int] = 22 +INT: Final[int] = 671088640 +INT16: Final[int] = 402653184 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +INT32: Final[int] = 671088640 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +FLOAT64: Final[int] = -134217728 +"""Floating-point types for structure descriptors.""" +BF_POS: Final[int] = 17 +BIG_ENDIAN: Final[int] = 1 +"""Layout type for a big-endian packed structure.""" +FLOAT32: Final[int] = -268435456 +"""Floating-point types for structure descriptors.""" +_property: TypeAlias = Incomplete +_descriptor: TypeAlias = Tuple | Dict + +def sizeof(struct: struct | _descriptor | dict, layout_type: int = NATIVE, /) -> int: + """ + Return size of data structure in bytes. The *struct* argument can be + either a structure class or a specific instantiated structure object + (or its aggregate field). + """ + ... + +def bytes_at(addr: int, size: int, /) -> bytes: + """ + Capture memory at the given address and size as bytes object. As bytes + object is immutable, memory is actually duplicated and copied into + bytes object, so if memory contents change later, created object + retains original value. + """ + ... + +def bytearray_at(addr: int, size: int, /) -> bytearray: + """ + Capture memory at the given address and size as bytearray object. + Unlike bytes_at() function above, memory is captured by reference, + so it can be both written too, and you will access current value + at the given memory address. + """ + ... + +def addressof(obj: AnyReadableBuf, /) -> int: + """ + Return address of an object. Argument should be bytes, bytearray or + other object supporting buffer protocol (and address of this buffer + is what actually returned). + """ + ... + +class struct: + """ + Module contents + --------------- + """ + def __init__(self, addr: int | struct, descriptor: _descriptor, layout_type: int = NATIVE, /) -> None: + """ + Instantiate a "foreign data structure" object based on structure address in + memory, descriptor (encoded as a dictionary), and layout type (see below). + """ + ... + @mp_available() # force push + def __getattr__(self, a): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uerrno.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uerrno.pyi new file mode 100644 index 0000000000..8d34ba6b73 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uerrno.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to errno +from errno import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uhashlib.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uhashlib.pyi new file mode 100644 index 0000000000..8b4b7bc778 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uhashlib.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to hashlib +from hashlib import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uheapq.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uheapq.pyi new file mode 100644 index 0000000000..71c066fcf4 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uheapq.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to heapq +from heapq import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uio.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uio.pyi new file mode 100644 index 0000000000..514a4f945d --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uio.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to io +from io import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ujson.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ujson.pyi new file mode 100644 index 0000000000..0de669254d --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ujson.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to json +from json import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/umachine.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/umachine.pyi new file mode 100644 index 0000000000..e1fdb35a46 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/umachine.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to machine +from machine import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uos.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uos.pyi new file mode 100644 index 0000000000..8c99e764b0 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uos.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to os +from os import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uplatform.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uplatform.pyi new file mode 100644 index 0000000000..22ad247bf6 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uplatform.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to platform +from platform import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/urandom.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/urandom.pyi new file mode 100644 index 0000000000..b912f07931 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/urandom.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to random +from random import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ure.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ure.pyi new file mode 100644 index 0000000000..dbe8b6a52c --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ure.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to re +from re import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/urequests.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/urequests.pyi new file mode 100644 index 0000000000..d53bcfbeb1 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/urequests.pyi @@ -0,0 +1 @@ +def __getattr__(attr): ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uselect.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uselect.pyi new file mode 100644 index 0000000000..a543041c4d --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uselect.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to select +from select import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/usocket.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/usocket.pyi new file mode 100644 index 0000000000..140590c295 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/usocket.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to socket +from socket import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ussl.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ussl.pyi new file mode 100644 index 0000000000..3115761c4b --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ussl.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to ssl +from ssl import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ustruct.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ustruct.pyi new file mode 100644 index 0000000000..0f7fb657af --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/ustruct.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to struct +from struct import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/usys.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/usys.pyi new file mode 100644 index 0000000000..298d7a8ac3 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/usys.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to sys +from sys import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/utime.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/utime.pyi new file mode 100644 index 0000000000..1f972a5b62 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/utime.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to time +from time import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uwebsocket.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uwebsocket.pyi new file mode 100644 index 0000000000..afa801ba21 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uwebsocket.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to websocket +from websocket import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uzlib.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uzlib.pyi new file mode 100644 index 0000000000..5fad9a23c9 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/uzlib.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to zlib +from zlib import * diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/vfs.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/vfs.pyi new file mode 100644 index 0000000000..f24ae6eb51 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/vfs.pyi @@ -0,0 +1,240 @@ +""" +Virtual filesystem control. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/vfs.html + +The ``vfs`` module contains functions for creating filesystem objects and +mounting/unmounting them in the Virtual Filesystem. + +Filesystem mounting +------------------- + +Some ports provide a Virtual Filesystem (VFS) and the ability to mount multiple +"real" filesystems within this VFS. Filesystem objects can be mounted at either +the root of the VFS, or at a subdirectory that lives in the root. This allows +dynamic and flexible configuration of the filesystem that is seen by Python +programs. Ports that have this functionality provide the :func:`mount` and +:func:`umount` functions, and possibly various filesystem implementations +represented by VFS classes. + +--- +Module: 'vfs' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import _BlockDeviceProtocol +from abc import ABC, abstractmethod +from typing import List, overload +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def umount(mount_point: Incomplete) -> Incomplete: + """ + Unmount a filesystem. *mount_point* can be a string naming the mount location, + or a previously-mounted filesystem object. During the unmount process the + method ``umount()`` is called on the filesystem object. + + Will raise ``OSError(EINVAL)`` if *mount_point* is not found. + """ + ... + +@overload +def mount(fsobj, mount_point: str, *, readonly: bool = False) -> None: + """ + :noindex: + + With no arguments to :func:`mount`, return a list of tuples representing + all active mountpoints. + + The returned list has the form *[(fsobj, mount_point), ...]*. + """ + ... + +@overload +def mount() -> List[tuple[Incomplete, str]]: + """ + :noindex: + + With no arguments to :func:`mount`, return a list of tuples representing + all active mountpoints. + + The returned list has the form *[(fsobj, mount_point), ...]*. + """ + ... + +class VfsLfs2: + """ + Create a filesystem object that uses the `littlefs v2 filesystem format`_. + Storage of the littlefs filesystem is provided by *block_dev*, which must + support the :ref:`extended interface `. + Objects created by this constructor can be mounted using :func:`mount`. + + The *mtime* argument enables modification timestamps for files, stored using + littlefs attributes. This option can be disabled or enabled differently each + mount time and timestamps will only be added or updated if *mtime* is enabled, + otherwise the timestamps will remain untouched. Littlefs v2 filesystems without + timestamps will work without reformatting and timestamps will be added + transparently to existing files once they are opened for writing. When *mtime* + is enabled `os.stat` on files without timestamps will return 0 for the timestamp. + + See :ref:`filesystem` for more information. + """ + def rename(self, *args, **kwargs) -> Incomplete: ... + @staticmethod + def mkfs(block_dev: AbstractBlockDev, readsize=32, progsize=32, lookahead=32) -> None: + """ + Build a Lfs2 filesystem on *block_dev*. + + ``Note:`` There are reports of littlefs v2 failing in certain situations, + for details see `littlefs issue 295`_. + """ + ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, block_dev: AbstractBlockDev, readsize=32, progsize=32, lookahead=32, mtime=True) -> None: ... + +class VfsFat: + """ + Create a filesystem object that uses the FAT filesystem format. Storage of + the FAT filesystem is provided by *block_dev*. + Objects created by this constructor can be mounted using :func:`mount`. + """ + def rename(self, *args, **kwargs) -> Incomplete: ... + @staticmethod + def mkfs(block_dev: AbstractBlockDev) -> None: + """ + Build a FAT filesystem on *block_dev*. + """ + ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, block_dev: AbstractBlockDev) -> None: ... + +class AbstractBlockDev: + # + @abstractmethod + @overload + def readblocks(self, block_num: int, buf: bytearray) -> bool: ... + @abstractmethod + @overload + def readblocks(self, block_num: int, buf: bytearray, offset: int) -> bool: + """ + The first form reads aligned, multiples of blocks. + Starting at the block given by the index *block_num*, read blocks from + the device into *buf* (an array of bytes). + The number of blocks to read is given by the length of *buf*, + which will be a multiple of the block size. + + The second form allows reading at arbitrary locations within a block, + and arbitrary lengths. + Starting at block index *block_num*, and byte offset within that block + of *offset*, read bytes from the device into *buf* (an array of bytes). + The number of bytes to read is given by the length of *buf*. + """ + ... + + @abstractmethod + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, /) -> None: + """ + The first form writes aligned, multiples of blocks, and requires that the + blocks that are written to be first erased (if necessary) by this method. + Starting at the block given by the index *block_num*, write blocks from + *buf* (an array of bytes) to the device. + The number of blocks to write is given by the length of *buf*, + which will be a multiple of the block size. + + The second form allows writing at arbitrary locations within a block, + and arbitrary lengths. Only the bytes being written should be changed, + and the caller of this method must ensure that the relevant blocks are + erased via a prior ``ioctl`` call. + Starting at block index *block_num*, and byte offset within that block + of *offset*, write bytes from *buf* (an array of bytes) to the device. + The number of bytes to write is given by the length of *buf*. + + Note that implementations must never implicitly erase blocks if the offset + argument is specified, even if it is zero. + """ + + @abstractmethod + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, offset: int, /) -> None: + """ + The first form writes aligned, multiples of blocks, and requires that the + blocks that are written to be first erased (if necessary) by this method. + Starting at the block given by the index *block_num*, write blocks from + *buf* (an array of bytes) to the device. + The number of blocks to write is given by the length of *buf*, + which will be a multiple of the block size. + + The second form allows writing at arbitrary locations within a block, + and arbitrary lengths. Only the bytes being written should be changed, + and the caller of this method must ensure that the relevant blocks are + erased via a prior ``ioctl`` call. + Starting at block index *block_num*, and byte offset within that block + of *offset*, write bytes from *buf* (an array of bytes) to the device. + The number of bytes to write is given by the length of *buf*. + + Note that implementations must never implicitly erase blocks if the offset + argument is specified, even if it is zero. + """ + ... + + @abstractmethod + @overload + def ioctl(self, op: int, arg) -> int | None: ... + # + @abstractmethod + @overload + def ioctl(self, op: int) -> int | None: + """ + Control the block device and query its parameters. The operation to + perform is given by *op* which is one of the following integers: + + - 1 -- initialise the device (*arg* is unused) + - 2 -- shutdown the device (*arg* is unused) + - 3 -- sync the device (*arg* is unused) + - 4 -- get a count of the number of blocks, should return an integer + (*arg* is unused) + - 5 -- get the number of bytes in a block, should return an integer, + or ``None`` in which case the default value of 512 is used + (*arg* is unused) + - 6 -- erase a block, *arg* is the block number to erase + + As a minimum ``ioctl(4, ...)`` must be intercepted; for littlefs + ``ioctl(6, ...)`` must also be intercepted. The need for others is + hardware dependent. + + Prior to any call to ``writeblocks(block, ...)`` littlefs issues + ``ioctl(6, block)``. This enables a device driver to erase the block + prior to a write if the hardware requires it. Alternatively a driver + might intercept ``ioctl(6, block)`` and return 0 (success). In this case + the driver assumes responsibility for detecting the need for erasure. + + Unless otherwise stated ``ioctl(op, arg)`` can return ``None``. + Consequently an implementation can ignore unused values of ``op``. Where + ``op`` is intercepted, the return value for operations 4 and 5 are as + detailed above. Other operations should return 0 on success and non-zero + for failure, with the value returned being an ``OSError`` errno code. + """ + ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/webrepl.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/webrepl.pyi new file mode 100644 index 0000000000..92c4ed832c --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/webrepl.pyi @@ -0,0 +1,16 @@ +from _typeshed import Incomplete +from micropython import const as const + +listen_s: Incomplete +client_s: Incomplete +DEBUG: int +_DEFAULT_STATIC_HOST: str +static_host = _DEFAULT_STATIC_HOST + +def server_handshake(cl): ... +def send_html(cl) -> None: ... +def setup_conn(port, accept_handler): ... +def accept_conn(listen_sock): ... +def stop() -> None: ... +def start(port: int = 8266, password=None, accept_handler=...) -> None: ... +def start_foreground(port: int = 8266, password=None) -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/webrepl_setup.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/webrepl_setup.pyi new file mode 100644 index 0000000000..4fb5ba7854 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/webrepl_setup.pyi @@ -0,0 +1,10 @@ +RC: str +CONFIG: str + +def input_choice(prompt, choices): ... +def getpass(prompt): ... +def input_pass(): ... +def exists(fname): ... +def get_daemon_status(): ... +def change_daemon(action) -> None: ... +def main() -> None: ... diff --git a/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/websocket.pyi b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/websocket.pyi new file mode 100644 index 0000000000..393cea0558 --- /dev/null +++ b/publish/micropython-v1_27_0-rp2-rpi_pico_w-stubs/websocket.pyi @@ -0,0 +1,17 @@ +""" +Module: 'websocket' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +class websocket: + def readline(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_boot_fat.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_boot_fat.pyi new file mode 100644 index 0000000000..ec0077130a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_boot_fat.pyi @@ -0,0 +1,8 @@ +""" +Module: '_boot_fat' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_onewire.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_onewire.pyi new file mode 100644 index 0000000000..49f6f067b2 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_onewire.pyi @@ -0,0 +1,15 @@ +""" +Module: '_onewire' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def reset(*args, **kwargs) -> Incomplete: ... +def writebyte(*args, **kwargs) -> Incomplete: ... +def writebit(*args, **kwargs) -> Incomplete: ... +def crc8(*args, **kwargs) -> Incomplete: ... +def readbyte(*args, **kwargs) -> Incomplete: ... +def readbit(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_thread.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_thread.pyi new file mode 100644 index 0000000000..de3c141663 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/_thread.pyi @@ -0,0 +1,33 @@ +""" +Multithreading support. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/_thread.html + +CPython module: :mod:`python:_thread` https://docs.python.org/3/library/_thread.html . + +This module implements multithreading support. + +This module is highly experimental and its API is not yet fully settled +and not yet described in this documentation. + +--- +Module: '_thread' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def get_ident(*args, **kwargs) -> Incomplete: ... +def start_new_thread(*args, **kwargs) -> Incomplete: ... +def stack_size(*args, **kwargs) -> Incomplete: ... +def exit(*args, **kwargs) -> Incomplete: ... +def allocate_lock(*args, **kwargs) -> Incomplete: ... + +class LockType: + def locked(self, *args, **kwargs) -> Incomplete: ... + def release(self, *args, **kwargs) -> Incomplete: ... + def acquire(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/__init__.pyi new file mode 100644 index 0000000000..8bb449317b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/__init__.pyi @@ -0,0 +1,191 @@ +""" +Module: 'aioble.__init__' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final, Generator +from _typeshed import Incomplete + +ADDR_PUBLIC: Final[int] = 0 +ADDR_RANDOM: Final[int] = 1 +def log_warn(*args, **kwargs) -> Incomplete: + ... + +def log_info(*args, **kwargs) -> Incomplete: + ... + +def log_error(*args, **kwargs) -> Incomplete: + ... + +def register_services(*args, **kwargs) -> Incomplete: + ... + +def stop(*args, **kwargs) -> Incomplete: + ... + +def config(*args, **kwargs) -> Incomplete: + ... + +def const(*args, **kwargs) -> Incomplete: + ... + + +class Service(): + def _tuple(self, *args, **kwargs) -> Incomplete: + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class scan(): + def cancel(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + +def advertise(*args, **kwargs) -> Generator: ## = + ... + + +class Characteristic(): + def _remote_write(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_read(self, *args, **kwargs) -> Incomplete: + ... + + def notify(self, *args, **kwargs) -> Incomplete: + ... + + def on_read(self, *args, **kwargs) -> Incomplete: + ... + + def _tuple(self, *args, **kwargs) -> Incomplete: + ... + + def write(self, *args, **kwargs) -> Incomplete: + ... + + def read(self, *args, **kwargs) -> Incomplete: + ... + + def _register(self, *args, **kwargs) -> Incomplete: + ... + + def _indicate_done(self, *args, **kwargs) -> Incomplete: + ... + + def _init_capture(self, *args, **kwargs) -> Incomplete: + ... + + def written(*args, **kwargs) -> Generator: ## = + ... + + def indicate(*args, **kwargs) -> Generator: ## = + ... + + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class GattError(Exception): + ... + +class BufferedCharacteristic(): + def on_read(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_read(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_write(self, *args, **kwargs) -> Incomplete: + ... + + def notify(self, *args, **kwargs) -> Incomplete: + ... + + def _tuple(self, *args, **kwargs) -> Incomplete: + ... + + def _init_capture(self, *args, **kwargs) -> Incomplete: + ... + + def read(self, *args, **kwargs) -> Incomplete: + ... + + def write(self, *args, **kwargs) -> Incomplete: + ... + + def _indicate_done(self, *args, **kwargs) -> Incomplete: + ... + + def written(*args, **kwargs) -> Generator: ## = + ... + + def _register(self, *args, **kwargs) -> Incomplete: + ... + + def indicate(*args, **kwargs) -> Generator: ## = + ... + + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class DeviceDisconnectedError(Exception): + ... + +class Descriptor(): + def _tuple(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_read(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_write(self, *args, **kwargs) -> Incomplete: + ... + + def on_read(self, *args, **kwargs) -> Incomplete: + ... + + def _register(self, *args, **kwargs) -> Incomplete: + ... + + def read(self, *args, **kwargs) -> Incomplete: + ... + + def write(self, *args, **kwargs) -> Incomplete: + ... + + def _init_capture(self, *args, **kwargs) -> Incomplete: + ... + + def written(*args, **kwargs) -> Generator: ## = + ... + + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class Device(): + def addr_hex(self, *args, **kwargs) -> Incomplete: + ... + + def connect(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/central.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/central.pyi new file mode 100644 index 0000000000..9a0b64ced4 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/central.pyi @@ -0,0 +1,81 @@ +""" +Module: 'aioble.central' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def _central_shutdown(*args, **kwargs) -> Incomplete: ... +def ensure_active(*args, **kwargs) -> Incomplete: ... +def _central_irq(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +ble: Incomplete ## = + +class DeviceTimeout: + def _timeout_sleep(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class scan: + def cancel(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +_active_scanner: Incomplete ## = None + +def _cancel_pending(*args, **kwargs) -> Generator: ## = + ... + +class ScanResult: + def _update(self, *args, **kwargs) -> Incomplete: ... + def name(self, *args, **kwargs) -> Incomplete: ... + def manufacturer(*args, **kwargs) -> Generator: ## = + ... + def services(*args, **kwargs) -> Generator: ## = + ... + def _decode_field(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +_connecting: set ## = set() + +def _connect(*args, **kwargs) -> Generator: ## = + ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Device: + def addr_hex(self, *args, **kwargs) -> Incomplete: ... + def connect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/client.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/client.pyi new file mode 100644 index 0000000000..f99ed6286e --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/client.pyi @@ -0,0 +1,120 @@ +""" +Module: 'aioble.client' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def _client_irq(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class GattError(Exception): ... + +class ClientService: + def characteristics(self, *args, **kwargs) -> Incomplete: ... + def _start_discovery(self, *args, **kwargs) -> Incomplete: ... + def characteristic(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = + +class ClientDiscover: + def _discover_result(self, *args, **kwargs) -> Incomplete: ... + def _discover_done(self, *args, **kwargs) -> Incomplete: ... + def _start(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class deque: + def pop(self, *args, **kwargs) -> Incomplete: ... + def appendleft(self, *args, **kwargs) -> Incomplete: ... + def popleft(self, *args, **kwargs) -> Incomplete: ... + def extend(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class ClientDescriptor: + def _read_result(self, *args, **kwargs) -> Incomplete: ... + def _read_done(self, *args, **kwargs) -> Incomplete: ... + def _write_done(self, *args, **kwargs) -> Incomplete: ... + def _register_with_connection(self, *args, **kwargs) -> Incomplete: ... + def _start_discovery(self, *args, **kwargs) -> Incomplete: ... + def _check(self, *args, **kwargs) -> Incomplete: ... + def _find(self, *args, **kwargs) -> Incomplete: ... + def _connection(self, *args, **kwargs) -> Incomplete: ... + def write(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class BaseClientCharacteristic: + def _write_done(self, *args, **kwargs) -> Incomplete: ... + def _read_done(self, *args, **kwargs) -> Incomplete: ... + def _read_result(self, *args, **kwargs) -> Incomplete: ... + def _register_with_connection(self, *args, **kwargs) -> Incomplete: ... + def _find(self, *args, **kwargs) -> Incomplete: ... + def _check(self, *args, **kwargs) -> Incomplete: ... + def write(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class ClientCharacteristic: + def _on_notify(self, *args, **kwargs) -> Incomplete: ... + def _register_with_connection(self, *args, **kwargs) -> Incomplete: ... + def _on_indicate(self, *args, **kwargs) -> Incomplete: ... + def _read_result(self, *args, **kwargs) -> Incomplete: ... + def _on_notify_indicate(self, *args, **kwargs) -> Incomplete: ... + def _read_done(self, *args, **kwargs) -> Incomplete: ... + def _start_discovery(self, *args, **kwargs) -> Incomplete: ... + def descriptors(self, *args, **kwargs) -> Incomplete: ... + def _write_done(self, *args, **kwargs) -> Incomplete: ... + def _find(self, *args, **kwargs) -> Incomplete: ... + def _check(self, *args, **kwargs) -> Incomplete: ... + def _connection(self, *args, **kwargs) -> Incomplete: ... + def subscribe(*args, **kwargs) -> Generator: ## = + ... + def indicated(*args, **kwargs) -> Generator: ## = + ... + def notified(*args, **kwargs) -> Generator: ## = + ... + def descriptor(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def write(*args, **kwargs) -> Generator: ## = + ... + def _notified_indicated(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/core.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/core.pyi new file mode 100644 index 0000000000..63e8f67337 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/core.pyi @@ -0,0 +1,25 @@ +""" +Module: 'aioble.core' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +_irq_handlers: list = [] +_shutdown_handlers: list = [] +log_level: int = 1 + +def ensure_active(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def config(*args, **kwargs) -> Incomplete: ... +def stop(*args, **kwargs) -> Incomplete: ... +def ble_irq(*args, **kwargs) -> Incomplete: ... + +ble: Incomplete ## = + +class GattError(Exception): ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/device.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/device.pyi new file mode 100644 index 0000000000..c668bd281d --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/device.pyi @@ -0,0 +1,53 @@ +""" +Module: 'aioble.device' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def _device_irq(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class Device: + def addr_hex(self, *args, **kwargs) -> Incomplete: ... + def connect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DeviceDisconnectedError(Exception): ... + +class DeviceTimeout: + def _timeout_sleep(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/l2cap.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/l2cap.pyi new file mode 100644 index 0000000000..d2ba328348 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/l2cap.pyi @@ -0,0 +1,66 @@ +""" +Module: 'aioble.l2cap' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +_listening: bool = False + +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def _l2cap_irq(*args, **kwargs) -> Incomplete: ... +def _l2cap_shutdown(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... +def accept(*args, **kwargs) -> Generator: ## = + ... + +ble: Incomplete ## = + +class L2CAPChannel: + def available(self, *args, **kwargs) -> Incomplete: ... + def _assert_connected(self, *args, **kwargs) -> Incomplete: ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def recvinto(*args, **kwargs) -> Generator: ## = + ... + def send(*args, **kwargs) -> Generator: ## = + ... + def flush(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +def connect(*args, **kwargs) -> Generator: ## = + ... + +class L2CAPConnectionError(Exception): ... +class L2CAPDisconnectedError(Exception): ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/peripheral.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/peripheral.pyi new file mode 100644 index 0000000000..dc36a2087c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/peripheral.pyi @@ -0,0 +1,62 @@ +""" +Module: 'aioble.peripheral' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def _peripheral_shutdown(*args, **kwargs) -> Incomplete: ... +def ensure_active(*args, **kwargs) -> Incomplete: ... +def _peripheral_irq(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def _append(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class Device: + def addr_hex(self, *args, **kwargs) -> Incomplete: ... + def connect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +_incoming_connection: Incomplete ## = None +_connect_event: Incomplete ## = None + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DeviceTimeout: + def _timeout_sleep(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = + +def advertise(*args, **kwargs) -> Generator: ## = + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/security.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/security.pyi new file mode 100644 index 0000000000..3164987ab6 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/security.pyi @@ -0,0 +1,54 @@ +""" +Module: 'aioble.security' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final, Generator +from _typeshed import Incomplete + +_modified: bool = False +_DEFAULT_PATH: Final[str] = "ble_secrets.json" +_secrets: dict = {} + +def _security_irq(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def _security_shutdown(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def load_secrets(*args, **kwargs) -> Incomplete: ... +def schedule(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... +def _save_secrets(*args, **kwargs) -> Incomplete: ... + +_path: Incomplete ## = None + +def pair(*args, **kwargs) -> Generator: ## = + ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/server.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/server.pyi new file mode 100644 index 0000000000..bca231a3b1 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/aioble/server.pyi @@ -0,0 +1,133 @@ +""" +Module: 'aioble.server' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +_registered_characteristics: dict = {} + +def _server_shutdown(*args, **kwargs) -> Incomplete: ... +def ensure_active(*args, **kwargs) -> Incomplete: ... +def _server_irq(*args, **kwargs) -> Incomplete: ... +def register_services(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class BaseCharacteristic: + def _remote_read(self, *args, **kwargs) -> Incomplete: ... + def _register(self, *args, **kwargs) -> Incomplete: ... + def _remote_write(self, *args, **kwargs) -> Incomplete: ... + def on_read(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def _init_capture(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def written(*args, **kwargs) -> Generator: ## = + ... + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class BufferedCharacteristic: + def on_read(self, *args, **kwargs) -> Incomplete: ... + def _remote_read(self, *args, **kwargs) -> Incomplete: ... + def _remote_write(self, *args, **kwargs) -> Incomplete: ... + def notify(self, *args, **kwargs) -> Incomplete: ... + def _tuple(self, *args, **kwargs) -> Incomplete: ... + def _init_capture(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def _indicate_done(self, *args, **kwargs) -> Incomplete: ... + def written(*args, **kwargs) -> Generator: ## = + ... + def _register(self, *args, **kwargs) -> Incomplete: ... + def indicate(*args, **kwargs) -> Generator: ## = + ... + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = + +class deque: + def pop(self, *args, **kwargs) -> Incomplete: ... + def appendleft(self, *args, **kwargs) -> Incomplete: ... + def popleft(self, *args, **kwargs) -> Incomplete: ... + def extend(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DeviceTimeout: + def _timeout_sleep(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Service: + def _tuple(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class GattError(Exception): ... + +class Characteristic: + def _remote_write(self, *args, **kwargs) -> Incomplete: ... + def _remote_read(self, *args, **kwargs) -> Incomplete: ... + def notify(self, *args, **kwargs) -> Incomplete: ... + def on_read(self, *args, **kwargs) -> Incomplete: ... + def _tuple(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def _register(self, *args, **kwargs) -> Incomplete: ... + def _indicate_done(self, *args, **kwargs) -> Incomplete: ... + def _init_capture(self, *args, **kwargs) -> Incomplete: ... + def written(*args, **kwargs) -> Generator: ## = + ... + def indicate(*args, **kwargs) -> Generator: ## = + ... + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Descriptor: + def _tuple(self, *args, **kwargs) -> Incomplete: ... + def _remote_read(self, *args, **kwargs) -> Incomplete: ... + def _remote_write(self, *args, **kwargs) -> Incomplete: ... + def on_read(self, *args, **kwargs) -> Incomplete: ... + def _register(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def _init_capture(self, *args, **kwargs) -> Incomplete: ... + def written(*args, **kwargs) -> Generator: ## = + ... + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/binascii.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/binascii.pyi new file mode 100644 index 0000000000..37fbee885b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/binascii.pyi @@ -0,0 +1,61 @@ +""" +Binary/ASCII conversions. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/binascii.html + +CPython module: :mod:`python:binascii` https://docs.python.org/3/library/binascii.html . + +This module implements conversions between binary data and various +encodings of it in ASCII form (in both directions). + +--- +Module: 'binascii' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import Any, Optional +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def crc32(data, value: Optional[Any] = None) -> Incomplete: + """ + Compute CRC-32, the 32-bit checksum of *data*, starting with an initial CRC + of *value*. The default initial CRC is zero. The algorithm is consistent + with the ZIP file checksum. + """ + ... + +def hexlify(data: bytes, sep: str | bytes = ..., /) -> bytes: + """ + Convert the bytes in the *data* object to a hexadecimal representation. + Returns a bytes object. + + If the additional argument *sep* is supplied it is used as a separator + between hexadecimal values. + """ + ... + +def unhexlify(data: str | bytes, /) -> bytes: + """ + Convert hexadecimal data to binary representation. Returns bytes string. + (i.e. inverse of hexlify) + """ + ... + +def b2a_base64(data: bytes, /) -> bytes: + """ + Encode binary data in base64 format, as in `RFC 3548 + `_. Returns the encoded data + followed by a newline character if newline is true, as a bytes object. + """ + ... + +def a2b_base64(data: str | bytes, /) -> bytes: + """ + Decode base64-encoded data, ignoring invalid characters in the input. + Conforms to `RFC 2045 s.6.8 `_. + Returns a bytes object. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/bluetooth.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/bluetooth.pyi new file mode 100644 index 0000000000..39b8a07fe3 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/bluetooth.pyi @@ -0,0 +1,871 @@ +""" +Low-level Bluetooth radio functionality. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/bluetooth.html + +This module provides an interface to a Bluetooth controller on a board. +Currently this supports Bluetooth Low Energy (BLE) in Central, Peripheral, +Broadcaster, and Observer roles, as well as GATT Server and Client and L2CAP +connection-oriented-channels. A device may operate in multiple roles +concurrently. Pairing (and bonding) is supported on some ports. + +This API is intended to match the low-level Bluetooth protocol and provide +building-blocks for higher-level abstractions such as specific device types. + +``Note:`` For most applications, we recommend using the higher-level + `aioble library `_. + +``Note:`` This module is still under development and its classes, functions, + methods and constants are subject to change. + +--- +Module: 'bluetooth' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Callable, overload, Final +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf, _IRQ +from typing_extensions import Awaitable, TypeAlias, TypeVar + +FLAG_NOTIFY: Final[int] = 16 +FLAG_READ: Final[int] = 2 +FLAG_WRITE: Final[int] = 8 +FLAG_INDICATE: Final[int] = 32 +FLAG_WRITE_NO_RESPONSE: Final[int] = 4 +_Flag: TypeAlias = int +_Descriptor: TypeAlias = tuple["UUID", _Flag] +_Characteristic: TypeAlias = tuple["UUID", _Flag] | tuple["UUID", _Flag, tuple[_Descriptor, ...]] +_Service: TypeAlias = tuple["UUID", tuple[_Characteristic, ...]] + +class UUID: + """ + class UUID + ---------- + """ + def __init__(self, value: int | str, /) -> None: + """ + Creates a UUID instance with the specified **value**. + + The **value** can be either: + + - A 16-bit integer. e.g. ``0x2908``. + - A 128-bit UUID string. e.g. ``'6E400001-B5A3-F393-E0A9-E50E24DCCA9E'``. + """ + ... + +class BLE: + """ + class BLE + --------- + """ + def gatts_notify(self, value_handle: memoryview, data: bytes, /) -> None: + """ + Sends a notification request to a connected client. + + If *data* is ``None`` (the default), then the current local value (as set + with :meth:`gatts_write `) will be sent. + + Otherwise, if *data* is not ``None``, then that value is sent to the client + as part of the notification. The local value will not be modified. + + **Note:** The notification will be sent regardless of the subscription + status of the client to this characteristic. + """ + ... + def gatts_indicate(self, conn_handle: memoryview, value_handle: memoryview, /) -> None: + """ + Sends a indication request to a connected client. + + If *data* is ``None`` (the default), then the current local value (as set + with :meth:`gatts_write `) will be sent. + + Otherwise, if *data* is not ``None``, then that value is sent to the client + as part of the indication. The local value will not be modified. + + On acknowledgment (or failure, e.g. timeout), the + ``_IRQ_GATTS_INDICATE_DONE`` event will be raised. + + **Note:** The indication will be sent regardless of the subscription + status of the client to this characteristic. + """ + ... + def gattc_write( + self, + conn_handle: memoryview, + value_handle: memoryview, + data: bytes, + mode: int = 0, + /, + ) -> None: + """ + Issue a remote write to a connected server for the specified + characteristic or descriptor handle. + + The argument *mode* specifies the write behaviour, with the currently + supported values being: + + * ``mode=0`` (default) is a write-without-response: the write will + be sent to the remote server but no confirmation will be + returned, and no event will be raised. + * ``mode=1`` is a write-with-response: the remote server is + requested to send a response/acknowledgement that it received the + data. + + If a response is received from the remote server the + ``_IRQ_GATTC_WRITE_DONE`` event will be raised. + """ + ... + def gattc_read(self, conn_handle: memoryview, value_handle: memoryview, /) -> None: + """ + Issue a remote read to a connected server for the specified + characteristic or descriptor handle. + + When a value is available, the ``_IRQ_GATTC_READ_RESULT`` event will be + raised. Additionally, the ``_IRQ_GATTC_READ_DONE`` will be raised. + """ + ... + def gattc_exchange_mtu(self, conn_handle: memoryview, /) -> None: + """ + Initiate MTU exchange with a connected server, using the preferred MTU + set using ``BLE.config(mtu=value)``. + + The ``_IRQ_MTU_EXCHANGED`` event will be raised when MTU exchange + completes. + + **Note:** MTU exchange is typically initiated by the central. When using + the BlueKitchen stack in the central role, it does not support a remote + peripheral initiating the MTU exchange. NimBLE works for both roles. + """ + ... + def gatts_read(self, value_handle: memoryview, /) -> bytes: + """ + Reads the local value for this handle (which has either been written by + :meth:`gatts_write ` or by a remote client). + """ + ... + def gatts_write(self, value_handle: memoryview, data: bytes, send_update: bool = False, /) -> None: + """ + Writes the local value for this handle, which can be read by a client. + + If *send_update* is ``True``, then any subscribed clients will be notified + (or indicated, depending on what they're subscribed to and which operations + the characteristic supports) about this write. + """ + ... + def gatts_set_buffer(self, conn_handle: memoryview, len: int, append: bool = False, /) -> None: + """ + Sets the internal buffer size for a value in bytes. This will limit the + largest possible write that can be received. The default is 20. + + Setting *append* to ``True`` will make all remote writes append to, rather + than replace, the current value. At most *len* bytes can be buffered in + this way. When you use :meth:`gatts_read `, the value will + be cleared after reading. This feature is useful when implementing something + like the Nordic UART Service. + """ + ... + def gatts_register_services(self, services_definition: tuple[_Service, ...], /) -> tuple[tuple[memoryview, ...], ...]: + """ + Configures the server with the specified services, replacing any + existing services. + + *services_definition* is a list of **services**, where each **service** is a + two-element tuple containing a UUID and a list of **characteristics**. + + Each **characteristic** is a two-or-three-element tuple containing a UUID, a + **flags** value, and optionally a list of *descriptors*. + + Each **descriptor** is a two-element tuple containing a UUID and a **flags** + value. + + The **flags** are a bitwise-OR combination of the flags defined below. These + set both the behaviour of the characteristic (or descriptor) as well as the + security and privacy requirements. + + The return value is a list (one element per service) of tuples (each element + is a value handle). Characteristics and descriptor handles are flattened + into the same tuple, in the order that they are defined. + + The following example registers two services (Heart Rate, and Nordic UART):: + + HR_UUID = bluetooth.UUID(0x180D) + HR_CHAR = (bluetooth.UUID(0x2A37), bluetooth.FLAG_READ | bluetooth.FLAG_NOTIFY,) + HR_SERVICE = (HR_UUID, (HR_CHAR,),) + UART_UUID = bluetooth.UUID('6E400001-B5A3-F393-E0A9-E50E24DCCA9E') + UART_TX = (bluetooth.UUID('6E400003-B5A3-F393-E0A9-E50E24DCCA9E'), bluetooth.FLAG_READ | bluetooth.FLAG_NOTIFY,) + UART_RX = (bluetooth.UUID('6E400002-B5A3-F393-E0A9-E50E24DCCA9E'), bluetooth.FLAG_WRITE,) + UART_SERVICE = (UART_UUID, (UART_TX, UART_RX,),) + SERVICES = (HR_SERVICE, UART_SERVICE,) + ( (hr,), (tx, rx,), ) = bt.gatts_register_services(SERVICES) + + The three value handles (``hr``, ``tx``, ``rx``) can be used with + :meth:`gatts_read `, :meth:`gatts_write `, :meth:`gatts_notify `, and + :meth:`gatts_indicate `. + + **Note:** Advertising must be stopped before registering services. + + Available flags for characteristics and descriptors are:: + + from micropython import const + _FLAG_BROADCAST = const(0x0001) + _FLAG_READ = const(0x0002) + _FLAG_WRITE_NO_RESPONSE = const(0x0004) + _FLAG_WRITE = const(0x0008) + _FLAG_NOTIFY = const(0x0010) + _FLAG_INDICATE = const(0x0020) + _FLAG_AUTHENTICATED_SIGNED_WRITE = const(0x0040) + + _FLAG_AUX_WRITE = const(0x0100) + _FLAG_READ_ENCRYPTED = const(0x0200) + _FLAG_READ_AUTHENTICATED = const(0x0400) + _FLAG_READ_AUTHORIZED = const(0x0800) + _FLAG_WRITE_ENCRYPTED = const(0x1000) + _FLAG_WRITE_AUTHENTICATED = const(0x2000) + _FLAG_WRITE_AUTHORIZED = const(0x4000) + + As for the IRQs above, any required constants should be added to your Python code. + """ + ... + def irq(self, handler: Callable[[int, tuple[memoryview, ...]], Any], /) -> _IRQ: + """ + Registers a callback for events from the BLE stack. The *handler* takes two + arguments, ``event`` (which will be one of the codes below) and ``data`` + (which is an event-specific tuple of values). + + **Note:** As an optimisation to prevent unnecessary allocations, the ``addr``, + ``adv_data``, ``char_data``, ``notify_data``, and ``uuid`` entries in the + tuples are read-only memoryview instances pointing to :mod:`bluetooth`'s internal + ringbuffer, and are only valid during the invocation of the IRQ handler + function. If your program needs to save one of these values to access after + the IRQ handler has returned (e.g. by saving it in a class instance or global + variable), then it needs to take a copy of the data, either by using ``bytes()`` + or ``bluetooth.UUID()``, like this:: + + connected_addr = bytes(addr) # equivalently: adv_data, char_data, or notify_data + matched_uuid = bluetooth.UUID(uuid) + + For example, the IRQ handler for a scan result might inspect the ``adv_data`` + to decide if it's the correct device, and only then copy the address data to be + used elsewhere in the program. And to print data from within the IRQ handler, + ``print(bytes(addr))`` will be needed. + + An event handler showing all possible events:: + + def bt_irq(event, data): + if event == _IRQ_CENTRAL_CONNECT: + # A central has connected to this peripheral. + conn_handle, addr_type, addr = data + elif event == _IRQ_CENTRAL_DISCONNECT: + # A central has disconnected from this peripheral. + conn_handle, addr_type, addr = data + elif event == _IRQ_GATTS_WRITE: + # A client has written to this characteristic or descriptor. + conn_handle, attr_handle = data + elif event == _IRQ_GATTS_READ_REQUEST: + # A client has issued a read. Note: this is only supported on STM32. + # Return a non-zero integer to deny the read (see below), or zero (or None) + # to accept the read. + conn_handle, attr_handle = data + elif event == _IRQ_SCAN_RESULT: + # A single scan result. + addr_type, addr, adv_type, rssi, adv_data = data + elif event == _IRQ_SCAN_DONE: + # Scan duration finished or manually stopped. + pass + elif event == _IRQ_PERIPHERAL_CONNECT: + # A successful gap_connect(). + conn_handle, addr_type, addr = data + elif event == _IRQ_PERIPHERAL_DISCONNECT: + # Connected peripheral has disconnected. + conn_handle, addr_type, addr = data + elif event == _IRQ_GATTC_SERVICE_RESULT: + # Called for each service found by gattc_discover_services(). + conn_handle, start_handle, end_handle, uuid = data + elif event == _IRQ_GATTC_SERVICE_DONE: + # Called once service discovery is complete. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, status = data + elif event == _IRQ_GATTC_CHARACTERISTIC_RESULT: + # Called for each characteristic found by gattc_discover_services(). + conn_handle, end_handle, value_handle, properties, uuid = data + elif event == _IRQ_GATTC_CHARACTERISTIC_DONE: + # Called once service discovery is complete. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, status = data + elif event == _IRQ_GATTC_DESCRIPTOR_RESULT: + # Called for each descriptor found by gattc_discover_descriptors(). + conn_handle, dsc_handle, uuid = data + elif event == _IRQ_GATTC_DESCRIPTOR_DONE: + # Called once service discovery is complete. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, status = data + elif event == _IRQ_GATTC_READ_RESULT: + # A gattc_read() has completed. + conn_handle, value_handle, char_data = data + elif event == _IRQ_GATTC_READ_DONE: + # A gattc_read() has completed. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, value_handle, status = data + elif event == _IRQ_GATTC_WRITE_DONE: + # A gattc_write() has completed. + # Note: Status will be zero on success, implementation-specific value otherwise. + conn_handle, value_handle, status = data + elif event == _IRQ_GATTC_NOTIFY: + # A server has sent a notify request. + conn_handle, value_handle, notify_data = data + elif event == _IRQ_GATTC_INDICATE: + # A server has sent an indicate request. + conn_handle, value_handle, notify_data = data + elif event == _IRQ_GATTS_INDICATE_DONE: + # A client has acknowledged the indication. + # Note: Status will be zero on successful acknowledgment, implementation-specific value otherwise. + conn_handle, value_handle, status = data + elif event == _IRQ_MTU_EXCHANGED: + # ATT MTU exchange complete (either initiated by us or the remote device). + conn_handle, mtu = data + elif event == _IRQ_L2CAP_ACCEPT: + # A new channel has been accepted. + # Return a non-zero integer to reject the connection, or zero (or None) to accept. + conn_handle, cid, psm, our_mtu, peer_mtu = data + elif event == _IRQ_L2CAP_CONNECT: + # A new channel is now connected (either as a result of connecting or accepting). + conn_handle, cid, psm, our_mtu, peer_mtu = data + elif event == _IRQ_L2CAP_DISCONNECT: + # Existing channel has disconnected (status is zero), or a connection attempt failed (non-zero status). + conn_handle, cid, psm, status = data + elif event == _IRQ_L2CAP_RECV: + # New data is available on the channel. Use l2cap_recvinto to read. + conn_handle, cid = data + elif event == _IRQ_L2CAP_SEND_READY: + # A previous l2cap_send that returned False has now completed and the channel is ready to send again. + # If status is non-zero, then the transmit buffer overflowed and the application should re-send the data. + conn_handle, cid, status = data + elif event == _IRQ_CONNECTION_UPDATE: + # The remote device has updated connection parameters. + conn_handle, conn_interval, conn_latency, supervision_timeout, status = data + elif event == _IRQ_ENCRYPTION_UPDATE: + # The encryption state has changed (likely as a result of pairing or bonding). + conn_handle, encrypted, authenticated, bonded, key_size = data + elif event == _IRQ_GET_SECRET: + # Return a stored secret. + # If key is None, return the index'th value of this sec_type. + # Otherwise return the corresponding value for this sec_type and key. + sec_type, index, key = data + return value + elif event == _IRQ_SET_SECRET: + # Save a secret to the store for this sec_type and key. + sec_type, key, value = data + return True + elif event == _IRQ_PASSKEY_ACTION: + # Respond to a passkey request during pairing. + # See gap_passkey() for details. + # action will be an action that is compatible with the configured "io" config. + # passkey will be non-zero if action is "numeric comparison". + conn_handle, action, passkey = data + + + The event codes are:: + + from micropython import const + _IRQ_CENTRAL_CONNECT = const(1) + _IRQ_CENTRAL_DISCONNECT = const(2) + _IRQ_GATTS_WRITE = const(3) + _IRQ_GATTS_READ_REQUEST = const(4) + _IRQ_SCAN_RESULT = const(5) + _IRQ_SCAN_DONE = const(6) + _IRQ_PERIPHERAL_CONNECT = const(7) + _IRQ_PERIPHERAL_DISCONNECT = const(8) + _IRQ_GATTC_SERVICE_RESULT = const(9) + _IRQ_GATTC_SERVICE_DONE = const(10) + _IRQ_GATTC_CHARACTERISTIC_RESULT = const(11) + _IRQ_GATTC_CHARACTERISTIC_DONE = const(12) + _IRQ_GATTC_DESCRIPTOR_RESULT = const(13) + _IRQ_GATTC_DESCRIPTOR_DONE = const(14) + _IRQ_GATTC_READ_RESULT = const(15) + _IRQ_GATTC_READ_DONE = const(16) + _IRQ_GATTC_WRITE_DONE = const(17) + _IRQ_GATTC_NOTIFY = const(18) + _IRQ_GATTC_INDICATE = const(19) + _IRQ_GATTS_INDICATE_DONE = const(20) + _IRQ_MTU_EXCHANGED = const(21) + _IRQ_L2CAP_ACCEPT = const(22) + _IRQ_L2CAP_CONNECT = const(23) + _IRQ_L2CAP_DISCONNECT = const(24) + _IRQ_L2CAP_RECV = const(25) + _IRQ_L2CAP_SEND_READY = const(26) + _IRQ_CONNECTION_UPDATE = const(27) + _IRQ_ENCRYPTION_UPDATE = const(28) + _IRQ_GET_SECRET = const(29) + _IRQ_SET_SECRET = const(30) + + For the ``_IRQ_GATTS_READ_REQUEST`` event, the available return codes are:: + + _GATTS_NO_ERROR = const(0x00) + _GATTS_ERROR_READ_NOT_PERMITTED = const(0x02) + _GATTS_ERROR_WRITE_NOT_PERMITTED = const(0x03) + _GATTS_ERROR_INSUFFICIENT_AUTHENTICATION = const(0x05) + _GATTS_ERROR_INSUFFICIENT_AUTHORIZATION = const(0x08) + _GATTS_ERROR_INSUFFICIENT_ENCRYPTION = const(0x0f) + + For the ``_IRQ_PASSKEY_ACTION`` event, the available actions are:: + + _PASSKEY_ACTION_NONE = const(0) + _PASSKEY_ACTION_INPUT = const(2) + _PASSKEY_ACTION_DISPLAY = const(3) + _PASSKEY_ACTION_NUMERIC_COMPARISON = const(4) + + In order to save space in the firmware, these constants are not included on the + :mod:`bluetooth` module. Add the ones that you need from the list above to your + program. + """ + ... + def gap_connect( + self, + addr_type: int, + addr: bytes, + scan_duration_ms: int = 2000, + min_conn_interval_us: int | None = None, + max_conn_interval_us: int | None = None, + /, + ) -> None: + """ + Connect to a peripheral. + + See :meth:`gap_scan ` for details about address types. + + To cancel an outstanding connection attempt early, call + ``gap_connect(None)``. + + On success, the ``_IRQ_PERIPHERAL_CONNECT`` event will be raised. If + cancelling a connection attempt, the ``_IRQ_PERIPHERAL_DISCONNECT`` event + will be raised. + + The device will wait up to *scan_duration_ms* to receive an advertising + payload from the device. + + The connection interval can be configured in **micro** seconds using either + or both of *min_conn_interval_us* and *max_conn_interval_us*. Otherwise a + default interval will be chosen, typically between 30000 and 50000 + microseconds. A shorter interval will increase throughput, at the expense + of power usage. + """ + ... + def gap_advertise( + self, + interval_us: int, + adv_data: AnyReadableBuf | None = None, + /, + *, + resp_data: AnyReadableBuf | None = None, + connectable: bool = True, + ) -> None: + """ + Starts advertising at the specified interval (in **micro** seconds). This + interval will be rounded down to the nearest 625us. To stop advertising, set + *interval_us* to ``None``. + + *adv_data* and *resp_data* can be any type that implements the buffer + protocol (e.g. ``bytes``, ``bytearray``, ``str``). *adv_data* is included + in all broadcasts, and *resp_data* is send in reply to an active scan. + + **Note:** if *adv_data* (or *resp_data*) is ``None``, then the data passed + to the previous call to ``gap_advertise`` will be reused. This allows a + broadcaster to resume advertising with just ``gap_advertise(interval_us)``. + To clear the advertising payload pass an empty ``bytes``, i.e. ``b''``. + """ + ... + + @overload + def config(self, param: str, /) -> Any: + """ + Get or set configuration values of the BLE interface. To get a value the + parameter name should be quoted as a string, and just one parameter is + queried at a time. To set values use the keyword syntax, and one or more + parameter can be set at a time. + + Currently supported values are: + + - ``'mac'``: The current address in use, depending on the current address mode. + This returns a tuple of ``(addr_type, addr)``. + + See :meth:`gatts_write ` for details about address type. + + This may only be queried while the interface is currently active. + + - ``'addr_mode'``: Sets the address mode. Values can be: + + * 0x00 - PUBLIC - Use the controller's public address. + * 0x01 - RANDOM - Use a generated static address. + * 0x02 - RPA - Use resolvable private addresses. + * 0x03 - NRPA - Use non-resolvable private addresses. + + By default the interface mode will use a PUBLIC address if available, otherwise + it will use a RANDOM address. + + - ``'gap_name'``: Get/set the GAP device name used by service 0x1800, + characteristic 0x2a00. This can be set at any time and changed multiple + times. + + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store + incoming events. This buffer is global to the entire BLE driver and so + handles incoming data for all events, including all characteristics. + Increasing this allows better handling of bursty incoming data (for + example scan results) and the ability to receive larger characteristic values. + + - ``'mtu'``: Get/set the MTU that will be used during a ATT MTU exchange. The + resulting MTU will be the minimum of this and the remote device's MTU. + ATT MTU exchange will not happen automatically (unless the remote device initiates + it), and must be manually initiated with + :meth:`gattc_exchange_mtu`. + Use the ``_IRQ_MTU_EXCHANGED`` event to discover the MTU for a given connection. + + - ``'bond'``: Sets whether bonding will be enabled during pairing. When + enabled, pairing requests will set the "bond" flag and the keys will be stored + by both devices. + + - ``'mitm'``: Sets whether MITM-protection is required for pairing. + + - ``'io'``: Sets the I/O capabilities of this device. + + Available options are:: + + _IO_CAPABILITY_DISPLAY_ONLY = const(0) + _IO_CAPABILITY_DISPLAY_YESNO = const(1) + _IO_CAPABILITY_KEYBOARD_ONLY = const(2) + _IO_CAPABILITY_NO_INPUT_OUTPUT = const(3) + _IO_CAPABILITY_KEYBOARD_DISPLAY = const(4) + + - ``'le_secure'``: Sets whether "LE Secure" pairing is required. Default is + false (i.e. allow "Legacy Pairing"). + """ + + @overload + def config(self, **kwargs) -> None: + """ + Get or set configuration values of the BLE interface. To get a value the + parameter name should be quoted as a string, and just one parameter is + queried at a time. To set values use the keyword syntax, and one or more + parameter can be set at a time. + + Currently supported values are: + + - ``'mac'``: The current address in use, depending on the current address mode. + This returns a tuple of ``(addr_type, addr)``. + + See :meth:`gatts_write ` for details about address type. + + This may only be queried while the interface is currently active. + + - ``'addr_mode'``: Sets the address mode. Values can be: + + * 0x00 - PUBLIC - Use the controller's public address. + * 0x01 - RANDOM - Use a generated static address. + * 0x02 - RPA - Use resolvable private addresses. + * 0x03 - NRPA - Use non-resolvable private addresses. + + By default the interface mode will use a PUBLIC address if available, otherwise + it will use a RANDOM address. + + - ``'gap_name'``: Get/set the GAP device name used by service 0x1800, + characteristic 0x2a00. This can be set at any time and changed multiple + times. + + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store + incoming events. This buffer is global to the entire BLE driver and so + handles incoming data for all events, including all characteristics. + Increasing this allows better handling of bursty incoming data (for + example scan results) and the ability to receive larger characteristic values. + + - ``'mtu'``: Get/set the MTU that will be used during a ATT MTU exchange. The + resulting MTU will be the minimum of this and the remote device's MTU. + ATT MTU exchange will not happen automatically (unless the remote device initiates + it), and must be manually initiated with + :meth:`gattc_exchange_mtu`. + Use the ``_IRQ_MTU_EXCHANGED`` event to discover the MTU for a given connection. + + - ``'bond'``: Sets whether bonding will be enabled during pairing. When + enabled, pairing requests will set the "bond" flag and the keys will be stored + by both devices. + + - ``'mitm'``: Sets whether MITM-protection is required for pairing. + + - ``'io'``: Sets the I/O capabilities of this device. + + Available options are:: + + _IO_CAPABILITY_DISPLAY_ONLY = const(0) + _IO_CAPABILITY_DISPLAY_YESNO = const(1) + _IO_CAPABILITY_KEYBOARD_ONLY = const(2) + _IO_CAPABILITY_NO_INPUT_OUTPUT = const(3) + _IO_CAPABILITY_KEYBOARD_DISPLAY = const(4) + + - ``'le_secure'``: Sets whether "LE Secure" pairing is required. Default is + false (i.e. allow "Legacy Pairing"). + """ + + @overload + def config(self, param: str, /) -> Any: + """ + Get or set configuration values of the BLE interface. To get a value the + parameter name should be quoted as a string, and just one parameter is + queried at a time. To set values use the keyword syntax, and one or more + parameter can be set at a time. + + Currently supported values are: + + - ``'mac'``: The current address in use, depending on the current address mode. + This returns a tuple of ``(addr_type, addr)``. + + See :meth:`gatts_write ` for details about address type. + + This may only be queried while the interface is currently active. + + - ``'addr_mode'``: Sets the address mode. Values can be: + + * 0x00 - PUBLIC - Use the controller's public address. + * 0x01 - RANDOM - Use a generated static address. + * 0x02 - RPA - Use resolvable private addresses. + * 0x03 - NRPA - Use non-resolvable private addresses. + + By default the interface mode will use a PUBLIC address if available, otherwise + it will use a RANDOM address. + + - ``'gap_name'``: Get/set the GAP device name used by service 0x1800, + characteristic 0x2a00. This can be set at any time and changed multiple + times. + + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store + incoming events. This buffer is global to the entire BLE driver and so + handles incoming data for all events, including all characteristics. + Increasing this allows better handling of bursty incoming data (for + example scan results) and the ability to receive larger characteristic values. + + - ``'mtu'``: Get/set the MTU that will be used during a ATT MTU exchange. The + resulting MTU will be the minimum of this and the remote device's MTU. + ATT MTU exchange will not happen automatically (unless the remote device initiates + it), and must be manually initiated with + :meth:`gattc_exchange_mtu`. + Use the ``_IRQ_MTU_EXCHANGED`` event to discover the MTU for a given connection. + + - ``'bond'``: Sets whether bonding will be enabled during pairing. When + enabled, pairing requests will set the "bond" flag and the keys will be stored + by both devices. + + - ``'mitm'``: Sets whether MITM-protection is required for pairing. + + - ``'io'``: Sets the I/O capabilities of this device. + + Available options are:: + + _IO_CAPABILITY_DISPLAY_ONLY = const(0) + _IO_CAPABILITY_DISPLAY_YESNO = const(1) + _IO_CAPABILITY_KEYBOARD_ONLY = const(2) + _IO_CAPABILITY_NO_INPUT_OUTPUT = const(3) + _IO_CAPABILITY_KEYBOARD_DISPLAY = const(4) + + - ``'le_secure'``: Sets whether "LE Secure" pairing is required. Default is + false (i.e. allow "Legacy Pairing"). + """ + + @overload + def config(self, **kwargs) -> None: + """ + Get or set configuration values of the BLE interface. To get a value the + parameter name should be quoted as a string, and just one parameter is + queried at a time. To set values use the keyword syntax, and one or more + parameter can be set at a time. + + Currently supported values are: + + - ``'mac'``: The current address in use, depending on the current address mode. + This returns a tuple of ``(addr_type, addr)``. + + See :meth:`gatts_write ` for details about address type. + + This may only be queried while the interface is currently active. + + - ``'addr_mode'``: Sets the address mode. Values can be: + + * 0x00 - PUBLIC - Use the controller's public address. + * 0x01 - RANDOM - Use a generated static address. + * 0x02 - RPA - Use resolvable private addresses. + * 0x03 - NRPA - Use non-resolvable private addresses. + + By default the interface mode will use a PUBLIC address if available, otherwise + it will use a RANDOM address. + + - ``'gap_name'``: Get/set the GAP device name used by service 0x1800, + characteristic 0x2a00. This can be set at any time and changed multiple + times. + + - ``'rxbuf'``: Get/set the size in bytes of the internal buffer used to store + incoming events. This buffer is global to the entire BLE driver and so + handles incoming data for all events, including all characteristics. + Increasing this allows better handling of bursty incoming data (for + example scan results) and the ability to receive larger characteristic values. + + - ``'mtu'``: Get/set the MTU that will be used during a ATT MTU exchange. The + resulting MTU will be the minimum of this and the remote device's MTU. + ATT MTU exchange will not happen automatically (unless the remote device initiates + it), and must be manually initiated with + :meth:`gattc_exchange_mtu`. + Use the ``_IRQ_MTU_EXCHANGED`` event to discover the MTU for a given connection. + + - ``'bond'``: Sets whether bonding will be enabled during pairing. When + enabled, pairing requests will set the "bond" flag and the keys will be stored + by both devices. + + - ``'mitm'``: Sets whether MITM-protection is required for pairing. + + - ``'io'``: Sets the I/O capabilities of this device. + + Available options are:: + + _IO_CAPABILITY_DISPLAY_ONLY = const(0) + _IO_CAPABILITY_DISPLAY_YESNO = const(1) + _IO_CAPABILITY_KEYBOARD_ONLY = const(2) + _IO_CAPABILITY_NO_INPUT_OUTPUT = const(3) + _IO_CAPABILITY_KEYBOARD_DISPLAY = const(4) + + - ``'le_secure'``: Sets whether "LE Secure" pairing is required. Default is + false (i.e. allow "Legacy Pairing"). + """ + + @overload + def active(self) -> bool: + """ + Optionally changes the active state of the BLE radio, and returns the + current state. + + The radio must be made active before using any other methods on this class. + """ + + @overload + def active(self, active: bool, /) -> None: + """ + Optionally changes the active state of the BLE radio, and returns the + current state. + + The radio must be made active before using any other methods on this class. + """ + + @overload + def active(self) -> bool: + """ + Optionally changes the active state of the BLE radio, and returns the + current state. + + The radio must be made active before using any other methods on this class. + """ + + @overload + def active(self, active: bool, /) -> None: + """ + Optionally changes the active state of the BLE radio, and returns the + current state. + + The radio must be made active before using any other methods on this class. + """ + def gattc_discover_services(self, conn_handle: memoryview, uuid: UUID | None = None, /) -> None: + """ + Query a connected server for its services. + + Optionally specify a service *uuid* to query for that service only. + + For each service discovered, the ``_IRQ_GATTC_SERVICE_RESULT`` event will + be raised, followed by ``_IRQ_GATTC_SERVICE_DONE`` on completion. + """ + ... + def gap_disconnect(self, conn_handle: memoryview, /) -> bool: + """ + Disconnect the specified connection handle. This can either be a + central that has connected to this device (if acting as a peripheral) + or a peripheral that was previously connected to by this device (if acting + as a central). + + On success, the ``_IRQ_PERIPHERAL_DISCONNECT`` or ``_IRQ_CENTRAL_DISCONNECT`` + event will be raised. + + Returns ``False`` if the connection handle wasn't connected, and ``True`` + otherwise. + """ + ... + def gattc_discover_descriptors(self, conn_handle: memoryview, start_handle: int, end_handle: int, /) -> None: + """ + Query a connected server for descriptors in the specified range. + + For each descriptor discovered, the ``_IRQ_GATTC_DESCRIPTOR_RESULT`` event + will be raised, followed by ``_IRQ_GATTC_DESCRIPTOR_DONE`` on completion. + """ + ... + def gattc_discover_characteristics( + self, + conn_handle: memoryview, + start_handle: int, + end_handle: int, + uuid: UUID | None = None, + /, + ) -> None: + """ + Query a connected server for characteristics in the specified range. + + Optionally specify a characteristic *uuid* to query for that + characteristic only. + + You can use ``start_handle=1``, ``end_handle=0xffff`` to search for a + characteristic in any service. + + For each characteristic discovered, the ``_IRQ_GATTC_CHARACTERISTIC_RESULT`` + event will be raised, followed by ``_IRQ_GATTC_CHARACTERISTIC_DONE`` on completion. + """ + ... + def gap_scan( + self, + duration_ms: int, + interval_us: int = 1280000, + window_us: int = 11250, + active: bool = False, + /, + ) -> None: + """ + Run a scan operation lasting for the specified duration (in **milli** seconds). + + To scan indefinitely, set *duration_ms* to ``0``. + + To stop scanning, set *duration_ms* to ``None``. + + Use *interval_us* and *window_us* to optionally configure the duty cycle. + The scanner will run for *window_us* **micro** seconds every *interval_us* + **micro** seconds for a total of *duration_ms* **milli** seconds. The default + interval and window are 1.28 seconds and 11.25 milliseconds respectively + (background scanning). + + For each scan result the ``_IRQ_SCAN_RESULT`` event will be raised, with event + data ``(addr_type, addr, adv_type, rssi, adv_data)``. + + ``addr_type`` values indicate public or random addresses: + * 0x00 - PUBLIC + * 0x01 - RANDOM (either static, RPA, or NRPA, the type is encoded in the address itself) + + ``adv_type`` values correspond to the Bluetooth Specification: + + * 0x00 - ADV_IND - connectable and scannable undirected advertising + * 0x01 - ADV_DIRECT_IND - connectable directed advertising + * 0x02 - ADV_SCAN_IND - scannable undirected advertising + * 0x03 - ADV_NONCONN_IND - non-connectable undirected advertising + * 0x04 - SCAN_RSP - scan response + + ``active`` can be set ``True`` if you want to receive scan responses in the results. + + When scanning is stopped (either due to the duration finishing or when + explicitly stopped), the ``_IRQ_SCAN_DONE`` event will be raised. + """ + ... + def __init__(self) -> None: + """ + Returns the singleton BLE object. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/cmath.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/cmath.pyi new file mode 100644 index 0000000000..150affd8cf --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/cmath.pyi @@ -0,0 +1,84 @@ +""" +Mathematical functions for complex numbers. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/cmath.html + +CPython module: :mod:`python:cmath` https://docs.python.org/3/library/cmath.html . + +The ``cmath`` module provides some basic mathematical functions for +working with complex numbers. + +Availability: not available on WiPy and ESP8266. Floating point support +required for this module. + +--- +Module: 'cmath' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import SupportsComplex, SupportsFloat, SupportsIndex, Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_C: TypeAlias = SupportsFloat | SupportsComplex | SupportsIndex | complex + +e: float = 2.7182818 +"""base of the natural logarithm""" +pi: float = 3.1415928 +"""the ratio of a circle's circumference to its diameter""" + +def polar(z: _C, /) -> Tuple: + """ + Returns, as a tuple, the polar form of ``z``. + """ + ... + +def sqrt(z: _C, /) -> complex: + """ + Return the square-root of ``z``. + """ + ... + +def rect(r: float, phi: float, /) -> float: + """ + Returns the complex number with modulus ``r`` and phase ``phi``. + """ + ... + +def sin(z: _C, /) -> float: + """ + Return the sine of ``z``. + """ + ... + +def exp(z: _C, /) -> float: + """ + Return the exponential of ``z``. + """ + ... + +def cos(z: _C, /) -> float: + """ + Return the cosine of ``z``. + """ + ... + +def phase(z: _C, /) -> float: + """ + Returns the phase of the number ``z``, in the range (-pi, +pi]. + """ + ... + +def log(z: _C, /) -> float: + """ + Return the natural logarithm of ``z``. The branch cut is along the negative real axis. + """ + ... + +def log10(z: _C, /) -> float: + """ + Return the base-10 logarithm of ``z``. The branch cut is along the negative real axis. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/cryptolib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/cryptolib.pyi new file mode 100644 index 0000000000..a8d1e5c469 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/cryptolib.pyi @@ -0,0 +1,165 @@ +""" +Cryptographic ciphers. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/cryptolib.html + +--- +Module: 'cryptolib' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf +from typing import overload +from typing_extensions import Awaitable, TypeAlias, TypeVar + +class aes: + """ + .. class:: aes + """ + + @overload + def encrypt(self, in_buf: AnyReadableBuf, /) -> bytes: + """ + Encrypt *in_buf*. If no *out_buf* is given result is returned as a + newly allocated `bytes` object. Otherwise, result is written into + mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer + to the same mutable buffer, in which case data is encrypted in-place. + """ + + @overload + def encrypt(self, in_buf: AnyReadableBuf, out_buf: AnyWritableBuf, /) -> None: + """ + Encrypt *in_buf*. If no *out_buf* is given result is returned as a + newly allocated `bytes` object. Otherwise, result is written into + mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer + to the same mutable buffer, in which case data is encrypted in-place. + """ + + @overload + def encrypt(self, in_buf: AnyReadableBuf, /) -> bytes: + """ + Encrypt *in_buf*. If no *out_buf* is given result is returned as a + newly allocated `bytes` object. Otherwise, result is written into + mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer + to the same mutable buffer, in which case data is encrypted in-place. + """ + + @overload + def encrypt(self, in_buf: AnyReadableBuf, out_buf: AnyWritableBuf, /) -> None: + """ + Encrypt *in_buf*. If no *out_buf* is given result is returned as a + newly allocated `bytes` object. Otherwise, result is written into + mutable buffer *out_buf*. *in_buf* and *out_buf* can also refer + to the same mutable buffer, in which case data is encrypted in-place. + """ + + @overload + def decrypt(self, in_buf: AnyReadableBuf, /) -> bytes: + """ + Like `encrypt()`, but for decryption. + """ + + @overload + def decrypt(self, in_buf: AnyReadableBuf, out_buf: AnyWritableBuf, /) -> None: + """ + Like `encrypt()`, but for decryption. + """ + + @overload + def decrypt(self, in_buf: AnyReadableBuf, /) -> bytes: + """ + Like `encrypt()`, but for decryption. + """ + + @overload + def decrypt(self, in_buf: AnyReadableBuf, out_buf: AnyWritableBuf, /) -> None: + """ + Like `encrypt()`, but for decryption. + """ + + @overload + def __init__(self, key: AnyReadableBuf, mode: int, /): + """ + Initialize cipher object, suitable for encryption/decryption. Note: + after initialization, cipher object can be use only either for + encryption or decryption. Running decrypt() operation after encrypt() + or vice versa is not supported. + + Parameters are: + + * *key* is an encryption/decryption key (bytes-like). + * *mode* is: + + * ``1`` (or ``cryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB). + * ``2`` (or ``cryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC). + * ``6`` (or ``cryptolib.MODE_CTR`` if it exists) for Counter mode (CTR). + + * *IV* is an initialization vector for CBC mode. + * For Counter mode, *IV* is the initial value for the counter. + """ + + @overload + def __init__(self, key: AnyReadableBuf, mode: int, IV: AnyReadableBuf, /): + """ + Initialize cipher object, suitable for encryption/decryption. Note: + after initialization, cipher object can be use only either for + encryption or decryption. Running decrypt() operation after encrypt() + or vice versa is not supported. + + Parameters are: + + * *key* is an encryption/decryption key (bytes-like). + * *mode* is: + + * ``1`` (or ``cryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB). + * ``2`` (or ``cryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC). + * ``6`` (or ``cryptolib.MODE_CTR`` if it exists) for Counter mode (CTR). + + * *IV* is an initialization vector for CBC mode. + * For Counter mode, *IV* is the initial value for the counter. + """ + + @overload + def __init__(self, key: AnyReadableBuf, mode: int, /): + """ + Initialize cipher object, suitable for encryption/decryption. Note: + after initialization, cipher object can be use only either for + encryption or decryption. Running decrypt() operation after encrypt() + or vice versa is not supported. + + Parameters are: + + * *key* is an encryption/decryption key (bytes-like). + * *mode* is: + + * ``1`` (or ``cryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB). + * ``2`` (or ``cryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC). + * ``6`` (or ``cryptolib.MODE_CTR`` if it exists) for Counter mode (CTR). + + * *IV* is an initialization vector for CBC mode. + * For Counter mode, *IV* is the initial value for the counter. + """ + + @overload + def __init__(self, key: AnyReadableBuf, mode: int, IV: AnyReadableBuf, /): + """ + Initialize cipher object, suitable for encryption/decryption. Note: + after initialization, cipher object can be use only either for + encryption or decryption. Running decrypt() operation after encrypt() + or vice versa is not supported. + + Parameters are: + + * *key* is an encryption/decryption key (bytes-like). + * *mode* is: + + * ``1`` (or ``cryptolib.MODE_ECB`` if it exists) for Electronic Code Book (ECB). + * ``2`` (or ``cryptolib.MODE_CBC`` if it exists) for Cipher Block Chaining (CBC). + * ``6`` (or ``cryptolib.MODE_CTR`` if it exists) for Counter mode (CTR). + + * *IV* is an initialization vector for CBC mode. + * For Counter mode, *IV* is the initial value for the counter. + """ diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/deflate.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/deflate.pyi new file mode 100644 index 0000000000..803f8dcf3a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/deflate.pyi @@ -0,0 +1,88 @@ +""" +Deflate compression & decompression. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/deflate.html + +This module allows compression and decompression of binary data with the +`DEFLATE algorithm `_ +(commonly used in the zlib library and gzip archiver). + +**Availability:** + +* Added in MicroPython v1.21. + +* Decompression: Enabled via the ``MICROPY_PY_DEFLATE`` build option, on by default + on ports with the "extra features" level or higher (which is most boards). + +* Compression: Enabled via the ``MICROPY_PY_DEFLATE_COMPRESS`` build option, on + by default on ports with the "full features" level or higher (generally this means + you need to build your own firmware to enable this). + +--- +Module: 'deflate' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar + +GZIP: Final[int] = 3 +"""Supported values for the *format* parameter.""" +RAW: Final[int] = 1 +"""Supported values for the *format* parameter.""" +ZLIB: Final[int] = 2 +"""Supported values for the *format* parameter.""" +AUTO: Final[int] = 0 +"""Supported values for the *format* parameter.""" + +class DeflateIO: + """ + This class can be used to wrap a *stream* which is any + :term:`stream-like ` object such as a file, socket, or stream + (including :class:`io.BytesIO`). It is itself a stream and implements the + standard read/readinto/write/close methods. + + The *stream* must be a blocking stream. Non-blocking streams are currently + not supported. + + The *format* can be set to any of the constants defined below, and defaults + to ``AUTO`` which for decompressing will auto-detect gzip or zlib streams, + and for compressing it will generate a raw stream. + + The *wbits* parameter sets the base-2 logarithm of the DEFLATE dictionary + window size. So for example, setting *wbits* to ``10`` sets the window size + to 1024 bytes. Valid values are ``5`` to ``15`` inclusive (corresponding to + window sizes of 32 to 32k bytes). + + If *wbits* is set to ``0`` (the default), then for compression a window size + of 256 bytes will be used (as if *wbits* was set to 8). For decompression, it + depends on the format: + + * ``RAW`` will use 256 bytes (corresponding to *wbits* set to 8). + * ``ZLIB`` (or ``AUTO`` with zlib detected) will use the value from the zlib + header. + * ``GZIP`` (or ``AUTO`` with gzip detected) will use 32 kilobytes + (corresponding to *wbits* set to 15). + + See the :ref:`window size ` notes below for more information + about the window size, zlib, and gzip streams. + + If *close* is set to ``True`` then the underlying stream will be closed + automatically when the :class:`deflate.DeflateIO` stream is closed. This is + useful if you want to return a :class:`deflate.DeflateIO` stream that wraps + another stream and not have the caller need to know about managing the + underlying stream. + + If compression is enabled, a given :class:`deflate.DeflateIO` instance + supports both reading and writing. For example, a bidirectional stream like + a socket can be wrapped, which allows for compression/decompression in both + directions. + """ + def readline(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, stream, format=AUTO, wbits=0, close=False, /) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/dht.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/dht.pyi new file mode 100644 index 0000000000..1ccfb53c50 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/dht.pyi @@ -0,0 +1,26 @@ +""" +Module: 'dht' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def dht_readinto(*args, **kwargs) -> Incomplete: ... + +class DHTBase: + def measure(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DHT22: + def measure(self, *args, **kwargs) -> Incomplete: ... + def temperature(self, *args, **kwargs) -> Incomplete: ... + def humidity(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DHT11: + def measure(self, *args, **kwargs) -> Incomplete: ... + def temperature(self, *args, **kwargs) -> Incomplete: ... + def humidity(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/doc_stubs.json b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/doc_stubs.json new file mode 100644 index 0000000000..1f15986da7 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/doc_stubs.json @@ -0,0 +1,480 @@ +{ + "$schema": "https://raw.githubusercontent.com/Josverl/micropython-stubber/main/data/schema/stubber-v1_4_0.json", + "firmware": { + "family": "micropython", + "port": "-", + "platform": "-", + "machine": "micropython", + "firmware": "micropython-v1_27_0", + "nodename": "micropython", + "version": "v1.27.0", + "release": "v1.27.0", + "sysname": "micropython" + }, + "stubber": { + "version": "1.26.3", + "stubtype": "documentation" + }, + "modules": [ + { + "file": "_thread/__init__.pyi", + "module": "__init__" + }, + { + "file": "array/__init__.pyi", + "module": "__init__" + }, + { + "file": "asyncio/__init__.pyi", + "module": "__init__" + }, + { + "file": "binascii/__init__.pyi", + "module": "__init__" + }, + { + "file": "bluetooth/__init__.pyi", + "module": "__init__" + }, + { + "file": "btree/__init__.pyi", + "module": "__init__" + }, + { + "file": "cmath/__init__.pyi", + "module": "__init__" + }, + { + "file": "collections/__init__.pyi", + "module": "__init__" + }, + { + "file": "cryptolib/__init__.pyi", + "module": "__init__" + }, + { + "file": "deflate/__init__.pyi", + "module": "__init__" + }, + { + "file": "errno/__init__.pyi", + "module": "__init__" + }, + { + "file": "esp/__init__.pyi", + "module": "__init__" + }, + { + "file": "esp32/__init__.pyi", + "module": "__init__" + }, + { + "file": "espnow/__init__.pyi", + "module": "__init__" + }, + { + "file": "framebuf/__init__.pyi", + "module": "__init__" + }, + { + "file": "gc/__init__.pyi", + "module": "__init__" + }, + { + "file": "gzip/__init__.pyi", + "module": "__init__" + }, + { + "file": "hashlib/__init__.pyi", + "module": "__init__" + }, + { + "file": "heapq/__init__.pyi", + "module": "__init__" + }, + { + "file": "io/__init__.pyi", + "module": "__init__" + }, + { + "file": "json/__init__.pyi", + "module": "__init__" + }, + { + "file": "lcd160cr/__init__.pyi", + "module": "__init__" + }, + { + "file": "machine/ADC.pyi", + "module": "ADC" + }, + { + "file": "machine/ADCBlock.pyi", + "module": "ADCBlock" + }, + { + "file": "machine/ADCWiPy.pyi", + "module": "ADCWiPy" + }, + { + "file": "machine/Counter.pyi", + "module": "Counter" + }, + { + "file": "machine/DAC.pyi", + "module": "DAC" + }, + { + "file": "machine/Encoder.pyi", + "module": "Encoder" + }, + { + "file": "machine/I2C.pyi", + "module": "I2C" + }, + { + "file": "machine/I2CTarget.pyi", + "module": "I2CTarget" + }, + { + "file": "machine/I2S.pyi", + "module": "I2S" + }, + { + "file": "machine/PWM.pyi", + "module": "PWM" + }, + { + "file": "machine/Pin.pyi", + "module": "Pin" + }, + { + "file": "machine/RTC.pyi", + "module": "RTC" + }, + { + "file": "machine/SD.pyi", + "module": "SD" + }, + { + "file": "machine/SDCard.pyi", + "module": "SDCard" + }, + { + "file": "machine/SPI.pyi", + "module": "SPI" + }, + { + "file": "machine/Signal.pyi", + "module": "Signal" + }, + { + "file": "machine/Timer.pyi", + "module": "Timer" + }, + { + "file": "machine/TimerWiPy.pyi", + "module": "TimerWiPy" + }, + { + "file": "machine/UART.pyi", + "module": "UART" + }, + { + "file": "machine/USBDevice.pyi", + "module": "USBDevice" + }, + { + "file": "machine/WDT.pyi", + "module": "WDT" + }, + { + "file": "machine/__init__.pyi", + "module": "__init__" + }, + { + "file": "marshal/__init__.pyi", + "module": "__init__" + }, + { + "file": "math/__init__.pyi", + "module": "__init__" + }, + { + "file": "micropython/__init__.pyi", + "module": "__init__" + }, + { + "file": "neopixel/__init__.pyi", + "module": "__init__" + }, + { + "file": "network/LAN.pyi", + "module": "LAN" + }, + { + "file": "network/PPP.pyi", + "module": "PPP" + }, + { + "file": "network/WIZNET5K.pyi", + "module": "WIZNET5K" + }, + { + "file": "network/WLAN.pyi", + "module": "WLAN" + }, + { + "file": "network/WLANWiPy.pyi", + "module": "WLANWiPy" + }, + { + "file": "network/__init__.pyi", + "module": "__init__" + }, + { + "file": "openamp/__init__.pyi", + "module": "__init__" + }, + { + "file": "os/__init__.pyi", + "module": "__init__" + }, + { + "file": "platform/__init__.pyi", + "module": "__init__" + }, + { + "file": "pyb/ADC.pyi", + "module": "ADC" + }, + { + "file": "pyb/Accel.pyi", + "module": "Accel" + }, + { + "file": "pyb/CAN.pyi", + "module": "CAN" + }, + { + "file": "pyb/DAC.pyi", + "module": "DAC" + }, + { + "file": "pyb/ExtInt.pyi", + "module": "ExtInt" + }, + { + "file": "pyb/Flash.pyi", + "module": "Flash" + }, + { + "file": "pyb/I2C.pyi", + "module": "I2C" + }, + { + "file": "pyb/LCD.pyi", + "module": "LCD" + }, + { + "file": "pyb/LED.pyi", + "module": "LED" + }, + { + "file": "pyb/Pin.pyi", + "module": "Pin" + }, + { + "file": "pyb/RTC.pyi", + "module": "RTC" + }, + { + "file": "pyb/SPI.pyi", + "module": "SPI" + }, + { + "file": "pyb/Servo.pyi", + "module": "Servo" + }, + { + "file": "pyb/Switch.pyi", + "module": "Switch" + }, + { + "file": "pyb/Timer.pyi", + "module": "Timer" + }, + { + "file": "pyb/UART.pyi", + "module": "UART" + }, + { + "file": "pyb/USB_HID.pyi", + "module": "USB_HID" + }, + { + "file": "pyb/USB_VCP.pyi", + "module": "USB_VCP" + }, + { + "file": "pyb/__init__.pyi", + "module": "__init__" + }, + { + "file": "random/__init__.pyi", + "module": "__init__" + }, + { + "file": "rp2/DMA.pyi", + "module": "DMA" + }, + { + "file": "rp2/Flash.pyi", + "module": "Flash" + }, + { + "file": "rp2/PIO.pyi", + "module": "PIO" + }, + { + "file": "rp2/StateMachine.pyi", + "module": "StateMachine" + }, + { + "file": "rp2/__init__.pyi", + "module": "__init__" + }, + { + "file": "select/__init__.pyi", + "module": "__init__" + }, + { + "file": "socket/__init__.pyi", + "module": "__init__" + }, + { + "file": "ssl/__init__.pyi", + "module": "__init__" + }, + { + "file": "stm/__init__.pyi", + "module": "__init__" + }, + { + "file": "struct/__init__.pyi", + "module": "__init__" + }, + { + "file": "sys/__init__.pyi", + "module": "__init__" + }, + { + "file": "time/__init__.pyi", + "module": "__init__" + }, + { + "file": "uarray.pyi", + "module": "uarray" + }, + { + "file": "uasyncio.pyi", + "module": "uasyncio" + }, + { + "file": "ubinascii.pyi", + "module": "ubinascii" + }, + { + "file": "ubluetooth.pyi", + "module": "ubluetooth" + }, + { + "file": "uctypes/__init__.pyi", + "module": "__init__" + }, + { + "file": "uerrno.pyi", + "module": "uerrno" + }, + { + "file": "uio.pyi", + "module": "uio" + }, + { + "file": "ujson.pyi", + "module": "ujson" + }, + { + "file": "umachine.pyi", + "module": "umachine" + }, + { + "file": "uos.pyi", + "module": "uos" + }, + { + "file": "uplatform.pyi", + "module": "uplatform" + }, + { + "file": "uselect.pyi", + "module": "uselect" + }, + { + "file": "usocket.pyi", + "module": "usocket" + }, + { + "file": "ussl.pyi", + "module": "ussl" + }, + { + "file": "ustruct.pyi", + "module": "ustruct" + }, + { + "file": "usys.pyi", + "module": "usys" + }, + { + "file": "utime.pyi", + "module": "utime" + }, + { + "file": "uzlib.pyi", + "module": "uzlib" + }, + { + "file": "vfs/__init__.pyi", + "module": "__init__" + }, + { + "file": "wipy/__init__.pyi", + "module": "__init__" + }, + { + "file": "wm8960/__init__.pyi", + "module": "__init__" + }, + { + "file": "zephyr/DiskAccess.pyi", + "module": "DiskAccess" + }, + { + "file": "zephyr/FlashArea.pyi", + "module": "FlashArea" + }, + { + "file": "zephyr/__init__.pyi", + "module": "__init__" + }, + { + "file": "zephyr/zsensor.pyi", + "module": "zsensor" + }, + { + "file": "zlib/__init__.pyi", + "module": "__init__" + } + ] +} \ No newline at end of file diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ds18x20.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ds18x20.pyi new file mode 100644 index 0000000000..88ec225808 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ds18x20.pyi @@ -0,0 +1,18 @@ +""" +Module: 'ds18x20' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def const(*args, **kwargs) -> Incomplete: ... + +class DS18X20: + def read_scratch(self, *args, **kwargs) -> Incomplete: ... + def read_temp(self, *args, **kwargs) -> Incomplete: ... + def write_scratch(self, *args, **kwargs) -> Incomplete: ... + def convert_temp(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/errno.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/errno.pyi new file mode 100644 index 0000000000..1910b435fe --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/errno.pyi @@ -0,0 +1,97 @@ +""" +System error codes. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/errno.html + +CPython module: :mod:`python:errno` https://docs.python.org/3/library/errno.html . + +This module provides access to symbolic error codes for `OSError` exception. +A particular inventory of codes depends on :term:`MicroPython port`. + +--- +Module: 'errno' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Dict, Final +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar + +ENOBUFS: Final[int] = 105 +"""No buffer space available""" +ENODEV: Final[int] = 19 +"""No such device""" +ENOENT: Final[int] = 2 +"""No such file or directory""" +EISDIR: Final[int] = 21 +"""Is a directory""" +EIO: Final[int] = 5 +"""I/O error""" +EINVAL: Final[int] = 22 +"""Invalid argument""" +EPERM: Final[int] = 1 +"""Operation not permitted""" +ETIMEDOUT: Final[int] = 110 +"""Connection timed out""" +ENOMEM: Final[int] = 12 +"""Out of memory""" +EOPNOTSUPP: Final[int] = 95 +"""Operation not supported""" +ENOTCONN: Final[int] = 107 +"""Transport endpoint is not connected""" +errorcode: dict = {} +"""\ +Dictionary mapping numeric error codes to strings with symbolic error +code (see above):: + +>>> print(errno.errorcode[errno.EEXIST]) +EEXIST +""" +EAGAIN: Final[int] = 11 +"""\ +Error codes, based on ANSI C/POSIX standard. All error codes start with +"E". As mentioned above, inventory of the codes depends on +:term:`MicroPython port`. Errors are usually accessible as ``exc.errno`` +where ``exc`` is an instance of `OSError`. Usage example:: + +try: +os.mkdir("my_dir") +except OSError as exc: +if exc.errno == errno.EEXIST: +print("Directory already exists") +""" +EALREADY: Final[int] = 114 +"""Operation already in progress""" +EBADF: Final[int] = 9 +"""Bad file descriptor""" +EADDRINUSE: Final[int] = 98 +"""Address already in use""" +EACCES: Final[int] = 13 +"""Permission denied""" +EINPROGRESS: Final[int] = 115 +"""Operation now in progress""" +EEXIST: Final[int] = 17 +"""\ +Error codes, based on ANSI C/POSIX standard. All error codes start with +"E". As mentioned above, inventory of the codes depends on +:term:`MicroPython port`. Errors are usually accessible as ``exc.errno`` +where ``exc`` is an instance of `OSError`. Usage example:: + +try: +os.mkdir("my_dir") +except OSError as exc: +if exc.errno == errno.EEXIST: +print("Directory already exists") +""" +EHOSTUNREACH: Final[int] = 113 +"""Host is unreachable""" +ECONNABORTED: Final[int] = 103 +"""Connection aborted""" +ECONNRESET: Final[int] = 104 +"""Connection reset by peer""" +ECONNREFUSED: Final[int] = 111 +"""Connection refused""" +ENOTSUP: Final[int] = ... +"""Operation not supported""" diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/firmware_stubs.json b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/firmware_stubs.json new file mode 100644 index 0000000000..07e0641998 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/firmware_stubs.json @@ -0,0 +1,95 @@ +{"firmware": {"mpy": "v6.3", "build": "", "ver": "1.27.0", "arch": "armv6m", "version": "1.27.0", "port": "rp2", "board": "RPI_PICO_W", "family": "micropython", "board_id": "RPI_PICO_W", "variant": "", "cpu": "RP2040"}, +"stubber": {"version": "v1.26.5"}, "stubtype": "firmware", +"modules" :[ +{"module": "_asyncio", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_asyncio.pyi"}, +{"module": "_boot_fat", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_boot_fat.pyi"}, +{"module": "_onewire", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_onewire.pyi"}, +{"module": "_rp2", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_rp2.pyi"}, +{"module": "_thread", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_thread.pyi"}, +{"module": "aioble.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/__init__.pyi"}, +{"module": "aioble.central", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/central.pyi"}, +{"module": "aioble.client", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/client.pyi"}, +{"module": "aioble.core", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/core.pyi"}, +{"module": "aioble.device", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/device.pyi"}, +{"module": "aioble.l2cap", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/l2cap.pyi"}, +{"module": "aioble.peripheral", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/peripheral.pyi"}, +{"module": "aioble.security", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/security.pyi"}, +{"module": "aioble.server", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/server.pyi"}, +{"module": "array", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/array.pyi"}, +{"module": "asyncio.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/__init__.pyi"}, +{"module": "asyncio.core", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/core.pyi"}, +{"module": "asyncio.event", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/event.pyi"}, +{"module": "asyncio.funcs", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/funcs.pyi"}, +{"module": "asyncio.lock", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/lock.pyi"}, +{"module": "asyncio.stream", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/stream.pyi"}, +{"module": "binascii", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/binascii.pyi"}, +{"module": "bluetooth", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/bluetooth.pyi"}, +{"module": "builtins", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/builtins.pyi"}, +{"module": "cmath", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cmath.pyi"}, +{"module": "collections", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/collections.pyi"}, +{"module": "cryptolib", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cryptolib.pyi"}, +{"module": "deflate", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/deflate.pyi"}, +{"module": "dht", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/dht.pyi"}, +{"module": "ds18x20", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ds18x20.pyi"}, +{"module": "errno", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/errno.pyi"}, +{"module": "framebuf", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/framebuf.pyi"}, +{"module": "gc", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/gc.pyi"}, +{"module": "hashlib", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/hashlib.pyi"}, +{"module": "heapq", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/heapq.pyi"}, +{"module": "io", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/io.pyi"}, +{"module": "json", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/json.pyi"}, +{"module": "lwip", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/lwip.pyi"}, +{"module": "machine", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/machine.pyi"}, +{"module": "math", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/math.pyi"}, +{"module": "micropython", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/micropython.pyi"}, +{"module": "mip", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip.pyi"}, +{"module": "mip.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip/__init__.pyi"}, +{"module": "neopixel", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/neopixel.pyi"}, +{"module": "network", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/network.pyi"}, +{"module": "ntptime", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ntptime.pyi"}, +{"module": "onewire", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/onewire.pyi"}, +{"module": "os", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/os.pyi"}, +{"module": "platform", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/platform.pyi"}, +{"module": "random", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/random.pyi"}, +{"module": "requests", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests.pyi"}, +{"module": "requests.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests/__init__.pyi"}, +{"module": "rp2", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/rp2.pyi"}, +{"module": "select", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/select.pyi"}, +{"module": "socket", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/socket.pyi"}, +{"module": "ssl", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ssl.pyi"}, +{"module": "struct", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/struct.pyi"}, +{"module": "sys", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/sys.pyi"}, +{"module": "time", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/time.pyi"}, +{"module": "tls", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/tls.pyi"}, +{"module": "uarray", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uarray.pyi"}, +{"module": "uasyncio.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/__init__.pyi"}, +{"module": "uasyncio.core", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/core.pyi"}, +{"module": "uasyncio.event", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/event.pyi"}, +{"module": "uasyncio.funcs", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/funcs.pyi"}, +{"module": "uasyncio.lock", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/lock.pyi"}, +{"module": "uasyncio.stream", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/stream.pyi"}, +{"module": "ubinascii", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubinascii.pyi"}, +{"module": "ubluetooth", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubluetooth.pyi"}, +{"module": "ucollections", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucollections.pyi"}, +{"module": "ucryptolib", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucryptolib.pyi"}, +{"module": "uctypes", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uctypes.pyi"}, +{"module": "uerrno", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uerrno.pyi"}, +{"module": "uhashlib", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uhashlib.pyi"}, +{"module": "uheapq", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uheapq.pyi"}, +{"module": "uio", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uio.pyi"}, +{"module": "ujson", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ujson.pyi"}, +{"module": "umachine", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/umachine.pyi"}, +{"module": "uos", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uos.pyi"}, +{"module": "uplatform", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uplatform.pyi"}, +{"module": "urandom", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urandom.pyi"}, +{"module": "ure", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ure.pyi"}, +{"module": "urequests", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urequests.pyi"}, +{"module": "uselect", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uselect.pyi"}, +{"module": "usocket", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usocket.pyi"}, +{"module": "ustruct", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ustruct.pyi"}, +{"module": "usys", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usys.pyi"}, +{"module": "utime", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/utime.pyi"}, +{"module": "uwebsocket", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uwebsocket.pyi"}, +{"module": "vfs", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/vfs.pyi"}, +{"module": "websocket", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/websocket.pyi"} +]} \ No newline at end of file diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/framebuf.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/framebuf.pyi new file mode 100644 index 0000000000..50b24ec360 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/framebuf.pyi @@ -0,0 +1,247 @@ +""" +Frame buffer manipulation. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/framebuf.html + +This module provides a general frame buffer which can be used to create +bitmap images, which can then be sent to a display. + +--- +Module: 'framebuf' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Optional, Union, overload, Final +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf +from typing_extensions import Awaitable, TypeAlias, TypeVar + +MONO_HMSB: Final[int] = 4 +"""\ +Monochrome (1-bit) color format +This defines a mapping where the bits in a byte are horizontally mapped. +Each byte occupies 8 horizontal pixels with bit 0 being the leftmost. +Subsequent bytes appear at successive horizontal locations until the +rightmost edge is reached. Further bytes are rendered on the next row, one +pixel lower. +""" +MONO_HLSB: Final[int] = 3 +"""\ +Monochrome (1-bit) color format +This defines a mapping where the bits in a byte are horizontally mapped. +Each byte occupies 8 horizontal pixels with bit 7 being the leftmost. +Subsequent bytes appear at successive horizontal locations until the +rightmost edge is reached. Further bytes are rendered on the next row, one +pixel lower. +""" +RGB565: Final[int] = 1 +"""Red Green Blue (16-bit, 5+6+5) color format""" +MONO_VLSB: Final[int] = 0 +"""\ +Monochrome (1-bit) color format +This defines a mapping where the bits in a byte are vertically mapped with +bit 0 being nearest the top of the screen. Consequently each byte occupies +8 vertical pixels. Subsequent bytes appear at successive horizontal +locations until the rightmost edge is reached. Further bytes are rendered +at locations starting at the leftmost edge, 8 pixels lower. +""" +MVLSB: Final[int] = 0 +GS2_HMSB: Final[int] = 5 +"""Grayscale (2-bit) color format""" +GS8: Final[int] = 6 +"""Grayscale (8-bit) color format""" +GS4_HMSB: Final[int] = 2 +"""Grayscale (4-bit) color format""" + +def FrameBuffer1(*args, **kwargs) -> Incomplete: ... + +class FrameBuffer: + """ + The FrameBuffer class provides a pixel buffer which can be drawn upon with + pixels, lines, rectangles, text and even other FrameBuffer's. It is useful + when generating output for displays. + + For example:: + + import framebuf + + # FrameBuffer needs 2 bytes for every RGB565 pixel + fbuf = framebuf.FrameBuffer(bytearray(100 * 10 * 2), 100, 10, framebuf.RGB565) + + fbuf.fill(0) + fbuf.text('MicroPython!', 0, 0, 0xffff) + fbuf.hline(0, 9, 96, 0xffff) + """ + def poly(self, x, y, coords, c, f: Union[bool, int] = False, /) -> Incomplete: + """ + Given a list of coordinates, draw an arbitrary (convex or concave) closed + polygon at the given x, y location using the given color. + + The *coords* must be specified as a :mod:`array` of integers, e.g. + ``array('h', [x0, y0, x1, y1, ... xn, yn])``. + + The optional *f* parameter can be set to ``True`` to fill the polygon. + Otherwise just a one pixel outline is drawn. + """ + ... + def vline(self, x: int, y: int, h: int, c: int, /) -> None: + """ + Draw a line from a set of coordinates using the given color and + a thickness of 1 pixel. The `line` method draws the line up to + a second set of coordinates whereas the `hline` and `vline` + methods draw horizontal and vertical lines respectively up to + a given length. + """ + ... + + @overload + def pixel(self, x: int, y: int, /) -> int: + """ + If *c* is not given, get the color value of the specified pixel. + If *c* is given, set the specified pixel to the given color. + """ + + @overload + def pixel(self, x: int, y: int, c: int, /) -> None: + """ + If *c* is not given, get the color value of the specified pixel. + If *c* is given, set the specified pixel to the given color. + """ + def text(self, s: str, x: int, y: int, c: int = 1, /) -> None: + """ + Write text to the FrameBuffer using the coordinates as the upper-left + corner of the text. The color of the text can be defined by the optional + argument but is otherwise a default value of 1. All characters have + dimensions of 8x8 pixels and there is currently no way to change the font. + """ + ... + def rect(self, x: int, y: int, w: int, h: int, c: int, f: Union[bool, int] = False, /) -> None: + """ + Draw a rectangle at the given location, size and color. + + The optional *f* parameter can be set to ``True`` to fill the rectangle. + Otherwise just a one pixel outline is drawn. + """ + ... + def scroll(self, xstep: int, ystep: int, /) -> None: + """ + Shift the contents of the FrameBuffer by the given vector. This may + leave a footprint of the previous colors in the FrameBuffer. + """ + ... + def ellipse(self, x, y, xr, yr, c, f: Union[bool, int] = False, m: Optional[int] = None) -> None: + """ + Draw an ellipse at the given location. Radii *xr* and *yr* define the + geometry; equal values cause a circle to be drawn. The *c* parameter + defines the color. + + The optional *f* parameter can be set to ``True`` to fill the ellipse. + Otherwise just a one pixel outline is drawn. + + The optional *m* parameter enables drawing to be restricted to certain + quadrants of the ellipse. The LS four bits determine which quadrants are + to be drawn, with bit 0 specifying Q1, b1 Q2, b2 Q3 and b3 Q4. Quadrants + are numbered counterclockwise with Q1 being top right. + """ + ... + def line(self, x1: int, y1: int, x2: int, y2: int, c: int, /) -> None: + """ + Draw a line from a set of coordinates using the given color and + a thickness of 1 pixel. The `line` method draws the line up to + a second set of coordinates whereas the `hline` and `vline` + methods draw horizontal and vertical lines respectively up to + a given length. + """ + ... + def blit( + self, + fbuf: FrameBuffer, + x: int, + y: int, + key: int = -1, + palette: Optional[bytes] = None, + /, + ) -> None: + """ + Draw another FrameBuffer on top of the current one at the given coordinates. + If *key* is specified then it should be a color integer and the + corresponding color will be considered transparent: all pixels with that + color value will not be drawn. (If the *palette* is specified then the *key* + is compared to the value from *palette*, not to the value directly from + *fbuf*.) + + *fbuf* can be another FrameBuffer instance, or a tuple or list of the form:: + + (buffer, width, height, format) + + or:: + + (buffer, width, height, format, stride) + + This matches the signature of the FrameBuffer constructor, and the elements + of the tuple/list are the same as the arguments to the constructor except that + the *buffer* here can be read-only. + + The *palette* argument enables blitting between FrameBuffers with differing + formats. Typical usage is to render a monochrome or grayscale glyph/icon to + a color display. The *palette* is a FrameBuffer instance whose format is + that of the current FrameBuffer. The *palette* height is one pixel and its + pixel width is the number of colors in the source FrameBuffer. The *palette* + for an N-bit source needs 2**N pixels; the *palette* for a monochrome source + would have 2 pixels representing background and foreground colors. The + application assigns a color to each pixel in the *palette*. The color of the + current pixel will be that of that *palette* pixel whose x position is the + color of the corresponding source pixel. + """ + ... + def hline(self, x: int, y: int, w: int, c: int, /) -> None: + """ + Draw a line from a set of coordinates using the given color and + a thickness of 1 pixel. The `line` method draws the line up to + a second set of coordinates whereas the `hline` and `vline` + methods draw horizontal and vertical lines respectively up to + a given length. + """ + ... + def fill(self, c: int, /) -> None: + """ + Fill the entire FrameBuffer with the specified color. + """ + ... + def fill_rect(self, *args, **kwargs) -> Incomplete: ... + def __init__( + self, + buffer: AnyWritableBuf, + width: int, + height: int, + format: int, + stride: int = ..., + /, + ) -> None: + """ + Construct a FrameBuffer object. The parameters are: + + - *buffer* is an object with a buffer protocol which must be large + enough to contain every pixel defined by the width, height and + format of the FrameBuffer. + - *width* is the width of the FrameBuffer in pixels + - *height* is the height of the FrameBuffer in pixels + - *format* specifies the type of pixel used in the FrameBuffer; + permissible values are listed under Constants below. These set the + number of bits used to encode a color value and the layout of these + bits in *buffer*. + Where a color value c is passed to a method, c is a small integer + with an encoding that is dependent on the format of the FrameBuffer. + - *stride* is the number of pixels between each horizontal line + of pixels in the FrameBuffer. This defaults to *width* but may + need adjustments when implementing a FrameBuffer within another + larger FrameBuffer or screen. The *buffer* size must accommodate + an increased step size. + + One must specify valid *buffer*, *width*, *height*, *format* and + optionally *stride*. Invalid *buffer* size or dimensions may lead to + unexpected errors. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/gc.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/gc.pyi new file mode 100644 index 0000000000..d1a11bbe1e --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/gc.pyi @@ -0,0 +1,112 @@ +""" +Control the garbage collector. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/gc.html + +CPython module: :mod:`python:gc` https://docs.python.org/3/library/gc.html . + +--- +Module: 'gc' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import overload +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def mem_alloc() -> int: + """ + Return the number of bytes of heap RAM that are allocated by Python code. + + Admonition:Difference to CPython + :class: attention + + This function is MicroPython extension. + """ + ... + +def isenabled(*args, **kwargs) -> Incomplete: ... +def mem_free() -> int: + """ + Return the number of bytes of heap RAM that is available for Python + code to allocate, or -1 if this amount is not known. + + Admonition:Difference to CPython + :class: attention + + This function is MicroPython extension. + """ + ... + +@overload +def threshold() -> int: + """ + Set or query the additional GC allocation threshold. Normally, a collection + is triggered only when a new allocation cannot be satisfied, i.e. on an + out-of-memory (OOM) condition. If this function is called, in addition to + OOM, a collection will be triggered each time after *amount* bytes have been + allocated (in total, since the previous time such an amount of bytes + have been allocated). *amount* is usually specified as less than the + full heap size, with the intention to trigger a collection earlier than when the + heap becomes exhausted, and in the hope that an early collection will prevent + excessive memory fragmentation. This is a heuristic measure, the effect + of which will vary from application to application, as well as + the optimal value of the *amount* parameter. + + Calling the function without argument will return the current value of + the threshold. A value of -1 means a disabled allocation threshold. + + Admonition:Difference to CPython + :class: attention + + This function is a MicroPython extension. CPython has a similar + function - ``set_threshold()``, but due to different GC + implementations, its signature and semantics are different. + """ + +@overload +def threshold(amount: int) -> None: + """ + Set or query the additional GC allocation threshold. Normally, a collection + is triggered only when a new allocation cannot be satisfied, i.e. on an + out-of-memory (OOM) condition. If this function is called, in addition to + OOM, a collection will be triggered each time after *amount* bytes have been + allocated (in total, since the previous time such an amount of bytes + have been allocated). *amount* is usually specified as less than the + full heap size, with the intention to trigger a collection earlier than when the + heap becomes exhausted, and in the hope that an early collection will prevent + excessive memory fragmentation. This is a heuristic measure, the effect + of which will vary from application to application, as well as + the optimal value of the *amount* parameter. + + Calling the function without argument will return the current value of + the threshold. A value of -1 means a disabled allocation threshold. + + Admonition:Difference to CPython + :class: attention + + This function is a MicroPython extension. CPython has a similar + function - ``set_threshold()``, but due to different GC + implementations, its signature and semantics are different. + """ + +def collect() -> None: + """ + Run a garbage collection. + """ + ... + +def enable() -> None: + """ + Enable automatic garbage collection. + """ + ... + +def disable() -> None: + """ + Disable automatic garbage collection. Heap memory can still be allocated, + and garbage collection can still be initiated manually using :meth:`gc.collect`. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/hashlib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/hashlib.pyi new file mode 100644 index 0000000000..b1736a430c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/hashlib.pyi @@ -0,0 +1,116 @@ +""" +Hashing algorithms. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/hashlib.html + +CPython module: :mod:`python:hashlib` https://docs.python.org/3/library/hashlib.html . + +This module implements binary data hashing algorithms. The exact inventory +of available algorithms depends on a board. Among the algorithms which may +be implemented: + +* SHA256 - The current generation, modern hashing algorithm (of SHA2 series). + It is suitable for cryptographically-secure purposes. Included in the + MicroPython core and any board is recommended to provide this, unless + it has particular code size constraints. + +* SHA1 - A previous generation algorithm. Not recommended for new usages, + but SHA1 is a part of number of Internet standards and existing + applications, so boards targeting network connectivity and + interoperability will try to provide this. + +* MD5 - A legacy algorithm, not considered cryptographically secure. Only + selected boards, targeting interoperability with legacy applications, + will offer this. + +--- +Module: 'hashlib' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf, _Hash +from typing import NoReturn, overload +from typing_extensions import Awaitable, TypeAlias, TypeVar, deprecated + +class sha1(_Hash): + """ + A previous generation algorithm. Not recommended for new usages, + but SHA1 is a part of number of Internet standards and existing + applications, so boards targeting network connectivity and + interoperability will try to provide this. + """ + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + @overload + def __init__(self): + """ + Create an SHA1 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self, data: AnyReadableBuf): + """ + Create an SHA1 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self): + """ + Create an SHA1 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self, data: AnyReadableBuf): + """ + Create an SHA1 hasher object and optionally feed ``data`` into it. + """ + +class sha256(_Hash): + """ + The current generation, modern hashing algorithm (of SHA2 series). + It is suitable for cryptographically-secure purposes. Included in the + MicroPython core and any board is recommended to provide this, unless + it has particular code size constraints. + """ + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + @overload + def __init__(self): + """ + Create an SHA256 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self, data: AnyReadableBuf): + """ + Create an SHA256 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self): + """ + Create an SHA256 hasher object and optionally feed ``data`` into it. + """ + + @overload + def __init__(self, data: AnyReadableBuf): + """ + Create an SHA256 hasher object and optionally feed ``data`` into it. + """ + +class md5(_Hash): + """ + A legacy algorithm, not considered cryptographically secure. Only + selected boards, targeting interoperability with legacy applications, + will offer this. + """ + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, data: AnyReadableBuf = ..., /) -> None: + """ + Create an MD5 hasher object and optionally feed ``data`` into it. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/heapq.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/heapq.pyi new file mode 100644 index 0000000000..e405e4d2e1 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/heapq.pyi @@ -0,0 +1,46 @@ +""" +Heap queue algorithm. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/heapq.html + +CPython module: :mod:`python:heapq` https://docs.python.org/3/library/heapq.html . + +This module implements the +`min heap queue algorithm `_. + +A heap queue is essentially a list that has its elements stored in such a way +that the first item of the list is always the smallest. + +--- +Module: 'heapq' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import Any +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_T = TypeVar("_T") + +def heappop(heap: list[_T], /) -> _T: + """ + Pop the first item from the ``heap``, and return it. Raise ``IndexError`` if + ``heap`` is empty. + + The returned item will be the smallest item in the ``heap``. + """ + ... + +def heappush(heap: list[_T], item: _T, /) -> None: + """ + Push the ``item`` onto the ``heap``. + """ + ... + +def heapify(x: list[Any], /) -> None: + """ + Convert the list ``x`` into a heap. This is an in-place operation. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/lwip.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/lwip.pyi new file mode 100644 index 0000000000..b98a8fcb8a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/lwip.pyi @@ -0,0 +1,51 @@ +""" +Module: 'lwip' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +SOCK_RAW: Final[int] = 3 +SOCK_STREAM: Final[int] = 1 +SOCK_DGRAM: Final[int] = 2 +MSG_PEEK: Final[int] = 1 +SO_REUSEADDR: Final[int] = 4 +SOL_SOCKET: Final[int] = 1 +SO_BROADCAST: Final[int] = 32 +TCP_NODELAY: Final[int] = 64 +AF_INET6: Final[int] = 10 +IPPROTO_IP: Final[int] = 0 +AF_INET: Final[int] = 2 +MSG_DONTWAIT: Final[int] = 2 +IP_DROP_MEMBERSHIP: Final[int] = 1025 +IPPROTO_TCP: Final[int] = 6 +IP_ADD_MEMBERSHIP: Final[int] = 1024 + +def reset(*args, **kwargs) -> Incomplete: ... +def print_pcbs(*args, **kwargs) -> Incomplete: ... +def getaddrinfo(*args, **kwargs) -> Incomplete: ... +def callback(*args, **kwargs) -> Incomplete: ... + +class socket: + def recvfrom(self, *args, **kwargs) -> Incomplete: ... + def recv(self, *args, **kwargs) -> Incomplete: ... + def makefile(self, *args, **kwargs) -> Incomplete: ... + def listen(self, *args, **kwargs) -> Incomplete: ... + def settimeout(self, *args, **kwargs) -> Incomplete: ... + def sendall(self, *args, **kwargs) -> Incomplete: ... + def setsockopt(self, *args, **kwargs) -> Incomplete: ... + def setblocking(self, *args, **kwargs) -> Incomplete: ... + def sendto(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def connect(self, *args, **kwargs) -> Incomplete: ... + def send(self, *args, **kwargs) -> Incomplete: ... + def bind(self, *args, **kwargs) -> Incomplete: ... + def accept(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/machine.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/machine.pyi new file mode 100644 index 0000000000..bf569c1c80 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/machine.pyi @@ -0,0 +1,3206 @@ +""" +Functions related to the hardware. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/machine.html + +The ``machine`` module contains specific functions related to the hardware +on a particular board. Most functions in this module allow to achieve direct +and unrestricted access to and control of hardware blocks on a system +(like CPU, timers, buses, etc.). Used incorrectly, this can lead to +malfunction, lockups, crashes of your board, and in extreme cases, hardware +damage. + +--- +Module: 'machine' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import NoReturn, Union, Tuple, Callable, List, Sequence, Any, Optional, overload, Final +from _typeshed import Incomplete +from _mpy_shed import _IRQ, AnyReadableBuf, AnyWritableBuf, mp_available +from typing_extensions import Awaitable, TypeAlias, TypeVar, deprecated +from vfs import AbstractBlockDev + +PWRON_RESET: Final[int] = 1 +"""Reset causes.""" +WDT_RESET: Final[int] = 3 +"""Reset causes.""" +ATTN_0DB: int = ... +ID_T: TypeAlias = int | str +PinLike: TypeAlias = Pin | int | str +IDLE: Incomplete +"""IRQ wake values.""" +SLEEP: Incomplete +"""IRQ wake values.""" +DEEPSLEEP: Incomplete +"""IRQ wake values.""" +HARD_RESET: Incomplete +"""Reset causes.""" +DEEPSLEEP_RESET: Incomplete +"""Reset causes.""" +SOFT_RESET: Incomplete +"""Reset causes.""" +WLAN_WAKE: Incomplete +"""Wake-up reasons.""" +PIN_WAKE: Incomplete +"""Wake-up reasons.""" +RTC_WAKE: Incomplete +"""Wake-up reasons.""" +_IRQ_STATE: TypeAlias = int + +def dht_readinto(*args, **kwargs) -> Incomplete: ... +def disable_irq() -> _IRQ_STATE: + """ + Disable interrupt requests. + Returns the previous IRQ state which should be considered an opaque value. + This return value should be passed to the `enable_irq()` function to restore + interrupts to their original state, before `disable_irq()` was called. + """ + ... + +def enable_irq(state: _IRQ_STATE, /) -> None: + """ + Re-enable interrupt requests. + The *state* parameter should be the value that was returned from the most + recent call to the `disable_irq()` function. + """ + ... + +def bitstream(pin, encoding, timing, data, /) -> Incomplete: + """ + Transmits *data* by bit-banging the specified *pin*. The *encoding* argument + specifies how the bits are encoded, and *timing* is an encoding-specific timing + specification. + + The supported encodings are: + + - ``0`` for "high low" pulse duration modulation. This will transmit 0 and + 1 bits as timed pulses, starting with the most significant bit. + The *timing* must be a four-tuple of nanoseconds in the format + ``(high_time_0, low_time_0, high_time_1, low_time_1)``. For example, + ``(400, 850, 800, 450)`` is the timing specification for WS2812 RGB LEDs + at 800kHz. + + The accuracy of the timing varies between ports. On Cortex M0 at 48MHz, it is + at best +/- 120ns, however on faster MCUs (ESP8266, ESP32, STM32, Pyboard), it + will be closer to +/-30ns. + + ``Note:`` For controlling WS2812 / NeoPixel strips, see the :mod:`neopixel` + module for a higher-level API. + """ + ... + +@overload +def deepsleep() -> NoReturn: + """ + Stops execution in an attempt to enter a low power state. + + If *time_ms* is specified then this will be the maximum time in milliseconds that + the sleep will last for. Otherwise the sleep can last indefinitely. + + With or without a timeout, execution may resume at any time if there are events + that require processing. Such events, or wake sources, should be configured before + sleeping, like `Pin` change or `RTC` timeout. + + The precise behaviour and power-saving capabilities of lightsleep and deepsleep is + highly dependent on the underlying hardware, but the general properties are: + + * A lightsleep has full RAM and state retention. Upon wake execution is resumed + from the point where the sleep was requested, with all subsystems operational. + + * A deepsleep may not retain RAM or any other state of the system (for example + peripherals or network interfaces). Upon wake execution is resumed from the main + script, similar to a hard or power-on reset. The `reset_cause()` function will + return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake + from other resets. + """ + +@overload +def deepsleep(time_ms: int, /) -> NoReturn: + """ + Stops execution in an attempt to enter a low power state. + + If *time_ms* is specified then this will be the maximum time in milliseconds that + the sleep will last for. Otherwise the sleep can last indefinitely. + + With or without a timeout, execution may resume at any time if there are events + that require processing. Such events, or wake sources, should be configured before + sleeping, like `Pin` change or `RTC` timeout. + + The precise behaviour and power-saving capabilities of lightsleep and deepsleep is + highly dependent on the underlying hardware, but the general properties are: + + * A lightsleep has full RAM and state retention. Upon wake execution is resumed + from the point where the sleep was requested, with all subsystems operational. + + * A deepsleep may not retain RAM or any other state of the system (for example + peripherals or network interfaces). Upon wake execution is resumed from the main + script, similar to a hard or power-on reset. The `reset_cause()` function will + return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake + from other resets. + """ + +def bootloader(value: Optional[Any] = None) -> None: + """ + Reset the device and enter its bootloader. This is typically used to put the + device into a state where it can be programmed with new firmware. + + Some ports support passing in an optional *value* argument which can control + which bootloader to enter, what to pass to it, or other things. + """ + ... + +def unique_id() -> bytes: + """ + Returns a byte string with a unique identifier of a board/SoC. It will vary + from a board/SoC instance to another, if underlying hardware allows. Length + varies by hardware (so use substring of a full value if you expect a short + ID). In some MicroPython ports, ID corresponds to the network MAC address. + """ + ... + +def soft_reset() -> NoReturn: + """ + Performs a :ref:`soft reset ` of the interpreter, deleting all + Python objects and resetting the Python heap. + """ + ... + +def reset_cause() -> int: + """ + Get the reset cause. See :ref:`constants ` for the possible return values. + """ + ... + +def time_pulse_us(pin: Pin, pulse_level: int, timeout_us: int = 1_000_000, /) -> int: + """ + Time a pulse on the given *pin*, and return the duration of the pulse in + microseconds. The *pulse_level* argument should be 0 to time a low pulse + or 1 to time a high pulse. + + If the current input value of the pin is different to *pulse_level*, + the function first (*) waits until the pin input becomes equal to *pulse_level*, + then (**) times the duration that the pin is equal to *pulse_level*. + If the pin is already equal to *pulse_level* then timing starts straight away. + + The function will return -2 if there was timeout waiting for condition marked + (*) above, and -1 if there was timeout during the main measurement, marked (**) + above. The timeout is the same for both cases and given by *timeout_us* (which + is in microseconds). + """ + ... + +@overload +def freq() -> int: + """ + Returns the CPU frequency in hertz. + + On some ports this can also be used to set the CPU frequency by passing in *hz*. + """ + +@overload +def freq(hz: int, /) -> None: + """ + Returns the CPU frequency in hertz. + + On some ports this can also be used to set the CPU frequency by passing in *hz*. + """ + +@overload +def freq(self) -> int: + """ + Returns the CPU frequency in hertz. + + On some ports this can also be used to set the CPU frequency by passing in *hz*. + """ + +@overload +def freq( + self, + value: int, + /, +) -> None: + """ + Returns the CPU frequency in hertz. + + On some ports this can also be used to set the CPU frequency by passing in *hz*. + """ + +def idle() -> None: + """ + Gates the clock to the CPU, useful to reduce power consumption at any time + during short or long periods. Peripherals continue working and execution + resumes as soon as any interrupt is triggered, or at most one millisecond + after the CPU was paused. + + It is recommended to call this function inside any tight loop that is + continuously checking for an external change (i.e. polling). This will reduce + power consumption without significantly impacting performance. To reduce + power consumption further then see the :func:`lightsleep`, + :func:`time.sleep()` and :func:`time.sleep_ms()` functions. + """ + ... + +def reset() -> NoReturn: + """ + :ref:`Hard resets ` the device in a manner similar to pushing the + external RESET button. + """ + ... + +@overload +def lightsleep() -> None: + """ + Stops execution in an attempt to enter a low power state. + + If *time_ms* is specified then this will be the maximum time in milliseconds that + the sleep will last for. Otherwise the sleep can last indefinitely. + + With or without a timeout, execution may resume at any time if there are events + that require processing. Such events, or wake sources, should be configured before + sleeping, like `Pin` change or `RTC` timeout. + + The precise behaviour and power-saving capabilities of lightsleep and deepsleep is + highly dependent on the underlying hardware, but the general properties are: + + * A lightsleep has full RAM and state retention. Upon wake execution is resumed + from the point where the sleep was requested, with all subsystems operational. + + * A deepsleep may not retain RAM or any other state of the system (for example + peripherals or network interfaces). Upon wake execution is resumed from the main + script, similar to a hard or power-on reset. The `reset_cause()` function will + return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake + from other resets. + """ + +@overload +def lightsleep(time_ms: int, /) -> None: + """ + Stops execution in an attempt to enter a low power state. + + If *time_ms* is specified then this will be the maximum time in milliseconds that + the sleep will last for. Otherwise the sleep can last indefinitely. + + With or without a timeout, execution may resume at any time if there are events + that require processing. Such events, or wake sources, should be configured before + sleeping, like `Pin` change or `RTC` timeout. + + The precise behaviour and power-saving capabilities of lightsleep and deepsleep is + highly dependent on the underlying hardware, but the general properties are: + + * A lightsleep has full RAM and state retention. Upon wake execution is resumed + from the point where the sleep was requested, with all subsystems operational. + + * A deepsleep may not retain RAM or any other state of the system (for example + peripherals or network interfaces). Upon wake execution is resumed from the main + script, similar to a hard or power-on reset. The `reset_cause()` function will + return `machine.DEEPSLEEP` and this can be used to distinguish a deepsleep wake + from other resets. + """ + +mem8: Incomplete ## = <8-bit memory> +"""Read/write 8 bits of memory.""" +mem32: Incomplete ## = <32-bit memory> +"""\ +Read/write 32 bits of memory. + +Use subscript notation ``[...]`` to index these objects with the address of +interest. Note that the address is the byte address, regardless of the size of +memory being accessed. + +Example use (registers are specific to an stm32 microcontroller): +""" +mem16: Incomplete ## = <16-bit memory> +"""Read/write 16 bits of memory.""" + +class PWM: + """ + This class provides pulse width modulation output. + + Example usage:: + + from machine import PWM + + pwm = PWM(pin) # create a PWM object on a pin + pwm.duty_u16(32768) # set duty to 50% + + # reinitialise with a period of 200us, duty of 5us + pwm.init(freq=5000, duty_ns=5000) + + pwm.duty_ns(3000) # set pulse width to 3us + + pwm.deinit() + + + Limitations of PWM + ------------------ + + * Not all frequencies can be generated with absolute accuracy due to + the discrete nature of the computing hardware. Typically the PWM frequency + is obtained by dividing some integer base frequency by an integer divider. + For example, if the base frequency is 80MHz and the required PWM frequency is + 300kHz the divider must be a non-integer number 80000000 / 300000 = 266.67. + After rounding the divider is set to 267 and the PWM frequency will be + 80000000 / 267 = 299625.5 Hz, not 300kHz. If the divider is set to 266 then + the PWM frequency will be 80000000 / 266 = 300751.9 Hz, but again not 300kHz. + + * The duty cycle has the same discrete nature and its absolute accuracy is not + achievable. On most hardware platforms the duty will be applied at the next + frequency period. Therefore, you should wait more than "1/frequency" before + measuring the duty. + + * The frequency and the duty cycle resolution are usually interdependent. + The higher the PWM frequency the lower the duty resolution which is available, + and vice versa. For example, a 300kHz PWM frequency can have a duty cycle + resolution of 8 bit, not 16-bit as may be expected. In this case, the lowest + 8 bits of *duty_u16* are insignificant. So:: + + pwm=PWM(Pin(13), freq=300_000, duty_u16=2**16//2) + + and:: + + pwm=PWM(Pin(13), freq=300_000, duty_u16=2**16//2 + 255) + + will generate PWM with the same 50% duty cycle. + """ + + @overload + def duty_u16(self) -> int: + """ + Get or set the current duty cycle of the PWM output, as an unsigned 16-bit + value in the range 0 to 65535 inclusive. + + With no arguments the duty cycle is returned. + + With a single *value* argument the duty cycle is set to that value, measured + as the ratio ``value / 65535``. + """ + + @overload + def duty_u16( + self, + value: int, + /, + ) -> None: + """ + Get or set the current duty cycle of the PWM output, as an unsigned 16-bit + value in the range 0 to 65535 inclusive. + + With no arguments the duty cycle is returned. + + With a single *value* argument the duty cycle is set to that value, measured + as the ratio ``value / 65535``. + """ + + @overload + def freq(self) -> int: + """ + Get or set the current frequency of the PWM output. + + With no arguments the frequency in Hz is returned. + + With a single *value* argument the frequency is set to that value in Hz. The + method may raise a ``ValueError`` if the frequency is outside the valid range. + """ + + @overload + def freq( + self, + value: int, + /, + ) -> None: + """ + Get or set the current frequency of the PWM output. + + With no arguments the frequency in Hz is returned. + + With a single *value* argument the frequency is set to that value in Hz. The + method may raise a ``ValueError`` if the frequency is outside the valid range. + """ + def init(self, *, freq: int = ..., duty_u16: int = ..., duty_ns: int = ...) -> None: + """ + Modify settings for the PWM object. See the above constructor for details + about the parameters. + """ + ... + + @overload + def duty_ns(self) -> int: + """ + Get or set the current pulse width of the PWM output, as a value in nanoseconds. + + With no arguments the pulse width in nanoseconds is returned. + + With a single *value* argument the pulse width is set to that value. + """ + + @overload + def duty_ns( + self, + value: int, + /, + ) -> None: + """ + Get or set the current pulse width of the PWM output, as a value in nanoseconds. + + With no arguments the pulse width in nanoseconds is returned. + + With a single *value* argument the pulse width is set to that value. + """ + def deinit(self) -> None: + """ + Disable the PWM output. + """ + ... + def __init__( + self, + dest: PinLike, + /, + *, + freq: int = ..., + duty_u16: int = ..., + duty_ns: int = ..., + ) -> None: + """ + Construct and return a new PWM object using the following parameters: + + - *dest* is the entity on which the PWM is output, which is usually a + :ref:`machine.Pin ` object, but a port may allow other values, + like integers. + - *freq* should be an integer which sets the frequency in Hz for the + PWM cycle. + - *duty_u16* sets the duty cycle as a ratio ``duty_u16 / 65535``. + - *duty_ns* sets the pulse width in nanoseconds. + + Setting *freq* may affect other PWM objects if the objects share the same + underlying PWM generator (this is hardware specific). + Only one of *duty_u16* and *duty_ns* should be specified at a time. + """ + +class WDT: + """ + The WDT is used to restart the system when the application crashes and ends + up into a non recoverable state. Once started it cannot be stopped or + reconfigured in any way. After enabling, the application must "feed" the + watchdog periodically to prevent it from expiring and resetting the system. + + Example usage:: + + from machine import WDT + wdt = WDT(timeout=2000) # enable it with a timeout of 2s + wdt.feed() + + Availability of this class: pyboard, WiPy, esp8266, esp32. + """ + def feed(self) -> None: + """ + Feed the WDT to prevent it from resetting the system. The application + should place this call in a sensible place ensuring that the WDT is + only fed after verifying that everything is functioning correctly. + """ + ... + def __init__(self, *, id: int = 0, timeout: int = 5000) -> None: + """ + Create a WDT object and start it. The timeout must be given in milliseconds. + Once it is running the timeout cannot be changed and the WDT cannot be stopped either. + + Notes: On the esp32 the minimum timeout is 1 second. On the esp8266 a timeout + cannot be specified, it is determined by the underlying system. + """ + +class I2S: + """ + I2S is a synchronous serial protocol used to connect digital audio devices. + At the physical level, a bus consists of 3 lines: SCK, WS, SD. + The I2S class supports controller operation. Peripheral operation is not supported. + + The I2S class is currently available as a Technical Preview. During the preview period, feedback from + users is encouraged. Based on this feedback, the I2S class API and implementation may be changed. + + I2S objects can be created and initialized using:: + + from machine import I2S + from machine import Pin + + # ESP32 + sck_pin = Pin(14) # Serial clock output + ws_pin = Pin(13) # Word clock output + sd_pin = Pin(12) # Serial data output + + or + + # PyBoards + sck_pin = Pin("Y6") # Serial clock output + ws_pin = Pin("Y5") # Word clock output + sd_pin = Pin("Y8") # Serial data output + + audio_out = I2S(2, + sck=sck_pin, ws=ws_pin, sd=sd_pin, + mode=I2S.TX, + bits=16, + format=I2S.MONO, + rate=44100, + ibuf=20000) + + audio_in = I2S(2, + sck=sck_pin, ws=ws_pin, sd=sd_pin, + mode=I2S.RX, + bits=32, + format=I2S.STEREO, + rate=22050, + ibuf=20000) + + 3 modes of operation are supported: + - blocking + - non-blocking + - uasyncio + + blocking:: + + num_written = audio_out.write(buf) # blocks until buf emptied + + num_read = audio_in.readinto(buf) # blocks until buf filled + + non-blocking:: + + audio_out.irq(i2s_callback) # i2s_callback is called when buf is emptied + num_written = audio_out.write(buf) # returns immediately + + audio_in.irq(i2s_callback) # i2s_callback is called when buf is filled + num_read = audio_in.readinto(buf) # returns immediately + + uasyncio:: + + swriter = uasyncio.StreamWriter(audio_out) + swriter.write(buf) + await swriter.drain() + + sreader = uasyncio.StreamReader(audio_in) + num_read = await sreader.readinto(buf) + """ + + RX: Final[int] = 0 + """for initialising the I2S bus ``mode`` to receive""" + MONO: Final[int] = 0 + """for initialising the I2S bus ``format`` to mono""" + STEREO: Final[int] = 1 + """for initialising the I2S bus ``format`` to stereo""" + TX: Final[int] = 1 + """for initialising the I2S bus ``mode`` to transmit""" + @staticmethod + def shift( + buf: AnyWritableBuf, + bits: int, + shift: int, + /, + ) -> None: + """ + bitwise shift of all samples contained in ``buf``. ``bits`` specifies sample size in bits. ``shift`` specifies the number of bits to shift each sample. + Positive for left shift, negative for right shift. + Typically used for volume control. Each bit shift changes sample volume by 6dB. + """ + ... + def init( + self, + *, + sck: PinLike, + ws: PinLike, + sd: PinLike, + mode: int, + bits: int, + format: int, + rate: int, + ibuf: int, + ) -> None: + """ + see Constructor for argument descriptions + """ + ... + def irq( + self, + handler: Callable[[Any], None], + /, + ) -> None: + """ + Set a callback. ``handler`` is called when ``buf`` is emptied (``write`` method) or becomes full (``readinto`` method). + Setting a callback changes the ``write`` and ``readinto`` methods to non-blocking operation. + ``handler`` is called in the context of the MicroPython scheduler. + """ + ... + def readinto( + self, + buf: AnyWritableBuf, + /, + ) -> int: + """ + Read audio samples into the buffer specified by ``buf``. ``buf`` must support the buffer protocol, such as bytearray or array. + "buf" byte ordering is little-endian. For Stereo format, left channel sample precedes right channel sample. For Mono format, + the left channel sample data is used. + Returns number of bytes read + """ + ... + def deinit(self) -> None: + """ + Deinitialize the I2S bus + """ + ... + def write( + self, + buf: AnyReadableBuf, + /, + ) -> int: + """ + Write audio samples contained in ``buf``. ``buf`` must support the buffer protocol, such as bytearray or array. + "buf" byte ordering is little-endian. For Stereo format, left channel sample precedes right channel sample. For Mono format, + the sample data is written to both the right and left channels. + Returns number of bytes written + """ + ... + def __init__( + self, + id: ID_T, + /, + *, + sck: PinLike, + ws: PinLike, + sd: PinLike, + mode: int, + bits: int, + format: int, + rate: int, + ibuf: int, + ) -> None: + """ + Construct an I2S object of the given id: + + - ``id`` identifies a particular I2S bus. + + ``id`` is board and port specific: + + - PYBv1.0/v1.1: has one I2S bus with id=2. + - PYBD-SFxW: has two I2S buses with id=1 and id=2. + - ESP32: has two I2S buses with id=0 and id=1. + + Keyword-only parameters that are supported on all ports: + + - ``sck`` is a pin object for the serial clock line + - ``ws`` is a pin object for the word select line + - ``sd`` is a pin object for the serial data line + - ``mode`` specifies receive or transmit + - ``bits`` specifies sample size (bits), 16 or 32 + - ``format`` specifies channel format, STEREO or MONO + - ``rate`` specifies audio sampling rate (samples/s) + - ``ibuf`` specifies internal buffer length (bytes) + + For all ports, DMA runs continuously in the background and allows user applications to perform other operations while + sample data is transfered between the internal buffer and the I2S peripheral unit. + Increasing the size of the internal buffer has the potential to increase the time that user applications can perform non-I2S operations + before underflow (e.g. ``write`` method) or overflow (e.g. ``readinto`` method). + """ + +class ADC: + """ + The ADC class provides an interface to analog-to-digital convertors, and + represents a single endpoint that can sample a continuous voltage and + convert it to a discretised value. + + Example usage:: + + import machine + + adc = machine.ADC(pin) # create an ADC object acting on a pin + val = adc.read_u16() # read a raw analog value in the range 0-65535 + """ + + CORE_TEMP: Final[int] = 4 + VREF: int = ... + CORE_VREF: int = ... + CORE_VBAT: int = ... + ATTN_0DB: int = 0 + ATTN_2_5DB: int = 1 + ATTN_6DB: int = 2 + ATTN_11DB: int = 3 + WIDTH_9BIT: int = 9 + WIDTH_10BIT: int = 10 + WIDTH_11BIT: int = 11 + WIDTH_12BIT: int = 12 + def read_u16(self) -> int: + """ + Take an analog reading and return an integer in the range 0-65535. + The return value represents the raw reading taken by the ADC, scaled + such that the minimum value is 0 and the maximum value is 65535. + """ + ... + def __init__(self, pin: PinLike, *, atten=ATTN_0DB) -> None: + """ + Access the ADC associated with a source identified by *id*. This + *id* may be an integer (usually specifying a channel number), a + :ref:`Pin ` object, or other value supported by the + underlying machine. + .. note:: + + WiPy has a custom implementation of ADC, see ADCWiPy for details. + + on ESP32 : `atten` specifies the attenuation level for the ADC input. + """ + + # ESP32 specific + @mp_available(port="esp32") + @deprecated("Use ADC.block().init(bits=bits) instead.") + def width(self, bits: int) -> None: + """ + Equivalent to ADC.block().init(bits=bits). + The only chip that can switch resolution to a lower one is the normal esp32. The C2 & S3 are stuck at 12 bits, while the S2 is at 13 bits. + + For compatibility, the ADC object also provides constants matching the supported ADC resolutions, per chip: + + ESP32: + ADC.WIDTH_9BIT = 9 + ADC.WIDTH_10BIT = 10 + ADC.WIDTH_11BIT = 11 + ADC.WIDTH_12BIT = 12 + + ESP32 C3 & S3: + ADC.WIDTH_12BIT = 12 + + ESP32 S2: + ADC.WIDTH_13BIT = 13 + + Available : ESP32 + """ + ... + + @mp_available(port="esp32") + @deprecated("Use read_u16() instead.") + def read(self) -> int: + """ + Take an analog reading and return an integer in the range 0-4095. + The return value represents the raw reading taken by the ADC, scaled + such that the minimum value is 0 and the maximum value is 4095. + + This method is deprecated, use `read_u16()` instead. + + Available : ESP32 + """ + ... + + @mp_available(port="esp32") + @deprecated("Use ADC.init(atten=atten) instead.") + def atten(self, atten: int) -> None: + """ + Set the attenuation level for the ADC input. + + Available : ESP32 + """ + ... + +class I2C: + """ + 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 lines respectively. + + I2C objects are created attached to a specific bus. They can be initialised + when created, or initialised later on. + + Printing the I2C object gives you information about its configuration. + + Both hardware and software I2C implementations exist via the + :ref:`machine.I2C ` and `machine.SoftI2C` classes. Hardware I2C uses + underlying hardware support of the system to perform the reads/writes and is + usually efficient and fast but may have restrictions on which pins can be used. + Software I2C is implemented by bit-banging and can be used on any pin but is not + as efficient. These classes have the same methods available and differ primarily + in the way they are constructed. + + Example usage:: + + from machine import I2C + + i2c = I2C(freq=400000) # create I2C peripheral at frequency of 400kHz + # depending on the port, extra parameters may be required + # to select the peripheral and/or pins to use + + i2c.scan() # scan for peripherals, returning a list of 7-bit addresses + + i2c.writeto(42, b'123') # write 3 bytes to peripheral with 7-bit address 42 + i2c.readfrom(42, 4) # read 4 bytes from peripheral with 7-bit address 42 + + i2c.readfrom_mem(42, 8, 3) # read 3 bytes from memory of peripheral 42, + # starting at memory-address 8 in the peripheral + i2c.writeto_mem(42, 2, b'\x10') # write 1 byte to memory of peripheral 42 + # starting at address 2 in the peripheral + """ + def readfrom_mem_into(self, addr: int, memaddr: int, buf: AnyWritableBuf, /, *, addrsize: int = 8) -> None: + """ + Read into *buf* from the peripheral specified by *addr* starting from the + memory address specified by *memaddr*. The number of bytes read is the + length of *buf*. + The argument *addrsize* specifies the address size in bits (on ESP8266 + this argument is not recognised and the address size is always 8 bits). + + The method returns ``None``. + """ + ... + def readfrom_into(self, addr: int, buf: AnyWritableBuf, stop: bool = True, /) -> None: + """ + Read into *buf* from the peripheral specified by *addr*. + The number of bytes read will be the length of *buf*. + If *stop* is true then a STOP condition is generated at the end of the transfer. + + The method returns ``None``. + """ + ... + def readfrom_mem(self, addr: int, memaddr: int, nbytes: int, /, *, addrsize: int = 8) -> bytes: + """ + Read *nbytes* from the peripheral specified by *addr* starting from the memory + address specified by *memaddr*. + The argument *addrsize* specifies the address size in bits. + Returns a `bytes` object with the data read. + """ + ... + def writeto_mem(self, addr: int, memaddr: int, buf: AnyReadableBuf, /, *, addrsize: int = 8) -> None: + """ + Write *buf* to the peripheral specified by *addr* starting from the + memory address specified by *memaddr*. + The argument *addrsize* specifies the address size in bits (on ESP8266 + this argument is not recognised and the address size is always 8 bits). + + The method returns ``None``. + """ + ... + def scan(self) -> List: + """ + Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of + those that respond. A device responds if it pulls the SDA line low after + its address (including a write bit) is sent on the bus. + """ + ... + def writeto(self, addr: int, buf: AnyReadableBuf, stop: bool = True, /) -> int: + """ + Write the bytes from *buf* to the peripheral specified by *addr*. If a + NACK is received following the write of a byte from *buf* then the + remaining bytes are not sent. If *stop* is true then a STOP condition is + generated at the end of the transfer, even if a NACK is received. + The function returns the number of ACKs that were received. + """ + ... + def writevto(self, addr: int, vector: Sequence[AnyReadableBuf], stop: bool = True, /) -> int: + """ + Write the bytes contained in *vector* to the peripheral specified by *addr*. + *vector* should be a tuple or list of objects with the buffer protocol. + The *addr* is sent once and then the bytes from each object in *vector* + are written out sequentially. The objects in *vector* may be zero bytes + in length in which case they don't contribute to the output. + + If a NACK is received following the write of a byte from one of the + objects in *vector* then the remaining bytes, and any remaining objects, + are not sent. If *stop* is true then a STOP condition is generated at + the end of the transfer, even if a NACK is received. The function + returns the number of ACKs that were received. + """ + ... + def start(self) -> None: + """ + Generate a START condition on the bus (SDA transitions to low while SCL is high). + """ + ... + def readfrom(self, addr: int, nbytes: int, stop: bool = True, /) -> bytes: + """ + Read *nbytes* from the peripheral specified by *addr*. + If *stop* is true then a STOP condition is generated at the end of the transfer. + Returns a `bytes` object with the data read. + """ + ... + def readinto(self, buf: AnyWritableBuf, nack: bool = True, /) -> None: + """ + Reads bytes from the bus and stores them into *buf*. The number of bytes + read is the length of *buf*. An ACK will be sent on the bus after + receiving all but the last byte. After the last byte is received, if *nack* + is true then a NACK will be sent, otherwise an ACK will be sent (and in this + case the peripheral assumes more bytes are going to be read in a later call). + """ + ... + + @overload + def init(self, *, freq: int = 400_000) -> None: + """ + Initialise the I2C bus with the given arguments: + + - *scl* is a pin object for the SCL line + - *sda* is a pin object for the SDA line + - *freq* is the SCL clock rate + + In the case of hardware I2C the actual clock frequency may be lower than the + requested frequency. This is dependent on the platform hardware. The actual + rate may be determined by printing the I2C object. + """ + + @overload + def init(self, *, scl: PinLike, sda: PinLike, freq: int = 400_000) -> None: + """ + Initialise the I2C bus with the given arguments: + + - *scl* is a pin object for the SCL line + - *sda* is a pin object for the SDA line + - *freq* is the SCL clock rate + + In the case of hardware I2C the actual clock frequency may be lower than the + requested frequency. This is dependent on the platform hardware. The actual + rate may be determined by printing the I2C object. + """ + def stop(self) -> None: + """ + Generate a STOP condition on the bus (SDA transitions to high while SCL is high). + """ + ... + def write(self, buf: AnyReadableBuf, /) -> int: + """ + Write the bytes from *buf* to the bus. Checks that an ACK is received + after each byte and stops transmitting the remaining bytes if a NACK is + received. The function returns the number of ACKs that were received. + """ + ... + + @overload + def __init__(self, id: ID_T, /, *, freq: int = 400_000): + """ + Construct and return a new I2C object using the following parameters: + + - *id* identifies a particular I2C peripheral. Allowed values for + depend on the particular port/board + - *scl* should be a pin object specifying the pin to use for SCL. + - *sda* should be a pin object specifying the pin to use for SDA. + - *freq* should be an integer which sets the maximum frequency + for SCL. + + Note that some ports/boards will have default values of *scl* and *sda* + that can be changed in this constructor. Others will have fixed values + of *scl* and *sda* that cannot be changed. + """ + + @overload + def __init__(self, id: ID_T, /, *, scl: PinLike, sda: PinLike, freq: int = 400_000): + """ + Construct and return a new I2C object using the following parameters: + + - *id* identifies a particular I2C peripheral. Allowed values for + depend on the particular port/board + - *scl* should be a pin object specifying the pin to use for SCL. + - *sda* should be a pin object specifying the pin to use for SDA. + - *freq* should be an integer which sets the maximum frequency + for SCL. + + Note that some ports/boards will have default values of *scl* and *sda* + that can be changed in this constructor. Others will have fixed values + of *scl* and *sda* that cannot be changed. + """ + + @overload + def __init__(self, *, scl: PinLike, sda: PinLike, freq: int = 400_000) -> None: + """ + Initialise the I2C bus with the given arguments: + + - *scl* is a pin object for the SCL line + - *sda* is a pin object for the SDA line + - *freq* is the SCL clock rate + + In the case of hardware I2C the actual clock frequency may be lower than the + requested frequency. This is dependent on the platform hardware. The actual + rate may be determined by printing the I2C object. + """ + +class I2CTarget: + """ + Construct and return a new I2CTarget object using the following parameters: + + - *id* identifies a particular I2C peripheral. Allowed values depend on the + particular port/board. Some ports have a default in which case this parameter + can be omitted. + - *addr* is the I2C address of the target. + - *addrsize* is the number of bits in the I2C target address. Valid values + are 7 and 10. + - *mem* is an object with the buffer protocol that is writable. If not + specified then there is no backing memory and data must be read/written + using the :meth:`I2CTarget.readinto` and :meth:`I2CTarget.write` methods. + - *mem_addrsize* is the number of bits in the memory address. Valid values + are 0, 8, 16, 24 and 32. + - *scl* is a pin object specifying the pin to use for SCL. + - *sda* is a pin object specifying the pin to use for SDA. + + Note that some ports/boards will have default values of *scl* and *sda* + that can be changed in this constructor. Others will have fixed values + of *scl* and *sda* that cannot be changed. + """ + + IRQ_END_READ: Final[int] = 16 + """IRQ trigger sources.""" + IRQ_ADDR_MATCH_WRITE: Final[int] = 2 + """IRQ trigger sources.""" + IRQ_END_WRITE: Final[int] = 32 + """IRQ trigger sources.""" + IRQ_READ_REQ: Final[int] = 4 + """IRQ trigger sources.""" + IRQ_ADDR_MATCH_READ: Final[int] = 1 + """IRQ trigger sources.""" + IRQ_WRITE_REQ: Final[int] = 8 + """IRQ trigger sources.""" + def deinit(self) -> Incomplete: + """ + Deinitialise the I2C target. After this method is called the hardware will no + longer respond to requests on the I2C bus, and no other methods can be called. + """ + ... + def irq(self, handler=None, trigger=IRQ_END_READ | IRQ_END_WRITE, hard=False) -> Incomplete: + """ + Configure an IRQ *handler* to be called when an event occurs. The possible events are + given by the following constants, which can be or'd together and passed to the *trigger* + argument: + + - ``IRQ_ADDR_MATCH_READ`` indicates that the target was addressed by a + controller for a read transaction. + - ``IRQ_ADDR_MATCH_WRITE`` indicates that the target was addressed by a + controller for a write transaction. + - ``IRQ_READ_REQ`` indicates that the controller is requesting data, and this + request must be satisfied by calling `I2CTarget.write` with the data to be + passed back to the controller. + - ``IRQ_WRITE_REQ`` indicates that the controller has written data, and the + data must be read by calling `I2CTarget.readinto`. + - ``IRQ_END_READ`` indicates that the controller has finished a read transaction. + - ``IRQ_END_WRITE`` indicates that the controller has finished a write transaction. + + Not all triggers are available on all ports. If a port has the constant then that + event is available. + + Note the following restrictions: + + - ``IRQ_ADDR_MATCH_READ``, ``IRQ_ADDR_MATCH_WRITE``, ``IRQ_READ_REQ`` and + ``IRQ_WRITE_REQ`` must be handled by a hard IRQ callback (with the *hard* argument + set to ``True``). This is because these events have very strict timing requirements + and must usually be satisfied synchronously with the hardware event. + + - ``IRQ_END_READ`` and ``IRQ_END_WRITE`` may be handled by either a soft or hard + IRQ callback (although note that all events must be registered with the same handler, + so if any events need a hard callback then all events must be hard). + + - If a memory buffer has been supplied in the constructor then ``IRQ_END_WRITE`` + is not emitted for the transaction that writes the memory address. This is to + allow ``IRQ_END_READ`` and ``IRQ_END_WRITE`` to function correctly as soft IRQ + callbacks, where the IRQ handler may be called quite some time after the actual + hardware event. + """ + ... + def write(self, buf) -> int: + """ + Write out the bytes from the given buffer, to be passed to the I2C controller + after it sends a read request. Returns the number of bytes written. Most ports + only accept one byte at a time to this method. + """ + ... + def readinto(self, buf) -> int: + """ + Read into the given buffer any pending bytes written by the I2C controller. + Returns the number of bytes read. + """ + ... + def __init__(self, id, addr, *, addrsize=7, mem=None, mem_addrsize=8, scl=None, sda=None) -> None: ... + +class SoftSPI(SPI): + """ + Construct a new software SPI object. Additional parameters must be + given, usually at least *sck*, *mosi* and *miso*, and these are used + to initialise the bus. See `SPI.init` for a description of the parameters. + """ + + LSB: Final[int] = 0 + """set the first bit to be the least significant bit""" + MSB: Final[int] = 1 + """set the first bit to be the most significant bit""" + def deinit(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def write_readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__( + self, + baudrate=500000, + *, + polarity=0, + phase=0, + bits=8, + firstbit=MSB, + sck: PinLike | None = None, + mosi: PinLike | None = None, + miso: PinLike | None = None, + ) -> None: ... + +class Timer: + """ + Hardware timers deal with timing of periods and events. Timers are perhaps + the most flexible and heterogeneous kind of hardware in MCUs and SoCs, + differently greatly from a model to a model. MicroPython's Timer class + defines a baseline operation of executing a callback with a given period + (or once after some delay), and allow specific boards to define more + non-standard behaviour (which thus won't be portable to other boards). + + See discussion of :ref:`important constraints ` on + Timer callbacks. + + .. note:: + + Memory can't be allocated inside irq handlers (an interrupt) and so + exceptions raised within a handler don't give much information. See + :func:`micropython.alloc_emergency_exception_buf` for how to get around this + limitation. + + If you are using a WiPy board please refer to :ref:`machine.TimerWiPy ` + instead of this class. + """ + + PERIODIC: Final[int] = 1 + """Timer operating mode.""" + ONE_SHOT: Final[int] = 0 + """Timer operating mode.""" + + @overload + def init( + self, + *, + mode: int = PERIODIC, + period: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ) -> None: ... + @overload + def init( + self, + *, + mode: int = PERIODIC, + freq: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ) -> None: ... + @overload + def init( + self, + *, + mode: int = PERIODIC, + tick_hz: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ) -> None: + """ + Initialise the timer. Example:: + + def mycallback(t): + pass + + # periodic at 1kHz + tim.init(mode=Timer.PERIODIC, freq=1000, callback=mycallback) + + # periodic with 100ms period + tim.init(period=100, callback=mycallback) + + # one shot firing after 1000ms + tim.init(mode=Timer.ONE_SHOT, period=1000, callback=mycallback) + + Keyword arguments: + + - ``mode`` can be one of: + + - ``Timer.ONE_SHOT`` - The timer runs once until the configured + period of the channel expires. + - ``Timer.PERIODIC`` - The timer runs periodically at the configured + frequency of the channel. + + - ``freq`` - The timer frequency, in units of Hz. The upper bound of + the frequency is dependent on the port. When both the ``freq`` and + ``period`` arguments are given, ``freq`` has a higher priority and + ``period`` is ignored. + + - ``period`` - The timer period, in milliseconds. + + - ``callback`` - The callable to call upon expiration of the timer period. + The callback must take one argument, which is passed the Timer object. + + The ``callback`` argument shall be specified. Otherwise an exception + will occur upon timer expiration: + ``TypeError: 'NoneType' object isn't callable`` + + - ``hard`` can be one of: + + - ``True`` - The callback will be executed in hard interrupt context, + which minimises delay and jitter but is subject to the limitations + described in :ref:`isr_rules`. Not all ports support hard interrupts, + see the port documentation for more information. + - ``False`` - The callback will be scheduled as a soft interrupt, + allowing it to allocate but possibly also introducing + garbage-collection delays and jitter. + + The default value of this parameter is port-specific for historical reasons. + """ + ... + def deinit(self) -> None: + """ + Deinitialises the timer. Stops the timer, and disables the timer peripheral. + """ + ... + @overload + def __init__(self, id: int, /): + """ + Construct a new timer object of the given ``id``. ``id`` of -1 constructs a + virtual timer (if supported by a board). + ``id`` shall not be passed as a keyword argument. + + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + *, + mode: int = PERIODIC, + period: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ): + """ + Construct a new timer object of the given ``id``. ``id`` of -1 constructs a + virtual timer (if supported by a board). + ``id`` shall not be passed as a keyword argument. + + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + *, + mode: int = PERIODIC, + freq: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ): + """ + Construct a new timer object of the given ``id``. ``id`` of -1 constructs a + virtual timer (if supported by a board). + ``id`` shall not be passed as a keyword argument. + + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + *, + mode: int = PERIODIC, + tick_hz: int | None = None, + callback: Callable[[Timer], None] | None = None, + hard: bool | None = None, + ): + """ + Construct a new timer object of the given ``id``. ``id`` of -1 constructs a + virtual timer (if supported by a board). + ``id`` shall not be passed as a keyword argument. + + See ``init`` for parameters of initialisation. + """ + +class UART: + """ + UART implements the standard UART/USART duplex serial communications protocol. At + the physical level it consists of 2 lines: RX and TX. The unit of communication + is a character (not to be confused with a string character) which can be 8 or 9 + bits wide. + + UART objects can be created and initialised using:: + + from machine import UART + + uart = UART(1, 9600) # init with given baudrate + uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters + + Supported parameters differ on a board: + + Pyboard: Bits can be 7, 8 or 9. Stop can be 1 or 2. With *parity=None*, + only 8 and 9 bits are supported. With parity enabled, only 7 and 8 bits + are supported. + + WiPy/CC3200: Bits can be 5, 6, 7, 8. Stop can be 1 or 2. + + A UART object acts like a `stream` object and reading and writing is done + using the standard stream methods:: + + uart.read(10) # read 10 characters, returns a bytes object + uart.read() # read all available characters + uart.readline() # read a line + uart.readinto(buf) # read and store into the given buffer + uart.write('abc') # write the 3 characters + """ + + INV_TX: Final[int] = 1 + RTS: Final[int] = 2 + """\ + Flow control options. + + Availability: esp32, mimxrt, renesas-ra, rp2, stm32. + """ + INV_RX: Final[int] = 2 + IRQ_TXIDLE: Final[int] = 32 + """\ + IRQ trigger sources. + + Availability: renesas-ra, stm32, esp32, rp2040, mimxrt, samd, cc3200. + """ + IRQ_BREAK: Final[int] = 512 + """\ + IRQ trigger sources. + + Availability: renesas-ra, stm32, esp32, rp2040, mimxrt, samd, cc3200. + """ + IRQ_RXIDLE: Final[int] = 64 + """\ + IRQ trigger sources. + + Availability: renesas-ra, stm32, esp32, rp2040, mimxrt, samd, cc3200. + """ + CTS: Final[int] = 1 + """\ + Flow control options. + + Availability: esp32, mimxrt, renesas-ra, rp2, stm32. + """ + IRQ_RX: Incomplete + IDLE: int = ... + def irq( + self, + handler: Callable[[UART], None] | None = None, + trigger: int = 0, + hard: bool = False, + /, + ) -> _IRQ: + """ + Configure an interrupt handler to be called when a UART event occurs. + + The arguments are: + + - *handler* is an optional function to be called when the interrupt event + triggers. The handler must take exactly one argument which is the + ``UART`` instance. + + - *trigger* configures the event(s) which can generate an interrupt. + Possible values are a mask of one or more of the following: + + - ``UART.IRQ_RXIDLE`` interrupt after receiving at least one character + and then the RX line goes idle. + - ``UART.IRQ_RX`` interrupt after each received character. + - ``UART.IRQ_TXIDLE`` interrupt after or while the last character(s) of + a message are or have been sent. + - ``UART.IRQ_BREAK`` interrupt when a break state is detected at RX + + - *hard* if true a hardware interrupt is used. This reduces the delay + between the pin change and the handler being called. Hard interrupt + handlers may not allocate memory; see :ref:`isr_rules`. + + Returns an irq object. + + Due to limitations of the hardware not all trigger events are available on all ports. + """ + ... + def sendbreak(self) -> None: + """ + Send a break condition on the bus. This drives the bus low for a duration + longer than required for a normal transmission of a character. + """ + ... + def deinit(self) -> None: + """ + Turn off the UART bus. + + .. note:: + You will not be able to call ``init()`` on the object after ``deinit()``. + A new instance needs to be created in that case. + """ + ... + + @overload + def init( + self, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + tx: PinLike | None = None, + rx: PinLike | None = None, + txbuf: int | None = None, + rxbuf: int | None = None, + timeout: int | None = None, + timeout_char: int | None = None, + invert: int | None = None, + ) -> None: + """ + Initialise the UART bus with the given parameters: + + - *baudrate* is the clock rate. + - *bits* is the number of bits per character, 7, 8 or 9. + - *parity* is the parity, ``None``, 0 (even) or 1 (odd). + - *stop* is the number of stop bits, 1 or 2. + + Additional keyword-only parameters that may be supported by a port are: + + - *tx* specifies the TX pin to use. + - *rx* specifies the RX pin to use. + - *rts* specifies the RTS (output) pin to use for hardware receive flow control. + - *cts* specifies the CTS (input) pin to use for hardware transmit flow control. + - *txbuf* specifies the length in characters of the TX buffer. + - *rxbuf* specifies the length in characters of the RX buffer. + - *timeout* specifies the time to wait for the first character (in ms). + - *timeout_char* specifies the time to wait between characters (in ms). + - *invert* specifies which lines to invert. + + - ``0`` will not invert lines (idle state of both lines is logic high). + - ``UART.INV_TX`` will invert TX line (idle state of TX line now logic low). + - ``UART.INV_RX`` will invert RX line (idle state of RX line now logic low). + - ``UART.INV_TX | UART.INV_RX`` will invert both lines (idle state at logic low). + + - *flow* specifies which hardware flow control signals to use. The value + is a bitmask. + + - ``0`` will ignore hardware flow control signals. + - ``UART.RTS`` will enable receive flow control by using the RTS output pin to + signal if the receive FIFO has sufficient space to accept more data. + - ``UART.CTS`` will enable transmit flow control by pausing transmission when the + CTS input pin signals that the receiver is running low on buffer space. + - ``UART.RTS | UART.CTS`` will enable both, for full hardware flow control. + + On the WiPy only the following keyword-only parameter is supported: + + - *pins* is a 4 or 2 item list indicating the TX, RX, RTS and CTS pins (in that order). + Any of the pins can be None if one wants the UART to operate with limited functionality. + If the RTS pin is given the RX pin must be given as well. The same applies to CTS. + When no pins are given, then the default set of TX and RX pins is taken, and hardware + flow control will be disabled. If *pins* is ``None``, no pin assignment will be made. + + .. note:: + It is possible to call ``init()`` multiple times on the same object in + order to reconfigure UART on the fly. That allows using single UART + peripheral to serve different devices attached to different GPIO pins. + Only one device can be served at a time in that case. + Also do not call ``deinit()`` as it will prevent calling ``init()`` + again. + """ + + @overload + def init( + self, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + pins: tuple[PinLike, PinLike] | None = None, + ) -> None: + """ + Initialise the UART bus with the given parameters: + + - *baudrate* is the clock rate. + - *bits* is the number of bits per character, 7, 8 or 9. + - *parity* is the parity, ``None``, 0 (even) or 1 (odd). + - *stop* is the number of stop bits, 1 or 2. + + Additional keyword-only parameters that may be supported by a port are: + + - *tx* specifies the TX pin to use. + - *rx* specifies the RX pin to use. + - *rts* specifies the RTS (output) pin to use for hardware receive flow control. + - *cts* specifies the CTS (input) pin to use for hardware transmit flow control. + - *txbuf* specifies the length in characters of the TX buffer. + - *rxbuf* specifies the length in characters of the RX buffer. + - *timeout* specifies the time to wait for the first character (in ms). + - *timeout_char* specifies the time to wait between characters (in ms). + - *invert* specifies which lines to invert. + + - ``0`` will not invert lines (idle state of both lines is logic high). + - ``UART.INV_TX`` will invert TX line (idle state of TX line now logic low). + - ``UART.INV_RX`` will invert RX line (idle state of RX line now logic low). + - ``UART.INV_TX | UART.INV_RX`` will invert both lines (idle state at logic low). + + - *flow* specifies which hardware flow control signals to use. The value + is a bitmask. + + - ``0`` will ignore hardware flow control signals. + - ``UART.RTS`` will enable receive flow control by using the RTS output pin to + signal if the receive FIFO has sufficient space to accept more data. + - ``UART.CTS`` will enable transmit flow control by pausing transmission when the + CTS input pin signals that the receiver is running low on buffer space. + - ``UART.RTS | UART.CTS`` will enable both, for full hardware flow control. + + On the WiPy only the following keyword-only parameter is supported: + + - *pins* is a 4 or 2 item list indicating the TX, RX, RTS and CTS pins (in that order). + Any of the pins can be None if one wants the UART to operate with limited functionality. + If the RTS pin is given the RX pin must be given as well. The same applies to CTS. + When no pins are given, then the default set of TX and RX pins is taken, and hardware + flow control will be disabled. If *pins* is ``None``, no pin assignment will be made. + + .. note:: + It is possible to call ``init()`` multiple times on the same object in + order to reconfigure UART on the fly. That allows using single UART + peripheral to serve different devices attached to different GPIO pins. + Only one device can be served at a time in that case. + Also do not call ``deinit()`` as it will prevent calling ``init()`` + again. + """ + + @overload + def init( + self, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + pins: tuple[PinLike, PinLike, PinLike, PinLike] | None = None, + ) -> None: + """ + Initialise the UART bus with the given parameters: + + - *baudrate* is the clock rate. + - *bits* is the number of bits per character, 7, 8 or 9. + - *parity* is the parity, ``None``, 0 (even) or 1 (odd). + - *stop* is the number of stop bits, 1 or 2. + + Additional keyword-only parameters that may be supported by a port are: + + - *tx* specifies the TX pin to use. + - *rx* specifies the RX pin to use. + - *rts* specifies the RTS (output) pin to use for hardware receive flow control. + - *cts* specifies the CTS (input) pin to use for hardware transmit flow control. + - *txbuf* specifies the length in characters of the TX buffer. + - *rxbuf* specifies the length in characters of the RX buffer. + - *timeout* specifies the time to wait for the first character (in ms). + - *timeout_char* specifies the time to wait between characters (in ms). + - *invert* specifies which lines to invert. + + - ``0`` will not invert lines (idle state of both lines is logic high). + - ``UART.INV_TX`` will invert TX line (idle state of TX line now logic low). + - ``UART.INV_RX`` will invert RX line (idle state of RX line now logic low). + - ``UART.INV_TX | UART.INV_RX`` will invert both lines (idle state at logic low). + + - *flow* specifies which hardware flow control signals to use. The value + is a bitmask. + + - ``0`` will ignore hardware flow control signals. + - ``UART.RTS`` will enable receive flow control by using the RTS output pin to + signal if the receive FIFO has sufficient space to accept more data. + - ``UART.CTS`` will enable transmit flow control by pausing transmission when the + CTS input pin signals that the receiver is running low on buffer space. + - ``UART.RTS | UART.CTS`` will enable both, for full hardware flow control. + + On the WiPy only the following keyword-only parameter is supported: + + - *pins* is a 4 or 2 item list indicating the TX, RX, RTS and CTS pins (in that order). + Any of the pins can be None if one wants the UART to operate with limited functionality. + If the RTS pin is given the RX pin must be given as well. The same applies to CTS. + When no pins are given, then the default set of TX and RX pins is taken, and hardware + flow control will be disabled. If *pins* is ``None``, no pin assignment will be made. + + .. note:: + It is possible to call ``init()`` multiple times on the same object in + order to reconfigure UART on the fly. That allows using single UART + peripheral to serve different devices attached to different GPIO pins. + Only one device can be served at a time in that case. + Also do not call ``deinit()`` as it will prevent calling ``init()`` + again. + """ + def flush(self) -> Incomplete: + """ + Waits until all data has been sent. In case of a timeout, an exception is raised. The timeout + duration depends on the tx buffer size and the baud rate. Unless flow control is enabled, a timeout + should not occur. + + .. note:: + + For the esp8266 and nrf ports the call returns while the last byte is sent. + If required, a one character wait time has to be added in the calling script. + + Availability: rp2, esp32, esp8266, mimxrt, cc3200, stm32, nrf ports, renesas-ra + """ + ... + def txdone(self) -> bool: + """ + Tells whether all data has been sent or no data transfer is happening. In this case, + it returns ``True``. If a data transmission is ongoing it returns ``False``. + + .. note:: + + For the esp8266 and nrf ports the call may return ``True`` even if the last byte + of a transfer is still being sent. If required, a one character wait time has to be + added in the calling script. + + Availability: rp2, esp32, esp8266, mimxrt, cc3200, stm32, nrf ports, renesas-ra + """ + ... + + @overload + def read(self) -> bytes | None: + """ + Read characters. If ``nbytes`` is specified then read at most that many bytes, + otherwise read as much data as possible. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: a bytes object containing the bytes read in. Returns ``None`` + on timeout. + """ + + @overload + def read(self, nbytes: int, /) -> bytes | None: + """ + Read characters. If ``nbytes`` is specified then read at most that many bytes, + otherwise read as much data as possible. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: a bytes object containing the bytes read in. Returns ``None`` + on timeout. + """ + def any(self) -> int: + """ + Returns an integer counting the number of characters that can be read without + blocking. It will return 0 if there are no characters available and a positive + number if there are characters. The method may return 1 even if there is more + than one character available for reading. + + For more sophisticated querying of available characters use select.poll:: + + poll = select.poll() + poll.register(uart, select.POLLIN) + poll.poll(timeout) + """ + ... + def write(self, buf: AnyReadableBuf, /) -> Union[int, None]: + """ + Write the buffer of bytes to the bus. + + Return value: number of bytes written or ``None`` on timeout. + """ + ... + + @overload + def readinto(self, buf: AnyWritableBuf, /) -> int | None: + """ + Read bytes into the ``buf``. If ``nbytes`` is specified then read at most + that many bytes. Otherwise, read at most ``len(buf)`` bytes. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: number of bytes read and stored into ``buf`` or ``None`` on + timeout. + """ + + @overload + def readinto(self, buf: AnyWritableBuf, nbytes: int, /) -> int | None: + """ + Read bytes into the ``buf``. If ``nbytes`` is specified then read at most + that many bytes. Otherwise, read at most ``len(buf)`` bytes. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: number of bytes read and stored into ``buf`` or ``None`` on + timeout. + """ + def readline(self) -> Union[str, None]: + """ + Read a line, ending in a newline character. It may return sooner if a timeout + is reached. The timeout is configurable in the constructor. + + Return value: the line read or ``None`` on timeout. + """ + ... + @overload + def __init__( + self, + id: ID_T, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + tx: PinLike | None = None, + rx: PinLike | None = None, + txbuf: int | None = None, + rxbuf: int | None = None, + timeout: int | None = None, + timeout_char: int | None = None, + invert: int | None = None, + ): + """ + Construct a UART object of the given id. + """ + + @overload + def __init__( + self, + id: ID_T, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + pins: tuple[PinLike, PinLike] | None = None, + ): + """ + Construct a UART object of the given id from a tuple of two pins. + """ + + @overload + def __init__( + self, + id: ID_T, + /, + baudrate: int = 9600, + bits: int = 8, + parity: int | None = None, + stop: int = 1, + *, + pins: tuple[PinLike, PinLike, PinLike, PinLike] | None = None, + ): + """ + Construct a UART object of the given id from a tuple of four pins. + """ + +class USBDevice: + """ + Construct a USBDevice object. + + ``Note:`` This object is a singleton, each call to this constructor + returns the same object reference. + """ + + BUILTIN_NONE: Incomplete + BUILTIN_DEFAULT: Incomplete + BUILTIN_CDC: Incomplete + BUILTIN_MSC: Incomplete + BUILTIN_CDC_MSC: int + def submit_xfer(self, ep, buffer, /) -> bool: + """ + Submit a USB transfer on endpoint number ``ep``. ``buffer`` must be + an object implementing the buffer interface, with read access for + ``IN`` endpoints and write access for ``OUT`` endpoints. + + ``Note:`` ``ep`` cannot be the control Endpoint number 0. Control + transfers are built up through successive executions of + ``control_xfer_cb``, see above. + + Returns ``True`` if successful, ``False`` if the transfer could not + be queued (as USB device is not configured by host, or because + another transfer is queued on this endpoint.) + + When the USB host completes the transfer, the ``xfer_cb`` callback + is called (see above). + + Raises ``OSError`` with reason ``MP_EINVAL`` If the USB device is not + active. + """ + ... + def config( + self, + desc_dev, + desc_cfg, + desc_strs=None, + open_itf_cb=None, + reset_cb=None, + control_xfer_cb=None, + xfer_cb=None, + ) -> None: + """ + Configures the ``USBDevice`` singleton object with the USB runtime device + state and callback functions: + + - ``desc_dev`` - A bytes-like object containing + the new USB device descriptor. + + - ``desc_cfg`` - A bytes-like object containing the + new USB configuration descriptor. + + - ``desc_strs`` - Optional object holding strings or bytes objects + containing USB string descriptor values. Can be a list, a dict, or any + object which supports subscript indexing with integer keys (USB string + descriptor index). + + Strings are an optional USB feature, and this parameter can be unset + (default) if no strings are referenced in the device and configuration + descriptors, or if only built-in strings should be used. + + Apart from index 0, all the string values should be plain ASCII. Index 0 + is the special "languages" USB descriptor, represented as a bytes object + with a custom format defined in the USB standard. ``None`` can be + returned at index 0 in order to use a default "English" language + descriptor. + + To fall back to providing a built-in string value for a given index, a + subscript lookup can return ``None``, raise ``KeyError``, or raise + ``IndexError``. + + - ``open_itf_cb`` - This callback is called once for each interface + or Interface Association Descriptor in response to a Set + Configuration request from the USB Host (the final stage before + the USB device is available to the host). + + The callback takes a single argument, which is a memoryview of the + interface or IAD descriptor that the host is accepting (including + all associated descriptors). It is a view into the same + ``desc_cfg`` object that was provided as a separate + argument to this function. The memoryview is only valid until the + callback function returns. + + - ``reset_cb`` - This callback is called when the USB host performs + a bus reset. The callback takes no arguments. Any in-progress + transfers will never complete. The USB host will most likely + proceed to re-enumerate the USB device by calling the descriptor + callbacks and then ``open_itf_cb()``. + + - ``control_xfer_cb`` - This callback is called one or more times + for each USB control transfer (device Endpoint 0). It takes two + arguments. + + The first argument is the control transfer stage. It is one of: + + - ``1`` for SETUP stage. + - ``2`` for DATA stage. + - ``3`` for ACK stage. + + Second argument is a memoryview to read the USB control request + data for this stage. The memoryview is only valid until the + callback function returns. Data in this memoryview will be the same + across each of the three stages of a single transfer. + + A successful transfer consists of this callback being called in sequence + for the three stages. Generally speaking, if a device wants to do + something in response to a control request then it's best to wait until + the ACK stage to confirm the host controller completed the transfer as + expected. + + The callback should return one of the following values: + + - ``False`` to stall the endpoint and reject the transfer. It won't + proceed to any remaining stages. + - ``True`` to continue the transfer to the next stage. + - A buffer object can be returned at the SETUP stage when the transfer + will send or receive additional data. Typically this is the case when + the ``wLength`` field in the request has a non-zero value. This should + be a writable buffer for an ``OUT`` direction transfer, or a readable + buffer with data for an ``IN`` direction transfer. + + - ``xfer_cb`` - This callback is called whenever a non-control + transfer submitted by calling :func:`USBDevice.submit_xfer` completes. + + The callback has three arguments: + + 1. The Endpoint number for the completed transfer. + 2. Result value: ``True`` if the transfer succeeded, ``False`` + otherwise. + 3. Number of bytes successfully transferred. In the case of a + "short" transfer, The result is ``True`` and ``xferred_bytes`` + will be smaller than the length of the buffer submitted for the + transfer. + + ``Note:`` If a bus reset occurs (see :func:`USBDevice.reset`), + ``xfer_cb`` is not called for any transfers that have not + already completed. + """ + ... + def remote_wakeup(self) -> bool: + """ + Wake up host if we are in suspend mode and the REMOTE_WAKEUP feature + is enabled by the host. This has to be enabled in the USB attributes, + and on the host. Returns ``True`` if remote wakeup was enabled and + active and the host was woken up. + """ + ... + def stall(self, ep, stall: bool | None = None, /) -> bool: + """ + Calling this function gets or sets the STALL state of a device endpoint. + + ``ep`` is the number of the endpoint. + + If the optional ``stall`` parameter is set, this is a boolean flag + for the STALL state. + + The return value is the current stall state of the endpoint (before + any change made by this function). + + An endpoint that is set to STALL may remain stalled until this + function is called again, or STALL may be cleared automatically by + the USB host. + + Raises ``OSError`` with reason ``MP_EINVAL`` If the USB device is not + active. + """ + ... + def active(self, value: Any | None = None, /) -> bool: + """ + Returns the current active state of this runtime USB device as a + boolean. The runtime USB device is "active" when it is available to + interact with the host, it doesn't mean that a USB Host is actually + present. + + If the optional ``value`` argument is set to a truthy value, then + the USB device will be activated. + + If the optional ``value`` argument is set to a falsey value, then + the USB device is deactivated. While the USB device is deactivated, + it will not be detected by the USB Host. + + To simulate a disconnect and a reconnect of the USB device, call + ``active(False)`` followed by ``active(True)``. This may be + necessary if the runtime device configuration has changed, so that + the host sees the new device. + """ + ... + + class BUILTIN_CDC: + ep_max: int = 3 + itf_max: int = 2 + str_max: int = 5 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"\t\x02K\x00\x02\x01\x00\x80}\x08\x0b\x00\x02\x02\x02\x00\x00\t\x04\x00\x00\x01\x02\x02\x00\x04\x05$\x00 \x01\x05$\x01\x00\x01\x04$\x02\x06\x05$\x06\x00\x01\x07\x05\x81\x03\x08\x00\x01\t\x04\x01\x00\x02\n\x00\x00\x00\x07\x05\x02\x02@\x00\x00\x07\x05\x82\x02@\x00\x00" + def __init__(self, *argv, **kwargs) -> None: ... + + class BUILTIN_NONE: + ep_max: int = 0 + itf_max: int = 0 + str_max: int = 1 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"" + def __init__(self, *argv, **kwargs) -> None: ... + + class BUILTIN_DEFAULT: + ep_max: int = 3 + itf_max: int = 2 + str_max: int = 5 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"\t\x02K\x00\x02\x01\x00\x80}\x08\x0b\x00\x02\x02\x02\x00\x00\t\x04\x00\x00\x01\x02\x02\x00\x04\x05$\x00 \x01\x05$\x01\x00\x01\x04$\x02\x06\x05$\x06\x00\x01\x07\x05\x81\x03\x08\x00\x01\t\x04\x01\x00\x02\n\x00\x00\x00\x07\x05\x02\x02@\x00\x00\x07\x05\x82\x02@\x00\x00" + def __init__(self, *argv, **kwargs) -> None: ... + + def __init__(self) -> None: ... + +class Pin: + """ + A pin object is used to control I/O pins (also known as GPIO - general-purpose + input/output). Pin objects are commonly associated with a physical pin that can + drive an output voltage and read input voltages. The pin class has methods to set the mode of + the pin (IN, OUT, etc) and methods to get and set the digital logic level. + For analog control of a pin, see the :class:`ADC` class. + + A pin object is constructed by using an identifier which unambiguously + specifies a certain I/O pin. The allowed forms of the identifier and the + physical pin that the identifier maps to are port-specific. Possibilities + for the identifier are an integer, a string or a tuple with port and pin + number. + + Usage Model:: + + from machine import Pin + + # create an output pin on pin #0 + p0 = Pin(0, Pin.OUT) + + # set the value low then high + p0.value(0) + p0.value(1) + + # create an input pin on pin #2, with a pull up resistor + p2 = Pin(2, Pin.IN, Pin.PULL_UP) + + # read and print the pin value + print(p2.value()) + + # reconfigure pin #0 in input mode with a pull down resistor + p0.init(p0.IN, p0.PULL_DOWN) + + # configure an irq callback + p0.irq(lambda p:print(p)) + """ + + ALT_SPI: Final[int] = 1 + IN: Final[int] = 0 + """Selects the pin mode.""" + ALT_USB: Final[int] = 9 + ALT_UART: Final[int] = 2 + IRQ_FALLING: Final[int] = 4 + """Selects the IRQ trigger type.""" + OUT: Final[int] = 1 + """Selects the pin mode.""" + OPEN_DRAIN: Final[int] = 2 + """Selects the pin mode.""" + IRQ_RISING: Final[int] = 8 + """Selects the IRQ trigger type.""" + PULL_DOWN: Final[int] = 2 + """\ + Selects whether there is a pull up/down resistor. Use the value + ``None`` for no pull. + """ + ALT_SIO: Final[int] = 5 + ALT_GPCK: Final[int] = 8 + ALT: Final[int] = 3 + """Selects the pin mode.""" + PULL_UP: Final[int] = 1 + """\ + Selects whether there is a pull up/down resistor. Use the value + ``None`` for no pull. + """ + ALT_I2C: Final[int] = 3 + ALT_PWM: Final[int] = 4 + ALT_PIO1: Final[int] = 7 + ALT_PIO0: Final[int] = 6 + ALT_OPEN_DRAIN: Incomplete + ANALOG: Incomplete + PULL_HOLD: Incomplete + DRIVE_0: int + DRIVE_1: int + DRIVE_2: int + IRQ_LOW_LEVEL: Incomplete + IRQ_HIGH_LEVEL: Incomplete + def low(self) -> None: + """ + Set pin to "0" output level. + + Availability: mimxrt, nrf, renesas-ra, rp2, samd, stm32 ports. + """ + ... + def irq( + self, + /, + handler: Callable[[Pin], None] | None = None, + trigger: int = (IRQ_FALLING | IRQ_RISING), + *, + priority: int = 1, + wake: int | None = None, + hard: bool = False, + ) -> Callable[..., Incomplete]: + """ + Configure an interrupt handler to be called when the trigger source of the + pin is active. If the pin mode is ``Pin.IN`` then the trigger source is + the external value on the pin. If the pin mode is ``Pin.OUT`` then the + trigger source is the output buffer of the pin. Otherwise, if the pin mode + is ``Pin.OPEN_DRAIN`` then the trigger source is the output buffer for + state '0' and the external pin value for state '1'. + + The arguments are: + + - ``handler`` is an optional function to be called when the interrupt + triggers. The handler must take exactly one argument which is the + ``Pin`` instance. + + - ``trigger`` configures the event which can generate an interrupt. + Possible values are: + + - ``Pin.IRQ_FALLING`` interrupt on falling edge. + - ``Pin.IRQ_RISING`` interrupt on rising edge. + - ``Pin.IRQ_LOW_LEVEL`` interrupt on low level. + - ``Pin.IRQ_HIGH_LEVEL`` interrupt on high level. + + These values can be OR'ed together to trigger on multiple events. + + - ``priority`` sets the priority level of the interrupt. The values it + can take are port-specific, but higher values always represent higher + priorities. + + - ``wake`` selects the power mode in which this interrupt can wake up the + system. It can be ``machine.IDLE``, ``machine.SLEEP`` or ``machine.DEEPSLEEP``. + These values can also be OR'ed together to make a pin generate interrupts in + more than one power mode. + + - ``hard`` if true a hardware interrupt is used. This reduces the delay + between the pin change and the handler being called. Hard interrupt + handlers may not allocate memory; see :ref:`isr_rules`. + Not all ports support this argument. + + This method returns a callback object. + + The following methods are not part of the core Pin API and only implemented on certain ports. + """ + ... + def toggle(self) -> Incomplete: + """ + Toggle output pin from "0" to "1" or vice-versa. + + Availability: cc3200, esp32, esp8266, mimxrt, rp2, samd ports. + """ + ... + def off(self) -> None: + """ + Set pin to "0" output level. + """ + ... + def on(self) -> None: + """ + Set pin to "1" output level. + """ + ... + def init( + self, + mode: int = -1, + pull: int = -1, + *, + value: Any = None, + drive: int | None = None, + alt: int | None = None, + ) -> None: + """ + Re-initialise the pin using the given parameters. Only those arguments that + are specified will be set. The rest of the pin peripheral state will remain + unchanged. See the constructor documentation for details of the arguments. + + Returns ``None``. + """ + ... + + @overload + def value(self) -> int: + """ + This method allows to set and get the value of the pin, depending on whether + the argument ``x`` is supplied or not. + + If the argument is omitted then this method gets the digital logic level of + the pin, returning 0 or 1 corresponding to low and high voltage signals + respectively. The behaviour of this method depends on the mode of the pin: + + - ``Pin.IN`` - The method returns the actual input value currently present + on the pin. + - ``Pin.OUT`` - The behaviour and return value of the method is undefined. + - ``Pin.OPEN_DRAIN`` - If the pin is in state '0' then the behaviour and + return value of the method is undefined. Otherwise, if the pin is in + state '1', the method returns the actual input value currently present + on the pin. + + If the argument is supplied then this method sets the digital logic level of + the pin. The argument ``x`` can be anything that converts to a boolean. + If it converts to ``True``, the pin is set to state '1', otherwise it is set + to state '0'. The behaviour of this method depends on the mode of the pin: + + - ``Pin.IN`` - The value is stored in the output buffer for the pin. The + pin state does not change, it remains in the high-impedance state. The + stored value will become active on the pin as soon as it is changed to + ``Pin.OUT`` or ``Pin.OPEN_DRAIN`` mode. + - ``Pin.OUT`` - The output buffer is set to the given value immediately. + - ``Pin.OPEN_DRAIN`` - If the value is '0' the pin is set to a low voltage + state. Otherwise the pin is set to high-impedance state. + + When setting the value this method returns ``None``. + """ + + @overload + def value(self, x: Any, /) -> None: + """ + This method allows to set and get the value of the pin, depending on whether + the argument ``x`` is supplied or not. + + If the argument is omitted then this method gets the digital logic level of + the pin, returning 0 or 1 corresponding to low and high voltage signals + respectively. The behaviour of this method depends on the mode of the pin: + + - ``Pin.IN`` - The method returns the actual input value currently present + on the pin. + - ``Pin.OUT`` - The behaviour and return value of the method is undefined. + - ``Pin.OPEN_DRAIN`` - If the pin is in state '0' then the behaviour and + return value of the method is undefined. Otherwise, if the pin is in + state '1', the method returns the actual input value currently present + on the pin. + + If the argument is supplied then this method sets the digital logic level of + the pin. The argument ``x`` can be anything that converts to a boolean. + If it converts to ``True``, the pin is set to state '1', otherwise it is set + to state '0'. The behaviour of this method depends on the mode of the pin: + + - ``Pin.IN`` - The value is stored in the output buffer for the pin. The + pin state does not change, it remains in the high-impedance state. The + stored value will become active on the pin as soon as it is changed to + ``Pin.OUT`` or ``Pin.OPEN_DRAIN`` mode. + - ``Pin.OUT`` - The output buffer is set to the given value immediately. + - ``Pin.OPEN_DRAIN`` - If the value is '0' the pin is set to a low voltage + state. Otherwise the pin is set to high-impedance state. + + When setting the value this method returns ``None``. + """ + def high(self) -> None: + """ + Set pin to "1" output level. + + Availability: mimxrt, nrf, renesas-ra, rp2, samd, stm32 ports. + """ + ... + + class cpu: + GPIO20: Pin ## = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO25: Pin ## = Pin(GPIO25, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO26: Pin ## = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO27: Pin ## = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO24: Pin ## = Pin(GPIO24, mode=ALT, alt=31) + GPIO21: Pin ## = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO22: Pin ## = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO23: Pin ## = Pin(GPIO23, mode=ALT, alt=31) + GPIO28: Pin ## = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO6: Pin ## = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO7: Pin ## = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO8: Pin ## = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO5: Pin ## = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO29: Pin ## = Pin(GPIO29, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO3: Pin ## = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO4: Pin ## = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO9: Pin ## = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO2: Pin ## = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO1: Pin ## = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO10: Pin ## = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO11: Pin ## = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO0: Pin ## = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) + EXT_GPIO0: Pin ## = Pin(EXT_GPIO0, mode=IN) + EXT_GPIO1: Pin ## = Pin(EXT_GPIO1, mode=IN) + EXT_GPIO2: Pin ## = Pin(EXT_GPIO2, mode=IN) + GPIO12: Pin ## = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO17: Pin ## = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO18: Pin ## = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO19: Pin ## = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO16: Pin ## = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO13: Pin ## = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO14: Pin ## = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO15: Pin ## = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) + def __init__(self, *argv, **kwargs) -> None: ... + + class board: + GP3: Pin ## = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) + GP28: Pin ## = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) + GP4: Pin ## = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) + GP5: Pin ## = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) + GP22: Pin ## = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) + GP27: Pin ## = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) + GP26: Pin ## = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) + WL_GPIO2: Pin ## = Pin(EXT_GPIO2, mode=IN) + WL_GPIO0: Pin ## = Pin(EXT_GPIO0, mode=IN) + LED: Pin ## = Pin(EXT_GPIO0, mode=IN) + WL_GPIO1: Pin ## = Pin(EXT_GPIO1, mode=IN) + GP6: Pin ## = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) + GP7: Pin ## = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) + GP9: Pin ## = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) + GP8: Pin ## = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) + GP12: Pin ## = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) + GP11: Pin ## = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) + GP13: Pin ## = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) + GP14: Pin ## = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) + GP0: Pin ## = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) + GP10: Pin ## = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) + GP1: Pin ## = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) + GP21: Pin ## = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) + GP2: Pin ## = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) + GP19: Pin ## = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) + GP20: Pin ## = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) + GP15: Pin ## = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) + GP16: Pin ## = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) + GP18: Pin ## = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) + GP17: Pin ## = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) + def __init__(self, *argv, **kwargs) -> None: ... + + def __init__( + self, + id: Any, + /, + mode: int = -1, + pull: int = -1, + *, + value: Any = None, + drive: int | None = None, + alt: int | None = None, + ) -> None: + """ + Access the pin peripheral (GPIO pin) associated with the given ``id``. If + additional arguments are given in the constructor then they are used to initialise + the pin. Any settings that are not specified will remain in their previous state. + + The arguments are: + + - ``id`` is mandatory and can be an arbitrary object. Among possible value + types are: int (an internal Pin identifier), str (a Pin name), and tuple + (pair of [port, pin]). + + - ``mode`` specifies the pin mode, which can be one of: + + - ``Pin.IN`` - Pin is configured for input. If viewed as an output the pin + is in high-impedance state. + + - ``Pin.OUT`` - Pin is configured for (normal) output. + + - ``Pin.OPEN_DRAIN`` - Pin is configured for open-drain output. Open-drain + output works in the following way: if the output value is set to 0 the pin + is active at a low level; if the output value is 1 the pin is in a high-impedance + state. Not all ports implement this mode, or some might only on certain pins. + + - ``Pin.ALT`` - Pin is configured to perform an alternative function, which is + port specific. For a pin configured in such a way any other Pin methods + (except :meth:`Pin.init`) are not applicable (calling them will lead to undefined, + or a hardware-specific, result). Not all ports implement this mode. + + - ``Pin.ALT_OPEN_DRAIN`` - The Same as ``Pin.ALT``, but the pin is configured as + open-drain. Not all ports implement this mode. + + - ``Pin.ANALOG`` - Pin is configured for analog input, see the :class:`ADC` class. + + - ``pull`` specifies if the pin has a (weak) pull resistor attached, and can be + one of: + + - ``None`` - No pull up or down resistor. + - ``Pin.PULL_UP`` - Pull up resistor enabled. + - ``Pin.PULL_DOWN`` - Pull down resistor enabled. + + - ``value`` is valid only for Pin.OUT and Pin.OPEN_DRAIN modes and specifies initial + output pin value if given, otherwise the state of the pin peripheral remains + unchanged. + + - ``drive`` specifies the output power of the pin and can be one of: ``Pin.LOW_POWER``, + ``Pin.MED_POWER`` or ``Pin.HIGH_POWER``. The actual current driving capabilities + are port dependent. Not all ports implement this argument. + + - ``alt`` specifies an alternate function for the pin and the values it can take are + port dependent. This argument is valid only for ``Pin.ALT`` and ``Pin.ALT_OPEN_DRAIN`` + modes. It may be used when a pin supports more than one alternate function. If only + one pin alternate function is supported the this argument is not required. Not all + ports implement this argument. + + As specified above, the Pin class allows to set an alternate function for a particular + pin, but it does not specify any further operations on such a pin. Pins configured in + alternate-function mode are usually not used as GPIO but are instead driven by other + hardware peripherals. The only operation supported on such a pin is re-initialising, + by calling the constructor or :meth:`Pin.init` method. If a pin that is configured in + alternate-function mode is re-initialised with ``Pin.IN``, ``Pin.OUT``, or + ``Pin.OPEN_DRAIN``, the alternate function will be removed from the pin. + """ + + @overload + def __call__(self) -> int: + """ + Pin objects are callable. The call method provides a (fast) shortcut to set + and get the value of the pin. It is equivalent to Pin.value([x]). + See :meth:`Pin.value` for more details. + """ + + @overload + def __call__(self, x: Any, /) -> None: + """ + Pin objects are callable. The call method provides a (fast) shortcut to set + and get the value of the pin. It is equivalent to Pin.value([x]). + See :meth:`Pin.value` for more details. + """ + + @overload + def mode(self) -> int: + """ + Get or set the pin mode. + See the constructor documentation for details of the ``mode`` argument. + + Availability: cc3200, stm32 ports. + """ + + @overload + def mode(self, mode: int, /) -> None: + """ + Get or set the pin mode. + See the constructor documentation for details of the ``mode`` argument. + + Availability: cc3200, stm32 ports. + """ + + @overload + def pull(self) -> int: + """ + Get or set the pin pull state. + See the constructor documentation for details of the ``pull`` argument. + + Availability: cc3200, stm32 ports. + """ + + @overload + def pull(self, pull: int, /) -> None: + """ + Get or set the pin pull state. + See the constructor documentation for details of the ``pull`` argument. + + Availability: cc3200, stm32 ports. + """ + + @overload + def drive(self, drive: int, /) -> None: + """ + Get or set the pin drive strength. + See the constructor documentation for details of the ``drive`` argument. + + Availability: cc3200 port. + """ + ... + + @overload + def drive(self, /) -> int: + """ + Get or set the pin drive strength. + See the constructor documentation for details of the ``drive`` argument. + + Availability: cc3200 port. + """ + +class SoftI2C(I2C): + """ + Construct a new software I2C object. The parameters are: + + - *scl* should be a pin object specifying the pin to use for SCL. + - *sda* should be a pin object specifying the pin to use for SDA. + - *freq* should be an integer which sets the maximum frequency + for SCL. + - *timeout* is the maximum time in microseconds to wait for clock + stretching (SCL held low by another device on the bus), after + which an ``OSError(ETIMEDOUT)`` exception is raised. + """ + def readfrom_mem_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_mem(self, *args, **kwargs) -> Incomplete: ... + def writeto_mem(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def writeto(self, *args, **kwargs) -> Incomplete: ... + def writevto(self, *args, **kwargs) -> Incomplete: ... + def start(self, *args, **kwargs) -> Incomplete: ... + def readfrom(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def stop(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, scl, sda, *, freq=400000, timeout=50000) -> None: ... + +class RTC: + """ + The RTC is an independent clock that keeps track of the date + and time. + + Example usage:: + + rtc = machine.RTC() + rtc.datetime((2020, 1, 21, 2, 10, 32, 36, 0)) + print(rtc.datetime()) + + + + The documentation for RTC is in a poor state;1 + """ + + ALARM0: Incomplete + def datetime(self, datetimetuple: Any | None = None) -> Tuple: + """ + Get or set the date and time of the RTC. + + With no arguments, this method returns an 8-tuple with the current + date and time. With 1 argument (being an 8-tuple) it sets the date + and time. + + The 8-tuple has the following format: + + (year, month, day, weekday, hours, minutes, seconds, subseconds) + + The meaning of the ``subseconds`` field is hardware dependent. + """ + ... + @overload + def __init__(self, id: int = 0): + """ + Create an RTC object. See init for parameters of initialization. + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def __init__(self, id: int = 0, /, *, datetime: tuple[int, int, int, int, int, int, int, int]): + """ + Create an RTC object. See init for parameters of initialization. + + The documentation for RTC is in a poor state; better to experiment and use `dir`! + """ + + @overload + def init(self) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def init(self, datetime: tuple[int, int, int, int, int, int, int, int], /) -> None: + """ + Initialise the RTC. Datetime is a tuple of the form: + + ``(year, month, day, hour, minute, second, microsecond, tzinfo)`` + + All eight arguments must be present. The ``microsecond`` and ``tzinfo`` + values are currently ignored but might be used in the future. + + Availability: CC3200, ESP32, MIMXRT, SAMD. The rtc.init() method on + the stm32 and renesas-ra ports just (re-)starts the RTC and does not + accept arguments. + """ + + @overload + def alarm(self, id: int, time: int, /, *, repeat: bool = False) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + + @overload + def alarm(self, id: int, time: tuple[int, int, int, int, int, int, int, int], /) -> None: + """ + Set the RTC alarm. Time might be either a millisecond value to program the alarm to + current time + time_in_ms in the future, or a datetimetuple. If the time passed is in + milliseconds, repeat can be set to ``True`` to make the alarm periodic. + """ + +class SPI: + """ + SPI is a synchronous serial protocol that is driven by a controller. At the + physical level, a bus consists of 3 lines: SCK, MOSI, MISO. Multiple devices + can share the same bus. Each device should have a separate, 4th signal, + CS (Chip Select), to select a particular device on a bus with which + communication takes place. Management of a CS signal should happen in + user code (via machine.Pin class). + + Both hardware and software SPI implementations exist via the + :ref:`machine.SPI ` and `machine.SoftSPI` classes. Hardware SPI uses underlying + hardware support of the system to perform the reads/writes and is usually + efficient and fast but may have restrictions on which pins can be used. + Software SPI is implemented by bit-banging and can be used on any pin but + is not as efficient. These classes have the same methods available and + differ primarily in the way they are constructed. + + Example usage:: + + from machine import SPI, Pin + + spi = SPI(0, baudrate=400000) # Create SPI peripheral 0 at frequency of 400kHz. + # Depending on the use case, extra parameters may be required + # to select the bus characteristics and/or pins to use. + cs = Pin(4, mode=Pin.OUT, value=1) # Create chip-select on pin 4. + + try: + cs(0) # Select peripheral. + spi.write(b"12345678") # Write 8 bytes, and don't care about received data. + finally: + cs(1) # Deselect peripheral. + + try: + cs(0) # Select peripheral. + rxdata = spi.read(8, 0x42) # Read 8 bytes while writing 0x42 for each byte. + finally: + cs(1) # Deselect peripheral. + + rxdata = bytearray(8) + try: + cs(0) # Select peripheral. + spi.readinto(rxdata, 0x42) # Read 8 bytes inplace while writing 0x42 for each byte. + finally: + cs(1) # Deselect peripheral. + + txdata = b"12345678" + rxdata = bytearray(len(txdata)) + try: + cs(0) # Select peripheral. + spi.write_readinto(txdata, rxdata) # Simultaneously write and read bytes. + finally: + cs(1) # Deselect peripheral. + """ + + LSB: Final[int] = 0 + """set the first bit to be the least significant bit""" + MSB: Final[int] = 1 + """set the first bit to be the most significant bit""" + CONTROLLER: Incomplete + def deinit(self) -> None: + """ + Turn off the SPI bus. + """ + ... + + @overload + def init( + self, + baudrate: int = 1_000_000, + *, + polarity: int = 0, + phase: int = 0, + bits: int = 8, + firstbit: int = MSB, + sck: PinLike | None = None, + mosi: PinLike | None = None, + miso: PinLike | None = None, + ) -> None: + """ + Initialise the SPI bus with the given parameters: + + - ``baudrate`` is the SCK clock rate. + - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. + - ``phase`` can be 0 or 1 to sample data on the first or second clock edge + respectively. + - ``bits`` is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware. + - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. + - ``sck``, ``mosi``, ``miso`` are pins (machine.Pin) objects to use for bus signals. For most + hardware SPI blocks (as selected by ``id`` parameter to the constructor), pins are fixed + and cannot be changed. In some cases, hardware blocks allow 2-3 alternative pin sets for + a hardware SPI block. Arbitrary pin assignments are possible only for a bitbanging SPI driver + (``id`` = -1). + - ``pins`` - WiPy port doesn't ``sck``, ``mosi``, ``miso`` arguments, and instead allows to + specify them as a tuple of ``pins`` parameter. + + In the case of hardware SPI the actual clock frequency may be lower than the + requested baudrate. This is dependent on the platform hardware. The actual + rate may be determined by printing the SPI object. + """ + + @overload + def init( + self, + baudrate: int = 1_000_000, + *, + polarity: int = 0, + phase: int = 0, + bits: int = 8, + firstbit: int = MSB, + pins: tuple[PinLike, PinLike, PinLike] | None = None, + ) -> None: + """ + Initialise the SPI bus with the given parameters: + + - ``baudrate`` is the SCK clock rate. + - ``polarity`` can be 0 or 1, and is the level the idle clock line sits at. + - ``phase`` can be 0 or 1 to sample data on the first or second clock edge + respectively. + - ``bits`` is the width in bits of each transfer. Only 8 is guaranteed to be supported by all hardware. + - ``firstbit`` can be ``SPI.MSB`` or ``SPI.LSB``. + - ``sck``, ``mosi``, ``miso`` are pins (machine.Pin) objects to use for bus signals. For most + hardware SPI blocks (as selected by ``id`` parameter to the constructor), pins are fixed + and cannot be changed. In some cases, hardware blocks allow 2-3 alternative pin sets for + a hardware SPI block. Arbitrary pin assignments are possible only for a bitbanging SPI driver + (``id`` = -1). + - ``pins`` - WiPy port doesn't ``sck``, ``mosi``, ``miso`` arguments, and instead allows to + specify them as a tuple of ``pins`` parameter. + + In the case of hardware SPI the actual clock frequency may be lower than the + requested baudrate. This is dependent on the platform hardware. The actual + rate may be determined by printing the SPI object. + """ + def write_readinto(self, write_buf: AnyReadableBuf, read_buf: AnyWritableBuf, /) -> int: + """ + Write the bytes from ``write_buf`` while reading into ``read_buf``. The + buffers can be the same or different, but both buffers must have the + same length. + Returns ``None``. + + Note: on WiPy this function returns the number of bytes written. + """ + ... + def read(self, nbytes: int, write: int = 0x00, /) -> bytes: + """ + Read a number of bytes specified by ``nbytes`` while continuously writing + the single byte given by ``write``. + Returns a ``bytes`` object with the data that was read. + """ + ... + def write(self, buf: AnyReadableBuf, /) -> int: + """ + Write the bytes contained in ``buf``. + Returns ``None``. + + Note: on WiPy this function returns the number of bytes written. + """ + ... + def readinto(self, buf: AnyWritableBuf, write: int = 0x00, /) -> int: + """ + Read into the buffer specified by ``buf`` while continuously writing the + single byte given by ``write``. + Returns ``None``. + + Note: on WiPy this function returns the number of bytes read. + """ + ... + @overload + def __init__(self, id: int, /): + """ + Construct an SPI object on the given bus, *id*. Values of *id* depend + on a particular port and its hardware. Values 0, 1, etc. are commonly used + to select hardware SPI block #0, #1, etc. + + With no additional parameters, the SPI object is created but not + initialised (it has the settings from the last initialisation of + the bus, if any). If extra arguments are given, the bus is initialised. + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + baudrate: int = 1_000_000, + *, + polarity: int = 0, + phase: int = 0, + bits: int = 8, + firstbit: int = MSB, + sck: PinLike | None = None, + mosi: PinLike | None = None, + miso: PinLike | None = None, + ): + """ + Construct an SPI object on the given bus, *id*. Values of *id* depend + on a particular port and its hardware. Values 0, 1, etc. are commonly used + to select hardware SPI block #0, #1, etc. + + With no additional parameters, the SPI object is created but not + initialised (it has the settings from the last initialisation of + the bus, if any). If extra arguments are given, the bus is initialised. + See ``init`` for parameters of initialisation. + """ + + @overload + def __init__( + self, + id: int, + /, + baudrate: int = 1_000_000, + *, + polarity: int = 0, + phase: int = 0, + bits: int = 8, + firstbit: int = MSB, + pins: tuple[PinLike, PinLike, PinLike] | None = None, + ): + """ + Construct an SPI object on the given bus, *id*. Values of *id* depend + on a particular port and its hardware. Values 0, 1, etc. are commonly used + to select hardware SPI block #0, #1, etc. + + With no additional parameters, the SPI object is created but not + initialised (it has the settings from the last initialisation of + the bus, if any). If extra arguments are given, the bus is initialised. + See ``init`` for parameters of initialisation. + """ + +class Signal(Pin): + """ + The Signal class is a simple extension of the `Pin` class. Unlike Pin, which + can be only in "absolute" 0 and 1 states, a Signal can be in "asserted" + (on) or "deasserted" (off) states, while being inverted (active-low) or + not. In other words, it adds logical inversion support to Pin functionality. + While this may seem a simple addition, it is exactly what is needed to + support wide array of simple digital devices in a way portable across + different boards, which is one of the major MicroPython goals. Regardless + of whether different users have an active-high or active-low LED, a normally + open or normally closed relay - you can develop a single, nicely looking + application which works with each of them, and capture hardware + configuration differences in few lines in the config file of your app. + + Example:: + + from machine import Pin, Signal + + # Suppose you have an active-high LED on pin 0 + led1_pin = Pin(0, Pin.OUT) + # ... and active-low LED on pin 1 + led2_pin = Pin(1, Pin.OUT) + + # Now to light up both of them using Pin class, you'll need to set + # them to different values + led1_pin.value(1) + led2_pin.value(0) + + # Signal class allows to abstract away active-high/active-low + # difference + led1 = Signal(led1_pin, invert=False) + led2 = Signal(led2_pin, invert=True) + + # Now lighting up them looks the same + led1.value(1) + led2.value(1) + + # Even better: + led1.on() + led2.on() + + Following is the guide when Signal vs Pin should be used: + + * Use Signal: If you want to control a simple on/off (including software + PWM!) devices like LEDs, multi-segment indicators, relays, buzzers, or + read simple binary sensors, like normally open or normally closed buttons, + pulled high or low, Reed switches, moisture/flame detectors, etc. etc. + Summing up, if you have a real physical device/sensor requiring GPIO + access, you likely should use a Signal. + + * Use Pin: If you implement a higher-level protocol or bus to communicate + with more complex devices. + + The split between Pin and Signal come from the use cases above and the + architecture of MicroPython: Pin offers the lowest overhead, which may + be important when bit-banging protocols. But Signal adds additional + flexibility on top of Pin, at the cost of minor overhead (much smaller + than if you implemented active-high vs active-low device differences in + Python manually!). Also, Pin is a low-level object which needs to be + implemented for each support board, while Signal is a high-level object + which comes for free once Pin is implemented. + + If in doubt, give the Signal a try! Once again, it is offered to save + developers from the need to handle unexciting differences like active-low + vs active-high signals, and allow other users to share and enjoy your + application, instead of being frustrated by the fact that it doesn't + work for them simply because their LEDs or relays are wired in a slightly + different way. + """ + def off(self) -> None: + """ + Deactivate signal. + """ + ... + def on(self) -> None: + """ + Activate signal. + """ + ... + + @overload + def value(self) -> int: + """ + This method allows to set and get the value of the signal, depending on whether + the argument ``x`` is supplied or not. + + If the argument is omitted then this method gets the signal level, 1 meaning + signal is asserted (active) and 0 - signal inactive. + + If the argument is supplied then this method sets the signal level. The + argument ``x`` can be anything that converts to a boolean. If it converts + to ``True``, the signal is active, otherwise it is inactive. + + Correspondence between signal being active and actual logic level on the + underlying pin depends on whether signal is inverted (active-low) or not. + For non-inverted signal, active status corresponds to logical 1, inactive - + to logical 0. For inverted/active-low signal, active status corresponds + to logical 0, while inactive - to logical 1. + """ + + @overload + def value(self, x: Any, /) -> None: + """ + This method allows to set and get the value of the signal, depending on whether + the argument ``x`` is supplied or not. + + If the argument is omitted then this method gets the signal level, 1 meaning + signal is asserted (active) and 0 - signal inactive. + + If the argument is supplied then this method sets the signal level. The + argument ``x`` can be anything that converts to a boolean. If it converts + to ``True``, the signal is active, otherwise it is inactive. + + Correspondence between signal being active and actual logic level on the + underlying pin depends on whether signal is inverted (active-low) or not. + For non-inverted signal, active status corresponds to logical 1, inactive - + to logical 0. For inverted/active-low signal, active status corresponds + to logical 0, while inactive - to logical 1. + """ + + @overload + def __init__(self, pin_obj: PinLike, invert: bool = False, /): + """ + Create a Signal object. There're two ways to create it: + + * By wrapping existing Pin object - universal method which works for + any board. + * By passing required Pin parameters directly to Signal constructor, + skipping the need to create intermediate Pin object. Available on + many, but not all boards. + + The arguments are: + + - ``pin_obj`` is existing Pin object. + + - ``pin_arguments`` are the same arguments as can be passed to Pin constructor. + + - ``invert`` - if True, the signal will be inverted (active low). + """ + + @overload + def __init__( + self, + id: PinLike, + /, + mode: int = -1, + pull: int = -1, + *, + value: Any = None, + drive: int | None = None, + alt: int | None = None, + invert: bool = False, + ): + """ + Create a Signal object. There're two ways to create it: + + * By wrapping existing Pin object - universal method which works for + any board. + * By passing required Pin parameters directly to Signal constructor, + skipping the need to create intermediate Pin object. Available on + many, but not all boards. + + The arguments are: + + - ``pin_obj`` is existing Pin object. + + - ``pin_arguments`` are the same arguments as can be passed to Pin constructor. + + - ``invert`` - if True, the signal will be inverted (active low). + """ + +class ADCBlock: + @overload + def connect(self, channel: int, **kwargs) -> ADC: ... + @overload + def connect(self, source: PinLike, **kwargs) -> ADC: ... + @overload + def connect(self, channel: int, source: PinLike, **kwargs) -> ADC: + """ + Connect up a channel on the ADC peripheral so it is ready for sampling, + and return an :ref:`ADC ` object that represents that connection. + + The *channel* argument must be an integer, and *source* must be an object + (for example a :ref:`Pin `) which can be connected up for sampling. + + If only *channel* is given then it is configured for sampling. + + If only *source* is given then that object is connected to a default + channel ready for sampling. + + If both *channel* and *source* are given then they are connected together + and made ready for sampling. + + Any additional keyword arguments are used to configure the returned ADC object, + via its :meth:`init ` method. + """ + ... + +class SDCard: + @overload + def readblocks(self, block_num: int, buf: bytearray) -> bool: + """ + The first form reads aligned, multiples of blocks. + Starting at the block given by the index *block_num*, read blocks from + the device into *buf* (an array of bytes). + The number of blocks to read is given by the length of *buf*, + which will be a multiple of the block size. + """ + + @overload + def readblocks(self, block_num: int, buf: bytearray, offset: int) -> bool: + """ + The second form allows reading at arbitrary locations within a block, + and arbitrary lengths. + Starting at block index *block_num*, and byte offset within that block + of *offset*, read bytes from the device into *buf* (an array of bytes). + The number of bytes to read is given by the length of *buf*. + """ + + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, /) -> None: + """ + The first form writes aligned, multiples of blocks, and requires that the + blocks that are written to be first erased (if necessary) by this method. + Starting at the block given by the index *block_num*, write blocks from + *buf* (an array of bytes) to the device. + The number of blocks to write is given by the length of *buf*, + which will be a multiple of the block size. + """ + + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, offset: int, /) -> None: + """ + The second form allows writing at arbitrary locations within a block, + and arbitrary lengths. Only the bytes being written should be changed, + and the caller of this method must ensure that the relevant blocks are + erased via a prior ``ioctl`` call. + Starting at block index *block_num*, and byte offset within that block + of *offset*, write bytes from *buf* (an array of bytes) to the device. + The number of bytes to write is given by the length of *buf*. + + Note that implementations must never implicitly erase blocks if the offset + argument is specified, even if it is zero. + """ diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/math.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/math.pyi new file mode 100644 index 0000000000..1d5f007d33 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/math.pyi @@ -0,0 +1,269 @@ +""" +Mathematical functions. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/math.html + +CPython module: :mod:`python:math` https://docs.python.org/3/library/math.html . + +The ``math`` module provides some basic mathematical functions for +working with floating-point numbers. + +*Note:* On the pyboard, floating-point numbers have 32-bit precision. + +Availability: not available on WiPy. Floating point support required +for this module. + +--- +Module: 'math' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import SupportsFloat, Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +inf: float = inf +nan: float = nan +pi: float = 3.1415928 +"""the ratio of a circle's circumference to its diameter""" +e: float = 2.7182818 +"""base of the natural logarithm""" +tau: float = 6.2831856 + +def ldexp(x: SupportsFloat, exp: int, /) -> float: + """ + Return ``x * (2**exp)``. + """ + ... + +def lgamma(x: SupportsFloat, /) -> float: + """ + Return the natural logarithm of the gamma function of ``x``. + """ + ... + +def trunc(x: SupportsFloat, /) -> int: + """ + Return an integer, being ``x`` rounded towards 0. + """ + ... + +def isclose(*args, **kwargs) -> Incomplete: ... +def gamma(x: SupportsFloat, /) -> float: + """ + Return the gamma function of ``x``. + """ + ... + +def isnan(x: SupportsFloat, /) -> bool: + """ + Return ``True`` if ``x`` is not-a-number + """ + ... + +def isfinite(x: SupportsFloat, /) -> bool: + """ + Return ``True`` if ``x`` is finite. + """ + ... + +def isinf(x: SupportsFloat, /) -> bool: + """ + Return ``True`` if ``x`` is infinite. + """ + ... + +def sqrt(x: SupportsFloat, /) -> float: + """ + Return the square root of ``x``. + """ + ... + +def sinh(x: SupportsFloat, /) -> float: + """ + Return the hyperbolic sine of ``x``. + """ + ... + +def log(x: SupportsFloat, /) -> float: + """ + With one argument, return the natural logarithm of *x*. + + With two arguments, return the logarithm of *x* to the given *base*. + """ + ... + +def tan(x: SupportsFloat, /) -> float: + """ + Return the tangent of ``x``. + """ + ... + +def tanh(x: SupportsFloat, /) -> float: + """ + Return the hyperbolic tangent of ``x``. + """ + ... + +def log2(x: SupportsFloat, /) -> float: + """ + Return the base-2 logarithm of ``x``. + """ + ... + +def log10(x: SupportsFloat, /) -> float: + """ + Return the base-10 logarithm of ``x``. + """ + ... + +def sin(x: SupportsFloat, /) -> float: + """ + Return the sine of ``x``. + """ + ... + +def modf(x: SupportsFloat, /) -> Tuple: + """ + Return a tuple of two floats, being the fractional and integral parts of + ``x``. Both return values have the same sign as ``x``. + """ + ... + +def radians(x: SupportsFloat, /) -> float: + """ + Return degrees ``x`` converted to radians. + """ + ... + +def atanh(x: SupportsFloat, /) -> float: + """ + Return the inverse hyperbolic tangent of ``x``. + """ + ... + +def atan2(y: SupportsFloat, x: SupportsFloat, /) -> float: + """ + Return the principal value of the inverse tangent of ``y/x``. + """ + ... + +def atan(x: SupportsFloat, /) -> float: + """ + Return the inverse tangent of ``x``. + """ + ... + +def ceil(x: SupportsFloat, /) -> int: + """ + Return an integer, being ``x`` rounded towards positive infinity. + """ + ... + +def copysign(x: SupportsFloat, y: SupportsFloat, /) -> float: + """ + Return ``x`` with the sign of ``y``. + """ + ... + +def frexp(x: SupportsFloat, /) -> tuple[float, 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`` + exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise + the relation ``0.5 <= abs(m) < 1`` holds. + """ + ... + +def acos(x: SupportsFloat, /) -> float: + """ + Return the inverse cosine of ``x``. + """ + ... + +def pow(x: SupportsFloat, y: SupportsFloat, /) -> float: + """ + Returns ``x`` to the power of ``y``. + """ + ... + +def asinh(x: SupportsFloat, /) -> float: + """ + Return the inverse hyperbolic sine of ``x``. + """ + ... + +def acosh(x: SupportsFloat, /) -> float: + """ + Return the inverse hyperbolic cosine of ``x``. + """ + ... + +def asin(x: SupportsFloat, /) -> float: + """ + Return the inverse sine of ``x``. + """ + ... + +def factorial(*args, **kwargs) -> Incomplete: ... +def fabs(x: SupportsFloat, /) -> float: + """ + Return the absolute value of ``x``. + """ + ... + +def expm1(x: SupportsFloat, /) -> float: + """ + Return ``exp(x) - 1``. + """ + ... + +def floor(x: SupportsFloat, /) -> int: + """ + Return an integer, being ``x`` rounded towards negative infinity. + """ + ... + +def fmod(x: SupportsFloat, y: SupportsFloat, /) -> float: + """ + Return the remainder of ``x/y``. + """ + ... + +def cos(x: SupportsFloat, /) -> float: + """ + Return the cosine of ``x``. + """ + ... + +def degrees(x: SupportsFloat, /) -> float: + """ + Return radians ``x`` converted to degrees. + """ + ... + +def cosh(x: SupportsFloat, /) -> float: + """ + Return the hyperbolic cosine of ``x``. + """ + ... + +def exp(x: SupportsFloat, /) -> float: + """ + Return the exponential of ``x``. + """ + ... + +def erf(x: SupportsFloat, /) -> float: + """ + Return the error function of ``x``. + """ + ... + +def erfc(x: SupportsFloat, /) -> float: + """ + Return the complementary error function of ``x``. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/micropython.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/micropython.pyi new file mode 100644 index 0000000000..4c83f10c9f --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/micropython.pyi @@ -0,0 +1,346 @@ +""" +Access and control MicroPython internals. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/micropython.html + +--- +Module: 'micropython' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import mp_available +from typing import Any, Callable, Optional, Tuple, overload +from typing_extensions import Awaitable, ParamSpec, TypeAlias, TypeVar + +_T = TypeVar("_T") +_F = TypeVar("_F", bound=Callable[..., Any]) +Const_T = TypeVar("Const_T", int, float, str, bytes, Tuple) +_Param = ParamSpec("_Param") +_Ret = TypeVar("_Ret") + +@overload +def opt_level() -> int: + """ + If *level* is given then this function sets the optimisation level for subsequent + compilation of scripts, and returns ``None``. Otherwise it returns the current + optimisation level. + + The optimisation level controls the following compilation features: + + - Assertions: at level 0 assertion statements are enabled and compiled into the + bytecode; at levels 1 and higher assertions are not compiled. + - Built-in ``__debug__`` variable: at level 0 this variable expands to ``True``; + at levels 1 and higher it expands to ``False``. + - Source-code line numbers: at levels 0, 1 and 2 source-code line number are + stored along with the bytecode so that exceptions can report the line number + they occurred at; at levels 3 and higher line numbers are not stored. + + The default optimisation level is usually level 0. + """ + +@overload +def opt_level(level: int, /) -> None: + """ + If *level* is given then this function sets the optimisation level for subsequent + compilation of scripts, and returns ``None``. Otherwise it returns the current + optimisation level. + + The optimisation level controls the following compilation features: + + - Assertions: at level 0 assertion statements are enabled and compiled into the + bytecode; at levels 1 and higher assertions are not compiled. + - Built-in ``__debug__`` variable: at level 0 this variable expands to ``True``; + at levels 1 and higher it expands to ``False``. + - Source-code line numbers: at levels 0, 1 and 2 source-code line number are + stored along with the bytecode so that exceptions can report the line number + they occurred at; at levels 3 and higher line numbers are not stored. + + The default optimisation level is usually level 0. + """ + +@overload +def mem_info() -> None: + """ + Print information about currently used memory. If the *verbose* argument + is given then extra information is printed. + + The information that is printed is implementation dependent, but currently + includes the amount of stack and heap used. In verbose mode it prints out + the entire heap indicating which blocks are used and which are free. + """ + +@overload +def mem_info(verbose: Any, /) -> None: + """ + Print information about currently used memory. If the *verbose* argument + is given then extra information is printed. + + The information that is printed is implementation dependent, but currently + includes the amount of stack and heap used. In verbose mode it prints out + the entire heap indicating which blocks are used and which are free. + """ + +def kbd_intr(chr: int) -> None: + """ + Set the character that will raise a `KeyboardInterrupt` exception. By + default this is set to 3 during script execution, corresponding to Ctrl-C. + Passing -1 to this function will disable capture of Ctrl-C, and passing 3 + will restore it. + + This function can be used to prevent the capturing of Ctrl-C on the + incoming stream of characters that is usually used for the REPL, in case + that stream is used for other purposes. + """ + ... + +@overload +def qstr_info() -> None: + """ + Print information about currently interned strings. If the *verbose* + argument is given then extra information is printed. + + The information that is printed is implementation dependent, but currently + includes the number of interned strings and the amount of RAM they use. In + verbose mode it prints out the names of all RAM-interned strings. + """ + +@overload +def qstr_info(verbose: bool, /) -> None: + """ + Print information about currently interned strings. If the *verbose* + argument is given then extra information is printed. + + The information that is printed is implementation dependent, but currently + includes the number of interned strings and the amount of RAM they use. In + verbose mode it prints out the names of all RAM-interned strings. + """ + +def schedule(func: Callable[[_T], None], arg: _T, /) -> None: + """ + Schedule the function *func* to be executed "very soon". The function + is passed the value *arg* as its single argument. "Very soon" means that + the MicroPython runtime will do its best to execute the function at the + earliest possible time, given that it is also trying to be efficient, and + that the following conditions hold: + + - A scheduled function will never preempt another scheduled function. + - Scheduled functions are always executed "between opcodes" which means + that all fundamental Python operations (such as appending to a list) + are guaranteed to be atomic. + - A given port may define "critical regions" within which scheduled + functions will never be executed. Functions may be scheduled within + a critical region but they will not be executed until that region + is exited. An example of a critical region is a preempting interrupt + handler (an IRQ). + + A use for this function is to schedule a callback from a preempting IRQ. + Such an IRQ puts restrictions on the code that runs in the IRQ (for example + the heap may be locked) and scheduling a function to call later will lift + those restrictions. + + On multi-threaded ports, the scheduled function's behaviour depends on + whether the Global Interpreter Lock (GIL) is enabled for the specific port: + + - If GIL is enabled, the function can preempt any thread and run in its + context. + - If GIL is disabled, the function will only preempt the main thread and run + in its context. + + Note: If `schedule()` is called from a preempting IRQ, when memory + allocation is not allowed and the callback to be passed to `schedule()` is + a bound method, passing this directly will fail. This is because creating a + reference to a bound method causes memory allocation. A solution is to + create a reference to the method in the class constructor and to pass that + reference to `schedule()`. This is discussed in detail here + :ref:`reference documentation ` under "Creation of Python + objects". + + There is a finite queue to hold the scheduled functions and `schedule()` + will raise a `RuntimeError` if the queue is full. + """ + ... + +def stack_use() -> int: + """ + Return an integer representing the current amount of stack that is being + used. The absolute value of this is not particularly useful, rather it + should be used to compute differences in stack usage at different points. + """ + ... + +def heap_unlock() -> int: + """ + Lock or unlock the heap. When locked no memory allocation can occur and a + `MemoryError` will be raised if any heap allocation is attempted. + `heap_locked()` returns a true value if the heap is currently locked. + + These functions can be nested, ie `heap_lock()` can be called multiple times + in a row and the lock-depth will increase, and then `heap_unlock()` must be + called the same number of times to make the heap available again. + + Both `heap_unlock()` and `heap_locked()` return the current lock depth + (after unlocking for the former) as a non-negative integer, with 0 meaning + the heap is not locked. + + If the REPL becomes active with the heap locked then it will be forcefully + unlocked. + + Note: `heap_locked()` is not enabled on most ports by default, + requires ``MICROPY_PY_MICROPYTHON_HEAP_LOCKED``. + """ + ... + +def const(expr: Const_T, /) -> Const_T: + """ + Used to declare that the expression is a constant so that the compiler can + optimise it. The use of this function should be as follows:: + + from micropython import const + + CONST_X = const(123) + CONST_Y = const(2 * CONST_X + 1) + + Constants declared this way are still accessible as global variables from + outside the module they are declared in. On the other hand, if a constant + begins with an underscore then it is hidden, it is not available as a global + variable, and does not take up any memory during execution. + + This `const` function is recognised directly by the MicroPython parser and is + provided as part of the :mod:`micropython` module mainly so that scripts can be + written which run under both CPython and MicroPython, by following the above + pattern. + """ + ... + +def heap_lock() -> int: + """ + Lock or unlock the heap. When locked no memory allocation can occur and a + `MemoryError` will be raised if any heap allocation is attempted. + `heap_locked()` returns a true value if the heap is currently locked. + + These functions can be nested, ie `heap_lock()` can be called multiple times + in a row and the lock-depth will increase, and then `heap_unlock()` must be + called the same number of times to make the heap available again. + + Both `heap_unlock()` and `heap_locked()` return the current lock depth + (after unlocking for the former) as a non-negative integer, with 0 meaning + the heap is not locked. + + If the REPL becomes active with the heap locked then it will be forcefully + unlocked. + + Note: `heap_locked()` is not enabled on most ports by default, + requires ``MICROPY_PY_MICROPYTHON_HEAP_LOCKED``. + """ + ... + +def alloc_emergency_exception_buf(size: int, /) -> None: + """ + Allocate *size* bytes of RAM for the emergency exception buffer (a good + size is around 100 bytes). The buffer is used to create exceptions in cases + when normal RAM allocation would fail (eg within an interrupt handler) and + therefore give useful traceback information in these situations. + + A good way to use this function is to put it at the start of your main script + (eg ``boot.py`` or ``main.py``) and then the emergency exception buffer will be active + for all the code following it. + """ + ... + +class RingIO: + def readinto(self, buf, nbytes: Optional[Any] = None) -> int: + """ + Read available bytes into the provided ``buf``. If ``nbytes`` is + specified then read at most that many bytes. Otherwise, read at + most ``len(buf)`` bytes. + + Return value: Integer count of the number of bytes read into ``buf``. + """ + ... + def write(self, buf) -> int: + """ + Non-blocking write of bytes from ``buf`` into the ringbuffer, limited + by the available space in the ringbuffer. + + Return value: Integer count of bytes written. + """ + ... + def readline(self, nbytes: Optional[Any] = None) -> bytes: + """ + Read a line, ending in a newline character or return if one exists in + the buffer, else return available bytes in buffer. If ``nbytes`` is + specified then read at most that many bytes. + + Return value: a bytes object containing the line read. + """ + ... + def any(self) -> int: + """ + Returns an integer counting the number of characters that can be read. + """ + ... + def read(self, nbytes: Optional[Any] = None) -> bytes: + """ + Read available characters. This is a non-blocking function. If ``nbytes`` + is specified then read at most that many bytes, otherwise read as much + data as possible. + + Return value: a bytes object containing the bytes read. Will be + zero-length bytes object if no data is available. + """ + ... + def close(self) -> Incomplete: + """ + No-op provided as part of standard `stream` interface. Has no effect + on data in the ringbuffer. + """ + ... + def __init__(self, size) -> None: ... + +# decorators +@mp_available() # force merge +def viper(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]: + """ + The Viper code emitter is not fully compliant. It supports special Viper native data types in pursuit of performance. + Integer processing is non-compliant because it uses machine words: arithmetic on 32 bit hardware is performed modulo 2**32. + Like the Native emitter Viper produces machine instructions but further optimisations are performed, substantially increasing + performance especially for integer arithmetic and bit manipulations. + See: https://docs.micropython.org/en/latest/reference/speed_python.html?highlight=viper#the-native-code-emitter + """ + ... + +@mp_available() # force merge +def native(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]: + """ + This causes the MicroPython compiler to emit native CPU opcodes rather than bytecode. + It covers the bulk of the MicroPython functionality, so most functions will require no adaptation. + See: https://docs.micropython.org/en/latest/reference/speed_python.html#the-native-code-emitter + """ + ... + +@mp_available(macro="MICROPY_EMIT_INLINE_THUMB") # force merge +def asm_thumb(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]: + """ + This decorator is used to mark a function as containing inline assembler code. + The assembler code is written is a subset of the ARM Thumb-2 instruction set, and is executed on the target CPU. + + Availability: Only on specific boards where MICROPY_EMIT_INLINE_THUMB is defined. + See: https://docs.micropython.org/en/latest/reference/asm_thumb2_index.html + """ + ... + +@mp_available(port="esp8266") # force merge +def asm_xtensa(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]: + """ + This decorator is used to mark a function as containing inline assembler code for the esp8266. + The assembler code is written in the Xtensa instruction set, and is executed on the target CPU. + + Availability: Only on eps8266 boards. + """ + ... + # See : + # - https://github.com/orgs/micropython/discussions/12965 + # - https://github.com/micropython/micropython/pull/16731 diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/mip/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/mip/__init__.pyi new file mode 100644 index 0000000000..5aba52ded5 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/mip/__init__.pyi @@ -0,0 +1,36 @@ +""" +Module: 'mip.__init__' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +allowed_mip_url_prefixes: tuple = () +def _ensure_path_exists(*args, **kwargs) -> Incomplete: + ... + +def _install_json(*args, **kwargs) -> Incomplete: + ... + +def _install_package(*args, **kwargs) -> Incomplete: + ... + +def _rewrite_url(*args, **kwargs) -> Incomplete: + ... + +def const(*args, **kwargs) -> Incomplete: + ... + +def _download_file(*args, **kwargs) -> Incomplete: + ... + +def install(*args, **kwargs) -> Incomplete: + ... + +def _check_exists(*args, **kwargs) -> Incomplete: + ... + +def _chunk(*args, **kwargs) -> Incomplete: + ... + diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/neopixel.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/neopixel.pyi new file mode 100644 index 0000000000..c5677555cd --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/neopixel.pyi @@ -0,0 +1,73 @@ +""" +Control of WS2812 / NeoPixel LEDs. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/neopixel.html + +This module provides a driver for WS2818 / NeoPixel LEDs. + +``Note:`` This module is only included by default on the ESP8266, ESP32 and RP2 + ports. On STM32 / Pyboard and others, you can either install the + ``neopixel`` package using :term:`mip`, or you can download the module + directly from :term:`micropython-lib` and copy it to the filesystem. + +--- +Module: 'neopixel' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import _NeoPixelBase +from machine import Pin +from typing import Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_Color: TypeAlias = tuple[int, int, int] | tuple[int, int, int, int] + +def bitstream(*args, **kwargs) -> Incomplete: ... + +class NeoPixel(_NeoPixelBase): + """ + This class stores pixel data for a WS2812 LED strip connected to a pin. The + application should set pixel data and then call :meth:`NeoPixel.write` + when it is ready to update the strip. + + For example:: + + import neopixel + + # 32 LED strip connected to X8. + p = machine.Pin.board.X8 + n = neopixel.NeoPixel(p, 32) + + # Draw a red gradient. + for i in range(32): + n[i] = (i * 8, 0, 0) + + # Update the strip. + n.write() + """ + + ORDER: tuple = () + def write(self) -> None: + """ + Writes the current pixel data to the strip. + """ + ... + def fill(self, pixel: _Color, /) -> None: + """ + Sets the value of all pixels to the specified *pixel* value (i.e. an + RGB/RGBW tuple). + """ + ... + def __init__(self, pin: Pin, n: int, /, *, bpp: int = 3, timing: int = 1) -> None: + """ + Construct an NeoPixel object. The parameters are: + + - *pin* is a machine.Pin instance. + - *n* is the number of LEDs in the strip. + - *bpp* is 3 for RGB LEDs, and 4 for RGBW LEDs. + - *timing* is 0 for 400KHz, and 1 for 800kHz LEDs (most are 800kHz). + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/network.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/network.pyi new file mode 100644 index 0000000000..f586ebd422 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/network.pyi @@ -0,0 +1,577 @@ +""" +Network configuration. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/network.html + +This module provides network drivers and routing configuration. To use this +module, a MicroPython variant/build with network capabilities must be installed. +Network drivers for specific hardware are available within this module and are +used to configure hardware network interface(s). Network services provided +by configured interfaces are then available for use via the :mod:`socket` +module. + +For example:: + + # connect/ show IP config a specific network interface + # see below for examples of specific drivers + import network + import time + nic = network.Driver(...) + if not nic.isconnected(): + nic.connect() + print("Waiting for connection...") + while not nic.isconnected(): + time.sleep(1) + print(nic.ipconfig("addr4")) + + # now use socket as usual + import socket + addr = socket.getaddrinfo('micropython.org', 80)[0][-1] + s = socket.socket() + s.connect(addr) + s.send(b'GET / HTTP/1.1 + +Host: micropython.org + + + +') + data = s.recv(1000) + s.close() + +--- +Module: 'network' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Protocol, Callable, List, Optional, Any, Tuple, overload, Final +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar +from machine import Pin, SPI +from abc import abstractmethod + +STA_IF: Final[int] = 0 +STAT_IDLE: Final[int] = 0 +STAT_NO_AP_FOUND: Final[int] = -2 +STAT_WRONG_PASSWORD: Final[int] = -3 +STAT_GOT_IP: Final[int] = 3 +AP_IF: Final[int] = 1 +STAT_CONNECTING: Final[int] = 1 +STAT_CONNECT_FAIL: Final[int] = -1 + +def hostname(name: Optional[Any] = None) -> Incomplete: + """ + Get or set the hostname that will identify this device on the network. It will + be used by all interfaces. + + This hostname is used for: + * Sending to the DHCP server in the client request. (If using DHCP) + * Broadcasting via mDNS. (If enabled) + + If the *name* parameter is provided, the hostname will be set to this value. + If the function is called without parameters, it returns the current + hostname. + + A change in hostname is typically only applied during connection. For DHCP + this is because the hostname is part of the DHCP client request, and the + implementation of mDNS in most ports only initialises the hostname once + during connection. For this reason, you must set the hostname before + activating/connecting your network interfaces. + + The length of the hostname is limited to 32 characters. + :term:`MicroPython ports ` may choose to set a lower + limit for memory reasons. If the given name does not fit, a `ValueError` + is raised. + + The default hostname is typically the name of the board. + """ + ... + +def ipconfig(param: Optional[str] = None, *args, **kwargs) -> str: + """ + Get or set global IP-configuration parameters. + Supported parameters are the following (availability of a particular + parameter depends on the port and the specific network interface): + + * ``dns`` Get/set DNS server. This method can support both, IPv4 and + IPv6 addresses. + * ``prefer`` (``4/6``) Specify which address type to return, if a domain + name has both A and AAAA records. Note, that this does not clear the + local DNS cache, so that any previously obtained addresses might not + change. + """ + ... + +def route(*args, **kwargs) -> Incomplete: ... +def country(code: Optional[Any] = None) -> Incomplete: + """ + Get or set the two-letter ISO 3166-1 Alpha-2 country code to be used for + radio compliance. + + If the *code* parameter is provided, the country will be set to this value. + If the function is called without parameters, it returns the current + country. + + The default code ``"XX"`` represents the "worldwide" region. + """ + ... + +class WLAN: + """ + Create a WLAN network interface object. Supported interfaces are + ``network.WLAN.IF_STA`` (station aka client, connects to upstream WiFi access + points) and ``network.WLAN.IF_AP`` (access point, allows other WiFi clients to + connect). Availability of the methods below depends on interface type. + For example, only STA interface may `WLAN.connect()` to an access point. + """ + + PM_POWERSAVE: Final[int] = 17 + SEC_OPEN: Final[int] = 0 + SEC_WPA2_WPA3: Final[int] = 20971524 + SEC_WPA3: Final[int] = 16777220 + SEC_WPA_WPA2: Final[int] = 4194310 + PM_PERFORMANCE: Final[int] = 10555714 + """\ + WLAN.PM_POWERSAVE + WLAN.PM_NONE + + Allowed values for the ``WLAN.config(pm=...)`` network interface parameter: + + * ``PM_PERFORMANCE``: enable WiFi power management to balance power + savings and WiFi performance + * ``PM_POWERSAVE``: enable WiFi power management with additional power + savings and reduced WiFi performance + * ``PM_NONE``: disable wifi power management + """ + IF_AP: Final[int] = 1 + IF_STA: Final[int] = 0 + PM_NONE: Final[int] = 16 + PROTOCOL_DEFAULTS: Incomplete + PROTOCOL_LR: Incomplete + def ipconfig(self, *args, **kwargs) -> Incomplete: ... + def status(self, param: Optional[Any] = None) -> List[int]: + """ + Return the current status of the wireless connection. + + When called with no argument the return value describes the network link status. + The possible statuses are defined as constants in the :mod:`network` module: + + * ``STAT_IDLE`` -- no connection and no activity, + * ``STAT_CONNECTING`` -- connecting in progress, + * ``STAT_WRONG_PASSWORD`` -- failed due to incorrect password, + * ``STAT_NO_AP_FOUND`` -- failed because no access point replied, + * ``STAT_CONNECT_FAIL`` -- failed due to other problems, + * ``STAT_GOT_IP`` -- connection successful. + + When called with one argument *param* should be a string naming the status + parameter to retrieve, and different parameters are supported depending on the + mode the WiFi is in. + + In STA mode, passing ``'rssi'`` returns a signal strength indicator value, whose + format varies depending on the port (this is available on all ports that support + WiFi network interfaces, except for CC3200). + + In AP mode, passing ``'stations'`` returns a list of connected WiFi stations + (this is available on all ports that support WiFi network interfaces, except for + CC3200). The format of the station information entries varies across ports, + providing either the raw BSSID of the connected station, the IP address of the + connected station, or both. + """ + ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def send_ethernet(self, *args, **kwargs) -> Incomplete: ... + def isconnected(self) -> bool: + """ + In case of STA mode, returns ``True`` if connected to a WiFi access + point and has a valid IP address. In AP mode returns ``True`` when a + station is connected. Returns ``False`` otherwise. + """ + ... + def scan(self) -> List[Tuple]: + """ + Scan for the available wireless networks. + Hidden networks -- where the SSID is not broadcast -- will also be scanned + if the WLAN interface allows it. + + Scanning is only possible on STA interface. Returns list of tuples with + the information about WiFi access points: + + (ssid, bssid, channel, RSSI, security, hidden) + + *bssid* is hardware address of an access point, in binary form, returned as + bytes object. You can use `binascii.hexlify()` to convert it to ASCII form. + + There are five values for security: + + * 0 -- open + * 1 -- WEP + * 2 -- WPA-PSK + * 3 -- WPA2-PSK + * 4 -- WPA/WPA2-PSK + + and two for hidden: + + * 0 -- visible + * 1 -- hidden + """ + ... + def config(self, *args, **kwargs) -> Incomplete: + """ + Get or set general network interface parameters. These methods allow to work + with additional parameters beyond standard IP configuration (as dealt with by + `AbstractNIC.ipconfig()`). These include network-specific and hardware-specific + parameters. For setting parameters, keyword argument syntax should be used, + multiple parameters can be set at once. For querying, parameters name should + be quoted as a string, and only one parameter can be queries at time:: + + # Set WiFi access point name (formally known as SSID) and WiFi channel + ap.config(ssid='My AP', channel=11) + # Query params one by one + print(ap.config('ssid')) + print(ap.config('channel')) + + Following are commonly supported parameters (availability of a specific parameter + depends on network technology type, driver, and :term:`MicroPython port`). + + ============= =========== + Parameter Description + ============= =========== + mac MAC address (bytes) + ssid WiFi access point name (string) + channel WiFi channel (integer). Depending on the port this may only be supported on the AP interface. + hidden Whether SSID is hidden (boolean) + security Security protocol supported (enumeration, see module constants) + key Access key (string) + hostname The hostname that will be sent to DHCP (STA interfaces) and mDNS (if supported, both STA and AP). (Deprecated, use :func:`network.hostname` instead) + reconnects Number of reconnect attempts to make (integer, 0=none, -1=unlimited) + txpower Maximum transmit power in dBm (integer or float) + pm WiFi Power Management setting (see below for allowed values) + protocol (ESP32 Only.) WiFi Low level 802.11 protocol. See `WLAN.PROTOCOL_DEFAULTS`. + ============= =========== + """ + ... + def ifconfig(self, configtuple: Optional[Any] = None) -> Tuple: + """ + Get/set IP-level network interface parameters: IP address, subnet mask, + gateway and DNS server. When called with no arguments, this method returns + a 4-tuple with the above information. To set the above values, pass a + 4-tuple with the required information. For example:: + + nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) + """ + ... + def active(self, is_active: Optional[Any] = None) -> None: + """ + Activate ("up") or deactivate ("down") network interface, if boolean + argument is passed. Otherwise, query current state if no argument is + provided. Most other methods require active interface. + """ + ... + def disconnect(self) -> None: + """ + Disconnect from the currently connected wireless network. + """ + ... + def connect(self, ssid=None, key=None, *, bssid=None) -> None: + """ + Connect to the specified wireless network, using the specified key. + If *bssid* is given then the connection will be restricted to the + access-point with that MAC address (the *ssid* must also be specified + in this case). + """ + ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, interface_id) -> None: ... + +class LAN: + @overload + def active(self, /) -> bool: + """ + With a parameter, it sets the interface active if *state* is true, otherwise it + sets it inactive. + Without a parameter, it returns the state. + """ + + @overload + def active(self, is_active: bool | int, /) -> None: + """ + With a parameter, it sets the interface active if *state* is true, otherwise it + sets it inactive. + Without a parameter, it returns the state. + """ + +class WLANWiPy: + @overload + def __init__(self, id: int = 0, /): + """ + Create a WLAN object, and optionally configure it. See `init()` for params of configuration. + + .. note:: + + The ``WLAN`` constructor is special in the sense that if no arguments besides the id are given, + it will return the already existing ``WLAN`` instance without re-configuring it. This is + because ``WLAN`` is a system feature of the WiPy. If the already existing instance is not + initialized it will do the same as the other constructors an will initialize it with default + values. + """ + + @overload + def __init__( + self, + id: int, + /, + *, + mode: int, + ssid: str, + auth: tuple[str, str], + channel: int, + antenna: int, + ): + """ + Create a WLAN object, and optionally configure it. See `init()` for params of configuration. + + .. note:: + + The ``WLAN`` constructor is special in the sense that if no arguments besides the id are given, + it will return the already existing ``WLAN`` instance without re-configuring it. This is + because ``WLAN`` is a system feature of the WiPy. If the already existing instance is not + initialized it will do the same as the other constructors an will initialize it with default + values. + """ + + @overload + def mode(self) -> int: + """ + Get or set the WLAN mode. + """ + + @overload + def mode(self, mode: int, /) -> None: + """ + Get or set the WLAN mode. + """ + + @overload + def ssid(self) -> str: + """ + Get or set the SSID when in AP mode. + """ + + @overload + def ssid(self, ssid: str, /) -> None: + """ + Get or set the SSID when in AP mode. + """ + + @overload + def auth(self) -> int: + """ + Get or set the authentication type when in AP mode. + """ + + @overload + def auth(self, auth: int, /) -> None: + """ + Get or set the authentication type when in AP mode. + """ + + @overload + def channel(self) -> int: + """ + Get or set the channel (only applicable in AP mode). + """ + + @overload + def channel(self, channel: int, /) -> None: + """ + Get or set the channel (only applicable in AP mode). + """ + + @overload + def antenna(self) -> int: + """ + Get or set the antenna type (external or internal). + """ + + @overload + def antenna(self, antenna: int, /) -> None: + """ + Get or set the antenna type (external or internal). + """ + + @overload + def mac(self) -> bytes: + """ + Get or set a 6-byte long bytes object with the MAC address. + """ + + @overload + def mac(self, mac: bytes, /) -> None: + """ + Get or set a 6-byte long bytes object with the MAC address. + """ + +class AbstractNIC: + @overload + @abstractmethod + def active(self, /) -> bool: + """ + Activate ("up") or deactivate ("down") the network interface, if + a boolean argument is passed. Otherwise, query current state if + no argument is provided. Most other methods require an active + interface (behaviour of calling them on inactive interface is + undefined). + """ + + @overload + @abstractmethod + def active(self, is_active: bool | int, /) -> None: + """ + Activate ("up") or deactivate ("down") the network interface, if + a boolean argument is passed. Otherwise, query current state if + no argument is provided. Most other methods require an active + interface (behaviour of calling them on inactive interface is + undefined). + """ + + @overload + @abstractmethod + def connect(self, key: str | None = None, /, **kwargs: Any) -> None: + """ + Connect the interface to a network. This method is optional, and + available only for interfaces which are not "always connected". + If no parameters are given, connect to the default (or the only) + service. If a single parameter is given, it is the primary identifier + of a service to connect to. It may be accompanied by a key + (password) required to access said service. There can be further + arbitrary keyword-only parameters, depending on the networking medium + type and/or particular device. Parameters can be used to: a) + specify alternative service identifier types; b) provide additional + connection parameters. For various medium types, there are different + sets of predefined/recommended parameters, among them: + + * WiFi: *bssid* keyword to connect to a specific BSSID (MAC address) + """ + + @overload + @abstractmethod + def connect(self, service_id: Any, key: str | None = None, /, **kwargs: Any) -> None: + """ + Connect the interface to a network. This method is optional, and + available only for interfaces which are not "always connected". + If no parameters are given, connect to the default (or the only) + service. If a single parameter is given, it is the primary identifier + of a service to connect to. It may be accompanied by a key + (password) required to access said service. There can be further + arbitrary keyword-only parameters, depending on the networking medium + type and/or particular device. Parameters can be used to: a) + specify alternative service identifier types; b) provide additional + connection parameters. For various medium types, there are different + sets of predefined/recommended parameters, among them: + + * WiFi: *bssid* keyword to connect to a specific BSSID (MAC address) + """ + + @overload + @abstractmethod + def status(self) -> Any: + """ + Query dynamic status information of the interface. When called with no + argument the return value describes the network link status. Otherwise + *param* should be a string naming the particular status parameter to + retrieve. + + The return types and values are dependent on the network + medium/technology. Some of the parameters that may be supported are: + + * WiFi STA: use ``'rssi'`` to retrieve the RSSI of the AP signal + * WiFi AP: use ``'stations'`` to retrieve a list of all the STAs + connected to the AP. The list contains tuples of the form + (MAC, RSSI). + """ + + @overload + @abstractmethod + def status(self, param: str, /) -> Any: + """ + Query dynamic status information of the interface. When called with no + argument the return value describes the network link status. Otherwise + *param* should be a string naming the particular status parameter to + retrieve. + + The return types and values are dependent on the network + medium/technology. Some of the parameters that may be supported are: + + * WiFi STA: use ``'rssi'`` to retrieve the RSSI of the AP signal + * WiFi AP: use ``'stations'`` to retrieve a list of all the STAs + connected to the AP. The list contains tuples of the form + (MAC, RSSI). + """ + + @overload + @abstractmethod + def ifconfig(self) -> tuple[str, str, str, str]: + """ + ``Note:`` This function is deprecated, use `ipconfig()` instead. + + Get/set IP-level network interface parameters: IP address, subnet mask, + gateway and DNS server. When called with no arguments, this method returns + a 4-tuple with the above information. To set the above values, pass a + 4-tuple with the required information. For example:: + + nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) + """ + + @overload + @abstractmethod + def ifconfig(self, ip_mask_gateway_dns: tuple[str, str, str, str], /) -> None: + """ + ``Note:`` This function is deprecated, use `ipconfig()` instead. + + Get/set IP-level network interface parameters: IP address, subnet mask, + gateway and DNS server. When called with no arguments, this method returns + a 4-tuple with the above information. To set the above values, pass a + 4-tuple with the required information. For example:: + + nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) + """ + + @overload + @abstractmethod + def config(self, param: str, /) -> Any: + """ + Get or set general network interface parameters. These methods allow to work + with additional parameters beyond standard IP configuration (as dealt with by + `ipconfig()`). These include network-specific and hardware-specific + parameters. For setting parameters, the keyword argument + syntax should be used, and multiple parameters can be set at once. For + querying, a parameter name should be quoted as a string, and only one + parameter can be queried at a time:: + + # Set WiFi access point name (formally known as SSID) and WiFi channel + ap.config(ssid='My AP', channel=11) + # Query params one by one + print(ap.config('ssid')) + print(ap.config('channel')) + """ + + @overload + @abstractmethod + def config(self, **kwargs: Any) -> None: + """ + Get or set general network interface parameters. These methods allow to work + with additional parameters beyond standard IP configuration (as dealt with by + `ipconfig()`). These include network-specific and hardware-specific + parameters. For setting parameters, the keyword argument + syntax should be used, and multiple parameters can be set at once. For + querying, a parameter name should be quoted as a string, and only one + parameter can be queried at a time:: + + # Set WiFi access point name (formally known as SSID) and WiFi channel + ap.config(ssid='My AP', channel=11) + # Query params one by one + print(ap.config('ssid')) + print(ap.config('channel')) + """ diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ntptime.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ntptime.pyi new file mode 100644 index 0000000000..4d97d88d53 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ntptime.pyi @@ -0,0 +1,15 @@ +""" +Module: 'ntptime' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +timeout: int = 1 +host: str = "pool.ntp.org" + +def time(*args, **kwargs) -> Incomplete: ... +def settime(*args, **kwargs) -> Incomplete: ... +def gmtime(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/onewire.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/onewire.pyi new file mode 100644 index 0000000000..1c8b44b318 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/onewire.pyi @@ -0,0 +1,28 @@ +""" +Module: 'onewire' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +class OneWireError(Exception): ... + +class OneWire: + SKIP_ROM: Final[int] = 204 + SEARCH_ROM: Final[int] = 240 + MATCH_ROM: Final[int] = 85 + def select_rom(self, *args, **kwargs) -> Incomplete: ... + def writebit(self, *args, **kwargs) -> Incomplete: ... + def writebyte(self, *args, **kwargs) -> Incomplete: ... + def _search_rom(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def crc8(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def reset(self, *args, **kwargs) -> Incomplete: ... + def readbit(self, *args, **kwargs) -> Incomplete: ... + def readbyte(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/platform.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/platform.pyi new file mode 100644 index 0000000000..e2d5aa460a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/platform.pyi @@ -0,0 +1,51 @@ +""" +Access to underlying platform’s identifying data. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/platform.html + +CPython module: :mod:`python:platform` https://docs.python.org/3/library/platform.html . + +This module tries to retrieve as much platform-identifying data as possible. It +makes this information available via function APIs. + +--- +Module: 'platform' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from typing import Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def platform() -> str: + """ + Returns a string identifying the underlying platform. This string is composed + of several substrings in the following order, delimited by dashes (``-``): + + - the name of the platform system (e.g. Unix, Windows or MicroPython) + - the MicroPython version + - the architecture of the platform + - the version of the underlying platform + - the concatenation of the name of the libc that MicroPython is linked to + and its corresponding version. + + For example, this could be + ``"MicroPython-1.20.0-xtensa-IDFv4.2.4-with-newlib3.0.0"``. + """ + ... + +def python_compiler() -> str: + """ + Returns a string identifying the compiler used for compiling MicroPython. + """ + ... + +def libc_ver() -> Tuple: + """ + Returns a tuple of strings *(lib, version)*, where *lib* is the name of the + libc that MicroPython is linked to, and *version* the corresponding version + of this libc. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/random.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/random.pyi new file mode 100644 index 0000000000..f62e718b0a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/random.pyi @@ -0,0 +1,115 @@ +""" +Random numbers. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/random.html + +This module implements a pseudo-random number generator (PRNG). + +CPython module: :mod:`python:random` https://docs.python.org/3/library/random.html . . + +.. note:: + + The following notation is used for intervals: + + - () are open interval brackets and do not include their endpoints. + For example, (0, 1) means greater than 0 and less than 1. + In set notation: (0, 1) = {x | 0 < x < 1}. + + - [] are closed interval brackets which include all their limit points. + For example, [0, 1] means greater than or equal to 0 and less than + or equal to 1. + In set notation: [0, 1] = {x | 0 <= x <= 1}. + +.. note:: + + The :func:`randrange`, :func:`randint` and :func:`choice` functions are only + available if the ``MICROPY_PY_RANDOM_EXTRA_FUNCS`` configuration option is + enabled. + +--- +Module: 'random' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import Subscriptable +from typing import overload +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_T = TypeVar("_T") + +@overload +def randrange(stop: int, /) -> int: + """ + The first form returns a random integer from the range [0, *stop*). + The second form returns a random integer from the range [*start*, *stop*). + The third form returns a random integer from the range [*start*, *stop*) in + steps of *step*. For instance, calling ``randrange(1, 10, 2)`` will + return odd numbers between 1 and 9 inclusive. + """ + +@overload +def randrange(start: int, stop: int, /) -> int: + """ + The first form returns a random integer from the range [0, *stop*). + The second form returns a random integer from the range [*start*, *stop*). + The third form returns a random integer from the range [*start*, *stop*) in + steps of *step*. For instance, calling ``randrange(1, 10, 2)`` will + return odd numbers between 1 and 9 inclusive. + """ + +@overload +def randrange(start: int, stop: int, step: int, /) -> int: + """ + The first form returns a random integer from the range [0, *stop*). + The second form returns a random integer from the range [*start*, *stop*). + The third form returns a random integer from the range [*start*, *stop*) in + steps of *step*. For instance, calling ``randrange(1, 10, 2)`` will + return odd numbers between 1 and 9 inclusive. + """ + +def random() -> int: + """ + Return a random floating point number in the range [0.0, 1.0). + """ + ... + +def seed(n: int | None = None, /) -> None: + """ + Initialise the random number generator module with the seed *n* which should + be an integer. When no argument (or ``None``) is passed in it will (if + supported by the port) initialise the PRNG with a true random number + (usually a hardware generated random number). + + The ``None`` case only works if ``MICROPY_PY_RANDOM_SEED_INIT_FUNC`` is + enabled by the port, otherwise it raises ``ValueError``. + """ + ... + +def uniform(a: float, b: float) -> int: + """ + Return a random floating point number N such that *a* <= N <= *b* for *a* <= *b*, + and *b* <= N <= *a* for *b* < *a*. + """ + ... + +def choice(sequence: Subscriptable, /) -> None: + """ + Chooses and returns one item at random from *sequence* (tuple, list or + any object that supports the subscript operation). + """ + ... + +def randint(a: int, b: int, /) -> int: + """ + Return a random integer in the range [*a*, *b*]. + """ + ... + +def getrandbits(n: int, /) -> int: + """ + Return an integer with *n* random bits (0 <= n <= 32). + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/requests/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/requests/__init__.pyi new file mode 100644 index 0000000000..1d48b0fa2c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/requests/__init__.pyi @@ -0,0 +1,42 @@ +""" +Module: 'requests.__init__' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def delete(*args, **kwargs) -> Incomplete: + ... + +def head(*args, **kwargs) -> Incomplete: + ... + +def patch(*args, **kwargs) -> Incomplete: + ... + +def post(*args, **kwargs) -> Incomplete: + ... + +def request(*args, **kwargs) -> Incomplete: + ... + +def put(*args, **kwargs) -> Incomplete: + ... + +def get(*args, **kwargs) -> Incomplete: + ... + + +class Response(): + def json(self, *args, **kwargs) -> Incomplete: + ... + + def close(self, *args, **kwargs) -> Incomplete: + ... + + content: Incomplete ## = + text: Incomplete ## = + def __init__(self, *argv, **kwargs) -> None: + ... + diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/rp2/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/rp2/__init__.pyi new file mode 100644 index 0000000000..3aa5dce1e3 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/rp2/__init__.pyi @@ -0,0 +1,993 @@ +""" +Functionality specific to the RP2. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/rp2.html + +The ``rp2`` module contains functions and classes specific to the RP2040, as +used in the Raspberry Pi Pico. + +See the `RP2040 Python datasheet +`_ +for more information, and `pico-micropython-examples +`_ +for example code. + +--- +Module: 'rp2.PIOASMEmit' + +--- +This module provides type hints for the `rp2.asm_pio` module in the Raspberry Pi Pico Python SDK. +It includes definitions for constants, functions, and directives used in PIO assembly programming. + +The module includes docstrings for each function and directive, providing information on their usage and parameters. + +Note: This module is intended for use with type checking and does not contain actual implementations of the functions. + +For more information on PIO assembly programming and the Raspberry Pi Pico Python SDK, refer to the following documents: +- raspberry-pi-pico-python-sdk.pdf: https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf +- raspberry-pi-pico-c-sdk.pdf: https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf + +For a simpler and clearer reference on PIO assembly, you can also visit: https://dernulleffekt.de/doku.php?id=raspberrypipico:pico_pio + + +rp2.PIO type hints have to be loaded manually. Add the following lines to the top of the file with the PIO assembler code: + +```py +# ----------------------------------------------- +# add type hints for the rp2.PIO Instructions +try: + from typing_extensions import TYPE_CHECKING # type: ignore +except ImportError: + TYPE_CHECKING = False +if TYPE_CHECKING: + from rp2.asm_pio import * +# ----------------------------------------------- +``` + +--- +Module: 'rp2' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Union, Dict, List, Literal, overload, Any, Callable, Optional, Final +from _typeshed import Incomplete +from micropython import const +from typing_extensions import Awaitable, TypeAlias, TypeVar, TYPE_CHECKING +from _mpy_shed import AnyReadableBuf, AnyWritableBuf, _IRQ +from vfs import AbstractBlockDev +from machine import Pin + +_PIO_ASM_Program: TypeAlias = Callable +_IRQ_TRIGGERS: TypeAlias = Literal[256, 512, 1024, 2048] + +_pio_funcs: dict = {} +_pio_directives: tuple = () +_pio_instructions: tuple = () + +def bootsel_button() -> int: + """ + Temporarily turns the QSPI_SS pin into an input and reads its value, + returning 1 for low and 0 for high. + On a typical RP2040 board with a BOOTSEL button, a return value of 1 + indicates that the button is pressed. + + Since this function temporarily disables access to the external flash + memory, it also temporarily disables interrupts and the other core to + prevent them from trying to execute code from flash. + """ + ... + +def asm_pio( + *, + out_init: Union[Pin, List[Pin], int, List[int], None] = None, + set_init: Union[Pin, List[Pin], int, List[int], None] = None, + sideset_init: Union[Pin, List[Pin], int, List[int], None] = None, + side_pindir: bool = False, + in_shiftdir=0, + out_shiftdir=0, + autopush=False, + autopull=False, + push_thresh=32, + pull_thresh=32, + fifo_join=PIO.JOIN_NONE, +) -> Callable[..., _PIO_ASM_Program]: + """ + Assemble a PIO program. + + The following parameters control the initial state of the GPIO pins, as one + of `PIO.IN_LOW`, `PIO.IN_HIGH`, `PIO.OUT_LOW` or `PIO.OUT_HIGH`. If the + program uses more than one pin, provide a tuple, e.g. + ``out_init=(PIO.OUT_LOW, PIO.OUT_LOW)``. + + - *out_init* configures the pins used for ``out()`` instructions. + - *set_init* configures the pins used for ``set()`` instructions. There can + be at most 5. + - *sideset_init* configures the pins used for ``.side()`` modifiers. There + can be at most 5. + - *side_pindir* when set to ``True`` configures ``.side()`` modifiers to be + used for pin directions, instead of pin values (the default, when ``False``). + + The following parameters are used by default, but can be overridden in + `StateMachine.init()`: + + - *in_shiftdir* is the default direction the ISR will shift, either + `PIO.SHIFT_LEFT` or `PIO.SHIFT_RIGHT`. + - *out_shiftdir* is the default direction the OSR will shift, either + `PIO.SHIFT_LEFT` or `PIO.SHIFT_RIGHT`. + - *push_thresh* is the threshold in bits before auto-push or conditional + re-pushing is triggered. + - *pull_thresh* is the threshold in bits before auto-pull or conditional + re-pulling is triggered. + + The remaining parameters are: + + - *autopush* configures whether auto-push is enabled. + - *autopull* configures whether auto-pull is enabled. + - *fifo_join* configures whether the 4-word TX and RX FIFOs should be + combined into a single 8-word FIFO for one direction only. The options + are `PIO.JOIN_NONE`, `PIO.JOIN_RX` and `PIO.JOIN_TX`. + """ + ... + +def country(*args, **kwargs) -> Incomplete: ... +def asm_pio_encode(instr, sideset_count, sideset_opt=False) -> int: + """ + Assemble a single PIO instruction. You usually want to use `asm_pio()` + instead. + + >>> rp2.asm_pio_encode("set(0, 1)", 0) + 57345 + """ + ... + +def const(*args, **kwargs) -> Incomplete: ... + +class DMA: + """ + Claim one of the DMA controller channels for exclusive use. + """ + def irq(self, handler: Optional[Callable] = None, hard: bool = False) -> _IRQ: + """ + Returns the IRQ object for this DMA channel and optionally configures it. + """ + ... + def unpack_ctrl(self, value: int) -> dict: + """ + Unpack a value for a DMA channel control register into a dictionary with key/value pairs + for each of the fields in the control register. *value* is the ``ctrl`` register value + to unpack. + + This method will return values for all the keys that can be passed to ``DMA.pack_ctrl``. + In addition, it will also return the read-only flags in the control register: ``busy``, + which goes high when a transfer starts and low when it ends, and ``ahb_err``, which is + the logical OR of the ``read_err`` and ``write_err`` flags. These values will be ignored + when packing, so that the dictionary created by unpacking a control register can be used + directly as the keyword arguments for packing. + """ + ... + def pack_ctrl( + self, + *, + enable: bool = True, + high_pri: bool = False, + size: int = 2, + inc_read: bool = True, + inc_write: bool = True, + # RP2350-only fields: + inc_read_rev: Optional[bool] = None, # RP2350 only + inc_write_rev: Optional[bool] = None, # RP2350 only + **kwargs, + ) -> int: + """ + Pack the values provided in the keyword arguments into the named fields of a new control + register value. Any field that is not provided will be set to a default value. The + default will either be taken from the provided ``default`` value, or if that is not + given, a default suitable for the current channel; setting this to the current value + of the `DMA.ctrl` attribute provides an easy way to override a subset of the fields. + + The keys for the keyword arguments can be any key returned by the :meth:`DMA.unpack_ctrl()` + method. The writable values are: + + - *enable*: ``bool`` Set to enable the channel (default: ``True``). + + - *high_pri*: ``bool`` Make this channel's bus traffic high priority (default: ``False``). + + - *size*: ``int`` Transfer size: 0=byte, 1=half word, 2=word (default: 2). + + - *inc_read*: ``bool`` Increment the read address after each transfer (default: ``True``). + + - *inc_write*: ``bool`` Increment the write address after each transfer (default: ``True``). + + - *ring_size*: ``int`` If non-zero, only the bottom ``ring_size`` bits of one + address register will change when an address is incremented, causing the + address to wrap at the next ``1 << ring_size`` byte boundary. Which + address is wrapped is controlled by the ``ring_sel`` flag. A zero value + disables address wrapping. + + - *ring_sel*: ``bool`` Set to ``False`` to have the ``ring_size`` apply to the read address + or ``True`` to apply to the write address. + + - *chain_to*: ``int`` The channel number for a channel to trigger after this transfer + completes. Setting this value to this DMA object's own channel number + disables chaining (this is the default). + + - *treq_sel*: ``int`` Select a Transfer Request signal. See section 2.5.3 in the RP2040 + datasheet for details. + + - *irq_quiet*: ``bool`` Do not generate interrupt at the end of each transfer. Interrupts + will instead be generated when a zero value is written to the trigger + register, which will halt a sequence of chained transfers (default: + ``True``). + + - *bswap*: ``bool`` If set to true, bytes in words or half-words will be reversed before + writing (default: ``True``). + + - *sniff_en*: ``bool`` Set to ``True`` to allow data to be accessed by the chips sniff + hardware (default: ``False``). + + - *write_err*: ``bool`` Setting this to ``True`` will clear a previously reported write + error. + + - *read_err*: ``bool`` Setting this to ``True`` will clear a previously reported read + error. + + See the description of the ``CH0_CTRL_TRIG`` register in section 2.5.7 of the RP2040 + datasheet for details of all of these fields. + """ + ... + def close(self) -> None: + """ + Release the claim on the underlying DMA channel and free the interrupt + handler. The :class:`DMA` object can not be used after this operation. + """ + ... + def config( + self, + read: int | AnyReadableBuf | None = None, + write: int | AnyWritableBuf | None = None, + count: int = -1, + ctrl: int = -1, + trigger: bool = False, + ) -> None: + """ + Configure the DMA registers for the channel and optionally start the transfer. + Parameters are: + + - *read*: The address from which the DMA controller will start reading data or + an object that will provide data to be read. It can be an integer or any + object that supports the buffer protocol. + - *write*: The address to which the DMA controller will start writing or an + object into which data will be written. It can be an integer or any object + that supports the buffer protocol. + - *count*: The number of bus transfers that will execute before this channel + stops. Note that this is the number of transfers, not the number of bytes. + If the transfers are 2 or 4 bytes wide then the total amount of data moved + (and thus the size of required buffer) needs to be multiplied accordingly. + - *ctrl*: The value for the DMA control register. This is an integer value + that is typically packed using the :meth:`DMA.pack_ctrl()`. + - *trigger*: Optionally commence the transfer immediately. + """ + ... + def active(self, value: Any | None = None) -> bool: + """ + Gets or sets whether the DMA channel is currently running. + + >>> sm.active() + 0 + >>> sm.active(1) + >>> while sm.active(): + """ + ... + def __init__( + self, + read: int | AnyReadableBuf | None = None, + write: int | AnyWritableBuf | None = None, + count: int = -1, + ctrl: int = -1, + trigger: bool = False, + ) -> None: ... + +class PIO: + """ + Gets the PIO instance numbered *id*. The RP2040 has two PIO instances, + numbered 0 and 1. + + Raises a ``ValueError`` if any other argument is provided. + """ + + JOIN_TX: Final[int] = 1 + """These constants are used for the *fifo_join* argument to `asm_pio`.""" + JOIN_NONE: Final[int] = 0 + """These constants are used for the *fifo_join* argument to `asm_pio`.""" + JOIN_RX: Final[int] = 2 + """These constants are used for the *fifo_join* argument to `asm_pio`.""" + SHIFT_LEFT: Final[int] = 0 + """\ + These constants are used for the *in_shiftdir* and *out_shiftdir* arguments + to `asm_pio` or `StateMachine.init`. + """ + OUT_HIGH: Final[int] = 3 + """\ + These constants are used for the *out_init*, *set_init*, and *sideset_init* + arguments to `asm_pio`. + """ + OUT_LOW: Final[int] = 2 + """\ + These constants are used for the *out_init*, *set_init*, and *sideset_init* + arguments to `asm_pio`. + """ + SHIFT_RIGHT: Final[int] = 1 + """\ + These constants are used for the *in_shiftdir* and *out_shiftdir* arguments + to `asm_pio` or `StateMachine.init`. + """ + IN_LOW: Final[int] = 0 + """\ + These constants are used for the *out_init*, *set_init*, and *sideset_init* + arguments to `asm_pio`. + """ + IRQ_SM3: Final[int] = 2048 + """These constants are used for the *trigger* argument to `PIO.irq`.""" + IN_HIGH: Final[int] = 1 + """\ + These constants are used for the *out_init*, *set_init*, and *sideset_init* + arguments to `asm_pio`. + """ + IRQ_SM2: Final[int] = 1024 + """These constants are used for the *trigger* argument to `PIO.irq`.""" + IRQ_SM0: Final[int] = 256 + """These constants are used for the *trigger* argument to `PIO.irq`.""" + IRQ_SM1: Final[int] = 512 + """These constants are used for the *trigger* argument to `PIO.irq`.""" + def state_machine(self, id: int, program: _PIO_ASM_Program, **kwargs) -> StateMachine: + """ + Gets the state machine numbered *id*. On the RP2040, each PIO instance has + four state machines, numbered 0 to 3. + + Optionally initialize it with a *program*: see `StateMachine.init`. + + >>> rp2.PIO(1).state_machine(3) + StateMachine(7) + """ + ... + def remove_program(self, program: Optional[_PIO_ASM_Program] = None) -> None: + """ + Remove *program* from the instruction memory of this PIO instance. + + If no program is provided, it removes all programs. + + It is not an error to remove a program which has already been removed. + """ + ... + def irq( + self, + handler: Optional[Callable[[PIO], None]] = None, + trigger: _IRQ_TRIGGERS | None = None, + hard: bool = False, + ) -> _IRQ: + """ + Returns the IRQ object for this PIO instance. + + MicroPython only uses IRQ 0 on each PIO instance. IRQ 1 is not available. + + Optionally configure it. + """ + ... + def add_program(self, program: _PIO_ASM_Program) -> None: + """ + Add the *program* to the instruction memory of this PIO instance. + + The amount of memory available for programs on each PIO instance is + limited. If there isn't enough space left in the PIO's program memory + this method will raise ``OSError(ENOMEM)``. + """ + ... + def __init__(self, id: int) -> None: ... + +class StateMachine: + """ + Get the state machine numbered *id*. The RP2040 has two identical PIO + instances, each with 4 state machines: so there are 8 state machines in + total, numbered 0 to 7. + + Optionally initialize it with the given program *program*: see + `StateMachine.init`. + """ + def irq(self, handler: Optional[Callable] = None, trigger: int = 0 | 1, hard: bool = False) -> _IRQ: + """ + Returns the IRQ object for the given StateMachine. + + Optionally configure it. + """ + ... + def put(self, value: Union[int, bytes, bytearray], shift: int = 0): + """ + Push words onto the state machine's TX FIFO. + + *value* can be an integer, an array of type ``B``, ``H`` or ``I``, or a + `bytearray`. + + This method will block until all words have been written to the FIFO. If + the FIFO is, or becomes, full, the method will block until the state machine + pulls enough words to complete the write. + + Each word is first shifted left by *shift* bits, i.e. the state machine + receives ``word << shift``. + """ + ... + def restart(self) -> None: + """ + Restarts the state machine and jumps to the beginning of the program. + + This method clears the state machine's internal state using the RP2040's + ``SM_RESTART`` register. This includes: + + - input and output shift counters + - the contents of the input shift register + - the delay counter + - the waiting-on-IRQ state + - a stalled instruction run using `StateMachine.exec()` + """ + ... + def rx_fifo(self) -> int: + """ + Returns the number of words in the state machine's RX FIFO. A value of 0 + indicates the FIFO is empty. + + Useful for checking if data is waiting to be read, before calling + `StateMachine.get()`. + """ + ... + def tx_fifo(self) -> int: + """ + Returns the number of words in the state machine's TX FIFO. A value of 0 + indicates the FIFO is empty. + + Useful for checking if there is space to push another word using + `StateMachine.put()`. + """ + ... + def init( + self, + program: _PIO_ASM_Program, + *, + freq: int = 1, + in_base: Pin | None = None, + out_base: Pin | None = None, + set_base: Pin | None = None, + jmp_pin: Pin | None = None, + sideset_base: Pin | None = None, + in_shiftdir: int | None = None, + out_shiftdir: int | None = None, + push_thresh: int | None = None, + pull_thresh: int | None = None, + **kwargs, + ) -> None: + """ + Configure the state machine instance to run the given *program*. + + The program is added to the instruction memory of this PIO instance. If the + instruction memory already contains this program, then its offset is + reused so as to save on instruction memory. + + - *freq* is the frequency in Hz to run the state machine at. Defaults to + the system clock frequency. + + The clock divider is computed as ``system clock frequency / freq``, so + there can be slight rounding errors. + + The minimum possible clock divider is one 65536th of the system clock: so + at the default system clock frequency of 125MHz, the minimum value of + *freq* is ``1908``. To run state machines at slower frequencies, you'll + need to reduce the system clock speed with `machine.freq()`. + - *in_base* is the first pin to use for ``in()`` instructions. + - *out_base* is the first pin to use for ``out()`` instructions. + - *set_base* is the first pin to use for ``set()`` instructions. + - *jmp_pin* is the first pin to use for ``jmp(pin, ...)`` instructions. + - *sideset_base* is the first pin to use for side-setting. + - *in_shiftdir* is the direction the ISR will shift, either + `PIO.SHIFT_LEFT` or `PIO.SHIFT_RIGHT`. + - *out_shiftdir* is the direction the OSR will shift, either + `PIO.SHIFT_LEFT` or `PIO.SHIFT_RIGHT`. + - *push_thresh* is the threshold in bits before auto-push or conditional + re-pushing is triggered. + - *pull_thresh* is the threshold in bits before auto-pull or conditional + re-pulling is triggered. + + Note: pins used for *in_base* need to be configured manually for input (or + otherwise) so that the PIO can see the desired signal (they could be input + pins, output pins, or connected to a different peripheral). The *jmp_pin* + can also be configured manually, but by default will be an input pin. + """ + ... + def exec(self, instr: Union[int, str]) -> None: + """ + Execute a single PIO instruction. + + If *instr* is a string then uses `asm_pio_encode` to encode the instruction + from the given string. + + >>> sm.exec("set(0, 1)") + + If *instr* is an integer then it is treated as an already encoded PIO + machine code instruction to be executed. + + >>> sm.exec(rp2.asm_pio_encode("out(y, 8)", 0)) + """ + ... + def get(self, buf: Optional[bytearray] = None, shift: int = 0) -> Union[int, None]: + """ + Pull a word from the state machine's RX FIFO. + + If the FIFO is empty, it blocks until data arrives (i.e. the state machine + pushes a word). + + The value is shifted right by *shift* bits before returning, i.e. the + return value is ``word >> shift``. + """ + ... + + @overload + def active(self, value: None) -> bool: ... + @overload + def active(self, value: Union[bool, int]) -> None: + """ + Gets or sets whether the state machine is currently running. + + >>> sm.active() + True + >>> sm.active(0) + False + """ + ... + def __init__( + self, + id: int, + program: _PIO_ASM_Program, + *, + freq: int = 1, + in_base: Pin | None = None, + out_base: Pin | None = None, + set_base: Pin | None = None, + jmp_pin: Pin | None = None, + sideset_base: Pin | None = None, + in_shiftdir: int | None = None, + out_shiftdir: int | None = None, + push_thresh: int | None = None, + pull_thresh: int | None = None, + **kwargs, + ) -> None: ... + +class PIOASMEmit: + """ + The PIOASMEmit class provides a comprehensive interface for constructing PIO programs, + handling the intricacies of instruction encoding, label management, and program state. + This allows users to build complex PIO programs in pythone, leveraging the flexibility + and power of the PIO state machine. + + The class should not be instantiated directly, but used via the `@asm_pio` decorator. + """ + def in_(self, src: int, data) -> _PIO_ASM_Program: + """rp2.PIO IN instruction. + + Shift Bit count bits from Source into the Input Shift Register (ISR). + Shift direction is configured for each state machine by SHIFTCTRL_IN_SHIFTDIR. + Additionally, increase the input shift count by Bit count, saturating at 32. + + * Source: + 000: PINS + 001: X (scratch register X) + 010: Y (scratch register Y) + 011: NULL (all zeroes) + 100: Reserved + 101: Reserved + 110: ISR + 111: OSR + * Bit count: How many bits to shift into the ISR. 1…32 bits, 32 is encoded as 00000. + + If automatic push is enabled, IN will also push the ISR contents to the RX FIFO if the push threshold is reached + (SHIFTCTRL_PUSH_THRESH). IN still executes in one cycle, whether an automatic push takes place or not. The state machine + will stall if the RX FIFO is full when an automatic push occurs. An automatic push clears the ISR contents to all-zeroes, + and clears the input shift count. + IN always uses the least significant Bit count bits of the source data. For example, if PINCTRL_IN_BASE is set to 5, the + instruction IN PINS, 3 will take the values of pins 5, 6 and 7, and shift these into the ISR. First the ISR is shifted to the left + or right to make room for the new input data, then the input data is copied into the gap this leaves. The bit order of the + input data is not dependent on the shift direction. + NULL can be used for shifting the ISR’s contents. For example, UARTs receive the LSB first, so must shift to the right. + After 8 IN PINS, 1 instructions, the input serial data will occupy bits 31…24 of the ISR. An IN NULL, 24 instruction will shift + in 24 zero bits, aligning the input data at ISR bits 7…0. Alternatively, the processor or DMA could perform a byte read + from FIFO address + 3, which would take bits 31…24 of the FIFO contents. + """ + ... + def side(self, value: int): + """rp2.PIO side modifier. + This is a modifier which can be applied to any instruction, and is used to control side-set pin values. + value: the value (bits) to output on the side-set pins + + When an instruction has side 0 next to it, the corresponding output is set LOW, + and when it has side 1 next to it, the corresponding output is set HIGH. + There can be up to 5 side-set pins, in which case side N is interpreted as a binary number. + + `side(0b00011)` sets the first and the second side-set pin HIGH, and the others LOW. + """ + ... + def out(self, destination: int, bit_count: int) -> _PIO_ASM_Program: + """rp2.PIO OUT instruction. + + Shift Bit count bits out of the Output Shift Register (OSR), and write those bits to Destination. + Additionally, increase the output shift count by Bit count, saturating at 32. + + Destination: (use lowercase in MicroPython) + - 000: PINS + - 001: X (scratch register X) + - 010: Y (scratch register Y) + - 011: NULL (discard data) + - 100: PINDIRS + - 101: PC + - 110: ISR (also sets ISR shift counter to Bit count) + - 111: EXEC (Execute OSR shift data as instruction) + + Bit_count: + how many bits to shift out of the OSR. 1…32 bits, 32 is encoded as 00000. + + A 32-bit value is written to Destination: the lower Bit count bits come from the OSR, and the remainder are zeroes. This + value is the least significant Bit count bits of the OSR if SHIFTCTRL_OUT_SHIFTDIR is to the right, otherwise it is the most + significant bits. + + PINS and PINDIRS use the OUT pin mapping. + + If automatic pull is enabled, the OSR is automatically refilled from the TX FIFO if the pull threshold, SHIFTCTRL_PULL_THRESH, + is reached. The output shift count is simultaneously cleared to 0. In this case, the OUT will stall if the TX FIFO is empty, + but otherwise still executes in one cycle. + + OUT EXEC allows instructions to be included inline in the FIFO datastream. The OUT itself executes on one cycle, and the + instruction from the OSR is executed on the next cycle. There are no restrictions on the types of instructions which can + be executed by this mechanism. Delay cycles on the initial OUT are ignored, but the executee may insert delay cycles as + normal. + + OUT PC behaves as an unconditional jump to an address shifted out from the OSR. + """ + ... + def jmp(self, condition, label: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO JMP instruction. + + Set program counter to Address if Condition is true, otherwise no operation. + Delay cycles on a JMP always take effect, whether Condition is true or false, and they take place after Condition is + evaluated and the program counter is updated. + + Parameters: + + `condition`: + - `None` : (no condition): Always + - `not_x` : !X: scratch X zero + - `x_dec` : X--: scratch X non-zero, prior to decrement + - `not_y` : !Y: scratch Y zero + - `y_dec` : Y--: scratch Y non-zero, prior to decrement + - `x_not_y` : X!=Y: scratch X not equal scratch Y + - `pin` : PIN: branch on input pin + - `not_osre` : !OSRE: output shift register not empty + + `label`: Instruction address to jump to. In the instruction encoding, this is an absolute address within the PIO + instruction memory. + + `JMP PIN` branches on the GPIO selected by EXECCTRL_JMP_PIN, a configuration field which selects one out of the maximum + of 32 GPIO inputs visible to a state machine, independently of the state machine’s other input mapping. The branch is + taken if the GPIO is high. + + `!OSRE` compares the bits shifted out since the last PULL with the shift count threshold configured by SHIFTCTRL_PULL_THRESH. + This is the same threshold used by autopull. + + `JMP X--` and `JMP Y--` always decrement scratch register X or Y, respectively. The decrement is not conditional on the + current value of the scratch register. The branch is conditioned on the initial value of the register, i.e. before the + decrement took place: if the register is initially nonzero, the branch is taken. + """ + ... + def start_pass(self, pass_) -> None: + """The start_pass method is used to start a pass over the instructions, + setting up the necessary state for the pass. It handles wrapping instructions + if needed and adjusts the delay maximum based on the number of side-set bits. + """ + ... + def wrap(self) -> None: + """rp2.PIO WRAP directive. + + Placed after an instruction, this directive specifies the instruction after which, + in normal control flow (i.e. jmp with false condition, or no jmp), the program + wraps (to .wrap_target instruction). This directive is invalid outside of a + program, may only be used once within a program, and if not specified + defaults to after the last program instruction. + """ + ... + def word(self, instr, label: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO instruction. + + Stores a raw 16-bit value as an instruction in the program. This directive is + invalid outside of a program. + """ + ... + def wait(self, polarity: int, src: int, index: int, /) -> _PIO_ASM_Program: + """rp2.PIO WAIT instruction. + + Stall until some condition is met. + Like all stalling instructions, delay cycles begin after the instruction completes. That is, if any delay cycles are present, + they do not begin counting until after the wait condition is met. + + Parameters: + + Polarity: + 1: wait for a 1. + 0: wait for a 0. + + Source: what to wait on. Values are: + 00: GPIO: System GPIO input selected by Index. This is an absolute GPIO index, and is not affected by the state machine’s input IO mapping. + 01: PIN: Input pin selected by Index. This state machine’s input IO mapping is applied first, and then Index + selects which of the mapped bits to wait on. In other words, the pin is selected by adding Index to the + PINCTRL_IN_BASE configuration, modulo 32. + 10: IRQ: PIO IRQ flag selected by Index + 11: Reserved + + Index: which pin or bit to check. + + WAIT x IRQ behaves slightly differently from other WAIT sources: + * If Polarity is 1, the selected IRQ flag is cleared by the state machine upon the wait condition being met. + * The flag index is decoded in the same way as the IRQ index field: if the MSB is set, the state machine ID (0…3) is + added to the IRQ index, by way of modulo-4 addition on the two LSBs. For example, state machine 2 with a flag + value of '0x11' will wait on flag 3, and a flag value of '0x13' will wait on flag 1. This allows multiple state machines + running the same program to synchronise with each other. + CAUTION + WAIT 1 IRQ x should not be used with IRQ flags presented to the interrupt controller, to avoid a race condition with a + system interrupt handler + """ + ... + def wrap_target(self) -> None: + """rp2.PIO WRAP_TARGET directive. + + This directive specifies the instruction where + execution continues due to program wrapping. This directive is invalid outside + of a program, may only be used once within a program, and if not specified + defaults to the start of the program + """ + def delay(self, delay: int): + """rp2.PIO delay modifier. + + The delay method allows setting a delay for the current instruction, + ensuring it does not exceed the maximum allowed delay. + """ + def label(self, label: str) -> None: + """rp2.PIO instruction. + + Labels are of the form: + + : + + or + + PUBLIC : + + at the start of a line + """ + ... + def irq(self, mod, index: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO instruction. + + Set or clear the IRQ flag selected by Index argument. + * Clear: if 1, clear the flag selected by Index, instead of raising it. If Clear is set, the Wait bit has no effect. + * Wait: if 1, halt until the raised flag is lowered again, e.g. if a system interrupt handler has acknowledged the flag. + * Index: + + The 3 LSBs specify an IRQ index from 0-7. This IRQ flag will be set/cleared depending on the Clear bit. + + If the MSB is set, the state machine ID (0…3) is added to the IRQ index, by way of modulo-4 addition on the + two LSBs. For example, state machine 2 with a flag value of 0x11 will raise flag 3, and a flag value of 0x13 will raise flag 1. + + IRQ flags 4-7 are visible only to the state machines; IRQ flags 0-3 can be routed out to system level interrupts, on either + of the PIO’s two external interrupt request lines, configured by IRQ0_INTE and IRQ1_INTE. + The modulo addition bit allows relative addressing of 'IRQ' and 'WAIT' instructions, for synchronising state machines + which are running the same program. Bit 2 (the third LSB) is unaffected by this addition. + If Wait is set, Delay cycles do not begin until after the wait period elapses.""" + def set(self, destination: int, data) -> _PIO_ASM_Program: + """rp2.PIO SET instruction. + + Write immediate value Data to Destination. + + • Destination: + 000: PINS + 001: X (scratch register X) 5 LSBs are set to Data, all others cleared to 0. + 010: Y (scratch register Y) 5 LSBs are set to Data, all others cleared to 0. + 011: Reserved + 100: PINDIRS + 101: Reserved + 110: Reserved + 111: Reserved + • Data: 5-bit immediate value to drive to pins or register. + + This can be used to assert control signals such as a clock or chip select, or to initialise loop counters. As Data is 5 bits in + size, scratch registers can be SET to values from 0-31, which is sufficient for a 32-iteration loop. + The mapping of SET and OUT onto pins is configured independently. They may be mapped to distinct locations, for + example if one pin is to be used as a clock signal, and another for data. They may also be overlapping ranges of pins: a + UART transmitter might use SET to assert start and stop bits, and OUT instructions to shift out FIFO data to the same pins. + """ + ... + def mov(self, dest, src, operation: int | None = None) -> _PIO_ASM_Program: + """rp2.PIO MOV instruction. + + Copy data from Source to Destination. + + Destination: + - 000: PINS (Uses same pin mapping as OUT) + - 001: X (Scratch register X) + - 010: Y (Scratch register Y) + - 011: Reserved + - 100: EXEC (Execute data as instruction) + - 101: PC + - 110: ISR (Input shift counter is reset to 0 by this operation, i.e. empty) + - 111: OSR (Output shift counter is reset to 0 by this operation, i.e. full) + + Operation: + - 00: None + - 01: Invert (bitwise complement) + - 10: Bit-reverse + - 11: Reserved + + Source: + - 000: PINS (Uses same pin mapping as IN) + - 001: X + - 010: Y + - 011: NULL + - 100: Reserved + - 101: STATUS + - 110: ISR + - 111: OSR + + MOV PC causes an unconditional jump. MOV EXEC has the same behaviour as OUT EXEC (Section 3.4.5), and allows register + contents to be executed as an instruction. The MOV itself executes in 1 cycle, and the instruction in Source on the next + cycle. Delay cycles on MOV EXEC are ignored, but the executee may insert delay cycles as normal. + The STATUS source has a value of all-ones or all-zeroes, depending on some state machine status such as FIFO + full/empty, configured by EXECCTRL_STATUS_SEL. + + MOV can manipulate the transferred data in limited ways, specified by the Operation argument. Invert sets each bit in + Destination to the logical NOT of the corresponding bit in Source, i.e. 1 bits become 0 bits, and vice versa. Bit reverse sets + each bit n in Destination to bit 31 - n in Source, assuming the bits are numbered 0 to 31. + MOV dst, PINS reads pins using the IN pin mapping, and writes the full 32-bit value to the destination without masking. + The LSB of the read value is the pin indicated by PINCTRL_IN_BASE, and each successive bit comes from a higher numbered pin, wrapping after 31. + + """ + ... + def push(self, value: int = ..., value2: int = ...) -> _PIO_ASM_Program: + """rp2.PIO PUSH instruction. + + Push the contents of the ISR into the RX FIFO, as a single 32-bit word. Clear ISR to all-zeroes. + * IfFull: If 1, do nothing unless the total input shift count has reached its threshold, SHIFTCTRL_PUSH_THRESH (the same + as for autopush). + * Block: If 1, stall execution if RX FIFO is full. + + PUSH IFFULL helps to make programs more compact, like autopush. It is useful in cases where the IN would stall at an + inappropriate time if autopush were enabled, e.g. if the state machine is asserting some external control signal at this + point. + The PIO assembler sets the Block bit by default. If the Block bit is not set, the PUSH does not stall on a full RX FIFO, instead + continuing immediately to the next instruction. The FIFO state and contents are unchanged when this happens. The ISR + is still cleared to all-zeroes, and the FDEBUG_RXSTALL flag is set (the same as a blocking PUSH or autopush to a full RX FIFO) + to indicate data was lost. + + """ + ... + def pull(self, block: int = block, timeout: int = 0) -> _PIO_ASM_Program: + """rp2.PIO PULL instruction. + + Load a 32-bit word from the TX FIFO into the OSR. + * IfEmpty: If 1, do nothing unless the total output shift count has reached its threshold, SHIFTCTRL_PULL_THRESH (the + same as for autopull). + * Block: If 1, stall if TX FIFO is empty. If 0, pulling from an empty FIFO copies scratch X to OSR. + + Some peripherals (UART, SPI…) should halt when no data is available, and pick it up as it comes in; others (I2S) should + clock continuously, and it is better to output placeholder or repeated data than to stop clocking. This can be achieved + with the Block parameter. + A nonblocking PULL on an empty FIFO has the same effect as MOV OSR, X. The program can either preload scratch register + X with a suitable default, or execute a MOV X, OSR after each PULL NOBLOCK, so that the last valid FIFO word will be recycled + until new data is available. + + PULL IFEMPTY is useful if an OUT with autopull would stall in an inappropriate location when the TX FIFO is empty. For + example, a UART transmitter should not stall immediately after asserting the start bit. IfEmpty permits some of the same + program simplifications as autopull, but the stall occurs at a controlled point in the program. + + NOTE: + When autopull is enabled, any PULL instruction is a no-op when the OSR is full, so that the PULL instruction behaves as + a barrier. OUT NULL, 32 can be used to explicitly discard the OSR contents. See the RP2040 Datasheet for more detail + on autopull + """ + ... + def nop(self) -> _PIO_ASM_Program: + """rp2.PIO NOP instruction. + + Assembles to mov y, y. "No operation", has no particular side effect, but a useful vehicle for a side-set + operation or an extra delay. + """ + ... + def __init__( + self, + *, + out_init: int | List | None = ..., + set_init: int | List | None = ..., + sideset_init: int | List | None = ..., + in_shiftdir: int = ..., + out_shiftdir: int = ..., + autopush: bool = ..., + autopull: bool = ..., + push_thresh: int = ..., + pull_thresh: int = ..., + fifo_join: int = ..., + ) -> None: ... + @overload + def __getitem__(self, key): ... + @overload + def __getitem__(self, key: int): ... + @overload + def __getitem__(self, key): ... + @overload + def __getitem__(self, key: int): ... + +class Flash(AbstractBlockDev): + """ + Gets the singleton object for accessing the SPI flash memory. + """ + @overload + def readblocks(self, block_num: int, buf: bytearray) -> bool: + """ + The first form reads aligned, multiples of blocks. + Starting at the block given by the index *block_num*, read blocks from + the device into *buf* (an array of bytes). + The number of blocks to read is given by the length of *buf*, + which will be a multiple of the block size. + """ + + @overload + def readblocks(self, block_num: int, buf: bytearray, offset: int) -> bool: + """ + The second form allows reading at arbitrary locations within a block, + and arbitrary lengths. + Starting at block index *block_num*, and byte offset within that block + of *offset*, read bytes from the device into *buf* (an array of bytes). + The number of bytes to read is given by the length of *buf*. + """ + + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, /) -> None: + """ + The first form writes aligned, multiples of blocks, and requires that the + blocks that are written to be first erased (if necessary) by this method. + Starting at the block given by the index *block_num*, write blocks from + *buf* (an array of bytes) to the device. + The number of blocks to write is given by the length of *buf*, + which will be a multiple of the block size. + """ + + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, offset: int, /) -> None: + """ + The second form allows writing at arbitrary locations within a block, + and arbitrary lengths. Only the bytes being written should be changed, + and the caller of this method must ensure that the relevant blocks are + erased via a prior ``ioctl`` call. + Starting at block index *block_num*, and byte offset within that block + of *offset*, write bytes from *buf* (an array of bytes) to the device. + The number of bytes to write is given by the length of *buf*. + + Note that implementations must never implicitly erase blocks if the offset + argument is specified, even if it is zero. + """ + + @overload + def ioctl(self, op: int, arg) -> int | None: ... + # + @overload + def ioctl(self, op: int) -> int | None: + """ + These methods implement the simple and extended + :ref:`block protocol ` defined by + :class:`vfs.AbstractBlockDev`. + """ + def __init__(self) -> None: ... + +class PIOASMError(Exception): ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/rp2/asm_pio.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/rp2/asm_pio.pyi new file mode 100644 index 0000000000..4346014d1c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/rp2/asm_pio.pyi @@ -0,0 +1,459 @@ +""" +This module provides type hints for the `rp2.asm_pio` module in the Raspberry Pi Pico Python SDK. +It includes definitions for constants, functions, and directives used in PIO assembly programming. + +The module includes docstrings for each function and directive, providing information on their usage and parameters. + +Note: This module is intended for use with type checking and does not contain actual implementations of the functions. + +For more information on PIO assembly programming and the Raspberry Pi Pico Python SDK, refer to the following documents: +- raspberry-pi-pico-python-sdk.pdf: https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-python-sdk.pdf +- raspberry-pi-pico-c-sdk.pdf: https://datasheets.raspberrypi.org/pico/raspberry-pi-pico-c-sdk.pdf + +For a simpler and clearer reference on PIO assembly, you can also visit: https://dernulleffekt.de/doku.php?id=raspberrypipico:pico_pio + + +rp2.PIO type hints have to be loaded manually. Add the following lines to the top of the file with the PIO assembler code: + +```py +# ----------------------------------------------- +# add type hints for the rp2.PIO Instructions +try: + from typing_extensions import TYPE_CHECKING # type: ignore +except ImportError: + TYPE_CHECKING = False +if TYPE_CHECKING: + from rp2.asm_pio import * +# ----------------------------------------------- +``` +""" + +from typing import Final, Optional + +from _typeshed import Incomplete +from typing_extensions import TYPE_CHECKING + +from micropython import const # type: ignore + +# ref: https://github.com/Josverl/PIO_ASM_typing + +# The decorator has limited type information, to improve this it may be needed to depend on Pyton 3.10 or later to allow for a better support for type hints +# The type hints are not complete, also some of the methods currently need to be duplicated to allow for the fluent style of programming. e.g. out().side(0) +# The text for the docstrings originates from multiple locations, and is not always consistent. - Micropython RP2 Documentation - not fully complete on all methods and classes - RP2 python and C datasheets - sometime the language does not make sense in a python context. +# The defined methods and functions are also avaiable to the type checkers after/outside the scope where the @rp2.asm_pio decorator is used, this is not needed and should be removed. This can/will be confusing when the same names are used in the PIO assembler code and in the python code. + +if TYPE_CHECKING: + # defined functions are all methods of the (frozen) class PIOASMEmit: + # but also have a self method + from rp2 import PIOASMEmit, _PIO_ASM_Program + + # constants defined for PIO assembly + # TODO: Make Final - or make const always return Final + + gpio = const(0) + # "pin": see below, translated to 1 + # "irq": see below function, translated to 2 + # source/dest constants for in_, out, mov, set + pins = 0 + x = 1 + y = 2 + null = 3 + pindirs = 4 + pc = 5 + status = 5 + isr = 6 + osr = 7 + exec = (8,) # translated to 4 for mov, 7 for ou + # operation functions for mov's src + def invert(x: int) -> int: + return x | 8 + + def reverse(x: int) -> int: + return x | 16 + # jmp condition constants + not_x = 1 + x_dec = 2 + not_y = 3 + y_dec = 4 + x_not_y = 5 + pin = 6 + not_osre = 7 + # constants and modifiers for irq + # constants for push, pull + noblock = 0x01 + block = 0x21 + clear = 0x40 + + iffull = 0x40 + ifempty = 0x40 + + # rel = lambda x: x | 0x10 + def rel(x: int) -> int: + """Relative IRQ number""" + return x | 0x10 + #################################################################################### + # missing + # .define ( PUBLIC ) + # Define an integer symbol named with the value (see Section # 3.3.3). + # If this .define appears before the first program in the input file, then the + # define is global to all programs, otherwise it is local to the program in which it + # occurs. If PUBLIC is specified the symbol will be emitted into the assembled + # output for use by user code. For the SDK this takes the form of: + # #define _ value for program symbols or #define + # value for global symbols + + # .origin + # Optional directive to specify the PIO instruction memory offset at which the + # program must load. Most commonly this is used for programs that must load + # at offset 0, because they use data based JMPs with the (absolute) jmp target + # being stored in only a few bits. This directive is invalid outside of a program + + #################################################################################### + def delay(delay: int) -> _PIO_ASM_Program: + """rp2.PIO delay modifier. + + The delay method allows setting a delay for the current instruction, + ensuring it does not exceed the maximum allowed delay. + """ + ... + + def side(value: int) -> _PIO_ASM_Program: + """rp2.PIO WRAP modifier. + This is a modifier which can be applied to any instruction, and is used to control side-set pin values. + value: the value (bits) to output on the side-set pins + + When an instruction has side 0 next to it, the corresponding output is set LOW, + and when it has side 1 next to it, the corresponding output is set HIGH. + There can be up to 5 side-set pins, in which case side N is interpreted as a binary number. + + `side(0b00011)` sets the first and the second side-set pin HIGH, and the others LOW. + """ + ... + + def wrap_target() -> None: + """rp2.PIO WRAP_TARGET directive. + + This directive specifies the instruction where + execution continues due to program wrapping. This directive is invalid outside + of a program, may only be used once within a program, and if not specified + defaults to the start of the program + """ + ... + + def wrap() -> None: + """rp2.PIO WRAP directive. + + Placed after an instruction, this directive specifies the instruction after which, + in normal control flow (i.e. jmp with false condition, or no jmp), the program + wraps (to .wrap_target instruction). This directive is invalid outside of a + program, may only be used once within a program, and if not specified + defaults to after the last program instruction. + """ + ... + + def label(label: str) -> None: + """rp2.PIO LABEL directive. + + Labels are of the form: + + : + + or + + PUBLIC : + + at the start of a line + """ + ... + + def word(instr, label: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO instruction. + + Stores a raw 16-bit value as an instruction in the program. This directive is + invalid outside of a program. + """ + ... + + def nop() -> _PIO_ASM_Program: + """rp2.PIO NOP instruction. + + Assembles to mov y, y. "No operation", has no particular side effect, but a useful vehicle for a side-set + operation or an extra delay. + """ + ... + + def jmp(condition, label: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO JMP instruction. + + Set program counter to Address if Condition is true, otherwise no operation. + Delay cycles on a JMP always take effect, whether Condition is true or false, and they take place after Condition is + evaluated and the program counter is updated. + + Parameters: + + `condition`: + - `None` : (no condition): Always + - `not_x` : !X: scratch X zero + - `x_dec` : X--: scratch X non-zero, prior to decrement + - `not_y` : !Y: scratch Y zero + - `y_dec` : Y--: scratch Y non-zero, prior to decrement + - `x_not_y` : X!=Y: scratch X not equal scratch Y + - `pin` : PIN: branch on input pin + - `not_osre` : !OSRE: output shift register not empty + + `label`: Instruction address to jump to. In the instruction encoding, this is an absolute address within the PIO + instruction memory. + + `JMP PIN` branches on the GPIO selected by EXECCTRL_JMP_PIN, a configuration field which selects one out of the maximum + of 32 GPIO inputs visible to a state machine, independently of the state machine’s other input mapping. The branch is + taken if the GPIO is high. + + `!OSRE` compares the bits shifted out since the last PULL with the shift count threshold configured by SHIFTCTRL_PULL_THRESH. + This is the same threshold used by autopull. + + `JMP X--` and `JMP Y--` always decrement scratch register X or Y, respectively. The decrement is not conditional on the + current value of the scratch register. The branch is conditioned on the initial value of the register, i.e. before the + decrement took place: if the register is initially nonzero, the branch is taken. + """ + ... + + def wait(polarity: int, src: int, index: int, /) -> _PIO_ASM_Program: + """rp2.PIO WAIT instruction. + + Stall until some condition is met. + Like all stalling instructions, delay cycles begin after the instruction completes. That is, if any delay cycles are present, + they do not begin counting until after the wait condition is met. + + Parameters: + + Polarity: + 1: wait for a 1. + 0: wait for a 0. + + Source: what to wait on. Values are: + 00: GPIO: System GPIO input selected by Index. This is an absolute GPIO index, and is not affected by the state machine’s input IO mapping. + 01: PIN: Input pin selected by Index. This state machine’s input IO mapping is applied first, and then Index + selects which of the mapped bits to wait on. In other words, the pin is selected by adding Index to the + PINCTRL_IN_BASE configuration, modulo 32. + 10: IRQ: PIO IRQ flag selected by Index + 11: Reserved + + Index: which pin or bit to check. + + WAIT x IRQ behaves slightly differently from other WAIT sources: + * If Polarity is 1, the selected IRQ flag is cleared by the state machine upon the wait condition being met. + * The flag index is decoded in the same way as the IRQ index field: if the MSB is set, the state machine ID (0…3) is + added to the IRQ index, by way of modulo-4 addition on the two LSBs. For example, state machine 2 with a flag + value of '0x11' will wait on flag 3, and a flag value of '0x13' will wait on flag 1. This allows multiple state machines + running the same program to synchronise with each other. + CAUTION + WAIT 1 IRQ x should not be used with IRQ flags presented to the interrupt controller, to avoid a race condition with a + system interrupt handler + """ + ... + + def in_(src, data) -> _PIO_ASM_Program: + """rp2.PIO IN instruction. + + Shift Bit count bits from Source into the Input Shift Register (ISR). + Shift direction is configured for each state machine by SHIFTCTRL_IN_SHIFTDIR. + Additionally, increase the input shift count by Bit count, saturating at 32. + + * Source: + 000: PINS + 001: X (scratch register X) + 010: Y (scratch register Y) + 011: NULL (all zeroes) + 100: Reserved + 101: Reserved + 110: ISR + 111: OSR + * Bit count: How many bits to shift into the ISR. 1…32 bits, 32 is encoded as 00000. + + If automatic push is enabled, IN will also push the ISR contents to the RX FIFO if the push threshold is reached + (SHIFTCTRL_PUSH_THRESH). IN still executes in one cycle, whether an automatic push takes place or not. The state machine + will stall if the RX FIFO is full when an automatic push occurs. An automatic push clears the ISR contents to all-zeroes, + and clears the input shift count. + IN always uses the least significant Bit count bits of the source data. For example, if PINCTRL_IN_BASE is set to 5, the + instruction IN PINS, 3 will take the values of pins 5, 6 and 7, and shift these into the ISR. First the ISR is shifted to the left + or right to make room for the new input data, then the input data is copied into the gap this leaves. The bit order of the + input data is not dependent on the shift direction. + NULL can be used for shifting the ISR’s contents. For example, UARTs receive the LSB first, so must shift to the right. + After 8 IN PINS, 1 instructions, the input serial data will occupy bits 31…24 of the ISR. An IN NULL, 24 instruction will shift + in 24 zero bits, aligning the input data at ISR bits 7…0. Alternatively, the processor or DMA could perform a byte read + from FIFO address + 3, which would take bits 31…24 of the FIFO contents. + """ + ... + + def out(destination: int, bit_count: int) -> _PIO_ASM_Program: + """rp2.PIO OUT instruction. + + Shift Bit count bits out of the Output Shift Register (OSR), and write those bits to Destination. + Additionally, increase the output shift count by Bit count, saturating at 32. + + Destination: (use lowercase in MicroPython) + - 000: PINS + - 001: X (scratch register X) + - 010: Y (scratch register Y) + - 011: NULL (discard data) + - 100: PINDIRS + - 101: PC + - 110: ISR (also sets ISR shift counter to Bit count) + - 111: EXEC (Execute OSR shift data as instruction) + + Bit_count: + how many bits to shift out of the OSR. 1…32 bits, 32 is encoded as 00000. + + A 32-bit value is written to Destination: the lower Bit count bits come from the OSR, and the remainder are zeroes. This + value is the least significant Bit count bits of the OSR if SHIFTCTRL_OUT_SHIFTDIR is to the right, otherwise it is the most + significant bits. + + PINS and PINDIRS use the OUT pin mapping. + + If automatic pull is enabled, the OSR is automatically refilled from the TX FIFO if the pull threshold, SHIFTCTRL_PULL_THRESH, + is reached. The output shift count is simultaneously cleared to 0. In this case, the OUT will stall if the TX FIFO is empty, + but otherwise still executes in one cycle. + + OUT EXEC allows instructions to be included inline in the FIFO datastream. The OUT itself executes on one cycle, and the + instruction from the OSR is executed on the next cycle. There are no restrictions on the types of instructions which can + be executed by this mechanism. Delay cycles on the initial OUT are ignored, but the executee may insert delay cycles as + normal. + + OUT PC behaves as an unconditional jump to an address shifted out from the OSR. + """ + ... + + def push(value: int = ..., value2: int = ...) -> _PIO_ASM_Program: + """rp2.PIO PUSH instruction.. + + Push the contents of the ISR into the RX FIFO, as a single 32-bit word. Clear ISR to all-zeroes. + * IfFull: If 1, do nothing unless the total input shift count has reached its threshold, SHIFTCTRL_PUSH_THRESH (the same + as for autopush). + * Block: If 1, stall execution if RX FIFO is full. + + PUSH IFFULL helps to make programs more compact, like autopush. It is useful in cases where the IN would stall at an + inappropriate time if autopush were enabled, e.g. if the state machine is asserting some external control signal at this + point. + The PIO assembler sets the Block bit by default. If the Block bit is not set, the PUSH does not stall on a full RX FIFO, instead + continuing immediately to the next instruction. The FIFO state and contents are unchanged when this happens. The ISR + is still cleared to all-zeroes, and the FDEBUG_RXSTALL flag is set (the same as a blocking PUSH or autopush to a full RX FIFO) + to indicate data was lost. + + """ + ... + + def pull(block: int = block, timeout: int = 0) -> _PIO_ASM_Program: + """rp2.PIO PULL instruction.. + + Load a 32-bit word from the TX FIFO into the OSR. + * IfEmpty: If 1, do nothing unless the total output shift count has reached its threshold, SHIFTCTRL_PULL_THRESH (the + same as for autopull). + * Block: If 1, stall if TX FIFO is empty. If 0, pulling from an empty FIFO copies scratch X to OSR. + + Some peripherals (UART, SPI…) should halt when no data is available, and pick it up as it comes in; others (I2S) should + clock continuously, and it is better to output placeholder or repeated data than to stop clocking. This can be achieved + with the Block parameter. + A nonblocking PULL on an empty FIFO has the same effect as MOV OSR, X. The program can either preload scratch register + X with a suitable default, or execute a MOV X, OSR after each PULL NOBLOCK, so that the last valid FIFO word will be recycled + until new data is available. + + PULL IFEMPTY is useful if an OUT with autopull would stall in an inappropriate location when the TX FIFO is empty. For + example, a UART transmitter should not stall immediately after asserting the start bit. IfEmpty permits some of the same + program simplifications as autopull, but the stall occurs at a controlled point in the program. + + NOTE: + When autopull is enabled, any PULL instruction is a no-op when the OSR is full, so that the PULL instruction behaves as + a barrier. OUT NULL, 32 can be used to explicitly discard the OSR contents. See the RP2040 Datasheet for more detail + on autopull + """ + ... + + def mov(dest, src, operation: Optional[int] = None) -> _PIO_ASM_Program: + """rp2.PIO MOV instruction.. + + Copy data from Source to Destination. + + Destination: + - 000: PINS (Uses same pin mapping as OUT) + - 001: X (Scratch register X) + - 010: Y (Scratch register Y) + - 011: Reserved + - 100: EXEC (Execute data as instruction) + - 101: PC + - 110: ISR (Input shift counter is reset to 0 by this operation, i.e. empty) + - 111: OSR (Output shift counter is reset to 0 by this operation, i.e. full) + + Operation: + - 00: None + - 01: Invert (bitwise complement) + - 10: Bit-reverse + - 11: Reserved + + Source: + - 000: PINS (Uses same pin mapping as IN) + - 001: X + - 010: Y + - 011: NULL + - 100: Reserved + - 101: STATUS + - 110: ISR + - 111: OSR + + MOV PC causes an unconditional jump. MOV EXEC has the same behaviour as OUT EXEC (Section 3.4.5), and allows register + contents to be executed as an instruction. The MOV itself executes in 1 cycle, and the instruction in Source on the next + cycle. Delay cycles on MOV EXEC are ignored, but the executee may insert delay cycles as normal. + The STATUS source has a value of all-ones or all-zeroes, depending on some state machine status such as FIFO + full/empty, configured by EXECCTRL_STATUS_SEL. + + MOV can manipulate the transferred data in limited ways, specified by the Operation argument. Invert sets each bit in + Destination to the logical NOT of the corresponding bit in Source, i.e. 1 bits become 0 bits, and vice versa. Bit reverse sets + each bit n in Destination to bit 31 - n in Source, assuming the bits are numbered 0 to 31. + MOV dst, PINS reads pins using the IN pin mapping, and writes the full 32-bit value to the destination without masking. + The LSB of the read value is the pin indicated by PINCTRL_IN_BASE, and each successive bit comes from a higher numbered pin, wrapping after 31. + + """ + ... + + def irq(mod, index: Incomplete | None = ...) -> _PIO_ASM_Program: + """rp2.PIO instruction. + + Set or clear the IRQ flag selected by Index argument. + * Clear: if 1, clear the flag selected by Index, instead of raising it. If Clear is set, the Wait bit has no effect. + * Wait: if 1, halt until the raised flag is lowered again, e.g. if a system interrupt handler has acknowledged the flag. + * Index: + + The 3 LSBs specify an IRQ index from 0-7. This IRQ flag will be set/cleared depending on the Clear bit. + + If the MSB is set, the state machine ID (0…3) is added to the IRQ index, by way of modulo-4 addition on the + two LSBs. For example, state machine 2 with a flag value of 0x11 will raise flag 3, and a flag value of 0x13 will raise flag 1. + + IRQ flags 4-7 are visible only to the state machines; IRQ flags 0-3 can be routed out to system level interrupts, on either + of the PIO’s two external interrupt request lines, configured by IRQ0_INTE and IRQ1_INTE. + The modulo addition bit allows relative addressing of 'IRQ' and 'WAIT' instructions, for synchronising state machines + which are running the same program. Bit 2 (the third LSB) is unaffected by this addition. + If Wait is set, Delay cycles do not begin until after the wait period elapses.""" + ... + + def set(destination, data) -> _PIO_ASM_Program: + """rp2.PIO SET instruction.. + + Write immediate value Data to Destination. + + • Destination: + 000: PINS + 001: X (scratch register X) 5 LSBs are set to Data, all others cleared to 0. + 010: Y (scratch register Y) 5 LSBs are set to Data, all others cleared to 0. + 011: Reserved + 100: PINDIRS + 101: Reserved + 110: Reserved + 111: Reserved + • Data: 5-bit immediate value to drive to pins or register. + + This can be used to assert control signals such as a clock or chip select, or to initialise loop counters. As Data is 5 bits in + size, scratch registers can be SET to values from 0-31, which is sufficient for a 32-iteration loop. + The mapping of SET and OUT onto pins is configured independently. They may be mapped to distinct locations, for + example if one pin is to be used as a clock signal, and another for data. They may also be overlapping ranges of pins: a + UART transmitter might use SET to assert start and stop bits, and OUT instructions to shift out FIFO data to the same pins. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/select.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/select.pyi new file mode 100644 index 0000000000..845fc36bcb --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/select.pyi @@ -0,0 +1,118 @@ +""" +Wait for events on a set of streams. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/select.html + +CPython module: :mod:`python:select` https://docs.python.org/3/library/select.html . + +This module provides functions to efficiently wait for events on multiple +`streams ` (select streams which are ready for operations). + +--- +Module: 'select' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Iterable, Iterator, List, Optional, Tuple, Final +from _typeshed import Incomplete +from typing_extensions import Awaitable, TypeAlias, TypeVar + +POLLOUT: Final[int] = 4 +POLLIN: Final[int] = 1 +POLLHUP: Final[int] = 16 +POLLERR: Final[int] = 8 + +def select( + rlist: Iterable[Any], + wlist: Iterable[Any], + xlist: Iterable[Any], + timeout: int = -1, + /, +) -> None: + """ + Wait for activity on a set of objects. + + This function is provided by some MicroPython ports for compatibility + and is not efficient. Usage of :class:`Poll` is recommended instead. + """ + ... + +class poll: + """ + Create an instance of the Poll class. + """ + def __init__(self) -> None: ... + def register(self, obj, eventmask: Optional[Any] = None) -> None: + """ + Register `stream` *obj* for polling. *eventmask* is logical OR of: + + * ``select.POLLIN`` - data available for reading + * ``select.POLLOUT`` - more data can be written + + Note that flags like ``select.POLLHUP`` and ``select.POLLERR`` are + *not* valid as input eventmask (these are unsolicited events which + will be returned from `poll()` regardless of whether they are asked + for). This semantics is per POSIX. + + *eventmask* defaults to ``select.POLLIN | select.POLLOUT``. + + It is OK to call this function multiple times for the same *obj*. + Successive calls will update *obj*'s eventmask to the value of + *eventmask* (i.e. will behave as `modify()`). + """ + ... + def unregister(self, obj) -> Incomplete: + """ + Unregister *obj* from polling. + """ + ... + def modify(self, obj, eventmask) -> None: + """ + Modify the *eventmask* for *obj*. If *obj* is not registered, `OSError` + is raised with error of ENOENT. + """ + ... + def poll(self, timeout=-1, /) -> List: + """ + Wait for at least one of the registered objects to become ready or have an + exceptional condition, with optional timeout in milliseconds (if *timeout* + arg is not specified or -1, there is no timeout). + + Returns list of (``obj``, ``event``, ...) tuples. There may be other elements in + tuple, depending on a platform and version, so don't assume that its size is 2. + The ``event`` element specifies which events happened with a stream and + is a combination of ``select.POLL*`` constants described above. Note that + flags ``select.POLLHUP`` and ``select.POLLERR`` can be returned at any time + (even if were not asked for), and must be acted on accordingly (the + corresponding stream unregistered from poll and likely closed), because + otherwise all further invocations of `poll()` may return immediately with + these flags set for this stream again. + + In case of timeout, an empty list is returned. + + Admonition:Difference to CPython + :class: attention + + Tuples returned may contain more than 2 elements as described above. + """ + ... + def ipoll(self, timeout=-1, flags=0, /) -> Iterator[Tuple]: + """ + Like :meth:`poll.poll`, but instead returns an iterator which yields a + `callee-owned tuple`. This function provides an efficient, allocation-free + way to poll on streams. + + If *flags* is 1, one-shot behaviour for events is employed: streams for + which events happened will have their event masks automatically reset + (equivalent to ``poll.modify(obj, 0)``), so new events for such a stream + won't be processed until new mask is set with `poll.modify()`. This + behaviour is useful for asynchronous I/O schedulers. + + Admonition:Difference to CPython + :class: attention + + This function is a MicroPython extension. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/socket.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/socket.pyi new file mode 100644 index 0000000000..8fa90e45e6 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/socket.pyi @@ -0,0 +1,426 @@ +""" +Socket module. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/socket.html + +CPython module: :mod:`python:socket` https://docs.python.org/3/library/socket.html . + +This module provides access to the BSD socket interface. + +Admonition:Difference to CPython + :class: attention + + For efficiency and consistency, socket objects in MicroPython implement a `stream` + (file-like) interface directly. In CPython, you need to convert a socket to + a file-like object using `makefile()` method. This method is still supported + by MicroPython (but is a no-op), so where compatibility with CPython matters, + be sure to use it. + +Socket address format(s) +------------------------ + +The native socket address format of the ``socket`` module is an opaque data type +returned by `getaddrinfo` function, which must be used to resolve textual address +(including numeric addresses):: + + sockaddr = socket.getaddrinfo('www.micropython.org', 80)[0][-1] + # You must use getaddrinfo() even for numeric addresses + sockaddr = socket.getaddrinfo('127.0.0.1', 80)[0][-1] + # Now you can use that address + sock.connect(sockaddr) + +Using `getaddrinfo` is the most efficient (both in terms of memory and processing +power) and portable way to work with addresses. + +However, ``socket`` module (note the difference with native MicroPython +``socket`` module described here) provides CPython-compatible way to specify +addresses using tuples, as described below. Note that depending on a +:term:`MicroPython port`, ``socket`` module can be builtin or need to be +installed from `micropython-lib` (as in the case of :term:`MicroPython Unix port`), +and some ports still accept only numeric addresses in the tuple format, +and require to use `getaddrinfo` function to resolve domain names. + +Summing up: + +* Always use `getaddrinfo` when writing portable applications. +* Tuple addresses described below can be used as a shortcut for + quick hacks and interactive use, if your port supports them. + +Tuple address format for ``socket`` module: + +* IPv4: *(ipv4_address, port)*, where *ipv4_address* is a string with + dot-notation numeric IPv4 address, e.g. ``"8.8.8.8"``, and *port* is and + integer port number in the range 1-65535. Note the domain names are not + accepted as *ipv4_address*, they should be resolved first using + `socket.getaddrinfo()`. +* IPv6: *(ipv6_address, port, flowinfo, scopeid)*, where *ipv6_address* + is a string with colon-notation numeric IPv6 address, e.g. ``"2001:db8::1"``, + and *port* is an integer port number in the range 1-65535. *flowinfo* + must be 0. *scopeid* is the interface scope identifier for link-local + addresses. Note the domain names are not accepted as *ipv6_address*, + they should be resolved first using `socket.getaddrinfo()`. Availability + of IPv6 support depends on a :term:`MicroPython port`. + +--- +Module: 'socket' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Literal, Tuple, overload, Final +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf +from typing_extensions import Awaitable, TypeAlias, TypeVar + +SOCK_RAW: Final[int] = 3 +SOCK_STREAM: Final[int] = 1 +"""Socket types.""" +SOCK_DGRAM: Final[int] = 2 +"""Socket types.""" +MSG_PEEK: Final[int] = 1 +SO_REUSEADDR: Final[int] = 4 +SOL_SOCKET: Final[int] = 1 +SO_BROADCAST: Final[int] = 32 +TCP_NODELAY: Final[int] = 64 +AF_INET6: Final[int] = 10 +"""Address family types. Availability depends on a particular :term:`MicroPython port`.""" +IPPROTO_IP: Final[int] = 0 +AF_INET: Final[int] = 2 +"""Address family types. Availability depends on a particular :term:`MicroPython port`.""" +MSG_DONTWAIT: Final[int] = 2 +IP_DROP_MEMBERSHIP: Final[int] = 1025 +IPPROTO_TCP: Final[int] = 6 +"""\ +IP protocol numbers. Availability depends on a particular :term:`MicroPython port`. +Note that you don't need to specify these in a call to `socket.socket()`, +because `SOCK_STREAM` socket type automatically selects `IPPROTO_TCP`, and +`SOCK_DGRAM` - `IPPROTO_UDP`. Thus, the only real use of these constants +is as an argument to `setsockopt()`. +""" +IP_ADD_MEMBERSHIP: Final[int] = 1024 +IPPROTO_UDP: Incomplete +"""\ +IP protocol numbers. Availability depends on a particular :term:`MicroPython port`. +Note that you don't need to specify these in a call to `socket.socket()`, +because `SOCK_STREAM` socket type automatically selects `IPPROTO_TCP`, and +`SOCK_DGRAM` - `IPPROTO_UDP`. Thus, the only real use of these constants +is as an argument to `setsockopt()`. +""" +IPPROTO_SEC: Incomplete +"""Special protocol value to create SSL-compatible socket.""" +_Address: TypeAlias = tuple[str, int] | tuple[str, int, int, int] | str +Socket: TypeAlias = socket + +def reset(*args, **kwargs) -> Incomplete: ... +def print_pcbs(*args, **kwargs) -> Incomplete: ... +def getaddrinfo( + host: str, + port: int, + af: int = 0, + type: int = 0, + proto: int = 0, + flags: int = 0, + /, +) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int]]]: + """ + Translate the host/port argument into a sequence of 5-tuples that contain all the + necessary arguments for creating a socket connected to that service. Arguments + *af*, *type*, and *proto* (which have the same meaning as for the `socket()` function) + can be used to filter which kind of addresses are returned. If a parameter is not + specified or zero, all combinations of addresses can be returned (requiring + filtering on the user side). + + The resulting list of 5-tuples has the following structure:: + + (family, type, proto, canonname, sockaddr) + + The following example shows how to connect to a given url:: + + s = socket.socket() + # This assumes that if "type" is not specified, an address for + # SOCK_STREAM will be returned, which may be not true + s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1]) + + Recommended use of filtering params:: + + s = socket.socket() + # Guaranteed to return an address which can be connect'ed to for + # stream operation. + s.connect(socket.getaddrinfo('www.micropython.org', 80, 0, SOCK_STREAM)[0][-1]) + + Admonition:Difference to CPython + :class: attention + + CPython raises a ``socket.gaierror`` exception (`OSError` subclass) in case + of error in this function. MicroPython doesn't have ``socket.gaierror`` + and raises OSError directly. Note that error numbers of `getaddrinfo()` + form a separate namespace and may not match error numbers from + the :mod:`errno` module. To distinguish `getaddrinfo()` errors, they are + represented by negative numbers, whereas standard system errors are + positive numbers (error numbers are accessible using ``e.args[0]`` property + from an exception object). The use of negative values is a provisional + detail which may change in the future. + """ + ... + +def callback(*args, **kwargs) -> Incomplete: ... + +class socket: + """ + A unix like socket, for more information see module ``socket``'s description. + + The name, `Socket`, used for typing is not the same as the runtime name, `socket` (note lowercase `s`). + The reason for this difference is that the runtime uses `socket` as both a class name and as a method name and + this is not possible within code written entirely in Python and therefore not possible within typing code. + """ + def recvfrom(self, bufsize: int, /) -> Tuple: + """ + Receive data from the socket. The return value is a pair *(bytes, address)* where *bytes* is a + bytes object representing the data received and *address* is the address of the socket sending + the data. + + See the `recv` function for an explanation of the optional *flags* argument. + """ + ... + def recv(self, bufsize: int, /) -> bytes: + """ + Receive data from the socket. The return value is a bytes object representing the data + received. The maximum amount of data to be received at once is specified by bufsize. + + Most ports support the optional *flags* argument. Available *flags* are defined as constants + in the socket module and have the same meaning as in CPython. ``MSG_PEEK`` and ``MSG_DONTWAIT`` + are supported on all ports which accept the *flags* argument. + """ + ... + + @overload + def makefile(self, mode: Literal["rb", "wb", "rwb"] = "rb", buffering: int = 0, /) -> Socket: + """ + Return a file object associated with the socket. The exact returned type depends on the arguments + given to makefile(). The support is limited to binary modes only ('rb', 'wb', and 'rwb'). + CPython's arguments: *encoding*, *errors* and *newline* are not supported. + + Admonition:Difference to CPython + :class: attention + + As MicroPython doesn't support buffered streams, values of *buffering* + parameter is ignored and treated as if it was 0 (unbuffered). + + Admonition:Difference to CPython + :class: attention + + Closing the file object returned by makefile() WILL close the + original socket as well. + """ + + @overload + def makefile(self, mode: str, buffering: int = 0, /) -> Socket: + """ + Return a file object associated with the socket. The exact returned type depends on the arguments + given to makefile(). The support is limited to binary modes only ('rb', 'wb', and 'rwb'). + CPython's arguments: *encoding*, *errors* and *newline* are not supported. + + Admonition:Difference to CPython + :class: attention + + As MicroPython doesn't support buffered streams, values of *buffering* + parameter is ignored and treated as if it was 0 (unbuffered). + + Admonition:Difference to CPython + :class: attention + + Closing the file object returned by makefile() WILL close the + original socket as well. + """ + def listen(self, backlog: int = ..., /) -> None: + """ + Enable a server to accept connections. If *backlog* is specified, it must be at least 0 + (if it's lower, it will be set to 0); and specifies the number of unaccepted connections + that the system will allow before refusing new connections. If not specified, a default + reasonable value is chosen. + """ + ... + def settimeout(self, value: float | None, /) -> None: + """ + **Note**: Not every port supports this method, see below. + + Set a timeout on blocking socket operations. The value argument can be a nonnegative floating + point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations + will raise an `OSError` exception if the timeout period value has elapsed before the operation has + completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket + is put in blocking mode. + + Not every :term:`MicroPython port` supports this method. A more portable and + generic solution is to use `select.poll` object. This allows to wait on + multiple objects at the same time (and not just on sockets, but on generic + `stream` objects which support polling). Example:: + + # Instead of: + s.settimeout(1.0) # time in seconds + s.read(10) # may timeout + + # Use: + poller = select.poll() + poller.register(s, select.POLLIN) + res = poller.poll(1000) # time in milliseconds + if not res: + # s is still not ready for input, i.e. operation timed out + + Admonition:Difference to CPython + :class: attention + + CPython raises a ``socket.timeout`` exception in case of timeout, + which is an `OSError` subclass. MicroPython raises an OSError directly + instead. If you use ``except OSError:`` to catch the exception, + your code will work both in MicroPython and CPython. + """ + ... + def sendall(self, bytes: AnyReadableBuf, /) -> int: + """ + Send all data to the socket. The socket must be connected to a remote socket. + Unlike `send()`, this method will try to send all of data, by sending data + chunk by chunk consecutively. + + The behaviour of this method on non-blocking sockets is undefined. Due to this, + on MicroPython, it's recommended to use `write()` method instead, which + has the same "no short writes" policy for blocking sockets, and will return + number of bytes sent on non-blocking sockets. + """ + ... + def setsockopt(self, level: int, optname: int, value: AnyReadableBuf | int, /) -> None: + """ + Set the value of the given socket option. The needed symbolic constants are defined in the + socket module (SO_* etc.). The *value* can be an integer or a bytes-like object representing + a buffer. + """ + ... + def setblocking(self, value: bool, /) -> None: + """ + Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking, + else to blocking mode. + + This method is a shorthand for certain `settimeout()` calls: + + * ``sock.setblocking(True)`` is equivalent to ``sock.settimeout(None)`` + * ``sock.setblocking(False)`` is equivalent to ``sock.settimeout(0)`` + """ + ... + def sendto(self, bytes: AnyReadableBuf, address: _Address, /) -> None: + """ + Send data to the socket. The socket should not be connected to a remote socket, since the + destination socket is specified by *address*. + """ + ... + def readline(self) -> bytes: + """ + Read a line, ending in a newline character. + + Return value: the line read. + """ + ... + + @overload + def readinto(self, buf: AnyWritableBuf, /) -> int | None: + """ + Read bytes into the *buf*. If *nbytes* is specified then read at most + that many bytes. Otherwise, read at most *len(buf)* bytes. Just as + `read()`, this method follows "no short reads" policy. + + Return value: number of bytes read and stored into *buf*. + """ + + @overload + def readinto(self, buf: AnyWritableBuf, nbytes: int, /) -> int | None: + """ + Read bytes into the *buf*. If *nbytes* is specified then read at most + that many bytes. Otherwise, read at most *len(buf)* bytes. Just as + `read()`, this method follows "no short reads" policy. + + Return value: number of bytes read and stored into *buf*. + """ + + @overload + def read(self) -> bytes: + """ + Read up to size bytes from the socket. Return a bytes object. If *size* is not given, it + reads all data available from the socket until EOF; as such the method will not return until + the socket is closed. This function tries to read as much data as + requested (no "short reads"). This may be not possible with + non-blocking socket though, and then less data will be returned. + """ + + @overload + def read(self, size: int, /) -> bytes: + """ + Read up to size bytes from the socket. Return a bytes object. If *size* is not given, it + reads all data available from the socket until EOF; as such the method will not return until + the socket is closed. This function tries to read as much data as + requested (no "short reads"). This may be not possible with + non-blocking socket though, and then less data will be returned. + """ + def close(self) -> None: + """ + Mark the socket closed and release all resources. Once that happens, all future operations + on the socket object will fail. The remote end will receive EOF indication if + supported by protocol. + + Sockets are automatically closed when they are garbage-collected, but it is recommended + to `close()` them explicitly as soon you finished working with them. + """ + ... + def connect(self, address: _Address | bytes, /) -> None: + """ + Connect to a remote socket at *address*. + """ + ... + def send(self, bytes: AnyReadableBuf, /) -> int: + """ + Send data to the socket. The socket must be connected to a remote socket. + Returns number of bytes sent, which may be smaller than the length of data + ("short write"). + """ + ... + def bind(self, address: _Address | bytes, /) -> None: + """ + Bind the socket to *address*. The socket must not already be bound. + """ + ... + def accept(self) -> Tuple: + """ + Accept a connection. The socket must be bound to an address and listening for connections. + The return value is a pair (conn, address) where conn is a new socket object usable to send + and receive data on the connection, and address is the address bound to the socket on the + other end of the connection. + """ + ... + def write(self, buf: AnyReadableBuf, /) -> int: + """ + Write the buffer of bytes to the socket. This function will try to + write all data to a socket (no "short writes"). This may be not possible + with a non-blocking socket though, and returned value will be less than + the length of *buf*. + + Return value: number of bytes written. + """ + ... + def __init__( + self, + af: int = AF_INET, + type: int = SOCK_STREAM, + proto: int = IPPROTO_TCP, + /, + ) -> None: + """ + Create a new socket using the given address family, socket type and + protocol number. Note that specifying *proto* in most cases is not + required (and not recommended, as some MicroPython ports may omit + ``IPPROTO_*`` constants). Instead, *type* argument will select needed + protocol automatically:: + + # Create STREAM TCP socket + socket(AF_INET, SOCK_STREAM) + # Create DGRAM UDP socket + socket(AF_INET, SOCK_DGRAM) + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/time.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/time.pyi new file mode 100644 index 0000000000..c5a9c409e8 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/time.pyi @@ -0,0 +1,306 @@ +""" +Time related functions. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/time.html + +CPython module: :mod:`python:time` https://docs.python.org/3/library/time.html . + +The ``time`` module provides functions for getting the current time and date, +measuring time intervals, and for delays. + +**Time Epoch**: The unix, windows, webassembly, alif, mimxrt and rp2 ports +use the standard for POSIX systems epoch of 1970-01-01 00:00:00 UTC. +The other embedded ports use an epoch of 2000-01-01 00:00:00 UTC. +Epoch year may be determined with ``gmtime(0)[0]``. + +**Maintaining actual calendar date/time**: This requires a +Real Time Clock (RTC). On systems with underlying OS (including some +RTOS), an RTC may be implicit. Setting and maintaining actual calendar +time is responsibility of OS/RTOS and is done outside of MicroPython, +it just uses OS API to query date/time. On baremetal ports however +system time depends on ``machine.RTC()`` object. The current calendar time +may be set using ``machine.RTC().datetime(tuple)`` function, and maintained +by following means: + +* By a backup battery (which may be an additional, optional component for + a particular board). +* Using networked time protocol (requires setup by a port/user). +* Set manually by a user on each power-up (many boards then maintain + RTC time across hard resets, though some may require setting it again + in such case). + +If actual calendar time is not maintained with a system/MicroPython RTC, +functions below which require reference to current absolute time may +behave not as expected. + +--- +Module: 'time' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import _TimeTuple +from typing import Tuple +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_TicksMs: TypeAlias = int +_TicksUs: TypeAlias = int +_TicksCPU: TypeAlias = int +_Ticks = TypeVar("_Ticks", _TicksMs, _TicksUs, _TicksCPU, int) + +def ticks_diff(ticks1: _Ticks, ticks2: _Ticks, /) -> int: + """ + Measure ticks difference between values returned from `ticks_ms()`, `ticks_us()`, + or `ticks_cpu()` functions, as a signed value which may wrap around. + + The argument order is the same as for subtraction + operator, ``ticks_diff(ticks1, ticks2)`` has the same meaning as ``ticks1 - ticks2``. + However, values returned by `ticks_ms()`, etc. functions may wrap around, so + directly using subtraction on them will produce incorrect result. That is why + `ticks_diff()` is needed, it implements modular (or more specifically, ring) + arithmetic to produce correct result even for wrap-around values (as long as they not + too distant in between, see below). The function returns **signed** value in the range + [*-TICKS_PERIOD/2* .. *TICKS_PERIOD/2-1*] (that's a typical range definition for + two's-complement signed binary integers). If the result is negative, it means that + *ticks1* occurred earlier in time than *ticks2*. Otherwise, it means that + *ticks1* occurred after *ticks2*. This holds **only** if *ticks1* and *ticks2* + are apart from each other for no more than *TICKS_PERIOD/2-1* ticks. If that does + not hold, incorrect result will be returned. Specifically, if two tick values are + apart for *TICKS_PERIOD/2-1* ticks, that value will be returned by the function. + However, if *TICKS_PERIOD/2* of real-time ticks has passed between them, the + function will return *-TICKS_PERIOD/2* instead, i.e. result value will wrap around + to the negative range of possible values. + + Informal rationale of the constraints above: Suppose you are locked in a room with no + means to monitor passing of time except a standard 12-notch clock. Then if you look at + dial-plate now, and don't look again for another 13 hours (e.g., if you fall for a + long sleep), then once you finally look again, it may seem to you that only 1 hour + has passed. To avoid this mistake, just look at the clock regularly. Your application + should do the same. "Too long sleep" metaphor also maps directly to application + behaviour: don't let your application run any single task for too long. Run tasks + in steps, and do time-keeping in between. + + `ticks_diff()` is designed to accommodate various usage patterns, among them: + + * Polling with timeout. In this case, the order of events is known, and you will deal + only with positive results of `ticks_diff()`:: + + # Wait for GPIO pin to be asserted, but at most 500us + start = time.ticks_us() + while pin.value() == 0: + if time.ticks_diff(time.ticks_us(), start) > 500: + raise TimeoutError + + * Scheduling events. In this case, `ticks_diff()` result may be negative + if an event is overdue:: + + # This code snippet is not optimized + now = time.ticks_ms() + scheduled_time = task.scheduled_time() + if ticks_diff(scheduled_time, now) > 0: + print("Too early, let's nap") + sleep_ms(ticks_diff(scheduled_time, now)) + task.run() + elif ticks_diff(scheduled_time, now) == 0: + print("Right at time!") + task.run() + elif ticks_diff(scheduled_time, now) < 0: + print("Oops, running late, tell task to run faster!") + task.run(run_faster=true) + + Note: Do not pass `time()` values to `ticks_diff()`, you should use + normal mathematical operations on them. But note that `time()` may (and will) + also overflow. This is known as https://en.wikipedia.org/wiki/Year_2038_problem . + """ + ... + +def ticks_add(ticks: _Ticks, delta: int, /) -> _Ticks: + """ + Offset ticks value by a given number, which can be either positive or negative. + Given a *ticks* value, this function allows to calculate ticks value *delta* + ticks before or after it, following modular-arithmetic definition of tick values + (see `ticks_ms()` above). *ticks* parameter must be a direct result of call + to `ticks_ms()`, `ticks_us()`, or `ticks_cpu()` functions (or from previous + call to `ticks_add()`). However, *delta* can be an arbitrary integer number + or numeric expression. `ticks_add()` is useful for calculating deadlines for + events/tasks. (Note: you must use `ticks_diff()` function to work with + deadlines.) + + Examples:: + + # Find out what ticks value there was 100ms ago + print(ticks_add(time.ticks_ms(), -100)) + + # Calculate deadline for operation and test for it + deadline = ticks_add(time.ticks_ms(), 200) + while ticks_diff(deadline, time.ticks_ms()) > 0: + do_a_little_of_something() + + # Find out TICKS_MAX used by this port + print(ticks_add(0, -1)) + """ + ... + +def ticks_cpu() -> _TicksCPU: + """ + Similar to `ticks_ms()` and `ticks_us()`, but with the highest possible resolution + in the system. This is usually CPU clocks, and that's why the function is named that + way. But it doesn't have to be a CPU clock, some other timing source available in a + system (e.g. high-resolution timer) can be used instead. The exact timing unit + (resolution) of this function is not specified on ``time`` module level, but + documentation for a specific port may provide more specific information. This + function is intended for very fine benchmarking or very tight real-time loops. + Avoid using it in portable code. + + Availability: Not every port implements this function. + """ + ... + +def time() -> int: + """ + Returns the number of seconds, as an integer, since the Epoch, assuming that + underlying RTC is set and maintained as described above. If an RTC is not set, this + function returns number of seconds since a port-specific reference point in time (for + embedded boards without a battery-backed RTC, usually since power up or reset). If you + want to develop portable MicroPython application, you should not rely on this function + to provide higher than second precision. If you need higher precision, absolute + timestamps, use `time_ns()`. If relative times are acceptable then use the + `ticks_ms()` and `ticks_us()` functions. If you need calendar time, `gmtime()` or + `localtime()` without an argument is a better choice. + + Admonition:Difference to CPython + :class: attention + + In CPython, this function returns number of + seconds since Unix epoch, 1970-01-01 00:00 UTC, as a floating-point, + usually having microsecond precision. With MicroPython, only Unix port + uses the same Epoch, and if floating-point precision allows, + returns sub-second precision. Embedded hardware usually doesn't have + floating-point precision to represent both long time ranges and subsecond + precision, so they use integer value with second precision. Some embedded + hardware also lacks battery-powered RTC, so returns number of seconds + since last power-up or from other relative, hardware-specific point + (e.g. reset). + """ + ... + +def ticks_ms() -> int: + """ + Returns an increasing millisecond counter with an arbitrary reference point, that + wraps around after some value. + + The wrap-around value is not explicitly exposed, but we will + refer to it as *TICKS_MAX* to simplify discussion. Period of the values is + *TICKS_PERIOD = TICKS_MAX + 1*. *TICKS_PERIOD* is guaranteed to be a power of + two, but otherwise may differ from port to port. The same period value is used + for all of `ticks_ms()`, `ticks_us()`, `ticks_cpu()` functions (for + simplicity). Thus, these functions will return a value in range [*0* .. + *TICKS_MAX*], inclusive, total *TICKS_PERIOD* values. Note that only + non-negative values are used. For the most part, you should treat values returned + by these functions as opaque. The only operations available for them are + `ticks_diff()` and `ticks_add()` functions described below. + + Note: Performing standard mathematical operations (+, -) or relational + operators (<, <=, >, >=) directly on these value will lead to invalid + result. Performing mathematical operations and then passing their results + as arguments to `ticks_diff()` or `ticks_add()` will also lead to + invalid results from the latter functions. + """ + ... + +def ticks_us() -> _TicksUs: + """ + Just like `ticks_ms()` above, but in microseconds. + """ + ... + +def time_ns() -> int: + """ + Similar to `time()` but returns nanoseconds since the Epoch, as an integer (usually + a big integer, so will allocate on the heap). + """ + ... + +def localtime(secs: int | None = None, /) -> Tuple: + """ + Convert the time *secs* expressed in seconds since the Epoch (see above) into an + 8-tuple which contains: ``(year, month, mday, hour, minute, second, weekday, yearday)`` + If *secs* is not provided or None, then the current time from the RTC is used. + + The `gmtime()` function returns a date-time tuple in UTC, and `localtime()` returns a + date-time tuple in local time. + + The format of the entries in the 8-tuple are: + + * year includes the century (for example 2014). + * month is 1-12 + * mday is 1-31 + * hour is 0-23 + * minute is 0-59 + * second is 0-59 + * weekday is 0-6 for Mon-Sun + * yearday is 1-366 + """ + ... + +def sleep_us(us: int, /) -> None: + """ + Delay for given number of microseconds, should be positive or 0. + + This function attempts to provide an accurate delay of at least *us* + microseconds, but it may take longer if the system has other higher priority + processing to perform. + """ + ... + +def gmtime(secs: int | None = None, /) -> Tuple: + """ + Convert the time *secs* expressed in seconds since the Epoch (see above) into an + 8-tuple which contains: ``(year, month, mday, hour, minute, second, weekday, yearday)`` + If *secs* is not provided or None, then the current time from the RTC is used. + + The `gmtime()` function returns a date-time tuple in UTC, and `localtime()` returns a + date-time tuple in local time. + + The format of the entries in the 8-tuple are: + + * year includes the century (for example 2014). + * month is 1-12 + * mday is 1-31 + * hour is 0-23 + * minute is 0-59 + * second is 0-59 + * weekday is 0-6 for Mon-Sun + * yearday is 1-366 + """ + ... + +def sleep_ms(ms: int, /) -> None: + """ + Delay for given number of milliseconds, should be positive or 0. + + This function will delay for at least the given number of milliseconds, but + may take longer than that if other processing must take place, for example + interrupt handlers or other threads. Passing in 0 for *ms* will still allow + this other processing to occur. Use `sleep_us()` for more precise delays. + """ + ... + +def mktime(local_time: _TimeTuple, /) -> int: + """ + This is inverse function of localtime. It's argument is a full 8-tuple + which expresses a time as per localtime. It returns an integer which is + the number of seconds since the time epoch. + """ + ... + +def sleep(seconds: float, /) -> None: + """ + Sleep for the given number of seconds. Some boards may accept *seconds* as a + floating-point number to sleep for a fractional number of seconds. Note that + other boards may not accept a floating-point argument, for compatibility with + them use `sleep_ms()` and `sleep_us()` functions. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/tls.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/tls.pyi new file mode 100644 index 0000000000..ad252fcbe9 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/tls.pyi @@ -0,0 +1,26 @@ +""" +Module: 'tls' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +PROTOCOL_TLS_SERVER: Final[int] = 1 +PROTOCOL_DTLS_CLIENT: Final[int] = 2 +PROTOCOL_DTLS_SERVER: Final[int] = 3 +PROTOCOL_TLS_CLIENT: Final[int] = 0 +MBEDTLS_VERSION: Final[str] = "Mbed TLS 3.6.2" +CERT_NONE: Final[int] = 0 +CERT_OPTIONAL: Final[int] = 1 +CERT_REQUIRED: Final[int] = 2 + +class SSLContext: + def load_verify_locations(self, *args, **kwargs) -> Incomplete: ... + def set_ciphers(self, *args, **kwargs) -> Incomplete: ... + def wrap_socket(self, *args, **kwargs) -> Incomplete: ... + def load_cert_chain(self, *args, **kwargs) -> Incomplete: ... + def get_ciphers(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uarray.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uarray.pyi new file mode 100644 index 0000000000..e5c0fe438f --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uarray.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to array +from array import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uasyncio.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uasyncio.pyi new file mode 100644 index 0000000000..3d69c52f24 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uasyncio.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to asyncio +from asyncio import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ubinascii.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ubinascii.pyi new file mode 100644 index 0000000000..3a77380ad5 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ubinascii.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to binascii +from binascii import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ubluetooth.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ubluetooth.pyi new file mode 100644 index 0000000000..4046c2c755 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ubluetooth.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to bluetooth +from bluetooth import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ucollections.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ucollections.pyi new file mode 100644 index 0000000000..deb830d909 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ucollections.pyi @@ -0,0 +1,153 @@ +""" +Collection and container types. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/collections.html + +CPython module: :mod:`python:collections` https://docs.python.org/3/library/collections.html . + +This module implements advanced collection and container types to +hold/accumulate various objects. + +--- +Module: 'ucollections' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Dict, Generic, Tuple, Any, Final, Generator +from _typeshed import Incomplete +from collections.abc import Iterable +from typing_extensions import Awaitable, TypeAlias, TypeVar + +_KT = TypeVar("_KT") +_VT = TypeVar("_VT") +_T = TypeVar("_T") + +def namedtuple(name: str, fields: str | Iterable[str]) -> type[Tuple[Any, ...]]: + """ + This is factory function to create a new namedtuple type with a specific + name and set of fields. A namedtuple is a subclass of tuple which allows + to access its fields not just by numeric index, but also with an attribute + access syntax using symbolic field names. Fields is a sequence of strings + specifying field names. For compatibility with CPython it can also be a + a string with space-separated field named (but this is less efficient). + Example of use:: + + from collections import namedtuple + + MyTuple = namedtuple("MyTuple", ("id", "name")) + t1 = MyTuple(1, "foo") + t2 = MyTuple(2, "bar") + print(t1.name) + assert t2.name == t2[1] + """ + ... + +class OrderedDict(Dict[_KT, _VT], Generic[_KT, _VT]): + """ + ``dict`` type subclass which remembers and preserves the order of keys + added. When ordered dict is iterated over, keys/items are returned in + the order they were added:: + + from collections import OrderedDict + + # To make benefit of ordered keys, OrderedDict should be initialized + # from sequence of (key, value) pairs. + d = OrderedDict([("z", 1), ("a", 2)]) + # More items can be added as usual + d["w"] = 5 + d["b"] = 3 + for k, v in d.items(): + print(k, v) + + Output:: + + z 1 + a 2 + w 5 + b 3 + """ + def popitem(self) -> Incomplete: + """ + Remove and return a (key, value) pair from the dictionary. + Pairs are returned in LIFO order. + + Admonition:Difference to CPython + :class: attention + + ``OrderedDict.popitem()`` does not support the ``last=False`` argument and + will always remove and return the last item if present. + + A workaround for this is to use ``pop()`` to remove the first item:: + + first_key = next(iter(d)) + d.pop(first_key) + """ + ... + def pop(self, *args, **kwargs) -> Incomplete: ... + def values(self, *args, **kwargs) -> Incomplete: ... + def setdefault(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def copy(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def keys(self, *args, **kwargs) -> Incomplete: ... + def get(self, *args, **kwargs) -> Incomplete: ... + def items(self, *args, **kwargs) -> Incomplete: ... + @classmethod + def fromkeys(cls, *args, **kwargs) -> Incomplete: ... + def __init__(self, *args, **kwargs) -> None: ... + +class deque: + """ + Minimal implementation of a deque that implements a FIFO buffer. + """ + def pop(self) -> Incomplete: + """ + Remove and return an item from the right side of the deque. + Raises ``IndexError`` if no items are present. + """ + ... + def appendleft(self, x: _T, /) -> Incomplete: + """ + Add *x* to the left side of the deque. + Raises ``IndexError`` if overflow checking is enabled and there is + no more room in the queue. + """ + ... + def popleft(self) -> Any: + """ + Remove and return an item from the left side of the deque. + Raises ``IndexError`` if no items are present. + """ + ... + def extend(self, iterable: Iterable[_T], /) -> Incomplete: + """ + Extend the deque by appending all the items from *iterable* to + the right of the deque. + Raises ``IndexError`` if overflow checking is enabled and there is + no more room in the deque. + """ + ... + def append(self, x: _T, /) -> None: + """ + Add *x* to the right side of the deque. + Raises ``IndexError`` if overflow checking is enabled and there is + no more room in the queue. + """ + ... + def __init__(self, iterable: tuple[Any], maxlen: int, flags: int = 0, /) -> None: + """ + Deques (double-ended queues) are a list-like container that support O(1) + appends and pops from either side of the deque. New deques are created + using the following arguments: + + - *iterable* must be the empty tuple, and the new deque is created empty. + + - *maxlen* must be specified and the deque will be bounded to this + maximum length. Once the deque is full, any new items added will + discard items from the opposite end. + + - The optional *flags* can be 1 to check for overflow when adding items. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ucryptolib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ucryptolib.pyi new file mode 100644 index 0000000000..6b8b56a685 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ucryptolib.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to cryptolib +from cryptolib import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uctypes.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uctypes.pyi new file mode 100644 index 0000000000..ba2458b265 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uctypes.pyi @@ -0,0 +1,164 @@ +""" +Access binary data in a structured way. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/uctypes.html + +This module implements "foreign data interface" for MicroPython. The idea +behind it is similar to CPython's ``ctypes`` modules, but the actual API is +different, streamlined and optimized for small size. The basic idea of the +module is to define data structure layout with about the same power as the +C language allows, and then access it using familiar dot-syntax to reference +sub-fields. + +--- +Module: 'uctypes' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Dict, Tuple, Any, Final, Generator +from _typeshed import Incomplete +from _mpy_shed import AnyReadableBuf, AnyWritableBuf, mp_available +from typing_extensions import Awaitable, TypeAlias, TypeVar + +VOID: Final[int] = 0 +"""\ +``VOID`` is an alias for ``UINT8``, and is provided to conveniently define +C's void pointers: ``(uctypes.PTR, uctypes.VOID)``. +""" +NATIVE: Final[int] = 2 +"""\ +Layout type for a native structure - with data endianness and alignment +conforming to the ABI of the system on which MicroPython runs. +""" +PTR: Final[int] = 536870912 +"""\ +Type constants for pointers and arrays. Note that there is no explicit +constant for structures, it's implicit: an aggregate type without ``PTR`` +or ``ARRAY`` flags is a structure. +""" +SHORT: Final[int] = 402653184 +LONGLONG: Final[int] = 939524096 +INT8: Final[int] = 134217728 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +LITTLE_ENDIAN: Final[int] = 0 +"""\ +Layout type for a little-endian packed structure. (Packed means that every +field occupies exactly as many bytes as defined in the descriptor, i.e. +the alignment is 1). +""" +LONG: Final[int] = 671088640 +UINT: Final[int] = 536870912 +ULONG: Final[int] = 536870912 +ULONGLONG: Final[int] = 805306368 +USHORT: Final[int] = 268435456 +UINT8: Final[int] = 0 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +UINT16: Final[int] = 268435456 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +UINT32: Final[int] = 536870912 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +UINT64: Final[int] = 805306368 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +INT64: Final[int] = 939524096 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +BFUINT16: Final[int] = -805306368 +BFUINT32: Final[int] = -536870912 +BFUINT8: Final[int] = -1073741824 +BFINT8: Final[int] = -939524096 +ARRAY: Final[int] = -1073741824 +"""\ +Type constants for pointers and arrays. Note that there is no explicit +constant for structures, it's implicit: an aggregate type without ``PTR`` +or ``ARRAY`` flags is a structure. +""" +BFINT16: Final[int] = -671088640 +BFINT32: Final[int] = -402653184 +BF_LEN: Final[int] = 22 +INT: Final[int] = 671088640 +INT16: Final[int] = 402653184 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +INT32: Final[int] = 671088640 +"""\ +Integer types for structure descriptors. Constants for 8, 16, 32, +and 64 bit types are provided, both signed and unsigned. +""" +FLOAT64: Final[int] = -134217728 +"""Floating-point types for structure descriptors.""" +BF_POS: Final[int] = 17 +BIG_ENDIAN: Final[int] = 1 +"""Layout type for a big-endian packed structure.""" +FLOAT32: Final[int] = -268435456 +"""Floating-point types for structure descriptors.""" +_property: TypeAlias = Incomplete +_descriptor: TypeAlias = Tuple | Dict + +def sizeof(struct: struct | _descriptor | dict, layout_type: int = NATIVE, /) -> int: + """ + Return size of data structure in bytes. The *struct* argument can be + either a structure class or a specific instantiated structure object + (or its aggregate field). + """ + ... + +def bytes_at(addr: int, size: int, /) -> bytes: + """ + Capture memory at the given address and size as bytes object. As bytes + object is immutable, memory is actually duplicated and copied into + bytes object, so if memory contents change later, created object + retains original value. + """ + ... + +def bytearray_at(addr: int, size: int, /) -> bytearray: + """ + Capture memory at the given address and size as bytearray object. + Unlike bytes_at() function above, memory is captured by reference, + so it can be both written too, and you will access current value + at the given memory address. + """ + ... + +def addressof(obj: AnyReadableBuf, /) -> int: + """ + Return address of an object. Argument should be bytes, bytearray or + other object supporting buffer protocol (and address of this buffer + is what actually returned). + """ + ... + +class struct: + """ + Module contents + --------------- + """ + def __init__(self, addr: int | struct, descriptor: _descriptor, layout_type: int = NATIVE, /) -> None: + """ + Instantiate a "foreign data structure" object based on structure address in + memory, descriptor (encoded as a dictionary), and layout type (see below). + """ + ... + @mp_available() # force push + def __getattr__(self, a): ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uerrno.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uerrno.pyi new file mode 100644 index 0000000000..8d34ba6b73 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uerrno.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to errno +from errno import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uhashlib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uhashlib.pyi new file mode 100644 index 0000000000..8b4b7bc778 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uhashlib.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to hashlib +from hashlib import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uheapq.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uheapq.pyi new file mode 100644 index 0000000000..71c066fcf4 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uheapq.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to heapq +from heapq import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uio.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uio.pyi new file mode 100644 index 0000000000..514a4f945d --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uio.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to io +from io import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ujson.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ujson.pyi new file mode 100644 index 0000000000..0de669254d --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ujson.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to json +from json import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/umachine.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/umachine.pyi new file mode 100644 index 0000000000..e1fdb35a46 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/umachine.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to machine +from machine import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uos.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uos.pyi new file mode 100644 index 0000000000..8c99e764b0 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uos.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to os +from os import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uplatform.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uplatform.pyi new file mode 100644 index 0000000000..22ad247bf6 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uplatform.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to platform +from platform import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/urandom.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/urandom.pyi new file mode 100644 index 0000000000..b912f07931 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/urandom.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to random +from random import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ure.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ure.pyi new file mode 100644 index 0000000000..dbe8b6a52c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ure.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to re +from re import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/urequests.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/urequests.pyi new file mode 100644 index 0000000000..ec902ea4e8 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/urequests.pyi @@ -0,0 +1,25 @@ +""" +Module: 'urequests' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def delete(*args, **kwargs) -> Incomplete: ... +def head(*args, **kwargs) -> Incomplete: ... +def patch(*args, **kwargs) -> Incomplete: ... +def post(*args, **kwargs) -> Incomplete: ... +def request(*args, **kwargs) -> Incomplete: ... +def put(*args, **kwargs) -> Incomplete: ... +def get(*args, **kwargs) -> Incomplete: ... + +class Response: + def json(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + + content: Incomplete ## = + text: Incomplete ## = + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uselect.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uselect.pyi new file mode 100644 index 0000000000..a543041c4d --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uselect.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to select +from select import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/usocket.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/usocket.pyi new file mode 100644 index 0000000000..140590c295 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/usocket.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to socket +from socket import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ussl.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ussl.pyi new file mode 100644 index 0000000000..3115761c4b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ussl.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to ssl +from ssl import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ustruct.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ustruct.pyi new file mode 100644 index 0000000000..0f7fb657af --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/ustruct.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to struct +from struct import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/usys.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/usys.pyi new file mode 100644 index 0000000000..298d7a8ac3 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/usys.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to sys +from sys import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/utime.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/utime.pyi new file mode 100644 index 0000000000..1f972a5b62 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/utime.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to time +from time import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uwebsocket.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uwebsocket.pyi new file mode 100644 index 0000000000..afa801ba21 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uwebsocket.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to websocket +from websocket import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uzlib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uzlib.pyi new file mode 100644 index 0000000000..5fad9a23c9 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/uzlib.pyi @@ -0,0 +1,2 @@ +# This umodule is a MicroPython reference to zlib +from zlib import * diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/vfs.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/vfs.pyi new file mode 100644 index 0000000000..f24ae6eb51 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/vfs.pyi @@ -0,0 +1,240 @@ +""" +Virtual filesystem control. + +MicroPython module: https://docs.micropython.org/en/v1.27.0/library/vfs.html + +The ``vfs`` module contains functions for creating filesystem objects and +mounting/unmounting them in the Virtual Filesystem. + +Filesystem mounting +------------------- + +Some ports provide a Virtual Filesystem (VFS) and the ability to mount multiple +"real" filesystems within this VFS. Filesystem objects can be mounted at either +the root of the VFS, or at a subdirectory that lives in the root. This allows +dynamic and flexible configuration of the filesystem that is seen by Python +programs. Ports that have this functionality provide the :func:`mount` and +:func:`umount` functions, and possibly various filesystem implementations +represented by VFS classes. + +--- +Module: 'vfs' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete +from _mpy_shed import _BlockDeviceProtocol +from abc import ABC, abstractmethod +from typing import List, overload +from typing_extensions import Awaitable, TypeAlias, TypeVar + +def umount(mount_point: Incomplete) -> Incomplete: + """ + Unmount a filesystem. *mount_point* can be a string naming the mount location, + or a previously-mounted filesystem object. During the unmount process the + method ``umount()`` is called on the filesystem object. + + Will raise ``OSError(EINVAL)`` if *mount_point* is not found. + """ + ... + +@overload +def mount(fsobj, mount_point: str, *, readonly: bool = False) -> None: + """ + :noindex: + + With no arguments to :func:`mount`, return a list of tuples representing + all active mountpoints. + + The returned list has the form *[(fsobj, mount_point), ...]*. + """ + ... + +@overload +def mount() -> List[tuple[Incomplete, str]]: + """ + :noindex: + + With no arguments to :func:`mount`, return a list of tuples representing + all active mountpoints. + + The returned list has the form *[(fsobj, mount_point), ...]*. + """ + ... + +class VfsLfs2: + """ + Create a filesystem object that uses the `littlefs v2 filesystem format`_. + Storage of the littlefs filesystem is provided by *block_dev*, which must + support the :ref:`extended interface `. + Objects created by this constructor can be mounted using :func:`mount`. + + The *mtime* argument enables modification timestamps for files, stored using + littlefs attributes. This option can be disabled or enabled differently each + mount time and timestamps will only be added or updated if *mtime* is enabled, + otherwise the timestamps will remain untouched. Littlefs v2 filesystems without + timestamps will work without reformatting and timestamps will be added + transparently to existing files once they are opened for writing. When *mtime* + is enabled `os.stat` on files without timestamps will return 0 for the timestamp. + + See :ref:`filesystem` for more information. + """ + def rename(self, *args, **kwargs) -> Incomplete: ... + @staticmethod + def mkfs(block_dev: AbstractBlockDev, readsize=32, progsize=32, lookahead=32) -> None: + """ + Build a Lfs2 filesystem on *block_dev*. + + ``Note:`` There are reports of littlefs v2 failing in certain situations, + for details see `littlefs issue 295`_. + """ + ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, block_dev: AbstractBlockDev, readsize=32, progsize=32, lookahead=32, mtime=True) -> None: ... + +class VfsFat: + """ + Create a filesystem object that uses the FAT filesystem format. Storage of + the FAT filesystem is provided by *block_dev*. + Objects created by this constructor can be mounted using :func:`mount`. + """ + def rename(self, *args, **kwargs) -> Incomplete: ... + @staticmethod + def mkfs(block_dev: AbstractBlockDev) -> None: + """ + Build a FAT filesystem on *block_dev*. + """ + ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, block_dev: AbstractBlockDev) -> None: ... + +class AbstractBlockDev: + # + @abstractmethod + @overload + def readblocks(self, block_num: int, buf: bytearray) -> bool: ... + @abstractmethod + @overload + def readblocks(self, block_num: int, buf: bytearray, offset: int) -> bool: + """ + The first form reads aligned, multiples of blocks. + Starting at the block given by the index *block_num*, read blocks from + the device into *buf* (an array of bytes). + The number of blocks to read is given by the length of *buf*, + which will be a multiple of the block size. + + The second form allows reading at arbitrary locations within a block, + and arbitrary lengths. + Starting at block index *block_num*, and byte offset within that block + of *offset*, read bytes from the device into *buf* (an array of bytes). + The number of bytes to read is given by the length of *buf*. + """ + ... + + @abstractmethod + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, /) -> None: + """ + The first form writes aligned, multiples of blocks, and requires that the + blocks that are written to be first erased (if necessary) by this method. + Starting at the block given by the index *block_num*, write blocks from + *buf* (an array of bytes) to the device. + The number of blocks to write is given by the length of *buf*, + which will be a multiple of the block size. + + The second form allows writing at arbitrary locations within a block, + and arbitrary lengths. Only the bytes being written should be changed, + and the caller of this method must ensure that the relevant blocks are + erased via a prior ``ioctl`` call. + Starting at block index *block_num*, and byte offset within that block + of *offset*, write bytes from *buf* (an array of bytes) to the device. + The number of bytes to write is given by the length of *buf*. + + Note that implementations must never implicitly erase blocks if the offset + argument is specified, even if it is zero. + """ + + @abstractmethod + @overload + def writeblocks(self, block_num: int, buf: bytes | bytearray, offset: int, /) -> None: + """ + The first form writes aligned, multiples of blocks, and requires that the + blocks that are written to be first erased (if necessary) by this method. + Starting at the block given by the index *block_num*, write blocks from + *buf* (an array of bytes) to the device. + The number of blocks to write is given by the length of *buf*, + which will be a multiple of the block size. + + The second form allows writing at arbitrary locations within a block, + and arbitrary lengths. Only the bytes being written should be changed, + and the caller of this method must ensure that the relevant blocks are + erased via a prior ``ioctl`` call. + Starting at block index *block_num*, and byte offset within that block + of *offset*, write bytes from *buf* (an array of bytes) to the device. + The number of bytes to write is given by the length of *buf*. + + Note that implementations must never implicitly erase blocks if the offset + argument is specified, even if it is zero. + """ + ... + + @abstractmethod + @overload + def ioctl(self, op: int, arg) -> int | None: ... + # + @abstractmethod + @overload + def ioctl(self, op: int) -> int | None: + """ + Control the block device and query its parameters. The operation to + perform is given by *op* which is one of the following integers: + + - 1 -- initialise the device (*arg* is unused) + - 2 -- shutdown the device (*arg* is unused) + - 3 -- sync the device (*arg* is unused) + - 4 -- get a count of the number of blocks, should return an integer + (*arg* is unused) + - 5 -- get the number of bytes in a block, should return an integer, + or ``None`` in which case the default value of 512 is used + (*arg* is unused) + - 6 -- erase a block, *arg* is the block number to erase + + As a minimum ``ioctl(4, ...)`` must be intercepted; for littlefs + ``ioctl(6, ...)`` must also be intercepted. The need for others is + hardware dependent. + + Prior to any call to ``writeblocks(block, ...)`` littlefs issues + ``ioctl(6, block)``. This enables a device driver to erase the block + prior to a write if the hardware requires it. Alternatively a driver + might intercept ``ioctl(6, block)`` and return 0 (success). In this case + the driver assumes responsibility for detecting the need for erasure. + + Unless otherwise stated ``ioctl(op, arg)`` can return ``None``. + Consequently an implementation can ignore unused values of ``op``. Where + ``op`` is intercepted, the return value for operations 4 and 5 are as + detailed above. Other operations should return 0 on success and non-zero + for failure, with the value returned being an ``OSError`` errno code. + """ + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/websocket.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/websocket.pyi new file mode 100644 index 0000000000..393cea0558 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W-merged/websocket.pyi @@ -0,0 +1,17 @@ +""" +Module: 'websocket' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +class websocket: + def readline(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_asyncio.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_asyncio.pyi new file mode 100644 index 0000000000..e4dc9e67c6 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_asyncio.pyi @@ -0,0 +1,18 @@ +""" +Module: '_asyncio' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +class TaskQueue: + def push(self, *args, **kwargs) -> Incomplete: ... + def peek(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def pop(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Task: + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_boot_fat.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_boot_fat.pyi new file mode 100644 index 0000000000..ec0077130a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_boot_fat.pyi @@ -0,0 +1,8 @@ +""" +Module: '_boot_fat' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_onewire.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_onewire.pyi new file mode 100644 index 0000000000..49f6f067b2 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_onewire.pyi @@ -0,0 +1,15 @@ +""" +Module: '_onewire' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def reset(*args, **kwargs) -> Incomplete: ... +def writebyte(*args, **kwargs) -> Incomplete: ... +def writebit(*args, **kwargs) -> Incomplete: ... +def crc8(*args, **kwargs) -> Incomplete: ... +def readbyte(*args, **kwargs) -> Incomplete: ... +def readbit(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_rp2.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_rp2.pyi new file mode 100644 index 0000000000..c729ad0450 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_rp2.pyi @@ -0,0 +1,59 @@ +""" +Module: '_rp2' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +def country(*args, **kwargs) -> Incomplete: ... +def bootsel_button(*args, **kwargs) -> Incomplete: ... + +class Flash: + def readblocks(self, *args, **kwargs) -> Incomplete: ... + def writeblocks(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DMA: + def irq(self, *args, **kwargs) -> Incomplete: ... + def unpack_ctrl(self, *args, **kwargs) -> Incomplete: ... + def pack_ctrl(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def config(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class StateMachine: + def irq(self, *args, **kwargs) -> Incomplete: ... + def put(self, *args, **kwargs) -> Incomplete: ... + def restart(self, *args, **kwargs) -> Incomplete: ... + def rx_fifo(self, *args, **kwargs) -> Incomplete: ... + def tx_fifo(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def exec(self, *args, **kwargs) -> Incomplete: ... + def get(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class PIO: + JOIN_TX: Final[int] = 1 + JOIN_NONE: Final[int] = 0 + JOIN_RX: Final[int] = 2 + SHIFT_LEFT: Final[int] = 0 + OUT_HIGH: Final[int] = 3 + OUT_LOW: Final[int] = 2 + SHIFT_RIGHT: Final[int] = 1 + IN_LOW: Final[int] = 0 + IRQ_SM3: Final[int] = 2048 + IN_HIGH: Final[int] = 1 + IRQ_SM2: Final[int] = 1024 + IRQ_SM0: Final[int] = 256 + IRQ_SM1: Final[int] = 512 + def state_machine(self, *args, **kwargs) -> Incomplete: ... + def remove_program(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def add_program(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_thread.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_thread.pyi new file mode 100644 index 0000000000..8b2268ca6e --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_thread.pyi @@ -0,0 +1,20 @@ +""" +Module: '_thread' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def get_ident(*args, **kwargs) -> Incomplete: ... +def start_new_thread(*args, **kwargs) -> Incomplete: ... +def stack_size(*args, **kwargs) -> Incomplete: ... +def exit(*args, **kwargs) -> Incomplete: ... +def allocate_lock(*args, **kwargs) -> Incomplete: ... + +class LockType: + def locked(self, *args, **kwargs) -> Incomplete: ... + def release(self, *args, **kwargs) -> Incomplete: ... + def acquire(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/__init__.pyi new file mode 100644 index 0000000000..8bb449317b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/__init__.pyi @@ -0,0 +1,191 @@ +""" +Module: 'aioble.__init__' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final, Generator +from _typeshed import Incomplete + +ADDR_PUBLIC: Final[int] = 0 +ADDR_RANDOM: Final[int] = 1 +def log_warn(*args, **kwargs) -> Incomplete: + ... + +def log_info(*args, **kwargs) -> Incomplete: + ... + +def log_error(*args, **kwargs) -> Incomplete: + ... + +def register_services(*args, **kwargs) -> Incomplete: + ... + +def stop(*args, **kwargs) -> Incomplete: + ... + +def config(*args, **kwargs) -> Incomplete: + ... + +def const(*args, **kwargs) -> Incomplete: + ... + + +class Service(): + def _tuple(self, *args, **kwargs) -> Incomplete: + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class scan(): + def cancel(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + +def advertise(*args, **kwargs) -> Generator: ## = + ... + + +class Characteristic(): + def _remote_write(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_read(self, *args, **kwargs) -> Incomplete: + ... + + def notify(self, *args, **kwargs) -> Incomplete: + ... + + def on_read(self, *args, **kwargs) -> Incomplete: + ... + + def _tuple(self, *args, **kwargs) -> Incomplete: + ... + + def write(self, *args, **kwargs) -> Incomplete: + ... + + def read(self, *args, **kwargs) -> Incomplete: + ... + + def _register(self, *args, **kwargs) -> Incomplete: + ... + + def _indicate_done(self, *args, **kwargs) -> Incomplete: + ... + + def _init_capture(self, *args, **kwargs) -> Incomplete: + ... + + def written(*args, **kwargs) -> Generator: ## = + ... + + def indicate(*args, **kwargs) -> Generator: ## = + ... + + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class GattError(Exception): + ... + +class BufferedCharacteristic(): + def on_read(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_read(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_write(self, *args, **kwargs) -> Incomplete: + ... + + def notify(self, *args, **kwargs) -> Incomplete: + ... + + def _tuple(self, *args, **kwargs) -> Incomplete: + ... + + def _init_capture(self, *args, **kwargs) -> Incomplete: + ... + + def read(self, *args, **kwargs) -> Incomplete: + ... + + def write(self, *args, **kwargs) -> Incomplete: + ... + + def _indicate_done(self, *args, **kwargs) -> Incomplete: + ... + + def written(*args, **kwargs) -> Generator: ## = + ... + + def _register(self, *args, **kwargs) -> Incomplete: + ... + + def indicate(*args, **kwargs) -> Generator: ## = + ... + + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class DeviceDisconnectedError(Exception): + ... + +class Descriptor(): + def _tuple(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_read(self, *args, **kwargs) -> Incomplete: + ... + + def _remote_write(self, *args, **kwargs) -> Incomplete: + ... + + def on_read(self, *args, **kwargs) -> Incomplete: + ... + + def _register(self, *args, **kwargs) -> Incomplete: + ... + + def read(self, *args, **kwargs) -> Incomplete: + ... + + def write(self, *args, **kwargs) -> Incomplete: + ... + + def _init_capture(self, *args, **kwargs) -> Incomplete: + ... + + def written(*args, **kwargs) -> Generator: ## = + ... + + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class Device(): + def addr_hex(self, *args, **kwargs) -> Incomplete: + ... + + def connect(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/central.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/central.pyi new file mode 100644 index 0000000000..9a0b64ced4 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/central.pyi @@ -0,0 +1,81 @@ +""" +Module: 'aioble.central' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def _central_shutdown(*args, **kwargs) -> Incomplete: ... +def ensure_active(*args, **kwargs) -> Incomplete: ... +def _central_irq(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +ble: Incomplete ## = + +class DeviceTimeout: + def _timeout_sleep(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class scan: + def cancel(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +_active_scanner: Incomplete ## = None + +def _cancel_pending(*args, **kwargs) -> Generator: ## = + ... + +class ScanResult: + def _update(self, *args, **kwargs) -> Incomplete: ... + def name(self, *args, **kwargs) -> Incomplete: ... + def manufacturer(*args, **kwargs) -> Generator: ## = + ... + def services(*args, **kwargs) -> Generator: ## = + ... + def _decode_field(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +_connecting: set ## = set() + +def _connect(*args, **kwargs) -> Generator: ## = + ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Device: + def addr_hex(self, *args, **kwargs) -> Incomplete: ... + def connect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/client.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/client.pyi new file mode 100644 index 0000000000..f99ed6286e --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/client.pyi @@ -0,0 +1,120 @@ +""" +Module: 'aioble.client' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def _client_irq(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class GattError(Exception): ... + +class ClientService: + def characteristics(self, *args, **kwargs) -> Incomplete: ... + def _start_discovery(self, *args, **kwargs) -> Incomplete: ... + def characteristic(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = + +class ClientDiscover: + def _discover_result(self, *args, **kwargs) -> Incomplete: ... + def _discover_done(self, *args, **kwargs) -> Incomplete: ... + def _start(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class deque: + def pop(self, *args, **kwargs) -> Incomplete: ... + def appendleft(self, *args, **kwargs) -> Incomplete: ... + def popleft(self, *args, **kwargs) -> Incomplete: ... + def extend(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class ClientDescriptor: + def _read_result(self, *args, **kwargs) -> Incomplete: ... + def _read_done(self, *args, **kwargs) -> Incomplete: ... + def _write_done(self, *args, **kwargs) -> Incomplete: ... + def _register_with_connection(self, *args, **kwargs) -> Incomplete: ... + def _start_discovery(self, *args, **kwargs) -> Incomplete: ... + def _check(self, *args, **kwargs) -> Incomplete: ... + def _find(self, *args, **kwargs) -> Incomplete: ... + def _connection(self, *args, **kwargs) -> Incomplete: ... + def write(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class BaseClientCharacteristic: + def _write_done(self, *args, **kwargs) -> Incomplete: ... + def _read_done(self, *args, **kwargs) -> Incomplete: ... + def _read_result(self, *args, **kwargs) -> Incomplete: ... + def _register_with_connection(self, *args, **kwargs) -> Incomplete: ... + def _find(self, *args, **kwargs) -> Incomplete: ... + def _check(self, *args, **kwargs) -> Incomplete: ... + def write(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class ClientCharacteristic: + def _on_notify(self, *args, **kwargs) -> Incomplete: ... + def _register_with_connection(self, *args, **kwargs) -> Incomplete: ... + def _on_indicate(self, *args, **kwargs) -> Incomplete: ... + def _read_result(self, *args, **kwargs) -> Incomplete: ... + def _on_notify_indicate(self, *args, **kwargs) -> Incomplete: ... + def _read_done(self, *args, **kwargs) -> Incomplete: ... + def _start_discovery(self, *args, **kwargs) -> Incomplete: ... + def descriptors(self, *args, **kwargs) -> Incomplete: ... + def _write_done(self, *args, **kwargs) -> Incomplete: ... + def _find(self, *args, **kwargs) -> Incomplete: ... + def _check(self, *args, **kwargs) -> Incomplete: ... + def _connection(self, *args, **kwargs) -> Incomplete: ... + def subscribe(*args, **kwargs) -> Generator: ## = + ... + def indicated(*args, **kwargs) -> Generator: ## = + ... + def notified(*args, **kwargs) -> Generator: ## = + ... + def descriptor(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def write(*args, **kwargs) -> Generator: ## = + ... + def _notified_indicated(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/core.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/core.pyi new file mode 100644 index 0000000000..63e8f67337 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/core.pyi @@ -0,0 +1,25 @@ +""" +Module: 'aioble.core' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +_irq_handlers: list = [] +_shutdown_handlers: list = [] +log_level: int = 1 + +def ensure_active(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def config(*args, **kwargs) -> Incomplete: ... +def stop(*args, **kwargs) -> Incomplete: ... +def ble_irq(*args, **kwargs) -> Incomplete: ... + +ble: Incomplete ## = + +class GattError(Exception): ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/device.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/device.pyi new file mode 100644 index 0000000000..c668bd281d --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/device.pyi @@ -0,0 +1,53 @@ +""" +Module: 'aioble.device' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def _device_irq(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class Device: + def addr_hex(self, *args, **kwargs) -> Incomplete: ... + def connect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DeviceDisconnectedError(Exception): ... + +class DeviceTimeout: + def _timeout_sleep(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/l2cap.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/l2cap.pyi new file mode 100644 index 0000000000..d2ba328348 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/l2cap.pyi @@ -0,0 +1,66 @@ +""" +Module: 'aioble.l2cap' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +_listening: bool = False + +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def _l2cap_irq(*args, **kwargs) -> Incomplete: ... +def _l2cap_shutdown(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... +def accept(*args, **kwargs) -> Generator: ## = + ... + +ble: Incomplete ## = + +class L2CAPChannel: + def available(self, *args, **kwargs) -> Incomplete: ... + def _assert_connected(self, *args, **kwargs) -> Incomplete: ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def recvinto(*args, **kwargs) -> Generator: ## = + ... + def send(*args, **kwargs) -> Generator: ## = + ... + def flush(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +def connect(*args, **kwargs) -> Generator: ## = + ... + +class L2CAPConnectionError(Exception): ... +class L2CAPDisconnectedError(Exception): ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/peripheral.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/peripheral.pyi new file mode 100644 index 0000000000..dc36a2087c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/peripheral.pyi @@ -0,0 +1,62 @@ +""" +Module: 'aioble.peripheral' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def _peripheral_shutdown(*args, **kwargs) -> Incomplete: ... +def ensure_active(*args, **kwargs) -> Incomplete: ... +def _peripheral_irq(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def _append(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class Device: + def addr_hex(self, *args, **kwargs) -> Incomplete: ... + def connect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +_incoming_connection: Incomplete ## = None +_connect_event: Incomplete ## = None + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DeviceTimeout: + def _timeout_sleep(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = + +def advertise(*args, **kwargs) -> Generator: ## = + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/security.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/security.pyi new file mode 100644 index 0000000000..3164987ab6 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/security.pyi @@ -0,0 +1,54 @@ +""" +Module: 'aioble.security' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final, Generator +from _typeshed import Incomplete + +_modified: bool = False +_DEFAULT_PATH: Final[str] = "ble_secrets.json" +_secrets: dict = {} + +def _security_irq(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def _security_shutdown(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def load_secrets(*args, **kwargs) -> Incomplete: ... +def schedule(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... +def _save_secrets(*args, **kwargs) -> Incomplete: ... + +_path: Incomplete ## = None + +def pair(*args, **kwargs) -> Generator: ## = + ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/server.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/server.pyi new file mode 100644 index 0000000000..bca231a3b1 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/server.pyi @@ -0,0 +1,133 @@ +""" +Module: 'aioble.server' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +_registered_characteristics: dict = {} + +def _server_shutdown(*args, **kwargs) -> Incomplete: ... +def ensure_active(*args, **kwargs) -> Incomplete: ... +def _server_irq(*args, **kwargs) -> Incomplete: ... +def register_services(*args, **kwargs) -> Incomplete: ... +def log_error(*args, **kwargs) -> Incomplete: ... +def register_irq_handler(*args, **kwargs) -> Incomplete: ... +def log_warn(*args, **kwargs) -> Incomplete: ... +def log_info(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class BaseCharacteristic: + def _remote_read(self, *args, **kwargs) -> Incomplete: ... + def _register(self, *args, **kwargs) -> Incomplete: ... + def _remote_write(self, *args, **kwargs) -> Incomplete: ... + def on_read(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def _init_capture(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def written(*args, **kwargs) -> Generator: ## = + ... + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class BufferedCharacteristic: + def on_read(self, *args, **kwargs) -> Incomplete: ... + def _remote_read(self, *args, **kwargs) -> Incomplete: ... + def _remote_write(self, *args, **kwargs) -> Incomplete: ... + def notify(self, *args, **kwargs) -> Incomplete: ... + def _tuple(self, *args, **kwargs) -> Incomplete: ... + def _init_capture(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def _indicate_done(self, *args, **kwargs) -> Incomplete: ... + def written(*args, **kwargs) -> Generator: ## = + ... + def _register(self, *args, **kwargs) -> Incomplete: ... + def indicate(*args, **kwargs) -> Generator: ## = + ... + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +ble: Incomplete ## = + +class deque: + def pop(self, *args, **kwargs) -> Incomplete: ... + def appendleft(self, *args, **kwargs) -> Incomplete: ... + def popleft(self, *args, **kwargs) -> Incomplete: ... + def extend(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DeviceTimeout: + def _timeout_sleep(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Service: + def _tuple(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class GattError(Exception): ... + +class Characteristic: + def _remote_write(self, *args, **kwargs) -> Incomplete: ... + def _remote_read(self, *args, **kwargs) -> Incomplete: ... + def notify(self, *args, **kwargs) -> Incomplete: ... + def on_read(self, *args, **kwargs) -> Incomplete: ... + def _tuple(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def _register(self, *args, **kwargs) -> Incomplete: ... + def _indicate_done(self, *args, **kwargs) -> Incomplete: ... + def _init_capture(self, *args, **kwargs) -> Incomplete: ... + def written(*args, **kwargs) -> Generator: ## = + ... + def indicate(*args, **kwargs) -> Generator: ## = + ... + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DeviceConnection: + _connected: dict = {} + def is_connected(self, *args, **kwargs) -> Incomplete: ... + def _run_task(self, *args, **kwargs) -> Incomplete: ... + def services(self, *args, **kwargs) -> Incomplete: ... + def timeout(self, *args, **kwargs) -> Incomplete: ... + def device_task(*args, **kwargs) -> Generator: ## = + ... + def l2cap_connect(*args, **kwargs) -> Generator: ## = + ... + def pair(*args, **kwargs) -> Generator: ## = + ... + def service(*args, **kwargs) -> Generator: ## = + ... + def l2cap_accept(*args, **kwargs) -> Generator: ## = + ... + def disconnected(*args, **kwargs) -> Generator: ## = + ... + def exchange_mtu(*args, **kwargs) -> Generator: ## = + ... + def disconnect(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Descriptor: + def _tuple(self, *args, **kwargs) -> Incomplete: ... + def _remote_read(self, *args, **kwargs) -> Incomplete: ... + def _remote_write(self, *args, **kwargs) -> Incomplete: ... + def on_read(self, *args, **kwargs) -> Incomplete: ... + def _register(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def _init_capture(self, *args, **kwargs) -> Incomplete: ... + def written(*args, **kwargs) -> Generator: ## = + ... + def _run_capture_task(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/array.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/array.pyi new file mode 100644 index 0000000000..ce9f52de6b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/array.pyi @@ -0,0 +1,13 @@ +""" +Module: 'array' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +class array: + def extend(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/__init__.pyi new file mode 100644 index 0000000000..71f5891b49 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/__init__.pyi @@ -0,0 +1,278 @@ +""" +Module: 'asyncio.__init__' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +_attrs: dict = {} +def current_task(*args, **kwargs) -> Incomplete: + ... + +def get_event_loop(*args, **kwargs) -> Incomplete: + ... + +def create_task(*args, **kwargs) -> Incomplete: + ... + +def ticks_diff(*args, **kwargs) -> Incomplete: + ... + +def new_event_loop(*args, **kwargs) -> Incomplete: + ... + +def ticks(*args, **kwargs) -> Incomplete: + ... + +def run_until_complete(*args, **kwargs) -> Incomplete: + ... + +def run(*args, **kwargs) -> Incomplete: + ... + +def wait_for_ms(*args, **kwargs) -> Incomplete: + ... + +def sleep_ms(*args, **kwargs) -> Incomplete: + ... + +def ticks_add(*args, **kwargs) -> Incomplete: + ... + +def sleep(*args, **kwargs) -> Incomplete: + ... + + +class TaskQueue(): + def push(self, *args, **kwargs) -> Incomplete: + ... + + def peek(self, *args, **kwargs) -> Incomplete: + ... + + def remove(self, *args, **kwargs) -> Incomplete: + ... + + def pop(self, *args, **kwargs) -> Incomplete: + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + +def open_connection(*args, **kwargs) -> Generator: ## = + ... + +cur_task: Incomplete ## = None +def gather(*args, **kwargs) -> Generator: ## = + ... + + +class Task(): + def __init__(self, *argv, **kwargs) -> None: + ... + +def wait_for(*args, **kwargs) -> Generator: ## = + ... + + +class CancelledError(Exception): + ... +def start_server(*args, **kwargs) -> Generator: ## = + ... + + +class Lock(): + def locked(self, *args, **kwargs) -> Incomplete: + ... + + def release(self, *args, **kwargs) -> Incomplete: + ... + + def acquire(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class StreamWriter(): + def write(self, *args, **kwargs) -> Incomplete: + ... + + def get_extra_info(self, *args, **kwargs) -> Incomplete: + ... + + def close(self, *args, **kwargs) -> Incomplete: + ... + + def awritestr(*args, **kwargs) -> Generator: ## = + ... + + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + + def drain(*args, **kwargs) -> Generator: ## = + ... + + def readexactly(*args, **kwargs) -> Generator: ## = + ... + + def readinto(*args, **kwargs) -> Generator: ## = + ... + + def read(*args, **kwargs) -> Generator: ## = + ... + + def awrite(*args, **kwargs) -> Generator: ## = + ... + + def readline(*args, **kwargs) -> Generator: ## = + ... + + def aclose(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class StreamReader(): + def write(self, *args, **kwargs) -> Incomplete: + ... + + def get_extra_info(self, *args, **kwargs) -> Incomplete: + ... + + def close(self, *args, **kwargs) -> Incomplete: + ... + + def awritestr(*args, **kwargs) -> Generator: ## = + ... + + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + + def drain(*args, **kwargs) -> Generator: ## = + ... + + def readexactly(*args, **kwargs) -> Generator: ## = + ... + + def readinto(*args, **kwargs) -> Generator: ## = + ... + + def read(*args, **kwargs) -> Generator: ## = + ... + + def awrite(*args, **kwargs) -> Generator: ## = + ... + + def readline(*args, **kwargs) -> Generator: ## = + ... + + def aclose(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class SingletonGenerator(): + def __init__(self, *argv, **kwargs) -> None: + ... + + +class Loop(): + def get_exception_handler(self, *args, **kwargs) -> Incomplete: + ... + + def default_exception_handler(self, *args, **kwargs) -> Incomplete: + ... + + def set_exception_handler(self, *args, **kwargs) -> Incomplete: + ... + + def run_forever(self, *args, **kwargs) -> Incomplete: + ... + + def run_until_complete(self, *args, **kwargs) -> Incomplete: + ... + + def stop(self, *args, **kwargs) -> Incomplete: + ... + + def close(self, *args, **kwargs) -> Incomplete: + ... + + def create_task(self, *args, **kwargs) -> Incomplete: + ... + + def call_exception_handler(self, *args, **kwargs) -> Incomplete: + ... + + _exc_handler: Incomplete ## = None + def __init__(self, *argv, **kwargs) -> None: + ... + + +class Event(): + def set(self, *args, **kwargs) -> Incomplete: + ... + + def is_set(self, *args, **kwargs) -> Incomplete: + ... + + def clear(self, *args, **kwargs) -> Incomplete: + ... + + def wait(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class ThreadSafeFlag(): + def set(self, *args, **kwargs) -> Incomplete: + ... + + def ioctl(self, *args, **kwargs) -> Incomplete: + ... + + def clear(self, *args, **kwargs) -> Incomplete: + ... + + def wait(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class IOQueue(): + def queue_read(self, *args, **kwargs) -> Incomplete: + ... + + def wait_io_event(self, *args, **kwargs) -> Incomplete: + ... + + def queue_write(self, *args, **kwargs) -> Incomplete: + ... + + def remove(self, *args, **kwargs) -> Incomplete: + ... + + def _enqueue(self, *args, **kwargs) -> Incomplete: + ... + + def _dequeue(self, *args, **kwargs) -> Incomplete: + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class TimeoutError(Exception): + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/core.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/core.pyi new file mode 100644 index 0000000000..4ca0971479 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/core.pyi @@ -0,0 +1,73 @@ +""" +Module: 'asyncio.core' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +_exc_context: dict = {} + +def ticks(*args, **kwargs) -> Incomplete: ... +def create_task(*args, **kwargs) -> Incomplete: ... +def _promote_to_task(*args, **kwargs) -> Incomplete: ... +def ticks_diff(*args, **kwargs) -> Incomplete: ... +def run(*args, **kwargs) -> Incomplete: ... +def run_until_complete(*args, **kwargs) -> Incomplete: ... +def current_task(*args, **kwargs) -> Incomplete: ... +def new_event_loop(*args, **kwargs) -> Incomplete: ... +def get_event_loop(*args, **kwargs) -> Incomplete: ... +def sleep_ms(*args, **kwargs) -> Incomplete: ... +def ticks_add(*args, **kwargs) -> Incomplete: ... +def sleep(*args, **kwargs) -> Incomplete: ... + +cur_task: Incomplete ## = None +_task_queue: Incomplete ## = + +class Loop: + def get_exception_handler(self, *args, **kwargs) -> Incomplete: ... + def default_exception_handler(self, *args, **kwargs) -> Incomplete: ... + def set_exception_handler(self, *args, **kwargs) -> Incomplete: ... + def run_forever(self, *args, **kwargs) -> Incomplete: ... + def run_until_complete(self, *args, **kwargs) -> Incomplete: ... + def stop(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def create_task(self, *args, **kwargs) -> Incomplete: ... + def call_exception_handler(self, *args, **kwargs) -> Incomplete: ... + + _exc_handler: Incomplete ## = None + def __init__(self, *argv, **kwargs) -> None: ... + +class CancelledError(Exception): ... + +class TaskQueue: + def push(self, *args, **kwargs) -> Incomplete: ... + def peek(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def pop(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Task: + def __init__(self, *argv, **kwargs) -> None: ... + +class TimeoutError(Exception): ... + +class IOQueue: + def queue_read(self, *args, **kwargs) -> Incomplete: ... + def wait_io_event(self, *args, **kwargs) -> Incomplete: ... + def queue_write(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def _enqueue(self, *args, **kwargs) -> Incomplete: ... + def _dequeue(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class SingletonGenerator: + def __init__(self, *argv, **kwargs) -> None: ... + +def _stopper(*args, **kwargs) -> Generator: ## = + ... + +_stop_task: Incomplete ## = None +_io_queue: Incomplete ## = diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/event.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/event.pyi new file mode 100644 index 0000000000..fdb7c5923b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/event.pyi @@ -0,0 +1,25 @@ +""" +Module: 'asyncio.event' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +class ThreadSafeFlag: + def set(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def wait(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Event: + def set(self, *args, **kwargs) -> Incomplete: ... + def is_set(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def wait(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/funcs.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/funcs.pyi new file mode 100644 index 0000000000..72429ad150 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/funcs.pyi @@ -0,0 +1,22 @@ +""" +Module: 'asyncio.funcs' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def wait_for_ms(*args, **kwargs) -> Incomplete: ... +def gather(*args, **kwargs) -> Generator: ## = + ... +def wait_for(*args, **kwargs) -> Generator: ## = + ... + +class _Remove: + def remove(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +def _run(*args, **kwargs) -> Generator: ## = + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/lock.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/lock.pyi new file mode 100644 index 0000000000..0f85df079c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/lock.pyi @@ -0,0 +1,16 @@ +""" +Module: 'asyncio.lock' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +class Lock: + def locked(self, *args, **kwargs) -> Incomplete: ... + def release(self, *args, **kwargs) -> Incomplete: ... + def acquire(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/stream.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/stream.pyi new file mode 100644 index 0000000000..bc401f37ad --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/stream.pyi @@ -0,0 +1,96 @@ +""" +Module: 'asyncio.stream' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def stream_awrite(*args, **kwargs) -> Generator: ## = + ... +def open_connection(*args, **kwargs) -> Generator: ## = + ... +def start_server(*args, **kwargs) -> Generator: ## = + ... + +class StreamWriter: + def write(self, *args, **kwargs) -> Incomplete: ... + def get_extra_info(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def awritestr(*args, **kwargs) -> Generator: ## = + ... + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + def drain(*args, **kwargs) -> Generator: ## = + ... + def readexactly(*args, **kwargs) -> Generator: ## = + ... + def readinto(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def awrite(*args, **kwargs) -> Generator: ## = + ... + def readline(*args, **kwargs) -> Generator: ## = + ... + def aclose(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Server: + def close(self, *args, **kwargs) -> Incomplete: ... + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + def _serve(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Stream: + def write(self, *args, **kwargs) -> Incomplete: ... + def get_extra_info(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def awritestr(*args, **kwargs) -> Generator: ## = + ... + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + def drain(*args, **kwargs) -> Generator: ## = + ... + def readexactly(*args, **kwargs) -> Generator: ## = + ... + def readinto(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def awrite(*args, **kwargs) -> Generator: ## = + ... + def readline(*args, **kwargs) -> Generator: ## = + ... + def aclose(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class StreamReader: + def write(self, *args, **kwargs) -> Incomplete: ... + def get_extra_info(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def awritestr(*args, **kwargs) -> Generator: ## = + ... + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + def drain(*args, **kwargs) -> Generator: ## = + ... + def readexactly(*args, **kwargs) -> Generator: ## = + ... + def readinto(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def awrite(*args, **kwargs) -> Generator: ## = + ... + def readline(*args, **kwargs) -> Generator: ## = + ... + def aclose(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/binascii.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/binascii.pyi new file mode 100644 index 0000000000..0af2aea081 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/binascii.pyi @@ -0,0 +1,14 @@ +""" +Module: 'binascii' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def crc32(*args, **kwargs) -> Incomplete: ... +def hexlify(*args, **kwargs) -> Incomplete: ... +def unhexlify(*args, **kwargs) -> Incomplete: ... +def b2a_base64(*args, **kwargs) -> Incomplete: ... +def a2b_base64(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/bluetooth.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/bluetooth.pyi new file mode 100644 index 0000000000..be3d714e8c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/bluetooth.pyi @@ -0,0 +1,40 @@ +""" +Module: 'bluetooth' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +FLAG_NOTIFY: Final[int] = 16 +FLAG_READ: Final[int] = 2 +FLAG_WRITE: Final[int] = 8 +FLAG_INDICATE: Final[int] = 32 +FLAG_WRITE_NO_RESPONSE: Final[int] = 4 + +class UUID: + def __init__(self, *argv, **kwargs) -> None: ... + +class BLE: + def gatts_notify(self, *args, **kwargs) -> Incomplete: ... + def gatts_indicate(self, *args, **kwargs) -> Incomplete: ... + def gattc_write(self, *args, **kwargs) -> Incomplete: ... + def gattc_read(self, *args, **kwargs) -> Incomplete: ... + def gattc_exchange_mtu(self, *args, **kwargs) -> Incomplete: ... + def gatts_read(self, *args, **kwargs) -> Incomplete: ... + def gatts_write(self, *args, **kwargs) -> Incomplete: ... + def gatts_set_buffer(self, *args, **kwargs) -> Incomplete: ... + def gatts_register_services(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def gap_connect(self, *args, **kwargs) -> Incomplete: ... + def gap_advertise(self, *args, **kwargs) -> Incomplete: ... + def config(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + def gattc_discover_services(self, *args, **kwargs) -> Incomplete: ... + def gap_disconnect(self, *args, **kwargs) -> Incomplete: ... + def gattc_discover_descriptors(self, *args, **kwargs) -> Incomplete: ... + def gattc_discover_characteristics(self, *args, **kwargs) -> Incomplete: ... + def gap_scan(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/builtins.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/builtins.pyi new file mode 100644 index 0000000000..6ef7c834ca --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/builtins.pyi @@ -0,0 +1,305 @@ +""" +Module: 'builtins' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def any(*args, **kwargs) -> Incomplete: ... +def all(*args, **kwargs) -> Incomplete: ... +def len(*args, **kwargs) -> Incomplete: ... +def id(*args, **kwargs) -> Incomplete: ... +def sum(*args, **kwargs) -> Incomplete: ... +def issubclass(*args, **kwargs) -> Incomplete: ... +def iter(*args, **kwargs) -> Incomplete: ... +def abs(*args, **kwargs) -> Incomplete: ... +def isinstance(*args, **kwargs) -> Incomplete: ... +def setattr(*args, **kwargs) -> Incomplete: ... +def eval(*args, **kwargs) -> Incomplete: ... +def divmod(*args, **kwargs) -> Incomplete: ... +def hash(*args, **kwargs) -> Incomplete: ... +def exec(*args, **kwargs) -> Incomplete: ... +def getattr(*args, **kwargs) -> Incomplete: ... +def chr(*args, **kwargs) -> Incomplete: ... +def callable(*args, **kwargs) -> Incomplete: ... +def dir(*args, **kwargs) -> Incomplete: ... +def hasattr(*args, **kwargs) -> Incomplete: ... +def sorted(*args, **kwargs) -> Incomplete: ... +def globals(*args, **kwargs) -> Incomplete: ... +def max(*args, **kwargs) -> Incomplete: ... +def input(*args, **kwargs) -> Incomplete: ... +def hex(*args, **kwargs) -> Incomplete: ... +def help(*args, **kwargs) -> Incomplete: ... +def open(*args, **kwargs) -> Incomplete: ... +def ord(*args, **kwargs) -> Incomplete: ... +def pow(*args, **kwargs) -> Incomplete: ... +def oct(*args, **kwargs) -> Incomplete: ... +def min(*args, **kwargs) -> Incomplete: ... +def print(*args, **kwargs) -> Incomplete: ... +def repr(*args, **kwargs) -> Incomplete: ... +def locals(*args, **kwargs) -> Incomplete: ... +def compile(*args, **kwargs) -> Incomplete: ... +def bin(*args, **kwargs) -> Incomplete: ... +def execfile(*args, **kwargs) -> Incomplete: ... +def next(*args, **kwargs) -> Incomplete: ... +def delattr(*args, **kwargs) -> Incomplete: ... +def round(*args, **kwargs) -> Incomplete: ... + +NotImplemented: Incomplete ## = NotImplemented +Ellipsis: Incomplete ## = Ellipsis + +class set: + def discard(self, *args, **kwargs) -> Incomplete: ... + def isdisjoint(self, *args, **kwargs) -> Incomplete: ... + def intersection_update(self, *args, **kwargs) -> Incomplete: ... + def intersection(self, *args, **kwargs) -> Incomplete: ... + def issubset(self, *args, **kwargs) -> Incomplete: ... + def symmetric_difference_update(self, *args, **kwargs) -> Incomplete: ... + def symmetric_difference(self, *args, **kwargs) -> Incomplete: ... + def issuperset(self, *args, **kwargs) -> Incomplete: ... + def union(self, *args, **kwargs) -> Incomplete: ... + def difference_update(self, *args, **kwargs) -> Incomplete: ... + def pop(self, *args, **kwargs) -> Incomplete: ... + def copy(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def difference(self, *args, **kwargs) -> Incomplete: ... + def add(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class slice: + def __init__(self, *argv, **kwargs) -> None: ... + +class complex: + def __init__(self, *argv, **kwargs) -> None: ... + +class float: + def __init__(self, *argv, **kwargs) -> None: ... + +class filter: + def __init__(self, *argv, **kwargs) -> None: ... + +class enumerate: + def __init__(self, *argv, **kwargs) -> None: ... + +class frozenset: + def union(self, *args, **kwargs) -> Incomplete: ... + def issubset(self, *args, **kwargs) -> Incomplete: ... + def issuperset(self, *args, **kwargs) -> Incomplete: ... + def symmetric_difference(self, *args, **kwargs) -> Incomplete: ... + def isdisjoint(self, *args, **kwargs) -> Incomplete: ... + def copy(self, *args, **kwargs) -> Incomplete: ... + def difference(self, *args, **kwargs) -> Incomplete: ... + def intersection(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class reversed: + def __init__(self, *argv, **kwargs) -> None: ... + +class property: + def getter(self, *args, **kwargs) -> Incomplete: ... + def setter(self, *args, **kwargs) -> Incomplete: ... + def deleter(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class memoryview: + def hex(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class ViperTypeError(Exception): ... + +class tuple: + def index(self, *args, **kwargs) -> Incomplete: ... + def count(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class super: + def __init__(self, *argv, **kwargs) -> None: ... + +class str: + def rstrip(self, *args, **kwargs) -> Incomplete: ... + def startswith(self, *args, **kwargs) -> Incomplete: ... + def split(self, *args, **kwargs) -> Incomplete: ... + def rfind(self, *args, **kwargs) -> Incomplete: ... + def rsplit(self, *args, **kwargs) -> Incomplete: ... + def rindex(self, *args, **kwargs) -> Incomplete: ... + def replace(self, *args, **kwargs) -> Incomplete: ... + def partition(self, *args, **kwargs) -> Incomplete: ... + def strip(self, *args, **kwargs) -> Incomplete: ... + def rpartition(self, *args, **kwargs) -> Incomplete: ... + def upper(self, *args, **kwargs) -> Incomplete: ... + def encode(self, *args, **kwargs) -> Incomplete: ... + def center(self, *args, **kwargs) -> Incomplete: ... + def splitlines(self, *args, **kwargs) -> Incomplete: ... + def format(self, *args, **kwargs) -> Incomplete: ... + def isalpha(self, *args, **kwargs) -> Incomplete: ... + def index(self, *args, **kwargs) -> Incomplete: ... + def count(self, *args, **kwargs) -> Incomplete: ... + def find(self, *args, **kwargs) -> Incomplete: ... + def endswith(self, *args, **kwargs) -> Incomplete: ... + def lstrip(self, *args, **kwargs) -> Incomplete: ... + def join(self, *args, **kwargs) -> Incomplete: ... + def isdigit(self, *args, **kwargs) -> Incomplete: ... + def lower(self, *args, **kwargs) -> Incomplete: ... + def islower(self, *args, **kwargs) -> Incomplete: ... + def isupper(self, *args, **kwargs) -> Incomplete: ... + def isspace(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class type: + def __init__(self, *argv, **kwargs) -> None: ... + +class UnicodeError(Exception): ... + +class StopAsyncIteration: + def __init__(self, *argv, **kwargs) -> None: ... + +class zip: + def __init__(self, *argv, **kwargs) -> None: ... + +class IndentationError(Exception): ... +class KeyboardInterrupt(Exception): ... +class KeyError(Exception): ... +class IndexError(Exception): ... +class LookupError(Exception): ... +class NotImplementedError(Exception): ... +class NameError(Exception): ... +class MemoryError(Exception): ... +class OSError(Exception): ... +class ImportError(Exception): ... +class AttributeError(Exception): ... +class AssertionError(Exception): ... +class ArithmeticError(Exception): ... + +class GeneratorExit: + def __init__(self, *argv, **kwargs) -> None: ... + +class EOFError(Exception): ... + +class range: + def __init__(self, *argv, **kwargs) -> None: ... + +class bytearray: + def rstrip(self, *args, **kwargs) -> Incomplete: ... + def rsplit(self, *args, **kwargs) -> Incomplete: ... + def split(self, *args, **kwargs) -> Incomplete: ... + def startswith(self, *args, **kwargs) -> Incomplete: ... + def replace(self, *args, **kwargs) -> Incomplete: ... + def rindex(self, *args, **kwargs) -> Incomplete: ... + def rfind(self, *args, **kwargs) -> Incomplete: ... + def splitlines(self, *args, **kwargs) -> Incomplete: ... + def partition(self, *args, **kwargs) -> Incomplete: ... + def hex(self, *args, **kwargs) -> Incomplete: ... + def rpartition(self, *args, **kwargs) -> Incomplete: ... + def strip(self, *args, **kwargs) -> Incomplete: ... + def upper(self, *args, **kwargs) -> Incomplete: ... + def decode(self, *args, **kwargs) -> Incomplete: ... + def center(self, *args, **kwargs) -> Incomplete: ... + def find(self, *args, **kwargs) -> Incomplete: ... + def extend(self, *args, **kwargs) -> Incomplete: ... + def format(self, *args, **kwargs) -> Incomplete: ... + def index(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def endswith(self, *args, **kwargs) -> Incomplete: ... + def count(self, *args, **kwargs) -> Incomplete: ... + def lstrip(self, *args, **kwargs) -> Incomplete: ... + def isalpha(self, *args, **kwargs) -> Incomplete: ... + def isupper(self, *args, **kwargs) -> Incomplete: ... + def join(self, *args, **kwargs) -> Incomplete: ... + def lower(self, *args, **kwargs) -> Incomplete: ... + def islower(self, *args, **kwargs) -> Incomplete: ... + def isdigit(self, *args, **kwargs) -> Incomplete: ... + def isspace(self, *args, **kwargs) -> Incomplete: ... + @classmethod + def fromhex(cls, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class dict: + def popitem(self, *args, **kwargs) -> Incomplete: ... + def pop(self, *args, **kwargs) -> Incomplete: ... + def values(self, *args, **kwargs) -> Incomplete: ... + def setdefault(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def copy(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def keys(self, *args, **kwargs) -> Incomplete: ... + def get(self, *args, **kwargs) -> Incomplete: ... + def items(self, *args, **kwargs) -> Incomplete: ... + @classmethod + def fromkeys(cls, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class bytes: + def split(self, *args, **kwargs) -> Incomplete: ... + def rstrip(self, *args, **kwargs) -> Incomplete: ... + def startswith(self, *args, **kwargs) -> Incomplete: ... + def splitlines(self, *args, **kwargs) -> Incomplete: ... + def rfind(self, *args, **kwargs) -> Incomplete: ... + def rsplit(self, *args, **kwargs) -> Incomplete: ... + def rindex(self, *args, **kwargs) -> Incomplete: ... + def partition(self, *args, **kwargs) -> Incomplete: ... + def hex(self, *args, **kwargs) -> Incomplete: ... + def rpartition(self, *args, **kwargs) -> Incomplete: ... + def strip(self, *args, **kwargs) -> Incomplete: ... + def upper(self, *args, **kwargs) -> Incomplete: ... + def decode(self, *args, **kwargs) -> Incomplete: ... + def center(self, *args, **kwargs) -> Incomplete: ... + def index(self, *args, **kwargs) -> Incomplete: ... + def format(self, *args, **kwargs) -> Incomplete: ... + def isalpha(self, *args, **kwargs) -> Incomplete: ... + def replace(self, *args, **kwargs) -> Incomplete: ... + def count(self, *args, **kwargs) -> Incomplete: ... + def find(self, *args, **kwargs) -> Incomplete: ... + def endswith(self, *args, **kwargs) -> Incomplete: ... + def isdigit(self, *args, **kwargs) -> Incomplete: ... + def join(self, *args, **kwargs) -> Incomplete: ... + def lower(self, *args, **kwargs) -> Incomplete: ... + def lstrip(self, *args, **kwargs) -> Incomplete: ... + def isspace(self, *args, **kwargs) -> Incomplete: ... + def islower(self, *args, **kwargs) -> Incomplete: ... + def isupper(self, *args, **kwargs) -> Incomplete: ... + @classmethod + def fromhex(cls, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class int: + def to_bytes(self, *args, **kwargs) -> Incomplete: ... + @classmethod + def from_bytes(cls, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class object: + def __init__(self, *argv, **kwargs) -> None: ... + +class map: + def __init__(self, *argv, **kwargs) -> None: ... + +class list: + def pop(self, *args, **kwargs) -> Incomplete: ... + def insert(self, *args, **kwargs) -> Incomplete: ... + def index(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def reverse(self, *args, **kwargs) -> Incomplete: ... + def sort(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def extend(self, *args, **kwargs) -> Incomplete: ... + def copy(self, *args, **kwargs) -> Incomplete: ... + def count(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class OverflowError(Exception): ... + +class bool: + def __init__(self, *argv, **kwargs) -> None: ... + +class SyntaxError(Exception): ... +class StopIteration(Exception): ... +class RuntimeError(Exception): ... +class SystemExit(Exception): ... +class ZeroDivisionError(Exception): ... +class ValueError(Exception): ... +class TypeError(Exception): ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cmath.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cmath.pyi new file mode 100644 index 0000000000..11fc1f767a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cmath.pyi @@ -0,0 +1,21 @@ +""" +Module: 'cmath' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +e: float = 2.7182818 +pi: float = 3.1415928 + +def polar(*args, **kwargs) -> Incomplete: ... +def sqrt(*args, **kwargs) -> Incomplete: ... +def rect(*args, **kwargs) -> Incomplete: ... +def sin(*args, **kwargs) -> Incomplete: ... +def exp(*args, **kwargs) -> Incomplete: ... +def cos(*args, **kwargs) -> Incomplete: ... +def phase(*args, **kwargs) -> Incomplete: ... +def log(*args, **kwargs) -> Incomplete: ... +def log10(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/collections.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/collections.pyi new file mode 100644 index 0000000000..e8dadc9d17 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/collections.pyi @@ -0,0 +1,33 @@ +""" +Module: 'collections' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def namedtuple(*args, **kwargs) -> Incomplete: ... + +class OrderedDict: + def popitem(self, *args, **kwargs) -> Incomplete: ... + def pop(self, *args, **kwargs) -> Incomplete: ... + def values(self, *args, **kwargs) -> Incomplete: ... + def setdefault(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def copy(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def keys(self, *args, **kwargs) -> Incomplete: ... + def get(self, *args, **kwargs) -> Incomplete: ... + def items(self, *args, **kwargs) -> Incomplete: ... + @classmethod + def fromkeys(cls, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class deque: + def pop(self, *args, **kwargs) -> Incomplete: ... + def appendleft(self, *args, **kwargs) -> Incomplete: ... + def popleft(self, *args, **kwargs) -> Incomplete: ... + def extend(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cryptolib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cryptolib.pyi new file mode 100644 index 0000000000..7c71ac5343 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cryptolib.pyi @@ -0,0 +1,13 @@ +""" +Module: 'cryptolib' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +class aes: + def encrypt(self, *args, **kwargs) -> Incomplete: ... + def decrypt(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/deflate.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/deflate.pyi new file mode 100644 index 0000000000..a52fbe2efd --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/deflate.pyi @@ -0,0 +1,21 @@ +""" +Module: 'deflate' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +GZIP: Final[int] = 3 +RAW: Final[int] = 1 +ZLIB: Final[int] = 2 +AUTO: Final[int] = 0 + +class DeflateIO: + def readline(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/dht.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/dht.pyi new file mode 100644 index 0000000000..1ccfb53c50 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/dht.pyi @@ -0,0 +1,26 @@ +""" +Module: 'dht' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def dht_readinto(*args, **kwargs) -> Incomplete: ... + +class DHTBase: + def measure(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DHT22: + def measure(self, *args, **kwargs) -> Incomplete: ... + def temperature(self, *args, **kwargs) -> Incomplete: ... + def humidity(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class DHT11: + def measure(self, *args, **kwargs) -> Incomplete: ... + def temperature(self, *args, **kwargs) -> Incomplete: ... + def humidity(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ds18x20.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ds18x20.pyi new file mode 100644 index 0000000000..88ec225808 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ds18x20.pyi @@ -0,0 +1,18 @@ +""" +Module: 'ds18x20' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def const(*args, **kwargs) -> Incomplete: ... + +class DS18X20: + def read_scratch(self, *args, **kwargs) -> Incomplete: ... + def read_temp(self, *args, **kwargs) -> Incomplete: ... + def write_scratch(self, *args, **kwargs) -> Incomplete: ... + def convert_temp(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/errno.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/errno.pyi new file mode 100644 index 0000000000..849e9c61e1 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/errno.pyi @@ -0,0 +1,33 @@ +""" +Module: 'errno' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +ENOBUFS: Final[int] = 105 +ENODEV: Final[int] = 19 +ENOENT: Final[int] = 2 +EISDIR: Final[int] = 21 +EIO: Final[int] = 5 +EINVAL: Final[int] = 22 +EPERM: Final[int] = 1 +ETIMEDOUT: Final[int] = 110 +ENOMEM: Final[int] = 12 +EOPNOTSUPP: Final[int] = 95 +ENOTCONN: Final[int] = 107 +errorcode: dict = {} +EAGAIN: Final[int] = 11 +EALREADY: Final[int] = 114 +EBADF: Final[int] = 9 +EADDRINUSE: Final[int] = 98 +EACCES: Final[int] = 13 +EINPROGRESS: Final[int] = 115 +EEXIST: Final[int] = 17 +EHOSTUNREACH: Final[int] = 113 +ECONNABORTED: Final[int] = 103 +ECONNRESET: Final[int] = 104 +ECONNREFUSED: Final[int] = 111 diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/framebuf.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/framebuf.pyi new file mode 100644 index 0000000000..0f9cfc16c2 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/framebuf.pyi @@ -0,0 +1,35 @@ +""" +Module: 'framebuf' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +MONO_HMSB: Final[int] = 4 +MONO_HLSB: Final[int] = 3 +RGB565: Final[int] = 1 +MONO_VLSB: Final[int] = 0 +MVLSB: Final[int] = 0 +GS2_HMSB: Final[int] = 5 +GS8: Final[int] = 6 +GS4_HMSB: Final[int] = 2 + +def FrameBuffer1(*args, **kwargs) -> Incomplete: ... + +class FrameBuffer: + def poly(self, *args, **kwargs) -> Incomplete: ... + def vline(self, *args, **kwargs) -> Incomplete: ... + def pixel(self, *args, **kwargs) -> Incomplete: ... + def text(self, *args, **kwargs) -> Incomplete: ... + def rect(self, *args, **kwargs) -> Incomplete: ... + def scroll(self, *args, **kwargs) -> Incomplete: ... + def ellipse(self, *args, **kwargs) -> Incomplete: ... + def line(self, *args, **kwargs) -> Incomplete: ... + def blit(self, *args, **kwargs) -> Incomplete: ... + def hline(self, *args, **kwargs) -> Incomplete: ... + def fill(self, *args, **kwargs) -> Incomplete: ... + def fill_rect(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/gc.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/gc.pyi new file mode 100644 index 0000000000..4de0b84c4b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/gc.pyi @@ -0,0 +1,16 @@ +""" +Module: 'gc' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def mem_alloc(*args, **kwargs) -> Incomplete: ... +def isenabled(*args, **kwargs) -> Incomplete: ... +def mem_free(*args, **kwargs) -> Incomplete: ... +def threshold(*args, **kwargs) -> Incomplete: ... +def collect(*args, **kwargs) -> Incomplete: ... +def enable(*args, **kwargs) -> Incomplete: ... +def disable(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/hashlib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/hashlib.pyi new file mode 100644 index 0000000000..71a6f4f69a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/hashlib.pyi @@ -0,0 +1,23 @@ +""" +Module: 'hashlib' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +class sha1: + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class sha256: + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class md5: + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/heapq.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/heapq.pyi new file mode 100644 index 0000000000..02e84ff62a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/heapq.pyi @@ -0,0 +1,12 @@ +""" +Module: 'heapq' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def heappop(*args, **kwargs) -> Incomplete: ... +def heappush(*args, **kwargs) -> Incomplete: ... +def heapify(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/io.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/io.pyi new file mode 100644 index 0000000000..5b79a8ff59 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/io.pyi @@ -0,0 +1,37 @@ +""" +Module: 'io' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def open(*args, **kwargs) -> Incomplete: ... + +class IOBase: + def __init__(self, *argv, **kwargs) -> None: ... + +class StringIO: + def write(self, *args, **kwargs) -> Incomplete: ... + def flush(self, *args, **kwargs) -> Incomplete: ... + def getvalue(self, *args, **kwargs) -> Incomplete: ... + def seek(self, *args, **kwargs) -> Incomplete: ... + def tell(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class BytesIO: + def write(self, *args, **kwargs) -> Incomplete: ... + def flush(self, *args, **kwargs) -> Incomplete: ... + def getvalue(self, *args, **kwargs) -> Incomplete: ... + def seek(self, *args, **kwargs) -> Incomplete: ... + def tell(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/json.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/json.pyi new file mode 100644 index 0000000000..60ec553dc8 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/json.pyi @@ -0,0 +1,13 @@ +""" +Module: 'json' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def loads(*args, **kwargs) -> Incomplete: ... +def load(*args, **kwargs) -> Incomplete: ... +def dumps(*args, **kwargs) -> Incomplete: ... +def dump(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/lwip.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/lwip.pyi new file mode 100644 index 0000000000..b98a8fcb8a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/lwip.pyi @@ -0,0 +1,51 @@ +""" +Module: 'lwip' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +SOCK_RAW: Final[int] = 3 +SOCK_STREAM: Final[int] = 1 +SOCK_DGRAM: Final[int] = 2 +MSG_PEEK: Final[int] = 1 +SO_REUSEADDR: Final[int] = 4 +SOL_SOCKET: Final[int] = 1 +SO_BROADCAST: Final[int] = 32 +TCP_NODELAY: Final[int] = 64 +AF_INET6: Final[int] = 10 +IPPROTO_IP: Final[int] = 0 +AF_INET: Final[int] = 2 +MSG_DONTWAIT: Final[int] = 2 +IP_DROP_MEMBERSHIP: Final[int] = 1025 +IPPROTO_TCP: Final[int] = 6 +IP_ADD_MEMBERSHIP: Final[int] = 1024 + +def reset(*args, **kwargs) -> Incomplete: ... +def print_pcbs(*args, **kwargs) -> Incomplete: ... +def getaddrinfo(*args, **kwargs) -> Incomplete: ... +def callback(*args, **kwargs) -> Incomplete: ... + +class socket: + def recvfrom(self, *args, **kwargs) -> Incomplete: ... + def recv(self, *args, **kwargs) -> Incomplete: ... + def makefile(self, *args, **kwargs) -> Incomplete: ... + def listen(self, *args, **kwargs) -> Incomplete: ... + def settimeout(self, *args, **kwargs) -> Incomplete: ... + def sendall(self, *args, **kwargs) -> Incomplete: ... + def setsockopt(self, *args, **kwargs) -> Incomplete: ... + def setblocking(self, *args, **kwargs) -> Incomplete: ... + def sendto(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def connect(self, *args, **kwargs) -> Incomplete: ... + def send(self, *args, **kwargs) -> Incomplete: ... + def bind(self, *args, **kwargs) -> Incomplete: ... + def accept(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/machine.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/machine.pyi new file mode 100644 index 0000000000..c91c06a386 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/machine.pyi @@ -0,0 +1,297 @@ +""" +Module: 'machine' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +PWRON_RESET: Final[int] = 1 +WDT_RESET: Final[int] = 3 + +def dht_readinto(*args, **kwargs) -> Incomplete: ... +def disable_irq(*args, **kwargs) -> Incomplete: ... +def enable_irq(*args, **kwargs) -> Incomplete: ... +def bitstream(*args, **kwargs) -> Incomplete: ... +def deepsleep(*args, **kwargs) -> Incomplete: ... +def bootloader(*args, **kwargs) -> Incomplete: ... +def unique_id(*args, **kwargs) -> Incomplete: ... +def soft_reset(*args, **kwargs) -> Incomplete: ... +def reset_cause(*args, **kwargs) -> Incomplete: ... +def time_pulse_us(*args, **kwargs) -> Incomplete: ... +def freq(*args, **kwargs) -> Incomplete: ... +def idle(*args, **kwargs) -> Incomplete: ... +def reset(*args, **kwargs) -> Incomplete: ... +def lightsleep(*args, **kwargs) -> Incomplete: ... + +mem8: Incomplete ## = <8-bit memory> +mem32: Incomplete ## = <32-bit memory> +mem16: Incomplete ## = <16-bit memory> + +class PWM: + def duty_u16(self, *args, **kwargs) -> Incomplete: ... + def freq(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def duty_ns(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class WDT: + def feed(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class I2S: + RX: Final[int] = 0 + MONO: Final[int] = 0 + STEREO: Final[int] = 1 + TX: Final[int] = 1 + def shift(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class ADC: + CORE_TEMP: Final[int] = 4 + def read_u16(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class I2C: + def readfrom_mem_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_mem(self, *args, **kwargs) -> Incomplete: ... + def writeto_mem(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def writeto(self, *args, **kwargs) -> Incomplete: ... + def writevto(self, *args, **kwargs) -> Incomplete: ... + def start(self, *args, **kwargs) -> Incomplete: ... + def readfrom(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def stop(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class I2CTarget: + IRQ_END_READ: Final[int] = 16 + IRQ_ADDR_MATCH_WRITE: Final[int] = 2 + IRQ_END_WRITE: Final[int] = 32 + IRQ_READ_REQ: Final[int] = 4 + IRQ_ADDR_MATCH_READ: Final[int] = 1 + IRQ_WRITE_REQ: Final[int] = 8 + def deinit(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class SoftSPI: + LSB: Final[int] = 0 + MSB: Final[int] = 1 + def deinit(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def write_readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Timer: + PERIODIC: Final[int] = 1 + ONE_SHOT: Final[int] = 0 + def init(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class UART: + INV_TX: Final[int] = 1 + RTS: Final[int] = 2 + INV_RX: Final[int] = 2 + IRQ_TXIDLE: Final[int] = 32 + IRQ_BREAK: Final[int] = 512 + IRQ_RXIDLE: Final[int] = 64 + CTS: Final[int] = 1 + def irq(self, *args, **kwargs) -> Incomplete: ... + def sendbreak(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def flush(self, *args, **kwargs) -> Incomplete: ... + def txdone(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def any(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class USBDevice: + def submit_xfer(self, *args, **kwargs) -> Incomplete: ... + def config(self, *args, **kwargs) -> Incomplete: ... + def remote_wakeup(self, *args, **kwargs) -> Incomplete: ... + def stall(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + + class BUILTIN_CDC: + ep_max: int = 3 + itf_max: int = 2 + str_max: int = 5 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"\t\x02K\x00\x02\x01\x00\x80}\x08\x0b\x00\x02\x02\x02\x00\x00\t\x04\x00\x00\x01\x02\x02\x00\x04\x05$\x00 \x01\x05$\x01\x00\x01\x04$\x02\x06\x05$\x06\x00\x01\x07\x05\x81\x03\x08\x00\x01\t\x04\x01\x00\x02\n\x00\x00\x00\x07\x05\x02\x02@\x00\x00\x07\x05\x82\x02@\x00\x00" + def __init__(self, *argv, **kwargs) -> None: ... + + class BUILTIN_NONE: + ep_max: int = 0 + itf_max: int = 0 + str_max: int = 1 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"" + def __init__(self, *argv, **kwargs) -> None: ... + + class BUILTIN_DEFAULT: + ep_max: int = 3 + itf_max: int = 2 + str_max: int = 5 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"\t\x02K\x00\x02\x01\x00\x80}\x08\x0b\x00\x02\x02\x02\x00\x00\t\x04\x00\x00\x01\x02\x02\x00\x04\x05$\x00 \x01\x05$\x01\x00\x01\x04$\x02\x06\x05$\x06\x00\x01\x07\x05\x81\x03\x08\x00\x01\t\x04\x01\x00\x02\n\x00\x00\x00\x07\x05\x02\x02@\x00\x00\x07\x05\x82\x02@\x00\x00" + def __init__(self, *argv, **kwargs) -> None: ... + + def __init__(self, *argv, **kwargs) -> None: ... + +class Pin: + ALT_SPI: Final[int] = 1 + IN: Final[int] = 0 + ALT_USB: Final[int] = 9 + ALT_UART: Final[int] = 2 + IRQ_FALLING: Final[int] = 4 + OUT: Final[int] = 1 + OPEN_DRAIN: Final[int] = 2 + IRQ_RISING: Final[int] = 8 + PULL_DOWN: Final[int] = 2 + ALT_SIO: Final[int] = 5 + ALT_GPCK: Final[int] = 8 + ALT: Final[int] = 3 + PULL_UP: Final[int] = 1 + ALT_I2C: Final[int] = 3 + ALT_PWM: Final[int] = 4 + ALT_PIO1: Final[int] = 7 + ALT_PIO0: Final[int] = 6 + def low(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def toggle(self, *args, **kwargs) -> Incomplete: ... + def off(self, *args, **kwargs) -> Incomplete: ... + def on(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def value(self, *args, **kwargs) -> Incomplete: ... + def high(self, *args, **kwargs) -> Incomplete: ... + + class cpu: + GPIO20: Pin ## = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO25: Pin ## = Pin(GPIO25, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO26: Pin ## = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO27: Pin ## = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO24: Pin ## = Pin(GPIO24, mode=ALT, alt=31) + GPIO21: Pin ## = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO22: Pin ## = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO23: Pin ## = Pin(GPIO23, mode=ALT, alt=31) + GPIO28: Pin ## = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO6: Pin ## = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO7: Pin ## = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO8: Pin ## = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO5: Pin ## = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO29: Pin ## = Pin(GPIO29, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO3: Pin ## = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO4: Pin ## = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO9: Pin ## = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO2: Pin ## = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO1: Pin ## = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO10: Pin ## = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO11: Pin ## = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO0: Pin ## = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) + EXT_GPIO0: Pin ## = Pin(EXT_GPIO0, mode=IN) + EXT_GPIO1: Pin ## = Pin(EXT_GPIO1, mode=IN) + EXT_GPIO2: Pin ## = Pin(EXT_GPIO2, mode=IN) + GPIO12: Pin ## = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO17: Pin ## = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO18: Pin ## = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO19: Pin ## = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO16: Pin ## = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO13: Pin ## = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO14: Pin ## = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO15: Pin ## = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) + def __init__(self, *argv, **kwargs) -> None: ... + + class board: + GP3: Pin ## = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) + GP28: Pin ## = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) + GP4: Pin ## = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) + GP5: Pin ## = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) + GP22: Pin ## = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) + GP27: Pin ## = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) + GP26: Pin ## = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) + WL_GPIO2: Pin ## = Pin(EXT_GPIO2, mode=IN) + WL_GPIO0: Pin ## = Pin(EXT_GPIO0, mode=IN) + LED: Pin ## = Pin(EXT_GPIO0, mode=IN) + WL_GPIO1: Pin ## = Pin(EXT_GPIO1, mode=IN) + GP6: Pin ## = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) + GP7: Pin ## = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) + GP9: Pin ## = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) + GP8: Pin ## = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) + GP12: Pin ## = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) + GP11: Pin ## = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) + GP13: Pin ## = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) + GP14: Pin ## = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) + GP0: Pin ## = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) + GP10: Pin ## = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) + GP1: Pin ## = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) + GP21: Pin ## = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) + GP2: Pin ## = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) + GP19: Pin ## = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) + GP20: Pin ## = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) + GP15: Pin ## = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) + GP16: Pin ## = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) + GP18: Pin ## = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) + GP17: Pin ## = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) + def __init__(self, *argv, **kwargs) -> None: ... + + def __init__(self, *argv, **kwargs) -> None: ... + +class SoftI2C: + def readfrom_mem_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_mem(self, *args, **kwargs) -> Incomplete: ... + def writeto_mem(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def writeto(self, *args, **kwargs) -> Incomplete: ... + def writevto(self, *args, **kwargs) -> Incomplete: ... + def start(self, *args, **kwargs) -> Incomplete: ... + def readfrom(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def stop(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class RTC: + def datetime(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class SPI: + LSB: Final[int] = 0 + MSB: Final[int] = 1 + def deinit(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def write_readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Signal: + def off(self, *args, **kwargs) -> Incomplete: ... + def on(self, *args, **kwargs) -> Incomplete: ... + def value(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/math.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/math.pyi new file mode 100644 index 0000000000..fbbf548cda --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/math.pyi @@ -0,0 +1,55 @@ +""" +Module: 'math' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +inf: float = inf +nan: float = nan +pi: float = 3.1415928 +e: float = 2.7182818 +tau: float = 6.2831856 + +def ldexp(*args, **kwargs) -> Incomplete: ... +def lgamma(*args, **kwargs) -> Incomplete: ... +def trunc(*args, **kwargs) -> Incomplete: ... +def isclose(*args, **kwargs) -> Incomplete: ... +def gamma(*args, **kwargs) -> Incomplete: ... +def isnan(*args, **kwargs) -> Incomplete: ... +def isfinite(*args, **kwargs) -> Incomplete: ... +def isinf(*args, **kwargs) -> Incomplete: ... +def sqrt(*args, **kwargs) -> Incomplete: ... +def sinh(*args, **kwargs) -> Incomplete: ... +def log(*args, **kwargs) -> Incomplete: ... +def tan(*args, **kwargs) -> Incomplete: ... +def tanh(*args, **kwargs) -> Incomplete: ... +def log2(*args, **kwargs) -> Incomplete: ... +def log10(*args, **kwargs) -> Incomplete: ... +def sin(*args, **kwargs) -> Incomplete: ... +def modf(*args, **kwargs) -> Incomplete: ... +def radians(*args, **kwargs) -> Incomplete: ... +def atanh(*args, **kwargs) -> Incomplete: ... +def atan2(*args, **kwargs) -> Incomplete: ... +def atan(*args, **kwargs) -> Incomplete: ... +def ceil(*args, **kwargs) -> Incomplete: ... +def copysign(*args, **kwargs) -> Incomplete: ... +def frexp(*args, **kwargs) -> Incomplete: ... +def acos(*args, **kwargs) -> Incomplete: ... +def pow(*args, **kwargs) -> Incomplete: ... +def asinh(*args, **kwargs) -> Incomplete: ... +def acosh(*args, **kwargs) -> Incomplete: ... +def asin(*args, **kwargs) -> Incomplete: ... +def factorial(*args, **kwargs) -> Incomplete: ... +def fabs(*args, **kwargs) -> Incomplete: ... +def expm1(*args, **kwargs) -> Incomplete: ... +def floor(*args, **kwargs) -> Incomplete: ... +def fmod(*args, **kwargs) -> Incomplete: ... +def cos(*args, **kwargs) -> Incomplete: ... +def degrees(*args, **kwargs) -> Incomplete: ... +def cosh(*args, **kwargs) -> Incomplete: ... +def exp(*args, **kwargs) -> Incomplete: ... +def erf(*args, **kwargs) -> Incomplete: ... +def erfc(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/micropython.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/micropython.pyi new file mode 100644 index 0000000000..ea37618642 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/micropython.pyi @@ -0,0 +1,28 @@ +""" +Module: 'micropython' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def opt_level(*args, **kwargs) -> Incomplete: ... +def mem_info(*args, **kwargs) -> Incomplete: ... +def kbd_intr(*args, **kwargs) -> Incomplete: ... +def qstr_info(*args, **kwargs) -> Incomplete: ... +def schedule(*args, **kwargs) -> Incomplete: ... +def stack_use(*args, **kwargs) -> Incomplete: ... +def heap_unlock(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... +def heap_lock(*args, **kwargs) -> Incomplete: ... +def alloc_emergency_exception_buf(*args, **kwargs) -> Incomplete: ... + +class RingIO: + def readinto(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def any(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip.pyi new file mode 100644 index 0000000000..02543856c0 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip.pyi @@ -0,0 +1,20 @@ +""" +Module: 'mip' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +allowed_mip_url_prefixes: tuple = () + +def _ensure_path_exists(*args, **kwargs) -> Incomplete: ... +def _install_json(*args, **kwargs) -> Incomplete: ... +def _install_package(*args, **kwargs) -> Incomplete: ... +def _rewrite_url(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... +def _download_file(*args, **kwargs) -> Incomplete: ... +def install(*args, **kwargs) -> Incomplete: ... +def _check_exists(*args, **kwargs) -> Incomplete: ... +def _chunk(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip/__init__.pyi new file mode 100644 index 0000000000..5aba52ded5 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip/__init__.pyi @@ -0,0 +1,36 @@ +""" +Module: 'mip.__init__' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +allowed_mip_url_prefixes: tuple = () +def _ensure_path_exists(*args, **kwargs) -> Incomplete: + ... + +def _install_json(*args, **kwargs) -> Incomplete: + ... + +def _install_package(*args, **kwargs) -> Incomplete: + ... + +def _rewrite_url(*args, **kwargs) -> Incomplete: + ... + +def const(*args, **kwargs) -> Incomplete: + ... + +def _download_file(*args, **kwargs) -> Incomplete: + ... + +def install(*args, **kwargs) -> Incomplete: + ... + +def _check_exists(*args, **kwargs) -> Incomplete: + ... + +def _chunk(*args, **kwargs) -> Incomplete: + ... + diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/modules.json b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/modules.json new file mode 100644 index 0000000000..07e0641998 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/modules.json @@ -0,0 +1,95 @@ +{"firmware": {"mpy": "v6.3", "build": "", "ver": "1.27.0", "arch": "armv6m", "version": "1.27.0", "port": "rp2", "board": "RPI_PICO_W", "family": "micropython", "board_id": "RPI_PICO_W", "variant": "", "cpu": "RP2040"}, +"stubber": {"version": "v1.26.5"}, "stubtype": "firmware", +"modules" :[ +{"module": "_asyncio", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_asyncio.pyi"}, +{"module": "_boot_fat", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_boot_fat.pyi"}, +{"module": "_onewire", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_onewire.pyi"}, +{"module": "_rp2", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_rp2.pyi"}, +{"module": "_thread", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/_thread.pyi"}, +{"module": "aioble.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/__init__.pyi"}, +{"module": "aioble.central", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/central.pyi"}, +{"module": "aioble.client", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/client.pyi"}, +{"module": "aioble.core", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/core.pyi"}, +{"module": "aioble.device", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/device.pyi"}, +{"module": "aioble.l2cap", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/l2cap.pyi"}, +{"module": "aioble.peripheral", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/peripheral.pyi"}, +{"module": "aioble.security", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/security.pyi"}, +{"module": "aioble.server", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/aioble/server.pyi"}, +{"module": "array", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/array.pyi"}, +{"module": "asyncio.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/__init__.pyi"}, +{"module": "asyncio.core", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/core.pyi"}, +{"module": "asyncio.event", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/event.pyi"}, +{"module": "asyncio.funcs", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/funcs.pyi"}, +{"module": "asyncio.lock", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/lock.pyi"}, +{"module": "asyncio.stream", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/asyncio/stream.pyi"}, +{"module": "binascii", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/binascii.pyi"}, +{"module": "bluetooth", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/bluetooth.pyi"}, +{"module": "builtins", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/builtins.pyi"}, +{"module": "cmath", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cmath.pyi"}, +{"module": "collections", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/collections.pyi"}, +{"module": "cryptolib", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/cryptolib.pyi"}, +{"module": "deflate", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/deflate.pyi"}, +{"module": "dht", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/dht.pyi"}, +{"module": "ds18x20", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ds18x20.pyi"}, +{"module": "errno", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/errno.pyi"}, +{"module": "framebuf", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/framebuf.pyi"}, +{"module": "gc", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/gc.pyi"}, +{"module": "hashlib", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/hashlib.pyi"}, +{"module": "heapq", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/heapq.pyi"}, +{"module": "io", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/io.pyi"}, +{"module": "json", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/json.pyi"}, +{"module": "lwip", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/lwip.pyi"}, +{"module": "machine", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/machine.pyi"}, +{"module": "math", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/math.pyi"}, +{"module": "micropython", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/micropython.pyi"}, +{"module": "mip", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip.pyi"}, +{"module": "mip.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/mip/__init__.pyi"}, +{"module": "neopixel", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/neopixel.pyi"}, +{"module": "network", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/network.pyi"}, +{"module": "ntptime", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ntptime.pyi"}, +{"module": "onewire", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/onewire.pyi"}, +{"module": "os", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/os.pyi"}, +{"module": "platform", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/platform.pyi"}, +{"module": "random", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/random.pyi"}, +{"module": "requests", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests.pyi"}, +{"module": "requests.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests/__init__.pyi"}, +{"module": "rp2", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/rp2.pyi"}, +{"module": "select", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/select.pyi"}, +{"module": "socket", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/socket.pyi"}, +{"module": "ssl", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ssl.pyi"}, +{"module": "struct", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/struct.pyi"}, +{"module": "sys", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/sys.pyi"}, +{"module": "time", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/time.pyi"}, +{"module": "tls", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/tls.pyi"}, +{"module": "uarray", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uarray.pyi"}, +{"module": "uasyncio.__init__", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/__init__.pyi"}, +{"module": "uasyncio.core", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/core.pyi"}, +{"module": "uasyncio.event", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/event.pyi"}, +{"module": "uasyncio.funcs", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/funcs.pyi"}, +{"module": "uasyncio.lock", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/lock.pyi"}, +{"module": "uasyncio.stream", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/stream.pyi"}, +{"module": "ubinascii", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubinascii.pyi"}, +{"module": "ubluetooth", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubluetooth.pyi"}, +{"module": "ucollections", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucollections.pyi"}, +{"module": "ucryptolib", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucryptolib.pyi"}, +{"module": "uctypes", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uctypes.pyi"}, +{"module": "uerrno", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uerrno.pyi"}, +{"module": "uhashlib", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uhashlib.pyi"}, +{"module": "uheapq", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uheapq.pyi"}, +{"module": "uio", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uio.pyi"}, +{"module": "ujson", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ujson.pyi"}, +{"module": "umachine", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/umachine.pyi"}, +{"module": "uos", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uos.pyi"}, +{"module": "uplatform", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uplatform.pyi"}, +{"module": "urandom", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urandom.pyi"}, +{"module": "ure", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ure.pyi"}, +{"module": "urequests", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urequests.pyi"}, +{"module": "uselect", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uselect.pyi"}, +{"module": "usocket", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usocket.pyi"}, +{"module": "ustruct", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ustruct.pyi"}, +{"module": "usys", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usys.pyi"}, +{"module": "utime", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/utime.pyi"}, +{"module": "uwebsocket", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uwebsocket.pyi"}, +{"module": "vfs", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/vfs.pyi"}, +{"module": "websocket", "file": "/remote/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/websocket.pyi"} +]} \ No newline at end of file diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/neopixel.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/neopixel.pyi new file mode 100644 index 0000000000..cc6105cc1f --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/neopixel.pyi @@ -0,0 +1,16 @@ +""" +Module: 'neopixel' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def bitstream(*args, **kwargs) -> Incomplete: ... + +class NeoPixel: + ORDER: tuple = () + def write(self, *args, **kwargs) -> Incomplete: ... + def fill(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/network.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/network.pyi new file mode 100644 index 0000000000..8ae9fb343a --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/network.pyi @@ -0,0 +1,47 @@ +""" +Module: 'network' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +STA_IF: Final[int] = 0 +STAT_IDLE: Final[int] = 0 +STAT_NO_AP_FOUND: Final[int] = -2 +STAT_WRONG_PASSWORD: Final[int] = -3 +STAT_GOT_IP: Final[int] = 3 +AP_IF: Final[int] = 1 +STAT_CONNECTING: Final[int] = 1 +STAT_CONNECT_FAIL: Final[int] = -1 + +def hostname(*args, **kwargs) -> Incomplete: ... +def ipconfig(*args, **kwargs) -> Incomplete: ... +def route(*args, **kwargs) -> Incomplete: ... +def country(*args, **kwargs) -> Incomplete: ... + +class WLAN: + PM_POWERSAVE: Final[int] = 17 + SEC_OPEN: Final[int] = 0 + SEC_WPA2_WPA3: Final[int] = 20971524 + SEC_WPA3: Final[int] = 16777220 + SEC_WPA_WPA2: Final[int] = 4194310 + PM_PERFORMANCE: Final[int] = 10555714 + IF_AP: Final[int] = 1 + IF_STA: Final[int] = 0 + PM_NONE: Final[int] = 16 + def ipconfig(self, *args, **kwargs) -> Incomplete: ... + def status(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def send_ethernet(self, *args, **kwargs) -> Incomplete: ... + def isconnected(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def config(self, *args, **kwargs) -> Incomplete: ... + def ifconfig(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + def disconnect(self, *args, **kwargs) -> Incomplete: ... + def connect(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ntptime.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ntptime.pyi new file mode 100644 index 0000000000..4d97d88d53 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ntptime.pyi @@ -0,0 +1,15 @@ +""" +Module: 'ntptime' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +timeout: int = 1 +host: str = "pool.ntp.org" + +def time(*args, **kwargs) -> Incomplete: ... +def settime(*args, **kwargs) -> Incomplete: ... +def gmtime(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/onewire.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/onewire.pyi new file mode 100644 index 0000000000..1c8b44b318 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/onewire.pyi @@ -0,0 +1,28 @@ +""" +Module: 'onewire' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +class OneWireError(Exception): ... + +class OneWire: + SKIP_ROM: Final[int] = 204 + SEARCH_ROM: Final[int] = 240 + MATCH_ROM: Final[int] = 85 + def select_rom(self, *args, **kwargs) -> Incomplete: ... + def writebit(self, *args, **kwargs) -> Incomplete: ... + def writebyte(self, *args, **kwargs) -> Incomplete: ... + def _search_rom(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def crc8(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def reset(self, *args, **kwargs) -> Incomplete: ... + def readbit(self, *args, **kwargs) -> Incomplete: ... + def readbyte(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/os.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/os.pyi new file mode 100644 index 0000000000..14591f36a5 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/os.pyi @@ -0,0 +1,61 @@ +""" +Module: 'os' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +sep: str = "/" + +def rmdir(*args, **kwargs) -> Incomplete: ... +def stat(*args, **kwargs) -> Incomplete: ... +def urandom(*args, **kwargs) -> Incomplete: ... +def rename(*args, **kwargs) -> Incomplete: ... +def mount(*args, **kwargs) -> Incomplete: ... +def uname(*args, **kwargs) -> Incomplete: ... +def unlink(*args, **kwargs) -> Incomplete: ... +def statvfs(*args, **kwargs) -> Incomplete: ... +def umount(*args, **kwargs) -> Incomplete: ... +def sync(*args, **kwargs) -> Incomplete: ... +def mkdir(*args, **kwargs) -> Incomplete: ... +def dupterm(*args, **kwargs) -> Incomplete: ... +def chdir(*args, **kwargs) -> Incomplete: ... +def remove(*args, **kwargs) -> Incomplete: ... +def dupterm_notify(*args, **kwargs) -> Incomplete: ... +def listdir(*args, **kwargs) -> Incomplete: ... +def ilistdir(*args, **kwargs) -> Incomplete: ... +def getcwd(*args, **kwargs) -> Incomplete: ... + +class VfsFat: + def rename(self, *args, **kwargs) -> Incomplete: ... + def mkfs(self, *args, **kwargs) -> Incomplete: ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class VfsLfs2: + def rename(self, *args, **kwargs) -> Incomplete: ... + def mkfs(self, *args, **kwargs) -> Incomplete: ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/platform.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/platform.pyi new file mode 100644 index 0000000000..f9cd741545 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/platform.pyi @@ -0,0 +1,12 @@ +""" +Module: 'platform' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def platform(*args, **kwargs) -> Incomplete: ... +def python_compiler(*args, **kwargs) -> Incomplete: ... +def libc_ver(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/random.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/random.pyi new file mode 100644 index 0000000000..23badd3279 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/random.pyi @@ -0,0 +1,16 @@ +""" +Module: 'random' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def randrange(*args, **kwargs) -> Incomplete: ... +def random(*args, **kwargs) -> Incomplete: ... +def seed(*args, **kwargs) -> Incomplete: ... +def uniform(*args, **kwargs) -> Incomplete: ... +def choice(*args, **kwargs) -> Incomplete: ... +def randint(*args, **kwargs) -> Incomplete: ... +def getrandbits(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests.pyi new file mode 100644 index 0000000000..794e98f82c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests.pyi @@ -0,0 +1,24 @@ +""" +Module: 'requests' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def delete(*args, **kwargs) -> Incomplete: ... +def head(*args, **kwargs) -> Incomplete: ... +def patch(*args, **kwargs) -> Incomplete: ... +def post(*args, **kwargs) -> Incomplete: ... +def request(*args, **kwargs) -> Incomplete: ... +def put(*args, **kwargs) -> Incomplete: ... +def get(*args, **kwargs) -> Incomplete: ... + +class Response: + def json(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + + content: Incomplete ## = + text: Incomplete ## = + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests/__init__.pyi new file mode 100644 index 0000000000..1d48b0fa2c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/requests/__init__.pyi @@ -0,0 +1,42 @@ +""" +Module: 'requests.__init__' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def delete(*args, **kwargs) -> Incomplete: + ... + +def head(*args, **kwargs) -> Incomplete: + ... + +def patch(*args, **kwargs) -> Incomplete: + ... + +def post(*args, **kwargs) -> Incomplete: + ... + +def request(*args, **kwargs) -> Incomplete: + ... + +def put(*args, **kwargs) -> Incomplete: + ... + +def get(*args, **kwargs) -> Incomplete: + ... + + +class Response(): + def json(self, *args, **kwargs) -> Incomplete: + ... + + def close(self, *args, **kwargs) -> Incomplete: + ... + + content: Incomplete ## = + text: Incomplete ## = + def __init__(self, *argv, **kwargs) -> None: + ... + diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/rp2.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/rp2.pyi new file mode 100644 index 0000000000..35a5cc459e --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/rp2.pyi @@ -0,0 +1,88 @@ +""" +Module: 'rp2' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +_pio_funcs: dict = {} +_pio_directives: tuple = () +_pio_instructions: tuple = () + +def bootsel_button(*args, **kwargs) -> Incomplete: ... +def asm_pio(*args, **kwargs) -> Incomplete: ... +def country(*args, **kwargs) -> Incomplete: ... +def asm_pio_encode(*args, **kwargs) -> Incomplete: ... +def const(*args, **kwargs) -> Incomplete: ... + +class DMA: + def irq(self, *args, **kwargs) -> Incomplete: ... + def unpack_ctrl(self, *args, **kwargs) -> Incomplete: ... + def pack_ctrl(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def config(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class PIO: + JOIN_TX: Final[int] = 1 + JOIN_NONE: Final[int] = 0 + JOIN_RX: Final[int] = 2 + SHIFT_LEFT: Final[int] = 0 + OUT_HIGH: Final[int] = 3 + OUT_LOW: Final[int] = 2 + SHIFT_RIGHT: Final[int] = 1 + IN_LOW: Final[int] = 0 + IRQ_SM3: Final[int] = 2048 + IN_HIGH: Final[int] = 1 + IRQ_SM2: Final[int] = 1024 + IRQ_SM0: Final[int] = 256 + IRQ_SM1: Final[int] = 512 + def state_machine(self, *args, **kwargs) -> Incomplete: ... + def remove_program(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def add_program(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class StateMachine: + def irq(self, *args, **kwargs) -> Incomplete: ... + def put(self, *args, **kwargs) -> Incomplete: ... + def restart(self, *args, **kwargs) -> Incomplete: ... + def rx_fifo(self, *args, **kwargs) -> Incomplete: ... + def tx_fifo(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def exec(self, *args, **kwargs) -> Incomplete: ... + def get(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class PIOASMEmit: + def in_(self, *args, **kwargs) -> Incomplete: ... + def side(self, *args, **kwargs) -> Incomplete: ... + def out(self, *args, **kwargs) -> Incomplete: ... + def jmp(self, *args, **kwargs) -> Incomplete: ... + def start_pass(self, *args, **kwargs) -> Incomplete: ... + def wrap(self, *args, **kwargs) -> Incomplete: ... + def word(self, *args, **kwargs) -> Incomplete: ... + def wait(self, *args, **kwargs) -> Incomplete: ... + def wrap_target(self, *args, **kwargs) -> Incomplete: ... + def delay(self, *args, **kwargs) -> Incomplete: ... + def label(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def set(self, *args, **kwargs) -> Incomplete: ... + def mov(self, *args, **kwargs) -> Incomplete: ... + def push(self, *args, **kwargs) -> Incomplete: ... + def pull(self, *args, **kwargs) -> Incomplete: ... + def nop(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Flash: + def readblocks(self, *args, **kwargs) -> Incomplete: ... + def writeblocks(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class PIOASMError(Exception): ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/select.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/select.pyi new file mode 100644 index 0000000000..0fe0dd7162 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/select.pyi @@ -0,0 +1,17 @@ +""" +Module: 'select' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +POLLOUT: Final[int] = 4 +POLLIN: Final[int] = 1 +POLLHUP: Final[int] = 16 +POLLERR: Final[int] = 8 + +def select(*args, **kwargs) -> Incomplete: ... +def poll(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/socket.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/socket.pyi new file mode 100644 index 0000000000..3cec5cd63f --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/socket.pyi @@ -0,0 +1,51 @@ +""" +Module: 'socket' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +SOCK_RAW: Final[int] = 3 +SOCK_STREAM: Final[int] = 1 +SOCK_DGRAM: Final[int] = 2 +MSG_PEEK: Final[int] = 1 +SO_REUSEADDR: Final[int] = 4 +SOL_SOCKET: Final[int] = 1 +SO_BROADCAST: Final[int] = 32 +TCP_NODELAY: Final[int] = 64 +AF_INET6: Final[int] = 10 +IPPROTO_IP: Final[int] = 0 +AF_INET: Final[int] = 2 +MSG_DONTWAIT: Final[int] = 2 +IP_DROP_MEMBERSHIP: Final[int] = 1025 +IPPROTO_TCP: Final[int] = 6 +IP_ADD_MEMBERSHIP: Final[int] = 1024 + +def reset(*args, **kwargs) -> Incomplete: ... +def print_pcbs(*args, **kwargs) -> Incomplete: ... +def getaddrinfo(*args, **kwargs) -> Incomplete: ... +def callback(*args, **kwargs) -> Incomplete: ... + +class socket: + def recvfrom(self, *args, **kwargs) -> Incomplete: ... + def recv(self, *args, **kwargs) -> Incomplete: ... + def makefile(self, *args, **kwargs) -> Incomplete: ... + def listen(self, *args, **kwargs) -> Incomplete: ... + def settimeout(self, *args, **kwargs) -> Incomplete: ... + def sendall(self, *args, **kwargs) -> Incomplete: ... + def setsockopt(self, *args, **kwargs) -> Incomplete: ... + def setblocking(self, *args, **kwargs) -> Incomplete: ... + def sendto(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def connect(self, *args, **kwargs) -> Incomplete: ... + def send(self, *args, **kwargs) -> Incomplete: ... + def bind(self, *args, **kwargs) -> Incomplete: ... + def accept(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ssl.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ssl.pyi new file mode 100644 index 0000000000..f2f95cb2d8 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ssl.pyi @@ -0,0 +1,28 @@ +""" +Module: 'ssl' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +PROTOCOL_TLS_SERVER: Final[int] = 1 +PROTOCOL_DTLS_CLIENT: Final[int] = 2 +PROTOCOL_DTLS_SERVER: Final[int] = 3 +PROTOCOL_TLS_CLIENT: Final[int] = 0 +MBEDTLS_VERSION: Final[str] = "Mbed TLS 3.6.2" +CERT_NONE: Final[int] = 0 +CERT_OPTIONAL: Final[int] = 1 +CERT_REQUIRED: Final[int] = 2 + +def wrap_socket(*args, **kwargs) -> Incomplete: ... + +class SSLContext: + def load_verify_locations(self, *args, **kwargs) -> Incomplete: ... + def wrap_socket(self, *args, **kwargs) -> Incomplete: ... + def load_cert_chain(self, *args, **kwargs) -> Incomplete: ... + + verify_mode: Incomplete ## = + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/struct.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/struct.pyi new file mode 100644 index 0000000000..a393ca5ab1 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/struct.pyi @@ -0,0 +1,14 @@ +""" +Module: 'struct' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def pack_into(*args, **kwargs) -> Incomplete: ... +def unpack(*args, **kwargs) -> Incomplete: ... +def unpack_from(*args, **kwargs) -> Incomplete: ... +def pack(*args, **kwargs) -> Incomplete: ... +def calcsize(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/sys.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/sys.pyi new file mode 100644 index 0000000000..9b27e1ca9b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/sys.pyi @@ -0,0 +1,27 @@ +""" +Module: 'sys' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +platform: str = "rp2" +version_info: tuple = () +path: list = [] +version: str = "3.4.0; MicroPython v1.27.0 on 2025-12-09" +ps1: str = ">>> " +ps2: str = "... " +byteorder: str = "little" +modules: dict = {} +argv: list = [] +implementation: tuple = () +maxsize: int = 2147483647 + +def print_exception(*args, **kwargs) -> Incomplete: ... +def exit(*args, **kwargs) -> Incomplete: ... + +stderr: Incomplete ## = +stdout: Incomplete ## = +stdin: Incomplete ## = diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/time.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/time.pyi new file mode 100644 index 0000000000..c8a806868c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/time.pyi @@ -0,0 +1,22 @@ +""" +Module: 'time' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def ticks_diff(*args, **kwargs) -> Incomplete: ... +def ticks_add(*args, **kwargs) -> Incomplete: ... +def ticks_cpu(*args, **kwargs) -> Incomplete: ... +def time(*args, **kwargs) -> Incomplete: ... +def ticks_ms(*args, **kwargs) -> Incomplete: ... +def ticks_us(*args, **kwargs) -> Incomplete: ... +def time_ns(*args, **kwargs) -> Incomplete: ... +def localtime(*args, **kwargs) -> Incomplete: ... +def sleep_us(*args, **kwargs) -> Incomplete: ... +def gmtime(*args, **kwargs) -> Incomplete: ... +def sleep_ms(*args, **kwargs) -> Incomplete: ... +def mktime(*args, **kwargs) -> Incomplete: ... +def sleep(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/tls.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/tls.pyi new file mode 100644 index 0000000000..ad252fcbe9 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/tls.pyi @@ -0,0 +1,26 @@ +""" +Module: 'tls' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Final +from _typeshed import Incomplete + +PROTOCOL_TLS_SERVER: Final[int] = 1 +PROTOCOL_DTLS_CLIENT: Final[int] = 2 +PROTOCOL_DTLS_SERVER: Final[int] = 3 +PROTOCOL_TLS_CLIENT: Final[int] = 0 +MBEDTLS_VERSION: Final[str] = "Mbed TLS 3.6.2" +CERT_NONE: Final[int] = 0 +CERT_OPTIONAL: Final[int] = 1 +CERT_REQUIRED: Final[int] = 2 + +class SSLContext: + def load_verify_locations(self, *args, **kwargs) -> Incomplete: ... + def set_ciphers(self, *args, **kwargs) -> Incomplete: ... + def wrap_socket(self, *args, **kwargs) -> Incomplete: ... + def load_cert_chain(self, *args, **kwargs) -> Incomplete: ... + def get_ciphers(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uarray.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uarray.pyi new file mode 100644 index 0000000000..42d2346903 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uarray.pyi @@ -0,0 +1,14 @@ +""" +Module: 'uarray' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +class array: + def extend(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/__init__.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/__init__.pyi new file mode 100644 index 0000000000..a0ba179013 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/__init__.pyi @@ -0,0 +1,278 @@ +""" +Module: 'uasyncio.__init__' on micropython-v1.27.0-rp2-RPI_PICO_W +""" +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +_attrs: dict = {} +def current_task(*args, **kwargs) -> Incomplete: + ... + +def get_event_loop(*args, **kwargs) -> Incomplete: + ... + +def create_task(*args, **kwargs) -> Incomplete: + ... + +def ticks_diff(*args, **kwargs) -> Incomplete: + ... + +def new_event_loop(*args, **kwargs) -> Incomplete: + ... + +def ticks(*args, **kwargs) -> Incomplete: + ... + +def run_until_complete(*args, **kwargs) -> Incomplete: + ... + +def run(*args, **kwargs) -> Incomplete: + ... + +def wait_for_ms(*args, **kwargs) -> Incomplete: + ... + +def sleep_ms(*args, **kwargs) -> Incomplete: + ... + +def ticks_add(*args, **kwargs) -> Incomplete: + ... + +def sleep(*args, **kwargs) -> Incomplete: + ... + + +class TaskQueue(): + def push(self, *args, **kwargs) -> Incomplete: + ... + + def peek(self, *args, **kwargs) -> Incomplete: + ... + + def remove(self, *args, **kwargs) -> Incomplete: + ... + + def pop(self, *args, **kwargs) -> Incomplete: + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + +def open_connection(*args, **kwargs) -> Generator: ## = + ... + +cur_task: Incomplete ## = None +def gather(*args, **kwargs) -> Generator: ## = + ... + + +class Task(): + def __init__(self, *argv, **kwargs) -> None: + ... + +def wait_for(*args, **kwargs) -> Generator: ## = + ... + + +class CancelledError(Exception): + ... +def start_server(*args, **kwargs) -> Generator: ## = + ... + + +class Lock(): + def locked(self, *args, **kwargs) -> Incomplete: + ... + + def release(self, *args, **kwargs) -> Incomplete: + ... + + def acquire(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class StreamWriter(): + def write(self, *args, **kwargs) -> Incomplete: + ... + + def get_extra_info(self, *args, **kwargs) -> Incomplete: + ... + + def close(self, *args, **kwargs) -> Incomplete: + ... + + def awritestr(*args, **kwargs) -> Generator: ## = + ... + + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + + def drain(*args, **kwargs) -> Generator: ## = + ... + + def readexactly(*args, **kwargs) -> Generator: ## = + ... + + def readinto(*args, **kwargs) -> Generator: ## = + ... + + def read(*args, **kwargs) -> Generator: ## = + ... + + def awrite(*args, **kwargs) -> Generator: ## = + ... + + def readline(*args, **kwargs) -> Generator: ## = + ... + + def aclose(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class StreamReader(): + def write(self, *args, **kwargs) -> Incomplete: + ... + + def get_extra_info(self, *args, **kwargs) -> Incomplete: + ... + + def close(self, *args, **kwargs) -> Incomplete: + ... + + def awritestr(*args, **kwargs) -> Generator: ## = + ... + + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + + def drain(*args, **kwargs) -> Generator: ## = + ... + + def readexactly(*args, **kwargs) -> Generator: ## = + ... + + def readinto(*args, **kwargs) -> Generator: ## = + ... + + def read(*args, **kwargs) -> Generator: ## = + ... + + def awrite(*args, **kwargs) -> Generator: ## = + ... + + def readline(*args, **kwargs) -> Generator: ## = + ... + + def aclose(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class SingletonGenerator(): + def __init__(self, *argv, **kwargs) -> None: + ... + + +class Loop(): + def get_exception_handler(self, *args, **kwargs) -> Incomplete: + ... + + def default_exception_handler(self, *args, **kwargs) -> Incomplete: + ... + + def set_exception_handler(self, *args, **kwargs) -> Incomplete: + ... + + def run_forever(self, *args, **kwargs) -> Incomplete: + ... + + def run_until_complete(self, *args, **kwargs) -> Incomplete: + ... + + def stop(self, *args, **kwargs) -> Incomplete: + ... + + def close(self, *args, **kwargs) -> Incomplete: + ... + + def create_task(self, *args, **kwargs) -> Incomplete: + ... + + def call_exception_handler(self, *args, **kwargs) -> Incomplete: + ... + + _exc_handler: Incomplete ## = None + def __init__(self, *argv, **kwargs) -> None: + ... + + +class Event(): + def set(self, *args, **kwargs) -> Incomplete: + ... + + def is_set(self, *args, **kwargs) -> Incomplete: + ... + + def clear(self, *args, **kwargs) -> Incomplete: + ... + + def wait(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class ThreadSafeFlag(): + def set(self, *args, **kwargs) -> Incomplete: + ... + + def ioctl(self, *args, **kwargs) -> Incomplete: + ... + + def clear(self, *args, **kwargs) -> Incomplete: + ... + + def wait(*args, **kwargs) -> Generator: ## = + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class IOQueue(): + def queue_read(self, *args, **kwargs) -> Incomplete: + ... + + def wait_io_event(self, *args, **kwargs) -> Incomplete: + ... + + def queue_write(self, *args, **kwargs) -> Incomplete: + ... + + def remove(self, *args, **kwargs) -> Incomplete: + ... + + def _enqueue(self, *args, **kwargs) -> Incomplete: + ... + + def _dequeue(self, *args, **kwargs) -> Incomplete: + ... + + def __init__(self, *argv, **kwargs) -> None: + ... + + +class TimeoutError(Exception): + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/core.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/core.pyi new file mode 100644 index 0000000000..4bb0b9e8c3 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/core.pyi @@ -0,0 +1,73 @@ +""" +Module: 'uasyncio.core' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +_exc_context: dict = {} + +def ticks(*args, **kwargs) -> Incomplete: ... +def create_task(*args, **kwargs) -> Incomplete: ... +def _promote_to_task(*args, **kwargs) -> Incomplete: ... +def ticks_diff(*args, **kwargs) -> Incomplete: ... +def run(*args, **kwargs) -> Incomplete: ... +def run_until_complete(*args, **kwargs) -> Incomplete: ... +def current_task(*args, **kwargs) -> Incomplete: ... +def new_event_loop(*args, **kwargs) -> Incomplete: ... +def get_event_loop(*args, **kwargs) -> Incomplete: ... +def sleep_ms(*args, **kwargs) -> Incomplete: ... +def ticks_add(*args, **kwargs) -> Incomplete: ... +def sleep(*args, **kwargs) -> Incomplete: ... + +cur_task: Incomplete ## = None +_task_queue: Incomplete ## = + +class Loop: + def get_exception_handler(self, *args, **kwargs) -> Incomplete: ... + def default_exception_handler(self, *args, **kwargs) -> Incomplete: ... + def set_exception_handler(self, *args, **kwargs) -> Incomplete: ... + def run_forever(self, *args, **kwargs) -> Incomplete: ... + def run_until_complete(self, *args, **kwargs) -> Incomplete: ... + def stop(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def create_task(self, *args, **kwargs) -> Incomplete: ... + def call_exception_handler(self, *args, **kwargs) -> Incomplete: ... + + _exc_handler: Incomplete ## = None + def __init__(self, *argv, **kwargs) -> None: ... + +class CancelledError(Exception): ... + +class TaskQueue: + def push(self, *args, **kwargs) -> Incomplete: ... + def peek(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def pop(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Task: + def __init__(self, *argv, **kwargs) -> None: ... + +class TimeoutError(Exception): ... + +class IOQueue: + def queue_read(self, *args, **kwargs) -> Incomplete: ... + def wait_io_event(self, *args, **kwargs) -> Incomplete: ... + def queue_write(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def _enqueue(self, *args, **kwargs) -> Incomplete: ... + def _dequeue(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class SingletonGenerator: + def __init__(self, *argv, **kwargs) -> None: ... + +def _stopper(*args, **kwargs) -> Generator: ## = + ... + +_stop_task: Incomplete ## = None +_io_queue: Incomplete ## = diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/event.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/event.pyi new file mode 100644 index 0000000000..b18bcbc57f --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/event.pyi @@ -0,0 +1,25 @@ +""" +Module: 'uasyncio.event' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +class ThreadSafeFlag: + def set(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def wait(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Event: + def set(self, *args, **kwargs) -> Incomplete: ... + def is_set(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def wait(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/funcs.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/funcs.pyi new file mode 100644 index 0000000000..793440b552 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/funcs.pyi @@ -0,0 +1,22 @@ +""" +Module: 'uasyncio.funcs' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def wait_for_ms(*args, **kwargs) -> Incomplete: ... +def gather(*args, **kwargs) -> Generator: ## = + ... +def wait_for(*args, **kwargs) -> Generator: ## = + ... + +class _Remove: + def remove(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +def _run(*args, **kwargs) -> Generator: ## = + ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/lock.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/lock.pyi new file mode 100644 index 0000000000..5975ed3b12 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/lock.pyi @@ -0,0 +1,16 @@ +""" +Module: 'uasyncio.lock' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +class Lock: + def locked(self, *args, **kwargs) -> Incomplete: ... + def release(self, *args, **kwargs) -> Incomplete: ... + def acquire(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/stream.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/stream.pyi new file mode 100644 index 0000000000..86f3472cf3 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uasyncio/stream.pyi @@ -0,0 +1,96 @@ +""" +Module: 'uasyncio.stream' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Generator +from _typeshed import Incomplete + +def stream_awrite(*args, **kwargs) -> Generator: ## = + ... +def open_connection(*args, **kwargs) -> Generator: ## = + ... +def start_server(*args, **kwargs) -> Generator: ## = + ... + +class StreamWriter: + def write(self, *args, **kwargs) -> Incomplete: ... + def get_extra_info(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def awritestr(*args, **kwargs) -> Generator: ## = + ... + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + def drain(*args, **kwargs) -> Generator: ## = + ... + def readexactly(*args, **kwargs) -> Generator: ## = + ... + def readinto(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def awrite(*args, **kwargs) -> Generator: ## = + ... + def readline(*args, **kwargs) -> Generator: ## = + ... + def aclose(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Server: + def close(self, *args, **kwargs) -> Incomplete: ... + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + def _serve(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Stream: + def write(self, *args, **kwargs) -> Incomplete: ... + def get_extra_info(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def awritestr(*args, **kwargs) -> Generator: ## = + ... + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + def drain(*args, **kwargs) -> Generator: ## = + ... + def readexactly(*args, **kwargs) -> Generator: ## = + ... + def readinto(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def awrite(*args, **kwargs) -> Generator: ## = + ... + def readline(*args, **kwargs) -> Generator: ## = + ... + def aclose(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... + +class StreamReader: + def write(self, *args, **kwargs) -> Incomplete: ... + def get_extra_info(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def awritestr(*args, **kwargs) -> Generator: ## = + ... + def wait_closed(*args, **kwargs) -> Generator: ## = + ... + def drain(*args, **kwargs) -> Generator: ## = + ... + def readexactly(*args, **kwargs) -> Generator: ## = + ... + def readinto(*args, **kwargs) -> Generator: ## = + ... + def read(*args, **kwargs) -> Generator: ## = + ... + def awrite(*args, **kwargs) -> Generator: ## = + ... + def readline(*args, **kwargs) -> Generator: ## = + ... + def aclose(*args, **kwargs) -> Generator: ## = + ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubinascii.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubinascii.pyi new file mode 100644 index 0000000000..e042ff1a6c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubinascii.pyi @@ -0,0 +1,15 @@ +""" +Module: 'ubinascii' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def crc32(*args, **kwargs) -> Incomplete: ... +def hexlify(*args, **kwargs) -> Incomplete: ... +def unhexlify(*args, **kwargs) -> Incomplete: ... +def b2a_base64(*args, **kwargs) -> Incomplete: ... +def a2b_base64(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubluetooth.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubluetooth.pyi new file mode 100644 index 0000000000..0864da7917 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ubluetooth.pyi @@ -0,0 +1,40 @@ +""" +Module: 'ubluetooth' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +FLAG_NOTIFY: Final[int] = 16 +FLAG_READ: Final[int] = 2 +FLAG_WRITE: Final[int] = 8 +FLAG_INDICATE: Final[int] = 32 +FLAG_WRITE_NO_RESPONSE: Final[int] = 4 + +class UUID: + def __init__(self, *argv, **kwargs) -> None: ... + +class BLE: + def gatts_notify(self, *args, **kwargs) -> Incomplete: ... + def gatts_indicate(self, *args, **kwargs) -> Incomplete: ... + def gattc_write(self, *args, **kwargs) -> Incomplete: ... + def gattc_read(self, *args, **kwargs) -> Incomplete: ... + def gattc_exchange_mtu(self, *args, **kwargs) -> Incomplete: ... + def gatts_read(self, *args, **kwargs) -> Incomplete: ... + def gatts_write(self, *args, **kwargs) -> Incomplete: ... + def gatts_set_buffer(self, *args, **kwargs) -> Incomplete: ... + def gatts_register_services(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def gap_connect(self, *args, **kwargs) -> Incomplete: ... + def gap_advertise(self, *args, **kwargs) -> Incomplete: ... + def config(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + def gattc_discover_services(self, *args, **kwargs) -> Incomplete: ... + def gap_disconnect(self, *args, **kwargs) -> Incomplete: ... + def gattc_discover_descriptors(self, *args, **kwargs) -> Incomplete: ... + def gattc_discover_characteristics(self, *args, **kwargs) -> Incomplete: ... + def gap_scan(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucollections.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucollections.pyi new file mode 100644 index 0000000000..268bd4d8f7 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucollections.pyi @@ -0,0 +1,34 @@ +""" +Module: 'ucollections' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def namedtuple(*args, **kwargs) -> Incomplete: ... + +class OrderedDict: + def popitem(self, *args, **kwargs) -> Incomplete: ... + def pop(self, *args, **kwargs) -> Incomplete: ... + def values(self, *args, **kwargs) -> Incomplete: ... + def setdefault(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def copy(self, *args, **kwargs) -> Incomplete: ... + def clear(self, *args, **kwargs) -> Incomplete: ... + def keys(self, *args, **kwargs) -> Incomplete: ... + def get(self, *args, **kwargs) -> Incomplete: ... + def items(self, *args, **kwargs) -> Incomplete: ... + @classmethod + def fromkeys(cls, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class deque: + def pop(self, *args, **kwargs) -> Incomplete: ... + def appendleft(self, *args, **kwargs) -> Incomplete: ... + def popleft(self, *args, **kwargs) -> Incomplete: ... + def extend(self, *args, **kwargs) -> Incomplete: ... + def append(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucryptolib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucryptolib.pyi new file mode 100644 index 0000000000..8d09d61fd7 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ucryptolib.pyi @@ -0,0 +1,14 @@ +""" +Module: 'ucryptolib' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +class aes: + def encrypt(self, *args, **kwargs) -> Incomplete: ... + def decrypt(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uctypes.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uctypes.pyi new file mode 100644 index 0000000000..51c93f8231 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uctypes.pyi @@ -0,0 +1,50 @@ +""" +Module: 'uctypes' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +VOID: Final[int] = 0 +NATIVE: Final[int] = 2 +PTR: Final[int] = 536870912 +SHORT: Final[int] = 402653184 +LONGLONG: Final[int] = 939524096 +INT8: Final[int] = 134217728 +LITTLE_ENDIAN: Final[int] = 0 +LONG: Final[int] = 671088640 +UINT: Final[int] = 536870912 +ULONG: Final[int] = 536870912 +ULONGLONG: Final[int] = 805306368 +USHORT: Final[int] = 268435456 +UINT8: Final[int] = 0 +UINT16: Final[int] = 268435456 +UINT32: Final[int] = 536870912 +UINT64: Final[int] = 805306368 +INT64: Final[int] = 939524096 +BFUINT16: Final[int] = -805306368 +BFUINT32: Final[int] = -536870912 +BFUINT8: Final[int] = -1073741824 +BFINT8: Final[int] = -939524096 +ARRAY: Final[int] = -1073741824 +BFINT16: Final[int] = -671088640 +BFINT32: Final[int] = -402653184 +BF_LEN: Final[int] = 22 +INT: Final[int] = 671088640 +INT16: Final[int] = 402653184 +INT32: Final[int] = 671088640 +FLOAT64: Final[int] = -134217728 +BF_POS: Final[int] = 17 +BIG_ENDIAN: Final[int] = 1 +FLOAT32: Final[int] = -268435456 + +def sizeof(*args, **kwargs) -> Incomplete: ... +def bytes_at(*args, **kwargs) -> Incomplete: ... +def bytearray_at(*args, **kwargs) -> Incomplete: ... +def addressof(*args, **kwargs) -> Incomplete: ... + +class struct: + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uerrno.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uerrno.pyi new file mode 100644 index 0000000000..c7eed18a0c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uerrno.pyi @@ -0,0 +1,33 @@ +""" +Module: 'uerrno' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +ENOBUFS: Final[int] = 105 +ENODEV: Final[int] = 19 +ENOENT: Final[int] = 2 +EISDIR: Final[int] = 21 +EIO: Final[int] = 5 +EINVAL: Final[int] = 22 +EPERM: Final[int] = 1 +ETIMEDOUT: Final[int] = 110 +ENOMEM: Final[int] = 12 +EOPNOTSUPP: Final[int] = 95 +ENOTCONN: Final[int] = 107 +errorcode: dict = {} +EAGAIN: Final[int] = 11 +EALREADY: Final[int] = 114 +EBADF: Final[int] = 9 +EADDRINUSE: Final[int] = 98 +EACCES: Final[int] = 13 +EINPROGRESS: Final[int] = 115 +EEXIST: Final[int] = 17 +EHOSTUNREACH: Final[int] = 113 +ECONNABORTED: Final[int] = 103 +ECONNRESET: Final[int] = 104 +ECONNREFUSED: Final[int] = 111 diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uhashlib.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uhashlib.pyi new file mode 100644 index 0000000000..eb457fa0d0 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uhashlib.pyi @@ -0,0 +1,24 @@ +""" +Module: 'uhashlib' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +class sha1: + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class sha256: + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class md5: + def digest(self, *args, **kwargs) -> Incomplete: ... + def update(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uheapq.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uheapq.pyi new file mode 100644 index 0000000000..2f5f455bbd --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uheapq.pyi @@ -0,0 +1,13 @@ +""" +Module: 'uheapq' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def heappop(*args, **kwargs) -> Incomplete: ... +def heappush(*args, **kwargs) -> Incomplete: ... +def heapify(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uio.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uio.pyi new file mode 100644 index 0000000000..1279382956 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uio.pyi @@ -0,0 +1,38 @@ +""" +Module: 'uio' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def open(*args, **kwargs) -> Incomplete: ... + +class IOBase: + def __init__(self, *argv, **kwargs) -> None: ... + +class StringIO: + def write(self, *args, **kwargs) -> Incomplete: ... + def flush(self, *args, **kwargs) -> Incomplete: ... + def getvalue(self, *args, **kwargs) -> Incomplete: ... + def seek(self, *args, **kwargs) -> Incomplete: ... + def tell(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class BytesIO: + def write(self, *args, **kwargs) -> Incomplete: ... + def flush(self, *args, **kwargs) -> Incomplete: ... + def getvalue(self, *args, **kwargs) -> Incomplete: ... + def seek(self, *args, **kwargs) -> Incomplete: ... + def tell(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ujson.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ujson.pyi new file mode 100644 index 0000000000..af10e0863b --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ujson.pyi @@ -0,0 +1,14 @@ +""" +Module: 'ujson' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def loads(*args, **kwargs) -> Incomplete: ... +def load(*args, **kwargs) -> Incomplete: ... +def dumps(*args, **kwargs) -> Incomplete: ... +def dump(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/umachine.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/umachine.pyi new file mode 100644 index 0000000000..471bd5e8af --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/umachine.pyi @@ -0,0 +1,297 @@ +""" +Module: 'umachine' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +PWRON_RESET: Final[int] = 1 +WDT_RESET: Final[int] = 3 + +def dht_readinto(*args, **kwargs) -> Incomplete: ... +def disable_irq(*args, **kwargs) -> Incomplete: ... +def enable_irq(*args, **kwargs) -> Incomplete: ... +def bitstream(*args, **kwargs) -> Incomplete: ... +def deepsleep(*args, **kwargs) -> Incomplete: ... +def bootloader(*args, **kwargs) -> Incomplete: ... +def unique_id(*args, **kwargs) -> Incomplete: ... +def soft_reset(*args, **kwargs) -> Incomplete: ... +def reset_cause(*args, **kwargs) -> Incomplete: ... +def time_pulse_us(*args, **kwargs) -> Incomplete: ... +def freq(*args, **kwargs) -> Incomplete: ... +def idle(*args, **kwargs) -> Incomplete: ... +def reset(*args, **kwargs) -> Incomplete: ... +def lightsleep(*args, **kwargs) -> Incomplete: ... + +mem8: Incomplete ## = <8-bit memory> +mem32: Incomplete ## = <32-bit memory> +mem16: Incomplete ## = <16-bit memory> + +class PWM: + def duty_u16(self, *args, **kwargs) -> Incomplete: ... + def freq(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def duty_ns(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class WDT: + def feed(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class I2S: + RX: Final[int] = 0 + MONO: Final[int] = 0 + STEREO: Final[int] = 1 + TX: Final[int] = 1 + def shift(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class ADC: + CORE_TEMP: Final[int] = 4 + def read_u16(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class I2C: + def readfrom_mem_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_mem(self, *args, **kwargs) -> Incomplete: ... + def writeto_mem(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def writeto(self, *args, **kwargs) -> Incomplete: ... + def writevto(self, *args, **kwargs) -> Incomplete: ... + def start(self, *args, **kwargs) -> Incomplete: ... + def readfrom(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def stop(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class I2CTarget: + IRQ_END_READ: Final[int] = 16 + IRQ_ADDR_MATCH_WRITE: Final[int] = 2 + IRQ_END_WRITE: Final[int] = 32 + IRQ_READ_REQ: Final[int] = 4 + IRQ_ADDR_MATCH_READ: Final[int] = 1 + IRQ_WRITE_REQ: Final[int] = 8 + def deinit(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class SoftSPI: + LSB: Final[int] = 0 + MSB: Final[int] = 1 + def deinit(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def write_readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Timer: + PERIODIC: Final[int] = 1 + ONE_SHOT: Final[int] = 0 + def init(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class UART: + INV_TX: Final[int] = 1 + RTS: Final[int] = 2 + INV_RX: Final[int] = 2 + IRQ_TXIDLE: Final[int] = 32 + IRQ_BREAK: Final[int] = 512 + IRQ_RXIDLE: Final[int] = 64 + CTS: Final[int] = 1 + def irq(self, *args, **kwargs) -> Incomplete: ... + def sendbreak(self, *args, **kwargs) -> Incomplete: ... + def deinit(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def flush(self, *args, **kwargs) -> Incomplete: ... + def txdone(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def any(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class USBDevice: + def submit_xfer(self, *args, **kwargs) -> Incomplete: ... + def config(self, *args, **kwargs) -> Incomplete: ... + def remote_wakeup(self, *args, **kwargs) -> Incomplete: ... + def stall(self, *args, **kwargs) -> Incomplete: ... + def active(self, *args, **kwargs) -> Incomplete: ... + + class BUILTIN_CDC: + ep_max: int = 3 + itf_max: int = 2 + str_max: int = 5 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"\t\x02K\x00\x02\x01\x00\x80}\x08\x0b\x00\x02\x02\x02\x00\x00\t\x04\x00\x00\x01\x02\x02\x00\x04\x05$\x00 \x01\x05$\x01\x00\x01\x04$\x02\x06\x05$\x06\x00\x01\x07\x05\x81\x03\x08\x00\x01\t\x04\x01\x00\x02\n\x00\x00\x00\x07\x05\x02\x02@\x00\x00\x07\x05\x82\x02@\x00\x00" + def __init__(self, *argv, **kwargs) -> None: ... + + class BUILTIN_NONE: + ep_max: int = 0 + itf_max: int = 0 + str_max: int = 1 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"" + def __init__(self, *argv, **kwargs) -> None: ... + + class BUILTIN_DEFAULT: + ep_max: int = 3 + itf_max: int = 2 + str_max: int = 5 + desc_dev: bytes = b"\x12\x01\x00\x02\xef\x02\x01@\x8a.\x05\x00\x00\x01\x01\x02\x03\x01" + desc_cfg: bytes = b"\t\x02K\x00\x02\x01\x00\x80}\x08\x0b\x00\x02\x02\x02\x00\x00\t\x04\x00\x00\x01\x02\x02\x00\x04\x05$\x00 \x01\x05$\x01\x00\x01\x04$\x02\x06\x05$\x06\x00\x01\x07\x05\x81\x03\x08\x00\x01\t\x04\x01\x00\x02\n\x00\x00\x00\x07\x05\x02\x02@\x00\x00\x07\x05\x82\x02@\x00\x00" + def __init__(self, *argv, **kwargs) -> None: ... + + def __init__(self, *argv, **kwargs) -> None: ... + +class Pin: + ALT_SPI: Final[int] = 1 + IN: Final[int] = 0 + ALT_USB: Final[int] = 9 + ALT_UART: Final[int] = 2 + IRQ_FALLING: Final[int] = 4 + OUT: Final[int] = 1 + OPEN_DRAIN: Final[int] = 2 + IRQ_RISING: Final[int] = 8 + PULL_DOWN: Final[int] = 2 + ALT_SIO: Final[int] = 5 + ALT_GPCK: Final[int] = 8 + ALT: Final[int] = 3 + PULL_UP: Final[int] = 1 + ALT_I2C: Final[int] = 3 + ALT_PWM: Final[int] = 4 + ALT_PIO1: Final[int] = 7 + ALT_PIO0: Final[int] = 6 + def low(self, *args, **kwargs) -> Incomplete: ... + def irq(self, *args, **kwargs) -> Incomplete: ... + def toggle(self, *args, **kwargs) -> Incomplete: ... + def off(self, *args, **kwargs) -> Incomplete: ... + def on(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def value(self, *args, **kwargs) -> Incomplete: ... + def high(self, *args, **kwargs) -> Incomplete: ... + + class cpu: + GPIO20: Pin ## = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO25: Pin ## = Pin(GPIO25, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO26: Pin ## = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO27: Pin ## = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO24: Pin ## = Pin(GPIO24, mode=ALT, alt=31) + GPIO21: Pin ## = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO22: Pin ## = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO23: Pin ## = Pin(GPIO23, mode=ALT, alt=31) + GPIO28: Pin ## = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO6: Pin ## = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO7: Pin ## = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO8: Pin ## = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO5: Pin ## = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO29: Pin ## = Pin(GPIO29, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO3: Pin ## = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO4: Pin ## = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO9: Pin ## = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO2: Pin ## = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO1: Pin ## = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO10: Pin ## = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO11: Pin ## = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO0: Pin ## = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) + EXT_GPIO0: Pin ## = Pin(EXT_GPIO0, mode=IN) + EXT_GPIO1: Pin ## = Pin(EXT_GPIO1, mode=IN) + EXT_GPIO2: Pin ## = Pin(EXT_GPIO2, mode=IN) + GPIO12: Pin ## = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO17: Pin ## = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO18: Pin ## = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO19: Pin ## = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO16: Pin ## = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO13: Pin ## = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO14: Pin ## = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) + GPIO15: Pin ## = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) + def __init__(self, *argv, **kwargs) -> None: ... + + class board: + GP3: Pin ## = Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31) + GP28: Pin ## = Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31) + GP4: Pin ## = Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31) + GP5: Pin ## = Pin(GPIO5, mode=ALT, pull=PULL_DOWN, alt=31) + GP22: Pin ## = Pin(GPIO22, mode=ALT, pull=PULL_DOWN, alt=31) + GP27: Pin ## = Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31) + GP26: Pin ## = Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31) + WL_GPIO2: Pin ## = Pin(EXT_GPIO2, mode=IN) + WL_GPIO0: Pin ## = Pin(EXT_GPIO0, mode=IN) + LED: Pin ## = Pin(EXT_GPIO0, mode=IN) + WL_GPIO1: Pin ## = Pin(EXT_GPIO1, mode=IN) + GP6: Pin ## = Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31) + GP7: Pin ## = Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31) + GP9: Pin ## = Pin(GPIO9, mode=ALT, pull=PULL_DOWN, alt=31) + GP8: Pin ## = Pin(GPIO8, mode=ALT, pull=PULL_DOWN, alt=31) + GP12: Pin ## = Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31) + GP11: Pin ## = Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31) + GP13: Pin ## = Pin(GPIO13, mode=ALT, pull=PULL_DOWN, alt=31) + GP14: Pin ## = Pin(GPIO14, mode=ALT, pull=PULL_DOWN, alt=31) + GP0: Pin ## = Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31) + GP10: Pin ## = Pin(GPIO10, mode=ALT, pull=PULL_DOWN, alt=31) + GP1: Pin ## = Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31) + GP21: Pin ## = Pin(GPIO21, mode=ALT, pull=PULL_DOWN, alt=31) + GP2: Pin ## = Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31) + GP19: Pin ## = Pin(GPIO19, mode=ALT, pull=PULL_DOWN, alt=31) + GP20: Pin ## = Pin(GPIO20, mode=ALT, pull=PULL_DOWN, alt=31) + GP15: Pin ## = Pin(GPIO15, mode=ALT, pull=PULL_DOWN, alt=31) + GP16: Pin ## = Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31) + GP18: Pin ## = Pin(GPIO18, mode=ALT, pull=PULL_DOWN, alt=31) + GP17: Pin ## = Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31) + def __init__(self, *argv, **kwargs) -> None: ... + + def __init__(self, *argv, **kwargs) -> None: ... + +class SoftI2C: + def readfrom_mem_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_into(self, *args, **kwargs) -> Incomplete: ... + def readfrom_mem(self, *args, **kwargs) -> Incomplete: ... + def writeto_mem(self, *args, **kwargs) -> Incomplete: ... + def scan(self, *args, **kwargs) -> Incomplete: ... + def writeto(self, *args, **kwargs) -> Incomplete: ... + def writevto(self, *args, **kwargs) -> Incomplete: ... + def start(self, *args, **kwargs) -> Incomplete: ... + def readfrom(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def stop(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class RTC: + def datetime(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class SPI: + LSB: Final[int] = 0 + MSB: Final[int] = 1 + def deinit(self, *args, **kwargs) -> Incomplete: ... + def init(self, *args, **kwargs) -> Incomplete: ... + def write_readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class Signal: + def off(self, *args, **kwargs) -> Incomplete: ... + def on(self, *args, **kwargs) -> Incomplete: ... + def value(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uos.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uos.pyi new file mode 100644 index 0000000000..72e137a230 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uos.pyi @@ -0,0 +1,62 @@ +""" +Module: 'uos' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +sep: str = "/" + +def rmdir(*args, **kwargs) -> Incomplete: ... +def stat(*args, **kwargs) -> Incomplete: ... +def urandom(*args, **kwargs) -> Incomplete: ... +def rename(*args, **kwargs) -> Incomplete: ... +def mount(*args, **kwargs) -> Incomplete: ... +def uname(*args, **kwargs) -> Incomplete: ... +def unlink(*args, **kwargs) -> Incomplete: ... +def statvfs(*args, **kwargs) -> Incomplete: ... +def umount(*args, **kwargs) -> Incomplete: ... +def sync(*args, **kwargs) -> Incomplete: ... +def mkdir(*args, **kwargs) -> Incomplete: ... +def dupterm(*args, **kwargs) -> Incomplete: ... +def chdir(*args, **kwargs) -> Incomplete: ... +def remove(*args, **kwargs) -> Incomplete: ... +def dupterm_notify(*args, **kwargs) -> Incomplete: ... +def listdir(*args, **kwargs) -> Incomplete: ... +def ilistdir(*args, **kwargs) -> Incomplete: ... +def getcwd(*args, **kwargs) -> Incomplete: ... + +class VfsFat: + def rename(self, *args, **kwargs) -> Incomplete: ... + def mkfs(self, *args, **kwargs) -> Incomplete: ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class VfsLfs2: + def rename(self, *args, **kwargs) -> Incomplete: ... + def mkfs(self, *args, **kwargs) -> Incomplete: ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uplatform.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uplatform.pyi new file mode 100644 index 0000000000..ffcce296c8 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uplatform.pyi @@ -0,0 +1,13 @@ +""" +Module: 'uplatform' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def platform(*args, **kwargs) -> Incomplete: ... +def python_compiler(*args, **kwargs) -> Incomplete: ... +def libc_ver(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urandom.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urandom.pyi new file mode 100644 index 0000000000..738d0cdc22 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urandom.pyi @@ -0,0 +1,17 @@ +""" +Module: 'urandom' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def randrange(*args, **kwargs) -> Incomplete: ... +def random(*args, **kwargs) -> Incomplete: ... +def seed(*args, **kwargs) -> Incomplete: ... +def uniform(*args, **kwargs) -> Incomplete: ... +def choice(*args, **kwargs) -> Incomplete: ... +def randint(*args, **kwargs) -> Incomplete: ... +def getrandbits(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ure.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ure.pyi new file mode 100644 index 0000000000..a3b1662dc7 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ure.pyi @@ -0,0 +1,14 @@ +""" +Module: 'ure' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def sub(*args, **kwargs) -> Incomplete: ... +def search(*args, **kwargs) -> Incomplete: ... +def match(*args, **kwargs) -> Incomplete: ... +def compile(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urequests.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urequests.pyi new file mode 100644 index 0000000000..ec902ea4e8 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/urequests.pyi @@ -0,0 +1,25 @@ +""" +Module: 'urequests' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def delete(*args, **kwargs) -> Incomplete: ... +def head(*args, **kwargs) -> Incomplete: ... +def patch(*args, **kwargs) -> Incomplete: ... +def post(*args, **kwargs) -> Incomplete: ... +def request(*args, **kwargs) -> Incomplete: ... +def put(*args, **kwargs) -> Incomplete: ... +def get(*args, **kwargs) -> Incomplete: ... + +class Response: + def json(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + + content: Incomplete ## = + text: Incomplete ## = + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uselect.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uselect.pyi new file mode 100644 index 0000000000..e7d601ee87 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uselect.pyi @@ -0,0 +1,17 @@ +""" +Module: 'uselect' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +POLLOUT: Final[int] = 4 +POLLIN: Final[int] = 1 +POLLHUP: Final[int] = 16 +POLLERR: Final[int] = 8 + +def select(*args, **kwargs) -> Incomplete: ... +def poll(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usocket.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usocket.pyi new file mode 100644 index 0000000000..3f108ebeaf --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usocket.pyi @@ -0,0 +1,51 @@ +""" +Module: 'usocket' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +SOCK_RAW: Final[int] = 3 +SOCK_STREAM: Final[int] = 1 +SOCK_DGRAM: Final[int] = 2 +MSG_PEEK: Final[int] = 1 +SO_REUSEADDR: Final[int] = 4 +SOL_SOCKET: Final[int] = 1 +SO_BROADCAST: Final[int] = 32 +TCP_NODELAY: Final[int] = 64 +AF_INET6: Final[int] = 10 +IPPROTO_IP: Final[int] = 0 +AF_INET: Final[int] = 2 +MSG_DONTWAIT: Final[int] = 2 +IP_DROP_MEMBERSHIP: Final[int] = 1025 +IPPROTO_TCP: Final[int] = 6 +IP_ADD_MEMBERSHIP: Final[int] = 1024 + +def reset(*args, **kwargs) -> Incomplete: ... +def print_pcbs(*args, **kwargs) -> Incomplete: ... +def getaddrinfo(*args, **kwargs) -> Incomplete: ... +def callback(*args, **kwargs) -> Incomplete: ... + +class socket: + def recvfrom(self, *args, **kwargs) -> Incomplete: ... + def recv(self, *args, **kwargs) -> Incomplete: ... + def makefile(self, *args, **kwargs) -> Incomplete: ... + def listen(self, *args, **kwargs) -> Incomplete: ... + def settimeout(self, *args, **kwargs) -> Incomplete: ... + def sendall(self, *args, **kwargs) -> Incomplete: ... + def setsockopt(self, *args, **kwargs) -> Incomplete: ... + def setblocking(self, *args, **kwargs) -> Incomplete: ... + def sendto(self, *args, **kwargs) -> Incomplete: ... + def readline(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def connect(self, *args, **kwargs) -> Incomplete: ... + def send(self, *args, **kwargs) -> Incomplete: ... + def bind(self, *args, **kwargs) -> Incomplete: ... + def accept(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ustruct.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ustruct.pyi new file mode 100644 index 0000000000..0b69abf915 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/ustruct.pyi @@ -0,0 +1,15 @@ +""" +Module: 'ustruct' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def pack_into(*args, **kwargs) -> Incomplete: ... +def unpack(*args, **kwargs) -> Incomplete: ... +def unpack_from(*args, **kwargs) -> Incomplete: ... +def pack(*args, **kwargs) -> Incomplete: ... +def calcsize(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usys.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usys.pyi new file mode 100644 index 0000000000..8b493ec0f8 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/usys.pyi @@ -0,0 +1,28 @@ +""" +Module: 'usys' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +platform: str = "rp2" +version_info: tuple = () +path: list = [] +version: str = "3.4.0; MicroPython v1.27.0 on 2025-12-09" +ps1: str = ">>> " +ps2: str = "... " +byteorder: str = "little" +modules: dict = {} +argv: list = [] +implementation: tuple = () +maxsize: int = 2147483647 + +def print_exception(*args, **kwargs) -> Incomplete: ... +def exit(*args, **kwargs) -> Incomplete: ... + +stderr: Incomplete ## = +stdout: Incomplete ## = +stdin: Incomplete ## = diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/utime.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/utime.pyi new file mode 100644 index 0000000000..0fc2a44d4c --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/utime.pyi @@ -0,0 +1,23 @@ +""" +Module: 'utime' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +def ticks_diff(*args, **kwargs) -> Incomplete: ... +def ticks_add(*args, **kwargs) -> Incomplete: ... +def ticks_cpu(*args, **kwargs) -> Incomplete: ... +def time(*args, **kwargs) -> Incomplete: ... +def ticks_ms(*args, **kwargs) -> Incomplete: ... +def ticks_us(*args, **kwargs) -> Incomplete: ... +def time_ns(*args, **kwargs) -> Incomplete: ... +def localtime(*args, **kwargs) -> Incomplete: ... +def sleep_us(*args, **kwargs) -> Incomplete: ... +def gmtime(*args, **kwargs) -> Incomplete: ... +def sleep_ms(*args, **kwargs) -> Incomplete: ... +def mktime(*args, **kwargs) -> Incomplete: ... +def sleep(*args, **kwargs) -> Incomplete: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uwebsocket.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uwebsocket.pyi new file mode 100644 index 0000000000..f1db8f0d81 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/uwebsocket.pyi @@ -0,0 +1,18 @@ +""" +Module: 'uwebsocket' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from typing import Any, Final, Generator +from _typeshed import Incomplete + +class websocket: + def readline(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/vfs.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/vfs.pyi new file mode 100644 index 0000000000..3af0fc7602 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/vfs.pyi @@ -0,0 +1,43 @@ +""" +Module: 'vfs' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +def umount(*args, **kwargs) -> Incomplete: ... +def mount(*args, **kwargs) -> Incomplete: ... + +class VfsLfs2: + def rename(self, *args, **kwargs) -> Incomplete: ... + def mkfs(self, *args, **kwargs) -> Incomplete: ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... + +class VfsFat: + def rename(self, *args, **kwargs) -> Incomplete: ... + def mkfs(self, *args, **kwargs) -> Incomplete: ... + def mount(self, *args, **kwargs) -> Incomplete: ... + def statvfs(self, *args, **kwargs) -> Incomplete: ... + def rmdir(self, *args, **kwargs) -> Incomplete: ... + def stat(self, *args, **kwargs) -> Incomplete: ... + def umount(self, *args, **kwargs) -> Incomplete: ... + def remove(self, *args, **kwargs) -> Incomplete: ... + def mkdir(self, *args, **kwargs) -> Incomplete: ... + def open(self, *args, **kwargs) -> Incomplete: ... + def ilistdir(self, *args, **kwargs) -> Incomplete: ... + def chdir(self, *args, **kwargs) -> Incomplete: ... + def getcwd(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... diff --git a/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/websocket.pyi b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/websocket.pyi new file mode 100644 index 0000000000..393cea0558 --- /dev/null +++ b/stubs/micropython-v1_27_0-rp2-RPI_PICO_W/websocket.pyi @@ -0,0 +1,17 @@ +""" +Module: 'websocket' on micropython-v1.27.0-rp2-RPI_PICO_W +""" + +# MCU: {'mpy': 'v6.3', 'build': '', 'ver': '1.27.0', 'arch': 'armv6m', 'version': '1.27.0', 'port': 'rp2', 'board': 'RPI_PICO_W', 'family': 'micropython', 'board_id': 'RPI_PICO_W', 'variant': '', 'cpu': 'RP2040'} +# Stubber: v1.26.5 +from __future__ import annotations +from _typeshed import Incomplete + +class websocket: + def readline(self, *args, **kwargs) -> Incomplete: ... + def ioctl(self, *args, **kwargs) -> Incomplete: ... + def write(self, *args, **kwargs) -> Incomplete: ... + def close(self, *args, **kwargs) -> Incomplete: ... + def readinto(self, *args, **kwargs) -> Incomplete: ... + def read(self, *args, **kwargs) -> Incomplete: ... + def __init__(self, *argv, **kwargs) -> None: ... From b8a3d00c7f3765a5cc94c3edebaaffcd66f94dfb Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Wed, 25 Feb 2026 08:35:35 +0100 Subject: [PATCH 6/8] Refactor snippet score comparison workflow to unify script usage and enhance multi-version support Signed-off-by: Jos Verlinde --- .github/workflows/SNIPPET_SCORE_STRUCTURE.md | 4 +- .github/workflows/compare_score.py | 324 +++++++++++++------ .github/workflows/compare_score_v2.py | 268 --------------- .github/workflows/test_stub_quality.yml | 6 +- pyproject.toml | 32 +- 5 files changed, 270 insertions(+), 364 deletions(-) delete mode 100644 .github/workflows/compare_score_v2.py diff --git a/.github/workflows/SNIPPET_SCORE_STRUCTURE.md b/.github/workflows/SNIPPET_SCORE_STRUCTURE.md index 1e15738ad4..e9df710c53 100644 --- a/.github/workflows/SNIPPET_SCORE_STRUCTURE.md +++ b/.github/workflows/SNIPPET_SCORE_STRUCTURE.md @@ -127,7 +127,7 @@ VERSION_TYPE: recent_majors ### Comparison Logic -The `compare_score_v2.py` script: +The `compare_score.py` script: 1. Loads baseline from `$SNIPPET_SCORE` environment variable 2. Loads new results from `results/snippet_score.json` @@ -178,7 +178,7 @@ export TEST_VERSION=v1.27.0 export SNIPPET_SCORE='{"stable": {"v1.27.0": {"pass_rate": 0.95, ...}}, ...}' # Run comparison -python .github/workflows/compare_score_v2.py +python .github/workflows/compare_score.py ``` ## Migration from Old Format diff --git a/.github/workflows/compare_score.py b/.github/workflows/compare_score.py index 108014320e..f2c3faeec8 100644 --- a/.github/workflows/compare_score.py +++ b/.github/workflows/compare_score.py @@ -1,128 +1,272 @@ +#!/usr/bin/env python3 +"""Enhanced snippet score comparison with multi-version support and history tracking. + +Structure of SNIPPET_SCORE: +{ + "stable": { + "v1.27.0": { + "pass_rate": 0.95, + "executed": 100, + "passed": 95, + "failed": 5, + "timestamp": "2026-02-24T12:34:56Z", + "commit": "abc123" + } + }, + "preview": { + "pass_rate": 0.92, + "executed": 100, + "passed": 92, + "failed": 8, + "timestamp": "2026-02-24T12:34:56Z", + "version": "v1.28.0-preview" + }, + "recent_majors": { + "pass_rate": 0.93, + "executed": 300, + "passed": 279, + "failed": 21, + "timestamp": "2026-02-24T12:34:56Z", + "versions": ["v1.27.0", "v1.26.1", "v1.25.0"] + }, + "history": { + "v1.27.0": [ + {"pass_rate": 0.95, "executed": 100, "timestamp": "...", "commit": "..."}, + ... # up to last 10 records + ], + "preview": [...], + "recent_majors": [...] + } +} +""" + import json import os +import sys +from datetime import datetime, timezone +from typing import Optional import requests from dotenv import load_dotenv try: - - load_dotenv() # load variables - load_dotenv(".secrets") # load variables from the ".secrets" file + load_dotenv() + load_dotenv(".secrets") except: pass -# Thresholds for pass_rate comparison -PASS_RATE_TOLERANCE = 0.05 # allow up to 5% drop in pass_rate before failing -# 50%: enough to detect mass-skip scenarios (e.g. all stubs unavailable) while allowing -# natural variation as the stable version set changes over time -MIN_EXECUTED_FRACTION = 0.50 # require at least 50% of baseline executed count +# Thresholds +PASS_RATE_TOLERANCE = 0.05 # 5% drop tolerance +MIN_EXECUTED_FRACTION = 0.50 # require 50% of baseline executed +MAX_HISTORY_RECORDS = 10 # keep last 10 records per version -# has been propagated from repo vars to env vars -try: - current_scores = json.loads(os.getenv("SNIPPET_SCORE", '{"snippet_score": 0}')) -except json.decoder.JSONDecodeError: - current_scores = {"snippet_score": 0} -# set by pytest in custom conftest reporting -new_scores = {} -with open("results/snippet_score.json", "r") as f: - new_scores = json.load(f) +def get_version_type() -> str: + """Get version type from environment variable.""" + return os.getenv("VERSION_TYPE", "stable") # stable, preview, or recent_majors + +def get_current_version() -> Optional[str]: + """Get the specific version being tested (for stable).""" + return os.getenv("TEST_VERSION", None) -# Compare the scores and update the repository variable if necessary -def add_summary(msg, current_scores: dict, new_scores: dict): - if os.getenv("GITHUB_STEP_SUMMARY") is None: - print(f"The environment variable GITHUB_STEP_SUMMARY does not exist.") + +def load_baseline_scores() -> dict: + """Load baseline scores from environment variable.""" + try: + scores = json.loads(os.getenv("SNIPPET_SCORE", "{}")) + if not scores or "stable" not in scores: + # Migrate old format + return { + "stable": {}, + "preview": {}, + "recent_majors": {}, + "history": {}, + } + return scores + except json.decoder.JSONDecodeError: + return { + "stable": {}, + "preview": {}, + "recent_majors": {}, + "history": {}, + } + + +def load_new_scores() -> dict: + """Load new test results.""" + with open("results/snippet_score.json", "r") as f: + return json.load(f) + + +def add_summary(msg: str, version_type: str, new_scores: dict, baseline: dict): + """Add summary to GitHub Actions step summary.""" + summary_file = os.getenv("GITHUB_STEP_SUMMARY") + if not summary_file: + print("GITHUB_STEP_SUMMARY not available") return - with open(os.getenv("GITHUB_STEP_SUMMARY", 0), "a") as f: - f.write("# Snippets\n") - f.write(msg) - f.write("\n```json\n") - json.dump({"current": new_scores}, f) - f.write("\n") - json.dump({"previous": current_scores}, f) - f.write("\n```\n") + with open(summary_file, "a") as f: + f.write(f"# Snippet Test Results ({version_type})\n\n") + f.write(f"{msg}\n\n") + f.write("## New Results\n```json\n") + json.dump(new_scores, f, indent=2) + f.write("\n```\n\n") + f.write("## Baseline\n```json\n") + json.dump(baseline, f, indent=2) + f.write("\n```\n") def update_var(var_name: str, value: str): + """Update GitHub repository variable.""" repo = os.getenv("GITHUB_REPOSITORY", "Josverl/micropython-stubs") gh_token_vars = os.getenv("GH_TOKEN_VARS", os.getenv("GH_TOKEN", "-")) + if gh_token_vars == "-": - print("No token available to update the repository variable") - return - # update the repository variable + print("No token available to update repository variable") + return False + url = f"https://api.github.com/repos/{repo}/actions/variables/{var_name}" headers = { "Authorization": f"token {gh_token_vars}", "Content-Type": "application/json", "User-Agent": "josverl", } - data = {"name": str(var_name), "value": str(value)} - response = requests.patch(url, headers=headers, json=data) - response.raise_for_status() - - -# Compute new metrics - use pass_rate/executed when available, fall back to snippet_score -new_executed = new_scores.get("executed", new_scores.get("passed", 0) + new_scores.get("failed", 0)) -current_executed = current_scores.get("executed", 0) -new_pass_rate = new_scores.get("pass_rate", None) -current_pass_rate = current_scores.get("pass_rate", None) - -# Check minimum executed threshold (50% of baseline) - only when baseline has data -if current_executed > 0 and new_executed < current_executed * MIN_EXECUTED_FRACTION: - msg = ( - f"Too few tests executed: {new_executed} is less than " - f"{MIN_EXECUTED_FRACTION:.0%} of baseline ({current_executed}). " - f"Possible mass-skip or environment issue." - ) - print(msg) - add_summary(msg, current_scores, new_scores) - exit(1) - -# Compare using pass_rate when both baseline and current have it -if new_pass_rate is not None and current_pass_rate is not None: - rate_delta = new_pass_rate - current_pass_rate - if new_pass_rate < current_pass_rate - PASS_RATE_TOLERANCE: + data = {"name": var_name, "value": value} + + try: + response = requests.patch(url, headers=headers, json=data) + response.raise_for_status() + return True + except Exception as e: + print(f"Failed to update variable: {e}") + return False + + +def add_to_history(all_scores: dict, version_type: str, version_key: str, new_scores: dict): + """Add current results to history, keeping last MAX_HISTORY_RECORDS.""" + if "history" not in all_scores: + all_scores["history"] = {} + + if version_key not in all_scores["history"]: + all_scores["history"][version_key] = [] + + history_entry = { + "pass_rate": new_scores.get("pass_rate", 0), + "executed": new_scores.get("executed", 0), + "passed": new_scores.get("passed", 0), + "failed": new_scores.get("failed", 0), + "timestamp": datetime.now(timezone.utc).isoformat(), + "commit": os.getenv("GITHUB_SHA", "unknown")[:7], + } + + all_scores["history"][version_key].append(history_entry) + # Keep only last MAX_HISTORY_RECORDS + all_scores["history"][version_key] = all_scores["history"][version_key][-MAX_HISTORY_RECORDS:] + + +def compare_and_update(version_type: str, fail_on_drop: bool = False) -> int: + """ + Compare new scores with baseline and update if appropriate. + + Args: + version_type: "stable", "preview", or "recent_majors" + fail_on_drop: If True, exit with error code 1 on quality drop + + Returns: + 0 for success, 1 for failure + """ + all_scores = load_baseline_scores() + new_scores = load_new_scores() + + # Add metadata + new_scores["timestamp"] = datetime.now(timezone.utc).isoformat() + new_scores["commit"] = os.getenv("GITHUB_SHA", "unknown")[:7] + + # Determine the key to store under + if version_type == "stable": + version = get_current_version() + if not version: + print("ERROR: TEST_VERSION not set for stable tests") + return 1 + storage_key = version + baseline = all_scores["stable"].get(version, {}) + elif version_type == "preview": + storage_key = "preview" + new_scores["version"] = get_current_version() or "unknown" + baseline = all_scores.get("preview", {}) + elif version_type == "recent_majors": + storage_key = "recent_majors" + # Extract tested versions from new_scores if available + baseline = all_scores.get("recent_majors", {}) + else: + print(f"ERROR: Unknown version_type: {version_type}") + return 1 + + # Extract metrics + new_executed = new_scores.get("executed", 0) + baseline_executed = baseline.get("executed", 0) + new_pass_rate = new_scores.get("pass_rate", 0) + baseline_pass_rate = baseline.get("pass_rate", 0) + + # Check minimum executed threshold + if baseline_executed > 0 and new_executed < baseline_executed * MIN_EXECUTED_FRACTION: msg = ( - f"pass_rate dropped by more than {PASS_RATE_TOLERANCE:.0%}: " - f"{current_pass_rate:.2%} -> {new_pass_rate:.2%} " - f"(executed: {new_executed})" + f"⚠️ Too few tests executed: {new_executed} < " + f"{MIN_EXECUTED_FRACTION:.0%} of baseline ({baseline_executed}). " + f"Possible mass-skip or environment issue." ) print(msg) - add_summary(msg, current_scores, new_scores) - exit(1) - elif rate_delta >= 0: - msg = f"pass_rate improved or unchanged: {current_pass_rate:.2%} -> {new_pass_rate:.2%} (executed: {new_executed})" + add_summary(msg, version_type, new_scores, baseline) + return 1 if fail_on_drop else 0 + + # Compare pass rates + rate_delta = new_pass_rate - baseline_pass_rate + + if baseline_pass_rate > 0 and new_pass_rate < baseline_pass_rate - PASS_RATE_TOLERANCE: + msg = ( + f"❌ pass_rate dropped by more than {PASS_RATE_TOLERANCE:.0%}: " + f"{baseline_pass_rate:.2%} → {new_pass_rate:.2%} " + f"(Δ {rate_delta:.2%}, executed: {new_executed})" + ) + print(msg) + add_summary(msg, version_type, new_scores, baseline) + return 1 if fail_on_drop else 0 + elif rate_delta >= 0 or baseline_pass_rate == 0: + if baseline_pass_rate == 0: + msg = f"✨ New baseline established: {new_pass_rate:.2%} (executed: {new_executed})" + else: + msg = f"✅ pass_rate: {baseline_pass_rate:.2%} → {new_pass_rate:.2%} (Δ {rate_delta:+.2%}, executed: {new_executed})" print(msg) - add_summary(msg, current_scores, new_scores) + add_summary(msg, version_type, new_scores, baseline) + + # Update scores - stable is nested by version, preview/recent_majors are not + if version_type == "stable": + all_scores["stable"][storage_key] = new_scores + else: + all_scores[version_type] = new_scores + add_to_history(all_scores, version_type, storage_key, new_scores) + + # Only update on main branch if os.getenv("GITHUB_REF_NAME", "main") == "main": - update_var(var_name="SNIPPET_SCORE", value=json.dumps(new_scores, skipkeys=True, indent=4)) + update_var("SNIPPET_SCORE", json.dumps(all_scores, indent=2)) + + return 0 else: msg = ( - f"pass_rate decreased within tolerance: " - f"{current_pass_rate:.2%} -> {new_pass_rate:.2%} " - f"(delta: {rate_delta:.2%}, executed: {new_executed})" + f"⚠️ pass_rate decreased within tolerance: " + f"{baseline_pass_rate:.2%} → {new_pass_rate:.2%} " + f"(Δ {rate_delta:.2%}, executed: {new_executed})" ) print(msg) - add_summary(msg, current_scores, new_scores) -else: - # Fall back to legacy snippet_score comparison - if new_scores["snippet_score"] < current_scores["snippet_score"]: - msg = f"The snippet_score has decreased from {current_scores['snippet_score']} to {new_scores['snippet_score']}" - print(msg) - add_summary(msg, current_scores, new_scores) - exit(1) - elif new_scores["snippet_score"] == current_scores["snippet_score"]: - msg = f"The snippet_score has not changed from {current_scores['snippet_score']}" - print(msg) - add_summary(msg, current_scores, new_scores) - elif new_scores["snippet_score"] > current_scores["snippet_score"]: - msg = f"The snippet_score has improved to {new_scores['snippet_score']}" - print(msg) - add_summary(msg, current_scores, new_scores) - if os.getenv("GITHUB_REF_NAME", "main") == "main": - update_var(var_name="SNIPPET_SCORE", value=json.dumps(new_scores, skipkeys=True, indent=4)) + add_summary(msg, version_type, new_scores, baseline) + return 0 + + +if __name__ == "__main__": + version_type = get_version_type() + fail_on_drop = version_type == "stable" # Only fail on stable drops -print("Done") -exit(0) + print(f"Comparing {version_type} scores (fail_on_drop={fail_on_drop})") + exit_code = compare_and_update(version_type, fail_on_drop) + sys.exit(exit_code) diff --git a/.github/workflows/compare_score_v2.py b/.github/workflows/compare_score_v2.py deleted file mode 100644 index 93f9167662..0000000000 --- a/.github/workflows/compare_score_v2.py +++ /dev/null @@ -1,268 +0,0 @@ -#!/usr/bin/env python3 -"""Enhanced snippet score comparison with multi-version support and history tracking. - -Structure of SNIPPET_SCORE: -{ - "stable": { - "v1.27.0": { - "pass_rate": 0.95, - "executed": 100, - "passed": 95, - "failed": 5, - "timestamp": "2026-02-24T12:34:56Z", - "commit": "abc123" - } - }, - "preview": { - "pass_rate": 0.92, - "executed": 100, - "passed": 92, - "failed": 8, - "timestamp": "2026-02-24T12:34:56Z", - "version": "v1.28.0-preview" - }, - "recent_majors": { - "pass_rate": 0.93, - "executed": 300, - "passed": 279, - "failed": 21, - "timestamp": "2026-02-24T12:34:56Z", - "versions": ["v1.27.0", "v1.26.1", "v1.25.0"] - }, - "history": { - "v1.27.0": [ - {"pass_rate": 0.95, "executed": 100, "timestamp": "...", "commit": "..."}, - ... # up to last 10 records - ], - "preview": [...], - "recent_majors": [...] - } -} -""" -import json -import os -import sys -from datetime import datetime, timezone -from typing import Optional - -import requests -from dotenv import load_dotenv - -try: - load_dotenv() - load_dotenv(".secrets") -except: - pass - -# Thresholds -PASS_RATE_TOLERANCE = 0.05 # 5% drop tolerance -MIN_EXECUTED_FRACTION = 0.50 # require 50% of baseline executed -MAX_HISTORY_RECORDS = 10 # keep last 10 records per version - - -def get_version_type() -> str: - """Get version type from environment variable.""" - return os.getenv("VERSION_TYPE", "stable") # stable, preview, or recent_majors - - -def get_current_version() -> Optional[str]: - """Get the specific version being tested (for stable).""" - return os.getenv("TEST_VERSION", None) - - -def load_baseline_scores() -> dict: - """Load baseline scores from environment variable.""" - try: - scores = json.loads(os.getenv("SNIPPET_SCORE", "{}")) - if not scores or "stable" not in scores: - # Migrate old format - return { - "stable": {}, - "preview": {}, - "recent_majors": {}, - "history": {} - } - return scores - except json.decoder.JSONDecodeError: - return { - "stable": {}, - "preview": {}, - "recent_majors": {}, - "history": {} - } - - -def load_new_scores() -> dict: - """Load new test results.""" - with open("results/snippet_score.json", "r") as f: - return json.load(f) - - -def add_summary(msg: str, version_type: str, new_scores: dict, baseline: dict): - """Add summary to GitHub Actions step summary.""" - summary_file = os.getenv("GITHUB_STEP_SUMMARY") - if not summary_file: - print("GITHUB_STEP_SUMMARY not available") - return - - with open(summary_file, "a") as f: - f.write(f"# Snippet Test Results ({version_type})\n\n") - f.write(f"{msg}\n\n") - f.write("## New Results\n```json\n") - json.dump(new_scores, f, indent=2) - f.write("\n```\n\n") - f.write("## Baseline\n```json\n") - json.dump(baseline, f, indent=2) - f.write("\n```\n") - - -def update_var(var_name: str, value: str): - """Update GitHub repository variable.""" - repo = os.getenv("GITHUB_REPOSITORY", "Josverl/micropython-stubs") - gh_token_vars = os.getenv("GH_TOKEN_VARS", os.getenv("GH_TOKEN", "-")) - - if gh_token_vars == "-": - print("No token available to update repository variable") - return False - - url = f"https://api.github.com/repos/{repo}/actions/variables/{var_name}" - headers = { - "Authorization": f"token {gh_token_vars}", - "Content-Type": "application/json", - "User-Agent": "josverl", - } - data = {"name": var_name, "value": value} - - try: - response = requests.patch(url, headers=headers, json=data) - response.raise_for_status() - return True - except Exception as e: - print(f"Failed to update variable: {e}") - return False - - -def add_to_history(all_scores: dict, version_type: str, version_key: str, new_scores: dict): - """Add current results to history, keeping last MAX_HISTORY_RECORDS.""" - if "history" not in all_scores: - all_scores["history"] = {} - - if version_key not in all_scores["history"]: - all_scores["history"][version_key] = [] - - history_entry = { - "pass_rate": new_scores.get("pass_rate", 0), - "executed": new_scores.get("executed", 0), - "passed": new_scores.get("passed", 0), - "failed": new_scores.get("failed", 0), - "timestamp": datetime.now(timezone.utc).isoformat(), - "commit": os.getenv("GITHUB_SHA", "unknown")[:7] - } - - all_scores["history"][version_key].append(history_entry) - # Keep only last MAX_HISTORY_RECORDS - all_scores["history"][version_key] = all_scores["history"][version_key][-MAX_HISTORY_RECORDS:] - - -def compare_and_update(version_type: str, fail_on_drop: bool = False) -> int: - """ - Compare new scores with baseline and update if appropriate. - - Args: - version_type: "stable", "preview", or "recent_majors" - fail_on_drop: If True, exit with error code 1 on quality drop - - Returns: - 0 for success, 1 for failure - """ - all_scores = load_baseline_scores() - new_scores = load_new_scores() - - # Add metadata - new_scores["timestamp"] = datetime.now(timezone.utc).isoformat() - new_scores["commit"] = os.getenv("GITHUB_SHA", "unknown")[:7] - - # Determine the key to store under - if version_type == "stable": - version = get_current_version() - if not version: - print("ERROR: TEST_VERSION not set for stable tests") - return 1 - storage_key = version - baseline = all_scores["stable"].get(version, {}) - elif version_type == "preview": - storage_key = "preview" - new_scores["version"] = get_current_version() or "unknown" - baseline = all_scores.get("preview", {}) - elif version_type == "recent_majors": - storage_key = "recent_majors" - # Extract tested versions from new_scores if available - baseline = all_scores.get("recent_majors", {}) - else: - print(f"ERROR: Unknown version_type: {version_type}") - return 1 - - # Extract metrics - new_executed = new_scores.get("executed", 0) - baseline_executed = baseline.get("executed", 0) - new_pass_rate = new_scores.get("pass_rate", 0) - baseline_pass_rate = baseline.get("pass_rate", 0) - - # Check minimum executed threshold - if baseline_executed > 0 and new_executed < baseline_executed * MIN_EXECUTED_FRACTION: - msg = ( - f"⚠️ Too few tests executed: {new_executed} < " - f"{MIN_EXECUTED_FRACTION:.0%} of baseline ({baseline_executed}). " - f"Possible mass-skip or environment issue." - ) - print(msg) - add_summary(msg, version_type, new_scores, baseline) - return 1 if fail_on_drop else 0 - - # Compare pass rates - rate_delta = new_pass_rate - baseline_pass_rate - - if baseline_pass_rate > 0 and new_pass_rate < baseline_pass_rate - PASS_RATE_TOLERANCE: - msg = ( - f"❌ pass_rate dropped by more than {PASS_RATE_TOLERANCE:.0%}: " - f"{baseline_pass_rate:.2%} → {new_pass_rate:.2%} " - f"(Δ {rate_delta:.2%}, executed: {new_executed})" - ) - print(msg) - add_summary(msg, version_type, new_scores, baseline) - return 1 if fail_on_drop else 0 - elif rate_delta >= 0 or baseline_pass_rate == 0: - if baseline_pass_rate == 0: - msg = f"✨ New baseline established: {new_pass_rate:.2%} (executed: {new_executed})" - else: - msg = f"✅ pass_rate: {baseline_pass_rate:.2%} → {new_pass_rate:.2%} (Δ {rate_delta:+.2%}, executed: {new_executed})" - print(msg) - add_summary(msg, version_type, new_scores, baseline) - - # Update scores - all_scores[version_type][storage_key] = new_scores - add_to_history(all_scores, version_type, storage_key, new_scores) - - # Only update on main branch - if os.getenv("GITHUB_REF_NAME", "main") == "main": - update_var("SNIPPET_SCORE", json.dumps(all_scores, indent=2)) - - return 0 - else: - msg = ( - f"⚠️ pass_rate decreased within tolerance: " - f"{baseline_pass_rate:.2%} → {new_pass_rate:.2%} " - f"(Δ {rate_delta:.2%}, executed: {new_executed})" - ) - print(msg) - add_summary(msg, version_type, new_scores, baseline) - return 0 - - -if __name__ == "__main__": - version_type = get_version_type() - fail_on_drop = (version_type == "stable") # Only fail on stable drops - - print(f"Comparing {version_type} scores (fail_on_drop={fail_on_drop})") - exit_code = compare_and_update(version_type, fail_on_drop) - sys.exit(exit_code) diff --git a/.github/workflows/test_stub_quality.yml b/.github/workflows/test_stub_quality.yml index ed85cb042c..60b3ec2102 100644 --- a/.github/workflows/test_stub_quality.yml +++ b/.github/workflows/test_stub_quality.yml @@ -72,7 +72,7 @@ jobs: VERSION_TYPE: stable TEST_VERSION: ${{ steps.get_version.outputs.stable_version }} run: | - uv run python .github/workflows/compare_score_v2.py + uv run python .github/workflows/compare_score.py - name: Upload results artifact uses: actions/upload-artifact@v4 @@ -129,7 +129,7 @@ jobs: VERSION_TYPE: preview TEST_VERSION: ${{ steps.get_version.outputs.preview_version }} run: | - uv run python .github/workflows/compare_score_v2.py + uv run python .github/workflows/compare_score.py - name: Upload preview results artifact uses: actions/upload-artifact@v4 @@ -178,7 +178,7 @@ jobs: env: VERSION_TYPE: recent_majors run: | - uv run python .github/workflows/compare_score_v2.py + uv run python .github/workflows/compare_score.py - name: Upload recent majors results artifact uses: actions/upload-artifact@v4 diff --git a/pyproject.toml b/pyproject.toml index 37d7c6e294..1e9fa49003 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,6 +118,37 @@ markers = ["snippets: test snippets to check the stub quality"] [tool.ruff] # Exclude a variety of commonly ignored directories. +exclude = [ + "dist", + "repos", + # defaults + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", + ] # Same as Black. line-length = 140 @@ -129,7 +160,6 @@ target-version = "py39" [tool.ruff.format] # Like Black, use double quotes for strings. quote-style = "double" -exclude = [".*", "__*", "dist", "repos"] # Like Black, indent with spaces, rather than tabs. indent-style = "space" From 8ff6f0f896e1c1e79b8281d376e5fccf324916ac Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Wed, 25 Feb 2026 08:36:17 +0100 Subject: [PATCH 7/8] chore: format code Signed-off-by: Jos Verlinde --- .../actions/enhanced-diff/check_changes.py | 62 ++++++++---------- .../enhanced-diff/test_enhanced_diff.py | 65 +++++++------------ .../actions/get-mpversions/list_versions.py | 23 ++++--- 3 files changed, 65 insertions(+), 85 deletions(-) diff --git a/.github/actions/enhanced-diff/check_changes.py b/.github/actions/enhanced-diff/check_changes.py index 36174ed67c..e16e1a5b91 100644 --- a/.github/actions/enhanced-diff/check_changes.py +++ b/.github/actions/enhanced-diff/check_changes.py @@ -16,13 +16,7 @@ def run_git_command(cmd): """Run a git command and return the output.""" try: - result = subprocess.run( - cmd, - shell=True, - capture_output=True, - text=True, - check=True - ) + result = subprocess.run(cmd, shell=True, capture_output=True, text=True, check=True) return result.stdout.strip() except subprocess.CalledProcessError as e: print(f"Error running git command '{cmd}': {e}", file=sys.stderr) @@ -34,14 +28,14 @@ def get_changed_files(): output = run_git_command("git status --porcelain") if not output: return [] - + changed_files = [] - for line in output.split('\n'): + for line in output.split("\n"): if line.strip(): # Extract filename from git status output (remove status indicators) filename = line[3:].strip() # Skip the first 3 characters (status indicators and space) changed_files.append(filename) - + return changed_files @@ -49,21 +43,21 @@ def categorize_files(files): """Categorize files into JSON and non-JSON files.""" json_files = [] non_json_files = [] - + for file in files: - if file.lower().endswith('.json'): + if file.lower().endswith(".json"): json_files.append(file) else: non_json_files.append(file) - + return json_files, non_json_files def set_github_output(key, value): """Set GitHub Actions output variable.""" - github_output = os.getenv('GITHUB_OUTPUT') + github_output = os.getenv("GITHUB_OUTPUT") if github_output: - with open(github_output, 'a', encoding='utf-8') as f: + with open(github_output, "a", encoding="utf-8") as f: f.write(f"{key}={value}\n") else: print(f"::set-output name={key}::{value}") @@ -71,24 +65,24 @@ def set_github_output(key, value): def set_github_summary(content): """Set GitHub Actions step summary.""" - github_step_summary = os.getenv('GITHUB_STEP_SUMMARY') + github_step_summary = os.getenv("GITHUB_STEP_SUMMARY") if github_step_summary: - with open(github_step_summary, 'a', encoding='utf-8') as f: + with open(github_step_summary, "a", encoding="utf-8") as f: f.write(f"{content}\n") def main(): """Main function to check for changes and determine commit behavior.""" - verbose = os.getenv('VERBOSE', 'false').lower() in ('true', '1', 'yes') - + verbose = os.getenv("VERBOSE", "false").lower() in ("true", "1", "yes") + if verbose: print("::group::Enhanced diff check") print(f"Current working directory: {os.getcwd()}") - + # Get all changed files changed_files = get_changed_files() total_count = len(changed_files) - + if total_count == 0: if verbose: print("No changes detected.") @@ -99,39 +93,39 @@ def main(): if verbose: print("::endgroup::") return - + # Categorize files json_files, non_json_files = categorize_files(changed_files) json_count = len(json_files) non_json_count = len(non_json_files) - + # Decision logic: commit only if there are non-JSON file changes should_commit = non_json_count > 0 - + # Set outputs set_github_output("changed", "true" if should_commit else "false") set_github_output("count", str(total_count)) set_github_output("json_count", str(json_count)) set_github_output("non_json_count", str(non_json_count)) - + # Create summary if should_commit: summary_content = f"### Detected {total_count} changed files - Commit will proceed :rocket:\n" summary_content += f"- Non-JSON files: {non_json_count} (triggers commit)\n" summary_content += f"- JSON files: {json_count} (included in commit)\n\n" - + if non_json_files: summary_content += "**Non-JSON files changed:**\n" for file in non_json_files: summary_content += f"- {file}\n" - + if json_files: summary_content += "\n**JSON files changed (included in commit):**\n" for file in json_files: summary_content += f"- {file}\n" - + set_github_summary(summary_content) - + if verbose: print(f"### Commit will proceed - {non_json_count} non-JSON file(s) changed") print("Non-JSON files:") @@ -141,7 +135,7 @@ def main(): print("JSON files (included in commit):") for file in json_files: print(f" - {file}") - + else: summary_content = f"### Detected {total_count} changed files - No commit needed\n" summary_content += f"- Only JSON files changed: {json_count}\n" @@ -149,18 +143,18 @@ def main(): summary_content += "**JSON files changed (commit skipped):**\n" for file in json_files: summary_content += f"- {file}\n" - + set_github_summary(summary_content) - + if verbose: print(f"### No commit needed - only {json_count} JSON file(s) changed") print("JSON files (no commit triggered):") for file in json_files: print(f" - {file}") - + if verbose: print("::endgroup::") if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/.github/actions/enhanced-diff/test_enhanced_diff.py b/.github/actions/enhanced-diff/test_enhanced_diff.py index 4d9dc526aa..8c7d0833f3 100644 --- a/.github/actions/enhanced-diff/test_enhanced_diff.py +++ b/.github/actions/enhanced-diff/test_enhanced_diff.py @@ -20,46 +20,46 @@ def test_categorize_files(): """Test the file categorization logic.""" print("Testing file categorization...") - + # Test case 1: Mixed files files = ["stub.py", "config.json", "module.pyi", "data.json", "README.md"] json_files, non_json_files = categorize_files(files) - + expected_json = ["config.json", "data.json"] expected_non_json = ["stub.py", "module.pyi", "README.md"] - + assert json_files == expected_json, f"Expected {expected_json}, got {json_files}" assert non_json_files == expected_non_json, f"Expected {expected_non_json}, got {non_json_files}" print("✓ Mixed files test passed") - + # Test case 2: Only JSON files files = ["config.json", "package.json"] json_files, non_json_files = categorize_files(files) - + assert json_files == ["config.json", "package.json"] assert non_json_files == [] print("✓ JSON-only files test passed") - + # Test case 3: Only non-JSON files files = ["main.py", "utils.py", "README.md"] json_files, non_json_files = categorize_files(files) - + assert json_files == [] assert non_json_files == ["main.py", "utils.py", "README.md"] print("✓ Non-JSON-only files test passed") - + # Test case 4: Empty list files = [] json_files, non_json_files = categorize_files(files) - + assert json_files == [] assert non_json_files == [] print("✓ Empty files test passed") - + # Test case 5: Case insensitive JSON detection files = ["CONFIG.JSON", "data.Json", "mixed.JSON"] json_files, non_json_files = categorize_files(files) - + assert json_files == ["CONFIG.JSON", "data.Json", "mixed.JSON"] assert non_json_files == [] print("✓ Case insensitive JSON test passed") @@ -68,50 +68,33 @@ def test_categorize_files(): def simulate_git_status_scenarios(): """Simulate different git status scenarios to show decision logic.""" print("\nSimulating different change scenarios...") - + scenarios = [ - { - "name": "Only JSON files changed", - "files": ["config.json", "package.json"], - "should_commit": False - }, - { - "name": "Only non-JSON files changed", - "files": ["main.py", "README.md"], - "should_commit": True - }, - { - "name": "Mixed files changed", - "files": ["main.py", "config.json", "utils.py"], - "should_commit": True - }, - { - "name": "No files changed", - "files": [], - "should_commit": False - } + {"name": "Only JSON files changed", "files": ["config.json", "package.json"], "should_commit": False}, + {"name": "Only non-JSON files changed", "files": ["main.py", "README.md"], "should_commit": True}, + {"name": "Mixed files changed", "files": ["main.py", "config.json", "utils.py"], "should_commit": True}, + {"name": "No files changed", "files": [], "should_commit": False}, ] - + for scenario in scenarios: print(f"\nScenario: {scenario['name']}") - files = scenario['files'] + files = scenario["files"] json_files, non_json_files = categorize_files(files) - + should_commit = len(non_json_files) > 0 - + print(f" Files: {files}") print(f" JSON files: {json_files}") print(f" Non-JSON files: {non_json_files}") print(f" Should commit: {should_commit}") - - assert should_commit == scenario['should_commit'], \ - f"Expected should_commit={scenario['should_commit']}, got {should_commit}" + + assert should_commit == scenario["should_commit"], f"Expected should_commit={scenario['should_commit']}, got {should_commit}" print(" ✓ Decision logic correct") if __name__ == "__main__": print("Running enhanced diff checker tests...\n") - + try: test_categorize_files() simulate_git_status_scenarios() @@ -121,4 +104,4 @@ def simulate_git_status_scenarios(): sys.exit(1) except Exception as e: print(f"\n💥 Unexpected error: {e}") - sys.exit(1) \ No newline at end of file + sys.exit(1) diff --git a/.github/actions/get-mpversions/list_versions.py b/.github/actions/get-mpversions/list_versions.py index 8d5486ca84..901c7dda19 100644 --- a/.github/actions/get-mpversions/list_versions.py +++ b/.github/actions/get-mpversions/list_versions.py @@ -6,6 +6,7 @@ The module also includes a main block that generates a matrix of versions based on command-line arguments and environment variables. The matrix is printed as JSON and can be optionally written to a file if running in a GitHub Actions workflow. """ + import argparse import json import os @@ -17,9 +18,10 @@ # Token with no permissions to avoid throttling # https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#getting-a-higher-rate-limit -PAT_NO_ACCESS = "github_pat_"+"11AAHPVFQ0G4NTaQ73Bw5J"+"_fAp7K9sZ1qL8VFnI9g78eUlCdmOXHB3WzSdj2jtEYb4XF3N7PDJBl32qIxq" +PAT_NO_ACCESS = "github_pat_" + "11AAHPVFQ0G4NTaQ73Bw5J" + "_fAp7K9sZ1qL8VFnI9g78eUlCdmOXHB3WzSdj2jtEYb4XF3N7PDJBl32qIxq" PAT = os.environ.get("GITHUB_TOKEN") or PAT_NO_ACCESS + @lru_cache() def micropython_versions(start="v1.10"): g = Github(auth=Auth.Token(PAT)) @@ -32,6 +34,7 @@ def micropython_versions(start="v1.10"): tags = ["preview", "stable"] return tags + def major_minor(versions): """create a list of the most recent version for each major.minor""" mm_groups = {} @@ -45,11 +48,12 @@ def major_minor(versions): mm_groups[major_minor].append(v) return [max(v) for v in mm_groups.values()] + def main(): matrix = {} - + parser = argparse.ArgumentParser() - parser.add_argument("--stable", "--latest","-s", action=argparse.BooleanOptionalAction,default=True, help="Add latest version") + parser.add_argument("--stable", "--latest", "-s", action=argparse.BooleanOptionalAction, default=True, help="Add latest version") parser.add_argument("--preview", "-p", action=argparse.BooleanOptionalAction, default=False, help="Add preview version") parser.add_argument("--max", "-m", type=int, default=3, help="Maximum number of versions") @@ -58,24 +62,23 @@ def main(): # only run latests when running in ACT locally for testing if os.environ.get("ACT"): args.max = 1 - matrix["version"] = major_minor(micropython_versions(start="v1.20"))[1:args.max] - + matrix["version"] = major_minor(micropython_versions(start="v1.20"))[1 : args.max] # print(args) if args.stable: matrix["version"].insert(0, "stable") if args.preview: matrix["version"].insert(0, "preview") - matrix["version"]=matrix["version"][:args.max] + matrix["version"] = matrix["version"][: args.max] # GITHUB_OUTPUT is set by github actions - if os.getenv('GITHUB_OUTPUT'): - with open(os.getenv('GITHUB_OUTPUT'), 'a') as file: # type: ignore + if os.getenv("GITHUB_OUTPUT"): + with open(os.getenv("GITHUB_OUTPUT"), "a") as file: # type: ignore file.write(f"versions={json.dumps(matrix)}\n") - file.write(f'mp_versions={json.dumps(matrix["version"])}\n') + file.write(f"mp_versions={json.dumps(matrix['version'])}\n") else: print(json.dumps(matrix, indent=4)) + # sourcery skip: assign-if-exp, merge-dict-assign if __name__ == "__main__": main() - From 650eb00591fcabdbe2911939dbcb34aa860e9d5d Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Wed, 25 Feb 2026 14:42:39 +0100 Subject: [PATCH 8/8] Allow test snippets to continue on error --- .github/workflows/test_stub_quality.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_stub_quality.yml b/.github/workflows/test_stub_quality.yml index 60b3ec2102..87ad2b4b0c 100644 --- a/.github/workflows/test_stub_quality.yml +++ b/.github/workflows/test_stub_quality.yml @@ -63,6 +63,7 @@ jobs: # pwsh -file ./update-stubs.ps1 - name: Test the snippets (stable only - blocking) + continue-on-error: true run: | uv run pytest -m 'snippets' --stable-only --cache-clear --junitxml=./results/results.xml