First version of my PPM library.

Dependents:   PPM_Test QuadCopter Quadcopter_mk2

Have a look at PPM_Test to see how this library is used.

Import programPPM_Test

Test program for my PPM library.

Files at this revision

API Documentation at this revision

Comitter:
joe4465
Date:
Wed Apr 01 11:18:23 2015 +0000
Parent:
2:b67f18c84c05
Commit message:
...

Changed in this revision

Ppm.cpp Show annotated file Show diff for this revision Revisions of this file
Ppm.h Show annotated file Show diff for this revision Revisions of this file
diff -r b67f18c84c05 -r d13b9e50312f Ppm.cpp
--- a/Ppm.cpp	Wed Mar 04 18:49:31 2015 +0000
+++ b/Ppm.cpp	Wed Apr 01 11:18:23 2015 +0000
@@ -3,7 +3,7 @@
 //Ppm reader by Joe Roberts, based on work by John Wolter
 //This program takes the Ppm Signal (Pulse Position Modulation) from your RC transmitter and outputs the data between the min/max outputs passed into the constructor
 //See 
-Ppm::Ppm(PinName pin, float minimumOutput, float maximumOutput, int minimumPulseTime, int maximumPulseTime, int numberOfChannels, int throttleChannel) 
+Ppm::Ppm(PinName pin, int minimumOutput, int maximumOutput, int minimumPulseTime, int maximumPulseTime, int numberOfChannels, int throttleChannel) 
 {    
     //Assign local variables passed into constructor
     _ppmPin = new InterruptIn(pin);
@@ -80,7 +80,7 @@
 }
 
 //Place mapped channel data into the passed in array
-void Ppm::GetChannelData(float * channelData)
+void Ppm::GetChannelData(double* channelData)
 {
     //Iterate over the channel times array
     for(int i = 0; i < _numberOfChannels; i++)
@@ -90,14 +90,14 @@
         else
         {
             //Map the channel times to value between the channel min and channel max
-            channelData[i] = Map(_completeTimes[i] ,_minimumPulseTime, _maximumPulseTime, _minimumOutput, _maximumOutput);
+            channelData[i] = Map(_completeTimes[i] , _minimumPulseTime, _maximumPulseTime, _minimumOutput, _maximumOutput);
         }
     }
     
     return; 
 }
 
-float Ppm::Map(float input, float inputMin, float inputMax, float outputMin, float outputMax)
+double Ppm::Map(double input, double inputMin, double inputMax, double outputMin, double outputMax)
 {
     return (input - inputMin) * (outputMax - outputMin) / (inputMax - inputMin) + outputMin;
 }
\ No newline at end of file
diff -r b67f18c84c05 -r d13b9e50312f Ppm.h
--- a/Ppm.h	Wed Mar 04 18:49:31 2015 +0000
+++ b/Ppm.h	Wed Apr 01 11:18:23 2015 +0000
@@ -7,7 +7,7 @@
 {
     public:
         //Constructor
-        Ppm(PinName pin, float minimumOutput, float maximumOutput, int minimumPulseTime, int maximumPulseTime, int numberOfChannels, int throttleChannel);
+        Ppm(PinName pin, int minimumOutput, int maximumOutput, int minimumPulseTime, int maximumPulseTime, int numberOfChannels, int throttleChannel);
         
     private:
         //Interrupt
@@ -35,20 +35,20 @@
         //Minimum pulse time uS
         int _minimumPulseTime;
         //Maximum pulse time uS
-        int _maximumPulseTime;
+        double _maximumPulseTime;
         //Minimum output
-        float _minimumOutput;
+        double _minimumOutput;
         //Maximum output
-        float _maximumOutput;
+        double _maximumOutput;
         //Throttle channel - used for fail safe
         int _throttleChannel;
         
     public:
         //Get channel data
-        void GetChannelData(float * channelData);
+        void GetChannelData(double* channelData);
         
     private:
-        float Map(float input, float inputMin, float inputMax, float outputMin, float outputMax);
+        double Map(double input, double inputMin, double inputMax, double outputMin, double outputMax);
 };
 
 #endif