From aa090c6de83efde875a6bbf5847a5d6e93c6cf9b Mon Sep 17 00:00:00 2001 From: Angel Maldonado Date: Sun, 29 Sep 2019 13:30:36 +0200 Subject: [PATCH] Added visual effect of the winning car Compatibility with new hardware --- lib/Openledrace-lib/olr-controller.h | 4 ++-- src/open-led-race.ino | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/Openledrace-lib/olr-controller.h b/lib/Openledrace-lib/olr-controller.h index 74dbbfc..8bf36d6 100644 --- a/lib/Openledrace-lib/olr-controller.h +++ b/lib/Openledrace-lib/olr-controller.h @@ -12,8 +12,8 @@ extern "C"{ #include -#define PIN_P1 A2 // switch player 1 to PIN and GND -#define PIN_P2 A3 // switch player 2 to PIN and GND +#define PIN_P1 A0 // switch player 1 to PIN and GND +#define PIN_P2 A2 // switch player 2 to PIN and GND #define PIN_VCC_ADC1 6 // switch player 1 to PIN and GND #define PIN_VCC_ADC2 7 // switch player 2 to PIN and GND diff --git a/src/open-led-race.ino b/src/open-led-race.ino index c4f0229..97e875f 100644 --- a/src/open-led-race.ino +++ b/src/open-led-race.ino @@ -27,7 +27,7 @@ #include "olr-lib.h" #include "olr-param.h" -#define PIN_LED A0 // R 500 ohms to DI pin for WS2812 and WS2813, for WS2813 BI pin of first LED to GND , CAP 1000 uF to VCC 5v/GND,power supplie 5V 2A +#define PIN_LED 2 // R 500 ohms to DI pin for WS2812 and WS2813, for WS2813 BI pin of first LED to GND , CAP 1000 uF to VCC 5v/GND,power supplie 5V 2A #define PIN_AUDIO 3 // through CAP 2uf to speaker 8 ohms #define EOL '\n' @@ -155,8 +155,8 @@ void setup() { init_track( &tck ); init_car( &cars[0], &switchs[0], COLOR1 ); init_car( &cars[1], &switchs[1], COLOR2 ); - init_controller( &switchs[0], DEBUG_MODE, PIN_P1 ); - init_controller( &switchs[1], DEBUG_MODE, PIN_P2 ); + init_controller( &switchs[0], DIGITAL_MODE, PIN_P1 ); + init_controller( &switchs[1], DIGITAL_MODE, PIN_P2 ); track.begin(); @@ -222,6 +222,7 @@ void loop() { if( cars[i].st == CAR_FINISH ) { race.phase = COMPLETE; send_phase( race.phase ); + break; } } @@ -286,8 +287,9 @@ void run_racecycle( car_t *car, int i ) { if ( car->st == CAR_FINISH ){ car->trackID = NOT_TRACK; + draw_win( &tck, car ); sprintf( txbuff, "w%d%c", i + 1, EOL ); - Serial.print( txbuff );init_ramp( &tck ); + Serial.print( txbuff ); } } @@ -394,6 +396,11 @@ void draw_coin( track_t* tck ) { track.setPixelColor( 1 + cfg->nled_main + tck->led_speed, track.Color(0,0,250) ); } +void draw_win( track_t* tck, car_t* car) { + int const maxled = tck->cfg.track.nled_total; + for(int i=0; icolor ); +} void draw_car( track_t* tck, car_t* car ) { struct cfgtrack const* cfg = &tck->cfg.track;