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.
Revision 0:fb6e10232b73, committed 2015-03-04
- Comitter:
- sigveseb
- Date:
- Wed Mar 04 12:18:13 2015 +0000
- Commit message:
- add button notify
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Puck.lib Wed Mar 04 12:18:13 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Nordic-Pucks/code/Puck/#7d728fed55ab
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Mar 04 12:18:13 2015 +0000
@@ -0,0 +1,64 @@
+#define LOG_LEVEL_INFO
+#include "Puck.h"
+
+Puck* puck = &Puck::getPuck();
+
+InterruptIn pb1(BUTTON1);
+InterruptIn pb2(BUTTON2);
+
+uint8_t currentlyPushedButton = 0;
+
+void onButton1Pushed(void) {
+ currentlyPushedButton = 1;
+}
+
+void onButton2Pushed(void) {
+ currentlyPushedButton = 2;
+}
+
+void onButton3Pushed(void) {
+ currentlyPushedButton = 3;
+}
+
+void onButton4Pushed(void) {
+ currentlyPushedButton = 4;
+}
+
+// Sample Gatt characteristic and service UUIDs
+const UUID SAMPLE_GATT_SERVICE = stringToUUID("bftj sample ");
+const UUID SAMPLE_GATT_CHARACTERISTIC = stringToUUID("bftj sample char");
+
+int main(void) {
+
+ pb1.rise(&onButton1Pushed);
+ pb1.enable_irq();
+
+ pb2.rise(&onButton2Pushed);
+ pb2.enable_irq();
+
+
+
+ // Add the Gatt characteristic
+ int characteristicValueLength = 1;
+ puck->addCharacteristic(
+ SAMPLE_GATT_SERVICE,
+ SAMPLE_GATT_CHARACTERISTIC,
+ characteristicValueLength,
+ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
+
+ // Initialize the puck
+ puck->init(0xFEED);
+
+ // Set the initial value of the characteristic
+ uint8_t new_value = 0;
+ puck->updateCharacteristicValue(SAMPLE_GATT_CHARACTERISTIC, &new_value, characteristicValueLength);
+
+ // Let the puck do its thing
+ while(puck->drive()) {
+ if(currentlyPushedButton) {
+ puck->updateCharacteristicValue(SAMPLE_GATT_CHARACTERISTIC, ¤tlyPushedButton, 1);
+ LOG_INFO("button: %i\n", currentlyPushedButton);
+ currentlyPushedButton = 0;
+ }
+ };
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 04 12:18:13 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file