From 6d039f5e922653955f3dcfd856f25f461a391bb8 Mon Sep 17 00:00:00 2001 From: bigalex Date: Mon, 1 Oct 2012 22:27:16 +0200 Subject: [PATCH] switch_l and switch_r in bughal work now --- firmware/lib/bughal.c | 4 ++-- firmware/main.c | 42 +++--------------------------------------- 2 files changed, 5 insertions(+), 41 deletions(-) diff --git a/firmware/lib/bughal.c b/firmware/lib/bughal.c index 5e272d9..0eadfcd 100644 --- a/firmware/lib/bughal.c +++ b/firmware/lib/bughal.c @@ -71,11 +71,11 @@ void init_switch(void){ } bool switch_l(void){ - return PIND & 0b00000010; + return !(PIND & 0b00000001); }; bool switch_r(void){ - return PIND & 0b00000001; + return !(PIND & 0b00000010); }; diff --git a/firmware/main.c b/firmware/main.c index 799e087..b12161d 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -37,47 +37,11 @@ main(void) //do something //main polling loop; if (timer_expired(&t)){ - if (0==ledmode){ - ledmode =1; - led_on(LED_L); - - } else { - - ledmode=0; - led_off(LED_L); + if (switch_l()) {led_on(LED_L);} else {led_off(LED_L);}; + if (switch_r()) {led_on(LED_R);} else {led_off(LED_R);}; - }; - - USART0_crlf(); - if (0==ct%3){ - if (0==ct%5){ - //fizzbug - USART0_putc('f'); - USART0_putc('i'); - USART0_putc('z'); - USART0_putc('z'); - USART0_putc('b'); - USART0_putc('u'); - USART0_putc('g'); - } else { - //fizz - USART0_putc('f'); - USART0_putc('i'); - USART0_putc('z'); - USART0_putc('z'); - } - } else { - if (0==ct%5){ - //bug - USART0_putc('b'); - USART0_putc('u'); - USART0_putc('g'); - } else { - USART0_put_uint16(ct); - }; - }; timer_set(&t, 50); - ct++; + }; //end if timer expired //USART0_put_uint16(0xA09F);