adjust settings

This commit is contained in:
interfisch 2020-12-14 23:30:12 +01:00
parent 64a0f1b51e
commit b859b30ce4
1 changed files with 34 additions and 4 deletions

View File

@ -15,6 +15,7 @@
#include "effect.h" #include "effect.h"
#include "fx_scanner.h" #include "fx_scanner.h"
#include "fx_flash.h" #include "fx_flash.h"
#include "fx_stars.h"
void resetHeightmap(); void resetHeightmap();
@ -32,6 +33,7 @@ uint32_t Wheel(byte WheelPos);
void loadHeightmapRaw(); void loadHeightmapRaw();
void saveHeightmapRaw(); void saveHeightmapRaw();
#define PIN_LDR A0 //comment if not used
#define PIN D2 #define PIN D2
#define NUMPIXELS 600 #define NUMPIXELS 600
@ -43,17 +45,24 @@ long lastPixelUpdate=0;
long lastRoutineUpdate=0; long lastRoutineUpdate=0;
#define ROUTINEUPDATETIME 20 #define ROUTINEUPDATETIME 20
long lastCheckspawn=0; long lastCheckspawn=0;
#define CHECKSPAWNDELAY 4000 //delay in ms to check random spawn #define CHECKSPAWNDELAY 2000 //delay in ms to check random spawn
#define SPAWNCHANCE 10 //1 out of x times wagon will spawn #define SPAWNCHANCE 40 //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 10000 //delay in ms to check random effect #define CHECKSPAWNDELAY_EFFECT 10000 //delay in ms to check random effect
#define SPAWNCHANCE_EFFECT_SCANNER 1000 //1 out of x times spawn effect #define SPAWNCHANCE_EFFECT_SCANNER 1000 //1 out of x times spawn effect
#define SPAWNCHANCE_EFFECT_FLASH 4000 //1 out of x times spawn effect #define SPAWNCHANCE_EFFECT_FLASH 4000 //1 out of x times spawn effect
#define SPAWNCHANCE_EFFECT_STARS 100 //1 out of x times spawn effect
#define BRIGHTNESS_RUN 200
#define BRIGHTNESS_RUN 200 //max brightness
#define BRIGHTNESS_RUN_MIN 20
#define BRIGHTNESS_DEBUG 150 #define BRIGHTNESS_DEBUG 150
#define LDR_MIN 700
#define LDR_MAX 150
unsigned long last_ldrread=0;
long loopmillis=0; long loopmillis=0;
uint8_t height[NUMPIXELS]; uint8_t height[NUMPIXELS];
@ -89,10 +98,15 @@ long last_changePersistancemode=0;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#ifdef PIN_LDR
pinMode(PIN_LDR, INPUT);
#endif
EEPROM.begin(4096); //set eeprom size, between 4 and 4096 bytes. EEPROM.begin(4096); //set eeprom size, between 4 and 4096 bytes.
strip.begin(); strip.begin();
strip.setBrightness(BRIGHTNESS_RUN); //150 strip.setBrightness(BRIGHTNESS_RUN); //150
strip.show(); // Initialize all pixels to 'off' strip.show(); // Initialize all pixels to 'off'
Serial.println("Started"); Serial.println("Started");
@ -289,6 +303,17 @@ void spawnWagon(float pos, float wagonlength,float startvel, float startacc, flo
void loop() { void loop() {
loopmillis=millis(); loopmillis=millis();
#ifdef PIN_LDR
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);
strip.setBrightness(_brightness);
last_ldrread=millis();
}
#endif
checkSerial(); checkSerial();
if (configmode){ if (configmode){
@ -437,6 +462,9 @@ void checkSerial(){
}else if (serialstring.equals("fx_flash")){ }else if (serialstring.equals("fx_flash")){
Serial.println("Effect Flash"); Serial.println("Effect Flash");
effect=new FX_Flash(NUMPIXELS,&strip,height,strip.Color(200,200,200)); effect=new FX_Flash(NUMPIXELS,&strip,height,strip.Color(200,200,200));
}else if (serialstring.equals("fx_stars")){
Serial.println("Effect Stars");
effect=new FX_Stars(NUMPIXELS,&strip,height);
} }
} }
@ -593,7 +621,9 @@ void loop_achterbahn(){
effect=new FX_Scanner(NUMPIXELS,&strip,height,255,-200,strip.Color(100,0,0)); effect=new FX_Scanner(NUMPIXELS,&strip,height,255,-200,strip.Color(100,0,0));
}else if (random(0,SPAWNCHANCE_EFFECT_FLASH)==0){ }else if (random(0,SPAWNCHANCE_EFFECT_FLASH)==0){
effect=new FX_Flash(NUMPIXELS,&strip,height,strip.Color(200,200,200)); effect=new FX_Flash(NUMPIXELS,&strip,height,strip.Color(200,200,200));
} }/*else if (random(0,SPAWNCHANCE_EFFECT_STARS)==0){
effect=new FX_Stars(NUMPIXELS,&strip,height);
}*/
} }