Compare commits

..

No commits in common. "e8fb1f2bb369f0515cdc9435ed62b6bcb24a85bb" and "b859b30ce49b480231f759fa5bcb4bc63182587a" have entirely different histories.

7 changed files with 33 additions and 138 deletions

View File

@ -18,7 +18,7 @@ PImage image_clear;
int currentID=0;
//int MAXID = 50; //inclusive
//int MAXID = 599;
int MAXID = 599;
int MAXID = 10;
int searchstate=0; //0=get reference image and ping box, 1=wait, 2=get image to compare and turn box off, 3=wait
long starttime_wait=0;

View File

@ -55,9 +55,15 @@ void FX_Flash::updateGraphics()
uint16_t _tmpr=_pxr+_r; //add colors
uint16_t _tmpg=_pxg+_g;
uint16_t _tmpb=_pxb+_b;
_tmpr=constrain(_tmpr,0,255);
_tmpg=constrain(_tmpg,0,255);
_tmpb=constrain(_tmpb,0,255);
if (_tmpr>255){ //clamp
_tmpr=255;
}
if (_tmpg>255){
_tmpg=255;
}
if (_tmpb>255){
_tmpb=255;
}
_strip->setPixelColor(i,_tmpr,_tmpg,_tmpb); //draw pixel
}

View File

@ -49,9 +49,15 @@ void FX_Scanner::updateGraphics()
uint16_t _tmpr=_pxr+_r; //add colors
uint16_t _tmpg=_pxg+_g;
uint16_t _tmpb=_pxb+_b;
_tmpr=constrain(_tmpr,0,255);
_tmpg=constrain(_tmpg,0,255);
_tmpb=constrain(_tmpb,0,255);
if (_tmpr>255){ //clamp
_tmpr=255;
}
if (_tmpg>255){
_tmpg=255;
}
if (_tmpb>255){
_tmpb=255;
}
_strip->setPixelColor(i,_tmpr,_tmpg,_tmpb); //draw pixel
}
}

View File

@ -1,87 +0,0 @@
#include "fx_shootingstar.h"
#include "effect.h"
FX_ShootingStar::FX_ShootingStar(int numpixels,Adafruit_NeoPixel *strip,uint8_t *height)
{
_numpixels=numpixels;
_strip=strip;
_starttime=millis();
_brightness=0;
_duration=random(200,3000);
_height=height;
//find a random pixel
_vel=0;
while (_vel==0)
{
_pos=random(10,numpixels-10); //start with random position
int _postest=0;
while(_vel<=0 && _postest<10) {
_postest++;
_vel = _height[_pos] - _height[_pos+_postest]; //height difference
}
_postest=0;
while(_vel<=0 && _postest>-10) {
_postest--;
_vel = _height[_pos] - _height[_pos+_postest]; //height difference
}
}
}
FX_ShootingStar::FX_ShootingStar()
{
}
void FX_ShootingStar::updateRoutine(float updatedelayms)
{
}
void FX_ShootingStar::updateGraphics()
{
#define STARTFLASHHEIGHT 100
#define BRIGHTFLASHHEIGHT 150
for(int i=0;i<_numpixels;i++){
if (_height[i]>=STARTFLASHHEIGHT){
uint8_t heightbrightness=map(_height[i],STARTFLASHHEIGHT,BRIGHTFLASHHEIGHT,0,255);
uint8_t _r = 1 >> 16;
uint8_t _g = 1 >> 8;
uint8_t _b = 1;
_r*=_brightness/255.0;
_g*=_brightness/255.0;
_b*=_brightness/255.0;
_r*=heightbrightness/255.0;
_g*=heightbrightness/255.0;
_b*=heightbrightness/255.0;
uint32_t _pxcolor=_strip->getPixelColor(i); //get current color of that pixel
uint8_t _pxr = _pxcolor >> 16;
uint8_t _pxg = _pxcolor >> 8;
uint8_t _pxb = _pxcolor;
uint16_t _tmpr=_pxr+_r; //add colors
uint16_t _tmpg=_pxg+_g;
uint16_t _tmpb=_pxb+_b;
_tmpr=constrain(_tmpr,0,255);
_tmpg=constrain(_tmpr,0,255);
_tmpb=constrain(_tmpr,0,255);
_strip->setPixelColor(i,_tmpr,_tmpg,_tmpb); //draw pixel
}
}
}
bool FX_ShootingStar::active()
{
/*
if (millis()-_starttime>_flashtime){
return false;
}*/
return true;
}

View File

@ -1,27 +0,0 @@
#ifndef FX_SHOOTINGSTAR_H
#define FX_SHOOTINGSTAR_H
#include <Adafruit_NeoPixel.h>
#include <math.h>
#include "effect.h"
class FX_ShootingStar : public Effect
{
public:
FX_ShootingStar(int numpixels,Adafruit_NeoPixel *strip,uint8_t *height);
FX_ShootingStar();
void updateRoutine(float updatedelayms);
void updateGraphics();
uint32_t Wheel(byte WheelPos,float brightness);
bool active();
private:
int _numpixels;
Adafruit_NeoPixel *_strip;
long _starttime;
uint8_t _brightness;
long _duration;
uint8_t *_height;
int _pos;
float _vel;
};
#endif

View File

@ -15,7 +15,7 @@
#include "effect.h"
#include "fx_scanner.h"
#include "fx_flash.h"
//#include "fx_shootingstar.h"
#include "fx_stars.h"
void resetHeightmap();
@ -46,18 +46,17 @@ 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 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 5000 //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_FLASH 1000 //1 out of x times spawn effect
#define SPAWNCHANCE_EFFECT_SHOOTINGSTAR 100 //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 //max brightness
//#define BRIGHTNESS_RUN_MIN 20
#define BRIGHTNESS_RUN_MIN 200
#define BRIGHTNESS_RUN_MIN 20
#define BRIGHTNESS_DEBUG 150
#define LDR_MIN 700
@ -105,7 +104,6 @@ void setup() {
EEPROM.begin(4096); //set eeprom size, between 4 and 4096 bytes.
strip.begin();
strip.setBrightness(BRIGHTNESS_RUN); //150
@ -277,7 +275,7 @@ void spawnWagon(){
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
Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, side_startpos, _randomlength, side_multi*random(map(_randomlength,3,20,5,10), map(_randomlength,3,20, 5,40))/10.0 , 0 , 5.0 , Wheel((uint8_t)random(0,255))); //spawn new wagon
@ -464,10 +462,10 @@ 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_shootingstar")){
Serial.println("Effect Shooting Star");
effect=new FX_ShootingStar(NUMPIXELS,&strip,height);
}*/
}else if (serialstring.equals("fx_stars")){
Serial.println("Effect Stars");
effect=new FX_Stars(NUMPIXELS,&strip,height);
}
}
}
@ -623,8 +621,8 @@ 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_SHOOTINGSTAR)==0){
effect=new FX_ShootingStar(NUMPIXELS,&strip,height);
}/*else if (random(0,SPAWNCHANCE_EFFECT_STARS)==0){
effect=new FX_Stars(NUMPIXELS,&strip,height);
}*/
}

View File

@ -81,8 +81,7 @@ void Wagon::updatePhysics(float updatedelayms)
#define CONST_G 9.81
#define PIXELDISTANCE 1.6666667 // 1/60.0 * 100
#define C_ROLL 0.001 // = Croll https://de.wikipedia.org/wiki/Rollwiderstand 0.001 (zug)
//#define AIRRESFIRST 0.018 //C_w*A*0.5*rho Air resistance: C_w * A * 0.5 * rho (.... *v^2) 0.18
#define AIRRESFIRST 0.05 //C_w*A*0.5*rho Air resistance: C_w * A * 0.5 * rho (.... *v^2) 0.18 test
#define AIRRESFIRST 0.018 //C_w*A*0.5*rho Air resistance: C_w * A * 0.5 * rho (.... *v^2) 0.18
#define AIRRES 0.001 //for slipstream at second wagon
#define AIRRESMUL 0.2 //how much of air resistance the next wagon has
//http://www.kfz-tech.de/Biblio/Formelsammlung/Luftwiderstand.htm C_w 0.6