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,14 +91,20 @@ void LinearColorSmoothing::updateLeds()
_writeToLedsEnable = true;
float k = 1.0f - 1.0f * deltaTime / (_targetTime - _previousTime);
int reddif = 0, greendif = 0, bluedif = 0;
for (size_t i = 0; i < _previousValues.size(); ++i)
{
ColorRgb & prev = _previousValues[i];
ColorRgb & target = _targetValues[i];
prev.red += k * (target.red - prev.red);
prev.green += k * (target.green - prev.green);
prev.blue += k * (target.blue - prev.blue);
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;

View File

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