Bluetooth Connected TOF Sensor

Dependencies:   BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed

Fork of BLE_HeartRate_IDB0XA1 by ST

Revision:
29:cf61a5826426
Parent:
28:def5e0f0fb06
Child:
30:e324e95c68a9
--- a/main.cpp	Wed Feb 01 22:08:56 2017 +0000
+++ b/main.cpp	Wed Feb 01 22:35:28 2017 +0000
@@ -132,8 +132,21 @@
       d.data.range_mm = dist;
    }
    
+   
+   void refreshDisplay(Dish &d, int msec)
+   {
+      Timer timer;
+   
+      timer.start();
+      for (int i=0; i < msec; i = timer.read_ms())
+         d.refresh();                  // refresh display
+      timer.stop();
+   }
+   
+   
    void loop(Blob &o, Dish &d)
    {
+      static const char *off = "          ";
       Bool state = false;
 
       for (;;)
@@ -149,16 +162,16 @@
          else
          {  if (state == true)
             {  if (isConnected(o))
-                  blink.connected();   // switch LED off
+                  blink.connected(off);   // switch LED off
                else
-                  blink.advertise();   // switch LED off
+                  blink.advertise(off);   // switch LED off
                state = false;
                set(o,chrPresence,state);
             }
          }
 
          if (d.red())                  // red slider switched to 'RANGE'?
-            d.refresh();               // refresh display
+            refreshDisplay(d,250);
          sleep(o);                     // 'sleep(o,10)' causes connect issues
       }
    }