Newer
Older
TestStandRepository / Software / Arduino / libraries / Arduino-Libraries / TemperatureController / DoEvery.cpp
  1. /**********************************************************************************************
  2. *
  3. * This Code is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
  4. **********************************************************************************************/
  5.  
  6. #include <DoEvery.h>
  7.  
  8. DoEvery::DoEvery(long _period) {
  9. period=_period;
  10. lastTime=0;
  11. }
  12.  
  13. void DoEvery::reset() {
  14. lastTime=millis();
  15. }
  16.  
  17. bool DoEvery::check() {
  18. if (millis()-lastTime > period) {
  19. lastTime+=period;
  20. return true;
  21. } else {
  22. return false;
  23. }
  24. }
  25.  
  26. bool DoEvery::before(double threshTime) {
  27. if (threshTime>=period) return true;
  28. if (millis()-lastTime < threshTime) {
  29. return true;
  30. } else {
  31. return false;
  32. }
  33. }