Guest User

Untitled

a guest
Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include "TimedAction.h"
  2.  
  3. /*
  4. || <<constructor>>
  5. */
  6. TimedAction::TimedAction(unsigned long intervl,void (*function)()){
  7. active = true;
  8. previous = 0;
  9. interval = intervl;
  10. execute = function;
  11. }
  12.  
  13. /*
  14. || <<constructor>>
  15. */
  16. TimedAction::TimedAction(unsigned long prev,unsigned long intervl,void (*function)()){
  17. active = true;
  18. previous = prev;
  19. interval = intervl;
  20. execute = function;
  21. }
  22.  
  23. void TimedAction::reset(){
  24. previous = millis();
  25. }
  26.  
  27. void TimedAction::disable(){
  28. active = false;
  29. }
  30.  
  31. void TimedAction::enable(){
  32. active = true;
  33. }
  34.  
  35. void TimedAction::check(){
  36. if ( active && (millis()-previous >= interval) ) {
  37. previous = millis();
  38. execute();
  39. }
  40. }
  41.  
  42. void TimedAction::setInterval( unsigned long intervl){
  43. interval = intervl;
  44. }
Add Comment
Please, Sign In to add comment