From fdb164da0a2d1e9e2a9f477f0cee26648ebc7e7c Mon Sep 17 00:00:00 2001 From: RickDB Date: Mon, 14 Mar 2016 23:19:20 +0100 Subject: [PATCH] Added multi Orb support, Orb ID should match that of leds index with a +1 offset (index 0 = Orb id 1 etc..) Code cleanup. Former-commit-id: af8a6df876f334c9a65b1a936b5bb85b380d86d1 --- libsrc/leddevice/LedDeviceAtmoOrb.cpp | 34 ++++++++++++--------------- libsrc/leddevice/LedDeviceAtmoOrb.h | 2 +- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.cpp b/libsrc/leddevice/LedDeviceAtmoOrb.cpp index 869cc932..901ce2d8 100644 --- a/libsrc/leddevice/LedDeviceAtmoOrb.cpp +++ b/libsrc/leddevice/LedDeviceAtmoOrb.cpp @@ -8,6 +8,7 @@ #include #include +//#include #include #include #include @@ -44,16 +45,11 @@ int LedDeviceAtmoOrb::write(const std::vector & ledValues) { return 0; } - // Iterate through colors and set Orb color. - unsigned int idx = 0; + // 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) { - // If color is identical skip color setter - if(color.red == lastRed && color.green == lastGreen && color.blue == lastBlue) - { - continue; - } - // Options parameter: // // 1 = force off @@ -63,23 +59,24 @@ int LedDeviceAtmoOrb::write(const std::vector & ledValues) { if (switchOffOnBlack && color.red == 0 && color.green == 0 && color.blue == 0) { // Force to black - for (int i = 0; i < orbIds.size(); i++) { - setColor(orbIds[i], color, 1); + for (unsigned int i = 0; i < orbIds.size(); i++) { + if (orbIds[i] == idx) + { + setColor(idx, color, 1); + } } } else { // Default send color - for (int i = 0; i < orbIds.size(); i++) { - setColor(orbIds[i], color, 4); + for (unsigned int i = 0; i < orbIds.size(); i++) { + if (orbIds[i] == idx) + { + setColor(idx, color, 4); + } } } - // Store current colors - lastRed = color.red; - lastGreen = color.green; - lastBlue = color.blue; - // Next light id. idx++; } @@ -118,8 +115,7 @@ void LedDeviceAtmoOrb::sendCommand(const QByteArray & bytes) { int LedDeviceAtmoOrb::switchOff() { // Default send color - for (int i = 0; i < orbIds.size(); i++) { - + for (unsigned int i = 0; i < orbIds.size(); i++) { QByteArray bytes; bytes.resize(5 + numLeds * 3); diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.h b/libsrc/leddevice/LedDeviceAtmoOrb.h index 794600cd..0517ff0f 100644 --- a/libsrc/leddevice/LedDeviceAtmoOrb.h +++ b/libsrc/leddevice/LedDeviceAtmoOrb.h @@ -52,7 +52,7 @@ public: /// /// @param output is the multicast address of Orbs /// - /// @param switchOffOnBlack kill lights for black (default: false) + /// @param switchOffOnBlack turn off Orbs on black (default: false) /// /// @param transitiontime is optional and not used at the moment ///