2015-02-23 06:18:33 -07:00
|
|
|
# check basic functionality of the timer class
|
|
|
|
|
2014-05-04 05:40:51 -06:00
|
|
|
import pyb
|
2014-05-03 09:43:27 -06:00
|
|
|
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())
|
2019-10-30 19:49:18 -06:00
|
|
|
|
|
|
|
# Setting and printing frequency
|
|
|
|
tim = Timer(2, freq=100)
|
|
|
|
print(tim.freq())
|
|
|
|
tim.freq(0.001)
|
2019-12-19 22:42:38 -07:00
|
|
|
print('{:.3f}'.format(tim.freq()))
|