mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add timer tests script.
This commit is contained in:
parent
c4669c8fba
commit
9a90204921
25
scripts/examples/02-Board-Control/timer_tests.py
Normal file
25
scripts/examples/02-Board-Control/timer_tests.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Timer Test Example
|
||||||
|
#
|
||||||
|
# This example tests all the timers.
|
||||||
|
|
||||||
|
import time
|
||||||
|
from pyb import Pin, Timer, LED
|
||||||
|
|
||||||
|
blue_led = LED(3)
|
||||||
|
|
||||||
|
# Note: functions that allocate memory are Not allowed in callbacks
|
||||||
|
def tick(timer):
|
||||||
|
blue_led.toggle()
|
||||||
|
|
||||||
|
print("")
|
||||||
|
for i in range(1, 18):
|
||||||
|
try:
|
||||||
|
print("Testing TIM%d... "%(i), end="")
|
||||||
|
tim = Timer(i, freq=10) # create a timer object using timer 4 - trigger at 1Hz
|
||||||
|
tim.callback(tick) # set the callback to our tick function
|
||||||
|
time.sleep(1000)
|
||||||
|
tim.deinit()
|
||||||
|
except ValueError as e:
|
||||||
|
print(e)
|
||||||
|
continue
|
||||||
|
print("done!")
|
||||||
Loading…
Reference in New Issue
Block a user