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_HeartRate by
Revision 73:05069f4ba756, committed 2015-09-29
- Comitter:
- szqt
- Date:
- Tue Sep 29 16:55:53 2015 +0000
- Parent:
- 72:469dbde1a238
- Commit message:
- Add BatteryLevel
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 469dbde1a238 -r 05069f4ba756 main.cpp
--- a/main.cpp Tue Sep 29 09:49:50 2015 +0000
+++ b/main.cpp Tue Sep 29 16:55:53 2015 +0000
@@ -56,6 +56,9 @@
HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER);
/* Setup auxiliary service. */
+ // BatteryService battery(ble);
+ uint8_t batteryLevel = 50; // init batteryLevel to 50%
+ BatteryService batteryService(ble, batteryLevel);
DeviceInformationService deviceInfo(ble, "ARM", "Model1", "SN1", "hw-rev1", "fw-rev1", "soft-rev1");
/* Setup advertising. */
@@ -84,6 +87,12 @@
// update bps
hrService.updateHeartRate(hrmCounter);
+
+ batteryLevel++;
+ if (batteryLevel == 100) {
+ batteryLevel = 20;
+ }
+ batteryService.updateBatteryLevel(batteryLevel);
} else {
ble.waitForEvent(); // low power wait for event
}
