kalibratie stappen project EMG

Dependencies:   HIDScope MODSERIAL biquadFilter mbed

Fork of Milestone_sample by Marijke Zondag

Revision:
19:466ada92bf65
Parent:
18:898f54c6aa3d
Child:
20:bd9495b31f50
diff -r 898f54c6aa3d -r 466ada92bf65 main.cpp
--- a/main.cpp	Mon Oct 22 12:48:44 2018 +0000
+++ b/main.cpp	Mon Oct 22 12:57:28 2018 +0000
@@ -25,6 +25,10 @@
 
 MODSERIAL pc(USBTX, USBRX);
 
+//HIDscope
+Ticker      sample_timer;
+HIDScope    scope( 2 );
+DigitalOut  led(LED1);
 
 //Global variables
 int encoder     = 0;                   //Starting point encoder
@@ -72,6 +76,19 @@
 Ticker MovAg_tick;
 
 //Functions
+void sample()
+{
+    /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */
+    scope.set(0, emg0_in.read() );
+    scope.set(1, emg1_in.read() );
+    /* Repeat the step above if required for more channels of required (channel 0 up to 5 = 6 channels) 
+    *  Ensure that enough channels are available (HIDScope scope( 2 ))
+    *  Finally, send all channels to the PC at once */
+    scope.send();
+    /* To indicate that the function is working, the LED is toggled */
+    led = !led;
+}
+
 void EMGFilter0()
 {
     double emg0          = emg0_in.read();
@@ -280,6 +297,7 @@
 { 
     //pc.baud(115200);
     //pc.printf("hello\n\r");
+    sample_timer.attach(&sample, 0.002);
     
     ledr = 0;       //Begin led = red, first state of calibration
     ledb = 1;
@@ -354,4 +372,5 @@
         
     }
 }
+ while(1) {}
 }