mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
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
This commit is contained in:
parent
0d8c4ac5fb
commit
fdb164da0a
@ -8,6 +8,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QTime>
|
||||
|
||||
//#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <set>
|
||||
@ -44,16 +45,11 @@ int LedDeviceAtmoOrb::write(const std::vector<ColorRgb> & 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,22 +59,23 @@ int LedDeviceAtmoOrb::write(const std::vector<ColorRgb> & 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);
|
||||
|
||||
|
@ -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
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user