confidential

Dependencies:   Chainable_RGB_LED mbed mbedConnectorInterface mbedEndpointNetwork

Revision:
2:0382d0c13a51
Parent:
1:73f962479f1a
--- a/mbedEndpointResources/Touch.h	Sat May 09 20:25:40 2015 +0000
+++ b/mbedEndpointResources/Touch.h	Sat May 09 21:00:59 2015 +0000
@@ -23,7 +23,13 @@
 #ifndef __TOUCH_RESOURCE_H__
 #define __TOUCH_RESOURCE_H__
 
+#define SIZE_STR_REP 2
+#define SIZE_STR_TIMESTAMP 10
+#define SIZE_MAX_ARR 50
+#define SIZE_MAX_RESULTS 700
+
 #include <stdio.h>
+#include <time.h>
 
 // Base class
 #include "DynamicResource.h"
@@ -34,10 +40,11 @@
 DigitalIn button(D2);
 MMA7660 accelemeter;
 
-int reps[50];
+int reps[SIZE_MAX_ARR];
+int times[SIZE_MAX_ARR];
 int idx = 0;
 
-char result[200];
+char result[SIZE_MAX_RESULTS];
 
 void touch_thread(void const *args)
 {
@@ -45,12 +52,13 @@
     accelemeter.init();
     bool up = false;
     int rep = 0;
+    int i = 0;
+    
     for (i = 0; i < 50; i++)
         reps[i] = -1;
     while(1) {
         if (!button) {
             printf("touch detected\n\r");
-            count++;
             LED_set_color("0000FF00");
             while(!button) {
                 accelemeter.getAcceleration(&ax,&ay,&az);
@@ -67,7 +75,8 @@
 
             LED_set_color("00000000");
             printf("Reps = %d\n\r", rep);
-            reps[idx++] = rep;
+            reps[idx] = rep;
+            times[idx++] = (int)time(NULL);
             rep = 0;
         }
     }
@@ -94,14 +103,17 @@
         */
         virtual string get() {
             int i = 0;
-            memset(result, 0, 200);
+            memset(result, 0, SIZE_MAX_RESULTS);
             
-            for (i = 0; i < idx; i++)
-            sprintf(result+(i*4), "%2d, ", reps[idx]);
-
+            for (i = 0; i < idx; i++) {
+                sprintf(result+(i*(SIZE_STR_REP + SIZE_STR_TIMESTAMP + 2)), "%2d,", reps[idx]);
+                sprintf(result+(SIZE_STR_REP+1)+(i*(SIZE_STR_REP + SIZE_STR_TIMESTAMP + 2)), "%10d,", times[idx]);
+            }
+            
             for (i = 0; i < 50; i++)
                 reps[i] = -1;
             idx = 0;
+            printf("results: %s\n", result);
             
             return(result);
         }