yotaro morizumi
/
zoomy_customLibrary
my new gear...
control_theory/nap.cpp@3:a9b4b2565a23, 2022-03-27 (annotated)
- Committer:
- yootee
- Date:
- Sun Mar 27 04:51:16 2022 +0000
- Revision:
- 3:a9b4b2565a23
- Parent:
- nap.cpp@0:1456b6f84c75
- Child:
- 6:e7f2335456c8
my new gear...
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 | } |