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.
Diff: main.cpp
- Revision:
- 2:691ccdef6f1e
- Parent:
- 1:05e9a83b721c
- Child:
- 3:ce23e131fdbd
--- a/main.cpp Sun May 26 13:25:39 2013 +0000
+++ b/main.cpp Sun May 26 13:39:31 2013 +0000
@@ -74,6 +74,36 @@
}
/**
+ *
+ */
+void executeAction(uint8_t commandType, uint8_t channel, uint8_t command)
+{
+ if (commandType != 0x4e)
+ {
+ // do nothing!
+ return;
+ }
+ // execute!
+ if ((command & 0x40) != 0)
+ {
+ led0 = 1;
+ }
+ else
+ {
+ led0 = 0;
+ }
+ if ((command & 0x08) != 0)
+ {
+ led1 = 1;
+ }
+ else
+ {
+ led1 = 0;
+ }
+
+}
+
+/**
* Recieved a message from ANT port.
*/
void receivedFromAnt()
@@ -82,6 +112,8 @@
uint8_t receivedBuffer[MAX_BUFSIZE];
receivedLength = antPort.BC_ANT_RecvPacket(receivedBuffer, MAX_BUFSIZE);
+ executeAction(receivedBuffer[2], receivedBuffer[4], receivedBuffer[6]);
+
printf("RX(%3d):", receivedLength);
for (int index = 0; index < receivedLength; index++)
{
@@ -135,12 +167,8 @@
while(1)
{
myLeds = statusLamp;
- led0 = 1;
- led1 = 1;
wait(0.5);
myLeds = 0;
- led0 = 0;
- led1 = 0;
wait(0.5);
}
}