From 6f418fc1b068c1a41113bb2b019a5803765e1deb Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Tue, 22 Jul 2014 07:57:36 -0700 Subject: Add support for selecting pin alternate functions from python. Converts generted pins to use qstrs instead of string pointers. This patch also adds the following functions: pyb.Pin.names() pyb.Pin.af_list() pyb.Pin.gpio() dir(pyb.Pin.board) and dir(pyb.Pin.cpu) also produce useful results. pyb.Pin now takes kw args. pyb.Pin.__str__ now prints more useful information about the pin configuration. I found the following functions in my boot.py to be useful: ```python def pins(): for pin_name in dir(pyb.Pin.board): pin = pyb.Pin(pin_name) print('{:10s} {:s}'.format(pin_name, str(pin))) def af(): for pin_name in dir(pyb.Pin.board): pin = pyb.Pin(pin_name) print('{:10s} {:s}'.format(pin_name, str(pin.af_list()))) ``` --- teensy/memzip_files/boot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'teensy/memzip_files/boot.py') diff --git a/teensy/memzip_files/boot.py b/teensy/memzip_files/boot.py index 4702d7b5d..6dd5516a9 100644 --- a/teensy/memzip_files/boot.py +++ b/teensy/memzip_files/boot.py @@ -1,2 +1,12 @@ import pyb print("Executing boot.py") + +def pins(): + for pin_name in dir(pyb.Pin.board): + pin = pyb.Pin(pin_name) + print('{:10s} {:s}'.format(pin_name, str(pin))) + +def af(): + for pin_name in dir(pyb.Pin.board): + pin = pyb.Pin(pin_name) + print('{:10s} {:s}'.format(pin_name, str(pin.af_list()))) -- cgit v1.2.3