trigger muxer on color changes

Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
Paulchen-Panther 2019-07-21 19:06:47 +02:00
parent 6e6d6f5892
commit a3b326a18d
No known key found for this signature in database
GPG Key ID: 84E3B692456B6840
6 changed files with 16 additions and 30 deletions

View File

@ -300,6 +300,7 @@ $(document).ready(function() {
rgb = rgbT;
sendColor();
setStorage('rmcpcolor', hex);
updateInputSelect();
});
$("#reset_color").off().on("click", function(){

View File

@ -37,7 +37,7 @@ public:
/// @param inst The instance to check
/// @return True when running else false
///
const bool IsInstanceRunning(const quint8& inst) { return _runningInstances.contains(inst); };
bool IsInstanceRunning(const quint8& inst) { return _runningInstances.contains(inst); };
///
/// @brief Get a Hyperion instance by index

View File

@ -182,6 +182,11 @@ public:
///
void clearAll(bool forceClearAll=false);
///
/// @brief Queue a manual push where muxer doesn't recognize them (e.g. continous single color pushes)
///
void queuePush(void){ emit timeRunner(); };
signals:
///
/// @brief Signal which emits when a effect or color with timeout > -1 is running, once per second

View File

@ -210,35 +210,13 @@ void JsonAPI::handleColorCommand(const QJsonObject& message, const QString& comm
// extract parameters
int priority = message["priority"].toInt();
int duration = message["duration"].toInt(-1);
QString origin = message["origin"].toString("Empty") + "@"+_peerAddress;
const QString origin = message["origin"].toString("Empty") + "@"+_peerAddress;
std::vector<ColorRgb> colorData(_hyperion->getLedCount());
const QJsonArray & jsonColor = message["color"].toArray();
unsigned int i = 0;
for (; i < unsigned(jsonColor.size()/3) && i < _hyperion->getLedCount(); ++i)
{
colorData[i].red = uint8_t(jsonColor.at(3u*i).toInt());
colorData[i].green = uint8_t(jsonColor.at(3u*i+1u).toInt());
colorData[i].blue = uint8_t(jsonColor.at(3u*i+2u).toInt());
}
const ColorRgb color = {uint8_t(jsonColor.at(0).toInt()),uint8_t(jsonColor.at(1).toInt()),uint8_t(jsonColor.at(2).toInt())};
// copy full blocks of led colors
unsigned size = i;
while (i + size < _hyperion->getLedCount())
{
memcpy(&(colorData[i]), colorData.data(), size * sizeof(ColorRgb));
i += size;
}
// copy remaining block of led colors
if (i < _hyperion->getLedCount())
{
memcpy(&(colorData[i]), colorData.data(), (_hyperion->getLedCount()-i) * sizeof(ColorRgb));
}
// register and set color
_hyperion->registerInput(priority, hyperion::COMP_COLOR, origin);
_hyperion->setInput(priority, colorData, duration);
// set color
_hyperion->setColor(priority, color, duration, origin);
// send reply
sendSuccessReply(command, tan);

View File

@ -357,8 +357,10 @@ void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_m
// register color
registerInput(priority, hyperion::COMP_COLOR, origin);
// write color to muxer
// write color to muxer & queuePush
setInput(priority, ledColors, timeout_ms);
if(timeout_ms <= 0)
_muxer.queuePush();
}
const QStringList & Hyperion::getAdjustmentIds() const

View File

@ -155,8 +155,8 @@ bool HyperionIManager::deleteInstance(const quint8& inst)
if(!isInstAllowed(inst))
return false;
// stop it if required as blocking
stopInstance(inst, true);
// stop it if required as blocking and wait
if (stopInstance(inst, true));
if(_instanceTable->deleteInstance(inst))
{