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.
Revision 5:cf85007ce40a, committed 2015-10-27
- Comitter:
- yohoo15
- Date:
- Tue Oct 27 08:54:37 2015 +0000
- Parent:
- 4:d32946ab9c54
- Commit message:
- this time with go flag;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 26 16:10:02 2015 +0000
+++ b/main.cpp Tue Oct 27 08:54:37 2015 +0000
@@ -5,9 +5,25 @@
#include "HIDScope.h"
#include <iostream>
-Ticker sample_timer;
+Ticker HIDScope_timer;
+Ticker Filteren_timer;
HIDScope scope(2);
+// defining flags
+volatile bool Flag_filteren = false;
+volatile bool Flag_HIDScope = false;
+
+// making function flags.
+void Go_flag_filteren()
+{
+ Flag_filteren = true;
+}
+
+void Go_flag_HIDScope()
+{
+ Flag_HIDScope = true;
+}
+
AnalogIn analog_emg_left(A0);
//AnalogIn analog_emg_right(A1);
double input = 0;
@@ -170,7 +186,7 @@
double test=1;
-void sample()
+void Filteren()
{
input = analog_emg_left.read();
input = input-0.45; //FIRST SUBTRACT MEAN THEN FILTER
@@ -178,14 +194,27 @@
filter_signal = filter(input, v1, v2);
//filter_right = filter(input_right, v1_right, v2_right);
+
+}
+void HIDScope_kijken()
+{
scope.set(0, input);
scope.set(1, filter_signal);
scope.send();
}
-
-
int main()
{
- sample_timer.attach(&sample, 0.002);
- while(1){}
+ HIDScope_timer.attach(&Go_flag_HIDScope, 0.002);
+ Filteren_timer.attach(&Go_flag_filteren,0.004);
+ while(1){
+ if(Flag_filteren) {
+ Flag_filteren = false;
+ Filteren();
+ }
+
+ if(Flag_HIDScope) {
+ Flag_HIDScope = false;
+ HIDScope_kijken();
+ }
+ }
}
\ No newline at end of file