41f768f3f3
In tests/pyb is now a suite of tests that tests the pyb module on the pyboard. They include expected output files because we can't run CPython on the pyboard to compare against. run-tests script has now been updated to allow pyboard tests to be run. Just pass the option --pyboard. This runs all basic, float and pyb tests. Note that float/math-fun.py currently fails because not all math functions are implemented in stmhal/.
29 lines
471 B
Python
29 lines
471 B
Python
from pyb import Timer
|
|
|
|
tim = Timer(4)
|
|
tim = Timer(4, prescaler=100, period=200)
|
|
print(tim.prescaler())
|
|
print(tim.period())
|
|
tim.prescaler(300)
|
|
print(tim.prescaler())
|
|
tim.period(400)
|
|
print(tim.period())
|
|
|
|
tim = Timer(4, freq=1)
|
|
tim.init(freq=2000)
|
|
def f(t):
|
|
print(1)
|
|
t.callback(None)
|
|
tim.callback(f)
|
|
pyb.delay(10)
|
|
|
|
# f3 closes over f2.y
|
|
def f2(x):
|
|
y = x
|
|
def f3(t):
|
|
print(2, y)
|
|
t.callback(None)
|
|
return f3
|
|
tim.callback(f2(3))
|
|
pyb.delay(10)
|