From b859b30ce49b480231f759fa5bcb4bc63182587a Mon Sep 17 00:00:00 2001 From: Fisch Date: Mon, 14 Dec 2020 23:30:12 +0100 Subject: [PATCH] adjust settings --- src/main.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6e8215c..2dbc14c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,7 @@ #include "effect.h" #include "fx_scanner.h" #include "fx_flash.h" +#include "fx_stars.h" void resetHeightmap(); @@ -32,6 +33,7 @@ uint32_t Wheel(byte WheelPos); void loadHeightmapRaw(); void saveHeightmapRaw(); +#define PIN_LDR A0 //comment if not used #define PIN D2 #define NUMPIXELS 600 @@ -43,17 +45,24 @@ long lastPixelUpdate=0; long lastRoutineUpdate=0; #define ROUTINEUPDATETIME 20 long lastCheckspawn=0; -#define CHECKSPAWNDELAY 4000 //delay in ms to check random spawn -#define SPAWNCHANCE 10 //1 out of x times wagon will spawn +#define CHECKSPAWNDELAY 2000 //delay in ms to check random spawn +#define SPAWNCHANCE 40 //1 out of x times wagon will spawn #define SPAWNCHANCEDOUBLE 5 //change of spawning a two trains simultaneously long lastCheckspawnEffect=0; #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_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 LDR_MIN 700 +#define LDR_MAX 150 +unsigned long last_ldrread=0; + long loopmillis=0; uint8_t height[NUMPIXELS]; @@ -89,10 +98,15 @@ long last_changePersistancemode=0; void setup() { Serial.begin(115200); + #ifdef PIN_LDR + pinMode(PIN_LDR, INPUT); + #endif + EEPROM.begin(4096); //set eeprom size, between 4 and 4096 bytes. strip.begin(); strip.setBrightness(BRIGHTNESS_RUN); //150 + strip.show(); // Initialize all pixels to 'off' Serial.println("Started"); @@ -289,6 +303,17 @@ void spawnWagon(float pos, float wagonlength,float startvel, float startacc, flo void loop() { 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(); if (configmode){ @@ -437,6 +462,9 @@ void checkSerial(){ }else if (serialstring.equals("fx_flash")){ Serial.println("Effect Flash"); 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)); }else if (random(0,SPAWNCHANCE_EFFECT_FLASH)==0){ 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); + }*/ }