Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of BLE_Button by
Diff: main.cpp
- Revision:
- 11:80a9d811aab1
- Parent:
- 10:7943b5c1117a
- Child:
- 12:d6be80bffa01
--- a/main.cpp Wed Dec 30 09:54:06 2015 +0000
+++ b/main.cpp Wed Aug 31 21:50:26 2016 +0000
@@ -19,6 +19,7 @@
#include "ButtonService.h"
DigitalOut led1(LED1);
+DigitalOut led2(LED2);
InterruptIn button(BUTTON1);
const static char DEVICE_NAME[] = "Button";
@@ -38,6 +39,7 @@
/* Note that the buttonPressedCallback() executes in interrupt context, so it is safer to access
* BLE device API from the main thread. */
buttonState = PRESSED;
+ led2 = 1;
}
void buttonReleasedCallback(void)
@@ -45,6 +47,7 @@
/* Note that the buttonReleasedCallback() executes in interrupt context, so it is safer to access
* BLE device API from the main thread. */
buttonState = RELEASED;
+ led2 = 0;
}
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
@@ -102,6 +105,7 @@
int main(void)
{
led1 = 1;
+ led2 = 1;
Ticker ticker;
ticker.attach(periodicCallback, 1);
button.fall(buttonPressedCallback);
@@ -112,8 +116,12 @@
/* SpinWait for initialization to complete. This is necessary because the
* BLE object is used in the main loop below. */
- while (ble.hasInitialized() == false) { /* spin loop */ }
-
+ while (ble.hasInitialized() == false) { /* spin loop */
+ led2 = 0;
+ wait(0.1);
+ led2 = 1 ;
+ }
+ led2 = 0;
while (true) {
if (buttonState != IDLE) {
buttonServicePtr->updateButtonState(buttonState);
