mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fix non image updates ignore blacklisted leds (#1635)
* Fix #1634 * Refactor to process blacklisted LEDs with less resources
This commit is contained in:
parent
d1879c2e39
commit
a5bb7e905b
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
// QT includes
|
// QT includes
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QJsonArray>
|
||||||
|
|
||||||
// Forward class declarations
|
// Forward class declarations
|
||||||
namespace Json { class Value; }
|
namespace Json { class Value; }
|
||||||
@ -73,7 +74,7 @@ inline ColorOrder stringToColorOrder(const QString & order)
|
|||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The Led structure contains the definition of the image portion used to determine a single led's
|
/// The Led structure contains the definition of the image portion used to determine a single LED's
|
||||||
/// color.
|
/// color.
|
||||||
/// @verbatim
|
/// @verbatim
|
||||||
/// |--------------------image--|
|
/// |--------------------image--|
|
||||||
@ -89,39 +90,66 @@ inline ColorOrder stringToColorOrder(const QString & order)
|
|||||||
///
|
///
|
||||||
struct Led
|
struct Led
|
||||||
{
|
{
|
||||||
/// The minimum vertical scan line included for this leds color
|
/// The minimum vertical scan line included for this LEDs color
|
||||||
double minX_frac;
|
double minX_frac;
|
||||||
/// The maximum vertical scan line included for this leds color
|
/// The maximum vertical scan line included for this LEDs color
|
||||||
double maxX_frac;
|
double maxX_frac;
|
||||||
/// The minimum horizontal scan line included for this leds color
|
/// The minimum horizontal scan line included for this LEDs color
|
||||||
double minY_frac;
|
double minY_frac;
|
||||||
/// The maximum horizontal scan line included for this leds color
|
/// The maximum horizontal scan line included for this LEDs color
|
||||||
double maxY_frac;
|
double maxY_frac;
|
||||||
|
/// A LEDs at {0,0,0,0} is not visible and therefore treated as blacklisted
|
||||||
|
bool isBlacklisted {false};
|
||||||
/// the color order
|
/// the color order
|
||||||
ColorOrder colorOrder;
|
ColorOrder colorOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The LedString contains the image integration information of the leds
|
/// The LedString contains the image integration information of the LEDs
|
||||||
///
|
///
|
||||||
class LedString
|
class LedString
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
/// Returns the led specifications
|
/// Returns the LED specifications
|
||||||
///
|
///
|
||||||
/// @return The list with led specifications
|
/// @return The list with led specifications
|
||||||
///
|
///
|
||||||
std::vector<Led>& leds();
|
std::vector<Led>& leds();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the led specifications
|
/// Returns the LED specifications
|
||||||
///
|
///
|
||||||
/// @return The list with led specifications
|
/// @return The list with led specifications
|
||||||
///
|
///
|
||||||
const std::vector<Led>& leds() const;
|
const std::vector<Led>& leds() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the IDs of blacklisted LEDs
|
||||||
|
///
|
||||||
|
/// @return ID List of blacklisted LEDs
|
||||||
|
///
|
||||||
|
std::vector<int>& blacklistedLedIds();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the IDs of blacklisted LEDs
|
||||||
|
///
|
||||||
|
/// @return ID List of blacklisted LEDs
|
||||||
|
///
|
||||||
|
const std::vector<int>& blacklistedLedIds() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Check, if teh layout has blacklisted LEDs configured
|
||||||
|
///
|
||||||
|
/// @return True, if blacklisted LEDs are configured
|
||||||
|
///
|
||||||
|
bool hasBlackListedLeds ();
|
||||||
|
|
||||||
|
static LedString createLedString(const QJsonArray& ledConfigArray, const ColorOrder deviceOrder);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The list with led specifications
|
/// The list with LED specifications
|
||||||
std::vector<Led> mLeds;
|
std::vector<Led> _leds;
|
||||||
|
/// The list containing IDs of blacklisted LED
|
||||||
|
std::vector<int> _blacklistedLedIds;
|
||||||
};
|
};
|
||||||
|
@ -177,44 +177,6 @@ namespace hyperion {
|
|||||||
return adjustment;
|
return adjustment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the 'led-string' with the integration area definition per led and the color
|
|
||||||
* ordering of the RGB channels
|
|
||||||
* @param ledsConfig The configuration of the led areas
|
|
||||||
* @param deviceOrder The default RGB channel ordering
|
|
||||||
* @return The constructed ledstring
|
|
||||||
*/
|
|
||||||
static LedString createLedString(const QJsonArray& ledConfigArray, const ColorOrder deviceOrder)
|
|
||||||
{
|
|
||||||
LedString ledString;
|
|
||||||
const QString deviceOrderStr = colorOrderToString(deviceOrder);
|
|
||||||
|
|
||||||
for (signed i = 0; i < ledConfigArray.size(); ++i)
|
|
||||||
{
|
|
||||||
const QJsonObject& ledConfig = ledConfigArray[i].toObject();
|
|
||||||
Led led;
|
|
||||||
|
|
||||||
led.minX_frac = qMax(0.0, qMin(1.0, ledConfig["hmin"].toDouble()));
|
|
||||||
led.maxX_frac = qMax(0.0, qMin(1.0, ledConfig["hmax"].toDouble()));
|
|
||||||
led.minY_frac = qMax(0.0, qMin(1.0, ledConfig["vmin"].toDouble()));
|
|
||||||
led.maxY_frac = qMax(0.0, qMin(1.0, ledConfig["vmax"].toDouble()));
|
|
||||||
// Fix if the user swapped min and max
|
|
||||||
if (led.minX_frac > led.maxX_frac)
|
|
||||||
{
|
|
||||||
std::swap(led.minX_frac, led.maxX_frac);
|
|
||||||
}
|
|
||||||
if (led.minY_frac > led.maxY_frac)
|
|
||||||
{
|
|
||||||
std::swap(led.minY_frac, led.maxY_frac);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the order of the rgb channels for this led (default is device order)
|
|
||||||
led.colorOrder = stringToColorOrder(ledConfig["colorOrder"].toString(deviceOrderStr));
|
|
||||||
ledString.leds().push_back(led);
|
|
||||||
}
|
|
||||||
return ledString;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QSize getLedLayoutGridSize(const QJsonArray& ledConfigArray)
|
static QSize getLedLayoutGridSize(const QJsonArray& ledConfigArray)
|
||||||
{
|
{
|
||||||
std::vector<int> midPointsX;
|
std::vector<int> midPointsX;
|
||||||
|
@ -52,7 +52,7 @@ Hyperion::Hyperion(quint8 instance, bool readonlyMode)
|
|||||||
, _instIndex(instance)
|
, _instIndex(instance)
|
||||||
, _settingsManager(new SettingsManager(instance, this, readonlyMode))
|
, _settingsManager(new SettingsManager(instance, this, readonlyMode))
|
||||||
, _componentRegister(nullptr)
|
, _componentRegister(nullptr)
|
||||||
, _ledString(hyperion::createLedString(getSetting(settings::LEDS).array(), hyperion::createColorOrder(getSetting(settings::DEVICE).object())))
|
, _ledString(LedString::createLedString(getSetting(settings::LEDS).array(), hyperion::createColorOrder(getSetting(settings::DEVICE).object())))
|
||||||
, _imageProcessor(nullptr)
|
, _imageProcessor(nullptr)
|
||||||
, _muxer(nullptr)
|
, _muxer(nullptr)
|
||||||
, _raw2ledAdjustment(hyperion::createLedColorsAdjustment(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object()))
|
, _raw2ledAdjustment(hyperion::createLedColorsAdjustment(static_cast<int>(_ledString.leds().size()), getSetting(settings::COLOR).object()))
|
||||||
@ -255,7 +255,7 @@ void Hyperion::handleSettingsUpdate(settings::type type, const QJsonDocument& co
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ledstring, img processor, muxer, ledGridSize (effect-engine image based effects), _ledBuffer and ByteOrder of ledstring
|
// ledstring, img processor, muxer, ledGridSize (effect-engine image based effects), _ledBuffer and ByteOrder of ledstring
|
||||||
_ledString = hyperion::createLedString(leds, hyperion::createColorOrder(getSetting(settings::DEVICE).object()));
|
_ledString = LedString::createLedString(leds, hyperion::createColorOrder(getSetting(settings::DEVICE).object()));
|
||||||
_imageProcessor->setLedString(_ledString);
|
_imageProcessor->setLedString(_ledString);
|
||||||
_muxer->updateLedColorsLength(static_cast<int>(_ledString.leds().size()));
|
_muxer->updateLedColorsLength(static_cast<int>(_ledString.leds().size()));
|
||||||
_ledGridSize = hyperion::getLedLayoutGridSize(leds);
|
_ledGridSize = hyperion::getLedLayoutGridSize(leds);
|
||||||
@ -291,7 +291,7 @@ void Hyperion::handleSettingsUpdate(settings::type type, const QJsonDocument& co
|
|||||||
// force ledString update, if device ByteOrder changed
|
// force ledString update, if device ByteOrder changed
|
||||||
if(_ledDeviceWrapper->getColorOrder() != dev["colorOrder"].toString("rgb"))
|
if(_ledDeviceWrapper->getColorOrder() != dev["colorOrder"].toString("rgb"))
|
||||||
{
|
{
|
||||||
_ledString = hyperion::createLedString(getSetting(settings::LEDS).array(), hyperion::createColorOrder(dev));
|
_ledString = LedString::createLedString(getSetting(settings::LEDS).array(), hyperion::createColorOrder(dev));
|
||||||
_imageProcessor->setLedString(_ledString);
|
_imageProcessor->setLedString(_ledString);
|
||||||
|
|
||||||
_ledStringColorOrder.clear();
|
_ledStringColorOrder.clear();
|
||||||
@ -671,6 +671,18 @@ void Hyperion::update()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_ledBuffer = priorityInfo.ledColors;
|
_ledBuffer = priorityInfo.ledColors;
|
||||||
|
|
||||||
|
if (_ledString.hasBlackListedLeds())
|
||||||
|
{
|
||||||
|
for (int id : _ledString.blacklistedLedIds())
|
||||||
|
{
|
||||||
|
if (id > _ledBuffer.size()-1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_ledBuffer.at(id) = ColorRgb::BLACK;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit rawLedColors before transform
|
// emit rawLedColors before transform
|
||||||
|
@ -1,16 +1,92 @@
|
|||||||
// STL includes
|
// STL includes
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// hyperion includes
|
// hyperion includes
|
||||||
#include <hyperion/LedString.h>
|
#include <hyperion/LedString.h>
|
||||||
|
|
||||||
|
// QT includes
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
std::vector<Led>& LedString::leds()
|
std::vector<Led>& LedString::leds()
|
||||||
{
|
{
|
||||||
return mLeds;
|
return _leds;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Led>& LedString::leds() const
|
const std::vector<Led>& LedString::leds() const
|
||||||
{
|
{
|
||||||
return mLeds;
|
return _leds;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int>& LedString::blacklistedLedIds()
|
||||||
|
{
|
||||||
|
return _blacklistedLedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<int>& LedString::blacklistedLedIds() const
|
||||||
|
{
|
||||||
|
return _blacklistedLedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LedString::hasBlackListedLeds()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (_blacklistedLedIds.size() > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the 'led-string' with the integration area definition per led and the color
|
||||||
|
* ordering of the RGB channels
|
||||||
|
* @param ledsConfig The configuration of the led areas
|
||||||
|
* @param deviceOrder The default RGB channel ordering
|
||||||
|
* @return The constructed ledstring
|
||||||
|
*/
|
||||||
|
LedString LedString::createLedString(const QJsonArray& ledConfigArray, const ColorOrder deviceOrder)
|
||||||
|
{
|
||||||
|
LedString ledString;
|
||||||
|
const QString deviceOrderStr = colorOrderToString(deviceOrder);
|
||||||
|
|
||||||
|
for (signed i = 0; i < ledConfigArray.size(); ++i)
|
||||||
|
{
|
||||||
|
const QJsonObject& ledConfig = ledConfigArray[i].toObject();
|
||||||
|
Led led;
|
||||||
|
|
||||||
|
led.minX_frac = qMax(0.0, qMin(1.0, ledConfig["hmin"].toDouble()));
|
||||||
|
led.maxX_frac = qMax(0.0, qMin(1.0, ledConfig["hmax"].toDouble()));
|
||||||
|
led.minY_frac = qMax(0.0, qMin(1.0, ledConfig["vmin"].toDouble()));
|
||||||
|
led.maxY_frac = qMax(0.0, qMin(1.0, ledConfig["vmax"].toDouble()));
|
||||||
|
// Fix if the user swapped min and max
|
||||||
|
if (led.minX_frac > led.maxX_frac)
|
||||||
|
{
|
||||||
|
std::swap(led.minX_frac, led.maxX_frac);
|
||||||
|
}
|
||||||
|
if (led.minY_frac > led.maxY_frac)
|
||||||
|
{
|
||||||
|
std::swap(led.minY_frac, led.maxY_frac);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the order of the rgb channels for this led (default is device order)
|
||||||
|
led.colorOrder = stringToColorOrder(ledConfig["colorOrder"].toString(deviceOrderStr));
|
||||||
|
|
||||||
|
led.isBlacklisted = false;
|
||||||
|
if (led.minX_frac < std::numeric_limits<double>::epsilon() &&
|
||||||
|
led.maxX_frac < std::numeric_limits<double>::epsilon() &&
|
||||||
|
led.minY_frac < std::numeric_limits<double>::epsilon() &&
|
||||||
|
led.maxY_frac < std::numeric_limits<double>::epsilon()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
led.isBlacklisted = true;
|
||||||
|
ledString.blacklistedLedIds().push_back(i);
|
||||||
|
}
|
||||||
|
ledString.leds().push_back(led);
|
||||||
|
}
|
||||||
|
return ledString;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ int main()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LedString ledString = hyperion::createLedString(config["leds"].toArray(), hyperion::createColorOrder(config["device"].toObject()));
|
const LedString ledString = LedString::createLedString(config["leds"].toArray(), hyperion::createColorOrder(config["device"].toObject()));
|
||||||
|
|
||||||
const ColorRgb testColor = {64, 123, 12};
|
const ColorRgb testColor = {64, 123, 12};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user