Smoothing Fix (#261)

Increase color change for small RGB differences.
This commit is contained in:
Robin Kobus 2016-10-04 22:13:29 +02:00 committed by redPanther
parent 89afedf3d5
commit 3156488b68
2 changed files with 16 additions and 8 deletions

View File

@ -91,15 +91,21 @@ void LinearColorSmoothing::updateLeds()
_writeToLedsEnable = true; _writeToLedsEnable = true;
float k = 1.0f - 1.0f * deltaTime / (_targetTime - _previousTime); float k = 1.0f - 1.0f * deltaTime / (_targetTime - _previousTime);
for (size_t i = 0; i < _previousValues.size(); ++i) int reddif = 0, greendif = 0, bluedif = 0;
{
ColorRgb & prev = _previousValues[i];
ColorRgb & target = _targetValues[i];
prev.red += k * (target.red - prev.red); for (size_t i = 0; i < _previousValues.size(); ++i)
prev.green += k * (target.green - prev.green); {
prev.blue += k * (target.blue - prev.blue); ColorRgb & prev = _previousValues[i];
} ColorRgb & target = _targetValues[i];
reddif = target.red - prev.red;
greendif = target.green - prev.green;
bluedif = target.blue - prev.blue;
prev.red += (reddif < 0 ? -1:1) * ceil(k * abs(reddif));
prev.green += (greendif < 0 ? -1:1) * ceil(k * abs(greendif));
prev.blue += (bluedif < 0 ? -1:1) * ceil(k * abs(bluedif));
}
_previousTime = now; _previousTime = now;
queueColors(_previousValues); queueColors(_previousValues);

View File

@ -3,6 +3,8 @@
// STL includes // STL includes
#include <string> #include <string>
#include <vector> #include <vector>
#include <stdlib.h>
#include <math.h>
// Qt includes // Qt includes
#include <QTimer> #include <QTimer>