Compare commits
2 Commits
e8fb1f2bb3
...
77d5ef1b5c
Author | SHA1 | Date |
---|---|---|
interfisch | 77d5ef1b5c | |
interfisch | 2b8f5381d9 |
|
@ -166,6 +166,7 @@ void setup() {
|
||||||
|
|
||||||
|
|
||||||
myPort = new Serial(this, "/dev/ttyUSB0", 115200);
|
myPort = new Serial(this, "/dev/ttyUSB0", 115200);
|
||||||
|
//myPort = new Serial(this, "COM3", 115200);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set() {
|
void Set() {
|
||||||
|
@ -191,7 +192,6 @@ void printHeightmap() {
|
||||||
myPort.write(writeserial);
|
myPort.write(writeserial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Debug() {
|
void Debug() {
|
||||||
String writeserial="debug\n";
|
String writeserial="debug\n";
|
||||||
myPort.write(writeserial);
|
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_LDR A0 //comment if not used
|
||||||
|
|
||||||
#define PIN D2
|
#define PIN D4
|
||||||
#define NUMPIXELS 600
|
#define NUMPIXELS 600
|
||||||
|
|
||||||
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||||
|
@ -46,7 +46,7 @@ long lastRoutineUpdate=0;
|
||||||
#define ROUTINEUPDATETIME 20
|
#define ROUTINEUPDATETIME 20
|
||||||
long lastCheckspawn=0;
|
long lastCheckspawn=0;
|
||||||
#define CHECKSPAWNDELAY 2000 //delay in ms to check random spawn
|
#define CHECKSPAWNDELAY 2000 //delay in ms to check random spawn
|
||||||
#define SPAWNCHANCE 20 //1 out of x times wagon will spawn
|
#define SPAWNCHANCE 10 //1 out of x times wagon will spawn
|
||||||
#define SPAWNCHANCEDOUBLE 5 //change of spawning a two trains simultaneously
|
#define SPAWNCHANCEDOUBLE 5 //change of spawning a two trains simultaneously
|
||||||
long lastCheckspawnEffect=0;
|
long lastCheckspawnEffect=0;
|
||||||
#define CHECKSPAWNDELAY_EFFECT 5000 //delay in ms to check random effect
|
#define CHECKSPAWNDELAY_EFFECT 5000 //delay in ms to check random effect
|
||||||
|
@ -263,22 +263,23 @@ void spawnWagon(){
|
||||||
// pos, wagonlength, startvel , startacc, trainmass, wagoncolor
|
// 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
|
//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;
|
int side_startpos=0; //start at beginning of strip
|
||||||
int side_multi=1;
|
int side_multi=1; //start in forward direction
|
||||||
|
|
||||||
/*
|
|
||||||
if (random(0,2)==0){ //spawn from other side
|
/*if (random(0,2)==0){ //spawn from other side
|
||||||
side_startpos=NUMPIXELS+_randomlength;
|
side_startpos=NUMPIXELS+_randomlength;
|
||||||
side_multi=-1;
|
side_multi=-1;
|
||||||
}
|
}*/
|
||||||
*/
|
|
||||||
|
|
||||||
//Force start from end of strip
|
//Force start from end of strip
|
||||||
side_startpos=NUMPIXELS+_randomlength;
|
//side_startpos=NUMPIXELS+_randomlength; //start at end of strip
|
||||||
side_multi=-1;
|
//side_multi=-1; //start in backward direction
|
||||||
|
|
||||||
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
|
//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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -309,8 +310,8 @@ void loop() {
|
||||||
if (millis()-last_ldrread > 10000) {
|
if (millis()-last_ldrread > 10000) {
|
||||||
int _light=analogRead(PIN_LDR);
|
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);
|
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("kilian="); Serial.println(_light);
|
||||||
Serial.print("ergbebinis="); Serial.println(_brightness);
|
//Serial.print("ergbebinis="); Serial.println(_brightness);
|
||||||
strip.setBrightness(_brightness);
|
strip.setBrightness(_brightness);
|
||||||
last_ldrread=millis();
|
last_ldrread=millis();
|
||||||
}
|
}
|
||||||
|
@ -677,6 +678,7 @@ void saveHeightmapRaw(){
|
||||||
c_eepromaddress++;
|
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
|
EEPROM.commit(); //write changes to eeprom. EEPROM.end() will also commit and release the ram copy of eeprom contents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue