Effect of ramp and box configurable with the controls after switching on
This commit is contained in:
parent
ce4ae3d0ee
commit
3372cade52
5 changed files with 28 additions and 6 deletions
|
@ -13,8 +13,8 @@ extern "C"{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DIG_CONTROL_1 A0 // switch player 1 to PIN and GND
|
#define DIG_CONTROL_1 A2 // switch player 1 to PIN and GND
|
||||||
#define DIG_CONTROL_2 A2 // switch player 2 to PIN and GND
|
#define DIG_CONTROL_2 A0 // switch player 2 to PIN and GND
|
||||||
#define DIG_CONTROL_3 A1 // switch player 3 to PIN and GND
|
#define DIG_CONTROL_3 A1 // switch player 3 to PIN and GND
|
||||||
#define DIG_CONTROL_4 A3 // switch player 4 to PIN and GND
|
#define DIG_CONTROL_4 A3 // switch player 4 to PIN and GND
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ void init_ramp( track_t* tck ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_ramp( track_t* tck ) {
|
void set_ramp( track_t* tck ) {
|
||||||
struct cfgramp const* r = &tck->cfg.ramp;
|
struct cfgramp* r = &tck->cfg.ramp;
|
||||||
for( int i=0; i<(r->center - r->init); i++ )
|
for( int i=0; i<(r->center - r->init); i++ )
|
||||||
tck->gmap[r->init+i] = 127-i*((float)r->high/(r->center - r->init));
|
tck->gmap[r->init+i] = 127-i*((float)r->high/(r->center - r->init));
|
||||||
|
|
||||||
|
@ -90,6 +90,12 @@ void set_ramp( track_t* tck ) {
|
||||||
|
|
||||||
for( int i=0; i<(r->end - r->center); i++ )
|
for( int i=0; i<(r->end - r->center); i++ )
|
||||||
tck->gmap[r->center+i+1] = 127+r->high-i*((float)r->high/(r->end-r->center));
|
tck->gmap[r->center+i+1] = 127+r->high-i*((float)r->high/(r->end-r->center));
|
||||||
|
|
||||||
|
r->enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ramp_isactive( track_t* tck ) {
|
||||||
|
return tck->cfg.ramp.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ void init_ramp( track_t* tck );
|
||||||
|
|
||||||
void set_ramp( track_t* tck );
|
void set_ramp( track_t* tck );
|
||||||
|
|
||||||
|
bool ramp_isactive( track_t* tck );
|
||||||
|
|
||||||
void init_car( car_t* car, controller_t* ct, uint32_t color );
|
void init_car( car_t* car, controller_t* ct, uint32_t color );
|
||||||
|
|
||||||
void update_track( track_t* tck, car_t* car );
|
void update_track( track_t* tck, car_t* car );
|
||||||
|
|
|
@ -35,6 +35,7 @@ struct cfgramp {
|
||||||
int center;
|
int center;
|
||||||
int end;
|
int end;
|
||||||
int high;
|
int high;
|
||||||
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct brdinfo {
|
struct brdinfo {
|
||||||
|
|
|
@ -32,14 +32,14 @@
|
||||||
#define EOL '\n'
|
#define EOL '\n'
|
||||||
|
|
||||||
|
|
||||||
#define COLOR1 track.Color(0,255,0)
|
#define COLOR1 track.Color(255,0,0)
|
||||||
#define COLOR2 track.Color(255,0,0)
|
#define COLOR2 track.Color(0,255,0)
|
||||||
#define COLOR3 track.Color(255,255,255)
|
#define COLOR3 track.Color(255,255,255)
|
||||||
#define COLOR4 track.Color(0,0,255)
|
#define COLOR4 track.Color(0,0,255)
|
||||||
|
|
||||||
|
|
||||||
enum{
|
enum{
|
||||||
MAX_CARS = 4,
|
MAX_CARS = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,6 +176,16 @@ void setup() {
|
||||||
|
|
||||||
track.begin();
|
track.begin();
|
||||||
|
|
||||||
|
if ( digitalRead( DIG_CONTROL_1 ) == 0 ) { //push switch 1 on reset for activate physic
|
||||||
|
set_ramp( &tck );
|
||||||
|
draw_ramp( &tck );
|
||||||
|
track.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( digitalRead( DIG_CONTROL_2 ) == 0 ) { //push switch 2 on reset for activate box
|
||||||
|
track_configure( &tck, 240 );
|
||||||
|
}
|
||||||
|
|
||||||
race.cfg.startline = true;
|
race.cfg.startline = true;
|
||||||
race.cfg.nlap = 5;
|
race.cfg.nlap = 5;
|
||||||
race.cfg.nrepeat = 1;
|
race.cfg.nrepeat = 1;
|
||||||
|
@ -225,6 +235,9 @@ void loop() {
|
||||||
tck.ledtime = millis() + random(2000,7000);
|
tck.ledtime = millis() + random(2000,7000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( ramp_isactive( &tck ) )
|
||||||
|
draw_ramp( &tck );
|
||||||
|
|
||||||
if( tck.ledcoin > 0 )
|
if( tck.ledcoin > 0 )
|
||||||
draw_coin( &tck );
|
draw_coin( &tck );
|
||||||
else if( millis() > tck.ledtime )
|
else if( millis() > tck.ledtime )
|
||||||
|
|
Loading…
Add table
Reference in a new issue