mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Leddevice refactoring the next next part (#263)
* switch rs232 provider to completly async transfer * start of implementing a seperate init function for leddevices * rename setconfig to init * more fixes * implement missing code * fix code style * remove debug code * remove debug stuff * set loglevel to original state
This commit is contained in:
@@ -460,7 +460,6 @@ LedString Hyperion::createLedString(const QJsonValue& ledsConfig, const ColorOrd
|
||||
}
|
||||
|
||||
// Get the order of the rgb channels for this led (default is device order)
|
||||
const QJsonObject& colorOrder = ledConfigArray[i].toObject();
|
||||
led.colorOrder = stringToColorOrder(index["colorOrder"].toString(deviceOrderStr));
|
||||
ledString.leds().push_back(led);
|
||||
}
|
||||
@@ -674,7 +673,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const QJsonObject &qjsonConfig
|
||||
getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, _messageForwarder->forwardingEnabled());
|
||||
|
||||
// initialize leddevices
|
||||
_device = LedDeviceFactory::construct(jsonConfig["device"]);
|
||||
_device = LedDeviceFactory::construct(jsonConfig["device"],_hwLedCount);
|
||||
_deviceSmooth = createColorSmoothing(qjsonConfig["smoothing"].toObject(), _device);
|
||||
getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, _deviceSmooth->componentState());
|
||||
|
||||
@@ -968,7 +967,7 @@ void Hyperion::update()
|
||||
if (_adjustmentEnabled) _raw2ledAdjustment->applyAdjustment(_ledBuffer);
|
||||
if (_temperatureEnabled) _raw2ledTemperature->applyCorrection(_ledBuffer);
|
||||
|
||||
// init colororder vector, if nempty
|
||||
// init colororder vector, if empty
|
||||
if (_ledStringColorOrder.empty())
|
||||
{
|
||||
for (Led& led : _ledString.leds())
|
||||
|
@@ -4,6 +4,8 @@
|
||||
#include "LinearColorSmoothing.h"
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
LinearColorSmoothing::LinearColorSmoothing( LedDevice * ledDevice, double ledUpdateFrequency_hz, int settlingTime_ms, unsigned updateDelay, bool continuousOutput)
|
||||
@@ -91,21 +93,21 @@ void LinearColorSmoothing::updateLeds()
|
||||
_writeToLedsEnable = true;
|
||||
float k = 1.0f - 1.0f * deltaTime / (_targetTime - _previousTime);
|
||||
|
||||
int reddif = 0, greendif = 0, bluedif = 0;
|
||||
int reddif = 0, greendif = 0, bluedif = 0;
|
||||
|
||||
for (size_t i = 0; i < _previousValues.size(); ++i)
|
||||
{
|
||||
ColorRgb & prev = _previousValues[i];
|
||||
ColorRgb & target = _targetValues[i];
|
||||
for (size_t i = 0; i < _previousValues.size(); ++i)
|
||||
{
|
||||
ColorRgb & prev = _previousValues[i];
|
||||
ColorRgb & target = _targetValues[i];
|
||||
|
||||
reddif = target.red - prev.red;
|
||||
greendif = target.green - prev.green;
|
||||
bluedif = 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));
|
||||
}
|
||||
prev.red += (reddif < 0 ? -1:1) * std::ceil(k * std::abs(reddif));
|
||||
prev.green += (greendif < 0 ? -1:1) * std::ceil(k * std::abs(greendif));
|
||||
prev.blue += (bluedif < 0 ? -1:1) * std::ceil(k * std::abs(bluedif));
|
||||
}
|
||||
_previousTime = now;
|
||||
|
||||
queueColors(_previousValues);
|
||||
|
@@ -3,8 +3,7 @@
|
||||
// STL includes
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
// Qt includes
|
||||
#include <QTimer>
|
||||
|
Reference in New Issue
Block a user