implement effect as abstract class. implement fx_scanner
This commit is contained in:
parent
f6b8fa4ff4
commit
12acffc57c
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "wagon.h"
|
#include "wagon.h"
|
||||||
|
#include "effect.h"
|
||||||
#include "fx_scanner.h"
|
#include "fx_scanner.h"
|
||||||
|
|
||||||
#define PIN D2
|
#define PIN D2
|
||||||
|
@ -40,7 +41,7 @@ int selectedpixel=-1; //-1 = none
|
||||||
|
|
||||||
uint8_t wagoncount=0;
|
uint8_t wagoncount=0;
|
||||||
|
|
||||||
FX_Scanner effect;
|
Effect* effect = NULL;
|
||||||
|
|
||||||
|
|
||||||
//define config
|
//define config
|
||||||
|
@ -379,7 +380,10 @@ void checkSerial(){
|
||||||
}
|
}
|
||||||
}else if (serialstring.equals("fx_scanner")){
|
}else if (serialstring.equals("fx_scanner")){
|
||||||
Serial.println("Effect Scanner");
|
Serial.println("Effect Scanner");
|
||||||
effect=FX_Scanner(NUMPIXELS,&strip,height,255,-200,strip.Color(100,0,0));
|
if (effect!=NULL){
|
||||||
|
delete effect;
|
||||||
|
}
|
||||||
|
effect=new FX_Scanner(NUMPIXELS,&strip,height,255,-200,strip.Color(100,0,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -425,8 +429,10 @@ void loop_achterbahn(){
|
||||||
}
|
}
|
||||||
|
|
||||||
//Effects
|
//Effects
|
||||||
if (effect.active()){
|
if (effect != NULL ){
|
||||||
effect.updateGraphics();
|
if (effect->active()){
|
||||||
|
effect->updateGraphics();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strip.show();
|
strip.show();
|
||||||
|
@ -459,8 +465,13 @@ void loop_achterbahn(){
|
||||||
}
|
}
|
||||||
|
|
||||||
//Effects
|
//Effects
|
||||||
if (effect.active()){
|
if (effect != NULL ){
|
||||||
effect.updateRoutine(ROUTINEUPDATETIME);
|
if (effect->active()){
|
||||||
|
effect->updateRoutine(ROUTINEUPDATETIME);
|
||||||
|
}else{ //effect not active anymore
|
||||||
|
delete effect;
|
||||||
|
effect=NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef EFFECT_H
|
||||||
|
#define EFFECT_H
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
class Effect
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Effect(){}
|
||||||
|
virtual void updateRoutine(float updatedelayms) = 0;
|
||||||
|
virtual void updateGraphics() = 0;
|
||||||
|
virtual bool active() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "fx_scanner.h"
|
#include "fx_scanner.h"
|
||||||
|
#include "effect.h"
|
||||||
|
|
||||||
FX_Scanner::FX_Scanner(int numpixels,Adafruit_NeoPixel *strip,uint8_t *height,int startpos,float scannervel,uint32_t scannercolor)
|
FX_Scanner::FX_Scanner(int numpixels,Adafruit_NeoPixel *strip,uint8_t *height,int startpos,float scannervel,uint32_t scannercolor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
#define FX_SCANNER_H
|
#define FX_SCANNER_H
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "effect.h"
|
||||||
|
|
||||||
class FX_Scanner
|
class FX_Scanner : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FX_Scanner(int numpixels,Adafruit_NeoPixel *strip,uint8_t *height,int startpos,float scannervel,uint32_t scannercolor);
|
FX_Scanner(int numpixels,Adafruit_NeoPixel *strip,uint8_t *height,int startpos,float scannervel,uint32_t scannercolor);
|
||||||
|
|
Loading…
Reference in New Issue