Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
db80b654
Commit
db80b654
authored
Mar 20, 2015
by
Damien George
Browse files
tests: Make pyb/timer test check callback timing properly.
parent
49d8e5eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/pyb/timer_callback.py
View file @
db80b654
...
...
@@ -22,20 +22,28 @@ def cb3(x):
return
cb4
# create a timer with a callback, using callback(None) to stop
tim
=
Timer
(
1
,
freq
=
1000
,
callback
=
cb1
)
pyb
.
delay
(
10
)
tim
=
Timer
(
1
,
freq
=
100
,
callback
=
cb1
)
pyb
.
delay
(
5
)
print
(
"before cb1"
)
pyb
.
delay
(
15
)
# create a timer with a callback, using deinit to stop
tim
=
Timer
(
2
,
freq
=
1000
,
callback
=
cb2
)
pyb
.
delay
(
10
)
tim
=
Timer
(
2
,
freq
=
100
,
callback
=
cb2
)
pyb
.
delay
(
5
)
print
(
"before cb2"
)
pyb
.
delay
(
15
)
# create a timer, then set the freq, then set the callback
tim
=
Timer
(
4
)
tim
.
init
(
freq
=
20
00
)
tim
.
init
(
freq
=
1
00
)
tim
.
callback
(
cb1
)
pyb
.
delay
(
10
)
pyb
.
delay
(
5
)
print
(
"before cb1"
)
pyb
.
delay
(
15
)
# test callback with a closure
tim
.
init
(
freq
=
30
00
)
tim
.
init
(
freq
=
1
00
)
tim
.
callback
(
cb3
(
3
))
pyb
.
delay
(
10
)
pyb
.
delay
(
5
)
print
(
"before cb4"
)
pyb
.
delay
(
15
)
tests/pyb/timer_callback.py.exp
View file @
db80b654
before cb1
cb1
before cb2
cb2
before cb1
cb1
before cb4
cb4 3
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment