Updated version of RenBuggy Servo that can accept instructions based on time or distance.
Fork of RenBuggyServo by
Diff: Car.h
- Revision:
- 1:3e1290de9c8d
- Parent:
- 0:d388aed56112
- Child:
- 2:287a808baad7
diff -r d388aed56112 -r 3e1290de9c8d Car.h --- a/Car.h Fri Mar 07 07:54:13 2014 +0000 +++ b/Car.h Mon Mar 10 10:15:22 2014 +0000 @@ -32,18 +32,29 @@ class Car { private: + PwmOut m_servo; PwmOut m_motor; - int m_pwmPeriod; // Period used in PWM. + + int m_speed; + int m_servoRange; // Pulsewidth range to full left/right from centre (1.5ms) float m_servoDegrees; // Angle to full right/left turn from centre (0). - float distanceToTimeConverter(float distance); + + float m_wheelCircumference; // The circumference of the wheel with stripes. + int m_countsPerRevolution; // The number of stripes on the wheel. + //InterruptIn m_stripeInterrupt; + + //float distanceToTimeConverter(float distance); + public: + Car(PinName servoPin, PinName motorPin); + Car(PinName servoPin, PinName motorPin, int countsPerRevolution, float wheelCircumference); ~Car(); + void setSpeed(int speed_us); void forwards(float distance); - void forwards(int speed); void forwards(); void stop(); void setDirection(int degrees); @@ -53,6 +64,8 @@ void configureMotor_us(int pulsewidth_us, int period_us); void configureMotor_ms(int pulsewidth_ms, int period_ms); + + void configureEncoder(int countsPerRevolution, float wheelCircumference); }; #endif // CAR_H \ No newline at end of file