Motor
Fork of Motor by
Diff: motor.h
- Revision:
- 5:99fa6dffea40
- Parent:
- 3:94db629c0a83
- Child:
- 6:37199f371bf8
diff -r 94db629c0a83 -r 99fa6dffea40 motor.h --- a/motor.h Sat Sep 14 17:18:51 2013 +0000 +++ b/motor.h Mon Sep 16 17:53:13 2013 +0000 @@ -6,6 +6,9 @@ #include "qed.h" class Motor { +protected: + FunctionPointer stallWarningCallback; + FunctionPointer stallErrorCallback; public: Motor(PinName PWMpin, PCA9555 *ioExt, unsigned int dir1Pin, unsigned int dir2Pin, PinName encA, PinName encB); @@ -13,6 +16,20 @@ void setSpeed(int newSpeed); int getSpeed(); void pid(); + + void stallWarning(void (*function)(void)); + + template<typename T> + void stallWarning(T *object, void (T::*member)(void)) { + stallWarningCallback.attach(object, member); + } + + void stallError(void (*function)(void)); + + template<typename T> + void stallError(T *object, void (T::*member)(void)) { + stallErrorCallback.attach(object, member); + } private: PwmOut pwm; @@ -26,8 +43,6 @@ void resetPID(); - //void pid(); - int setPoint; int pMulti; int iDiv; @@ -40,6 +55,10 @@ int minPwm; int pidMulti; int iMax; + + int currentPWM; + int stallCounter; + int stallCounterLimit; }; #endif \ No newline at end of file