switch on a LED when beacon is detected
[beacon-rx-433.git] / main.c
diff --git a/main.c b/main.c
index 290a3e3..5dd4f1d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -330,7 +330,7 @@ static uint8_t get_input(int i)
 #ifdef HOST_VERSION
        return !!x[i];
 #else
-       return !!(PINB & RADIO_BIT);
+       return !!(PINB & (1 << RADIO_BIT));
 #endif
 }
 
@@ -347,6 +347,11 @@ static void set_output(int16_t i)
        printf("%d pow_fond=%d pow_harm1=%d pow_other=%d cpt_filter=%d detected=%d\n",
               i, pow_fond, pow_harm1, pow_other, cpt_filter, detected);
 #else
+       if (detected)
+               PORTB |= (1 << LED_BIT);
+       else
+               PORTB &= ~(1 << LED_BIT);
+
        /* when we receive, output a square signal at 625 hz */
        if ((detected == 1) && (i & 4))
                PORTB |= (1 << BUZ_BIT);
@@ -371,13 +376,6 @@ int main(void)
        DDRB |= (1 << LED_BIT) | (1 << BUZ_BIT);
 #endif
 
-       while (1) {
-               PORTB |= (1 << LED_BIT);
-               wait_ms(500);
-               PORTB &= ~(1 << LED_BIT);
-               wait_ms(500);
-       }
-
        i = 0;
        init_timer();
 
@@ -405,8 +403,8 @@ int main(void)
 
                set_output(i);
 
-#ifdef HOST_VERSION
                i ++;
+#ifdef HOST_VERSION
                if (i >= sizeof(x))
                        break;
 #endif