Change larson scanner

This commit is contained in:
Juergen Jung 2017-01-31 20:13:45 +01:00
parent 5292c43489
commit 6bb63c68bd
1 changed files with 20 additions and 7 deletions

View File

@ -5,7 +5,7 @@
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
#define PIN D1 #define PIN D1
#define NUMPIXELS 144 #define NUMPIXELS 30
uint16_t effectI=0,effectJ=0,wait = 50; uint16_t effectI=0,effectJ=0,wait = 50;
unsigned long lastCall = 0; unsigned long lastCall = 0;
@ -32,6 +32,13 @@ uint32_t wheel(byte wheelPos) {
return pixels.Color(wheelPos * 3, 255 - wheelPos * 3, 0); return pixels.Color(wheelPos * 3, 255 - wheelPos * 3, 0);
} }
void getRGBValues(uint32_t *rgbBuffer,uint32_t const color){
rgbBuffer[0] = color >> 16 & 255;
rgbBuffer[1] = color >> 8 & 255;
rgbBuffer[2] = color & 255;
return ;
}
bool onSetPixel(const HomieRange& range, const String& value){ bool onSetPixel(const HomieRange& range, const String& value){
if(!range.isRange){ if(!range.isRange){
for(int i=0;i<pixels.numPixels();i++){ for(int i=0;i<pixels.numPixels();i++){
@ -85,7 +92,6 @@ bool onSetLength(const HomieRange& range, const String& value){
stripNode.setProperty("length").send(value); stripNode.setProperty("length").send(value);
} }
void loopHandler() { void loopHandler() {
if (effect == "none"){ if (effect == "none"){
return; return;
@ -94,15 +100,20 @@ void loopHandler() {
int SpeedDelay = 20; int SpeedDelay = 20;
int ReturnDelay = 50; int ReturnDelay = 50;
int EyeSize = 5; int EyeSize = 5;
uint32_t rgb[3] = {0};
for(int i = 0; i < pixels.numPixels()-EyeSize-2; i++) { for(int i = 0; i < pixels.numPixels()-EyeSize-2; i++) {
pixels.clear(); pixels.clear();
pixels.show(); pixels.show();
pixels.setPixelColor(i, 255/10, 0, 0);
getRGBValues(rgb,wheel(wPos));
pixels.setPixelColor(i, rgb[0]/10, rgb[1]/10, rgb[2]/10);
for(int j = 1; j <= EyeSize; j++) { for(int j = 1; j <= EyeSize; j++) {
//pixels.setPixelColor(i+j, 255, 0, 0);
pixels.setPixelColor(i+j, wheel(wPos++)); pixels.setPixelColor(i+j, wheel(wPos++));
} }
pixels.setPixelColor(i+EyeSize+1, 255/10, 0, 0); uint32_t rgb[3] = {0};
getRGBValues(rgb,wheel(wPos));
pixels.setPixelColor(i+EyeSize+1, rgb[0]/10, rgb[1]/10, rgb[2]/10);
pixels.show(); pixels.show();
delay(SpeedDelay); delay(SpeedDelay);
} }
@ -111,12 +122,14 @@ void loopHandler() {
for(int i = pixels.numPixels()-EyeSize-2; i > 0; i--) { for(int i = pixels.numPixels()-EyeSize-2; i > 0; i--) {
pixels.clear(); pixels.clear();
pixels.show(); pixels.show();
pixels.setPixelColor(i, 255/10, 0, 0); getRGBValues(rgb,wheel(wPos));
pixels.setPixelColor(i, rgb[0]/10, rgb[1]/10, rgb[2]/10);
//pixels.setPixelColor(i, 255/10, 0, 0);
for(int j = 1; j <= EyeSize; j++) { for(int j = 1; j <= EyeSize; j++) {
//pixels.setPixelColor(i+j, 255, 0, 0); //pixels.setPixelColor(i+j, 255, 0, 0);
pixels.setPixelColor(i+j, wheel(wPos++)); pixels.setPixelColor(i+j, wheel(wPos++));
} }
pixels.setPixelColor(i+EyeSize+1, 255/10, 0, 0); pixels.setPixelColor(i+EyeSize+1, rgb[0]/10, rgb[1]/10, rgb[2]/10);
pixels.show(); pixels.show();
delay(SpeedDelay); delay(SpeedDelay);
} }