From 4959a386f76139396653bdb63e5305225ffc3356 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 16 Aug 2018 12:49:53 -0700 Subject: [PATCH] SwapPixelColor (#221) --- keywords.txt | 1 + src/NeoPixelBus.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/keywords.txt b/keywords.txt index 33587b5..4afc0e1 100644 --- a/keywords.txt +++ b/keywords.txt @@ -105,6 +105,7 @@ PixelsSize KEYWORD2 PixelCount KEYWORD2 SetPixelColor KEYWORD2 GetPixelColor KEYWORD2 +SwapPixelColor KEYWORD2 CalculateBrightness KEYWORD2 Darken KEYWORD2 Lighten KEYWORD2 diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h index eaf88c6..25f9b81 100644 --- a/src/NeoPixelBus.h +++ b/src/NeoPixelBus.h @@ -322,7 +322,14 @@ public: } } + void SwapPixelColor(uint16_t indexPixelOne, uint16_t indexPixelTwo) + { + auto colorOne = GetPixelColor(indexPixelOne); + auto colorTwo = GetPixelColor(indexPixelTwo); + SetPixelColor(indexPixelOne, colorTwo); + SetPixelColor(indexPixelTwo, colorOne); + }; protected: const uint16_t _countPixels; // Number of RGB LEDs in strip