p kj
/
MKS22-CubeFine
LPC824
Fork of CubeFine by
Diff: Microduino_Motor.h
- Revision:
- 0:362c1482232c
- Child:
- 2:7964622fb5a5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Microduino_Motor.h Thu Jun 02 04:03:31 2016 +0000 @@ -0,0 +1,46 @@ +#ifndef Motor_h +#define Motor_h + +//#include "Arduino.h" +#include "mbed.h" + +#define CHAN_LEFT 0 +#define CHAN_RIGHT 1 + +#if 0 +typedef struct { + uint8_t nbr_A :6 ; + uint8_t nbr_B :6 ; +} MotorPin_t; +#else +typedef struct { + PinName nbr_A; + PinName nbr_B; +} MotorPin_t; + +#endif + +typedef struct { + MotorPin_t Pin; +} motor_t; + +class Motor +{ +public: + Motor(PinName _motor_pinA, PinName _motor_pinB); + void Fix(float _fix); + void Driver(int16_t _motor_driver); + void Free(); + void Brake(); + int16_t GetData(int16_t _throttle, int16_t _steering, uint8_t _dir); +private: + uint8_t motorIndex; // index into the channel data for this key + float fix; + int16_t _motor_vol; +protected: + pwmout_t _pwmA; + pwmout_t _pwmB; + int _period_us; +}; + +#endif \ No newline at end of file