From: Olivier Matz Date: Thu, 23 May 2013 18:10:13 +0000 (+0200) Subject: move set_output() in main loop X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0878ff0726cff2df249e065eebdbd9c35ce9071c;p=beacon-rx-433.git move set_output() in main loop this is finally clearer, especially because we will add modes in next commit Signed-off-by: Olivier Matz --- diff --git a/main.c b/main.c index e794376..35a86cf 100644 --- a/main.c +++ b/main.c @@ -344,32 +344,6 @@ static uint8_t get_input(int i) #endif } -static void set_output(int16_t i) -{ - int8_t detected = 0; - - if (cpt_filter > 250) - detected = 1; - -#ifdef HOST_VERSION - printf("%d fil_fond=%d fil_harm1=%d fil_other=%d\n", - i, fil_fond, fil_harm1, fil_other); - 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) - LED_ON(); - else - LED_OFF(); - - /* when we receive, output a square signal at 625 hz */ - if ((detected == 1) && (i & 4)) - BUZZER_ON(); - else - BUZZER_OFF(); -#endif -} - /* The CPU runs at 8Mhz. Fe = 5Khz @@ -379,6 +353,7 @@ static void set_output(int16_t i) */ int main(void) { + int8_t detected = 0; int16_t i; /* led and buzzer are outputs */ @@ -411,9 +386,30 @@ int main(void) else if (cpt_filter > 0) cpt_filter--; - set_output(i); +#ifdef HOST_VERSION + /* display values */ + printf("%d fil_fond=%d fil_harm1=%d fil_other=%d\n", + i, fil_fond, fil_harm1, fil_other); + 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) + LED_ON(); + else + LED_OFF(); + + /* output a square signal at 625 hz if beacon is + * detected */ + if ((detected == 1) && (i & 4)) + BUZZER_ON(); + else + BUZZER_OFF(); + +#endif i ++; + #ifdef HOST_VERSION if (i >= sizeof(x)) break;