From: Roland Hieber Date: Wed, 16 Nov 2011 22:57:45 +0000 (+0100) Subject: Rime remote control: start with 1, set the LEDs to the exact value that is sent X-Git-Url: https://git.rohieb.name/wsn-p.git/commitdiff_plain/9f16f0aad6c0bbdeec2fa8484481ababb7aee56c?ds=sidebyside;hp=de0c58813a2c42b2b59715dc18bc164bd68eaa28 Rime remote control: start with 1, set the LEDs to the exact value that is sent --- diff --git a/exercise_remotecontrol/rime/led_remote_control.c b/exercise_remotecontrol/rime/led_remote_control.c index 1eae8fe..bde4d3e 100644 --- a/exercise_remotecontrol/rime/led_remote_control.c +++ b/exercise_remotecontrol/rime/led_remote_control.c @@ -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