EZR
Dependencies: CRC16 FreescaleIAP FreescaleWatchdog GGSProtocol LM75B PIMA Parameters PersistentCircularQueue SerialNumberV2COM mbed-dev-watchdog_2016_03_04
Fork of smartRamalKW by
Diff: sensor.cpp
- Revision:
- 9:e501499af4ef
- Parent:
- 8:e8d86c66283c
- Child:
- 16:cae76dbd681f
diff -r e8d86c66283c -r e501499af4ef sensor.cpp --- a/sensor.cpp Thu Jul 02 22:57:47 2015 +0000 +++ b/sensor.cpp Wed Jul 22 15:09:01 2015 +0000 @@ -51,9 +51,9 @@ float calculateRMS(){ float rms = 0; for(int i=0; i < DEFAULT_SAMPLES; i++){ - sample[i] = sample[i]*APP_PARAMETERS.SAMPLES_ANG_COEF + APP_PARAMETERS.SAMPLES_LIN_COEF; + sample[i] = abs(sample[i]*APP_PARAMETERS.SAMPLES_ANG_COEF.floatValue + APP_PARAMETERS.SAMPLES_LIN_COEF.floatValue); rms += sample[i]*sample[i]; } - rms = rms / (float)DEFAULT_SAMPLES; + rms = rms / DEFAULT_SAMPLES; return sqrt(rms); }