Compare commits

..

2 Commits

Author SHA1 Message Date
interfisch 77d5ef1b5c new config raum3 ctdo 2024-01-12 22:36:33 +01:00
interfisch 2b8f5381d9 change parameters 2021-10-16 14:43:55 +02:00
2 changed files with 17 additions and 15 deletions

View File

@ -166,6 +166,7 @@ void setup() {
myPort = new Serial(this, "/dev/ttyUSB0", 115200);
//myPort = new Serial(this, "COM3", 115200);
}
void Set() {
@ -191,7 +192,6 @@ void printHeightmap() {
myPort.write(writeserial);
}
void Debug() {
String writeserial="debug\n";
myPort.write(writeserial);

View File

@ -35,7 +35,7 @@ void saveHeightmapRaw();
#define PIN_LDR A0 //comment if not used
#define PIN D2
#define PIN D4
#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 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
long lastCheckspawnEffect=0;
#define CHECKSPAWNDELAY_EFFECT 5000 //delay in ms to check random effect
@ -263,22 +263,23 @@ 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;
int side_multi=1;
int side_startpos=0; //start at beginning of strip
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_multi=-1;
}
*/
}*/
//Force start from end of strip
side_startpos=NUMPIXELS+_randomlength;
side_multi=-1;
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
//side_startpos=NUMPIXELS+_randomlength; //start at end of strip
//side_multi=-1; //start in backward direction
//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) {
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();
}
@ -677,6 +678,7 @@ 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
}