:)

Dependencies:   HIDScope MODSERIAL mbed-dsp mbed

Fork of emg_filter by Tanja H

Files at this revision

API Documentation at this revision

Comitter:
s1340735
Date:
Fri Oct 17 09:45:41 2014 +0000
Parent:
28:2d1c7d7635d0
Child:
30:5d8e6f0fabc1
Commit message:
hid scope toegevoegd van victor

Changed in this revision

EMGfilter.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/EMGfilter.cpp	Fri Oct 17 09:10:53 2014 +0000
+++ b/EMGfilter.cpp	Fri Oct 17 09:45:41 2014 +0000
@@ -3,6 +3,44 @@
 #include "MODSERIAL.h"
 #include "arm_math.h"
 
+HIDScope::HIDScope(int channels) : hid(64,64) 
+{
+    bufferData      = new float[channels]();
+    channelCount    = channels;
+    scopeData.length = 64;
+}
+
+void HIDScope::set(int ch, float val)
+{
+    bufferData[ch] = val;
+}
+
+void HIDScope::set(int ch, int val)
+{
+    set(ch,(float)val);
+}
+
+void HIDScope::set(int ch, bool val)
+{
+    set(ch,(val ? 1.0f : 0.0f));
+}
+
+void HIDScope::set(int ch, double val)
+{
+    set(ch,(float)val);
+}
+
+void HIDScope::send()
+{    
+    for(int ch=0; ch<channelCount; ch++)
+        memcpy(&scopeData.data[ch*4], &bufferData[ch], 4); // Copy a 4 byte float to the char array
+    
+    // Send non blocking, can be adjusted to blocking (hid.send)
+    hid.sendNB(&scopeData);
+}
+
+// ****** emg filter shizzle ******
+
 //Define objects
 AnalogIn    emgB(PTB0); //Analog input bicep
 AnalogIn    emgT(PTB1); //Analog input tricep