Updated for the next revision of the motor board
Diff: MotorShield.h
- Revision:
- 3:2f46953e7c8b
- Parent:
- 1:4c3c2b7337a6
- Child:
- 5:d2dffc88e94d
diff -r 30503be9a375 -r 2f46953e7c8b MotorShield.h --- a/MotorShield.h Wed Aug 26 00:24:51 2020 +0000 +++ b/MotorShield.h Wed Aug 26 02:43:57 2020 +0000 @@ -1,33 +1,22 @@ /* Library to interface with 2.74 Motor Shield -** Uses a modified version of FastPWM library to improve PWM accuracy +** Uses low level HAL libraries to enable high speed PWM */ - - class MotorShield { public: - /** Receives two PinName variables. - * @param echoPin mbed pin to which the echo signal is connected to - * @param triggerPin mbed pin to which the trigger signal is connected to - */ - MotorShield(PinName forwardPin, PinName reversePin); - - /** Calculates the distance in cm, with the calculation time of 25 ms. - * @returns distance of the measuring object in cm. - */ - void write(double duty_cycle); - void period(double period); - void direction(int direction); + MotorShield(int periodTicks); + void motorAWrite(double duty_cycle, int direction); + void motorBWrite(double duty_cycle, int direction); + void motorCWrite(double duty_cycle, int direction); + void motorDWrite(double duty_cycle, int direction); + void changePeriod(int periodTicks); private: - int direction_val; - double duty_cycle_val; - double period_val; + int periodTickVal; + void init(); - void init(); - void writePWM(); };