Skip to content

Commit

Permalink
Bugfix/Hotfix/Update
Browse files Browse the repository at this point in the history
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
  • Loading branch information
Paulchen-Panther committed Jul 2, 2019
1 parent d739d9e commit d414942
Show file tree
Hide file tree
Showing 20 changed files with 152 additions and 118 deletions.
9 changes: 6 additions & 3 deletions assets/webconfig/js/content_leds.js
Expand Up @@ -193,10 +193,10 @@ function createClassicLeds(){
}
}

createLeftLeds();
createBottomLeds();
createRightLeds();
createTopLeds();
createRightLeds();
createBottomLeds();
createLeftLeds();

//check led gap pos
if (ledsgpos+ledsglength > ledArray.length)
Expand Down Expand Up @@ -429,6 +429,9 @@ $(document).ready(function() {
// create and update editor
$("#leddevices").off().on("change", function() {
var generalOptions = window.serverSchema.properties.device;

// Modified schema enty "hardwareLedCount" in generalOptions to minimum LedCount

var specificOptions = window.serverSchema.properties.alldevices[$(this).val()];
conf_editor = createJsonEditor('editor_container', {
generalOptions : generalOptions,
Expand Down
2 changes: 1 addition & 1 deletion config/hyperion.config.json.commented
Expand Up @@ -31,7 +31,7 @@
"output" : "/dev/null",
"rate" : 1000000,
"colorOrder" : "rgb",
"rewriteTime": 0
"rewriteTime": 5000
},

/// Color manipulation configuration used to tune the output colors to specific surroundings.
Expand Down
8 changes: 4 additions & 4 deletions include/api/JsonAPI.h
Expand Up @@ -6,7 +6,7 @@
#include <utils/Components.h>
#include <hyperion/Hyperion.h>

// qt includess
// qt includes
#include <QJsonObject>
#include <QMutex>
#include <QString>
Expand Down Expand Up @@ -63,8 +63,8 @@ public slots:
// true if further callbacks are forbidden (http)
bool _noListener;

/// The peer address of the client
QString _peerAddress;
/// The peer address of the client
QString _peerAddress;

/// Log instance
Logger* _log;
Expand All @@ -86,7 +86,7 @@ public slots:
/// mutex to determine state of image streaming
QMutex _image_stream_mutex;

/// mutex to determine state of image streaming
/// mutex to determine state of led streaming
QMutex _led_stream_mutex;

/// timeout for live video refresh
Expand Down
21 changes: 15 additions & 6 deletions include/hyperion/Hyperion.h
Expand Up @@ -5,14 +5,14 @@
#include <QMap>

// QT includes
//#include <QObject>
#include <QString>
#include <QStringList>
#include <QSize>
#include <QJsonObject>
#include <QJsonValue>
#include <QJsonArray>
#include <QFileSystemWatcher>
#include <QMutex>

// hyperion-utils includes
#include <utils/Image.h>
Expand Down Expand Up @@ -410,8 +410,11 @@ public slots:
/// Signal which is emitted, when a new json message should be forwarded
void forwardJsonMessage(QJsonObject);

/// Signal which is emitted, when a new proto image should be forwarded
void forwardProtoMessage(const QString, const Image<ColorRgb>);
/// Signal which is emitted, when a new system proto image should be forwarded
void forwardSystemProtoMessage(const QString, const Image<ColorRgb>);

/// Signal which is emitted, when a new V4l proto image should be forwarded
void forwardV4lProtoMessage(const QString, const Image<ColorRgb>);

///
/// @brief Is emitted from clients who request a videoMode change
Expand Down Expand Up @@ -474,6 +477,12 @@ private slots:
///
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);

///
/// @brief Handle priority updates from Priority Muxer
/// @param priority The new visible priority
///
void handlePriorityChanges(const quint8 &priority);

private:

///
Expand Down Expand Up @@ -560,12 +569,12 @@ private slots:
/// Capture control for Daemon native capture
CaptureCont* _captureCont;

// lock Hyperion::update() for exec
bool _lockUpdate = false;

/// buffer for leds (with adjustment)
std::vector<ColorRgb> _ledBuffer;

/// Boblight instance
BoblightServer* _boblightServer;

/// mutex
QMutex _changes;
};
2 changes: 1 addition & 1 deletion include/hyperion/ImageProcessor.h
Expand Up @@ -150,7 +150,7 @@ public slots:
// Check black border detection
verifyBorder(image);

// Determine the mean-colors of each led (using the existing mapping)
// Determine the mean or uni colors of each led (using the existing mapping)
switch (_mappingType)
{
case 1: _imageToLeds->getUniLedColor(image, ledColors); break;
Expand Down
6 changes: 3 additions & 3 deletions include/hyperion/ImageToLedsMap.h
Expand Up @@ -61,7 +61,7 @@ namespace hyperion
unsigned verticalBorder() { return _verticalBorder; };

///
/// Determines the mean-color for each led using the mapping the image given
/// Determines the mean color for each led using the mapping the image given
/// at construction.
///
/// @param[in] image The image from which to extract the led colors
Expand Down Expand Up @@ -104,7 +104,7 @@ namespace hyperion
}

///
/// Determines the mean-color for each led using the mapping the image given
/// Determines the uni color for each led using the mapping the image given
/// at construction.
///
/// @param[in] image The image from which to extract the led colors
Expand All @@ -120,7 +120,7 @@ namespace hyperion
}

///
/// Determines the mean color for each led using the mapping the image given
/// Determines the uni color for each led using the mapping the image given
/// at construction.
///
/// @param[in] image The image from which to extract the led colors
Expand Down
8 changes: 8 additions & 0 deletions include/leddevice/LedDevice.h
Expand Up @@ -84,6 +84,14 @@ public slots:
///
void enableStateChanged(bool newState);

///
/// PIPER signal for Priority Muxer -> LedDevice
///
/// @brief Handle priority updates from Priority Muxer
/// @param priority The new visible priority
///
void visiblePriorityChanged(const quint8 &priority);

protected:
virtual bool init(const QJsonObject &deviceConfig);

Expand Down
4 changes: 2 additions & 2 deletions include/utils/hyperion.h
Expand Up @@ -40,12 +40,12 @@ namespace hyperion {
(uint8_t)FGCONFIG_ARRAY.at(2).toInt(0)
};
hyperion->setColor(FG_PRIORITY, fg_color, fg_duration_ms);
Info(Logger::getInstance("HYPERION"),"Inital foreground color set (%d %d %d)",fg_color.red,fg_color.green,fg_color.blue);
Info(Logger::getInstance("HYPERION"),"Initial foreground color set (%d %d %d)",fg_color.red,fg_color.green,fg_color.blue);
}
else
{
int result = hyperion->setEffect(fgEffectConfig, FG_PRIORITY, fg_duration_ms);
Info(Logger::getInstance("HYPERION"),"Inital foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed"));
Info(Logger::getInstance("HYPERION"),"Initial foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed"));
}
}
#undef FGCONFIG_ARRAY
Expand Down
1 change: 0 additions & 1 deletion libsrc/effectengine/EffectEngine.cpp
Expand Up @@ -30,7 +30,6 @@ EffectEngine::EffectEngine(Hyperion * hyperion)
{

Q_INIT_RESOURCE(EffectEngine);
qRegisterMetaType<std::vector<ColorRgb>>("std::vector<ColorRgb>");
qRegisterMetaType<hyperion::Components>("hyperion::Components");

// connect the Hyperion channel clear feedback
Expand Down
4 changes: 2 additions & 2 deletions libsrc/hyperion/CaptureCont.cpp
Expand Up @@ -73,7 +73,7 @@ void CaptureCont::setSystemCaptureEnable(const bool& enable)
{
_hyperion->registerInput(_systemCaptPrio, hyperion::COMP_GRABBER);
connect(GlobalSignals::getInstance(), &GlobalSignals::setSystemImage, this, &CaptureCont::handleSystemImage);
connect(GlobalSignals::getInstance(), &GlobalSignals::setSystemImage, _hyperion, &Hyperion::forwardProtoMessage);
connect(GlobalSignals::getInstance(), &GlobalSignals::setSystemImage, _hyperion, &Hyperion::forwardSystemProtoMessage);
}
else
{
Expand All @@ -94,7 +94,7 @@ void CaptureCont::setV4LCaptureEnable(const bool& enable)
{
_hyperion->registerInput(_v4lCaptPrio, hyperion::COMP_V4L);
connect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, this, &CaptureCont::handleV4lImage);
connect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, _hyperion, &Hyperion::forwardProtoMessage);
connect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, _hyperion, &Hyperion::forwardV4lProtoMessage);
}
else
{
Expand Down
72 changes: 34 additions & 38 deletions libsrc/hyperion/Hyperion.cpp
Expand Up @@ -106,8 +106,8 @@ Hyperion::Hyperion(HyperionDaemon* daemon, const quint8& instance, const QString
_ledStringColorOrder.insert(_ledStringColorOrder.begin() + led.index, led.colorOrder);
}

// connect Hyperion::update with Muxer visible priority changes as muxer updates independent
connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::update);
// connect Hyperion::handlePriorityChanges with Muxer visible priority changes as muxer updates independent
connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::handlePriorityChanges);

// listens for ComponentRegister changes of COMP_ALL to perform core enable/disable actions
connect(&_componentRegister, &ComponentRegister::updatedComponentState, this, &Hyperion::updatedComponentState);
Expand Down Expand Up @@ -186,7 +186,6 @@ void Hyperion::freeObjects(bool emitCloseSignal)
delete _boblightServer;
delete _captureCont;
delete _effectEngine;
//delete _deviceSmooth;
delete _raw2ledAdjustment;
delete _messageForwarder;
delete _settingsManager;
Expand All @@ -209,10 +208,13 @@ void Hyperion::handleSettingsUpdate(const settings::type& type, const QJsonDocum
}
else if(type == settings::LEDS)
{
QMutexLocker lock(&_changes);

const QJsonArray leds = config.array();

// lock update()
_lockUpdate = true;
// // lock update()
// _lockUpdate = true;

// stop and cache all running effects, as effects depend heavily on ledlayout
_effectEngine->cacheRunningEffects();

Expand Down Expand Up @@ -249,12 +251,13 @@ void Hyperion::handleSettingsUpdate(const settings::type& type, const QJsonDocum
// start cached effects
_effectEngine->startCachedEffects();

// unlock
_lockUpdate = false;
// // unlock
// _lockUpdate = false;
}
else if(type == settings::DEVICE)
{
_lockUpdate = true;
QMutexLocker lock(&_changes);
// _lockUpdate = true;
QJsonObject dev = config.object();

// handle hwLedCount update
Expand All @@ -278,7 +281,7 @@ void Hyperion::handleSettingsUpdate(const settings::type& type, const QJsonDocum
// do always reinit until the led devices can handle dynamic changes
dev["currentLedCount"] = int(_hwLedCount); // Inject led count info
_ledDeviceWrapper->createLedDevice(dev);
_lockUpdate = false;
// _lockUpdate = false;
}
// update once to push single color sets / adjustments/ ledlayout resizes and update ledBuffer color
update();
Expand Down Expand Up @@ -578,50 +581,25 @@ void Hyperion::updatedComponentState(const hyperion::Components comp, const bool

void Hyperion::update()
{
if(_lockUpdate)
return;

// the ledbuffer resize for hwledcount needs to be reverted
if(_hwLedCount > _ledBuffer.size())
_ledBuffer.resize(getLedCount());
QMutexLocker lock(&_changes);

// Obtain the current priority channel
int priority = _muxer.getCurrentPriority();
const PriorityMuxer::InputInfo priorityInfo = _muxer.getInputInfo(priority);

// eval comp change
bool compChanged = false;
if (priorityInfo.componentId != _prevCompId)
{
compChanged = true;
_prevCompId = priorityInfo.componentId;
}

// copy image & process OR copy ledColors from muxer
Image<ColorRgb> image = priorityInfo.image;
if(image.size() > 3)
{
emit currentImage(image);
// disable the black border detector for effects and ledmapping to 0
if(compChanged)
{
_imageProcessor->setBlackbarDetectDisable((_prevCompId == hyperion::COMP_EFFECT));
_imageProcessor->setHardLedMappingType((_prevCompId == hyperion::COMP_EFFECT) ? 0 : -1);
}
_imageProcessor->process(image, _ledBuffer);
_ledBuffer = _imageProcessor->process(image);
}
else
{
_ledBuffer = priorityInfo.ledColors;
}

// emit rawLedColors before transform
emit rawLedColors(_ledBuffer);

// apply adjustments
if(compChanged)
_raw2ledAdjustment->setBacklightEnabled((_prevCompId != hyperion::COMP_COLOR && _prevCompId != hyperion::COMP_EFFECT));

_raw2ledAdjustment->applyAdjustment(_ledBuffer);

// insert cloned leds into buffer
Expand Down Expand Up @@ -660,7 +638,8 @@ void Hyperion::update()
}
i++;
}
// fill aditional hw leds with black

// fill additional hw leds with black
if ( _hwLedCount > _ledBuffer.size() )
{
_ledBuffer.resize(_hwLedCount, ColorRgb::BLACK);
Expand All @@ -671,11 +650,28 @@ void Hyperion::update()
{
_deviceSmooth->selectConfig(priorityInfo.smooth_cfg);

// feed smoothing in pause mode to maintain a smooth transistion back to smoth mode
// feed smoothing in pause mode to maintain a smooth transistion back to smooth mode
if (_deviceSmooth->enabled() || _deviceSmooth->pause())
_deviceSmooth->setLedValues(_ledBuffer);

if (! _deviceSmooth->enabled())
emit ledDeviceData(_ledBuffer);
}
}

void Hyperion::handlePriorityChanges(const quint8 &priority)
{
QMutexLocker lock(&_changes);

// Obtain the current priority channel
const PriorityMuxer::InputInfo priorityInfo = _muxer.getInputInfo(priority);

// evaluate comp change
if (priorityInfo.componentId != _prevCompId)
{
_imageProcessor->setBlackbarDetectDisable((_prevCompId == hyperion::COMP_EFFECT));
_imageProcessor->setHardLedMappingType((_prevCompId == hyperion::COMP_EFFECT) ? 0 : -1);
_prevCompId = priorityInfo.componentId;
_raw2ledAdjustment->setBacklightEnabled((_prevCompId != hyperion::COMP_COLOR && _prevCompId != hyperion::COMP_EFFECT));
}
}
1 change: 0 additions & 1 deletion libsrc/hyperion/LinearColorSmoothing.h
Expand Up @@ -3,7 +3,6 @@
// STL includes
#include <vector>


// Qt includes
#include <QVector>

Expand Down

0 comments on commit d414942

Please sign in to comment.