![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my new gear...
Diff: nap.cpp
- Revision:
- 0:1456b6f84c75
diff -r 000000000000 -r 1456b6f84c75 nap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nap.cpp Fri Feb 25 05:20:11 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; +}