Bradley Kohler
/
FRDM_Pacemaker
a pacemaker
clock.cpp@2:ab8469051a2d, 2016-10-26 (annotated)
- Committer:
- kohlerba
- Date:
- Wed Oct 26 14:04:14 2016 +0000
- Revision:
- 2:ab8469051a2d
- Parent:
- 1:446bd28a1f19
- Child:
- 3:334300ac49e5
pacing works with busy loops.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kohlerba | 0:9e97accb2a4c | 1 | #include "clock.h" |
kohlerba | 0:9e97accb2a4c | 2 | |
kohlerba | 0:9e97accb2a4c | 3 | Ticker tick; |
kohlerba | 0:9e97accb2a4c | 4 | double counter = 0; |
kohlerba | 0:9e97accb2a4c | 5 | |
kohlerba | 1:446bd28a1f19 | 6 | int start_clock(void){ |
kohlerba | 0:9e97accb2a4c | 7 | tick.attach(&count_time, 0.0001); |
kohlerba | 1:446bd28a1f19 | 8 | return 1; |
kohlerba | 0:9e97accb2a4c | 9 | } |
kohlerba | 0:9e97accb2a4c | 10 | |
kohlerba | 0:9e97accb2a4c | 11 | void count_time(void){ |
kohlerba | 0:9e97accb2a4c | 12 | counter += 0.0001; |
kohlerba | 0:9e97accb2a4c | 13 | } |
kohlerba | 0:9e97accb2a4c | 14 | |
kohlerba | 0:9e97accb2a4c | 15 | double get_time(void){ |
kohlerba | 0:9e97accb2a4c | 16 | return counter; |
kohlerba | 0:9e97accb2a4c | 17 | } |