mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
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
This commit is contained in:
parent
e318c9ab19
commit
d4dda2dcc4
@ -51,7 +51,18 @@ int LedDeviceAtmoOrb::write(const std::vector <ColorRgb> &ledValues) {
|
|||||||
// Iterate through colors and set Orb color
|
// Iterate through colors and set Orb color
|
||||||
// Start off with idx 1 as 0 is reserved for controlling all orbs at once
|
// Start off with idx 1 as 0 is reserved for controlling all orbs at once
|
||||||
unsigned int idx = 1;
|
unsigned int idx = 1;
|
||||||
|
|
||||||
for (const ColorRgb &color : ledValues) {
|
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 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 ||
|
if ((skipSmoothingDiff != 0 && useOrbSmoothing) && (abs(color.red - lastRed) >= skipSmoothingDiff || abs(color.blue - lastBlue) >= skipSmoothingDiff ||
|
||||||
@ -73,9 +84,15 @@ int LedDeviceAtmoOrb::write(const std::vector <ColorRgb> &ledValues) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store last colors send for light id
|
||||||
|
lastColorRedMap[idx] = color.red;
|
||||||
|
lastColorGreenMap[idx] = color.green;
|
||||||
|
lastColorBlueMap[idx] = color.blue;
|
||||||
|
|
||||||
// Next light id.
|
// Next light id.
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ public:
|
|||||||
class LedDeviceAtmoOrb : public QObject, public LedDevice {
|
class LedDeviceAtmoOrb : public QObject, public LedDevice {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
// Last color sent
|
// Last send color map
|
||||||
int lastRed;
|
QMap<int, int> lastColorRedMap;
|
||||||
int lastGreen;
|
QMap<int, int> lastColorGreenMap;
|
||||||
int lastBlue;
|
QMap<int, int> lastColorBlueMap;
|
||||||
|
|
||||||
// Multicast status
|
// Multicast status
|
||||||
bool joinedMulticastgroup;
|
bool joinedMulticastgroup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user