SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: Motor.h
- Revision:
- 8:92f6baeea027
- Parent:
- 4:25e028102625
diff -r 2cb18392649d -r 92f6baeea027 Motor.h --- a/Motor.h Fri Feb 03 04:08:32 2017 +0000 +++ b/Motor.h Fri Feb 03 19:40:27 2017 +0000 @@ -1,5 +1,11 @@ #pragma once -#include "mbed.h" + +#include <mbed.h> + +#define MotorDir unsigned char +#define MDIR_Forward 1 +#define MDIR_Backward 0 + class Motor{ @@ -9,25 +15,25 @@ ~Motor(); - static void setLeftSpeed(int speed); + void Update(float deltaTime); + + void setLeftSpeed(float speed); + + void setRightSpeed(float speed); - static void setRightSpeed(int speed); + void setSpeeds(float speedLeft, float speedRight); + + void setLeftDirection(MotorDir dir); - static void setSpeeds(int speedLeft, int speedRight); + void setRightDirection(MotorDir dir); + + void setDirections(MotorDir dirL, MotorDir dirR); private: - - static inline void init() - { - static bool initialized = false; - - if(!initialized) - { - initialized = true; - initializeMotor(); - } - } + DigitalOut m_dirL; + DigitalOut m_dirR; - static void initializeMotor(); - + PwmOut m_pwmL; + PwmOut m_pwmR; + }; \ No newline at end of file