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 MbedJSONValue mbed nRF51822
Fork of BLE_RedBearNano-SAndroidEDevice by
Revision 4:2ef9b332fa7c, committed 2017-10-06
- Comitter:
- giowild
- Date:
- Fri Oct 06 10:05:45 2017 +0000
- Parent:
- 3:16b7d807fa8c
- Commit message:
- Send Custom strings/parameters from Nano to smartphone
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 05 15:00:10 2017 +0000
+++ b/main.cpp Fri Oct 06 10:05:45 2017 +0000
@@ -475,10 +475,29 @@
enqueueItem(toSendQueue, buf, len);
}
+AnalogIn ain(P0_6);
+void fnCustomParameter() {
+ unsigned short val,max;
+ int i;
+ if (ble.getGapState().connected) {
+ i=0;
+ max=0;
+ while(i++<300) { // read the max of 3 consecutive samples = 3*100 (100=10ms/100us)
+ val = ain.read_u16();
+ if (val>max) max=val;
+ wait_us(100);
+ }
+
+ // enqueue into bluetooth queue
+ uint8_t buf[TXRX_BUF_LEN];
+ int len = sprintf((char *)buf,"W%d",val);
+ enqueueItem(toSendQueue, buf, len);
+ }
+}
+
int main(void)
{
-
for (int i=0;i<maxPins;i++) {
pinTypes[i] = PIN_NOTSET;
prevValues[i] = 0;
@@ -488,6 +507,11 @@
pinGroups[i]=NO_GROUP;
}
+ initPin(28,PIN_OUTPUT);
+ initPin(29,PIN_OUTPUT);
+ writeDigital(28,0);
+ writeDigital(29,1);
+
ble.init();
ble.onDisconnection(disconnectionCallback);
ble.onDataWritten(WrittenHandler);
@@ -520,6 +544,9 @@
Ticker gcdTicker;
gcdTicker.attach(changeGcdTiming, 5);
+
+ Ticker customParameterTicker;
+ customParameterTicker.attach(fnCustomParameter, 5);
recvQueue = ConstructQueue(40);
toSendQueue = ConstructQueue(40);
