SensorStream demo program that uses the 4 LEDs to indicate the accelerometer status
Dependencies: C12832_lcd EthernetInterface SensorDataParser mbed-rtos mbed USBDevice
Fork of SensorStream_BlinkyDemo by
Revision 1:50e52569be43, committed 2013-10-28
- Comitter:
- dan
- Date:
- Mon Oct 28 03:26:09 2013 +0000
- Parent:
- 0:a3d60f53f22f
- Child:
- 2:8d1e7078c230
- Commit message:
- Code cleanup
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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;
Demo Team
