Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. bool isStall(float count) {
  2. bool leftStall = false;
  3. bool rightStall = false;
  4.  
  5. int leftStartCount = left_encoder.Counts();
  6. int rightStartCount = right_encoder.Counts();
  7. //Wait 500 ms to reread encoder counts
  8. float start = TimeNow();
  9. while (TimeNow() - start < 0.3) {
  10. if (right_encoder.Counts() > count) {
  11. return false;
  12. }
  13. }
  14. int leftEndCount = left_encoder.Counts();
  15. int rightEndCount = right_encoder.Counts();
  16. if (rightEndCount - rightStartCount < 5) {
  17. rightStall = true;
  18. LCD.WriteRC("!!!-----R STALL------!!!",9,1);
  19. }
  20. if (leftEndCount - leftStartCount < 5) {
  21. leftStall = true;
  22. LCD.WriteRC("!!!-----L STALL------!!!",10,1);
  23. }
  24.  
  25. return leftStall && rightStall;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement