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: C12832_lcd EthernetInterface SensorDataParser mbed-rtos mbed USBDevice
Fork of SensorStream_BlinkyDemo by
Diff: main.cpp
- Revision:
- 1:50e52569be43
- Parent:
- 0:a3d60f53f22f
- Child:
- 2:8d1e7078c230
--- a/main.cpp Mon Oct 28 03:20:03 2013 +0000
+++ b/main.cpp Mon Oct 28 03:26:09 2013 +0000
@@ -37,20 +37,16 @@
server.bind(SERVER_PORT);
while (true) {
+ // receive udp packet
int n = server.receiveFrom(client, buffer, sizeof(buffer) - 1);
- if (n == sizeof(buffer) - 1)
- continue;
+ if (n == sizeof(buffer) - 1) continue;
+
buffer[n] = 0;
+ // parse the packet
if (parse_sensor_packet(buffer, &pd) == 0) continue;
- if(fabs(pd.ax) > SENSE_DELTA) {
- //printf("ax: %f\r\n", pd.ax);
- }
- if(fabs(pd.ay) > SENSE_DELTA) {
- //printf("ay: %f\r\n", pd.ay);
- }
-
+ // accelerometer x axis
if (pd.ax > 0) {
led_left = 0;
led_right = fabs(pd.ax) * 2;
@@ -59,6 +55,7 @@
led_right = 0;
}
+ // accelerometer y axis
if (pd.ay > 0) {
led_up = 0;
led_down = fabs(pd.ay) * 2;
