From 007268ca004c8e0c1fe201a5f1612cc29d6f0a91 Mon Sep 17 00:00:00 2001 From: Makuna Date: Sat, 16 Apr 2016 14:11:13 -0700 Subject: [PATCH] Better Naming --- .../NeoPixelBufferCylon.ino | 4 +- keywords.txt | 8 +- library.json | 2 +- library.properties | 2 +- src/NeoPixelBus.h | 6 +- .../{NeoPixelBuffer.h => NeoBuffer.h} | 4 +- ...ixelBufferMethods.h => NeoBufferMethods.h} | 8 +- ...NeoPixelSpriteSheet.h => NeoSpriteSheet.h} | 4 +- src/internal/NeoTexture.h | 95 ------------------- 9 files changed, 19 insertions(+), 114 deletions(-) rename src/internal/{NeoPixelBuffer.h => NeoBuffer.h} (97%) rename src/internal/{NeoPixelBufferMethods.h => NeoBufferMethods.h} (95%) rename src/internal/{NeoPixelSpriteSheet.h => NeoSpriteSheet.h} (97%) delete mode 100644 src/internal/NeoTexture.h diff --git a/examples/NeoPixelBufferCylon/NeoPixelBufferCylon.ino b/examples/NeoPixelBufferCylon/NeoPixelBufferCylon.ino index d3437507..a68660f4 100644 --- a/examples/NeoPixelBufferCylon/NeoPixelBufferCylon.ino +++ b/examples/NeoPixelBufferCylon/NeoPixelBufferCylon.ino @@ -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 @@ -26,7 +26,7 @@ NeoPixelBus strip(PixelCount, PixelPin); NeoPixelAnimator animations(AnimCount); // NeoPixel animation management object // sprite sheet stored in progmem using the same pixel feature as the NeoPixelBus -NeoPixelVerticalSpriteSheet> spriteSheet( +NeoVerticalSpriteSheet> spriteSheet( myImageWidth, // image width and sprite width since its vertical sprite sheet myImageHeight, // image height 1, // sprite is only one pixel high diff --git a/keywords.txt b/keywords.txt index 8c97b01c..e7653a18 100644 --- a/keywords.txt +++ b/keywords.txt @@ -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) diff --git a/library.json b/library.json index 8715cbb1..cbc1dea9 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/Makuna/NeoPixelBus" }, - "version": "2.1.0", + "version": "2.1.1", "frameworks": "arduino", "platforms": "*" } diff --git a/library.properties b/library.properties index c8735753..d3f252ee 100644 --- a/library.properties +++ b/library.properties @@ -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. diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h index 8f9857f2..859fc00d 100644 --- a/src/NeoPixelBus.h +++ b/src/NeoPixelBus.h @@ -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" diff --git a/src/internal/NeoPixelBuffer.h b/src/internal/NeoBuffer.h similarity index 97% rename from src/internal/NeoPixelBuffer.h rename to src/internal/NeoBuffer.h index 216e519c..691a9b8b 100644 --- a/src/internal/NeoPixelBuffer.h +++ b/src/internal/NeoBuffer.h @@ -25,10 +25,10 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -template class NeoPixelBuffer +template class NeoBuffer { public: - NeoPixelBuffer(uint16_t width, + NeoBuffer(uint16_t width, uint16_t height, PGM_VOID_P pixels) : _method(width, height, pixels) diff --git a/src/internal/NeoPixelBufferMethods.h b/src/internal/NeoBufferMethods.h similarity index 95% rename from src/internal/NeoPixelBufferMethods.h rename to src/internal/NeoBufferMethods.h index fffdaee3..0c1b2057 100644 --- a/src/internal/NeoPixelBufferMethods.h +++ b/src/internal/NeoBufferMethods.h @@ -40,10 +40,10 @@ typedef std::function LayoutMapCallback; #endif -template class NeoPixelBufferMethod +template 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 @@ template class NeoPixelBufferMethod uint8_t* _pixels; }; -template class NeoPixelBufferProgmemMethod +template 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) diff --git a/src/internal/NeoPixelSpriteSheet.h b/src/internal/NeoSpriteSheet.h similarity index 97% rename from src/internal/NeoPixelSpriteSheet.h rename to src/internal/NeoSpriteSheet.h index fe6c8f37..a0f277eb 100644 --- a/src/internal/NeoPixelSpriteSheet.h +++ b/src/internal/NeoSpriteSheet.h @@ -26,10 +26,10 @@ License along with NeoPixel. If not, see #pragma once -template class NeoPixelVerticalSpriteSheet +template class NeoVerticalSpriteSheet { public: - NeoPixelVerticalSpriteSheet(uint16_t width, + NeoVerticalSpriteSheet(uint16_t width, uint16_t height, uint16_t spriteHeight, PGM_VOID_P pixels) : diff --git a/src/internal/NeoTexture.h b/src/internal/NeoTexture.h deleted file mode 100644 index a304d604..00000000 --- a/src/internal/NeoTexture.h +++ /dev/null @@ -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 -. --------------------------------------------------------------------------*/ -#pragma once - -NOTES: -Where does the data come from? - * Loaded by external routine - - - -template 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(x2) - x1) * progress + x1; - float yf = (static_cast(y2) - y1) * progress + y1; - - uint16_t x = static_cast(xf); // truncates to lower uint - uint16_t y = static_cast(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 RgbTexture; -typedef Texture RgbwTexture; -typedef Texture HtmlTexture; -