Changed some stuff
Fork of EMG by
Diff: emg.cpp
- Revision:
- 29:373a2facb3ae
- Parent:
- 28:5a12ce2fa441
- Child:
- 30:aa0389e04d47
--- a/emg.cpp Thu Oct 29 10:43:46 2015 +0000 +++ b/emg.cpp Thu Oct 29 10:53:46 2015 +0000 @@ -13,29 +13,32 @@ double t_lowV[4]; double p_highV[4]; double p_lowV[4]; -double cal_mem[300]; -double b_min; -double t_min; -double p_min; +double b_min = 10.0f; +double t_min = 10.0f; +double p_min = 10.0f; void emg_cal(int emg){ + double cur; if(emg == 1){ for(int i=0; i<300; i++){ - cal_mem[i] = b_emg.read(); - } - b_min = min_element(cal_mem); - } - if(emg == 2){ - for(int i=0; i<300; i++){ - cal_mem[i] = t_emg.read(); + cur = b_emg.read(); + if(cur < b_min) + b_min = cur; } - t_min = min_element(cal_mem); } - if(emg == 3){ + else if(emg == 2){ for(int i=0; i<300; i++){ - cal_mem[i] = p_emg.read(); + cur = t_emg.read(); + if(cur < t_min) + t_min = cur; } - p_min = min_element(cal_mem); + } + else if(emg == 3){ + for(int i=0; i<300; i++){ + cur = p_emg.read(); + if(cur < p_min) + p_min = cur; + } } } double filter(double input, double coeff_input[], double coeff_output[], double prev_outputs[])