POC1.5 prototype 2 x color sensor 2 x LM75B 3 x AnalogIn 1 x accel

Dependencies:   mbed vt100

Revision:
8:5590f55bdf41
Parent:
6:44ca704f2bc1
Child:
9:f958fa2cdc74
--- a/af_utils/af_attriburtes.cpp	Thu Dec 07 01:06:46 2017 +0000
+++ b/af_utils/af_attriburtes.cpp	Thu Dec 07 10:13:13 2017 +0000
@@ -242,13 +242,13 @@
         pending->replied_time = timestamp ;
 
     }
-    ts2time(timestamp, &current_time) ;
+    ts2time(timestamp, &current_time) ; /* 12 us */
     print_time(&current_time) ;
     printf(" %5d ASR requested [%d] : ", attributeId, requestId) ;
     af_print_values(requestId, attributeId, valueLen, value) ;
     switch(attributeId) {
-    case ATTR_LINKED_TIMESTAMP: /* timestamp */
-        set_time(valueLen, value) ;
+    case ATTR_LINKED_TIMESTAMP: /* timestamp */  
+        set_time(valueLen, value) ; /* 68 us */
         afero->setAttributeComplete(requestId, attributeId, valueLen, value) ;
         printf("timestampe = %d\n", timestamp) ;
 //        print_date(&current_time) ;
@@ -347,6 +347,24 @@
              afero->setAttributeBool(ATTR_COLOR0_CALIBRATE, false) ;
         }
         break ;
+    case ATTR_COLOR0_PWM_R:
+        if (sensor[1]) {
+            color0_pwm[0] = (value[1] << 8) | value[0] ;
+        }
+        afero->setAttributeComplete(requestId, attributeId, valueLen, value) ;       
+        break ;
+    case ATTR_COLOR0_PWM_G:
+        if (sensor[1]) {
+            color0_pwm[1] = (value[1] << 8) | value[0] ;
+        }
+        afero->setAttributeComplete(requestId, attributeId, valueLen, value) ;       
+        break ;
+    case ATTR_COLOR0_PWM_B:
+        if (sensor[1]) {
+            color0_pwm[2] = (value[1] << 8) | value[0] ;
+        }
+        afero->setAttributeComplete(requestId, attributeId, valueLen, value) ;       
+        break ;
     case ATTR_COLOR1_ENABLE: /* color1 enable */
         if (sensor[2]) {
             if (value[0]) {
@@ -409,6 +427,24 @@
         }
 
         break ;
+    case ATTR_COLOR1_PWM_R:
+        if (sensor[2]) {
+            color1_pwm[0] = (value[1] << 8) | value[0] ;
+        }
+        afero->setAttributeComplete(requestId, attributeId, valueLen, value) ;       
+        break ;
+    case ATTR_COLOR1_PWM_G:
+        if (sensor[2]) {
+            color1_pwm[1] = (value[1] << 8) | value[0] ;
+        }
+        afero->setAttributeComplete(requestId, attributeId, valueLen, value) ;       
+        break ;
+    case ATTR_COLOR1_PWM_B:
+        if (sensor[2]) {
+            color1_pwm[2] = (value[1] << 8) | value[0] ;
+        }
+        afero->setAttributeComplete(requestId, attributeId, valueLen, value) ;       
+        break ;
     case ATTR_TEMP0_ENABLE: /* temp0 is used to control temp-sensors */
         if (sensor[3]) {
             if (value[0]) {
@@ -468,15 +504,17 @@
     const uint8_t   *value
 ) 
 {
+Timer timer ;
+int t0, t1 ;
     uint32_t timestamp = edge_time ;
     if ((pending != 0)&&(pending->request->requestId == requestId)) {
         pending->replied_time = timestamp ;
-    }
-    ts2time(timestamp, &current_time) ;
+    }   
+    ts2time(timestamp, &current_time) ; /* 12us */
     print_time(&current_time) ;
     printf(" %5d ASR reported [%d]: ", attributeId, requestId) ;
     if (attributeId == ATTR_LINKED_TIMESTAMP) { /* timestamp! */
-        set_time(valueLen, value) ;
+        set_time(valueLen, value) ; /* 68 us */
         printf("timestampe = %d\n", timestamp) ;
         print_date(&current_time) ;
 //        print_time(&current_time) ;