- PORTB &= ~(1 << TX_ENABLE_PORT);
- wait_ms(500);
- PORTB |= (1 << TX_ENABLE_PORT);
- for (i=0;i<100; i++) {
- PORTB |= (1 << DATA_PORT);
- PORTB |= (1 << BUZZER_PORT);
- _delay_us(1000);
- PORTB &= ~(1 << DATA_PORT);
- PORTB &= ~(1 << BUZZER_PORT);
- _delay_us(1000);
+ wait_period();
+
+ /* buzzer at 2 Khz after 10mns if not always on */
+ if (always_on || time_second > 600) {
+ if ((time_period & 1) && (time_period < 500))
+ BUZZER_ON();
+ else
+ BUZZER_OFF();
+ }
+ else
+ BUZZER_OFF();
+
+ /* radio at 500 Hz */
+ if (time_period < 500) {
+ TX_ENABLE();
+ if (time_period & 4)
+ TX_ON();
+ else
+ TX_OFF();
+ }
+ else
+ TX_DISABLE();
+
+ /* process next time vars */
+ time_period++;
+ if (time_period >= 4000) {
+ time_period = 0;
+ time_second ++;
+ }
+
+ /* filter button */
+ button = 0;
+ if (BUTTON_IS_PRESSED() && button_filter < 10)
+ button_filter++;
+ else if (BUTTON_IS_PRESSED() && button_filter == 10)
+ button = 1;
+ else if (!BUTTON_IS_PRESSED())
+ button_filter = 0;
+
+ /* change mode if button is pressed */
+ if (button) {
+ time_period = 0;
+ time_second = 0;
+ always_on = !always_on;