Tasmota/lib/lib_basic/NeoPixelBus-2.6.1.4/examples/bitmaps/NeoPixelBufferCylon/NeoPixelBufferCylon.ino
Jason2866 0e0275cf43
Patch 2 (#173)
* ili9341 update

* update ili9341

* Update support_tasmota.ino

* fix scripter bug

* Deep+

* Update ILI9341_2.cpp

Fix invert display

* Update xdsp_04_ili9341.ino

Fix display modes

* fix ili9341 m5stack

* Refactor DHT negative temps

* Standardize on unconnected pin being -1

* Back to chain+

* Strict

* strict

* Update platformio_tasmota32.ini

* Fix renderer

* Change NeoPixelBus library from v2.6.0 to v2.6.1.4

* display batch

* Update xdrv_13_display.ino

* ldf strict

Co-authored-by: gemu2015 <gmutz2010@googlemail.com>
Co-authored-by: Theo Arends <11044339+arendst@users.noreply.github.com>
2021-02-14 16:04:03 +01:00

75 lines
2.4 KiB
C++

// 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();
}