Speed profile working

Fork of Easyspin_lib by Julien Tiron

Revision:
1:9efe863db15e
Parent:
0:cba942f8172a
--- a/easyspin.h	Tue Jul 07 20:35:36 2015 +0000
+++ b/easyspin.h	Wed Aug 26 13:35:55 2015 +0000
@@ -21,12 +21,6 @@
 //#define _DEBUG_Easyspin
 #endif
 
-#ifdef _DEBUG_Easyspin
-/// Size of the log buffer
-#define DEBUG_BUFFER_SIZE    (75)
-/// Log buffer
-extern char EasyspinStrOut[DEBUG_BUFFER_SIZE];
-#endif
 
 /// Clear bit Macro 
 #ifndef cbi
@@ -355,6 +349,12 @@
   BACKWARD = 0
 } dir_t;
 
+///  Rotation options
+typedef enum {
+  RIGHT = 1,
+  LEFT = 0
+} rot_t;
+
 /// Shield state
 typedef enum {
   ACCELERATING = 0, 
@@ -441,6 +441,8 @@
     bool SetMinSpeed(uint8_t shieldId,uint16_t newMinSpeed); //Set the min speed in pps   
     bool SoftStop(uint8_t shieldId);                         //Progressively stops the motor 
     void WaitWhileActive(uint8_t shieldId);                  //Wait for the shield state becomes Inactive
+    void Turn(rot_t rotation, uint16_t angle);               //Turn left or right with the specified angle
+    void Move_cm(dir_t direction, uint16_t distance);        //Go forward or backward with the specified distance
     ///@}
     
     /// @defgroup group2 Easyspin control functions
@@ -463,17 +465,6 @@
     void SetDirection(uint8_t shieldId,             //Set the Easyspin direction pin
                               dir_t direction);      
     ///@}
-    
-    /// @defgroup group3 Delay functions
-    ///@{
-    /// @brief Required when 3 Easyspin shields are used 
-    /// to avoid conflicting depencieswith wiring.c 
-    /// (redefinition of ISR(TIMER0_OVF_vect).  
-    /// When only 2 Easyspin shields are used, prefer the use 
-    /// of standard Arduino functions (delay, delayMicroseconds).
-    static void WaitMs(uint16_t msDelay); // Wait for a delay in ms
-    static void WaitUs(uint16_t usDelay); // Wait for a delay in us
-    ///@}
         
     /// @defgroup group4 Functions for timer ISRs only
     /// @brief To be used inside the library by the timer ISRs only 
@@ -500,16 +491,21 @@
     void StartMovement(uint8_t shieldId);
     uint8_t Tval_Current_to_Par(double Tval);
     uint8_t Tmin_Time_to_Par(double Tmin);
+    void tick1();
+    void tick2();
     
     // variable members
     DigitalOut dir1;   
     DigitalOut dir2;
     DigitalOut dir3;
-    PwmOut pwm1;
-    PwmOut pwm2;
-    PwmOut pwm3;
+    DigitalOut pwm1;
+    DigitalOut pwm2;
+    DigitalOut pwm3;
     DigitalOut reset;       
     DigitalOut CS;
+    Ticker ticker1;
+    Ticker ticker2;
+    Ticker ticker3;
     InterruptIn flag;
     SPI spi;
     shieldParams_t shieldPrm[MAX_NUMBER_OF_SHIELDS];