![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my new gear...
control_theory/nap.cpp
- Committer:
- yootee
- Date:
- 2022-04-09
- Revision:
- 6:e7f2335456c8
- Parent:
- 3:a9b4b2565a23
File content as of revision 6:e7f2335456c8:
#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; if(prev_time > 18000000){ now_time = 0; prev_time = 0; nap.reset(); nap.start(); } } void NAP::setNaptime(float nap_time){ nap_time_ = nap_time; } void NAP::restart(){ nap.reset(); nap.start(); now_time = 0; prev_time = 0; }