First Last
/
BMT-K9-Groep7
Initial version
Revision 4:d0b4c806f4ea, committed 2013-10-17
- Comitter:
- vsluiter
- Date:
- Thu Oct 17 09:38:14 2013 +0000
- Parent:
- 3:57c5633df1ca
- Commit message:
- Initialization of variables moved to declarations
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 57c5633df1ca -r d0b4c806f4ea main.cpp --- a/main.cpp Thu Oct 17 09:29:52 2013 +0000 +++ b/main.cpp Thu Oct 17 09:38:14 2013 +0000 @@ -25,23 +25,25 @@ #define DEN3 -3.3189 #define DEN4 0.7816 + /* hou in de gaten welke waarden globaal gedefinieerd moeten worden*/ -float count; float square_biceps; float sum_biceps; float mean_biceps; +float count =0; +float square_biceps = 0; +float sum_biceps = 0; +float mean_biceps = 0.2; void looper() { /*value0 is huidig, 1 is t-1, 2 is t-2 etc. Gebruik later aanduidingen ABCD. */ - static char startup = 0; float mean; float sig_out_biceps; - static float in0,in1,in2,in3,in4; - static float out0,out1,out2,out3,out4; + //static variables keep their values between function calls + //the assignents are only executed the first iteration. + static float in0 =0,in1 =0 ,in2 = 0,in3 = 0,in4 = 0; + static float out0 = 0,out1 = 0 ,out2 = 0,out3 = 0,out4 = 0; float emg_abs; // square, mean en count eerder gedefinieerd - if (startup != 1) - {in0 = in1 = in2 = in3 = in4 = 0; - out0 = out1 = out2 = out3 = out4 = 0; - count = 0; square_biceps = 0; sum_biceps = 0; mean_biceps = 0.2; startup = 1; - } + // initialisation of globals should be done at initialization of program + // count = 0; square_biceps = 0; sum_biceps = 0; mean_biceps = 0.2; in4 = in3; in3 = in4; in3 = in2; in2 = in1; in1 = in0; in0 = emg_biceps.read(); red = in0; @@ -78,6 +80,8 @@ /*set the period for the PWM to the red LED*/ red.period_ms(2); // periode pwm = 2*Fs , blijkbaar. // blue.period_ms(2); + + /**Here you attach the 'void looper(void)' function to the Ticker object0 * The looper() function will be called every 0.001 seconds. * Please mind that the parentheses after looper are omitted when using attach.