vbfgh

Dependencies:   BLE_API HCSR04 X_NUCLEO_IDB0XA1 mbed

Fork of BLE_LED_Button_Nucleo by Jan Jongboom

Revision:
14:c75f17f554c1
Parent:
13:0326e963b96c
--- a/main.cpp	Tue May 03 10:20:03 2016 +0000
+++ b/main.cpp	Wed May 04 16:17:49 2016 +0000
@@ -18,15 +18,15 @@
 #include "ble/BLE.h"
 #include "LEDService.h"
 #include "ButtonService.h"
-
+#include "hcsr04.h"
 #define LED_ON          0
 #define LED_OFF         1
 
 DigitalOut alivenessLED(LED1, LED_OFF); // green
 DigitalOut actuatedLED(LED2, LED_OFF);  // red
 InterruptIn button(PC_13);
-
-const static char     DEVICE_NAME[] = "MY_BLE_DEVICE";
+HCSR04 usensor(D14,D15);
+const static char     DEVICE_NAME[] = "vs_device";
 static const uint16_t uuid16_list[] = { 
     LEDService::LED_SERVICE_UUID, 
     ButtonService::BUTTON_SERVICE_UUID
@@ -120,18 +120,18 @@
 
 void button_down() {
     if (!buttonServicePtr) return;
-    buttonServicePtr->updateButtonState(true);
+    buttonServicePtr->updateButtonState(usensor.get_dist_cm());
 }
 void button_up() {
     if (!buttonServicePtr) return;
-    buttonServicePtr->updateButtonState(false);
+    
 }
 
 int main(void)
 {
     // Blink the green LED!
     ticker.attach(periodicCallback, 1);
-    
+    usensor.start();
     button.fall(&button_down);
     button.rise(&button_up);