Provide a lowest permissible interval time to effects and limit the update rate of selected effects

This commit is contained in:
Lord-Grey
2024-11-30 22:08:41 +01:00
parent ee48f0c9b3
commit fb434dc492
16 changed files with 58 additions and 4 deletions

View File

@@ -13,6 +13,11 @@
// python utils
#include <python/PythonProgram.h>
// Constants
namespace {
int DEFAULT_MAX_UPDATE_RATE_HZ { 200 };
} //End of constants
Effect::Effect(Hyperion *hyperion, int priority, int timeout, const QString &script, const QString &name, const QJsonObject &args, const QString &imageData)
: QThread()
, _hyperion(hyperion)
@@ -27,6 +32,7 @@ Effect::Effect(Hyperion *hyperion, int priority, int timeout, const QString &scr
, _interupt(false)
, _imageSize(hyperion->getLedGridSize())
, _image(_imageSize,QImage::Format_ARGB32_Premultiplied)
, _lowestUpdateIntervalInSeconds(1/static_cast<double>(DEFAULT_MAX_UPDATE_RATE_HZ))
{
_colors.resize(_hyperion->getLedCount());
_colors.fill(ColorRgb::BLACK);

View File

@@ -123,6 +123,7 @@ PyMethodDef EffectModule::effectMethods[] = {
{"imageCOffset" , EffectModule::wrapImageCOffset , METH_VARARGS, "Add offset to the coordinate system"},
{"imageCShear" , EffectModule::wrapImageCShear , METH_VARARGS, "Shear of coordinate system by the given horizontal/vertical axis"},
{"imageResetT" , EffectModule::wrapImageResetT , METH_NOARGS, "Resets all coords modifications (rotate,offset,shear)"},
{"lowestUpdateInterval" , EffectModule::wrapLowestUpdateInterval , METH_NOARGS, "Gets the lowest permissible interval time in seconds"},
{NULL, NULL, 0, NULL}
};
@@ -1045,3 +1046,10 @@ PyObject* EffectModule::wrapImageResetT(PyObject *self, PyObject *args)
getEffect()->_painter->resetTransform();
Py_RETURN_NONE;
}
PyObject* EffectModule::wrapLowestUpdateInterval(PyObject* self, PyObject* args)
{
qDebug() << "_lowestUpdateIntervalInSeconds: " << getEffect()->_lowestUpdateIntervalInSeconds;
return Py_BuildValue("d", getEffect()->_lowestUpdateIntervalInSeconds);
}