David's line following code from the LVBots competition, 2015.
Dependencies: GeneralDebouncer Pacer PololuEncoder mbed
Fork of DeadReckoning by
Diff: main.cpp
- Revision:
- 12:835a4d24ae3b
- Parent:
- 10:e4dd36148539
- Child:
- 16:8eaa5bc2bdb1
--- a/main.cpp Sat Feb 22 04:53:35 2014 +0000 +++ b/main.cpp Sun Feb 23 22:23:34 2014 +0000 @@ -6,6 +6,7 @@ #include "leds.h" #include "pc_serial.h" #include "test.h" +#include "reckoner.h" int __attribute__((noreturn)) main() { @@ -18,10 +19,35 @@ // Test routines //testMotors(); //testEncoders(); - testLineSensors(); + //testLineSensors(); + testReckoner(); while(1) { } } + +void updateReckonerFromEncoders() +{ + while(encoderBuffer.hasEvents()) + { + PololuEncoderEvent event = encoderBuffer.readEvent(); + switch(event) + { + case ENCODER_LEFT | POLOLU_ENCODER_EVENT_INC: + reckoner.handleTickLeftForward(); + break; + case ENCODER_LEFT | POLOLU_ENCODER_EVENT_DEC: + reckoner.handleTickLeftBackward(); + break; + case ENCODER_RIGHT | POLOLU_ENCODER_EVENT_INC: + reckoner.handleTickRightForward(); + break; + case ENCODER_RIGHT | POLOLU_ENCODER_EVENT_DEC: + reckoner.handleTickRightBackward(); + break; + + } + } +}