Compare commits
No commits in common. "77d5ef1b5cfa83ec1fca40ba1b4d17ed59f067a8" and "e8fb1f2bb369f0515cdc9435ed62b6bcb24a85bb" have entirely different histories.
77d5ef1b5c
...
e8fb1f2bb3
|
@ -166,7 +166,6 @@ void setup() {
|
|||
|
||||
|
||||
myPort = new Serial(this, "/dev/ttyUSB0", 115200);
|
||||
//myPort = new Serial(this, "COM3", 115200);
|
||||
}
|
||||
|
||||
void Set() {
|
||||
|
@ -192,6 +191,7 @@ void printHeightmap() {
|
|||
myPort.write(writeserial);
|
||||
}
|
||||
|
||||
|
||||
void Debug() {
|
||||
String writeserial="debug\n";
|
||||
myPort.write(writeserial);
|
||||
|
|
30
src/main.cpp
30
src/main.cpp
|
@ -35,7 +35,7 @@ void saveHeightmapRaw();
|
|||
|
||||
#define PIN_LDR A0 //comment if not used
|
||||
|
||||
#define PIN D4
|
||||
#define PIN D2
|
||||
#define NUMPIXELS 600
|
||||
|
||||
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
@ -46,7 +46,7 @@ long lastRoutineUpdate=0;
|
|||
#define ROUTINEUPDATETIME 20
|
||||
long lastCheckspawn=0;
|
||||
#define CHECKSPAWNDELAY 2000 //delay in ms to check random spawn
|
||||
#define SPAWNCHANCE 10 //1 out of x times wagon will spawn
|
||||
#define SPAWNCHANCE 20 //1 out of x times wagon will spawn
|
||||
#define SPAWNCHANCEDOUBLE 5 //change of spawning a two trains simultaneously
|
||||
long lastCheckspawnEffect=0;
|
||||
#define CHECKSPAWNDELAY_EFFECT 5000 //delay in ms to check random effect
|
||||
|
@ -263,23 +263,22 @@ void spawnWagon(){
|
|||
// pos, wagonlength, startvel , startacc, trainmass, wagoncolor
|
||||
//Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, random(0, 20), _randomlength, random(map(_randomlength,3,40,1,1), map(_randomlength,3,40, 13,40))/10.0 , 0 , 5 , Wheel((uint8_t)random(0,255))); //spawn new wagon
|
||||
|
||||
int side_startpos=0; //start at beginning of strip
|
||||
int side_multi=1; //start in forward direction
|
||||
int side_startpos=0;
|
||||
int side_multi=1;
|
||||
|
||||
|
||||
/*if (random(0,2)==0){ //spawn from other side
|
||||
/*
|
||||
if (random(0,2)==0){ //spawn from other side
|
||||
side_startpos=NUMPIXELS+_randomlength;
|
||||
side_multi=-1;
|
||||
}*/
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
//Force start from end of strip
|
||||
//side_startpos=NUMPIXELS+_randomlength; //start at end of strip
|
||||
//side_multi=-1; //start in backward direction
|
||||
side_startpos=NUMPIXELS+_randomlength;
|
||||
side_multi=-1;
|
||||
|
||||
//Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,30,0,40)/10.0, map(_randomlength,3,30, 5,60))/10.0 , 0 , random(3.0,7.0) , Wheel((uint8_t)random(0,255))); //spawn new wagon
|
||||
Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,30,30,100)/10.0, map(_randomlength,3,30, 5,60))/10.0 , 0 , 1.8 , Wheel((uint8_t)random(0,255))); //spawn new wagon
|
||||
//Mass: the lighter the faster is changes speed
|
||||
Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,20,0,10)/10.0, map(_randomlength,3,20, 5,40))/10.0 , 0 , random(3.0,7.0) , Wheel((uint8_t)random(0,255))); //spawn new wagon
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -310,8 +309,8 @@ void loop() {
|
|||
if (millis()-last_ldrread > 10000) {
|
||||
int _light=analogRead(PIN_LDR);
|
||||
uint8_t _brightness = constrain(map(_light, LDR_MIN, LDR_MAX, BRIGHTNESS_RUN_MIN, BRIGHTNESS_RUN), BRIGHTNESS_RUN_MIN, BRIGHTNESS_RUN);
|
||||
//Serial.print("kilian="); Serial.println(_light);
|
||||
//Serial.print("ergbebinis="); Serial.println(_brightness);
|
||||
Serial.print("kilian="); Serial.println(_light);
|
||||
Serial.print("ergbebinis="); Serial.println(_brightness);
|
||||
strip.setBrightness(_brightness);
|
||||
last_ldrread=millis();
|
||||
}
|
||||
|
@ -678,7 +677,6 @@ void saveHeightmapRaw(){
|
|||
c_eepromaddress++;
|
||||
|
||||
}
|
||||
Serial.println("Saved to EEPROM");
|
||||
EEPROM.commit(); //write changes to eeprom. EEPROM.end() will also commit and release the ram copy of eeprom contents
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue