lololololol

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Revision:
11:008c8060e640
Parent:
10:3a3d6373b41c
Child:
12:6aabdca32aee
--- a/main.cpp	Fri Sep 20 07:09:28 2019 +0000
+++ b/main.cpp	Fri Sep 20 09:10:05 2019 +0000
@@ -2,12 +2,12 @@
 #include "HIDScope.h"
 
 Serial pc(USBTX,USBRX);
-HIDScope scope(2);
+HIDScope scope(4);
 Ticker AInTicker;
 InterruptIn BUT1(D1);
-InterruptIn BUT2(D0);
 PwmOut lichtje(D3);
 AnalogIn   ain(A0);
+AnalogIn   bin(A1);
 
 float getal;
 int n=5;
@@ -15,6 +15,9 @@
 volatile float x;
 volatile float x_prev=0; 
 volatile float y;
+volatile float xb;
+volatile float xb_prev=0; 
+volatile float yb;
 
 void ReadAnalogInAndFilter()
 {
@@ -24,6 +27,12 @@
     scope.set(1, y);// store data in second element of scope memory filter
     x_prev= x; // Prepare for next round
 
+    xb = bin;   // Capture data
+    scope.set(2, xb);   // store data in first element of scope memory
+    yb= (xb_prev+ xb)/2.0;   // averaging
+    scope.set(3, yb);// store data in second element of scope memory filter
+    xb_prev= xb; // Prepare for next round
+
     scope.send(); // send what's in scope memory to PC
 }
 
@@ -46,8 +55,6 @@
 int main() {
     pc.baud(115200);
     lichtje=1;
-    BUT1.fall(plus);
-    BUT2.fall(min);
     AInTicker.attach(&ReadAnalogInAndFilter, 0.01);
         while(true)
             {