ver 0.9.c
This commit is contained in:
parent
c0935700ae
commit
8b761685cc
4 changed files with 76 additions and 24 deletions
19
changelog.txt
Normal file
19
changelog.txt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Revisions history
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
* 2020-07-16: Ver 0.9.c - Luca
|
||||||
|
- Changes in [I/O Pin]<>[Car Color] association to match
|
||||||
|
the desired Phisical Buttons Layout (Quick Start Guide)
|
||||||
|
- Box/Pitlane
|
||||||
|
- Entry/exit point marked to help put in place led strip (circuit shape)
|
||||||
|
- Coin "Boost" scaled up to make "catch it" worth (almost always win the race)
|
||||||
|
- Minor bugfix:
|
||||||
|
- box_init(), box_isactive() use wrong var "rampactive"
|
||||||
|
|
||||||
|
* 2020-07-16: Ver 0.9.b - Gerardo
|
||||||
|
- Sound FX added
|
||||||
|
|
||||||
|
* 2019-10-10 - Ver 0.9.a
|
||||||
|
-First public Version by Angel Maldonado (Maker Faire Roma 2019)
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,10 @@ extern "C"{
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DIG_CONTROL_1 A2 // switch player 1 to PIN and GND
|
#define DIG_CONTROL_1 A2 // switch player 1 to PIN and GND
|
||||||
#define DIG_CONTROL_2 A0 // 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 A3 // switch player 3 to PIN and GND
|
||||||
#define DIG_CONTROL_4 A3 // switch player 4 to PIN and GND
|
#define DIG_CONTROL_4 A1 // switch player 4 to PIN and GND
|
||||||
|
|
||||||
#define PIN_VCC_ADC1 6
|
#define PIN_VCC_ADC1 6
|
||||||
#define PIN_VCC_ADC2 7
|
#define PIN_VCC_ADC2 7
|
||||||
|
|
|
@ -51,7 +51,7 @@ void process_aux_track( track_t* tck, car_t* car ){
|
||||||
|
|
||||||
if ( (int)car->dist_aux == tck->ledcoin
|
if ( (int)car->dist_aux == tck->ledcoin
|
||||||
&& car->speed <= controller_getAccel() ) {
|
&& car->speed <= controller_getAccel() ) {
|
||||||
car->speed = controller_getAccel ()*10;
|
car->speed = controller_getAccel ()*50;
|
||||||
tck->ledcoin = COIN_RESET;
|
tck->ledcoin = COIN_RESET;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,11 +98,11 @@ void car_resetPosition( car_t* car) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void box_init( track_t* tck ) {
|
void box_init( track_t* tck ) {
|
||||||
tck->rampactive = true;
|
tck->boxactive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool box_isactive( track_t* tck ) {
|
bool box_isactive( track_t* tck ) {
|
||||||
return tck->rampactive;
|
return tck->boxactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
int box_configure( track_t* tck, int init_box ) {
|
int box_configure( track_t* tck, int init_box ) {
|
||||||
|
@ -122,4 +122,3 @@ int ramp_configure( track_t* tck, int center, int high ) {
|
||||||
ramp->high = high;
|
ramp->high = high;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,30 @@
|
||||||
the Free Software Foundation; either version 3 of the License, or
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
by gbarbarov@singulardevices.com for Arduino day Seville 2019
|
|
||||||
|
|
||||||
Code made dirty and fast, next improvements in:
|
First public version by:
|
||||||
https://github.com/gbarbarov/led-race
|
Angel Maldonado (https://gitlab.com/angeljmc)
|
||||||
|
|
||||||
|
Basen on original idea and 2 players code by:
|
||||||
|
gbarbarov@singulardevices.com for Arduino day Seville 2019
|
||||||
|
https://github.com/gbarbarov/led-race
|
||||||
|
|
||||||
|
|
||||||
|
Public Repository for this code:
|
||||||
|
https://gitlab.com/open-led-race/olr-arduino
|
||||||
|
|
||||||
|
|
||||||
|
2020/07/16 - Ver 0.9.c
|
||||||
|
--see changelog.txt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
char const version[] = "0.9.c";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include "AsyncSerialLib.h"
|
#include "AsyncSerialLib.h"
|
||||||
|
@ -34,11 +52,12 @@
|
||||||
|
|
||||||
#define COLOR1 track.Color(255,0,0)
|
#define COLOR1 track.Color(255,0,0)
|
||||||
#define COLOR2 track.Color(0,255,0)
|
#define COLOR2 track.Color(0,255,0)
|
||||||
#define COLOR3 track.Color(255,255,255)
|
#define COLOR3 track.Color(0,0,255)
|
||||||
#define COLOR4 track.Color(0,0,255)
|
#define COLOR4 track.Color(255,255,255)
|
||||||
|
|
||||||
#define COLOR_RAMP track.Color(64,0,64)
|
#define COLOR_RAMP track.Color(64,0,64)
|
||||||
#define COLOR_COIN track.Color(0,255,255)
|
#define COLOR_COIN track.Color(0,255,255)
|
||||||
|
#define COLOR_BOXMARKS track.Color(64,64,0)
|
||||||
#define LED_SEMAPHORE 12
|
#define LED_SEMAPHORE 12
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +149,6 @@ int win_music[] = {
|
||||||
|
|
||||||
//int TBEEP=3;
|
//int TBEEP=3;
|
||||||
|
|
||||||
char const version[] = "0.9";
|
|
||||||
char tracksID[ NUM_TRACKS ][2] ={"U","M","B","I","O"};
|
char tracksID[ NUM_TRACKS ][2] ={"U","M","B","I","O"};
|
||||||
|
|
||||||
/* ----------- Function prototypes ------------------- */
|
/* ----------- Function prototypes ------------------- */
|
||||||
|
@ -150,6 +168,7 @@ AsyncSerial asyncSerial(data, dataLength,
|
||||||
Adafruit_NeoPixel track = Adafruit_NeoPixel( MAXLED, PIN_LED, NEO_GRB + NEO_KHZ800 );
|
Adafruit_NeoPixel track = Adafruit_NeoPixel( MAXLED, PIN_LED, NEO_GRB + NEO_KHZ800 );
|
||||||
|
|
||||||
|
|
||||||
|
char tmpmsg [20];
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
@ -158,40 +177,44 @@ void setup() {
|
||||||
controller_setup( );
|
controller_setup( );
|
||||||
param_load( &tck.cfg );
|
param_load( &tck.cfg );
|
||||||
|
|
||||||
car_init( &cars[0], &switchs[0], COLOR1 );
|
|
||||||
controller_init( &switchs[0], DIGITAL_MODE, DIG_CONTROL_1 );
|
controller_init( &switchs[0], DIGITAL_MODE, DIG_CONTROL_1 );
|
||||||
car_init( &cars[1], &switchs[1], COLOR2 );
|
car_init( &cars[0], &switchs[0], COLOR1 );
|
||||||
controller_init( &switchs[1], DIGITAL_MODE, DIG_CONTROL_2 );
|
controller_init( &switchs[1], DIGITAL_MODE, DIG_CONTROL_2 );
|
||||||
|
car_init( &cars[1], &switchs[1], COLOR2 );
|
||||||
|
|
||||||
race.numcars = 2;
|
race.numcars = 2;
|
||||||
|
|
||||||
if( controller_isActive( DIG_CONTROL_3 )) {
|
if( controller_isActive( DIG_CONTROL_3 )) {
|
||||||
car_init( &cars[2], &switchs[2], COLOR3 );
|
|
||||||
controller_init( &switchs[2], DIGITAL_MODE, DIG_CONTROL_3 );
|
controller_init( &switchs[2], DIGITAL_MODE, DIG_CONTROL_3 );
|
||||||
|
car_init( &cars[2], &switchs[2], COLOR3 );
|
||||||
++race.numcars;
|
++race.numcars;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( controller_isActive( DIG_CONTROL_4 )) {
|
if( controller_isActive( DIG_CONTROL_4 )) {
|
||||||
car_init( &cars[3], &switchs[3], COLOR4 );
|
|
||||||
controller_init( &switchs[3], DIGITAL_MODE, DIG_CONTROL_4 );
|
controller_init( &switchs[3], DIGITAL_MODE, DIG_CONTROL_4 );
|
||||||
|
car_init( &cars[3], &switchs[3], COLOR4 );
|
||||||
++race.numcars;
|
++race.numcars;
|
||||||
}
|
}
|
||||||
|
|
||||||
track.begin();
|
track.begin();
|
||||||
|
|
||||||
|
// Check Box before Physic/Sound to allow user to have Box and Physics with no sound
|
||||||
|
if ( digitalRead( DIG_CONTROL_2 ) == 0 ) { //push switch 2 on reset for activate boxes (pit lane)
|
||||||
|
box_init( &tck );
|
||||||
|
box_configure( &tck, 240 );
|
||||||
|
}
|
||||||
|
|
||||||
if ( digitalRead( DIG_CONTROL_1 ) == 0 ) { //push switch 1 on reset for activate physics
|
if ( digitalRead( DIG_CONTROL_1 ) == 0 ) { //push switch 1 on reset for activate physics
|
||||||
ramp_init( &tck );
|
ramp_init( &tck );
|
||||||
draw_ramp( &tck );
|
draw_ramp( &tck );
|
||||||
track.show();
|
track.show();
|
||||||
delay(1000);
|
delay(2000);
|
||||||
if ( digitalRead( DIG_CONTROL_1 ) == 0 ) { //retain push switch on reset for activate FX sound
|
if ( digitalRead( DIG_CONTROL_1 ) == 0 ) { //retain push switch on reset for activate FX sound
|
||||||
SMOTOR=1;
|
SMOTOR=1;
|
||||||
tone(PIN_AUDIO,100);}
|
tone(PIN_AUDIO,100);}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( digitalRead( DIG_CONTROL_2 ) == 0 ) { //push switch 2 on reset for activate boxes
|
|
||||||
box_init( &tck );
|
|
||||||
box_configure( &tck, 240 );
|
|
||||||
}
|
|
||||||
|
|
||||||
race.cfg.startline = true;
|
race.cfg.startline = true;
|
||||||
race.cfg.nlap = 5;
|
race.cfg.nlap = 5;
|
||||||
|
@ -227,6 +250,9 @@ void loop() {
|
||||||
if( ramp_isactive( &tck ) ){
|
if( ramp_isactive( &tck ) ){
|
||||||
draw_ramp( &tck );
|
draw_ramp( &tck );
|
||||||
}
|
}
|
||||||
|
if( box_isactive( &tck ) ) {
|
||||||
|
draw_box_entrypoint( &tck );
|
||||||
|
}
|
||||||
track.show();
|
track.show();
|
||||||
delay( 2000 );
|
delay( 2000 );
|
||||||
|
|
||||||
|
@ -469,6 +495,15 @@ void draw_ramp( track_t* tck ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void draw_box_entrypoint( track_t* tck ) {
|
||||||
|
struct cfgtrack const* cfg = &tck->cfg.track;
|
||||||
|
track.setPixelColor(cfg->init_aux ,COLOR_BOXMARKS ); // Pit lane exit (race start)
|
||||||
|
track.setPixelColor(cfg->init_aux - cfg->nled_aux + 1 ,COLOR_BOXMARKS ); // Pit lane Entrance
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void printdebug( const char * msg, int errlevel ) {
|
void printdebug( const char * msg, int errlevel ) {
|
||||||
|
|
||||||
char header[4];
|
char header[4];
|
||||||
|
|
Loading…
Add table
Reference in a new issue