filtering the signal needs tweaking but timing works,

Fork of SigInterpreter by Fabian van Hummel

Files at this revision

API Documentation at this revision

Comitter:
fabian101
Date:
Fri Oct 28 12:48:27 2016 +0000
Parent:
1:665ee7703fbe
Commit message:
28-10 friday, filtering is implemented but needs tweaking;

Changed in this revision

SigInterpreter.cpp Show annotated file Show diff for this revision Revisions of this file
SigInterpreter.h Show annotated file Show diff for this revision Revisions of this file
--- a/SigInterpreter.cpp	Fri Oct 21 09:12:19 2016 +0000
+++ b/SigInterpreter.cpp	Fri Oct 28 12:48:27 2016 +0000
@@ -1,36 +1,68 @@
 #include "SigInterpreter.h"
 
+BiQuadChain bqc;
+BiQuad bq1(a1_1,a2_1,b0_1,b1_1,b2_1);
+BiQuad bq2(a1_2,a2_2,b0_2,b1_2,b2_2);
+BiQuad bq3(a1_3,a2_3,b0_3,b1_3,b2_3);
+BiQuad bq4(a1_4,a2_4,b0_4,b1_4,b2_4);
+BiQuad bq5(a1_5,a2_5,b0_5,b1_5,b2_5);
+
 AnalogIn emg1(A0);
 AnalogIn emg2(A1);
 AnalogIn emg3(A2);
 AnalogIn emg4(A3);
+   
+SigInterpreter::SigInterpreter() 
+{
 
-SigInterpreter::SigInterpreter() {}
+}
 
 double SigInterpreter::readValue(int sig) {
     // returns the amplitude of EMG signal
-    if(sig > 4 || sig < 1) { // RIGHT
+    if(sig > 4 || sig < 1) 
+    { 
         // nope
         return 0.0;     // check later of dit idd goeie shit is
-    } if (sig == 1) {
+    } 
+    if (sig == 1) 
+    {
         float input = emg1.read();
-        return filter(input);
+        return (filter(input));
     }
-    if (sig == 2) {
+    if (sig == 2) 
+    {
         float input = emg2.read();
-        return filter(input);
+        return (filter(input));
     } 
-    if (sig == 3) {
+    if (sig == 3) 
+    {
         float input = emg3.read();
-        return filter(input);
+        return (filter(input));
     }
-    if (sig == 4) {
+    if (sig == 4) 
+    {
         float input = emg4.read();
-        return filter(input);
-    }     
-    return 0.0;
+        return (filter(input));
+    }
+    else 
+    {     
+        return 0.0;
+    }
 }
-double SigInterpreter::filter(float input) {
-    //filter the input)
-    return 0.0;     //default, return the filtered input
-}
\ No newline at end of file
+
+double SigInterpreter::filter(float input){
+  
+    float highpass1 = bq1.step(input);
+
+    float highpass2 = bq2.step(highpass1);
+    /*
+    float lowpass1 = bq3.step(highpass2);
+   
+    float lowpass2 = bq4.step(lowpass1);
+    
+    float lowpass3 = bq5.step(lowpass2);
+    */
+    
+    return fabs(input);
+}
+
--- a/SigInterpreter.h	Fri Oct 21 09:12:19 2016 +0000
+++ b/SigInterpreter.h	Fri Oct 28 12:48:27 2016 +0000
@@ -3,6 +3,8 @@
 
 #include "initialize.h"
 
+
+
 class SigInterpreter {
 
 public:
@@ -12,6 +14,6 @@
     double filter(float);
 
 private:
-
+    
 };
 #endif /* SIGINTERPRETER_H */