CircuitPython 9 on Raspberry Pi Pico 2 to get info

Simple CircuitPython code run on Raspberry Pi Pico 2/CircuitPython 9 to get info and pin alias.

cpy_pico2_info.py

import os, sys
import microcontroller
import board

print("====================================")
print(sys.implementation[0], os.uname()[3],
      "\nrun on", os.uname()[4])
print("====================================")
print()

# List all the Available Names
# ref: https://learn.adafruit.com/circuitpython-essentials/circuitpython-pins-and-modules#what-are-all-the-available-names-3082670

board_pins = []
for pin in dir(microcontroller.pin):
    if isinstance(getattr(microcontroller.pin, pin), microcontroller.Pin):
        pins = []
        for alias in dir(board):
            if getattr(board, alias) is getattr(microcontroller.pin, pin):
                pins.append("board.{}".format(alias))
        if len(pins) > 0:
            board_pins.append(" ".join(pins))

for pins in sorted(board_pins):
    print(pins)


output
====================================
circuitpython 9.2.0 on 2024-10-28 
run on Raspberry Pi Pico 2 with rp2350a
====================================

board.A0 board.GP26 board.GP26_A0
board.A1 board.GP27 board.GP27_A1
board.A2 board.GP28 board.GP28_A2
board.A3 board.VOLTAGE_MONITOR
board.GP0
board.GP1
board.GP10
board.GP11
board.GP12
board.GP13
board.GP14
board.GP15
board.GP16
board.GP17
board.GP18
board.GP19
board.GP2
board.GP20
board.GP21
board.GP22
board.GP23 board.SMPS_MODE
board.GP24 board.VBUS_SENSE
board.GP25 board.LED
board.GP3
board.GP4
board.GP5
board.GP6
board.GP7
board.GP8
board.GP9


Comments

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

my dev.tools - FNIRSI 2C23T 3-in-1 Dual Channel Oscilloscope/Multimeter/Signal Generator