IP Configuration
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
// DotStarTest
|
||||
// This example will cycle between showing four pixels as Red, Green, Blue, White
|
||||
// and then showing those pixels as Black.
|
||||
//
|
||||
// There is serial output of the current state so you can confirm and follow along
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
const uint16_t PixelCount = 4; // this example assumes 4 pixels, making it smaller will cause a failure
|
||||
|
||||
// make sure to set this to the correct pins
|
||||
const uint8_t DotClockPin = 2;
|
||||
const uint8_t DotDataPin = 3;
|
||||
|
||||
#define colorSaturation 128
|
||||
|
||||
// for software bit bang
|
||||
NeoPixelBus<DotStarBgrFeature, DotStarMethod> strip(PixelCount, DotClockPin, DotDataPin);
|
||||
|
||||
// for hardware SPI (best performance but must use hardware pins)
|
||||
//NeoPixelBus<DotStarBgrFeature, DotStarSpiMethod> strip(PixelCount);
|
||||
|
||||
// DotStars that support RGB color and a overall luminance/brightness value
|
||||
// NeoPixelBus<DotStarLbgrFeature, DotStarMethod> strip(PixelCount, DotClockPin, DotDataPin);
|
||||
// DotStars that support RGBW color with a seperate white element
|
||||
//NeoPixelBus<DotStarWbgrFeature, DotStarMethod> strip(PixelCount, DotClockPin, DotDataPin);
|
||||
|
||||
RgbColor red(colorSaturation, 0, 0);
|
||||
RgbColor green(0, colorSaturation, 0);
|
||||
RgbColor blue(0, 0, colorSaturation);
|
||||
RgbColor white(colorSaturation);
|
||||
RgbColor black(0);
|
||||
|
||||
// for use with RGB DotStars when using the luminance/brightness global value
|
||||
// note that its range is only 0 - 31 (31 is full bright) and
|
||||
// also note that it is not useful for POV displays as it will cause more flicker
|
||||
RgbwColor redL(colorSaturation, 0, 0, 31); // use white value to store luminance
|
||||
RgbwColor greenL(0, colorSaturation, 0, 31); // use white value to store luminance
|
||||
RgbwColor blueL(0, 0, colorSaturation, 31); // use white value to store luminance
|
||||
RgbwColor whiteL(255, 255, 255, colorSaturation / 8); // luminance is only 0-31
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
Serial.flush();
|
||||
|
||||
// this resets all the neopixels to an off state
|
||||
strip.Begin();
|
||||
strip.ClearTo(black);
|
||||
strip.Show();
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(5000);
|
||||
|
||||
Serial.println("Colors R, G, B, W...");
|
||||
|
||||
// set the colors,
|
||||
strip.SetPixelColor(0, red);
|
||||
strip.SetPixelColor(1, green);
|
||||
strip.SetPixelColor(2, blue);
|
||||
strip.SetPixelColor(3, white);
|
||||
strip.Show();
|
||||
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println("Off ...");
|
||||
|
||||
// turn off the pixels
|
||||
strip.SetPixelColor(0, black);
|
||||
strip.SetPixelColor(1, black);
|
||||
strip.SetPixelColor(2, black);
|
||||
strip.SetPixelColor(3, black);
|
||||
strip.Show();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// NeoPixelBrightness
|
||||
// This example will cycle brightness from high to low of
|
||||
// three pixels colored Red, Green, Blue.
|
||||
// This demonstrates the use of the NeoPixelBrightnessBus
|
||||
// with integrated brightness support
|
||||
//
|
||||
// There is serial output of the current state so you can
|
||||
// confirm and follow along
|
||||
//
|
||||
|
||||
#include <NeoPixelBrightnessBus.h> // instead of NeoPixelBus.h
|
||||
|
||||
const uint16_t PixelCount = 3; // this example assumes 3 pixels, making it smaller will cause a failure
|
||||
const uint8_t PixelPin = 14; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
#define colorSaturation 255 // saturation of color constants
|
||||
RgbColor red(colorSaturation, 0, 0);
|
||||
RgbColor green(0, colorSaturation, 0);
|
||||
RgbColor blue(0, 0, colorSaturation);
|
||||
|
||||
// Make sure to provide the correct color order feature
|
||||
// for your NeoPixels
|
||||
NeoPixelBrightnessBus<NeoRgbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
// you loose the original color the lower the dim value used
|
||||
// here due to quantization
|
||||
const uint8_t c_MinBrightness = 8;
|
||||
const uint8_t c_MaxBrightness = 255;
|
||||
|
||||
int8_t direction; // current direction of dimming
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
Serial.flush();
|
||||
|
||||
// this resets all the neopixels to an off state
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
direction = -1; // default to dim first
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
|
||||
// set our three original colors
|
||||
strip.SetPixelColor(0, red);
|
||||
strip.SetPixelColor(1, green);
|
||||
strip.SetPixelColor(2, blue);
|
||||
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint8_t brightness = strip.GetBrightness();
|
||||
Serial.println(brightness);
|
||||
|
||||
delay(100);
|
||||
|
||||
// swap diection of dim when limits are reached
|
||||
//
|
||||
if (direction < 0 && brightness <= c_MinBrightness)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
else if (direction > 0 && brightness >= c_MaxBrightness)
|
||||
{
|
||||
direction = -1;
|
||||
}
|
||||
// apply dimming
|
||||
brightness += direction;
|
||||
strip.SetBrightness(brightness);
|
||||
|
||||
// show the results
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
// NeoPixelGamma
|
||||
// This example will display a timed series of color gradiants with gamma correction
|
||||
// and then without.
|
||||
// If the last pixel is on, then the colors being shown are color corrected.
|
||||
// It will show Red grandiant, Green grandiant, Blue grandiant, a White grandiant, and
|
||||
// then repeat.
|
||||
//
|
||||
// This will demonstrate the use of the NeoGamma class
|
||||
//
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
const uint16_t PixelCount = 16; // make sure to set this to the number of pixels in your strip
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// for esp8266 omit the pin
|
||||
//NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
|
||||
|
||||
// uncomment only one of these to compare memory use or speed
|
||||
//
|
||||
// NeoGamma<NeoGammaEquationMethod> colorGamma;
|
||||
NeoGamma<NeoGammaTableMethod> colorGamma;
|
||||
|
||||
void DrawPixels(bool corrected, HslColor startColor, HslColor stopColor)
|
||||
{
|
||||
for (uint16_t index = 0; index < strip.PixelCount() - 1; index++)
|
||||
{
|
||||
float progress = index / static_cast<float>(strip.PixelCount() - 2);
|
||||
RgbColor color = HslColor::LinearBlend<NeoHueBlendShortestDistance>(startColor, stopColor, progress);
|
||||
if (corrected)
|
||||
{
|
||||
color = colorGamma.Correct(color);
|
||||
}
|
||||
strip.SetPixelColor(index, color);
|
||||
}
|
||||
|
||||
// use the last pixel to indicate if we are showing corrected colors or not
|
||||
if (corrected)
|
||||
{
|
||||
strip.SetPixelColor(strip.PixelCount() - 1, RgbColor(64));
|
||||
}
|
||||
else
|
||||
{
|
||||
strip.SetPixelColor(strip.PixelCount() - 1, RgbColor(0));
|
||||
}
|
||||
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
HslColor startColor;
|
||||
HslColor stopColor;
|
||||
|
||||
// red color
|
||||
startColor = HslColor(0.0f, 1.0f, 0.0f);
|
||||
stopColor = HslColor(0.0f, 1.0f, 0.5f);
|
||||
DrawPixels(true, startColor, stopColor);
|
||||
delay(5000);
|
||||
DrawPixels(false, startColor, stopColor);
|
||||
delay(5000);
|
||||
|
||||
// green color
|
||||
startColor = HslColor(0.33f, 1.0f, 0.0f);
|
||||
stopColor = HslColor(0.33f, 1.0f, 0.5f);
|
||||
DrawPixels(true, startColor, stopColor);
|
||||
delay(5000);
|
||||
DrawPixels(false, startColor, stopColor);
|
||||
delay(5000);
|
||||
|
||||
// blue color
|
||||
startColor = HslColor(0.66f, 1.0f, 0.0f);
|
||||
stopColor = HslColor(0.66f, 1.0f, 0.5f);
|
||||
DrawPixels(true, startColor, stopColor);
|
||||
delay(5000);
|
||||
DrawPixels(false, startColor, stopColor);
|
||||
delay(5000);
|
||||
|
||||
// white color
|
||||
startColor = HslColor(0.0f, 0.0f, 0.0f);
|
||||
stopColor = HslColor(0.0f, 0.0f, 0.5f);
|
||||
DrawPixels(true, startColor, stopColor);
|
||||
delay(5000);
|
||||
DrawPixels(false, startColor, stopColor);
|
||||
delay(5000);
|
||||
}
|
||||
139
lib/NeoPixelBus_by_Makuna/examples/NeoPixelTest/NeoPixelTest.ino
Normal file
139
lib/NeoPixelBus_by_Makuna/examples/NeoPixelTest/NeoPixelTest.ino
Normal file
@@ -0,0 +1,139 @@
|
||||
// NeoPixelTest
|
||||
// This example will cycle between showing four pixels as Red, Green, Blue, White
|
||||
// and then showing those pixels as Black.
|
||||
//
|
||||
// Included but commented out are examples of configuring a NeoPixelBus for
|
||||
// different color order including an extra white channel, different data speeds, and
|
||||
// for Esp8266 different methods to send the data.
|
||||
// NOTE: You will need to make sure to pick the one for your platform
|
||||
//
|
||||
//
|
||||
// There is serial output of the current state so you can confirm and follow along
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
const uint16_t PixelCount = 4; // this example assumes 4 pixels, making it smaller will cause a failure
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
#define colorSaturation 128
|
||||
|
||||
// three element pixels, in different order and speeds
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
//NeoPixelBus<NeoRgbFeature, Neo400KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
// For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use.
|
||||
// There are other Esp8266 alternative methods that provide more pin options, but also have
|
||||
// other side effects.
|
||||
// for details see wiki linked here https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
|
||||
// You can also use one of these for Esp8266,
|
||||
// each having their own restrictions
|
||||
//
|
||||
// These two are the same as above as the DMA method is the default
|
||||
// NOTE: These will ignore the PIN and use GPI03 pin
|
||||
//NeoPixelBus<NeoGrbFeature, NeoEsp8266Dma800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
//NeoPixelBus<NeoRgbFeature, NeoEsp8266Dma400KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
// Uart method is good for the Esp-01 or other pin restricted modules
|
||||
// for details see wiki linked here https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
// NOTE: These will ignore the PIN and use GPI02 pin
|
||||
//NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart1800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
//NeoPixelBus<NeoRgbFeature, NeoEsp8266Uart1400KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
// The bitbang method is really only good if you are not using WiFi features of the ESP
|
||||
// It works with all but pin 16
|
||||
//NeoPixelBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
//NeoPixelBus<NeoRgbFeature, NeoEsp8266BitBang400KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
// four element pixels, RGBW
|
||||
//NeoPixelBus<NeoRgbwFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
RgbColor red(colorSaturation, 0, 0);
|
||||
RgbColor green(0, colorSaturation, 0);
|
||||
RgbColor blue(0, 0, colorSaturation);
|
||||
RgbColor white(colorSaturation);
|
||||
RgbColor black(0);
|
||||
|
||||
HslColor hslRed(red);
|
||||
HslColor hslGreen(green);
|
||||
HslColor hslBlue(blue);
|
||||
HslColor hslWhite(white);
|
||||
HslColor hslBlack(black);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
Serial.flush();
|
||||
|
||||
// this resets all the neopixels to an off state
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(5000);
|
||||
|
||||
Serial.println("Colors R, G, B, W...");
|
||||
|
||||
// set the colors,
|
||||
// if they don't match in order, you need to use NeoGrbFeature feature
|
||||
strip.SetPixelColor(0, red);
|
||||
strip.SetPixelColor(1, green);
|
||||
strip.SetPixelColor(2, blue);
|
||||
strip.SetPixelColor(3, white);
|
||||
// the following line demonstrates rgbw color support
|
||||
// if the NeoPixels are rgbw types the following line will compile
|
||||
// if the NeoPixels are anything else, the following line will give an error
|
||||
//strip.SetPixelColor(3, RgbwColor(colorSaturation));
|
||||
strip.Show();
|
||||
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println("Off ...");
|
||||
|
||||
// turn off the pixels
|
||||
strip.SetPixelColor(0, black);
|
||||
strip.SetPixelColor(1, black);
|
||||
strip.SetPixelColor(2, black);
|
||||
strip.SetPixelColor(3, black);
|
||||
strip.Show();
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println("HSL Colors R, G, B, W...");
|
||||
|
||||
// set the colors,
|
||||
// if they don't match in order, you may need to use NeoGrbFeature feature
|
||||
strip.SetPixelColor(0, hslRed);
|
||||
strip.SetPixelColor(1, hslGreen);
|
||||
strip.SetPixelColor(2, hslBlue);
|
||||
strip.SetPixelColor(3, hslWhite);
|
||||
strip.Show();
|
||||
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println("Off again...");
|
||||
|
||||
// turn off the pixels
|
||||
strip.SetPixelColor(0, hslBlack);
|
||||
strip.SetPixelColor(1, hslBlack);
|
||||
strip.SetPixelColor(2, hslBlack);
|
||||
strip.SetPixelColor(3, hslBlack);
|
||||
strip.Show();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
// NeoPixelAnimation
|
||||
// This example will randomly pick a new color for each pixel and animate
|
||||
// the current color to the new color over a random small amount of time, using
|
||||
// a randomly selected animation curve.
|
||||
// It will repeat this process once all pixels have finished the animation
|
||||
//
|
||||
// This will demonstrate the use of the NeoPixelAnimator extended time feature.
|
||||
// This feature allows for different time scales to be used, allowing slow extended
|
||||
// animations to be created.
|
||||
//
|
||||
// This will demonstrate the use of the NeoEase animation ease methods; that provide
|
||||
// simulated acceleration to the animations.
|
||||
//
|
||||
// It also includes platform specific code for Esp8266 that demonstrates easy
|
||||
// animation state and function definition inline. This is not available on AVR
|
||||
// Arduinos; but the AVR compatible code is also included for comparison.
|
||||
//
|
||||
// The example includes some serial output that you can follow along with as it
|
||||
// does the animation.
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
const uint16_t PixelCount = 4; // make sure to set this to the number of pixels in your strip
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use.
|
||||
// There are other Esp8266 alternative methods that provide more pin options, but also have
|
||||
// other side effects.
|
||||
// for details see wiki linked here https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
|
||||
// NeoPixel animation time management object
|
||||
NeoPixelAnimator animations(PixelCount, NEO_CENTISECONDS);
|
||||
|
||||
// create with enough animations to have one per pixel, depending on the animation
|
||||
// effect, you may need more or less.
|
||||
//
|
||||
// since the normal animation time range is only about 65 seconds, by passing timescale value
|
||||
// to the NeoPixelAnimator constructor we can increase the time range, but we also increase
|
||||
// the time between the animation updates.
|
||||
// NEO_CENTISECONDS will update the animations every 100th of a second rather than the default
|
||||
// of a 1000th of a second, but the time range will now extend from about 65 seconds to about
|
||||
// 10.9 minutes. But you must remember that the values passed to StartAnimations are now
|
||||
// in centiseconds.
|
||||
//
|
||||
// Possible values from 1 to 32768, and there some helpful constants defined as...
|
||||
// NEO_MILLISECONDS 1 // ~65 seconds max duration, ms updates
|
||||
// NEO_CENTISECONDS 10 // ~10.9 minutes max duration, centisecond updates
|
||||
// NEO_DECISECONDS 100 // ~1.8 hours max duration, decisecond updates
|
||||
// NEO_SECONDS 1000 // ~18.2 hours max duration, second updates
|
||||
// NEO_DECASECONDS 10000 // ~7.5 days, 10 second updates
|
||||
//
|
||||
|
||||
#if defined(NEOPIXEBUS_NO_STL)
|
||||
// for AVR, you need to manage the state due to lack of STL/compiler support
|
||||
// for Esp8266 you can define the function using a lambda and state is created for you
|
||||
// see below for an example
|
||||
struct MyAnimationState
|
||||
{
|
||||
RgbColor StartingColor; // the color the animation starts at
|
||||
RgbColor EndingColor; // the color the animation will end at
|
||||
AnimEaseFunction Easeing; // the acceleration curve it will use
|
||||
};
|
||||
|
||||
MyAnimationState animationState[PixelCount];
|
||||
// one entry per pixel to match the animation timing manager
|
||||
|
||||
void AnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// first apply an easing (curve) to the animation
|
||||
// this simulates acceleration to the effect
|
||||
float progress = animationState[param.index].Easeing(param.progress);
|
||||
|
||||
// this gets called for each animation on every time step
|
||||
// progress will start at 0.0 and end at 1.0
|
||||
// we use the blend function on the RgbColor to mix
|
||||
// color based on the progress given to us in the animation
|
||||
RgbColor updatedColor = RgbColor::LinearBlend(
|
||||
animationState[param.index].StartingColor,
|
||||
animationState[param.index].EndingColor,
|
||||
progress);
|
||||
// apply the color to the strip
|
||||
strip.SetPixelColor(param.index, updatedColor);
|
||||
}
|
||||
#endif
|
||||
|
||||
void SetRandomSeed()
|
||||
{
|
||||
uint32_t seed;
|
||||
|
||||
// random works best with a seed that can use 31 bits
|
||||
// analogRead on a unconnected pin tends toward less than four bits
|
||||
seed = analogRead(0);
|
||||
delay(1);
|
||||
|
||||
for (int shifts = 3; shifts < 31; shifts += 3)
|
||||
{
|
||||
seed ^= analogRead(0) << shifts;
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// Serial.println(seed);
|
||||
randomSeed(seed);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
SetRandomSeed();
|
||||
|
||||
// just pick some colors
|
||||
for (uint16_t pixel = 0; pixel < PixelCount; pixel++)
|
||||
{
|
||||
RgbColor color = RgbColor(random(255), random(255), random(255));
|
||||
strip.SetPixelColor(pixel, color);
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
}
|
||||
|
||||
|
||||
void SetupAnimationSet()
|
||||
{
|
||||
// setup some animations
|
||||
for (uint16_t pixel = 0; pixel < PixelCount; pixel++)
|
||||
{
|
||||
const uint8_t peak = 128;
|
||||
|
||||
// pick a random duration of the animation for this pixel
|
||||
// since values are centiseconds, the range is 1 - 4 seconds
|
||||
uint16_t time = random(100, 400);
|
||||
|
||||
// each animation starts with the color that was present
|
||||
RgbColor originalColor = strip.GetPixelColor(pixel);
|
||||
// and ends with a random color
|
||||
RgbColor targetColor = RgbColor(random(peak), random(peak), random(peak));
|
||||
// with the random ease function
|
||||
AnimEaseFunction easing;
|
||||
|
||||
switch (random(3))
|
||||
{
|
||||
case 0:
|
||||
easing = NeoEase::CubicIn;
|
||||
break;
|
||||
case 1:
|
||||
easing = NeoEase::CubicOut;
|
||||
break;
|
||||
case 2:
|
||||
easing = NeoEase::QuadraticInOut;
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(NEOPIXEBUS_NO_STL)
|
||||
// each animation starts with the color that was present
|
||||
animationState[pixel].StartingColor = originalColor;
|
||||
// and ends with a random color
|
||||
animationState[pixel].EndingColor = targetColor;
|
||||
// using the specific curve
|
||||
animationState[pixel].Easeing = easing;
|
||||
|
||||
// now use the animation state we just calculated and start the animation
|
||||
// which will continue to run and call the update function until it completes
|
||||
animations.StartAnimation(pixel, time, AnimUpdate);
|
||||
#else
|
||||
// we must supply a function that will define the animation, in this example
|
||||
// we are using "lambda expression" to define the function inline, which gives
|
||||
// us an easy way to "capture" the originalColor and targetColor for the call back.
|
||||
//
|
||||
// this function will get called back when ever the animation needs to change
|
||||
// the state of the pixel, it will provide a animation progress value
|
||||
// from 0.0 (start of animation) to 1.0 (end of animation)
|
||||
//
|
||||
// we use this progress value to define how we want to animate in this case
|
||||
// we call RgbColor::LinearBlend which will return a color blended between
|
||||
// the values given, by the amount passed, hich is also a float value from 0.0-1.0.
|
||||
// then we set the color.
|
||||
//
|
||||
// There is no need for the MyAnimationState struct as the compiler takes care
|
||||
// of those details for us
|
||||
AnimUpdateCallback animUpdate = [=](const AnimationParam& param)
|
||||
{
|
||||
// progress will start at 0.0 and end at 1.0
|
||||
// we convert to the curve we want
|
||||
float progress = easing(param.progress);
|
||||
|
||||
// use the curve value to apply to the animation
|
||||
RgbColor updatedColor = RgbColor::LinearBlend(originalColor, targetColor, progress);
|
||||
strip.SetPixelColor(pixel, updatedColor);
|
||||
};
|
||||
|
||||
// now use the animation properties we just calculated and start the animation
|
||||
// which will continue to run and call the update function until it completes
|
||||
animations.StartAnimation(pixel, time, animUpdate);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (animations.IsAnimating())
|
||||
{
|
||||
// the normal loop just needs these two to run the active animations
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println();
|
||||
Serial.println("Setup Next Set...");
|
||||
// example function that sets up some animations
|
||||
SetupAnimationSet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// NeoPixelCylon
|
||||
// This example will move a Cylon Red Eye back and forth across the
|
||||
// the full collection of pixels on the strip.
|
||||
//
|
||||
// This will demonstrate the use of the NeoEase animation ease methods; that provide
|
||||
// simulated acceleration to the animations.
|
||||
//
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
const uint16_t PixelCount = 16; // make sure to set this to the number of pixels in your strip
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
const RgbColor CylonEyeColor(HtmlColor(0x7f0000));
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// for esp8266 omit the pin
|
||||
//NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
|
||||
|
||||
NeoPixelAnimator animations(2); // only ever need 2 animations
|
||||
|
||||
uint16_t lastPixel = 0; // track the eye position
|
||||
int8_t moveDir = 1; // track the direction of movement
|
||||
|
||||
// uncomment one of the lines below to see the effects of
|
||||
// changing the ease function on the movement animation
|
||||
AnimEaseFunction moveEase =
|
||||
// NeoEase::Linear;
|
||||
// NeoEase::QuadraticInOut;
|
||||
// NeoEase::CubicInOut;
|
||||
NeoEase::QuarticInOut;
|
||||
// NeoEase::QuinticInOut;
|
||||
// NeoEase::SinusoidalInOut;
|
||||
// NeoEase::ExponentialInOut;
|
||||
// NeoEase::CircularInOut;
|
||||
|
||||
void FadeAll(uint8_t darkenBy)
|
||||
{
|
||||
RgbColor color;
|
||||
for (uint16_t indexPixel = 0; indexPixel < strip.PixelCount(); indexPixel++)
|
||||
{
|
||||
color = strip.GetPixelColor(indexPixel);
|
||||
color.Darken(darkenBy);
|
||||
strip.SetPixelColor(indexPixel, color);
|
||||
}
|
||||
}
|
||||
|
||||
void FadeAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
if (param.state == AnimationState_Completed)
|
||||
{
|
||||
FadeAll(10);
|
||||
animations.RestartAnimation(param.index);
|
||||
}
|
||||
}
|
||||
|
||||
void MoveAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// apply the movement animation curve
|
||||
float progress = moveEase(param.progress);
|
||||
|
||||
// use the curved progress to calculate the pixel to effect
|
||||
uint16_t nextPixel;
|
||||
if (moveDir > 0)
|
||||
{
|
||||
nextPixel = progress * PixelCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextPixel = (1.0f - progress) * PixelCount;
|
||||
}
|
||||
|
||||
// if progress moves fast enough, we may move more than
|
||||
// one pixel, so we update all between the calculated and
|
||||
// the last
|
||||
if (lastPixel != nextPixel)
|
||||
{
|
||||
for (uint16_t i = lastPixel + moveDir; i != nextPixel; i += moveDir)
|
||||
{
|
||||
strip.SetPixelColor(i, CylonEyeColor);
|
||||
}
|
||||
}
|
||||
strip.SetPixelColor(nextPixel, CylonEyeColor);
|
||||
|
||||
lastPixel = nextPixel;
|
||||
|
||||
if (param.state == AnimationState_Completed)
|
||||
{
|
||||
// reverse direction of movement
|
||||
moveDir *= -1;
|
||||
|
||||
// done, time to restart this position tracking animation/timer
|
||||
animations.RestartAnimation(param.index);
|
||||
}
|
||||
}
|
||||
|
||||
void SetupAnimations()
|
||||
{
|
||||
// fade all pixels providing a tail that is longer the faster
|
||||
// the pixel moves.
|
||||
animations.StartAnimation(0, 5, FadeAnimUpdate);
|
||||
|
||||
// take several seconds to move eye fron one side to the other
|
||||
animations.StartAnimation(1, 2000, MoveAnimUpdate);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
SetupAnimations();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// this is all that is needed to keep it running
|
||||
// and avoiding using delay() is always a good thing for
|
||||
// any timing related routines
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
// NeoPixelFunFadeInOut
|
||||
// This example will randomly pick a color and fade all pixels to that color, then
|
||||
// it will fade them to black and restart over
|
||||
//
|
||||
// This example demonstrates the use of a single animation channel to animate all
|
||||
// the pixels at once.
|
||||
//
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
const uint16_t PixelCount = 16; // make sure to set this to the number of pixels in your strip
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
const uint8_t AnimationChannels = 1; // we only need one as all the pixels are animated at once
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use.
|
||||
// There are other Esp8266 alternative methods that provide more pin options, but also have
|
||||
// other side effects.
|
||||
// for details see wiki linked here https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
|
||||
NeoPixelAnimator animations(AnimationChannels); // NeoPixel animation management object
|
||||
|
||||
boolean fadeToColor = true; // general purpose variable used to store effect state
|
||||
|
||||
|
||||
// what is stored for state is specific to the need, in this case, the colors.
|
||||
// basically what ever you need inside the animation update function
|
||||
struct MyAnimationState
|
||||
{
|
||||
RgbColor StartingColor;
|
||||
RgbColor EndingColor;
|
||||
};
|
||||
|
||||
// one entry per pixel to match the animation timing manager
|
||||
MyAnimationState animationState[AnimationChannels];
|
||||
|
||||
void SetRandomSeed()
|
||||
{
|
||||
uint32_t seed;
|
||||
|
||||
// random works best with a seed that can use 31 bits
|
||||
// analogRead on a unconnected pin tends toward less than four bits
|
||||
seed = analogRead(0);
|
||||
delay(1);
|
||||
|
||||
for (int shifts = 3; shifts < 31; shifts += 3)
|
||||
{
|
||||
seed ^= analogRead(0) << shifts;
|
||||
delay(1);
|
||||
}
|
||||
|
||||
randomSeed(seed);
|
||||
}
|
||||
|
||||
// simple blend function
|
||||
void BlendAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// this gets called for each animation on every time step
|
||||
// progress will start at 0.0 and end at 1.0
|
||||
// we use the blend function on the RgbColor to mix
|
||||
// color based on the progress given to us in the animation
|
||||
RgbColor updatedColor = RgbColor::LinearBlend(
|
||||
animationState[param.index].StartingColor,
|
||||
animationState[param.index].EndingColor,
|
||||
param.progress);
|
||||
|
||||
// apply the color to the strip
|
||||
for (uint16_t pixel = 0; pixel < PixelCount; pixel++)
|
||||
{
|
||||
strip.SetPixelColor(pixel, updatedColor);
|
||||
}
|
||||
}
|
||||
|
||||
void FadeInFadeOutRinseRepeat(float luminance)
|
||||
{
|
||||
if (fadeToColor)
|
||||
{
|
||||
// Fade upto a random color
|
||||
// we use HslColor object as it allows us to easily pick a hue
|
||||
// with the same saturation and luminance so the colors picked
|
||||
// will have similiar overall brightness
|
||||
RgbColor target = HslColor(random(360) / 360.0f, 1.0f, luminance);
|
||||
uint16_t time = random(800, 2000);
|
||||
|
||||
animationState[0].StartingColor = strip.GetPixelColor(0);
|
||||
animationState[0].EndingColor = target;
|
||||
|
||||
animations.StartAnimation(0, time, BlendAnimUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// fade to black
|
||||
uint16_t time = random(600, 700);
|
||||
|
||||
animationState[0].StartingColor = strip.GetPixelColor(0);
|
||||
animationState[0].EndingColor = RgbColor(0);
|
||||
|
||||
animations.StartAnimation(0, time, BlendAnimUpdate);
|
||||
}
|
||||
|
||||
// toggle to the next effect state
|
||||
fadeToColor = !fadeToColor;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
SetRandomSeed();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (animations.IsAnimating())
|
||||
{
|
||||
// the normal loop just needs these two to run the active animations
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// no animation runnning, start some
|
||||
//
|
||||
FadeInFadeOutRinseRepeat(0.2f); // 0.0 = black, 0.25 is normal, 0.5 is bright
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
// NeoPixelFunLoop
|
||||
// This example will move a trail of light around a series of pixels.
|
||||
// A ring formation of pixels looks best.
|
||||
// The trail will have a slowly fading tail.
|
||||
//
|
||||
// This will demonstrate the use of the NeoPixelAnimator.
|
||||
// It shows the advanced use an animation to control the modification and
|
||||
// starting of other animations.
|
||||
// It also shows the normal use of animating colors.
|
||||
// It also demonstrates the ability to share an animation channel rather than
|
||||
// hard code them to pixels.
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
|
||||
const uint16_t PixelCount = 16; // make sure to set this to the number of pixels in your strip
|
||||
const uint16_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
const uint16_t AnimCount = PixelCount / 5 * 2 + 1; // we only need enough animations for the tail and one extra
|
||||
|
||||
const uint16_t PixelFadeDuration = 300; // third of a second
|
||||
// one second divide by the number of pixels = loop once a second
|
||||
const uint16_t NextPixelMoveDuration = 1000 / PixelCount; // how fast we move through the pixels
|
||||
|
||||
NeoGamma<NeoGammaTableMethod> colorGamma; // for any fade animations, best to correct gamma
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use.
|
||||
// There are other Esp8266 alternative methods that provide more pin options, but also have
|
||||
// other side effects.
|
||||
// for details see wiki linked here https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
|
||||
// what is stored for state is specific to the need, in this case, the colors and
|
||||
// the pixel to animate;
|
||||
// basically what ever you need inside the animation update function
|
||||
struct MyAnimationState
|
||||
{
|
||||
RgbColor StartingColor;
|
||||
RgbColor EndingColor;
|
||||
uint16_t IndexPixel; // which pixel this animation is effecting
|
||||
};
|
||||
|
||||
NeoPixelAnimator animations(AnimCount); // NeoPixel animation management object
|
||||
MyAnimationState animationState[AnimCount];
|
||||
uint16_t frontPixel = 0; // the front of the loop
|
||||
RgbColor frontColor; // the color at the front of the loop
|
||||
|
||||
void SetRandomSeed()
|
||||
{
|
||||
uint32_t seed;
|
||||
|
||||
// random works best with a seed that can use 31 bits
|
||||
// analogRead on a unconnected pin tends toward less than four bits
|
||||
seed = analogRead(0);
|
||||
delay(1);
|
||||
|
||||
for (int shifts = 3; shifts < 31; shifts += 3)
|
||||
{
|
||||
seed ^= analogRead(0) << shifts;
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// Serial.println(seed);
|
||||
randomSeed(seed);
|
||||
}
|
||||
|
||||
void FadeOutAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// this gets called for each animation on every time step
|
||||
// progress will start at 0.0 and end at 1.0
|
||||
// we use the blend function on the RgbColor to mix
|
||||
// color based on the progress given to us in the animation
|
||||
RgbColor updatedColor = RgbColor::LinearBlend(
|
||||
animationState[param.index].StartingColor,
|
||||
animationState[param.index].EndingColor,
|
||||
param.progress);
|
||||
// apply the color to the strip
|
||||
strip.SetPixelColor(animationState[param.index].IndexPixel,
|
||||
colorGamma.Correct(updatedColor));
|
||||
}
|
||||
|
||||
void LoopAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// wait for this animation to complete,
|
||||
// we are using it as a timer of sorts
|
||||
if (param.state == AnimationState_Completed)
|
||||
{
|
||||
// done, time to restart this position tracking animation/timer
|
||||
animations.RestartAnimation(param.index);
|
||||
|
||||
// pick the next pixel inline to start animating
|
||||
//
|
||||
frontPixel = (frontPixel + 1) % PixelCount; // increment and wrap
|
||||
if (frontPixel == 0)
|
||||
{
|
||||
// we looped, lets pick a new front color
|
||||
frontColor = HslColor(random(360) / 360.0f, 1.0f, 0.25f);
|
||||
}
|
||||
|
||||
uint16_t indexAnim;
|
||||
// do we have an animation available to use to animate the next front pixel?
|
||||
// if you see skipping, then either you are going to fast or need to increase
|
||||
// the number of animation channels
|
||||
if (animations.NextAvailableAnimation(&indexAnim, 1))
|
||||
{
|
||||
animationState[indexAnim].StartingColor = frontColor;
|
||||
animationState[indexAnim].EndingColor = RgbColor(0, 0, 0);
|
||||
animationState[indexAnim].IndexPixel = frontPixel;
|
||||
|
||||
animations.StartAnimation(indexAnim, PixelFadeDuration, FadeOutAnimUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
SetRandomSeed();
|
||||
|
||||
// we use the index 0 animation to time how often we move to the next
|
||||
// pixel in the strip
|
||||
animations.StartAnimation(0, NextPixelMoveDuration, LoopAnimUpdate);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// this is all that is needed to keep it running
|
||||
// and avoiding using delay() is always a good thing for
|
||||
// any timing related routines
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
// NeoPixelFunRandomChange
|
||||
// This example will randomly select a number pixels and then
|
||||
// start an animation to blend them from their current color to
|
||||
// randomly selected a color
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
const uint16_t PixelCount = 16; // make sure to set this to the number of pixels in your strip
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use.
|
||||
// There are other Esp8266 alternative methods that provide more pin options, but also have
|
||||
// other side effects.
|
||||
// for details see wiki linked here https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
|
||||
NeoPixelAnimator animations(PixelCount); // NeoPixel animation management object
|
||||
|
||||
// what is stored for state is specific to the need, in this case, the colors.
|
||||
// Basically what ever you need inside the animation update function
|
||||
struct MyAnimationState
|
||||
{
|
||||
RgbColor StartingColor;
|
||||
RgbColor EndingColor;
|
||||
};
|
||||
|
||||
// one entry per pixel to match the animation timing manager
|
||||
MyAnimationState animationState[PixelCount];
|
||||
|
||||
void SetRandomSeed()
|
||||
{
|
||||
uint32_t seed;
|
||||
|
||||
// random works best with a seed that can use 31 bits
|
||||
// analogRead on a unconnected pin tends toward less than four bits
|
||||
seed = analogRead(0);
|
||||
delay(1);
|
||||
|
||||
for (int shifts = 3; shifts < 31; shifts += 3)
|
||||
{
|
||||
seed ^= analogRead(0) << shifts;
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// Serial.println(seed);
|
||||
randomSeed(seed);
|
||||
}
|
||||
|
||||
// simple blend function
|
||||
void BlendAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// this gets called for each animation on every time step
|
||||
// progress will start at 0.0 and end at 1.0
|
||||
// we use the blend function on the RgbColor to mix
|
||||
// color based on the progress given to us in the animation
|
||||
RgbColor updatedColor = RgbColor::LinearBlend(
|
||||
animationState[param.index].StartingColor,
|
||||
animationState[param.index].EndingColor,
|
||||
param.progress);
|
||||
// apply the color to the strip
|
||||
strip.SetPixelColor(param.index, updatedColor);
|
||||
}
|
||||
|
||||
void PickRandom(float luminance)
|
||||
{
|
||||
// pick random count of pixels to animate
|
||||
uint16_t count = random(PixelCount);
|
||||
while (count > 0)
|
||||
{
|
||||
// pick a random pixel
|
||||
uint16_t pixel = random(PixelCount);
|
||||
|
||||
// pick random time and random color
|
||||
// we use HslColor object as it allows us to easily pick a color
|
||||
// with the same saturation and luminance
|
||||
uint16_t time = random(100, 400);
|
||||
animationState[pixel].StartingColor = strip.GetPixelColor(pixel);
|
||||
animationState[pixel].EndingColor = HslColor(random(360) / 360.0f, 1.0f, luminance);
|
||||
|
||||
animations.StartAnimation(pixel, time, BlendAnimUpdate);
|
||||
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
SetRandomSeed();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (animations.IsAnimating())
|
||||
{
|
||||
// the normal loop just needs these two to run the active animations
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// no animations runnning, start some
|
||||
//
|
||||
PickRandom(0.2f); // 0.0 = black, 0.25 is normal, 0.5 is bright
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
// NeoPixelFunLoop
|
||||
// This example will move a trail of light around a series of pixels.
|
||||
// A ring formation of pixels looks best.
|
||||
// The trail will have a slowly fading tail.
|
||||
//
|
||||
// This will demonstrate the use of the RotateRight method.
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
|
||||
const uint16_t PixelCount = 16; // make sure to set this to the number of pixels in your strip
|
||||
const uint16_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
const uint16_t AnimCount = 1; // we only need one
|
||||
const uint16_t TailLength = 6; // length of the tail, must be shorter than PixelCount
|
||||
const float MaxLightness = 0.4f; // max lightness at the head of the tail (0.5f is full bright)
|
||||
|
||||
NeoGamma<NeoGammaTableMethod> colorGamma; // for any fade animations, best to correct gamma
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// for esp8266 omit the pin
|
||||
//NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
|
||||
|
||||
NeoPixelAnimator animations(AnimCount); // NeoPixel animation management object
|
||||
|
||||
void SetRandomSeed()
|
||||
{
|
||||
uint32_t seed;
|
||||
|
||||
// random works best with a seed that can use 31 bits
|
||||
// analogRead on a unconnected pin tends toward less than four bits
|
||||
seed = analogRead(0);
|
||||
delay(1);
|
||||
|
||||
for (int shifts = 3; shifts < 31; shifts += 3)
|
||||
{
|
||||
seed ^= analogRead(0) << shifts;
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// Serial.println(seed);
|
||||
randomSeed(seed);
|
||||
}
|
||||
|
||||
void LoopAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// wait for this animation to complete,
|
||||
// we are using it as a timer of sorts
|
||||
if (param.state == AnimationState_Completed)
|
||||
{
|
||||
// done, time to restart this position tracking animation/timer
|
||||
animations.RestartAnimation(param.index);
|
||||
|
||||
// rotate the complete strip one pixel to the right on every update
|
||||
strip.RotateRight(1);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTailPixels()
|
||||
{
|
||||
// using Hsl as it makes it easy to pick from similiar saturated colors
|
||||
float hue = random(360) / 360.0f;
|
||||
for (uint16_t index = 0; index < strip.PixelCount() && index <= TailLength; index++)
|
||||
{
|
||||
float lightness = index * MaxLightness / TailLength;
|
||||
RgbColor color = HslColor(hue, 1.0f, lightness);
|
||||
|
||||
strip.SetPixelColor(index, colorGamma.Correct(color));
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
SetRandomSeed();
|
||||
|
||||
// Draw the tail that will be rotated through all the rest of the pixels
|
||||
DrawTailPixels();
|
||||
|
||||
// we use the index 0 animation to time how often we rotate all the pixels
|
||||
animations.StartAnimation(0, 66, LoopAnimUpdate);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// this is all that is needed to keep it running
|
||||
// and avoiding using delay() is always a good thing for
|
||||
// any timing related routines
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
// NeoPixelBuffer
|
||||
// This example will animate pixels using a bitmap stored on a SD card
|
||||
//
|
||||
//
|
||||
// This will demonstrate the use of the NeoBitmapFile object
|
||||
// NOTE: The images provided in the example directory should be copied to
|
||||
// the root of the SD card so the below code will find it.
|
||||
// NOTE: This sample and the included images were built for a 144 pixel strip so
|
||||
// running this with a smaller string may not look as interesting. Try providing
|
||||
// your own 24 bit bitmap for better results.
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
|
||||
const int chipSelect = D8; // make sure to set this to your SD carder reader CS
|
||||
|
||||
//typedef NeoGrbFeature MyPixelColorFeature;
|
||||
typedef NeoGrbwFeature MyPixelColorFeature;
|
||||
|
||||
const uint16_t PixelCount = 144; // the sample images are meant for 144 pixels
|
||||
const uint16_t PixelPin = 2;
|
||||
const uint16_t AnimCount = 1; // we only need one
|
||||
|
||||
NeoPixelBus<MyPixelColorFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// for esp8266 omit the pin
|
||||
//NeoPixelBus<MyPixelColorFeature, Neo800KbpsMethod> strip(PixelCount);
|
||||
NeoPixelAnimator animations(AnimCount); // NeoPixel animation management object
|
||||
|
||||
// our NeoBitmapFile will use the same color feature as NeoPixelBus and
|
||||
// we want it to use the SD File object
|
||||
NeoBitmapFile<MyPixelColorFeature, File> image;
|
||||
|
||||
uint16_t animState;
|
||||
|
||||
void LoopAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// wait for this animation to complete,
|
||||
// we are using it as a timer of sorts
|
||||
if (param.state == AnimationState_Completed)
|
||||
{
|
||||
// done, time to restart this position tracking animation/timer
|
||||
animations.RestartAnimation(param.index);
|
||||
|
||||
// draw the complete row at animState to the complete strip
|
||||
image.Blt(strip, 0, 0, animState, image.Width());
|
||||
animState = (animState + 1) % image.Height(); // increment and wrap
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
Serial.print("Initializing SD card...");
|
||||
|
||||
// see if the card is present and can be initialized:
|
||||
if (!SD.begin(chipSelect))
|
||||
{
|
||||
Serial.println("Card failed, or not present");
|
||||
// don't do anything more:
|
||||
return;
|
||||
}
|
||||
Serial.println("card initialized.");
|
||||
|
||||
// open the file
|
||||
File bitmapFile = SD.open("strings.bmp");
|
||||
if (!bitmapFile)
|
||||
{
|
||||
Serial.println("File open fail, or not present");
|
||||
// don't do anything more:
|
||||
return;
|
||||
}
|
||||
|
||||
// initialize the image with the file
|
||||
if (!image.Begin(bitmapFile))
|
||||
{
|
||||
Serial.println("File format fail, not a supported bitmap");
|
||||
// don't do anything more:
|
||||
return;
|
||||
}
|
||||
|
||||
animState = 0;
|
||||
// we use the index 0 animation to time how often we rotate all the pixels
|
||||
animations.StartAnimation(0, 30, LoopAnimUpdate);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// this is all that is needed to keep it running
|
||||
// and avoiding using delay() is always a good thing for
|
||||
// any timing related routines
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
// To recreate the data below, use the Paint.Net plugin "Arduino Progmem NeoPixel FileType"
|
||||
// to save as/export the included Cylon.pdn
|
||||
// Paint.Net - http://www.getpaint.net/download.html#download
|
||||
// Plugin - http://forums.getpaint.net/index.php?/topic/107921-arduino-neopixel-sketch-exporter/
|
||||
// This uses Flatten, GRB, Hexadecimal
|
||||
//
|
||||
|
||||
const uint16_t myImageWidth = 16;
|
||||
const uint16_t myImageHeight = 20;
|
||||
const uint8_t PROGMEM myImage[] = { // (16 x 20) GRB in Hexadecimal
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
@@ -0,0 +1,30 @@
|
||||
// To recreate the data below, use the Paint.Net plugin "Arduino Progmem NeoPixel FileType"
|
||||
// to save as/export the included Cylon.pdn
|
||||
// Paint.Net - http://www.getpaint.net/download.html#download
|
||||
// Plugin - http://forums.getpaint.net/index.php?/topic/107921-arduino-neopixel-sketch-exporter/
|
||||
// This uses Flatten, GRBW, Hexadecimal
|
||||
//
|
||||
|
||||
const uint16_t myImageWidth = 16;
|
||||
const uint16_t myImageHeight = 20;
|
||||
const uint8_t PROGMEM myImage[] = { // (16 x 20) GRBW in Hexadecimal
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
@@ -0,0 +1,74 @@
|
||||
// NeoPixelBufferCylon
|
||||
// This example will move a Cylon Red Eye back and forth across the
|
||||
// the full collection of pixels on the strip.
|
||||
//
|
||||
// This will demonstrate the use of the NeoVerticalSpriteSheet
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
// The actual image is contained in the data structure in one of the Cylon*.h files
|
||||
// You will need to use the one that has the same color feature as your NeoPixelBus
|
||||
// There are two provided, but you can create your own easily enough using
|
||||
// free versions of Paint.Net and the plugin
|
||||
#include "CylonGrb.h"
|
||||
typedef NeoGrbFeature MyPixelColorFeature;
|
||||
|
||||
// #include "CylonGrbw.h"
|
||||
// typedef NeoGrbwFeature MyPixelColorFeature;
|
||||
|
||||
const uint16_t PixelCount = 16; // the sample images are meant for 16 pixels
|
||||
const uint16_t PixelPin = 2;
|
||||
const uint16_t AnimCount = 1; // we only need one
|
||||
|
||||
NeoPixelBus<MyPixelColorFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// for esp8266 omit the pin
|
||||
//NeoPixelBus<MyPixelColorFeature, Neo800KbpsMethod> strip(PixelCount);
|
||||
NeoPixelAnimator animations(AnimCount); // NeoPixel animation management object
|
||||
|
||||
// sprite sheet stored in progmem using the same pixel feature as the NeoPixelBus
|
||||
NeoVerticalSpriteSheet<NeoBufferProgmemMethod<MyPixelColorFeature>> spriteSheet(
|
||||
myImageWidth, // image width and sprite width since its vertical sprite sheet
|
||||
myImageHeight, // image height
|
||||
1, // sprite is only one pixel high
|
||||
myImage);
|
||||
|
||||
uint16_t indexSprite;
|
||||
|
||||
void LoopAnimUpdate(const AnimationParam& param)
|
||||
{
|
||||
// wait for this animation to complete,
|
||||
// we are using it as a timer of sorts
|
||||
if (param.state == AnimationState_Completed)
|
||||
{
|
||||
// done, time to restart this position tracking animation/timer
|
||||
animations.RestartAnimation(param.index);
|
||||
|
||||
// draw the next frame in the sprite
|
||||
spriteSheet.Blt(strip, 0, indexSprite);
|
||||
indexSprite = (indexSprite + 1) % myImageHeight; // increment and wrap
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
indexSprite = 0;
|
||||
|
||||
// we use the index 0 animation to time how often we rotate all the pixels
|
||||
animations.StartAnimation(0, 60, LoopAnimUpdate);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// this is all that is needed to keep it running
|
||||
// and avoiding using delay() is always a good thing for
|
||||
// any timing related routines
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
// NeoPixelBufferShader
|
||||
// This example will provide a shader class to the NeoPixelBuffer that will dim and brighten
|
||||
// the pixels that are in the buffer (a device dependent bitmap)
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
const uint16_t PixelCount = 64; // set this to the size of your strip
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
// three element GRB pixels, change to your needs
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
// the buffer object,
|
||||
// defined to use memory with the same feature as the strip
|
||||
// initialized with the same number of pixels as our strip
|
||||
NeoBuffer<NeoBufferMethod<NeoGrbFeature>> image(8,8,NULL);
|
||||
|
||||
const RgbColor BrightRed(255, 0, 0);
|
||||
const RgbColor BrightGreen(0, 255, 0);
|
||||
const RgbColor BrightBlue(0, 0, 255);
|
||||
|
||||
const RgbColor BrightYellow(255, 255, 0);
|
||||
const RgbColor BrightCyan(0, 255, 255);
|
||||
const RgbColor BrightPurple(255, 0, 255);
|
||||
|
||||
const RgbColor DarkRed(32, 0, 0);
|
||||
const RgbColor DarkGreen(0, 32, 0);
|
||||
const RgbColor DarkBlue(0, 0, 32);
|
||||
|
||||
const RgbColor DarkYellow(32, 32, 0);
|
||||
const RgbColor DarkCyan(0, 32, 32);
|
||||
const RgbColor DarkPurple(32, 0, 32);
|
||||
|
||||
const RgbColor White(255);
|
||||
const RgbColor Black(0);
|
||||
|
||||
// define a custom shader object that provides brightness support
|
||||
// based upon the NeoShaderBase
|
||||
template<typename T_COLOR_FEATURE> class BrightnessShader : public NeoShaderBase
|
||||
{
|
||||
public:
|
||||
BrightnessShader():
|
||||
NeoShaderBase(),
|
||||
_brightness(255) // default to full bright
|
||||
{}
|
||||
|
||||
// required for a shader object, it will be called for
|
||||
// every pixel
|
||||
void Apply(uint16_t index, uint8_t* pDest, uint8_t* pSrc)
|
||||
{
|
||||
// we don't care what the index is so we ignore it
|
||||
//
|
||||
// to apply our brightness shader,
|
||||
// use the source color, modify, and apply to the destination
|
||||
|
||||
// for every byte in the pixel,
|
||||
// scale the source value by the brightness and
|
||||
// store it in the destination byte
|
||||
const uint8_t* pSrcEnd = pSrc + T_COLOR_FEATURE::PixelSize;
|
||||
while (pSrc != pSrcEnd)
|
||||
{
|
||||
*pDest++ = (*pSrc++ * (uint16_t(_brightness) + 1)) >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
// provide an accessor to set brightness
|
||||
void setBrightness(uint8_t brightness)
|
||||
{
|
||||
_brightness = brightness;
|
||||
Dirty(); // must call dirty when a property changes
|
||||
}
|
||||
|
||||
// provide an accessor to get brightness
|
||||
uint8_t getBrightness()
|
||||
{
|
||||
return _brightness;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t _brightness;
|
||||
};
|
||||
|
||||
// create an instance of our shader object with the same feature as our buffer
|
||||
BrightnessShader<NeoGrbFeature> shader;
|
||||
|
||||
// some dimming tracking variables and settings
|
||||
int8_t delta;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
Serial.flush();
|
||||
|
||||
// this resets all the neopixels to an off state
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
// dibs do not default to any color,
|
||||
// so clear it to black if you aren't going to draw
|
||||
// into every pixel
|
||||
image.ClearTo(Black);
|
||||
|
||||
// draw a pattern into the image
|
||||
uint8_t x = 0;
|
||||
uint8_t y = 0;
|
||||
image.SetPixelColor(x++, y, DarkRed);
|
||||
image.SetPixelColor(x++, y, DarkYellow);
|
||||
image.SetPixelColor(x++, y, DarkGreen);
|
||||
image.SetPixelColor(x++, y, DarkCyan);
|
||||
image.SetPixelColor(x++, y, DarkBlue);
|
||||
image.SetPixelColor(x++, y, DarkPurple);
|
||||
|
||||
x = 0;
|
||||
y = 1;
|
||||
image.SetPixelColor(x++, y, BrightRed);
|
||||
image.SetPixelColor(x++, y, BrightYellow);
|
||||
image.SetPixelColor(x++, y, BrightGreen);
|
||||
image.SetPixelColor(x++, y, BrightCyan);
|
||||
image.SetPixelColor(x++, y, BrightBlue);
|
||||
image.SetPixelColor(x++, y, BrightPurple);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
|
||||
delta = -1; // start by dimming downward
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// we increment by delta every 30ms
|
||||
delay(30);
|
||||
|
||||
// update the brightness in shader
|
||||
//
|
||||
uint8_t brightness = shader.getBrightness();
|
||||
// check if we flip directions
|
||||
if (brightness == 0)
|
||||
{
|
||||
delta = 1; // increment
|
||||
}
|
||||
else if (brightness == 255)
|
||||
{
|
||||
delta = -1; // decrement
|
||||
}
|
||||
// modify and apply
|
||||
brightness += delta;
|
||||
shader.setBrightness(brightness);
|
||||
|
||||
Serial.println(brightness);
|
||||
|
||||
|
||||
// render the image using the shader and then call Show()
|
||||
// these two should be called together in order
|
||||
//
|
||||
|
||||
// need to provide the type of color feature for the strip and
|
||||
// the type of our custom shader
|
||||
image.Render<BrightnessShader<NeoGrbFeature>>(strip, shader);
|
||||
strip.Show();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
// NeoPixelDibTest
|
||||
// This example will provide a shader class to the NeoPixelDib that will dim and brighten
|
||||
// the pixels that are in the Dib (Device Independant Bitmap)
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
const uint16_t PixelCount = 64; // set this to the size of your strip
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
// three element GRB pixels, change to your needs
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
// the DIB object, using RgbColor and initialized with the same number of pixels as our strip
|
||||
NeoDib<RgbColor> image(PixelCount);
|
||||
|
||||
const RgbColor BrightRed(255, 0, 0);
|
||||
const RgbColor BrightGreen(0, 255, 0);
|
||||
const RgbColor BrightBlue(0, 0, 255);
|
||||
|
||||
const RgbColor BrightYellow(255, 255, 0);
|
||||
const RgbColor BrightCyan(0, 255, 255);
|
||||
const RgbColor BrightPurple(255, 0, 255);
|
||||
|
||||
const RgbColor DarkRed(32, 0, 0);
|
||||
const RgbColor DarkGreen(0, 32, 0);
|
||||
const RgbColor DarkBlue(0, 0, 32);
|
||||
|
||||
const RgbColor DarkYellow(32, 32, 0);
|
||||
const RgbColor DarkCyan(0, 32, 32);
|
||||
const RgbColor DarkPurple(32, 0, 32);
|
||||
|
||||
const RgbColor White(255);
|
||||
const RgbColor Black(0);
|
||||
|
||||
// define a custom shader object that provides brightness support
|
||||
// based upon the NeoShaderBase
|
||||
class BrightnessShader : public NeoShaderBase
|
||||
{
|
||||
public:
|
||||
BrightnessShader():
|
||||
NeoShaderBase(),
|
||||
_brightness(255) // default to full bright
|
||||
{}
|
||||
|
||||
// required for a shader object, it will be called for
|
||||
// every pixel
|
||||
RgbColor Apply(uint16_t index, RgbColor original)
|
||||
{
|
||||
// we don't care what the index is so we ignore it
|
||||
//
|
||||
// to apply our brightness shader, modify the original color and return the color we want
|
||||
// blend from black (_brightness == 0.0) to the original color (_brightness == 1.0)
|
||||
|
||||
return RgbColor::LinearBlend(Black, original, (float)_brightness / 255.0f);
|
||||
}
|
||||
|
||||
// provide an accessor to set brightness
|
||||
void setBrightness(uint8_t brightness)
|
||||
{
|
||||
_brightness = brightness;
|
||||
Dirty(); // must call dirty when a property changes
|
||||
}
|
||||
|
||||
// provide an accessor to get brightness
|
||||
uint8_t getBrightness()
|
||||
{
|
||||
return _brightness;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t _brightness;
|
||||
};
|
||||
|
||||
// create an instance of our shader object
|
||||
BrightnessShader shader;
|
||||
|
||||
// some dimming tracking variables and settings
|
||||
int8_t delta;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
Serial.flush();
|
||||
|
||||
// this resets all the neopixels to an off state
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
// dibs do not default to any color,
|
||||
// so clear it to black if you aren't going to draw
|
||||
// into every pixel
|
||||
image.ClearTo(Black);
|
||||
|
||||
// draw a pattern into the image
|
||||
uint8_t index = 0;
|
||||
image.SetPixelColor(index++, DarkRed);
|
||||
image.SetPixelColor(index++, DarkYellow);
|
||||
image.SetPixelColor(index++, DarkGreen);
|
||||
image.SetPixelColor(index++, DarkCyan);
|
||||
image.SetPixelColor(index++, DarkBlue);
|
||||
image.SetPixelColor(index++, DarkPurple);
|
||||
|
||||
image.SetPixelColor(index++, Black);
|
||||
image.SetPixelColor(index++, Black);
|
||||
|
||||
image.SetPixelColor(index++, BrightRed);
|
||||
image.SetPixelColor(index++, BrightYellow);
|
||||
image.SetPixelColor(index++, BrightGreen);
|
||||
image.SetPixelColor(index++, BrightCyan);
|
||||
image.SetPixelColor(index++, BrightBlue);
|
||||
image.SetPixelColor(index++, BrightPurple);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
|
||||
delta = -1; // start by dimming downward
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// we increment by delta every 30ms
|
||||
delay(30);
|
||||
|
||||
// update the brightness in shader
|
||||
//
|
||||
uint8_t brightness = shader.getBrightness();
|
||||
// check if we flip directions
|
||||
if (brightness == 0)
|
||||
{
|
||||
delta = 1; // increment
|
||||
}
|
||||
else if (brightness == 255)
|
||||
{
|
||||
delta = -1; // decrement
|
||||
}
|
||||
// modify and apply
|
||||
brightness += delta;
|
||||
shader.setBrightness(brightness);
|
||||
|
||||
Serial.println(brightness);
|
||||
|
||||
|
||||
// render the image using the shader and then call Show()
|
||||
// these two should be called together in order
|
||||
//
|
||||
|
||||
// need to provide the type of color feature for the strip and
|
||||
// the type of our custom shader
|
||||
image.Render<NeoGrbFeature, BrightnessShader>(strip, shader);
|
||||
strip.Show();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// NeoSegmentBus
|
||||
// This example will demonstrate using the NeoSegmentBus which provides support for a
|
||||
// seven segment LED digit driven by three WS2811; connected in series with other digits
|
||||
//
|
||||
// See https://shop.idlehandsdev.com/products/addressable-7-segment-display for a hardware example
|
||||
//
|
||||
// This example will print the string "3.14" and then rotate it through the available digits
|
||||
//
|
||||
|
||||
#include <NeoPixelSegmentBus.h>
|
||||
|
||||
const uint16_t DigitCount = 4; // Max Digits, not segments, not pixels
|
||||
const uint8_t BusPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
#define brightness 128
|
||||
|
||||
NeoPixelSegmentBus<SevenSegmentFeature, NeoWs2811Method> strip(DigitCount, BusPin);
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show(); // clears all digits by default
|
||||
|
||||
delay(500);
|
||||
strip.SetString(0, "3.14", brightness);
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(2000);
|
||||
|
||||
strip.RotateLeft(1);
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
// NeoSegmentBus
|
||||
// This example will demonstrate using the NeoSegmentBus which provides support for a
|
||||
// seven segment LED digit driven by three WS2811; connected in series with other digits
|
||||
//
|
||||
// See https://shop.idlehandsdev.com/products/addressable-7-segment-display for a hardware example
|
||||
//
|
||||
// This example will print current seconds since start of the Arduino
|
||||
// with a digit animating a circling path for each second
|
||||
//
|
||||
|
||||
#include <NeoPixelSegmentBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
const uint16_t DigitCount = 5; // Max Digits, not segments, not pixels
|
||||
const uint8_t BusPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
const uint16_t CycleDigit = 0;
|
||||
const uint16_t SecondsDigit = 1;
|
||||
|
||||
#define brightness 128
|
||||
|
||||
NeoPixelSegmentBus<SevenSegmentFeature, NeoWs2811Method> strip(DigitCount, BusPin);
|
||||
|
||||
enum Animation
|
||||
{
|
||||
Animation_Cycle, // animation for the cycle indicator
|
||||
Animation_Fade, // animation for fade of seconds
|
||||
Animation_COUNT
|
||||
};
|
||||
|
||||
NeoPixelAnimator animations(Animation_COUNT);
|
||||
|
||||
void CycleAnimation(const AnimationParam& param)
|
||||
{
|
||||
// calculate which segment should be on using the animation progress
|
||||
uint8_t bitfield = 1 << (uint8_t)(param.progress * LedSegment_F);
|
||||
// instant a digit with that segment on
|
||||
SevenSegDigit digit(bitfield, brightness);
|
||||
// apply it to the strip
|
||||
strip.SetPixelColor(CycleDigit, digit);
|
||||
}
|
||||
|
||||
// for the animation of fading the new number in, we use
|
||||
// two digit DIBs (Device Independant Bitmaps) of SevenSegDigit to blend with;
|
||||
// each sized one less than the strip due to the first is a used for the cycle
|
||||
// animation.
|
||||
typedef NeoDib<SevenSegDigit> SevenSegDib;
|
||||
|
||||
SevenSegDib StartingDigits(DigitCount - 1);
|
||||
SevenSegDib EndingDigits(DigitCount - 1);
|
||||
|
||||
// shader class that will do the "string" blending
|
||||
//
|
||||
class DigitBlendShader
|
||||
{
|
||||
public:
|
||||
// this shader always renders and doesn't track a dirty state
|
||||
bool IsDirty() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ResetDirty()
|
||||
{
|
||||
}
|
||||
|
||||
SevenSegDigit Apply(uint16_t indexDigit, SevenSegDigit digit)
|
||||
{
|
||||
// since we call EndingDigits.Render below, the digit argument is
|
||||
// from the EndingDigits so no need to call GetPixelColor to get it
|
||||
// create a digit that is a blend between the last seconds
|
||||
// value and the next seconds value using the BlendAmount
|
||||
SevenSegDigit blendDigit = SevenSegDigit::LinearBlend(
|
||||
StartingDigits.GetPixelColor(indexDigit),
|
||||
digit,
|
||||
BlendAmount);
|
||||
|
||||
return blendDigit;
|
||||
}
|
||||
|
||||
float BlendAmount;
|
||||
};
|
||||
|
||||
// the instance of our shader class
|
||||
DigitBlendShader blendShader;
|
||||
|
||||
void FadeAnimation(const AnimationParam& param)
|
||||
{
|
||||
// set the shader property BlendAmount to the animation progress
|
||||
blendShader.BlendAmount = param.progress;
|
||||
// apply it to the strip at the SecondsDigit location
|
||||
EndingDigits.Render<SevenSegmentFeature, DigitBlendShader>(strip,
|
||||
blendShader,
|
||||
SecondsDigit);
|
||||
}
|
||||
|
||||
uint32_t lastSeconds;
|
||||
|
||||
void setup()
|
||||
{
|
||||
lastSeconds = millis() / 1000;
|
||||
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
// init animation Dibs as cleared
|
||||
StartingDigits.ClearTo(0);
|
||||
EndingDigits.ClearTo(0);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint32_t seconds = millis() / 1000;
|
||||
|
||||
// when the seconds change, start animations for the update
|
||||
//
|
||||
if (seconds != lastSeconds)
|
||||
{
|
||||
// copy last animation ending digits as starting digits
|
||||
StartingDigits = EndingDigits;
|
||||
|
||||
// format and display new value in ending digits dib
|
||||
String display(seconds);
|
||||
SevenSegDigit::SetString<SevenSegDib>(EndingDigits,
|
||||
0,
|
||||
display.c_str(),
|
||||
brightness);
|
||||
|
||||
// start the seconds fade animation
|
||||
animations.StartAnimation(Animation_Fade, 1000, FadeAnimation);
|
||||
|
||||
// start the cycle animation for the next second
|
||||
animations.StartAnimation(Animation_Cycle, 1000, CycleAnimation);
|
||||
|
||||
lastSeconds = seconds;
|
||||
}
|
||||
|
||||
if (animations.IsAnimating())
|
||||
{
|
||||
// the normal loop just needs these two to run the active animations
|
||||
animations.UpdateAnimations();
|
||||
strip.Show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
//----------------------------------------------------------------------
|
||||
// NeoPixelMosaicDump
|
||||
// This will dump to the serial output a grid map of the defined mosaic
|
||||
// The output is displayed as row column labeled grid with the NeoPixelBus
|
||||
// index of the pixel at the intersection of the row and column.
|
||||
//
|
||||
// To help with physical layout, there maybe included a symbol following the index
|
||||
// < means the index is the input index for the panel, the first on the panel
|
||||
// > means the index is the output index for the panel, the last on the panel
|
||||
//
|
||||
// This is useful in visualising the mosaic layout of your panels to
|
||||
// confirm you have them correctly wired together for this mosaic pattern
|
||||
//
|
||||
// It does not require that you have the actual panel connected
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <NeoPixelAnimator.h>
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
// uncomment one of these that matches your panel pixel layouts
|
||||
// rotation is ignored for mosaic as it applies a rotation for you
|
||||
// that is specific to the location of the panel within the mosaic
|
||||
// to reduce connection lengths
|
||||
|
||||
typedef ColumnMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef ColumnMajorLayout MyPanelLayout;
|
||||
// typedef RowMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef RowMajorLayout MyPanelLayout;
|
||||
|
||||
// make sure to set these panel and tile layout to match your sizes
|
||||
const uint8_t PanelWidth = 8; // a 8 pixel x 8 pixel matrix of leds on the panel
|
||||
const uint8_t PanelHeight = 8;
|
||||
const uint8_t TileWidth = 4; // laid out in 4 panels x 2 panels mosaic
|
||||
const uint8_t TileHeight = 2;
|
||||
|
||||
NeoMosaic <MyPanelLayout> mosaic(
|
||||
PanelWidth,
|
||||
PanelHeight,
|
||||
TileWidth,
|
||||
TileHeight);
|
||||
|
||||
void DumpMosaic()
|
||||
{
|
||||
Serial.println();
|
||||
|
||||
Serial.print("\t\t");
|
||||
for (int x = 0; x < mosaic.getWidth(); x++)
|
||||
{
|
||||
Serial.print(x);
|
||||
Serial.print("\t");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
Serial.print("\t---");
|
||||
for (int x = 0; x < mosaic.getWidth(); x++)
|
||||
{
|
||||
Serial.print("--------");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
for (int y = 0; y < mosaic.getHeight(); y++)
|
||||
{
|
||||
Serial.print(" ");
|
||||
Serial.print(y);
|
||||
Serial.print("\t|\t");
|
||||
|
||||
for (int x = 0; x < mosaic.getWidth(); x++)
|
||||
{
|
||||
NeoTopologyHint hint = mosaic.TopologyHint(x, y);
|
||||
|
||||
Serial.print(mosaic.Map(x, y));
|
||||
if (hint == NeoTopologyHint_FirstOnPanel)
|
||||
{
|
||||
Serial.print("<");
|
||||
}
|
||||
else if (hint == NeoTopologyHint_LastOnPanel)
|
||||
{
|
||||
Serial.print(">");
|
||||
}
|
||||
Serial.print("\t");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
DumpMosaic();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
//----------------------------------------------------------------------
|
||||
// NeoPixelTopologyTest
|
||||
// This will display specific colors in specific locations on the led panels
|
||||
//
|
||||
// This is useful in confirming the layout of your panels
|
||||
//
|
||||
// It does require that you have the actual panels connected
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <NeoPixelAnimator.h>
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
// uncomment one of these that matches your panel pixel layouts
|
||||
// rotation is ignored for mosaic as it applies a rotation for you
|
||||
// that is specific to the location of the panel within the mosaic
|
||||
// to reduce connection lengths
|
||||
|
||||
typedef ColumnMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef ColumnMajorLayout MyPanelLayout;
|
||||
// typedef RowMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef RowMajorLayout MyPanelLayout;
|
||||
|
||||
// make sure to set these panel values to the sizes of yours
|
||||
const uint8_t PanelWidth = 8; // 8 pixel x 8 pixel matrix of leds
|
||||
const uint8_t PanelHeight = 8;
|
||||
const uint8_t TileWidth = 4; // laid out in 4 panels x 2 panels mosaic
|
||||
const uint8_t TileHeight = 2;
|
||||
|
||||
const uint16_t PixelCount = PanelWidth * PanelHeight * TileWidth * TileHeight;
|
||||
const uint8_t PixelPin = 2;
|
||||
|
||||
NeoMosaic <MyPanelLayout> mosaic(
|
||||
PanelWidth,
|
||||
PanelHeight,
|
||||
TileWidth,
|
||||
TileHeight);
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// for esp8266 omit the pin
|
||||
//NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
|
||||
|
||||
RgbColor red(128, 0, 0);
|
||||
RgbColor green(0, 128, 0);
|
||||
RgbColor blue(0, 0, 128);
|
||||
RgbColor white(128);
|
||||
// if using NeoRgbwFeature above, use this white instead to use
|
||||
// the correct white element of the LED
|
||||
//RgbwColor white(128);
|
||||
RgbColor black(0);
|
||||
|
||||
const uint16_t left = 0;
|
||||
const uint16_t right = PanelWidth - 1;
|
||||
const uint16_t top = 0;
|
||||
const uint16_t bottom = PanelHeight - 1;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(2500);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("If your panel is correctly defined, you should see ...");
|
||||
Serial.println("Upper left is white.");
|
||||
Serial.println("Upper right is Red.");
|
||||
Serial.println("Lower right is Green");
|
||||
Serial.println("Lower Left is Blue");
|
||||
|
||||
// use the topo to map the 2d cordinate to the pixel
|
||||
// and use that to SetPixelColor
|
||||
strip.SetPixelColor(mosaic.Map(left, top), white);
|
||||
strip.SetPixelColor(mosaic.Map(right, top), red);
|
||||
strip.SetPixelColor(mosaic.Map(right, bottom), green);
|
||||
strip.SetPixelColor(mosaic.Map(left, bottom), blue);
|
||||
strip.Show();
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Cleared to black ...");
|
||||
strip.ClearTo(black);
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
//----------------------------------------------------------------------
|
||||
// NeoPixelRingTopologyTest
|
||||
// This will display specific colors in specific locations on the led rings
|
||||
//
|
||||
// This is useful in confirming the layout of your rings
|
||||
//
|
||||
// It does require that you have the actual series of rings connected
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
const uint8_t PixelCount = 119;
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
// define the layout of your series of rings
|
||||
//
|
||||
// This example is using all of Adafruits rings and a Jewel in the center.
|
||||
// The center is the input and all the rings are connected in series going outward
|
||||
//
|
||||
// Rings:
|
||||
// 0 - 1 (virtual ring, the center of the jewel)
|
||||
// 1 - 6 (virtual ring, the outer ring of the jewel)
|
||||
// 2 - 12 count ring
|
||||
// 3 - 16 count ring
|
||||
// 4 - 24 count ring
|
||||
// 5 - 60 count ring comprised of four arc segments
|
||||
//
|
||||
// The values below in Rings[] are the index of the first pixel in each ring.
|
||||
// An extra value is appended for a virtual ring start that also
|
||||
// represents the total count of pixels in the complete series and this extra
|
||||
// value is required.
|
||||
//
|
||||
class MyRingsLayout
|
||||
{
|
||||
protected:
|
||||
const uint16_t Rings[7] = {0, 1, 7, 19, 35, 59, PixelCount};
|
||||
};
|
||||
|
||||
// use the MyRingsLayout to declare the topo object
|
||||
//
|
||||
NeoRingTopology<MyRingsLayout> topo;
|
||||
|
||||
// declare our strip
|
||||
//
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
|
||||
// define some handy colors
|
||||
//
|
||||
RgbColor red(128, 0, 0);
|
||||
RgbColor green(0, 128, 0);
|
||||
RgbColor blue(0, 0, 128);
|
||||
RgbColor black(0);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(2500);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("If your panel is correctly defined, you should see ...");
|
||||
Serial.println("First pixel in each ring is Red.");
|
||||
Serial.println("Middle pixel in each ring is Green.");
|
||||
Serial.println("Last Pixel in each ring is Blue.");
|
||||
|
||||
|
||||
// use the topo to map the 2d polar cordinate to the pixel
|
||||
// and use that to SetPixelColor
|
||||
for (uint16_t ring = 0; ring < topo.getCountOfRings(); ring++)
|
||||
{
|
||||
// first pixel in each ring is red
|
||||
strip.SetPixelColor(topo.Map(ring, 0), red);
|
||||
// last pixel in each ring is blue
|
||||
strip.SetPixelColor(topo.Map(ring, topo.getPixelCountAtRing(ring) - 1), blue);
|
||||
// middle pixel in each ring is green
|
||||
strip.SetPixelColor(topo.Map(ring, topo.getPixelCountAtRing(ring) / 2), green);
|
||||
}
|
||||
strip.Show();
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Cleared to black ...");
|
||||
strip.ClearTo(black);
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
//----------------------------------------------------------------------
|
||||
// NeoPixelTileDump
|
||||
// This will dump to the serial output a grid map of the defined tiles
|
||||
// The output is displayed as row column labeled grid with the NeoPixelBus
|
||||
// index of the pixel at the intersection of the row and column
|
||||
//
|
||||
// To help with physical layout, there maybe included a symbol following the index
|
||||
// < means the index is the input index for the panel, the first on the panel
|
||||
// > means the index is the output index for the panel, the last on the panel
|
||||
//
|
||||
// This is useful in visualising the tile layout of your panels to
|
||||
// confirm you have them correctly wired together for the defined pattern
|
||||
//
|
||||
// It does not require that you have the actual panel connected
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <NeoPixelAnimator.h>
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
// uncomment one of these that matches your panel pixel layouts and
|
||||
// how you want them rotated. Not all the rotations are listed here
|
||||
// but you can modifiy the name to include the rotation of 90,180, or 270.
|
||||
|
||||
typedef ColumnMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef ColumnMajorLayout MyPanelLayout;
|
||||
// typedef RowMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef RowMajorLayout MyPanelLayout;
|
||||
// typedef RowMajor90Layout MyPanelLayout; // note rotation 90 was used
|
||||
|
||||
// change this to be one of the layouts which will define the layout
|
||||
// of the panels themselves
|
||||
typedef ColumnMajorLayout MyTilesLayout;
|
||||
|
||||
// make sure to set these panel and tile layout to match your sizes
|
||||
const uint8_t PanelWidth = 8; // 8 pixel x 8 pixel matrix of leds
|
||||
const uint8_t PanelHeight = 8;
|
||||
const uint8_t TileWidth = 4; // laid out in 4 panels x 2 panels mosaic
|
||||
const uint8_t TileHeight = 2;
|
||||
|
||||
NeoTiles <MyPanelLayout, MyTilesLayout> tiles(
|
||||
PanelWidth,
|
||||
PanelHeight,
|
||||
TileWidth,
|
||||
TileHeight);
|
||||
|
||||
void DumpTopo()
|
||||
{
|
||||
Serial.println();
|
||||
|
||||
Serial.print("\t\t");
|
||||
for (int x = 0; x < tiles.getWidth(); x++)
|
||||
{
|
||||
Serial.print(x);
|
||||
Serial.print("\t");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
Serial.print("\t---");
|
||||
for (int x = 0; x < tiles.getWidth(); x++)
|
||||
{
|
||||
Serial.print("--------");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
for (int y = 0; y < tiles.getHeight(); y++)
|
||||
{
|
||||
Serial.print(" ");
|
||||
Serial.print(y);
|
||||
Serial.print("\t|\t");
|
||||
|
||||
for (int x = 0; x < tiles.getWidth(); x++)
|
||||
{
|
||||
NeoTopologyHint hint = tiles.TopologyHint(x, y);
|
||||
|
||||
Serial.print(tiles.Map(x, y));
|
||||
if (hint == NeoTopologyHint_FirstOnPanel)
|
||||
{
|
||||
Serial.print("<");
|
||||
}
|
||||
else if (hint == NeoTopologyHint_LastOnPanel)
|
||||
{
|
||||
Serial.print(">");
|
||||
}
|
||||
Serial.print("\t");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
DumpTopo();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//----------------------------------------------------------------------
|
||||
// NeoPixelTilesTest
|
||||
// This will display specific colors in specific locations on the led panels
|
||||
//
|
||||
// This is useful in confirming the layout of your panels
|
||||
//
|
||||
// It does require that you have the actual panels connected
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <NeoPixelAnimator.h>
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
// uncomment one of these that matches your panel pixel layouts and
|
||||
// how you want them rotated. Not all the rotations are listed here
|
||||
// but you can modifiy the name to include the rotation of 90,180, or 270.
|
||||
|
||||
typedef ColumnMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef ColumnMajorLayout MyPanelLayout;
|
||||
// typedef RowMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef RowMajorLayout MyPanelLayout;
|
||||
// typedef RowMajor90Layout MyPanelLayout; // note rotation 90 was used
|
||||
|
||||
// change this to be one of the layouts which will define the layout
|
||||
// of the panels themselves
|
||||
typedef ColumnMajorLayout MyTilesLayout;
|
||||
|
||||
// make sure to set these panel values to the sizes of yours
|
||||
const uint8_t PanelWidth = 8; // 8 pixel x 8 pixel matrix of leds
|
||||
const uint8_t PanelHeight = 8;
|
||||
const uint8_t TileWidth = 4; // laid out in 4 panels x 2 panels mosaic
|
||||
const uint8_t TileHeight = 2;
|
||||
|
||||
const uint16_t PixelCount = PanelWidth * PanelHeight * TileWidth * TileHeight;
|
||||
const uint8_t PixelPin = 2;
|
||||
|
||||
NeoTiles <MyPanelLayout, MyTilesLayout> tiles(
|
||||
PanelWidth,
|
||||
PanelHeight,
|
||||
TileWidth,
|
||||
TileHeight);
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
//NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
//NeoPixelBus<NeoRgbwFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// for esp8266 omit the pin
|
||||
//NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
|
||||
|
||||
RgbColor red(128, 0, 0);
|
||||
RgbColor green(0, 128, 0);
|
||||
RgbColor blue(0, 0, 128);
|
||||
RgbColor white(128);
|
||||
// if using NeoRgbwFeature above, use this white instead to use
|
||||
// the correct white element of the LED
|
||||
//RgbwColor white(128);
|
||||
RgbColor black(0);
|
||||
|
||||
const uint16_t left = 0;
|
||||
const uint16_t right = PanelWidth - 1;
|
||||
const uint16_t top = 0;
|
||||
const uint16_t bottom = PanelHeight - 1;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(2500);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("If your panel is correctly defined, you should see ...");
|
||||
Serial.println("Upper left is white.");
|
||||
Serial.println("Upper right is Red.");
|
||||
Serial.println("Lower right is Green");
|
||||
Serial.println("Lower Left is Blue");
|
||||
|
||||
// use the topo to map the 2d cordinate to the pixel
|
||||
// and use that to SetPixelColor
|
||||
strip.SetPixelColor(tiles.Map(left, top), white);
|
||||
strip.SetPixelColor(tiles.Map(right, top), red);
|
||||
strip.SetPixelColor(tiles.Map(right, bottom), green);
|
||||
strip.SetPixelColor(tiles.Map(left, bottom), blue);
|
||||
strip.Show();
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Cleared to black ...");
|
||||
strip.ClearTo(black);
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
//----------------------------------------------------------------------
|
||||
// NeoPixelTopologyDump
|
||||
// This will dump to the serial output a grid map of the defined topology
|
||||
// The output is displayed as row column labeled grid with the NeoPixelBus
|
||||
// index of the pixel at the intersection of the row and column
|
||||
//
|
||||
// This is useful in visualising the layout of your panel so you can
|
||||
// confirm you have the correct pattern
|
||||
//
|
||||
// It does not require that you have the actual panel connected
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <NeoPixelAnimator.h>
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
// uncomment one of these that matches your panel pixel layouts and
|
||||
// how you want them rotated. Not all the rotations are listed here
|
||||
// but you can modifiy the name to include the rotation of 90,180, or 270.
|
||||
|
||||
typedef ColumnMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef ColumnMajorLayout MyPanelLayout;
|
||||
// typedef RowMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef RowMajorLayout MyPanelLayout;
|
||||
// typedef RowMajor90Layout MyPanelLayout; // note rotation 90 was used
|
||||
|
||||
// make sure to set these panel values to the sizes of yours
|
||||
const uint8_t PanelWidth = 8; // 8 pixel x 8 pixel matrix of leds
|
||||
const uint8_t PanelHeight = 8;
|
||||
|
||||
NeoTopology<MyPanelLayout> topo(PanelWidth, PanelHeight);
|
||||
|
||||
void DumpTopo()
|
||||
{
|
||||
Serial.println();
|
||||
|
||||
Serial.print("\t\t");
|
||||
for (int x = 0; x < topo.getWidth(); x++)
|
||||
{
|
||||
Serial.print(x);
|
||||
Serial.print("\t");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
Serial.print("\t--");
|
||||
for (int x = 0; x < topo.getWidth(); x++)
|
||||
{
|
||||
Serial.print("--------");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
for (int y = 0; y < topo.getHeight(); y++)
|
||||
{
|
||||
Serial.print(" ");
|
||||
Serial.print(y);
|
||||
Serial.print("\t|\t");
|
||||
|
||||
for (int x = 0; x < topo.getWidth(); x++)
|
||||
{
|
||||
Serial.print(topo.Map(x, y));
|
||||
Serial.print("\t");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
DumpTopo();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
//----------------------------------------------------------------------
|
||||
// NeoPixelTopologyTest
|
||||
// This will display specific colors in specific locations on the led panel
|
||||
//
|
||||
// This is useful in confirming the layout of your panel
|
||||
//
|
||||
// It does require that you have the actual panel connected
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include <NeoPixelAnimator.h>
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
// uncomment one of these that matches your panel pixel layouts and
|
||||
// how you want them rotated. Not all the rotations are listed here
|
||||
// but you can modifiy the name to include the rotation of 90,180, or 270.
|
||||
|
||||
typedef ColumnMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef ColumnMajorLayout MyPanelLayout;
|
||||
// typedef RowMajorAlternatingLayout MyPanelLayout;
|
||||
// typedef RowMajorLayout MyPanelLayout;
|
||||
// typedef RowMajor90Layout MyPanelLayout; // note rotation 90 was used
|
||||
|
||||
// make sure to set these panel values to the sizes of yours
|
||||
const uint8_t PanelWidth = 8; // 8 pixel x 8 pixel matrix of leds
|
||||
const uint8_t PanelHeight = 8;
|
||||
const uint16_t PixelCount = PanelWidth * PanelHeight;
|
||||
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
|
||||
|
||||
NeoTopology<MyPanelLayout> topo(PanelWidth, PanelHeight);
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
//NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
//NeoPixelBus<NeoRgbwFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
// for esp8266 omit the pin
|
||||
//NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount);
|
||||
|
||||
RgbColor red(128, 0, 0);
|
||||
RgbColor green(0, 128, 0);
|
||||
RgbColor blue(0, 0, 128);
|
||||
RgbColor white(128);
|
||||
// if using NeoRgbwFeature above, use this white instead to use
|
||||
// the correct white element of the LED
|
||||
//RgbwColor white(128);
|
||||
RgbColor black(0);
|
||||
|
||||
const uint16_t left = 0;
|
||||
const uint16_t right = PanelWidth - 1;
|
||||
const uint16_t top = 0;
|
||||
const uint16_t bottom = PanelHeight - 1;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // wait for serial attach
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Initializing...");
|
||||
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Running...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(2500);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("If your panel is correctly defined, you should see ...");
|
||||
Serial.println("Upper left is white.");
|
||||
Serial.println("Upper right is Red.");
|
||||
Serial.println("Lower right is Green");
|
||||
Serial.println("Lower Left is Blue");
|
||||
|
||||
// use the topo to map the 2d cordinate to the pixel
|
||||
// and use that to SetPixelColor
|
||||
strip.SetPixelColor(topo.Map(left, top), white);
|
||||
strip.SetPixelColor(topo.Map(right, top), red);
|
||||
strip.SetPixelColor(topo.Map(right, bottom), green);
|
||||
strip.SetPixelColor(topo.Map(left, bottom), blue);
|
||||
strip.Show();
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Cleared to black ...");
|
||||
strip.ClearTo(black);
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user