diff --git a/src/NeoPixelAnimator.h b/src/NeoPixelAnimator.h index d990599..b168164 100644 --- a/src/NeoPixelAnimator.h +++ b/src/NeoPixelAnimator.h @@ -27,7 +27,7 @@ License along with NeoPixel. If not, see #pragma once #include -#include "internal/NeoEase.h" +#include "internal/animations/NeoEase.h" enum AnimationState { diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h index c13c053..a3f708a 100644 --- a/src/NeoPixelBus.h +++ b/src/NeoPixelBus.h @@ -33,18 +33,12 @@ const uint8_t NEO_DIRTY = 0x80; // a change was made to pixel data that requires const uint16_t PixelIndex_OutOfBounds = 0xffff; #include "internal/NeoUtil.h" -#include "internal/NeoEase.h" +#include "internal/animations/NeoEase.h" #include "internal/NeoSettings.h" #include "internal/NeoColors.h" #include "internal/NeoColorFeatures.h" #include "internal/NeoTopologies.h" - -#include "internal/NeoBufferContext.h" -#include "internal/NeoBufferMethods.h" -#include "internal/NeoBuffer.h" -#include "internal/NeoSpriteSheet.h" -#include "internal/NeoDib.h" -#include "internal/NeoBitmapFile.h" +#include "internal/NeoBuffers.h" #include "internal/NeoBusChannel.h" diff --git a/src/internal/NeoBuffers.h b/src/internal/NeoBuffers.h new file mode 100644 index 0000000..a3eacc4 --- /dev/null +++ b/src/internal/NeoBuffers.h @@ -0,0 +1,40 @@ +/*------------------------------------------------------------------------- +NeoBuffers includes all the classes that describe pixel buffers + +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 + +#include "buffers/LayoutMapCallback.h" +#include "buffers/NeoShaderNop.h" +#include "buffers/NeoShaderBase.h" +#include "buffers/NeoBufferContext.h" + +#include "buffers/NeoBuffer.h" +#include "buffers/NeoBufferMethods.h" +#include "buffers/NeoBufferProgmemMethod.h" + +#include "buffers/NeoDib.h" +#include "buffers/NeoBitmapFile.h" +#include "buffers/NeoVerticalSpriteSheet.h" + diff --git a/src/internal/NeoEase.h b/src/internal/animations/NeoEase.h similarity index 100% rename from src/internal/NeoEase.h rename to src/internal/animations/NeoEase.h diff --git a/src/internal/NeoPixelAnimator.cpp b/src/internal/animations/NeoPixelAnimator.cpp similarity index 100% rename from src/internal/NeoPixelAnimator.cpp rename to src/internal/animations/NeoPixelAnimator.cpp diff --git a/src/internal/buffers/LayoutMapCallback.h b/src/internal/buffers/LayoutMapCallback.h new file mode 100644 index 0000000..d822f18 --- /dev/null +++ b/src/internal/buffers/LayoutMapCallback.h @@ -0,0 +1,41 @@ +/*------------------------------------------------------------------------- +LayoutMapCallback + +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 + + +#if defined(NEOPIXEBUS_NO_STL) + +typedef uint16_t(*LayoutMapCallback)(int16_t x, int16_t y); + +#else + +#undef max +#undef min +#include +typedef std::function LayoutMapCallback; + +#endif \ No newline at end of file diff --git a/src/internal/NeoBitmapFile.h b/src/internal/buffers/NeoBitmapFile.h similarity index 98% rename from src/internal/NeoBitmapFile.h rename to src/internal/buffers/NeoBitmapFile.h index 467d55d..d66316a 100644 --- a/src/internal/NeoBitmapFile.h +++ b/src/internal/buffers/NeoBitmapFile.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoPixel library +NeoBitmapFile Written by Michael C. Miller. @@ -67,6 +67,9 @@ enum BmpCompression BI_CmykRle4 }; +// T_COLOR_FEATURE - one of the Features +// T_FILE_METHOD - any standard File object following Arduino File methods/members +// template class NeoBitmapFile { public: diff --git a/src/internal/NeoBuffer.h b/src/internal/buffers/NeoBuffer.h similarity index 98% rename from src/internal/NeoBuffer.h rename to src/internal/buffers/NeoBuffer.h index adc439c..c2501c7 100644 --- a/src/internal/NeoBuffer.h +++ b/src/internal/buffers/NeoBuffer.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoPixel library +NeoBuffer Written by Michael C. Miller. @@ -25,6 +25,10 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once +// T_BUFFER_METHOD - one of +// NeoBufferMethod +// NeoBufferProgmemMethod +// template class NeoBuffer { public: diff --git a/src/internal/NeoBufferContext.h b/src/internal/buffers/NeoBufferContext.h similarity index 98% rename from src/internal/NeoBufferContext.h rename to src/internal/buffers/NeoBufferContext.h index 8b57344..d1cb0b8 100644 --- a/src/internal/NeoBufferContext.h +++ b/src/internal/buffers/NeoBufferContext.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoPixel library +NeoBufferContext Written by Michael C. Miller. diff --git a/src/internal/NeoBufferMethods.h b/src/internal/buffers/NeoBufferMethods.h similarity index 60% rename from src/internal/NeoBufferMethods.h rename to src/internal/buffers/NeoBufferMethods.h index 79d354f..169e1ff 100644 --- a/src/internal/NeoBufferMethods.h +++ b/src/internal/buffers/NeoBufferMethods.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoPixel library +NeoBufferMethod Written by Michael C. Miller. @@ -26,20 +26,6 @@ License along with NeoPixel. If not, see #pragma once - -#if defined(NEOPIXEBUS_NO_STL) - -typedef uint16_t(*LayoutMapCallback)(int16_t x, int16_t y); - -#else - -#undef max -#undef min -#include -typedef std::function LayoutMapCallback; - -#endif - template class NeoBufferMethod { public: @@ -162,102 +148,5 @@ private: uint8_t* _pixels; }; -template class NeoBufferProgmemMethod -{ -public: - NeoBufferProgmemMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels) : - _width(width), - _height(height), - _pixels(pixels) - { - } - operator NeoBufferContext() - { - return NeoBufferContext(Pixels(), PixelsSize()); - } - - uint8_t* Pixels() const - { - return (uint8_t*)_pixels; - }; - - size_t PixelsSize() const - { - return PixelSize() * PixelCount(); - }; - - size_t PixelSize() const - { - return T_COLOR_FEATURE::PixelSize; - }; - - uint16_t PixelCount() const - { - return _width * _height; - }; - - uint16_t Width() const - { - return _width; - }; - - uint16_t Height() const - { - return _height; - }; - - void SetPixelColor(uint16_t indexPixel, typename T_COLOR_FEATURE::ColorObject color) - { - // PROGMEM is read only, this will do nothing - }; - - void SetPixelColor(uint16_t x, uint16_t y, typename T_COLOR_FEATURE::ColorObject color) - { - // PROGMEM is read only, this will do nothing - }; - - typename T_COLOR_FEATURE::ColorObject GetPixelColor(uint16_t indexPixel) const - { - if (indexPixel >= PixelCount()) - { - // Pixel # is out of bounds, this will get converted to a - // color object type initialized to 0 (black) - return 0; - } - - return T_COLOR_FEATURE::retrievePixelColor_P(_pixels, indexPixel); - }; - - typename T_COLOR_FEATURE::ColorObject GetPixelColor(int16_t x, int16_t y) const - { - if (x < 0 || x >= _width || y < 0 || y >= _height) - { - // Pixel # is out of bounds, this will get converted to a - // color object type initialized to 0 (black) - return 0; - } - - uint16_t indexPixel = x + y * _width; - return T_COLOR_FEATURE::retrievePixelColor_P(_pixels, indexPixel); - }; - - void ClearTo(typename T_COLOR_FEATURE::ColorObject color) - { - // PROGMEM is read only, this will do nothing - }; - - void CopyPixels(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - T_COLOR_FEATURE::movePixelsInc_P(pPixelDest, pPixelSrc, count); - } - - typedef typename T_COLOR_FEATURE::ColorObject ColorObject; - typedef T_COLOR_FEATURE ColorFeature; - -private: - const uint16_t _width; - const uint16_t _height; - PGM_VOID_P _pixels; -}; diff --git a/src/internal/buffers/NeoBufferProgmemMethod.h b/src/internal/buffers/NeoBufferProgmemMethod.h new file mode 100644 index 0000000..c46848b --- /dev/null +++ b/src/internal/buffers/NeoBufferProgmemMethod.h @@ -0,0 +1,126 @@ +/*------------------------------------------------------------------------- +NeoBufferProgmemMethod + +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 + +template class NeoBufferProgmemMethod +{ +public: + NeoBufferProgmemMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels) : + _width(width), + _height(height), + _pixels(pixels) + { + } + + operator NeoBufferContext() + { + return NeoBufferContext(Pixels(), PixelsSize()); + } + + uint8_t* Pixels() const + { + return (uint8_t*)_pixels; + }; + + size_t PixelsSize() const + { + return PixelSize() * PixelCount(); + }; + + size_t PixelSize() const + { + return T_COLOR_FEATURE::PixelSize; + }; + + uint16_t PixelCount() const + { + return _width * _height; + }; + + uint16_t Width() const + { + return _width; + }; + + uint16_t Height() const + { + return _height; + }; + + void SetPixelColor(uint16_t indexPixel, typename T_COLOR_FEATURE::ColorObject color) + { + // PROGMEM is read only, this will do nothing + }; + + void SetPixelColor(uint16_t x, uint16_t y, typename T_COLOR_FEATURE::ColorObject color) + { + // PROGMEM is read only, this will do nothing + }; + + typename T_COLOR_FEATURE::ColorObject GetPixelColor(uint16_t indexPixel) const + { + if (indexPixel >= PixelCount()) + { + // Pixel # is out of bounds, this will get converted to a + // color object type initialized to 0 (black) + return 0; + } + + return T_COLOR_FEATURE::retrievePixelColor_P(_pixels, indexPixel); + }; + + typename T_COLOR_FEATURE::ColorObject GetPixelColor(int16_t x, int16_t y) const + { + if (x < 0 || x >= _width || y < 0 || y >= _height) + { + // Pixel # is out of bounds, this will get converted to a + // color object type initialized to 0 (black) + return 0; + } + + uint16_t indexPixel = x + y * _width; + return T_COLOR_FEATURE::retrievePixelColor_P(_pixels, indexPixel); + }; + + void ClearTo(typename T_COLOR_FEATURE::ColorObject color) + { + // PROGMEM is read only, this will do nothing + }; + + void CopyPixels(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + T_COLOR_FEATURE::movePixelsInc_P(pPixelDest, pPixelSrc, count); + } + + typedef typename T_COLOR_FEATURE::ColorObject ColorObject; + typedef T_COLOR_FEATURE ColorFeature; + +private: + const uint16_t _width; + const uint16_t _height; + PGM_VOID_P _pixels; +}; \ No newline at end of file diff --git a/src/internal/NeoDib.h b/src/internal/buffers/NeoDib.h similarity index 85% rename from src/internal/NeoDib.h rename to src/internal/buffers/NeoDib.h index 9ede9b1..f3d162f 100644 --- a/src/internal/NeoDib.h +++ b/src/internal/buffers/NeoDib.h @@ -1,5 +1,6 @@ /*------------------------------------------------------------------------- -NeoPixel library +NeoDib - Device Independant Bitmap, interal data stored in RGB/RGBW format +rather than the ColorFeature format Written by Michael C. Miller. @@ -25,59 +26,14 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -template class NeoShaderNop -{ -public: - NeoShaderNop() - { - } - - bool IsDirty() const - { - return true; - }; - - void Dirty() - { - }; - - void ResetDirty() - { - }; - - T_COLOR_OBJECT Apply(uint16_t, T_COLOR_OBJECT color) - { - return color; - }; -}; - -class NeoShaderBase -{ -public: - NeoShaderBase() : - _state(0) - { - } - - bool IsDirty() const - { - return (_state & NEO_DIRTY); - }; - - void Dirty() - { - _state |= NEO_DIRTY; - }; - - void ResetDirty() - { - _state &= ~NEO_DIRTY; - }; - -protected: - uint8_t _state; // internal state -}; - +// T_COLOR_OBJECT - one of the color objects +// RgbColor +// RgbwColor +// Rgb16Color +// Rgb48Color +// Rgbw64Color +// SevenSegDigit +// template class NeoDib { public: diff --git a/src/internal/buffers/NeoShaderBase.h b/src/internal/buffers/NeoShaderBase.h new file mode 100644 index 0000000..399c6f9 --- /dev/null +++ b/src/internal/buffers/NeoShaderBase.h @@ -0,0 +1,53 @@ +/*------------------------------------------------------------------------- +NeoShaderBase + +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 + +class NeoShaderBase +{ +public: + NeoShaderBase() : + _state(0) + { + } + + bool IsDirty() const + { + return (_state & NEO_DIRTY); + }; + + void Dirty() + { + _state |= NEO_DIRTY; + }; + + void ResetDirty() + { + _state &= ~NEO_DIRTY; + }; + +protected: + uint8_t _state; // internal state +}; \ No newline at end of file diff --git a/src/internal/buffers/NeoShaderNop.h b/src/internal/buffers/NeoShaderNop.h new file mode 100644 index 0000000..c7ca2e0 --- /dev/null +++ b/src/internal/buffers/NeoShaderNop.h @@ -0,0 +1,53 @@ +/*------------------------------------------------------------------------- +NeoShaderNop + +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 + +template class NeoShaderNop +{ +public: + NeoShaderNop() + { + } + + bool IsDirty() const + { + return true; + }; + + void Dirty() + { + }; + + void ResetDirty() + { + }; + + T_COLOR_OBJECT Apply(uint16_t, T_COLOR_OBJECT color) + { + return color; + }; +}; + diff --git a/src/internal/NeoSpriteSheet.h b/src/internal/buffers/NeoVerticalSpriteSheet.h similarity index 97% rename from src/internal/NeoSpriteSheet.h rename to src/internal/buffers/NeoVerticalSpriteSheet.h index 73fdde3..bc1885f 100644 --- a/src/internal/NeoSpriteSheet.h +++ b/src/internal/buffers/NeoVerticalSpriteSheet.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoPixel library +NeoVerticalSpriteSheet Written by Michael C. Miller. @@ -25,7 +25,10 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once - +// T_BUFFER_METHOD - one of +// NeoBufferMethod +// NeoBufferProgmemMethod +// template class NeoVerticalSpriteSheet { public: