![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my new gear...
nap.cpp@0:1456b6f84c75, 2022-02-25 (annotated)
- Committer:
- yootee
- Date:
- Fri Feb 25 05:20:11 2022 +0000
- Revision:
- 0:1456b6f84c75
my_custom
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yootee | 0:1456b6f84c75 | 1 | #include <nap.hpp> |
yootee | 0:1456b6f84c75 | 2 | |
yootee | 0:1456b6f84c75 | 3 | NAP::NAP(float nap_time):nap_time_(nap_time){ |
yootee | 0:1456b6f84c75 | 4 | restart(); |
yootee | 0:1456b6f84c75 | 5 | } |
yootee | 0:1456b6f84c75 | 6 | |
yootee | 0:1456b6f84c75 | 7 | void NAP::take_a_nap(){ |
yootee | 0:1456b6f84c75 | 8 | while((now_time - prev_time) < (nap_time_*1000)){ |
yootee | 0:1456b6f84c75 | 9 | now_time = nap.read_ms(); |
yootee | 0:1456b6f84c75 | 10 | } |
yootee | 0:1456b6f84c75 | 11 | prev_time = now_time; |
yootee | 0:1456b6f84c75 | 12 | } |
yootee | 0:1456b6f84c75 | 13 | |
yootee | 0:1456b6f84c75 | 14 | void NAP::setNaptime(float nap_time){ |
yootee | 0:1456b6f84c75 | 15 | nap_time_ = nap_time; |
yootee | 0:1456b6f84c75 | 16 | } |
yootee | 0:1456b6f84c75 | 17 | |
yootee | 0:1456b6f84c75 | 18 | void NAP::restart(){ |
yootee | 0:1456b6f84c75 | 19 | nap.reset(); |
yootee | 0:1456b6f84c75 | 20 | nap.start(); |
yootee | 0:1456b6f84c75 | 21 | now_time = 0; |
yootee | 0:1456b6f84c75 | 22 | prev_time = 0; |
yootee | 0:1456b6f84c75 | 23 | } |