mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
refactor: Led layout, clearAll (#703)
* add SSDP name field * YALL - yet another led layout * led layout migration * add initial vscode config * merge clearAll with clear, rename Hyperion::compStateChange * simpler components api * Corrected code formatting + triggered PR build * fix: regression from #636 * Support for color patterns Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
@@ -204,17 +204,29 @@ void JsonAPI::handleMessage(const QString& messageString, const QString& httpAut
|
||||
void JsonAPI::handleColorCommand(const QJsonObject& message, const QString& command, const int tan)
|
||||
{
|
||||
emit forwardJsonMessage(message);
|
||||
|
||||
// extract parameters
|
||||
int priority = message["priority"].toInt();
|
||||
int duration = message["duration"].toInt(-1);
|
||||
const QString origin = message["origin"].toString("JsonRpc") + "@"+_peerAddress;
|
||||
const QString origin = message["origin"].toString("JsonRpc") + "@" + _peerAddress;
|
||||
|
||||
const QJsonArray & jsonColor = message["color"].toArray();
|
||||
const ColorRgb color = {uint8_t(jsonColor.at(0).toInt()),uint8_t(jsonColor.at(1).toInt()),uint8_t(jsonColor.at(2).toInt())};
|
||||
const QJsonArray &jsonColor = message["color"].toArray();
|
||||
std::vector<uint8_t> colors;
|
||||
// TODO faster copy
|
||||
for (const auto &entry : jsonColor)
|
||||
{
|
||||
colors.emplace_back(uint8_t(entry.toInt()));
|
||||
}
|
||||
|
||||
std::vector<ColorRgb> fledColors;
|
||||
if (colors.size() % 3 == 0)
|
||||
{
|
||||
for (unsigned i = 0; i < colors.size(); i += 3)
|
||||
{
|
||||
fledColors.emplace_back(ColorRgb{colors[i], colors[i + 1], colors[i + 2]});
|
||||
}
|
||||
}
|
||||
|
||||
// set color
|
||||
_hyperion->setColor(priority, color, duration, origin);
|
||||
_hyperion->setColor(priority, fledColors, duration, origin);
|
||||
|
||||
// send reply
|
||||
sendSuccessReply(command, tan);
|
||||
@@ -562,7 +574,7 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject& message, const QString&
|
||||
|
||||
// get available components
|
||||
QJsonArray component;
|
||||
std::map<hyperion::Components, bool> components = _hyperion->getComponentRegister().getRegister();
|
||||
std::map<hyperion::Components, bool> components = _hyperion->getAllComponents();
|
||||
for(auto comp : components)
|
||||
{
|
||||
QJsonObject item;
|
||||
@@ -744,7 +756,7 @@ void JsonAPI::handleClearCommand(const QJsonObject& message, const QString& comm
|
||||
if(priority > 0)
|
||||
_hyperion->clear(priority);
|
||||
else if(priority < 0)
|
||||
_hyperion->clearall();
|
||||
_hyperion->clear(-1);
|
||||
else
|
||||
{
|
||||
sendErrorReply("Priority 0 is not allowed", command, tan);
|
||||
@@ -760,7 +772,7 @@ void JsonAPI::handleClearallCommand(const QJsonObject& message, const QString& c
|
||||
emit forwardJsonMessage(message);
|
||||
|
||||
// clear priority
|
||||
_hyperion->clearall();
|
||||
_hyperion->clear(-1);
|
||||
|
||||
// send reply
|
||||
sendSuccessReply(command, tan);
|
||||
@@ -920,7 +932,7 @@ void JsonAPI::handleConfigSetCommand(const QJsonObject& message, const QString &
|
||||
if (message.contains("config"))
|
||||
{
|
||||
QJsonObject config = message["config"].toObject();
|
||||
if(_hyperion->getComponentRegister().isComponentEnabled(hyperion::COMP_ALL))
|
||||
if(_hyperion->isComponentEnabled(hyperion::COMP_ALL))
|
||||
{
|
||||
if(_hyperion->saveSettings(config, true))
|
||||
sendSuccessReply(command,tan);
|
||||
@@ -1004,18 +1016,11 @@ void JsonAPI::handleComponentStateCommand(const QJsonObject& message, const QStr
|
||||
|
||||
Components component = stringToComponent(compStr);
|
||||
|
||||
if (compStr == "ALL" )
|
||||
{
|
||||
if(_hyperion->getComponentRegister().setHyperionEnable(compState))
|
||||
sendSuccessReply(command, tan);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (component != COMP_INVALID)
|
||||
if (component != COMP_INVALID)
|
||||
{
|
||||
// send result before apply
|
||||
sendSuccessReply(command, tan);
|
||||
_hyperion->setComponentState(component, compState);
|
||||
emit _hyperion->compStateChangeRequest(component, compState);
|
||||
return;
|
||||
}
|
||||
sendErrorReply("invalid component name", command, tan);
|
||||
|
@@ -32,7 +32,7 @@ BlackBorderProcessor::BlackBorderProcessor(Hyperion* hyperion, QObject* parent)
|
||||
connect(_hyperion, &Hyperion::settingsChanged, this, &BlackBorderProcessor::handleSettingsUpdate);
|
||||
|
||||
// listen for component state changes
|
||||
connect(_hyperion, &Hyperion::componentStateChanged, this, &BlackBorderProcessor::componentStateChanged);
|
||||
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &BlackBorderProcessor::handleCompStateChangeRequest);
|
||||
}
|
||||
|
||||
BlackBorderProcessor::~BlackBorderProcessor()
|
||||
@@ -65,11 +65,11 @@ void BlackBorderProcessor::handleSettingsUpdate(const settings::type& type, cons
|
||||
Debug(Logger::getInstance("BLACKBORDER"), "Set mode to: %s", QSTRING_CSTR(_detectionMode));
|
||||
|
||||
// eval the comp state
|
||||
componentStateChanged(hyperion::COMP_BLACKBORDER, obj["enable"].toBool(true));
|
||||
handleCompStateChangeRequest(hyperion::COMP_BLACKBORDER, obj["enable"].toBool(true));
|
||||
}
|
||||
}
|
||||
|
||||
void BlackBorderProcessor::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
void BlackBorderProcessor::handleCompStateChangeRequest(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if(component == hyperion::COMP_BLACKBORDER)
|
||||
{
|
||||
@@ -85,7 +85,7 @@ void BlackBorderProcessor::componentStateChanged(const hyperion::Components comp
|
||||
_enabled = enable;
|
||||
}
|
||||
|
||||
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_BLACKBORDER, enable);
|
||||
_hyperion->setNewComponentState(hyperion::COMP_BLACKBORDER, enable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ BoblightServer::BoblightServer(Hyperion* hyperion,const QJsonDocument& config)
|
||||
Debug(_log, "Instance created");
|
||||
|
||||
// listen for component change
|
||||
connect(_hyperion, SIGNAL(componentStateChanged(hyperion::Components,bool)), this, SLOT(componentStateChanged(hyperion::Components,bool)));
|
||||
connect(_hyperion, SIGNAL(compStateChangeRequest(hyperion::Components,bool)), this, SLOT(compStateChangeRequest(hyperion::Components,bool)));
|
||||
// listen new connection signal from server
|
||||
connect(_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
|
||||
|
||||
@@ -51,7 +51,7 @@ void BoblightServer::start()
|
||||
|
||||
Info(_log, "Started on port %d", _port);
|
||||
|
||||
_hyperion->getComponentRegister().componentStateChanged(COMP_BOBLIGHTSERVER, _server->isListening());
|
||||
_hyperion->setNewComponentState(COMP_BOBLIGHTSERVER, _server->isListening());
|
||||
}
|
||||
|
||||
void BoblightServer::stop()
|
||||
@@ -65,7 +65,7 @@ void BoblightServer::stop()
|
||||
_server->close();
|
||||
|
||||
Info(_log, "Stopped");
|
||||
_hyperion->getComponentRegister().componentStateChanged(COMP_BOBLIGHTSERVER, _server->isListening());
|
||||
_hyperion->setNewComponentState(COMP_BOBLIGHTSERVER, _server->isListening());
|
||||
}
|
||||
|
||||
bool BoblightServer::active()
|
||||
@@ -73,7 +73,7 @@ bool BoblightServer::active()
|
||||
return _server->isListening();
|
||||
}
|
||||
|
||||
void BoblightServer::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
void BoblightServer::compStateChangeRequest(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if (component == COMP_BOBLIGHTSERVER)
|
||||
{
|
||||
|
@@ -95,10 +95,7 @@ void FlatBufferClient::handleColorCommand(const hyperionnet::Color *colorReq)
|
||||
{
|
||||
// extract parameters
|
||||
const int32_t rgbData = colorReq->data();
|
||||
ColorRgb color;
|
||||
color.red = qRed(rgbData);
|
||||
color.green = qGreen(rgbData);
|
||||
color.blue = qBlue(rgbData);
|
||||
std::vector<ColorRgb> color{ ColorRgb{ uint8_t(qRed(rgbData)), uint8_t(qGreen(rgbData)), uint8_t(qBlue(rgbData)) } };
|
||||
|
||||
// set output
|
||||
emit setGlobalInputColor(_priority, color, colorReq->duration());
|
||||
@@ -172,17 +169,12 @@ void FlatBufferClient::handleClearCommand(const hyperionnet::Clear *clear)
|
||||
// extract parameters
|
||||
const int priority = clear->priority();
|
||||
|
||||
if (priority == -1) {
|
||||
emit clearAllGlobalInput();
|
||||
// Check if we are clearing ourselves.
|
||||
if (priority == _priority) {
|
||||
_priority = -1;
|
||||
}
|
||||
else {
|
||||
// Check if we are clearing ourselves.
|
||||
if (priority == _priority) {
|
||||
_priority = -1;
|
||||
}
|
||||
|
||||
emit clearGlobalInput(priority);
|
||||
}
|
||||
emit clearGlobalInput(priority);
|
||||
|
||||
sendSuccessReply();
|
||||
}
|
||||
|
@@ -41,12 +41,7 @@ signals:
|
||||
///
|
||||
/// @brief Forward clear command to HyperionDaemon
|
||||
///
|
||||
void clearGlobalInput(const int priority);
|
||||
|
||||
///
|
||||
/// @brief Forward clearAll command to HyperionDaemon
|
||||
///
|
||||
void clearAllGlobalInput(bool forceClearAll=false);
|
||||
void clearGlobalInput(const int priority, bool forceClearAll=false);
|
||||
|
||||
///
|
||||
/// @brief forward prepared image to HyperionDaemon
|
||||
@@ -56,7 +51,7 @@ signals:
|
||||
///
|
||||
/// @brief Forward requested color
|
||||
///
|
||||
void setGlobalInputColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "FlatBuffer" ,bool clearEffects = true);
|
||||
void setGlobalInputColor(const int priority, const std::vector<ColorRgb> &ledColor, const int timeout_ms, const QString& origin = "FlatBuffer" ,bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// @brief Emits whenever the client disconnected
|
||||
|
@@ -71,7 +71,6 @@ void FlatBufferServer::newConnection()
|
||||
connect(client, &FlatBufferClient::clientDisconnected, this, &FlatBufferServer::clientDisconnected);
|
||||
connect(client, &FlatBufferClient::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
|
||||
connect(client, &FlatBufferClient::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
|
||||
connect(client, &FlatBufferClient::clearAllGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput);
|
||||
connect(client, &FlatBufferClient::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
|
||||
connect(client, &FlatBufferClient::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &FlatBufferClient::registationRequired);
|
||||
|
@@ -60,7 +60,7 @@ V4L2Grabber::V4L2Grabber(const QString & device
|
||||
|
||||
// connect componentStateChange only for build-in grabber
|
||||
if (HyperionIManager::HIMinstance)
|
||||
connect(this, &Grabber::componentStateChanged, this, &V4L2Grabber::componentStateChanged);
|
||||
connect(this, &Grabber::compStateChangeRequest, this, &V4L2Grabber::compStateChangeRequest);
|
||||
|
||||
// init
|
||||
setDeviceVideoStandard(device, videoStandard);
|
||||
@@ -1176,7 +1176,7 @@ void V4L2Grabber::setDeviceVideoStandard(QString device, VideoStandard videoStan
|
||||
}
|
||||
}
|
||||
|
||||
void V4L2Grabber::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
void V4L2Grabber::compStateChangeRequest(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if (component == hyperion::COMP_V4L)
|
||||
{
|
||||
|
@@ -24,7 +24,7 @@ V4L2Wrapper::V4L2Wrapper(const QString &device,
|
||||
connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::DirectConnection);
|
||||
connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection);
|
||||
|
||||
connect(this, &V4L2Wrapper::componentStateChanged, _ggrabber, &Grabber::componentStateChanged);
|
||||
connect(this, &V4L2Wrapper::compStateChangeRequest, _ggrabber, &Grabber::compStateChangeRequest);
|
||||
}
|
||||
|
||||
bool V4L2Wrapper::start()
|
||||
|
@@ -25,7 +25,7 @@ CaptureCont::CaptureCont(Hyperion* hyperion)
|
||||
connect(_hyperion, &Hyperion::settingsChanged, this, &CaptureCont::handleSettingsUpdate);
|
||||
|
||||
// comp changes
|
||||
connect(_hyperion, &Hyperion::componentStateChanged, this, &CaptureCont::componentStateChanged);
|
||||
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &CaptureCont::handleCompStateChangeRequest);
|
||||
|
||||
// inactive timer system
|
||||
connect(_systemInactiveTimer, &QTimer::timeout, this, &CaptureCont::setSystemInactive);
|
||||
@@ -85,8 +85,8 @@ void CaptureCont::setSystemCaptureEnable(const bool& enable)
|
||||
_systemCaptName = "";
|
||||
}
|
||||
_systemCaptEnabled = enable;
|
||||
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_GRABBER, enable);
|
||||
_hyperion->setComponentState(hyperion::COMP_GRABBER, enable);
|
||||
_hyperion->setNewComponentState(hyperion::COMP_GRABBER, enable);
|
||||
//emit _hyperion->compStateChangeRequest(hyperion::COMP_GRABBER, enable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ void CaptureCont::setV4LCaptureEnable(const bool& enable)
|
||||
_v4lCaptName = "";
|
||||
}
|
||||
_v4lCaptEnabled = enable;
|
||||
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_V4L, enable);
|
||||
_hyperion->setComponentState(hyperion::COMP_V4L, enable);
|
||||
_hyperion->setNewComponentState(hyperion::COMP_V4L, enable);
|
||||
//emit _hyperion->compStateChangeRequest(hyperion::COMP_V4L, enable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ void CaptureCont::handleSettingsUpdate(const settings::type& type, const QJsonDo
|
||||
}
|
||||
}
|
||||
|
||||
void CaptureCont::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
void CaptureCont::handleCompStateChangeRequest(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if(component == hyperion::COMP_GRABBER)
|
||||
{
|
||||
|
@@ -16,51 +16,20 @@ ComponentRegister::ComponentRegister(Hyperion* hyperion)
|
||||
{
|
||||
_componentStates.emplace(e, ((e == COMP_ALL) ? true : false));
|
||||
}
|
||||
|
||||
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &ComponentRegister::handleCompStateChangeRequest);
|
||||
}
|
||||
|
||||
ComponentRegister::~ComponentRegister()
|
||||
{
|
||||
}
|
||||
|
||||
bool ComponentRegister::setHyperionEnable(const bool& state)
|
||||
{
|
||||
if(!state && _prevComponentStates.empty())
|
||||
{
|
||||
Debug(_log,"Disable Hyperion, store current component states");
|
||||
for(const auto comp : _componentStates)
|
||||
{
|
||||
// save state
|
||||
_prevComponentStates.emplace(comp.first, comp.second);
|
||||
// disable if enabled
|
||||
if(comp.second)
|
||||
_hyperion->setComponentState(comp.first, false);
|
||||
}
|
||||
componentStateChanged(COMP_ALL, false);
|
||||
return true;
|
||||
}
|
||||
else if(state && !_prevComponentStates.empty())
|
||||
{
|
||||
Debug(_log,"Enable Hyperion, recover previous component states");
|
||||
for(const auto comp : _prevComponentStates)
|
||||
{
|
||||
// if comp was enabled, enable again
|
||||
if(comp.second)
|
||||
_hyperion->setComponentState(comp.first, true);
|
||||
|
||||
}
|
||||
_prevComponentStates.clear();
|
||||
componentStateChanged(COMP_ALL, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int ComponentRegister::isComponentEnabled(const hyperion::Components& comp) const
|
||||
{
|
||||
return (_componentStates.count(comp)) ? _componentStates.at(comp) : -1;
|
||||
}
|
||||
|
||||
void ComponentRegister::componentStateChanged(const hyperion::Components comp, const bool activated)
|
||||
void ComponentRegister::setNewComponentState(const hyperion::Components comp, const bool activated)
|
||||
{
|
||||
if(_componentStates[comp] != activated)
|
||||
{
|
||||
@@ -70,3 +39,38 @@ void ComponentRegister::componentStateChanged(const hyperion::Components comp, c
|
||||
emit updatedComponentState(comp, activated);
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentRegister::handleCompStateChangeRequest(const hyperion::Components comp, const bool activated)
|
||||
{
|
||||
if(comp == COMP_ALL && !_inProgress)
|
||||
{
|
||||
_inProgress = true;
|
||||
if(!activated && _prevComponentStates.empty())
|
||||
{
|
||||
Debug(_log,"Disable Hyperion, store current component states");
|
||||
for(const auto comp : _componentStates)
|
||||
{
|
||||
// save state
|
||||
_prevComponentStates.emplace(comp.first, comp.second);
|
||||
// disable if enabled
|
||||
if(comp.second)
|
||||
emit _hyperion->compStateChangeRequest(comp.first, false);
|
||||
}
|
||||
setNewComponentState(COMP_ALL, false);
|
||||
}
|
||||
else if(activated && !_prevComponentStates.empty())
|
||||
{
|
||||
Debug(_log,"Enable Hyperion, recover previous component states");
|
||||
for(const auto comp : _prevComponentStates)
|
||||
{
|
||||
// if comp was enabled, enable again
|
||||
if(comp.second)
|
||||
emit _hyperion->compStateChangeRequest(comp.first, true);
|
||||
|
||||
}
|
||||
_prevComponentStates.clear();
|
||||
setNewComponentState(COMP_ALL, true);
|
||||
}
|
||||
_inProgress = false;
|
||||
}
|
||||
}
|
@@ -104,7 +104,7 @@ void Hyperion::start()
|
||||
ledDevice["currentLedCount"] = int(_hwLedCount); // Inject led count info
|
||||
|
||||
_ledDeviceWrapper = new LedDeviceWrapper(this);
|
||||
connect(this, &Hyperion::componentStateChanged, _ledDeviceWrapper, &LedDeviceWrapper::handleComponentState);
|
||||
connect(this, &Hyperion::compStateChangeRequest, _ledDeviceWrapper, &LedDeviceWrapper::handleComponentState);
|
||||
connect(this, &Hyperion::ledDeviceData, _ledDeviceWrapper, &LedDeviceWrapper::updateLeds);
|
||||
_ledDeviceWrapper->createLedDevice(ledDevice);
|
||||
|
||||
@@ -132,7 +132,6 @@ void Hyperion::start()
|
||||
// forwards global signals to the corresponding slots
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput, this, &Hyperion::registerInput);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput, this, &Hyperion::clear);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput, this, &Hyperion::clearall);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor, this, &Hyperion::setColor);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage, this, &Hyperion::setInputImage);
|
||||
|
||||
@@ -157,7 +156,7 @@ void Hyperion::stop()
|
||||
void Hyperion::freeObjects(bool emitCloseSignal)
|
||||
{
|
||||
// switch off all leds
|
||||
clearall(true);
|
||||
clear(-1,true);
|
||||
|
||||
if (emitCloseSignal)
|
||||
{
|
||||
@@ -309,13 +308,17 @@ bool Hyperion::sourceAutoSelectEnabled()
|
||||
|
||||
void Hyperion::setNewComponentState(const hyperion::Components& component, const bool& state)
|
||||
{
|
||||
_componentRegister.componentStateChanged(component, state);
|
||||
_componentRegister.setNewComponentState(component, state);
|
||||
}
|
||||
|
||||
void Hyperion::setComponentState(const hyperion::Components component, const bool state)
|
||||
std::map<hyperion::Components, bool> Hyperion::getAllComponents()
|
||||
{
|
||||
// TODO REMOVE THIS STEP
|
||||
emit componentStateChanged(component, state);
|
||||
return _componentRegister.getRegister();
|
||||
}
|
||||
|
||||
int Hyperion::isComponentEnabled(const hyperion::Components &comp)
|
||||
{
|
||||
return _componentRegister.isComponentEnabled(comp);
|
||||
}
|
||||
|
||||
void Hyperion::registerInput(const int priority, const hyperion::Components& component, const QString& origin, const QString& owner, unsigned smooth_cfg)
|
||||
@@ -372,14 +375,25 @@ bool Hyperion::setInputInactive(const quint8& priority)
|
||||
return _muxer.setInputInactive(priority);
|
||||
}
|
||||
|
||||
void Hyperion::setColor(const int priority, const ColorRgb &color, const int timeout_ms, const QString& origin, bool clearEffects)
|
||||
void Hyperion::setColor(const int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, const QString &origin, bool clearEffects)
|
||||
{
|
||||
// clear effect if this call does not come from an effect
|
||||
if(clearEffects)
|
||||
if (clearEffects)
|
||||
_effectEngine->channelCleared(priority);
|
||||
|
||||
// create led vector from single color
|
||||
std::vector<ColorRgb> ledColors(_ledString.leds().size(), color);
|
||||
// create full led vector from single/multiple colors
|
||||
unsigned int size = _ledString.leds().size();
|
||||
std::vector<ColorRgb> newLedColors;
|
||||
while (true)
|
||||
{
|
||||
for (const auto &entry : ledColors)
|
||||
{
|
||||
newLedColors.emplace_back(entry);
|
||||
if (newLedColors.size() == size)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
end:
|
||||
|
||||
if (getPriorityInfo(priority).componentId != hyperion::COMP_COLOR)
|
||||
clear(priority);
|
||||
@@ -388,8 +402,8 @@ void Hyperion::setColor(const int priority, const ColorRgb &color, const int tim
|
||||
registerInput(priority, hyperion::COMP_COLOR, origin);
|
||||
|
||||
// write color to muxer & queuePush
|
||||
setInput(priority, ledColors, timeout_ms);
|
||||
if(timeout_ms <= 0)
|
||||
setInput(priority, newLedColors, timeout_ms);
|
||||
if (timeout_ms <= 0)
|
||||
_muxer.queuePush();
|
||||
}
|
||||
|
||||
@@ -409,26 +423,28 @@ void Hyperion::adjustmentsUpdated()
|
||||
update();
|
||||
}
|
||||
|
||||
bool Hyperion::clear(const int priority)
|
||||
bool Hyperion::clear(const int priority, bool forceClearAll)
|
||||
{
|
||||
// send clear signal to the effect engine
|
||||
// (outside the check so the effect gets cleared even when the effect is not sending colors)
|
||||
_effectEngine->channelCleared(priority);
|
||||
if (priority < 0)
|
||||
{
|
||||
_muxer.clearAll(forceClearAll);
|
||||
|
||||
if(_muxer.clearInput(priority))
|
||||
// send clearall signal to the effect engine
|
||||
_effectEngine->allChannelsCleared();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// send clear signal to the effect engine
|
||||
// (outside the check so the effect gets cleared even when the effect is not sending colors)
|
||||
_effectEngine->channelCleared(priority);
|
||||
|
||||
if (_muxer.clearInput(priority))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Hyperion::clearall(bool forceClearAll)
|
||||
{
|
||||
_muxer.clearAll(forceClearAll);
|
||||
|
||||
// send clearall signal to the effect engine
|
||||
_effectEngine->allChannelsCleared();
|
||||
}
|
||||
|
||||
int Hyperion::getCurrentPriority() const
|
||||
{
|
||||
return _muxer.getCurrentPriority();
|
||||
|
@@ -76,7 +76,7 @@ bool HyperionIManager::startInstance(const quint8& inst, const bool& block)
|
||||
// from Hyperion
|
||||
connect(hyperion, &Hyperion::settingsChanged, this, &HyperionIManager::settingsChanged);
|
||||
connect(hyperion, &Hyperion::videoMode, this, &HyperionIManager::requestVideoMode);
|
||||
connect(hyperion, &Hyperion::componentStateChanged, this, &HyperionIManager::componentStateChanged);
|
||||
connect(hyperion, &Hyperion::compStateChangeRequest, this, &HyperionIManager::compStateChangeRequest);
|
||||
// to Hyperion
|
||||
connect(this, &HyperionIManager::newVideoMode, hyperion, &Hyperion::newVideoMode);
|
||||
|
||||
|
@@ -38,7 +38,7 @@ LinearColorSmoothing::LinearColorSmoothing(const QJsonDocument& config, Hyperion
|
||||
_cfgList.append(cfg);
|
||||
|
||||
// listen for comp changes
|
||||
connect(_hyperion, &Hyperion::componentStateChanged, this, &LinearColorSmoothing::componentStateChange);
|
||||
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &LinearColorSmoothing::componentStateChange);
|
||||
// timer
|
||||
connect(_timer, &QTimer::timeout, this, &LinearColorSmoothing::updateLeds);
|
||||
}
|
||||
@@ -235,7 +235,7 @@ void LinearColorSmoothing::setEnable(bool enable)
|
||||
clearQueuedColors();
|
||||
}
|
||||
// update comp register
|
||||
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, enable);
|
||||
_hyperion->setNewComponentState(hyperion::COMP_SMOOTHING, enable);
|
||||
}
|
||||
|
||||
void LinearColorSmoothing::setPause(bool pause)
|
||||
|
@@ -28,7 +28,7 @@ MessageForwarder::MessageForwarder(Hyperion *hyperion)
|
||||
connect(_hyperion, &Hyperion::settingsChanged, this, &MessageForwarder::handleSettingsUpdate);
|
||||
|
||||
// component changes
|
||||
connect(_hyperion, &Hyperion::componentStateChanged, this, &MessageForwarder::componentStateChanged);
|
||||
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &MessageForwarder::handleCompStateChangeRequest);
|
||||
|
||||
// connect with Muxer visible priority changes
|
||||
connect(_muxer, &PriorityMuxer::visiblePriorityChanged, this, &MessageForwarder::handlePriorityChanges);
|
||||
@@ -91,18 +91,18 @@ void MessageForwarder::handleSettingsUpdate(const settings::type &type, const QJ
|
||||
}
|
||||
|
||||
// update comp state
|
||||
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, obj["enable"].toBool(true));
|
||||
_hyperion->setNewComponentState(hyperion::COMP_FORWARDER, obj["enable"].toBool(true));
|
||||
}
|
||||
}
|
||||
|
||||
void MessageForwarder::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
void MessageForwarder::handleCompStateChangeRequest(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if (component == hyperion::COMP_FORWARDER && _forwarder_enabled != enable)
|
||||
{
|
||||
_forwarder_enabled = enable;
|
||||
handleSettingsUpdate(settings::NETFORWARD, _hyperion->getSetting(settings::NETFORWARD));
|
||||
Info(_log, "Forwarder change state to %s", (_forwarder_enabled ? "enabled" : "disabled"));
|
||||
_hyperion->getComponentRegister().componentStateChanged(component, _forwarder_enabled);
|
||||
_hyperion->setNewComponentState(component, _forwarder_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -74,6 +74,13 @@ SettingsManager::SettingsManager(const quint8& instance, QObject* parent)
|
||||
dbConfig[key] = doc.object();
|
||||
}
|
||||
|
||||
// possible data upgrade steps to prevent data loss
|
||||
if(handleConfigUpgrade(dbConfig))
|
||||
{
|
||||
saveSettings(dbConfig, true);
|
||||
}
|
||||
|
||||
|
||||
// validate full dbconfig against schema, on error we need to rewrite entire table
|
||||
QJsonSchemaChecker schemaChecker;
|
||||
schemaChecker.setSchema(schemaJson);
|
||||
@@ -108,6 +115,9 @@ const QJsonDocument SettingsManager::getSetting(const settings::type& type)
|
||||
|
||||
bool SettingsManager::saveSettings(QJsonObject config, const bool& correct)
|
||||
{
|
||||
// optional data upgrades e.g. imported legacy/older configs
|
||||
// handleConfigUpgrade(config);
|
||||
|
||||
// we need to validate data against schema
|
||||
QJsonSchemaChecker schemaChecker;
|
||||
schemaChecker.setSchema(schemaJson);
|
||||
@@ -156,3 +166,66 @@ bool SettingsManager::saveSettings(QJsonObject config, const bool& correct)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
||||
{
|
||||
bool migrated = false;
|
||||
|
||||
// LED LAYOUT UPGRADE
|
||||
// from { hscan: { minimum: 0.2, maximum: 0.3 }, vscan: { minimum: 0.2, maximumn: 0.3 } }
|
||||
// from { h: { min: 0.2, max: 0.3 }, v: { min: 0.2, max: 0.3 } }
|
||||
// to { hmin: 0.2, hmax: 0.3, vmin: 0.2, vmax: 0.3}
|
||||
if(config.contains("leds"))
|
||||
{
|
||||
const QJsonArray ledarr = config["leds"].toArray();
|
||||
const QJsonObject led = ledarr[0].toObject();
|
||||
|
||||
if(led.contains("hscan") || led.contains("h"))
|
||||
{
|
||||
const bool whscan = led.contains("hscan");
|
||||
QJsonArray newLedarr;
|
||||
|
||||
for(const auto & entry : ledarr)
|
||||
{
|
||||
const QJsonObject led = entry.toObject();
|
||||
QJsonObject hscan;
|
||||
QJsonObject vscan;
|
||||
QJsonValue hmin;
|
||||
QJsonValue hmax;
|
||||
QJsonValue vmin;
|
||||
QJsonValue vmax;
|
||||
QJsonObject nL;
|
||||
|
||||
if(whscan)
|
||||
{
|
||||
hscan = led["hscan"].toObject();
|
||||
vscan = led["vscan"].toObject();
|
||||
hmin = hscan["minimum"];
|
||||
hmax = hscan["maximum"];
|
||||
vmin = vscan["minimum"];
|
||||
vmax = vscan["maximum"];
|
||||
}
|
||||
else
|
||||
{
|
||||
hscan = led["h"].toObject();
|
||||
vscan = led["v"].toObject();
|
||||
hmin = hscan["min"];
|
||||
hmax = hscan["max"];
|
||||
vmin = vscan["min"];
|
||||
vmax = vscan["max"];
|
||||
}
|
||||
// append to led object
|
||||
nL["hmin"] = hmin;
|
||||
nL["hmax"] = hmax;
|
||||
nL["vmin"] = vmin;
|
||||
nL["vmax"] = vmax;
|
||||
newLedarr.append(nL);
|
||||
}
|
||||
// replace
|
||||
config["leds"] = newLedarr;
|
||||
migrated = true;
|
||||
Debug(_log,"LED Layout migrated");
|
||||
}
|
||||
}
|
||||
return migrated;
|
||||
}
|
||||
|
@@ -1,72 +1,64 @@
|
||||
{
|
||||
"type":"array",
|
||||
"required":true,
|
||||
"minItems":1,
|
||||
"items":
|
||||
{
|
||||
"type":"object",
|
||||
"required" : true,
|
||||
"properties":
|
||||
{
|
||||
"h":
|
||||
{
|
||||
"type":"object",
|
||||
"required" : true,
|
||||
"properties":
|
||||
{
|
||||
"min":
|
||||
{
|
||||
"type":"number",
|
||||
"minimum" : 0,
|
||||
"maximum" : 1,
|
||||
"required":true,
|
||||
"default" : 0
|
||||
},
|
||||
"max":
|
||||
{
|
||||
"type":"number",
|
||||
"minimum" : 0,
|
||||
"maximum" : 1,
|
||||
"required":true,
|
||||
"default" : 0.1
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
"type": "array",
|
||||
"required": true,
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"properties": {
|
||||
"hmin": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"required": true,
|
||||
"default": 0
|
||||
},
|
||||
"v":
|
||||
{
|
||||
"type":"object",
|
||||
"required" : true,
|
||||
"properties":
|
||||
{
|
||||
"min":
|
||||
{
|
||||
"type":"number",
|
||||
"minimum" : 0,
|
||||
"maximum" : 1,
|
||||
"required":true,
|
||||
"default" : 0
|
||||
},
|
||||
"max":
|
||||
{
|
||||
"type":"number",
|
||||
"minimum" : 0,
|
||||
"maximum" : 1,
|
||||
"required":true,
|
||||
"default" : 0.1
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
"hmax": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"required": true,
|
||||
"default": 0.1
|
||||
},
|
||||
"colorOrder":
|
||||
{
|
||||
"vmin": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"required": true,
|
||||
"default": 0
|
||||
},
|
||||
"vmax": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"required": true,
|
||||
"default": 0.1
|
||||
},
|
||||
"colorOrder": {
|
||||
"type": "string",
|
||||
"enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"],
|
||||
"options" : {
|
||||
"enum_titles" : ["edt_conf_enum_rgb", "edt_conf_enum_bgr", "edt_conf_enum_rbg", "edt_conf_enum_brg", "edt_conf_enum_gbr", "edt_conf_enum_grb"]
|
||||
"enum": [
|
||||
"rgb",
|
||||
"bgr",
|
||||
"rbg",
|
||||
"brg",
|
||||
"gbr",
|
||||
"grb"
|
||||
],
|
||||
"options": {
|
||||
"enum_titles": [
|
||||
"edt_conf_enum_rgb",
|
||||
"edt_conf_enum_bgr",
|
||||
"edt_conf_enum_rbg",
|
||||
"edt_conf_enum_brg",
|
||||
"edt_conf_enum_gbr",
|
||||
"edt_conf_enum_grb"
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
@@ -119,10 +119,7 @@ void ProtoClientConnection::handleColorCommand(const proto::ColorRequest &messag
|
||||
// extract parameters
|
||||
int priority = message.priority();
|
||||
int duration = message.has_duration() ? message.duration() : -1;
|
||||
ColorRgb color;
|
||||
color.red = qRed(message.rgbcolor());
|
||||
color.green = qGreen(message.rgbcolor());
|
||||
color.blue = qBlue(message.rgbcolor());
|
||||
std::vector<ColorRgb> color{ ColorRgb{ uint8_t(qRed(message.rgbcolor())), uint8_t(qGreen(message.rgbcolor())), uint8_t(qBlue(message.rgbcolor())) } };
|
||||
|
||||
if (priority < 100 || priority >= 200)
|
||||
{
|
||||
@@ -202,7 +199,7 @@ void ProtoClientConnection::handleClearCommand(const proto::ClearRequest &messag
|
||||
void ProtoClientConnection::handleClearallCommand()
|
||||
{
|
||||
// clear all priority
|
||||
emit clearAllGlobalInput();
|
||||
emit clearGlobalInput(-1);
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
|
@@ -41,12 +41,7 @@ signals:
|
||||
///
|
||||
/// @brief Forward clear command to HyperionDaemon
|
||||
///
|
||||
void clearGlobalInput(const int priority);
|
||||
|
||||
///
|
||||
/// @brief Forward clearAll command to HyperionDaemon
|
||||
///
|
||||
void clearAllGlobalInput(bool forceClearAll=false);
|
||||
void clearGlobalInput(const int priority, bool forceClearAll=false);
|
||||
|
||||
///
|
||||
/// @brief forward prepared image to HyperionDaemon
|
||||
@@ -56,7 +51,7 @@ signals:
|
||||
///
|
||||
/// @brief Forward requested color
|
||||
///
|
||||
void setGlobalInputColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
|
||||
void setGlobalInputColor(const int priority, const std::vector<ColorRgb> &ledColor, const int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// @brief Emits whenever the client disconnected
|
||||
|
@@ -71,7 +71,6 @@ void ProtoServer::newConnection()
|
||||
connect(client, &ProtoClientConnection::clientDisconnected, this, &ProtoServer::clientDisconnected);
|
||||
connect(client, &ProtoClientConnection::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
|
||||
connect(client, &ProtoClientConnection::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
|
||||
connect(client, &ProtoClientConnection::clearAllGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput);
|
||||
connect(client, &ProtoClientConnection::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
|
||||
connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <QNetworkInterface>
|
||||
#include <QNetworkConfigurationManager>
|
||||
|
||||
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, QObject * parent)
|
||||
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, const QString& name, QObject * parent)
|
||||
: SSDPServer(parent)
|
||||
, _webserver(webserver)
|
||||
, _localAddress()
|
||||
@@ -17,6 +17,7 @@ SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const
|
||||
{
|
||||
setFlatBufPort(flatBufPort);
|
||||
setJsonServerPort(jsonServerPort);
|
||||
setHyperionName(name);
|
||||
}
|
||||
|
||||
SSDPHandler::~SSDPHandler()
|
||||
@@ -76,6 +77,15 @@ void SSDPHandler::handleSettingsUpdate(const settings::type& type, const QJsonDo
|
||||
SSDPServer::setJsonServerPort(obj["port"].toInt());
|
||||
}
|
||||
}
|
||||
|
||||
if (type == settings::GENERAL)
|
||||
{
|
||||
const QJsonObject &obj = config.object();
|
||||
if (obj["name"].toString() != SSDPServer::getHyperionName())
|
||||
{
|
||||
SSDPServer::setHyperionName(obj["name"].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SSDPHandler::handleWebServerStateChange(const bool newState)
|
||||
|
@@ -28,6 +28,7 @@ static const QString UPNP_ALIVE_MESSAGE = "NOTIFY * HTTP/1.1\r\n"
|
||||
"USN: uuid:%5\r\n"
|
||||
"HYPERION-FBS-PORT: %6\r\n"
|
||||
"HYPERION-JSS-PORT: %7\r\n"
|
||||
"HYPERION-NAME: %8\r\n"
|
||||
"\r\n";
|
||||
|
||||
// Implement ssdp:update as per spec 1.1, section 1.2.4
|
||||
@@ -72,6 +73,7 @@ static const QString UPNP_MSEARCH_RESPONSE = "HTTP/1.1 200 OK\r\n"
|
||||
"USN: uuid:%6\r\n"
|
||||
"HYPERION-FBS-PORT: %7\r\n"
|
||||
"HYPERION-JSS-PORT: %8\r\n"
|
||||
"HYPERION-NAME: %9\r\n"
|
||||
"\r\n";
|
||||
|
||||
SSDPServer::SSDPServer(QObject * parent)
|
||||
@@ -172,7 +174,8 @@ void SSDPServer::sendMSearchResponse(const QString& st, const QString& senderIp,
|
||||
, st
|
||||
, _uuid
|
||||
, _fbsPort
|
||||
, _jssPort );
|
||||
, _jssPort
|
||||
, _name );
|
||||
|
||||
_udpSocket->writeDatagram(message.toUtf8(),
|
||||
QHostAddress(senderIp),
|
||||
@@ -203,7 +206,8 @@ void SSDPServer::sendAlive(const QString& st)
|
||||
, _serverHeader
|
||||
, tempUSN
|
||||
, _fbsPort
|
||||
, _jssPort );
|
||||
, _jssPort
|
||||
, _name );
|
||||
|
||||
// we repeat 3 times
|
||||
quint8 rep = 0;
|
||||
|
Reference in New Issue
Block a user