db

Files at this revision

API Documentation at this revision

Comitter:
japanet
Date:
Fri Oct 30 08:20:23 2015 +0000
Commit message:
d;

Changed in this revision

potensyon.cpp Show annotated file Show diff for this revision Revisions of this file
potensyon.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/potensyon.cpp	Fri Oct 30 08:20:23 2015 +0000
@@ -0,0 +1,18 @@
+#include "potensyon.h"
+
+potensyon::potensyon(AnalogIn *_ain):ain(_ain)//(PinName pin):ain(pin)
+{
+    rate=0;
+}
+
+double potensyon::angle() {
+    //double ans=ain.read();
+    double ans=ain->read();
+    double prev=0;    
+        
+    //prev = ain.read();    
+    prev = ain->read();
+    ans = (0.95 * ans + 0.05 * prev);  
+    f=ans*rate;
+    return f;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/potensyon.h	Fri Oct 30 08:20:23 2015 +0000
@@ -0,0 +1,33 @@
+#ifndef MBED_potensyon_H
+#define MBED_potensyon_H
+ 
+#include "mbed.h"
+ 
+class potensyon
+{
+    AnalogIn *ain;
+    public:
+    potensyon(AnalogIn *_ain/*PinName*/);
+    potensyon& operator=(int i) 
+    {
+        rate=i;
+        return *this;
+    }
+    
+    operator double()
+    {
+        return f;
+    }
+    
+   // ~AnalogIn();
+       int rate;
+    double angle ();
+        double f;
+    
+ 
+private:
+    //ain = new AnalogIn();
+    //AnalogIn ain;
+};
+ 
+#endif  //  MBED_potensyon_H
\ No newline at end of file