Merge pull request #1824 from kattni/i2s-template
Add I2S pin script, fix cap-touch script
This commit is contained in:
commit
00934d8c82
5 changed files with 80 additions and 7 deletions
|
|
@ -31,7 +31,7 @@ def get_unique_pins():
|
|||
"DOTSTAR_DATA",
|
||||
"APA102_SCK",
|
||||
"APA102_MOSI",
|
||||
"L",
|
||||
"LED",
|
||||
"SWITCH",
|
||||
"BUTTON",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
CircuitPython_Templates/cap_touch_pin_script/code.py 7: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
|
||||
|
|
@ -17,7 +17,7 @@ def is_touch_capable(pin_name):
|
|||
else:
|
||||
return False # Otherwise, the pins are invalid.
|
||||
except TypeError: # Error returned when checking a non-pin object in dir(board).
|
||||
pass # Passes over non-pin objects in dir(board).
|
||||
return False # Invalid if non-pin objects in dir(board).
|
||||
|
||||
|
||||
def get_pin_names():
|
||||
|
|
|
|||
|
|
@ -16,10 +16,27 @@ def is_hardware_i2c(scl, sda):
|
|||
|
||||
|
||||
def get_unique_pins():
|
||||
exclude = ['NEOPIXEL', 'APA102_MOSI', 'APA102_SCK']
|
||||
pins = [pin for pin in [
|
||||
getattr(board, p) for p in dir(board) if p not in exclude]
|
||||
if isinstance(pin, Pin)]
|
||||
exclude = [
|
||||
getattr(board, p)
|
||||
for p in [
|
||||
# This is not an exhaustive list of unexposed pins. Your results
|
||||
# may include other pins that you cannot easily connect to.
|
||||
"NEOPIXEL",
|
||||
"DOTSTAR_CLOCK",
|
||||
"DOTSTAR_DATA",
|
||||
"APA102_SCK",
|
||||
"APA102_MOSI",
|
||||
"LED",
|
||||
"SWITCH",
|
||||
"BUTTON",
|
||||
]
|
||||
if p in dir(board)
|
||||
]
|
||||
pins = [
|
||||
pin
|
||||
for pin in [getattr(board, p) for p in dir(board)]
|
||||
if isinstance(pin, Pin) and pin not in exclude
|
||||
]
|
||||
unique = []
|
||||
for p in pins:
|
||||
if p not in unique:
|
||||
|
|
|
|||
57
CircuitPython_Templates/i2s_find_pins/code.py
Normal file
57
CircuitPython_Templates/i2s_find_pins/code.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
"""
|
||||
CircuitPython I2S Pin Combination Identification Script
|
||||
"""
|
||||
import board
|
||||
import audiobusio
|
||||
from microcontroller import Pin
|
||||
|
||||
|
||||
def is_hardware_i2s(bit_clock, word_select, data):
|
||||
try:
|
||||
p = audiobusio.I2SOut(bit_clock, word_select, data)
|
||||
p.deinit()
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def get_unique_pins():
|
||||
exclude = [
|
||||
getattr(board, p)
|
||||
for p in [
|
||||
# This is not an exhaustive list of unexposed pins. Your results
|
||||
# may include other pins that you cannot easily connect to.
|
||||
"NEOPIXEL",
|
||||
"DOTSTAR_CLOCK",
|
||||
"DOTSTAR_DATA",
|
||||
"APA102_SCK",
|
||||
"APA102_MOSI",
|
||||
"LED",
|
||||
"SWITCH",
|
||||
"BUTTON",
|
||||
]
|
||||
if p in dir(board)
|
||||
]
|
||||
pins = [
|
||||
pin
|
||||
for pin in [getattr(board, p) for p in dir(board)]
|
||||
if isinstance(pin, Pin) and pin not in exclude
|
||||
]
|
||||
unique = []
|
||||
for p in pins:
|
||||
if p not in unique:
|
||||
unique.append(p)
|
||||
return unique
|
||||
|
||||
|
||||
for bit_clock_pin in get_unique_pins():
|
||||
for word_select_pin in get_unique_pins():
|
||||
for data_pin in get_unique_pins():
|
||||
if bit_clock_pin is word_select_pin or bit_clock_pin is data_pin or word_select_pin \
|
||||
is data_pin:
|
||||
continue
|
||||
if is_hardware_i2s(bit_clock_pin, word_select_pin, data_pin):
|
||||
print("Bit clock pin:", bit_clock_pin, "\t Word select pin:", word_select_pin,
|
||||
"\t Data pin:", data_pin)
|
||||
else:
|
||||
pass
|
||||
Loading…
Reference in a new issue