Skip to content

Commit db80b65

Browse files
committed
tests: Make pyb/timer test check callback timing properly.
1 parent 49d8e5e commit db80b65

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

tests/pyb/timer_callback.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,28 @@ def cb4(t):
2222
return cb4
2323

2424
# create a timer with a callback, using callback(None) to stop
25-
tim = Timer(1, freq=1000, callback=cb1)
26-
pyb.delay(10)
25+
tim = Timer(1, freq=100, callback=cb1)
26+
pyb.delay(5)
27+
print("before cb1")
28+
pyb.delay(15)
2729

2830
# create a timer with a callback, using deinit to stop
29-
tim = Timer(2, freq=1000, callback=cb2)
30-
pyb.delay(10)
31+
tim = Timer(2, freq=100, callback=cb2)
32+
pyb.delay(5)
33+
print("before cb2")
34+
pyb.delay(15)
3135

3236
# create a timer, then set the freq, then set the callback
3337
tim = Timer(4)
34-
tim.init(freq=2000)
38+
tim.init(freq=100)
3539
tim.callback(cb1)
36-
pyb.delay(10)
40+
pyb.delay(5)
41+
print("before cb1")
42+
pyb.delay(15)
3743

3844
# test callback with a closure
39-
tim.init(freq=3000)
45+
tim.init(freq=100)
4046
tim.callback(cb3(3))
41-
pyb.delay(10)
47+
pyb.delay(5)
48+
print("before cb4")
49+
pyb.delay(15)

tests/pyb/timer_callback.py.exp

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
before cb1
12
cb1
3+
before cb2
24
cb2
5+
before cb1
36
cb1
7+
before cb4
48
cb4 3

0 commit comments

Comments
 (0)