diff -r 4b5b4c7ba03d -r 7ed95dbadf1f blackbox/main.c --- a/blackbox/main.c Sat Dec 17 13:24:20 2011 +0100 +++ b/blackbox/main.c Sat Dec 17 13:35:40 2011 +0100 @@ -175,6 +175,32 @@ return 0; } +void startbutton(void) { + // start button press active + if (mode == 0) { + mode = 1; // set wait for race start mode + reset_vars(); + LED(1, 1); + LED(2, 1); + LED(3, 1); + LED(4, 1); + LED(5, 1); + RS232_puts_p(prepare); + } else if (mode == 1) { + // Initiate race countdown + sysclk.value = 0; + countdown = 5; + countdown_loops = COUNTDOWN_DELAY; + mode = 2; + LED(1, 0); + LED(2, 0); + LED(3, 0); + LED(4, 0); + LED(5, 0); + RS232_puts_p(countdownstart); + } +} + ISR ( USART_RXC_vect ) { uint8_t tmp; char c = UDR; @@ -246,6 +272,11 @@ RS232_puts_p(ok); break; + case '#': // remote start button press + RS232_puts_p(ok); + startbutton(); + break; + case '+': // toggle panic mode RS232_puts_p(ok); if (mode != 0xff) { @@ -569,6 +600,7 @@ } else slot[idx].seccnt++; } + int main(void) { @@ -602,31 +634,7 @@ btn_start = (PIN(SW_START_PORT) & _BV(SW_START)); if (old_start != btn_start) { // start button changed - if (btn_start == 0) { - // start button press active - if (mode == 0) { - mode = 1; // set wait for race start mode - reset_vars(); - LED(1, 1); - LED(2, 1); - LED(3, 1); - LED(4, 1); - LED(5, 1); - RS232_puts_p(prepare); - } else if (mode == 1) { - // Initiate race countdown - sysclk.value = 0; - countdown = 5; - countdown_loops = COUNTDOWN_DELAY; - mode = 2; - LED(1, 0); - LED(2, 0); - LED(3, 0); - LED(4, 0); - LED(5, 0); - RS232_puts_p(countdownstart); - } - } + if (btn_start == 0) startbutton(); old_start = btn_start; }