From af2cf886a2e155f6940695a1bd9ed9b9f4b2f533 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 15 Apr 2024 14:45:00 -0700 Subject: [PATCH] segment example use of NeoDib --- src/internal/buffers/NeoBuffer.h | 11 +++++++---- src/internal/buffers/NeoBufferMethods.h | 18 ++++++++++++++++++ src/internal/colors/SegmentDigit.cpp | 1 + src/internal/colors/SegmentDigit.h | 6 +++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/internal/buffers/NeoBuffer.h b/src/internal/buffers/NeoBuffer.h index 7f34bca..ada90d6 100644 --- a/src/internal/buffers/NeoBuffer.h +++ b/src/internal/buffers/NeoBuffer.h @@ -157,7 +157,9 @@ public: } template - void Render(NeoBufferContext destBuffer, T_SHADER& shader, uint16_t startIndex = 0) + void Render(NeoBufferContext destBuffer, + T_SHADER& shader, + uint16_t startIndex = 0) { uint16_t countPixels = destBuffer.PixelCount; @@ -175,7 +177,7 @@ public: template void Render(NeoBufferContext destBuffer, - NeoBufferContext srcBufferB, + const NeoBuffer& srcBufferB, T_SHADER& shader, uint16_t startIndex = 0) { @@ -189,7 +191,8 @@ public: for (uint16_t indexPixel = 0; indexPixel < countPixels; indexPixel++) { typename T_BUFFER_METHOD::ColorObject color = _method.GetPixelColor(indexPixel); - destBuffer.Pixels[indexPixel + startIndex] = shader.Apply(color, srcBufferB.Pixels[indexPixel]); + typename T_BUFFER_METHOD::ColorObject colorB = srcBufferB.GetPixelColor(indexPixel); + destBuffer.Pixels[indexPixel + startIndex] = shader.Apply(color, colorB); } } @@ -209,7 +212,7 @@ public: return result; } -private: +protected: T_BUFFER_METHOD _method; }; diff --git a/src/internal/buffers/NeoBufferMethods.h b/src/internal/buffers/NeoBufferMethods.h index 2f91a04..b22eaaa 100644 --- a/src/internal/buffers/NeoBufferMethods.h +++ b/src/internal/buffers/NeoBufferMethods.h @@ -54,6 +54,24 @@ public: _pixels = nullptr; } + NeoBufferMethod& operator=(const NeoBufferMethod& other) + { + uint16_t pixelCount = PixelCount(); + uint16_t pixelCountOther = other.PixelCount(); + + if (pixelCount > pixelCountOther) + { + pixelCount = pixelCountOther; + } + + for (size_t index = 0; index < pixelCount; index++) + { + _pixels[index] = other._pixels[index]; + } + + return *this; + } + operator NeoBufferContext() { return NeoBufferContext(Pixels(), PixelCount()); diff --git a/src/internal/colors/SegmentDigit.cpp b/src/internal/colors/SegmentDigit.cpp index ddc535b..63eef4e 100644 --- a/src/internal/colors/SegmentDigit.cpp +++ b/src/internal/colors/SegmentDigit.cpp @@ -25,6 +25,7 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #include +#include "RgbColorBase.h" #include "SegmentDigit.h" // diff --git a/src/internal/colors/SegmentDigit.h b/src/internal/colors/SegmentDigit.h index 5a63c44..2b9d50d 100644 --- a/src/internal/colors/SegmentDigit.h +++ b/src/internal/colors/SegmentDigit.h @@ -63,7 +63,7 @@ public: // ending at the decimal point // "abcdefg." // ------------------------------------------------------------------------ -struct SevenSegDigit +struct SevenSegDigit : RgbColorBase { typedef uint8_t ElementType; typedef NeoSevenSegCurrentSettings SettingsObject; @@ -191,6 +191,10 @@ struct SevenSegDigit // ------------------------------------------------------------------------ static SevenSegDigit LinearBlend(const SevenSegDigit& left, const SevenSegDigit& right, uint8_t progress); + static SevenSegDigit PgmRead(PGM_VOID_P pPixelSrc) + { + return _PgmReadByBytes(pPixelSrc); + } uint32_t CalcTotalTenthMilliAmpere(const SettingsObject& settings) {