AP1017 library for the Rev.E hardware with expanded capabilities.

Fork of AP1017 by AKM Development Platform

Revision:
3:f8e70f639ed0
Parent:
2:8a644b1066c4
Child:
4:c36159701cde
--- a/AP1017.h	Mon Apr 17 19:17:25 2017 +0000
+++ b/AP1017.h	Wed Apr 19 23:13:04 2017 +0000
@@ -49,9 +49,6 @@
         DIRECTION_BRAKE = 0x04      /**< Brake motor */
     } Rotation;
 
-    float       getFrequency(void);
-    float       getDutyCycle(void);
-    Rotation    getDirection(void);
 
     /**
      * Sets the direction to clockwise, counterclockwise, brake or coast.
@@ -63,93 +60,71 @@
      * @return Returns successful termination, ERROR_MOTORON for invalid
      *          direction switching, or ERROR_DIRECTION for invalid direction.
      */
-    Status  setDirection(char dir);
+    Status  setDirection(Rotation dir);
+    
+    /**
+     * Returns the currently set direction.
+     */
+    Rotation getDirection(void);
 
     /**
-     * Sets the duty cycle in percentage. Also sets the pulse width in
-     * microseconds by calculation using current value of the period.
+     * Sets the speed via setting the duty cycle. Duty cycle given
+     * as a percentage.
      *
      * @param dc Duty cycle as a proportion (0.0 to 1.0).
      * @return Returns successful termination or dutyc cyle error.
      */
-    Status  setDutyCycle(float dc);
-
-    /**
-     * Sets the frequency of the motor in Hertz.
-     * 
-     * @param f Frequency (Hertz).
-     * @return Returns successful termination or frequency error.
-     */
-    Status  setFrequency(float freq);
+    Status  setSpeed(float dc);
 
     /**
-     * Sets the period in microseconds.  Also sets the pulse width by
-     * calculation with the current value of the duty cycle.  Period will be
-     * changed even if motor is currently running.
-     *
-     * @param per PWM Period in microseconds.
-     * @return Returns successful termination or period error.
+     * Returns the currently set speed as a percentage.
      */
-    Status  setPeriod_us(float per);
-
-    /**
-     * Sets the pulse with in microseconds.  Also sets the duty cycle by
-     * calculation with the current value of the period.  Pulse width will be
-     * changed even if motor is currently running.
-     *
-     * @param pw Pulse width in microseconds.
-     * @return Returns successful termination or pulse width error.
-     */
-    Status  setPulseWidth_us(float pw);
+    float getSpeed(void);
 
     /**
      * Engages the motor.
      *
      * @return Returns successful termination or pulse width error.
      */
-    Status  startMotor(void);
+    Status  start(void);
 
     /**
      * Stops forced rotation of the motor.
      *
      * @return Returns successful termination or pulse width error.
      */
-    Status  stopMotor(void);
+    Status  stop(void);
 
     /**
      * Applies forced braking of motor.
      *
      * @return Returns successful termination or pulse width error.
      */
-    Status  brakeMotor(void);
+    Status  brake(void);
 
     /**
      * Removes force from the motor and allows it to spin freely.
      *
      * @return Returns successful termination or pulse width error.
      */
-    Status  coastMotor(void);
+    Status  coast(void);
 
 private:
 
-    bool    motorOn;            // Status flag for the motor
-    float   dutyCycle;          // Given as proportion: 0.00 to 1.00
-    float   freq_hz;            // PWM frequency
-    float   pulseWidth_us;      // Pulse width in microseconds
-    float   pwmPeriod_us;       // PWM period in microseconds
-
-    PwmOut      *motor;          // Motor object
+    bool        motorOn;            // Status flag for the motor
+    float       dutyCycle;          // Given as proportion: 0.00 to 1.00
+    Rotation    direction;
     
-    DigitalOut  *inA;            // Directions setting pin A
-    DigitalOut  *inB;            // Direction setting pin B
+    PwmOut      *motor;             // Motor object
+    
+    DigitalOut  *inA;               // Directions setting pin A
+    DigitalOut  *inB;               // Direction setting pin B
     /* inA=L, inB=L -> Standby (Coast)
      * inA=H, inB=L -> Forward (CW)
      * inA=L, inB=H -> Reverse (CCW)
      * inA=H, inB=H -> Brake
      */
 
-    //Status  initMotors(void);
-
 };
 
 #endif
\ No newline at end of file