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: mbed-src anaDMA stm32_adafruit
Revision 3:e0293a583075, committed 2015-01-03
- Comitter:
- willybayot
- Date:
- Sat Jan 03 15:49:27 2015 +0000
- Parent:
- 2:9f43dda627e1
- Child:
- 4:1540ef317898
- Commit message:
- revision 4;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Jan 03 15:44:24 2015 +0000
+++ b/main.cpp Sat Jan 03 15:49:27 2015 +0000
@@ -65,7 +65,8 @@
reading[0][0] += reading[0][i];
reading[0][0] /= integration_ratio; // Average reading
if (sample_count == 0) { // If first reading of session, save reading into ground reference signal level
- ref_reading[0] = reading[0][0];
+ for (i=0; i < integration_ratio;i++)
+ ref_reading[i] = reading[0][i];
sample_count++;
}
delta = ref_reading[0] - reading[0][0]; // Delta is the gradient
@@ -74,7 +75,8 @@
else
buzzer.period_ms(0);
if (delta != 0 && abs(delta) <= 0.01 ) // If delta is small enough but not nul, update the ref_reading with th ecurrent reading through a powerful low pass FIR filter.
- ref_reading[0] = (ref_reading[0]*127 + reading[0][0] ) / 128;
+ for (i=0; i < integration_ratio;i++)
+ ref_reading[i] = (ref_reading[i]*127 + reading[0][i] ) / 128;
if (button == 0) { // pushing again on the button and relasing it stops the session
while (button == 0)
;