mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Clear effects if a setColor comes from another source
Former-commit-id: 43084eeee26ee233ac1f0c71d6782b64b154f0da
This commit is contained in:
parent
9872d8f02b
commit
f1acf5a9e4
@ -105,7 +105,7 @@ public slots:
|
|||||||
/// @param[in] ledColor The color to write to the leds
|
/// @param[in] ledColor The color to write to the leds
|
||||||
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
|
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
|
||||||
///
|
///
|
||||||
void setColor(int priority, const ColorRgb &ledColor, const int timeout_ms);
|
void setColor(int priority, const ColorRgb &ledColor, const int timeout_ms, bool clearEffects = true);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Writes the given colors to all leds for the given time and priority
|
/// Writes the given colors to all leds for the given time and priority
|
||||||
@ -114,7 +114,7 @@ public slots:
|
|||||||
/// @param[in] ledColors The colors to write to the leds
|
/// @param[in] ledColors The colors to write to the leds
|
||||||
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
|
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
|
||||||
///
|
///
|
||||||
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms);
|
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects = true);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the list with unique transform identifiers
|
/// Returns the list with unique transform identifiers
|
||||||
|
@ -174,7 +174,7 @@ PyObject* Effect::wrapSetColor(PyObject *self, PyObject *args)
|
|||||||
if (PyArg_ParseTuple(args, "bbb", &color.red, &color.green, &color.blue))
|
if (PyArg_ParseTuple(args, "bbb", &color.red, &color.green, &color.blue))
|
||||||
{
|
{
|
||||||
std::fill(effect->_colors.begin(), effect->_colors.end(), color);
|
std::fill(effect->_colors.begin(), effect->_colors.end(), color);
|
||||||
effect->setColors(effect->_priority, effect->_colors, timeout);
|
effect->setColors(effect->_priority, effect->_colors, timeout, false);
|
||||||
return Py_BuildValue("");
|
return Py_BuildValue("");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -195,7 +195,7 @@ PyObject* Effect::wrapSetColor(PyObject *self, PyObject *args)
|
|||||||
{
|
{
|
||||||
char * data = PyByteArray_AS_STRING(bytearray);
|
char * data = PyByteArray_AS_STRING(bytearray);
|
||||||
memcpy(effect->_colors.data(), data, length);
|
memcpy(effect->_colors.data(), data, length);
|
||||||
effect->setColors(effect->_priority, effect->_colors, timeout);
|
effect->setColors(effect->_priority, effect->_colors, timeout, false);
|
||||||
return Py_BuildValue("");
|
return Py_BuildValue("");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -265,7 +265,7 @@ PyObject* Effect::wrapSetImage(PyObject *self, PyObject *args)
|
|||||||
memcpy(image.memptr(), data, length);
|
memcpy(image.memptr(), data, length);
|
||||||
|
|
||||||
effect->_imageProcessor->process(image, effect->_colors);
|
effect->_imageProcessor->process(image, effect->_colors);
|
||||||
effect->setColors(effect->_priority, effect->_colors, timeout);
|
effect->setColors(effect->_priority, effect->_colors, timeout, false);
|
||||||
return Py_BuildValue("");
|
return Py_BuildValue("");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -29,7 +29,7 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
void effectFinished(Effect * effect);
|
void effectFinished(Effect * effect);
|
||||||
|
|
||||||
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms);
|
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void effectFinished();
|
void effectFinished();
|
||||||
|
@ -83,7 +83,7 @@ int EffectEngine::runEffectScript(const std::string &script, const Json::Value &
|
|||||||
|
|
||||||
// create the effect
|
// create the effect
|
||||||
Effect * effect = new Effect(priority, timeout, script, args);
|
Effect * effect = new Effect(priority, timeout, script, args);
|
||||||
connect(effect, SIGNAL(setColors(int,std::vector<ColorRgb>,int)), _hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int)), Qt::QueuedConnection);
|
connect(effect, SIGNAL(setColors(int,std::vector<ColorRgb>,int,bool)), _hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int,bool)), Qt::QueuedConnection);
|
||||||
connect(effect, SIGNAL(effectFinished(Effect*)), this, SLOT(effectFinished(Effect*)));
|
connect(effect, SIGNAL(effectFinished(Effect*)), this, SLOT(effectFinished(Effect*)));
|
||||||
_activeEffects.push_back(effect);
|
_activeEffects.push_back(effect);
|
||||||
|
|
||||||
|
@ -392,17 +392,23 @@ unsigned Hyperion::getLedCount() const
|
|||||||
return _ledString.leds().size();
|
return _ledString.leds().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_ms)
|
void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_ms, bool clearEffects)
|
||||||
{
|
{
|
||||||
// create led output
|
// create led output
|
||||||
std::vector<ColorRgb> ledColors(_ledString.leds().size(), color);
|
std::vector<ColorRgb> ledColors(_ledString.leds().size(), color);
|
||||||
|
|
||||||
// set colors
|
// set colors
|
||||||
setColors(priority, ledColors, timeout_ms);
|
setColors(priority, ledColors, timeout_ms, clearEffects);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms)
|
void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms, bool clearEffects)
|
||||||
{
|
{
|
||||||
|
// clear effects if this call does not come from an effect
|
||||||
|
if (clearEffects)
|
||||||
|
{
|
||||||
|
_effectEngine->channelCleared(priority);
|
||||||
|
}
|
||||||
|
|
||||||
if (timeout_ms > 0)
|
if (timeout_ms > 0)
|
||||||
{
|
{
|
||||||
const uint64_t timeoutTime = QDateTime::currentMSecsSinceEpoch() + timeout_ms;
|
const uint64_t timeoutTime = QDateTime::currentMSecsSinceEpoch() + timeout_ms;
|
||||||
|
Loading…
Reference in New Issue
Block a user