forked from Makuna/NeoPixelBus
@@ -2,7 +2,7 @@
|
||||
// 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 NeoPixelVerticalSpriteSheet
|
||||
// This will demonstrate the use of the NeoVerticalSpriteSheet
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
@@ -26,7 +26,7 @@ NeoPixelBus<MyPixelColorFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
|
||||
NeoPixelAnimator animations(AnimCount); // NeoPixel animation management object
|
||||
|
||||
// sprite sheet stored in progmem using the same pixel feature as the NeoPixelBus
|
||||
NeoPixelVerticalSpriteSheet<NeoPixelBufferProgmemMethod<MyPixelColorFeature>> spriteSheet(
|
||||
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
|
||||
|
@@ -61,10 +61,10 @@ NeoHueBlendClockwiseDirection KEYWORD1
|
||||
NeoHueBlendCounterClockwiseDirection KEYWORD1
|
||||
NeoBufferContext KEYWORD1
|
||||
LayoutMapCallback KEYWORD1
|
||||
NeoPixelBufferMethod KEYWORD1
|
||||
NeoPixelBufferProgmemMethod KEYWORD1
|
||||
NeoPixelBuffer KEYWORD1
|
||||
NeoPixelVerticalSpriteSheet KEYWORD1
|
||||
NeoBufferMethod KEYWORD1
|
||||
NeoBufferProgmemMethod KEYWORD1
|
||||
NeoBuffer KEYWORD1
|
||||
NeoVerticalSpriteSheet KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
|
@@ -7,7 +7,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/Makuna/NeoPixelBus"
|
||||
},
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
name=NeoPixelBus by Makuna
|
||||
version=2.1.0
|
||||
version=2.1.1
|
||||
author=Michael C. Miller (makuna@live.com)
|
||||
maintainer=Michael C. Miller (makuna@live.com)
|
||||
sentence=A library that makes controlling NeoPixels (WS2811, WS2812 & SK6812) easy.
|
||||
|
@@ -41,9 +41,9 @@ License along with NeoPixel. If not, see
|
||||
#include "internal/NeoMosaic.h"
|
||||
|
||||
#include "internal/NeoBufferContext.h"
|
||||
#include "internal/NeoPixelBufferMethods.h"
|
||||
#include "internal/NeoPixelBuffer.h"
|
||||
#include "internal/NeoPixelSpriteSheet.h"
|
||||
#include "internal/NeoBufferMethods.h"
|
||||
#include "internal/NeoBuffer.h"
|
||||
#include "internal/NeoSpriteSheet.h"
|
||||
|
||||
#include "internal/NeoEase.h"
|
||||
#include "internal/NeoGamma.h"
|
||||
|
@@ -25,10 +25,10 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
template<typename T_BUFFER_METHOD> class NeoPixelBuffer
|
||||
template<typename T_BUFFER_METHOD> class NeoBuffer
|
||||
{
|
||||
public:
|
||||
NeoPixelBuffer(uint16_t width,
|
||||
NeoBuffer(uint16_t width,
|
||||
uint16_t height,
|
||||
PGM_VOID_P pixels) :
|
||||
_method(width, height, pixels)
|
@@ -40,10 +40,10 @@ typedef std::function<uint16_t(int16_t x, int16_t y)> LayoutMapCallback;
|
||||
|
||||
#endif
|
||||
|
||||
template<typename T_COLOR_FEATURE> class NeoPixelBufferMethod
|
||||
template<typename T_COLOR_FEATURE> class NeoBufferMethod
|
||||
{
|
||||
public:
|
||||
NeoPixelBufferMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels = NULL) :
|
||||
NeoBufferMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels = NULL) :
|
||||
_width(width),
|
||||
_height(height)
|
||||
{
|
||||
@@ -157,10 +157,10 @@ private:
|
||||
uint8_t* _pixels;
|
||||
};
|
||||
|
||||
template<typename T_COLOR_FEATURE> class NeoPixelBufferProgmemMethod
|
||||
template<typename T_COLOR_FEATURE> class NeoBufferProgmemMethod
|
||||
{
|
||||
public:
|
||||
NeoPixelBufferProgmemMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels) :
|
||||
NeoBufferProgmemMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels) :
|
||||
_width(width),
|
||||
_height(height),
|
||||
_pixels(pixels)
|
@@ -26,10 +26,10 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
template<typename T_BUFFER_METHOD> class NeoPixelVerticalSpriteSheet
|
||||
template<typename T_BUFFER_METHOD> class NeoVerticalSpriteSheet
|
||||
{
|
||||
public:
|
||||
NeoPixelVerticalSpriteSheet(uint16_t width,
|
||||
NeoVerticalSpriteSheet(uint16_t width,
|
||||
uint16_t height,
|
||||
uint16_t spriteHeight,
|
||||
PGM_VOID_P pixels) :
|
@@ -1,95 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Teture provides a texture object that can contain a matrix of Color
|
||||
values
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
NOTES:
|
||||
Where does the data come from?
|
||||
* Loaded by external routine
|
||||
|
||||
|
||||
|
||||
template<typename T_COLOR> class Texture
|
||||
{
|
||||
public:
|
||||
Texture(uint16_t width, uint16_t height, T_COLOR* pixels) :
|
||||
_width(width),
|
||||
_height(height),
|
||||
_pixels(pixels)
|
||||
{
|
||||
};
|
||||
|
||||
const T_COLOR* Blend(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, float progress)
|
||||
{
|
||||
x1 = constrain(x1, 0, _width - 1);
|
||||
y1 = constrain(y1, 0, _height - 1);
|
||||
x2 = constrain(x2, 0, _width - 1);
|
||||
y2 = constrain(y2, 0, _height - 1);
|
||||
|
||||
// calc cordinate of the four nearby pixels
|
||||
// first lerp our cordinates
|
||||
float xf = (static_cast<float>(x2) - x1) * progress + x1;
|
||||
float yf = (static_cast<float>(y2) - y1) * progress + y1;
|
||||
|
||||
uint16_t x = static_cast<uint16_t>(xf); // truncates to lower uint
|
||||
uint16_t y = static_cast<uint16_t>(yf); // truncates to lower uint
|
||||
uint16_t xn = x + 1;
|
||||
uint16_t yn = y + 1;
|
||||
|
||||
T_COLOR c00 = PixelAt(x, y);
|
||||
T_COLOR c01 = PixelAt(x, yn);
|
||||
T_COLOR c10 = PixelAt(xn, y);
|
||||
T_COLOR c11 = PixelAt(xn, yn);
|
||||
|
||||
// unitize progress cordinate to these pixels
|
||||
xf -= x;
|
||||
yf -= y;
|
||||
|
||||
return T_COLOR::BilinearBlend(c00, c01, c10, c11, xf, yf);
|
||||
};
|
||||
|
||||
const T_COLOR& PixelAt(uint16_t x, uint16_t y)
|
||||
{
|
||||
uint16_t xSafe = constrain(x, 0, _width - 1);
|
||||
uint16_t ySafe = constrain(y, 0, _height - 1);
|
||||
return pixelAt(xSafe, ySafe);
|
||||
}
|
||||
|
||||
private:
|
||||
const uint16_t _width;
|
||||
const uint16_t _height;
|
||||
const T_COLOR* _pixels;
|
||||
|
||||
const T_COLOR& pixelAt(uint16_t x, uint16_t y)
|
||||
{
|
||||
return *(_pixels + x + y * _width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef Texture<RgbColor> RgbTexture;
|
||||
typedef Texture<RgbwColor> RgbwTexture;
|
||||
typedef Texture<HtmlColor> HtmlTexture;
|
||||
|
Reference in New Issue
Block a user