From 4628d357704565af5d0a1273a7f8d42d2fa27daa Mon Sep 17 00:00:00 2001 From: Fisch Date: Wed, 5 Jun 2019 01:54:20 +0200 Subject: [PATCH] add persistancemodes --- achterbahn.ino | 42 ++++++++++++++++++++++++++++++++++++++++-- wagon.cpp | 10 +--------- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/achterbahn.ino b/achterbahn.ino index 16f87cd..eac2242 100644 --- a/achterbahn.ino +++ b/achterbahn.ino @@ -14,6 +14,7 @@ #include "fx_scanner.h" #include "fx_flash.h" + #define PIN D2 #define NUMPIXELS 600 @@ -51,6 +52,15 @@ uint8_t wagoncount=0; Effect* effect = NULL; +//Persistance effects +#define PERSMODE_BLACK 0 +#define PERSMODE_FADEPERCENT 1 +#define NUM_PERSMODE 2 //number of available persistancemodes +uint8_t persistancemode=PERSMODE_BLACK; +long last_changePersistancemode=0; +#define PERSISTANCEMODECHANGE_DELAY 180000 + + //define config //#define RESPAWNWAGON @@ -410,8 +420,36 @@ void loop_achterbahn(){ lastPixelUpdate=loopmillis; for (int i=0;i> 16; + uint8_t _pxg = _pxcolor >> 8; + uint8_t _pxb = _pxcolor; + + uint32_t c=strip.Color(_pxr*0.99,_pxg*0.99,_pxb*0.99); + strip.setPixelColor(i,c); + break; + } + case PERSMODE_BLACK: default: + { + uint32_t c=strip.Color(0,0,0); + strip.setPixelColor(i,c); + break; + } + } + } + + //possible persistancemode change + if (millis()>last_changePersistancemode+PERSISTANCEMODECHANGE_DELAY) { + if (random(0,10)!=0){ + persistancemode = PERSMODE_BLACK; + }else{ + persistancemode=random(1,NUM_PERSMODE); + } + last_changePersistancemode = millis(); } //Wagons diff --git a/wagon.cpp b/wagon.cpp index 2830113..e5c3fe5 100644 --- a/wagon.cpp +++ b/wagon.cpp @@ -305,15 +305,7 @@ void Wagon::updateGraphics() _tmpr=(uint16_t)(min(255,_tmpr*_brightnesscorrection)); _tmpg=(uint16_t)(min(255,_tmpg*_brightnesscorrection)); _tmpb=(uint16_t)(min(255,_tmpb*_brightnesscorrection)); - /*if (_tmpr>255){ //clamp - _tmpr=255; - } - if (_tmpg>255){ - _tmpg=255; - } - if (_tmpb>255){ - _tmpb=255; - }*/ + _strip->setPixelColor(iCorrected,_tmpr,_tmpg,_tmpb); //draw pixel } }