blackbox/main.c

changeset 144
8f07a8d15826
parent 143
cb514887cf17
child 145
80be5eb283d3
equal deleted inserted replaced
143:cb514887cf17 144:8f07a8d15826
531 slot[i].lap_time.value = 0; 531 slot[i].lap_time.value = 0;
532 } 532 }
533 sysclk.value = 0; 533 sysclk.value = 0;
534 } 534 }
535 535
536 void LED_REMOTE(uint8_t led) {
537 program_id = 6;
538 program_command = 0;
539 program_parameter = led;
540 program_count = 1;
541 }
542
536 void countdown_progress(void) { 543 void countdown_progress(void) {
537 // decrement COUNTDOWN_LOOPS 544 // decrement COUNTDOWN_LOOPS
538 if (countdown_loops>0) { 545 if (countdown_loops>0) {
539 countdown_loops--; 546 countdown_loops--;
540 } else { 547 } else {
541 countdown--; 548 countdown--;
542 countdown_loops = COUNTDOWN_DELAY; 549 countdown_loops = COUNTDOWN_DELAY;
543 } 550 }
544 switch (countdown) { 551 switch (countdown) {
545 case 5: LED(1, 1); break; 552 case 5: LED(1, 1); LED_REMOTE(1); break;
546 case 4: LED(2, 1); break; 553 case 4: LED(2, 1); LED_REMOTE(2); break;
547 case 3: LED(3, 1); break; 554 case 3: LED(3, 1); LED_REMOTE(3); break;
548 case 2: LED(4, 1); break; 555 case 2: LED(4, 1); LED_REMOTE(4); break;
549 case 1: LED(5, 1); break; 556 case 1: LED(5, 1); LED_REMOTE(5); break;
550 case 0: { // RACE START! 557 case 0: { // RACE START!
551 sysclk.value = 0; 558 sysclk.value = 0;
552 LEDS_OFF(); 559 LEDS_OFF();
553 LED(3, 1); 560 LED(3, 1);
561 LED_REMOTE(0);
554 mode = 3; 562 mode = 3;
555 } break; 563 } break;
556 } 564 }
557 } 565 }
558 566
706 if (mode==3) { 714 if (mode==3) {
707 // RACE START! 715 // RACE START!
708 // issue reset command to lap counter 716 // issue reset command to lap counter
709 mode = 0; 717 mode = 0;
710 RS232_puts_p(racestart); 718 RS232_puts_p(racestart);
719
720 /* BUG??
711 program_command = 6; 721 program_command = 6;
712 program_parameter = 9; 722 program_parameter = 9;
713 program_id = 0; 723 program_id = 0;
714 program_count = 1; 724 program_count = 1;
725 */
726
715 LAP_COUNTER_PORT |= _BV(LAP_COUNTER); 727 LAP_COUNTER_PORT |= _BV(LAP_COUNTER);
716 // TODO: beep long 728 // TODO: beep long
717 _delay_us(50); 729 _delay_us(50);
718 LAP_COUNTER_PORT &= ~_BV(LAP_COUNTER); 730 LAP_COUNTER_PORT &= ~_BV(LAP_COUNTER);
719 } 731 }

mercurial