From d4dda2dcc484ed97c67efecbc0376af5a49862ff Mon Sep 17 00:00:00 2001 From: Rick164 Date: Thu, 21 Apr 2016 14:51:43 +0200 Subject: [PATCH] AtmoOrb LedDevice now only processes new color commands and skips identical, saves last send color per light id separately in Qmap. (#602) Former-commit-id: 38873e5b718c73d95111abcb10cf148f6a6ab18b --- libsrc/leddevice/LedDeviceAtmoOrb.cpp | 17 +++++++++++++++++ libsrc/leddevice/LedDeviceAtmoOrb.h | 8 ++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.cpp b/libsrc/leddevice/LedDeviceAtmoOrb.cpp index 02ea1b62..8ad5f349 100644 --- a/libsrc/leddevice/LedDeviceAtmoOrb.cpp +++ b/libsrc/leddevice/LedDeviceAtmoOrb.cpp @@ -51,7 +51,18 @@ int LedDeviceAtmoOrb::write(const std::vector &ledValues) { // Iterate through colors and set Orb color // Start off with idx 1 as 0 is reserved for controlling all orbs at once unsigned int idx = 1; + for (const ColorRgb &color : ledValues) { + // Retrieve last send colors + int lastRed = lastColorRedMap[idx]; + int lastGreen = lastColorGreenMap[idx]; + int lastBlue = lastColorBlueMap[idx]; + + // If last colors send are identical than last send return + if(lastRed == color.red && lastGreen == color.green && lastBlue == color.blue) + { + return 0; + } // If color difference is higher than skipSmoothingDiff than we skip Orb smoothing (if enabled) and send it right away if ((skipSmoothingDiff != 0 && useOrbSmoothing) && (abs(color.red - lastRed) >= skipSmoothingDiff || abs(color.blue - lastBlue) >= skipSmoothingDiff || @@ -73,9 +84,15 @@ int LedDeviceAtmoOrb::write(const std::vector &ledValues) { } } + // Store last colors send for light id + lastColorRedMap[idx] = color.red; + lastColorGreenMap[idx] = color.green; + lastColorBlueMap[idx] = color.blue; + // Next light id. idx++; } + return 0; } diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.h b/libsrc/leddevice/LedDeviceAtmoOrb.h index fb3733aa..8c697af2 100644 --- a/libsrc/leddevice/LedDeviceAtmoOrb.h +++ b/libsrc/leddevice/LedDeviceAtmoOrb.h @@ -35,10 +35,10 @@ public: class LedDeviceAtmoOrb : public QObject, public LedDevice { Q_OBJECT public: - // Last color sent - int lastRed; - int lastGreen; - int lastBlue; + // Last send color map + QMap lastColorRedMap; + QMap lastColorGreenMap; + QMap lastColorBlueMap; // Multicast status bool joinedMulticastgroup;