Added visual effect of the winning car

Compatibility with new hardware
This commit is contained in:
Angel Maldonado 2019-09-29 13:30:36 +02:00
parent c4f360455b
commit aa090c6de8
2 changed files with 13 additions and 6 deletions

View file

@ -12,8 +12,8 @@ extern "C"{
#include <stdbool.h>
#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

View file

@ -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; i<maxled; ++i )
track.setPixelColor(i, car->color );
}
void draw_car( track_t* tck, car_t* car ) {
struct cfgtrack const* cfg = &tck->cfg.track;