Tomo Yamanaka / Mbed 2 deprecated ImageZoomInout_Sample

Dependencies:   GR-PEACH_video GraphicsFramework R_BSP mbed-rtos mbed

Fork of RGA_HelloWorld by Renesas

Files at this revision

API Documentation at this revision

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);
     }