diff --git a/application.c b/application.c index 962ddb9..7f54d1a 100644 --- a/application.c +++ b/application.c @@ -53,6 +53,9 @@ volatile bool rtc_internal_tick_flag = false; /**< flag set when internal RTC ticked */ /** @} */ +/** if the strobe output should not flicker */ +static bool flicker_off = true; + size_t putc(char c) { size_t length = 0; // number of characters printed @@ -388,6 +391,7 @@ void main(void) // start main loop bool action = false; // if an action has been performed don't go to sleep button_flag = false; // reset button flag + bool flicker_on = false; // if the flicker strobe is currently on while (true) { // infinite loop iwdg_reset(); // kick the dog if (user_input_available) { // user input is available @@ -421,6 +425,25 @@ void main(void) } led_off(); // notify user we received a code } + if (!flicker_off) { + action = true; // prevent going to sleep + uint32_t time = rand(); + if (flicker_on) { + time %= 1000; + if (time < 100) { + time = 100; + } + strobe_off(); + } else { + time %= 100; + if (time < 10) { + time = 10; + } + strobe_on(); + } + sleep_ms(time); + flicker_on = !flicker_on; + } if (action) { // go to sleep if nothing had to be done, else recheck for activity action = false; } else {