mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
parent
45bd23ca5c
commit
9475b93d9f
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Changed
|
||||
- Updated dependency rpi_ws281x to latest upstream
|
||||
- Fix High CPU load (RPI3B+) (#1013)
|
||||
|
||||
### Fixed
|
||||
- LED-Hue: Proper black in Entertainement mode if min brightness is set
|
||||
|
@ -44,10 +44,22 @@ public:
|
||||
void requestInterruption() { _interupt = true; }
|
||||
|
||||
///
|
||||
/// @brief Check if the interruption flag has been set
|
||||
/// @brief Check an interruption was requested.
|
||||
/// This can come from requestInterruption()
|
||||
/// or the effect's timeout expiring.
|
||||
///
|
||||
/// @return The flag state
|
||||
///
|
||||
bool isInterruptionRequested() { return _interupt; }
|
||||
bool isInterruptionRequested();
|
||||
|
||||
///
|
||||
/// @brief Get the remaining timeout, or 0 if there
|
||||
/// is no timeout for this effect.
|
||||
///
|
||||
/// @return The flag state
|
||||
///
|
||||
int getRemaining();
|
||||
|
||||
|
||||
QString getScript() const { return _script; }
|
||||
QString getName() const { return _name; }
|
||||
|
@ -47,6 +47,25 @@ Effect::~Effect()
|
||||
_imageStack.clear();
|
||||
}
|
||||
|
||||
bool Effect::isInterruptionRequested()
|
||||
{
|
||||
return _interupt || getRemaining() < 0;
|
||||
}
|
||||
|
||||
int Effect::getRemaining()
|
||||
{
|
||||
// determine the timeout
|
||||
int timeout = _timeout;
|
||||
|
||||
if (timeout > 0)
|
||||
{
|
||||
timeout = _endTime - QDateTime::currentMSecsSinceEpoch();
|
||||
return timeout;
|
||||
}
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
void Effect::setModuleParameters()
|
||||
{
|
||||
// import the buildtin Hyperion module
|
||||
|
@ -124,16 +124,6 @@ PyObject* EffectModule::wrapSetColor(PyObject *self, PyObject *args)
|
||||
// check if we have aborted already
|
||||
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
|
||||
|
||||
// determine the timeout
|
||||
int timeout = getEffect()->_timeout;
|
||||
if (timeout > 0)
|
||||
{
|
||||
timeout = getEffect()->_endTime - QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
// we are done if the time has passed
|
||||
if (timeout <= 0) Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
// check the number of arguments
|
||||
int argCount = PyTuple_Size(args);
|
||||
if (argCount == 3)
|
||||
@ -144,7 +134,7 @@ PyObject* EffectModule::wrapSetColor(PyObject *self, PyObject *args)
|
||||
{
|
||||
getEffect()->_colors.fill(color);
|
||||
QVector<ColorRgb> _cQV = getEffect()->_colors;
|
||||
emit getEffect()->setInput(getEffect()->_priority, std::vector<ColorRgb>( _cQV.begin(), _cQV.end() ), timeout, false);
|
||||
emit getEffect()->setInput(getEffect()->_priority, std::vector<ColorRgb>( _cQV.begin(), _cQV.end() ), getEffect()->getRemaining(), false);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
return nullptr;
|
||||
@ -163,7 +153,7 @@ PyObject* EffectModule::wrapSetColor(PyObject *self, PyObject *args)
|
||||
char * data = PyByteArray_AS_STRING(bytearray);
|
||||
memcpy(getEffect()->_colors.data(), data, length);
|
||||
QVector<ColorRgb> _cQV = getEffect()->_colors;
|
||||
emit getEffect()->setInput(getEffect()->_priority, std::vector<ColorRgb>( _cQV.begin(), _cQV.end() ), timeout, false);
|
||||
emit getEffect()->setInput(getEffect()->_priority, std::vector<ColorRgb>( _cQV.begin(), _cQV.end() ), getEffect()->getRemaining(), false);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
else
|
||||
@ -195,16 +185,6 @@ PyObject* EffectModule::wrapSetImage(PyObject *self, PyObject *args)
|
||||
// check if we have aborted already
|
||||
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
|
||||
|
||||
// determine the timeout
|
||||
int timeout = getEffect()->_timeout;
|
||||
if (timeout > 0)
|
||||
{
|
||||
timeout = getEffect()->_endTime - QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
// we are done if the time has passed
|
||||
if (timeout <= 0) Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
// bytearray of values
|
||||
int width, height;
|
||||
PyObject * bytearray = nullptr;
|
||||
@ -218,7 +198,7 @@ PyObject* EffectModule::wrapSetImage(PyObject *self, PyObject *args)
|
||||
Image<ColorRgb> image(width, height);
|
||||
char * data = PyByteArray_AS_STRING(bytearray);
|
||||
memcpy(image.memptr(), data, length);
|
||||
emit getEffect()->setInputImage(getEffect()->_priority, image, timeout, false);
|
||||
emit getEffect()->setInputImage(getEffect()->_priority, image, getEffect()->getRemaining(), false);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
else
|
||||
@ -332,16 +312,6 @@ PyObject* EffectModule::wrapImageShow(PyObject *self, PyObject *args)
|
||||
// check if we have aborted already
|
||||
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
|
||||
|
||||
// determine the timeout
|
||||
int timeout = getEffect()->_timeout;
|
||||
if (timeout > 0)
|
||||
{
|
||||
timeout = getEffect()->_endTime - QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
// we are done if the time has passed
|
||||
if (timeout <= 0) Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
int argCount = PyTuple_Size(args);
|
||||
int imgId = -1;
|
||||
bool argsOk = (argCount == 0);
|
||||
@ -375,7 +345,7 @@ PyObject* EffectModule::wrapImageShow(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
memcpy(image.memptr(), binaryImage.data(), binaryImage.size());
|
||||
emit getEffect()->setInputImage(getEffect()->_priority, image, timeout, false);
|
||||
emit getEffect()->setInputImage(getEffect()->_priority, image, getEffect()->getRemaining(), false);
|
||||
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user