diff --git a/Makefile b/Makefile index fbf72c5..ab8a275 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PYSQUARED_VERSION ?= v2.0.0-alpha-25w14-3 +PYSQUARED_VERSION ?= sx1280-manager PYSQUARED ?= git+https://github.com/proveskit/pysquared@$(PYSQUARED_VERSION) .PHONY: all @@ -51,6 +51,11 @@ else $(call rsync_to_dest,artifacts/proves,$(BOARD_MOUNT_POINT)) endif +# install-firmware +.PHONY: install-firmware +install-firmware: uv ## Install the board firmware onto a connected PROVES Kit + @$(UVX) --from git+https://github.com/proveskit/install-firmware@1.0.1 install-firmware v5a + .PHONY: clean clean: ## Remove all gitignored files such as downloaded libraries and artifacts git clean -dfX diff --git a/lib/requirements.txt b/lib/requirements.txt index 3ae3597..a445feb 100644 --- a/lib/requirements.txt +++ b/lib/requirements.txt @@ -1,4 +1,4 @@ -adafruit-circuitpython-74hc595==1.4.6 +adafruit-circuitpython-ina219==3.4.26 adafruit-circuitpython-asyncio @ git+https://github.com/adafruit/adafruit_circuitpython_asyncio@1.3.3 adafruit-circuitpython-drv2605==1.3.4 adafruit-circuitpython-lis2mdl==2.1.23 @@ -7,8 +7,9 @@ adafruit-circuitpython-mcp9808==3.3.24 adafruit-circuitpython-neopixel==6.3.12 adafruit-circuitpython-register==1.10.1 adafruit-circuitpython-rfm==1.0.3 -adafruit-circuitpython-tca9548a @ git+https://github.com/proveskit/Adafruit_CircuitPython_TCA9548A@1.0.0 +adafruit-circuitpython-tca9548a @ git+https://github.com/proveskit/Adafruit_CircuitPython_TCA9548A@1.1.0 adafruit-circuitpython-ticks==1.1.1 adafruit-circuitpython-veml7700==2.0.2 +Adafruit_CircuitPython_MCP230xx proves-circuitpython-rv3028 @ git+https://github.com/proveskit/PROVES_CircuitPython_RV3028@1.0.0 -proves-circuitpython-sx126 @ git+https://github.com/proveskit/micropySX126X@1.0.0 +proves-circuitpython-sx1280 @ git+https://github.com/proveskit/CircuitPython_SX1280@1.0.3 diff --git a/main.py b/main.py index a964743..9c7e765 100644 --- a/main.py +++ b/main.py @@ -3,25 +3,19 @@ # Created By: Michael Pham """ -Built for the PySquared FC Board -Version: 2.0.0 -Published: Nov 19, 2024 +Built for the PySquared V5a FC Board +Version: X.X.X +Published: """ import gc +import os import time +import board import digitalio import microcontroller -try: - # from board_definitions import proveskit_rp2040_v4 as board - raise ImportError -except ImportError: - import board - -import os - import lib.pysquared.functions as functions import lib.pysquared.nvm.register as register from lib.pysquared.cdh import CommandDataHandler @@ -30,7 +24,7 @@ from lib.pysquared.hardware.digitalio import initialize_pin from lib.pysquared.hardware.imu.manager.lsm6dsox import LSM6DSOXManager from lib.pysquared.hardware.magnetometer.manager.lis2mdl import LIS2MDLManager -from lib.pysquared.hardware.radio.manager.sx126x import SX126xManager +from lib.pysquared.hardware.radio.manager.sx1280 import SX1280Manager from lib.pysquared.logger import Logger from lib.pysquared.nvm.counter import Counter from lib.pysquared.nvm.flag import Flag @@ -43,7 +37,7 @@ rtc = MicrocontrollerManager() logger: Logger = Logger( - error_counter=Counter(index=register.ERRORCNT, datastore=microcontroller.nvm), + error_counter=Counter(index=register.ERRORCNT), colorized=False, ) @@ -68,38 +62,58 @@ # TODO(nateinaction): fix spi init spi0 = _spi_init( + logger, + board.SPI0_SCK, + board.SPI0_MOSI, + board.SPI0_MISO, + ) + + spi1 = _spi_init( logger, board.SPI1_SCK, board.SPI1_MOSI, board.SPI1_MISO, ) - radio = SX126xManager( + use_fsk_flag = Flag(index=register.FLAG, bit_index=7) + + radio = SX1280Manager( logger, config.radio, - Flag(index=register.FLAG, bit_index=7, datastore=microcontroller.nvm), - spi0, - initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT, True), - board.RF2_IO0, - initialize_pin(logger, board.RF1_RST, digitalio.Direction.OUTPUT, True), - board.RF2_IO4, + use_fsk_flag, + spi1, + initialize_pin(logger, board.SPI1_CS0, digitalio.Direction.OUTPUT, True), + initialize_pin(logger, board.RF2_RST, digitalio.Direction.OUTPUT, True), + initialize_pin(logger, board.RF2_IO0, digitalio.Direction.OUTPUT, True), + 2.4, + initialize_pin(logger, board.RF2_TX_EN, digitalio.Direction.OUTPUT, True), + initialize_pin(logger, board.RF2_RX_EN, digitalio.Direction.OUTPUT, True), ) i2c1 = initialize_i2c_bus( logger, - board.I2C1_SCL, - board.I2C1_SDA, + board.SCL1, + board.SDA1, 100000, ) - magnetometer = LIS2MDLManager(logger, i2c1) - - imu = LSM6DSOXManager(logger, i2c1, 0x6B) - c = Satellite(logger, config) sleep_helper = SleepHelper(c, logger, watchdog) + # radio = RFM9xManager( + # logger, + # config.radio, + # Flag(index=register.FLAG, bit_index=7), + # spi0, + # initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT, True), + # initialize_pin(logger, board.RF1_RST, digitalio.Direction.OUTPUT, True), + # ) + + magnetometer = LIS2MDLManager(logger, i2c1) + + imu = LSM6DSOXManager(logger, i2c1, 0x6B) + cdh = CommandDataHandler(config, logger, radio) f = functions.functions( @@ -156,9 +170,7 @@ def main(): f.listen_loiter() - f.all_face_data() watchdog.pet() - f.send_face() f.listen_loiter() diff --git a/pyproject.toml b/pyproject.toml index 0402196..21ec336 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] -name = "circuitpy-flight-software" -version = "2.0.0" -description = "Flight Software for the PROVES Kit" +name = "proveskit-rp2350-v5a" +version = "1.0.0" +description = "Flight Software for the PROVES Kit RP2350 v5A" readme = "README.md" requires-python = ">=3.13" dependencies = [ @@ -9,6 +9,7 @@ dependencies = [ "circuitpython-stubs==9.2.5", "coverage==7.6.10", "pre-commit==4.0.1", + "pyright[nodejs]==1.1.399", "pytest==8.3.2", ] @@ -16,36 +17,15 @@ dependencies = [ # Use `\n` line endings for all files line-ending = "lf" -[tool.pytest.ini_options] -pythonpath = "." -markers = [ - "slow: marks tests as slow (deselect with '-m \"not slow\"')", +[tool.pyright] +include = ["main.py", "boot.py", "repl.py", "safemode.py"] +exclude = [ + "**/__pycache__", + ".venv", + ".git", + "artifacts", + "lib", + "typings", ] - -[tool.coverage.run] -branch = true -relative_files = true - -[tool.coverage.report] -show_missing = true -skip_covered = false -include = [ - "lib/**/*.py", - "boot.py", - "main.py", - "repl.py", - "safemode.py", - ] -omit = [ - "lib/adafruit_*/**", - "lib/asyncio_*/**", - "lib/rv3028*/**", - "lib/neopixel.py", - "lib/pysquared/**" - ] - -[tool.coverage.html] -directory = ".coverage-reports/html" - -[tool.coverage.xml] -output = ".coverage-reports/coverage.xml" +stubPath = "./typings" +reportMissingModuleSource = false diff --git a/repl.py b/repl.py index 8e2f2a9..8ac8d73 100644 --- a/repl.py +++ b/repl.py @@ -1,15 +1,266 @@ -import microcontroller +# This is where the magic happens! +# This file is executed on every boot (including wake-boot from deepsleep) +# Created By: Michael Pham +""" +Built for the PySquared V5a FC Board +Version: X.X.X +Published: +""" + +import time + +import digitalio + +try: + # from board_definitions import proveskit_rp2040_v4 as board + raise ImportError +except ImportError: + import board + +import os + +import lib.pysquared.functions as functions import lib.pysquared.nvm.register as register +from lib.adafruit_mcp230xx.mcp23017 import ( + MCP23017, ### This is Hacky V5a Devel Stuff### +) +from lib.adafruit_mcp9808 import MCP9808 ### This is Hacky V5a Devel Stuff### +from lib.adafruit_tca9548a import TCA9548A ### This is Hacky V5a Devel Stuff### + +# from lib.pysquared.Big_Data import AllFaces ### This is Hacky V5a Devel Stuff### +from lib.pysquared.cdh import CommandDataHandler from lib.pysquared.config.config import Config +from lib.pysquared.hardware.busio import _spi_init, initialize_i2c_bus +from lib.pysquared.hardware.digitalio import initialize_pin +from lib.pysquared.hardware.imu.manager.lsm6dsox import LSM6DSOXManager +from lib.pysquared.hardware.magnetometer.manager.lis2mdl import LIS2MDLManager +from lib.pysquared.hardware.radio.manager.rfm9x import RFM9xManager +from lib.pysquared.hardware.radio.manager.sx1280 import SX1280Manager from lib.pysquared.logger import Logger from lib.pysquared.nvm.counter import Counter +from lib.pysquared.nvm.flag import Flag +from lib.pysquared.rtc.manager.microcontroller import MicrocontrollerManager from lib.pysquared.satellite import Satellite +from lib.pysquared.sleep_helper import SleepHelper +from lib.pysquared.watchdog import Watchdog +from version import __version__ + +rtc = MicrocontrollerManager() logger: Logger = Logger( - error_counter=Counter(index=register.ERRORCNT, datastore=microcontroller.nvm), + error_counter=Counter(index=register.ERRORCNT), colorized=False, ) + +logger.info( + "Booting", + hardware_version=os.uname().version, + software_version=__version__, +) + +watchdog = Watchdog(logger, board.WDT_WDI) +watchdog.pet() + +logger.debug("Initializing Config") config: Config = Config("config.json") -logger.info("Initializing a cubesat object as `c` in the REPL...") -c: Satellite = Satellite(logger, config) + +# TODO(nateinaction): fix spi init +spi0 = _spi_init( + logger, + board.SPI0_SCK, + board.SPI0_MOSI, + board.SPI0_MISO, +) + +spi1 = _spi_init( + logger, + board.SPI1_SCK, + board.SPI1_MOSI, + board.SPI1_MISO, +) + +i2c0 = initialize_i2c_bus( + logger, + board.SCL0, + board.SDA0, + 100000, +) + +i2c1 = initialize_i2c_bus( + logger, + board.SCL1, + board.SDA1, + 100000, +) + +c = Satellite(logger, config) + +sleep_helper = SleepHelper(c, logger, watchdog) + +radio = RFM9xManager( + logger, + config.radio, + Flag(index=register.FLAG, bit_index=7), + spi0, + initialize_pin(logger, board.SPI0_CS0, digitalio.Direction.OUTPUT, True), + initialize_pin(logger, board.RF1_RST, digitalio.Direction.OUTPUT, True), +) + +magnetometer = LIS2MDLManager(logger, i2c1) + +imu = LSM6DSOXManager(logger, i2c1, 0x6B) + +cdh = CommandDataHandler(config, logger, radio) + +f = functions.functions( + c, + logger, + config, + sleep_helper, + radio, + magnetometer, + imu, + watchdog, + cdh, +) + +### This is Hacky V5a Devel Stuff### + +## Initialize the Second Radio ## + +use_fsk_flag = Flag(index=register.FLAG, bit_index=7) + +radio2 = SX1280Manager( + logger, + config.radio, + use_fsk_flag, + spi1, + initialize_pin(logger, board.SPI1_CS0, digitalio.Direction.OUTPUT, True), + initialize_pin(logger, board.RF2_RST, digitalio.Direction.OUTPUT, True), + initialize_pin(logger, board.RF2_IO0, digitalio.Direction.OUTPUT, True), + 2.4, + initialize_pin(logger, board.RF2_TX_EN, digitalio.Direction.OUTPUT, True), + initialize_pin(logger, board.RF2_RX_EN, digitalio.Direction.OUTPUT, True), +) + +radio2.send("Hello World") +print("Radio2 sent Hello World") + +## Initializing the Burn Wire ## +ENABLE_BURN_A = initialize_pin( + logger, board.FIRE_DEPLOY1_A, digitalio.Direction.OUTPUT, True +) +ENABLE_BURN_B = initialize_pin( + logger, board.FIRE_DEPLOY1_B, digitalio.Direction.OUTPUT, True +) + + +def dumb_burn(duration=5) -> None: + """ + This function is used to test the burn wire. + It will turn on the burn wire for 5 seconds and then turn it off. + + Args: + duration (int): The duration to burn for in seconds. Default is 5 seconds. + Returns: + None + """ + ENABLE_BURN_A.value = False + ENABLE_BURN_B.value = False + logger.info("Burn Wire Enabled") + time.sleep(duration) + logger.info("Burn Wire Disabled") + ENABLE_BURN_A.value = True + ENABLE_BURN_B.value = True + + +## Initializing the Heater ## +def heater_pulse() -> None: + """ + This function is used to turn on the heater. + It will turn on the heater for 5 seconds and then turn it off. + + Args: + None + Returns: + None + """ + ENABLE_HEATER.value = False + logger.info("Heater Enabled") + time.sleep(5) + logger.info("Heater Disabled") + ENABLE_HEATER.value = True + + +## Initialize the MCP23017 GPIO Expander and its pins ## +GPIO_RESET = initialize_pin( + logger, board.GPIO_EXPANDER_RESET, digitalio.Direction.OUTPUT, True +) +mcp = MCP23017(i2c1) + +# This sets up all of the GPIO pins on the MCP23017 +FACE4_ENABLE = mcp.get_pin(8) +FACE0_ENABLE = mcp.get_pin(9) +FACE1_ENABLE = mcp.get_pin(10) +FACE2_ENABLE = mcp.get_pin(11) +FACE3_ENABLE = mcp.get_pin(12) +ENAB_RF = mcp.get_pin(13) +VBUS_RESET = mcp.get_pin(14) +SPI0_CS1 = mcp.get_pin(15) +ENABLE_HEATER = mcp.get_pin(0) +PAYLOAD_PWR_ENABLE = mcp.get_pin(1) +Z_GPIO0 = mcp.get_pin(2) +Z_GPIO1 = mcp.get_pin(3) +RF2_IO2 = mcp.get_pin(4) +RF2_IO1 = mcp.get_pin(5) + +# This defines the direction of the GPIO pins +FACE4_ENABLE.direction = digitalio.Direction.OUTPUT +FACE0_ENABLE.direction = digitalio.Direction.OUTPUT +FACE1_ENABLE.direction = digitalio.Direction.OUTPUT +FACE2_ENABLE.direction = digitalio.Direction.OUTPUT +FACE3_ENABLE.direction = digitalio.Direction.OUTPUT +ENAB_RF.direction = digitalio.Direction.OUTPUT +VBUS_RESET.direction = digitalio.Direction.OUTPUT +ENABLE_HEATER.direction = digitalio.Direction.OUTPUT +PAYLOAD_PWR_ENABLE.direction = digitalio.Direction.OUTPUT + + +# Face Control Helper Functions +def all_faces_off(): + """ + This function turns off all of the faces. Note the load switches are disabled high. + """ + FACE0_ENABLE.value = True + FACE1_ENABLE.value = True + FACE2_ENABLE.value = True + FACE3_ENABLE.value = True + FACE4_ENABLE.value = True + + +def all_faces_on(): + """ + This function turns on all of the faces. Note the load switches are enabled low. + """ + FACE0_ENABLE.value = False + FACE1_ENABLE.value = False + FACE2_ENABLE.value = False + FACE3_ENABLE.value = False + FACE4_ENABLE.value = False + + +## Face Sensor Stuff ## + +# This is the TCA9548A I2C Multiplexer +mux_reset = initialize_pin(logger, board.MUX_RESET, digitalio.Direction.OUTPUT, True) +all_faces_on() + +tca = TCA9548A(i2c1, address=int(0x77)) + +# all_faces = AllFaces(tca, logger) + +## Onboard Temp Sensor ## +mcp = MCP9808(i2c1, address=30) # Not working for some reason + +### This is Hacky V5a Devel Stuff### diff --git a/sonar-project.properties b/sonar-project.properties index db709ba..29be344 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,4 +1,4 @@ -sonar.projectKey=proveskit_circuitpython_rp2040_v5 +sonar.projectKey=proveskit_circuitpython_rp2040_v5a sonar.organization=proves-kit sonar.sources=boot.py, main.py, repl.py, safemode.py, lib/pysquared/ diff --git a/typings/board.pyi b/typings/board.pyi new file mode 100644 index 0000000..f4cfa40 --- /dev/null +++ b/typings/board.pyi @@ -0,0 +1,71 @@ +# SPDX-FileCopyrightText: 2024 Justin Myers +# +# SPDX-License-Identifier: MIT +""" +Board stub for PROVES Kit v5a + - port: raspberrypi + - board_id: proveskit_rp2040_v5a + - NVM size: 4096 + - Included modules: _asyncio, _bleio, _pixelmap, adafruit_bus_device, adafruit_pixelbuf, aesio, alarm, analogbufio, analogio, array, atexit, audiobusio, audiocore, audiomixer, audiomp3, audiopwmio, binascii, bitbangio, bitmapfilter, bitmaptools, bitops, board, builtins, builtins.pow3, busdisplay, busio, busio.SPI, busio.UART, codeop, collections, countio, digitalio, displayio, epaperdisplay, errno, floppyio, fontio, fourwire, framebufferio, getpass, gifio, hashlib, i2cdisplaybus, i2ctarget, imagecapture, io, jpegio, json, keypad, keypad.KeyMatrix, keypad.Keys, keypad.ShiftRegisterKeys, keypad_demux, keypad_demux.DemuxKeyMatrix, locale, math, memorymap, microcontroller, msgpack, neopixel_write, nvm, onewireio, os, os.getenv, paralleldisplaybus, pulseio, pwmio, qrio, rainbowio, random, re, rgbmatrix, rotaryio, rp2pio, rtc, sdcardio, select, sharpdisplay, storage, struct, supervisor, synthio, sys, terminalio, tilepalettemapper, time, touchio, traceback, ulab, usb, usb_cdc, usb_hid, usb_host, usb_midi, usb_video, vectorio, warnings, watchdog, zlib + - Frozen libraries: +--- +proveskit: This typings file was assembled by hand and is temporary until we can integrate the 5a board into upstream CircuitPython +""" + +# Imports +import busio +import microcontroller + +# Board Info: +board_id: str + +# Pins: +TX: microcontroller.Pin # GPIO0 +RX: microcontroller.Pin # GPIO1 +SDA1: microcontroller.Pin # GPIO2 +SCL1: microcontroller.Pin # GPIO3 +SDA0: microcontroller.Pin # GPIO4 +SCL0: microcontroller.Pin # GPIO5 +RF1_RST: microcontroller.Pin # GPIO6 +SPI1_CS0: microcontroller.Pin # GPIO7 +SPI0_MISO: microcontroller.Pin # GPIO8 +SPI0_CS0: microcontroller.Pin # GPIO9 +SPI0_SCK: microcontroller.Pin # GPIO10 +SPI0_MOSI: microcontroller.Pin # GPIO11 +RF1_IO4: microcontroller.Pin # GPIO12 +RF1_IO0: microcontroller.Pin # GPIO13 +RF2_IO3: microcontroller.Pin # GPIO14 +RF2_RST: microcontroller.Pin # GPIO17 +SPI1_CS1: microcontroller.Pin # GPIO15 +SPI1_MISO: microcontroller.Pin # GPIO16 +SPI1_SCK: microcontroller.Pin # GPIO18 +SPI1_MOSI: microcontroller.Pin # GPIO19 +GPIO_EXPANDER_RESET: microcontroller.Pin # GPIO20 +RF2_RX_EN: microcontroller.Pin # GPIO21 +RF2_TX_EN: microcontroller.Pin # GPIO22 +RF2_IO0: microcontroller.Pin # GPIO23 +WDT_WDI: microcontroller.Pin # GPIO24 +WDT_ENABLE: microcontroller.Pin # GPIO25 +MUX_RESET: microcontroller.Pin # GPIO26 +RTC_INT: microcontroller.Pin # GPIO27 +FIRE_DEPLOY1_A: microcontroller.Pin # GPIO28 +FIRE_DEPLOY1_B: microcontroller.Pin # GPIO29 + +# Members: +def I2C() -> busio.I2C: + """Returns the `busio.I2C` object for the board's designated I2C bus(es). + The object created is a singleton, and uses the default parameter values for `busio.I2C`. + """ + +def SPI() -> busio.SPI: + """Returns the `busio.SPI` object for the board's designated SPI bus(es). + The object created is a singleton, and uses the default parameter values for `busio.SPI`. + """ + +def UART() -> busio.UART: + """Returns the `busio.UART` object for the board's designated UART bus(es). + The object created is a singleton, and uses the default parameter values for `busio.UART`. + """ + +# Unmapped: +# none diff --git a/typings/gc.pyi b/typings/gc.pyi new file mode 100644 index 0000000..56dfe3b --- /dev/null +++ b/typings/gc.pyi @@ -0,0 +1,116 @@ +""" +Control the garbage collector. + +MicroPython module: https://docs.micropython.org/en/v1.25.0/library/gc.html + +CPython module: :mod:`python:gc` https://docs.python.org/3/library/gc.html . + +--- +Module: 'gc' on micropython-v1.25.0-rp2-RPI_PICO +--- +proveskit: Borrowed from https://github.com/Josverl/micropython-stubs +https://pypi.org/project/micropython-rp2-stubs/#files +""" + +# MCU: {'build': '', 'ver': '1.25.0', 'version': '1.25.0', 'port': 'rp2', 'board': 'RPI_PICO', 'mpy': 'v6.3', 'family': 'micropython', 'cpu': 'RP2040', 'arch': 'armv6m'} +# Stubber: v1.24.0 +from __future__ import annotations + +from typing import overload + +from _typeshed import Incomplete + +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/uv.lock b/uv.lock index c464954..a91556e 100644 --- a/uv.lock +++ b/uv.lock @@ -110,27 +110,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c5/55/51844dd50c4fc7a33b653bfaba4c2456f06955289ca770a5dbd5fd267374/cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9", size = 7249 }, ] -[[package]] -name = "circuitpy-flight-software" -version = "2.0.0" -source = { virtual = "." } -dependencies = [ - { name = "adafruit-circuitpython-typing" }, - { name = "circuitpython-stubs" }, - { name = "coverage" }, - { name = "pre-commit" }, - { name = "pytest" }, -] - -[package.metadata] -requires-dist = [ - { name = "adafruit-circuitpython-typing", specifier = "==1.11.2" }, - { name = "circuitpython-stubs", specifier = "==9.2.5" }, - { name = "coverage", specifier = "==7.6.10" }, - { name = "pre-commit", specifier = "==4.0.1" }, - { name = "pytest", specifier = "==8.3.2" }, -] - [[package]] name = "circuitpython-stubs" version = "9.2.5" @@ -222,6 +201,22 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314 }, ] +[[package]] +name = "nodejs-wheel-binaries" +version = "22.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/45/5b/6c5f973765b96793d4e4d03684bcbd273b17e471ecc7e9bec4c32b595ebd/nodejs_wheel_binaries-22.15.0.tar.gz", hash = "sha256:ff81aa2a79db279c2266686ebcb829b6634d049a5a49fc7dc6921e4f18af9703", size = 8054 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d3/a8/a32e5bb99e95c536e7dac781cffab1e7e9f8661b8ee296b93df77e4df7f9/nodejs_wheel_binaries-22.15.0-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:aa16366d48487fff89446fb237693e777aa2ecd987208db7d4e35acc40c3e1b1", size = 50514526 }, + { url = "https://files.pythonhosted.org/packages/05/e8/eb024dbb3a7d3b98c8922d1c306be989befad4d2132292954cb902f43b07/nodejs_wheel_binaries-22.15.0-py2.py3-none-macosx_11_0_x86_64.whl", hash = "sha256:a54bb3fee9170003fa8abc69572d819b2b1540344eff78505fcc2129a9175596", size = 51409179 }, + { url = "https://files.pythonhosted.org/packages/3f/0f/baa968456c3577e45c7d0e3715258bd175dcecc67b683a41a5044d5dae40/nodejs_wheel_binaries-22.15.0-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:867121ccf99d10523f6878a26db86e162c4939690e24cfb5bea56d01ea696c93", size = 57364460 }, + { url = "https://files.pythonhosted.org/packages/2f/a2/977f63cd07ed8fc27bc0d0cd72e801fc3691ffc8cd40a51496ff18a6d0a2/nodejs_wheel_binaries-22.15.0-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ab0fbcda2ddc8aab7db1505d72cb958f99324b3834c4543541a305e02bfe860", size = 57889101 }, + { url = "https://files.pythonhosted.org/packages/67/7f/57b9c24a4f0d25490527b043146aa0fdff2d8fdc82f90667cdaf6f00cfc9/nodejs_wheel_binaries-22.15.0-py2.py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2bde1d8e00cd955b9ce9ee9ac08309923e2778a790ee791b715e93e487e74bfd", size = 59190817 }, + { url = "https://files.pythonhosted.org/packages/fd/7f/970acbe33b81c22b3c7928f52e32347030aa46d23d779cf781cf9a9cf557/nodejs_wheel_binaries-22.15.0-py2.py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:acdd4ef73b6701aab9fbe02ac5e104f208a5e3c300402fa41ad7bc7f49499fbf", size = 60220316 }, + { url = "https://files.pythonhosted.org/packages/07/4c/030243c04bb60f0de66c2d7ee3be289c6d28ef09113c06ffa417bdfedf8f/nodejs_wheel_binaries-22.15.0-py2.py3-none-win_amd64.whl", hash = "sha256:51deaf13ee474e39684ce8c066dfe86240edb94e7241950ca789befbbbcbd23d", size = 40718853 }, + { url = "https://files.pythonhosted.org/packages/1f/49/011d472814af4fabeaab7d7ce3d5a1a635a3dadc23ae404d1f546839ecb3/nodejs_wheel_binaries-22.15.0-py2.py3-none-win_arm64.whl", hash = "sha256:01a3fe4d60477f93bf21a44219db33548c75d7fed6dc6e6f4c05cf0adf015609", size = 36436645 }, +] + [[package]] name = "packaging" version = "24.2" @@ -265,6 +260,29 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/16/8f/496e10d51edd6671ebe0432e33ff800aa86775d2d147ce7d43389324a525/pre_commit-4.0.1-py2.py3-none-any.whl", hash = "sha256:efde913840816312445dc98787724647c65473daefe420785f885e8ed9a06878", size = 218713 }, ] +[[package]] +name = "proveskit-rp2350-v5a" +version = "1.0.0" +source = { virtual = "." } +dependencies = [ + { name = "adafruit-circuitpython-typing" }, + { name = "circuitpython-stubs" }, + { name = "coverage" }, + { name = "pre-commit" }, + { name = "pyright", extra = ["nodejs"] }, + { name = "pytest" }, +] + +[package.metadata] +requires-dist = [ + { name = "adafruit-circuitpython-typing", specifier = "==1.11.2" }, + { name = "circuitpython-stubs", specifier = "==9.2.5" }, + { name = "coverage", specifier = "==7.6.10" }, + { name = "pre-commit", specifier = "==4.0.1" }, + { name = "pyright", extras = ["nodejs"], specifier = "==1.1.399" }, + { name = "pytest", specifier = "==8.3.2" }, +] + [[package]] name = "pyftdi" version = "0.56.0" @@ -277,6 +295,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/5a/96/a8de7b7e5556d4b00d1ca1969fc34c89a1b6d177876c7a31d42631b090fc/pyftdi-0.56.0-py3-none-any.whl", hash = "sha256:3ef0baadbf9031dde9d623ae66fac2d16ded36ce1b66c17765ca1944cb38b8b0", size = 145718 }, ] +[[package]] +name = "pyright" +version = "1.1.399" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nodeenv" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/db/9d/d91d5f6d26b2db95476fefc772e2b9a16d54c6bd0ea6bb5c1b6d635ab8b4/pyright-1.1.399.tar.gz", hash = "sha256:439035d707a36c3d1b443aec980bc37053fbda88158eded24b8eedcf1c7b7a1b", size = 3856954 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/b5/380380c9e7a534cb1783c70c3e8ac6d1193c599650a55838d0557586796e/pyright-1.1.399-py3-none-any.whl", hash = "sha256:55f9a875ddf23c9698f24208c764465ffdfd38be6265f7faf9a176e1dc549f3b", size = 5592584 }, +] + +[package.optional-dependencies] +nodejs = [ + { name = "nodejs-wheel-binaries" }, +] + [[package]] name = "pyserial" version = "3.5"