Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope MODSERIAL mbed-dsp mbed
Fork of emg_filter2 by
Revision 29:f54123765a47, committed 2014-10-17
- 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
