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: GR-PEACH_video GraphicsFramework R_BSP mbed-rtos mbed
Fork of RGA_HelloWorld by
Revision 6:6cad61e4a4c1, committed 2016-05-20
- Comitter:
- 1050186
- Date:
- Fri May 20 02:33:41 2016 +0000
- Parent:
- 5:ac895a9527ab
- Commit message:
- Modify main.cpp
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri May 13 07:10:27 2016 +0000
+++ b/main.cpp Fri May 20 02:33:41 2016 +0000
@@ -55,18 +55,18 @@
}
static float get_distance(void) {
- float tmp[10];
+ float tmp = 0;
float data = 0;
float distance = 0;
int cnt;
for (cnt = 0; cnt < 10; cnt++) {
- tmp[cnt] = ain;
- if (tmp[cnt] == 0) {
+ if (ain == 0) {
return 0;
}
+ tmp = tmp + ain;
}
- data = (tmp[0]+tmp[1]+tmp[2]+tmp[3]+tmp[4]+tmp[5]+tmp[6]+tmp[7]+tmp[8]+tmp[9]) / 10;
+ data = tmp / 10;
if ((data >= 0.121) && (data <= 0.970)) {
distance = 26.663 * pow((data * 3.3), -1.25);
}
