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 simpleBLEControl
Fork of BLE_API_DEMO by
Revision 54:52be0aeba318, committed 2014-11-28
- Comitter:
- antoniorohit
- Date:
- Fri Nov 28 08:10:25 2014 +0000
- Parent:
- 53:f503e75f0c94
- Commit message:
- Funnel + Base motor integrated positioning;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Nov 28 05:27:43 2014 +0000
+++ b/main.cpp Fri Nov 28 08:10:25 2014 +0000
@@ -53,13 +53,47 @@
// it's used to dispatch the callbacks
if(eventDataP->charHandle==writeToArduino_handler){ // The data is for the motor
uint16_t bytesRead = eventDataP->len;
- int turnSteps = *((int16_t *)eventDataP->data);
- if(is_button_pressed){ // Hack-way to turn both motors
- arduino.printf("%im\n", turnSteps); // <turn steps>m turns small motor
- }
- else{
- arduino.printf("%iM\n", turnSteps); // <turn steps>M turns large motor
- }
+ // What the BLE master will tell us is which funnels to dispense from
+ int funnel = *((int16_t *)eventDataP->data);
+ switch(funnel){
+ case 0:
+ arduino.printf("%dm", 0);
+ arduino.printf("%dM", 25);
+ arduino.printf("%dM", -25);
+ arduino.printf("%dm", 128);
+ arduino.printf("%dm", -128);
+ arduino.printf("%dm", -0);
+ break;
+ case 1:
+ arduino.printf("%dm", 128);
+ arduino.printf("%dM", 75);
+ arduino.printf("%dM", -75);
+ arduino.printf("%dm", 128);
+ arduino.printf("%dm", -128);
+ arduino.printf("%dm", -128);
+ break;
+ case 2:
+ arduino.printf("%dm", 256);
+ arduino.printf("%dM", 125);
+ arduino.printf("%dM", -125);
+ arduino.printf("%dm", 128);
+ arduino.printf("%dm", -128);
+ arduino.printf("%dm", -256);
+ break;
+
+ case 3:
+ arduino.printf("%dm", 384);
+ arduino.printf("%dM", 175);
+ arduino.printf("%dM", -175);
+ arduino.printf("%dm", 128);
+ arduino.printf("%dm", -128);
+ arduino.printf("%dm", -384);
+ break;
+
+ default:
+ break;
+ }
+
led1 = !led1.read(); // debug purposes
}
}
