Rime remote control: start with 1, set the LEDs to the exact value that is sent
authorRoland Hieber <rohieb@rohieb.name>
Wed, 16 Nov 2011 22:57:45 +0000 (23:57 +0100)
committerRoland Hieber <rohieb@rohieb.name>
Wed, 16 Nov 2011 22:57:45 +0000 (23:57 +0100)
exercise_remotecontrol/rime/led_remote_control.c

index 1eae8fe..bde4d3e 100644 (file)
@@ -10,11 +10,18 @@ AUTOSTART_PROCESSES(&led_remote_control_rime);
 void recv(struct broadcast_conn *ptr, const rimeaddr_t * sender) {
   char * val = (char *) packetbuf_dataptr();
   printf("node %d: recv from %d: %d\n", rimeaddr_node_addr, *sender, *val);
-  // FIXME
-  if(*val % 2) {
-    leds_toggle(LEDS_GREEN);
+
+  if((*val) & 0x01) {
+    leds_on(LEDS_GREEN);
+  } else {
+    leds_off(LEDS_GREEN);
+  }
+  if((*val) & 0x02) {
+    leds_on(LEDS_YELLOW);
+  } else {
+    leds_off(LEDS_YELLOW);
   }
-  leds_toggle(LEDS_YELLOW);
+
   printf("toggled LEDs\n");
 }
 
@@ -35,7 +42,7 @@ PROCESS_THREAD(led_remote_control_rime, ev, data) {
 
   static struct etimer timer;
   static char i;
-  for(i = 0; 1; i++) {
+  for(i = 1; 1; i++) {
     PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
 
     // debounce for 250 ms
This page took 0.040269 seconds and 4 git commands to generate.