Timendainum

BWander.cpp

Nov 6th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include "BWander.h"
  2.  
  3. BWander::BWander()
  4. {}
  5.  
  6. //tasks
  7. // 0 - stop
  8. // 1 - foreward
  9.  
  10. void BWander::init()
  11. {
  12.     //Serial.println("***************************BWander.init() ");
  13.     last = timer.getTime();
  14.     going = false;
  15.  
  16.     addTask(new Stop());
  17.     addTask(new Forward());
  18.  
  19. }
  20.  
  21. void BWander::execute()
  22. {
  23.     //Serial.println("BWander.execute() taskcount: " + (String)taskCount);
  24.     if ((timer.getTime() - last) > 3000)
  25.     {
  26.         going = !going;
  27.         last = timer.getTime();
  28.     }
  29.  
  30.     if (going)
  31.     {
  32.         Serial.println("go!");
  33.         tasks[1]->execute();
  34.     }
  35.     else
  36.     {
  37.         Serial.println("stop!");
  38.         tasks[0]->execute();
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment