![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my new gear...
Diff: control_theory/nap.cpp
- Revision:
- 3:a9b4b2565a23
- Parent:
- 0:1456b6f84c75
- Child:
- 6:e7f2335456c8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/control_theory/nap.cpp Sun Mar 27 04:51:16 2022 +0000 @@ -0,0 +1,23 @@ +#include <nap.hpp> + +NAP::NAP(float nap_time):nap_time_(nap_time){ + restart(); +} + +void NAP::take_a_nap(){ + while((now_time - prev_time) < (nap_time_*1000)){ + now_time = nap.read_ms(); + } + prev_time = now_time; +} + +void NAP::setNaptime(float nap_time){ + nap_time_ = nap_time; +} + +void NAP::restart(){ + nap.reset(); + nap.start(); + now_time = 0; + prev_time = 0; +}