Advertisement
Guest User

moveTo fix 1

a guest
Dec 1st, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. void loop() {
  2. timeCheck = micros();
  3. if ( wheelTIME == 0 || timeCheck - toggleTIME >= WHEEL_TIMEOUT ) {
  4. rpm = 0;
  5.  
  6. /* At time = 0 or time between timer
  7. * updates is too large, RPM is zero */
  8.  
  9. }
  10. else {
  11. rpm = (float) TIMER_TO_RPM / (float) wheelTIME;
  12. }
  13.  
  14. bikeSPEED = rpm * (float) RPM_TO_SPEED; // Calculate bike speed and determine gear
  15. getGear( bikeSPEED );
  16.  
  17. //moveSweep();
  18.  
  19. if( gear != lastGEAR ) {
  20.  
  21. /* If gear has changed, detach interrupt
  22. * and allow derailleur to shift */
  23.  
  24. detachInterrupt( wheel_ISR );
  25. moveTo ( shiftPosition[ gear ] );
  26. attachInterrupt( 1, wheel_ISR, FALLING );
  27. }
  28.  
  29. lastGEAR = gear; // Update last gear value
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement