David's line following code from the LVBots competition, 2015.
Dependencies: GeneralDebouncer Pacer PololuEncoder mbed
Fork of DeadReckoning by
Diff: turn_sensor.h
- Revision:
- 44:edcacba44760
- Child:
- 50:517c0f0e621f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/turn_sensor.h Wed Apr 15 19:14:39 2015 +0000 @@ -0,0 +1,35 @@ +#pragma once + +#include <mbed.h> + +class TurnSensor +{ + // TODO: for production code, you would want a way to set the gyro offset + + public: + + void start(); + void update(); + + int32_t getAngle() + { + return (int32_t)angleUnsigned; + } + + int16_t getAngleDegrees() + { + return (((int32_t)angleUnsigned >> 16) * 360) >> 16; + } + + int16_t getRate() + { + return rate; + } + + private: + + Timer timer; + uint32_t angleUnsigned; + int16_t rate; + uint16_t gyroLastUpdate; +}; \ No newline at end of file