Tarek Lule / MotorLib

Fork of MotorLib by CreaLab

Revision:
10:1df5a7a265e8
Parent:
9:5983c10d5f8e
Child:
11:25d26c72a2f7
--- a/motor.h	Mon Jul 17 14:02:22 2017 +0000
+++ b/motor.h	Thu Jul 27 07:25:47 2017 +0000
@@ -50,10 +50,18 @@
     void TestMotor();
     void RunMotor();
     void setMotorCallback(void (*mIT)());
-    void setMotorCallback(void (*mIT)(), bool onStop);
+     void setMotorCallback(void (*mIT)(), bool itOnStop);
+ 
+template<typename T>
+void setMotorCallback(T *object, void (T::*member)(void))
+{
+    _callback = callback(object,member);
+    itOnStop = true;
+}
+ 
     void removeMotorCallback();
 
-    
+    uint32_t getCalibration();    
     void setCalibration(uint32_t nbTicksforFullTurn);
     void setDelayBtwTicks(uint32_t tickTime); // in ms
     void setSpeed(float sForOneTurn) ;// nb of s to get rotation of 360° (if 20s, the motor will do 360° in 20 s). 
@@ -65,7 +73,7 @@
     void SetZero();
     
     MotorStateList getState();
-   
+    
     private:
     void initialization(PinName _MPh0, PinName _MPh1, PinName _MPh2, PinName _MPh3, uint32_t TickTime);
  
@@ -75,7 +83,8 @@
     void LeftMotor();
     void RightMotor();
     void ProcessMotorStateMachine();
-
+    Timer tuneTimings;
+uint32_t last;
     DigitalOut *MPh0, *MPh1, *MPh2, *MPh3;
     
     int MotorIndex;    // --- Motor Variable
@@ -86,8 +95,11 @@
     uint32_t    MotorFullTurn;  // Number of step for a complete turn
  //   uint32_t    NumWires;       // Number of Wires
     int32_t    NumSteps;       // Number of Steps = NumWire * MotorFullTurn
+    Callback<void()> _callback;
+
     void (*motorCallback)();
     bool itOnStop;
+    bool toremove;
 };
 
 #endif
\ No newline at end of file