Fix 1181 - Effects were not started from tray (#1199)

* Fix 1181, add constants and defaults

* Include #1195 changes
This commit is contained in:
LordGrey
2021-03-19 22:52:41 +01:00
committed by GitHub
parent 41af5c1b9e
commit 94d9b02734
12 changed files with 40 additions and 98 deletions

View File

@@ -12,6 +12,8 @@
// python utils
#include <python/PythonProgram.h>
const int Effect::ENDLESS = -1;
Effect::Effect(Hyperion *hyperion, int priority, int timeout, const QString &script, const QString &name, const QJsonObject &args, const QString &imageData)
: QThread()
, _hyperion(hyperion)
@@ -22,7 +24,7 @@ Effect::Effect(Hyperion *hyperion, int priority, int timeout, const QString &scr
, _args(args)
, _imageData(imageData)
, _endTime(-1)
, _colors()
, _interupt(false)
, _imageSize(hyperion->getLedGridSize())
, _image(_imageSize,QImage::Format_ARGB32_Premultiplied)
{
@@ -49,21 +51,20 @@ Effect::~Effect()
bool Effect::isInterruptionRequested()
{
return _interupt || getRemaining() < 0;
return _interupt || getRemaining() < ENDLESS;
}
int Effect::getRemaining()
int Effect::getRemaining() const
{
// determine the timeout
int timeout = _timeout;
if (timeout > 0)
{
timeout = _endTime - QDateTime::currentMSecsSinceEpoch();
timeout = static_cast<int>( _endTime - QDateTime::currentMSecsSinceEpoch());
return timeout;
}
return timeout;
return ENDLESS;
}
void Effect::setModuleParameters()

View File

@@ -19,8 +19,6 @@
EffectEngine::EffectEngine(Hyperion * hyperion)
: _hyperion(hyperion)
, _availableEffects()
, _activeEffects()
, _log(Logger::getInstance("EFFECTENGINE"))
, _effectFileHandler(EffectFileHandler::getInstance())
{
@@ -202,7 +200,7 @@ void EffectEngine::allChannelsCleared()
{
for (Effect * effect : _activeEffects)
{
if (effect->getPriority() != 254 && !effect->isInterruptionRequested())
if (effect->getPriority() != PriorityMuxer::BG_PRIORITY && !effect->isInterruptionRequested())
{
effect->requestInterruption();
}

View File

@@ -121,9 +121,6 @@ PyMethodDef EffectModule::effectMethods[] = {
PyObject* EffectModule::wrapSetColor(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
// check the number of arguments
int argCount = PyTuple_Size(args);
if (argCount == 3)
@@ -182,9 +179,6 @@ PyObject* EffectModule::wrapSetColor(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapSetImage(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
// bytearray of values
int width, height;
PyObject * bytearray = nullptr;
@@ -225,9 +219,6 @@ PyObject* EffectModule::wrapSetImage(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapGetImage(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
QString file;
QBuffer buffer;
QImageReader reader;
@@ -309,9 +300,6 @@ PyObject* EffectModule::wrapAbort(PyObject *self, PyObject *)
PyObject* EffectModule::wrapImageShow(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int imgId = -1;
bool argsOk = (argCount == 0);
@@ -352,9 +340,6 @@ PyObject* EffectModule::wrapImageShow(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageLinearGradient(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
PyObject * bytearray = nullptr;
int startRX = 0;
@@ -422,9 +407,6 @@ PyObject* EffectModule::wrapImageLinearGradient(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageConicalGradient(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
PyObject * bytearray = nullptr;
int centerX, centerY, angle;
@@ -491,9 +473,6 @@ PyObject* EffectModule::wrapImageConicalGradient(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageRadialGradient(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
PyObject * bytearray = nullptr;
int centerX, centerY, radius, focalX, focalY, focalRadius, spread;
@@ -572,9 +551,6 @@ PyObject* EffectModule::wrapImageRadialGradient(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageDrawPolygon(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
PyObject * bytearray = nullptr;
int argCount = PyTuple_Size(args);
@@ -633,9 +609,6 @@ PyObject* EffectModule::wrapImageDrawPolygon(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageDrawPie(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
PyObject * bytearray = nullptr;
QString brush;
@@ -730,9 +703,6 @@ PyObject* EffectModule::wrapImageDrawPie(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageSolidFill(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int r, g, b;
int a = 255;
@@ -772,9 +742,6 @@ PyObject* EffectModule::wrapImageSolidFill(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageDrawLine(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int r, g, b;
int a = 255;
@@ -813,9 +780,6 @@ PyObject* EffectModule::wrapImageDrawLine(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageDrawPoint(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int r, g, b, x, y;
int a = 255;
@@ -849,9 +813,6 @@ PyObject* EffectModule::wrapImageDrawPoint(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageDrawRect(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int r, g, b;
int a = 255;
@@ -891,9 +852,6 @@ PyObject* EffectModule::wrapImageDrawRect(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageSetPixel(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int r, g, b, x, y;
@@ -909,9 +867,6 @@ PyObject* EffectModule::wrapImageSetPixel(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageGetPixel(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int x, y;
@@ -925,9 +880,6 @@ PyObject* EffectModule::wrapImageGetPixel(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageSave(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
QImage img(getEffect()->_image.copy());
getEffect()->_imageStack.append(img);
@@ -936,9 +888,6 @@ PyObject* EffectModule::wrapImageSave(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageMinSize(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int w, h;
int width = getEffect()->_imageSize.width();
@@ -961,25 +910,16 @@ PyObject* EffectModule::wrapImageMinSize(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageWidth(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
return Py_BuildValue("i", getEffect()->_imageSize.width());
}
PyObject* EffectModule::wrapImageHeight(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
return Py_BuildValue("i", getEffect()->_imageSize.height());
}
PyObject* EffectModule::wrapImageCRotate(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int argCount = PyTuple_Size(args);
int angle;
@@ -994,9 +934,6 @@ PyObject* EffectModule::wrapImageCRotate(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageCOffset(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int offsetX = 0;
int offsetY = 0;
int argCount = PyTuple_Size(args);
@@ -1012,9 +949,6 @@ PyObject* EffectModule::wrapImageCOffset(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageCShear(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
int sh,sv;
int argCount = PyTuple_Size(args);
@@ -1028,9 +962,6 @@ PyObject* EffectModule::wrapImageCShear(PyObject *self, PyObject *args)
PyObject* EffectModule::wrapImageResetT(PyObject *self, PyObject *args)
{
// check if we have aborted already
if (getEffect()->isInterruptionRequested()) Py_RETURN_NONE;
getEffect()->_painter->resetTransform();
Py_RETURN_NONE;
}

View File

@@ -13,6 +13,8 @@
// utils
#include <utils/Logger.h>
const int PriorityMuxer::FG_PRIORITY = 1;
const int PriorityMuxer::BG_PRIORITY = 254;
const int PriorityMuxer::LOWEST_PRIORITY = std::numeric_limits<uint8_t>::max();
PriorityMuxer::PriorityMuxer(int ledCount, QObject * parent)
@@ -322,7 +324,7 @@ void PriorityMuxer::setCurrentTime()
newPriority = qMin(newPriority, infoIt->priority);
// call timeTrigger when effect or color is running with timeout > 0, blacklist prio 255
if(infoIt->priority < 254 && infoIt->timeoutTime_ms > 0 && (infoIt->componentId == hyperion::COMP_EFFECT || infoIt->componentId == hyperion::COMP_COLOR || infoIt->componentId == hyperion::COMP_IMAGE))
if(infoIt->priority < BG_PRIORITY && infoIt->timeoutTime_ms > 0 && (infoIt->componentId == hyperion::COMP_EFFECT || infoIt->componentId == hyperion::COMP_COLOR || infoIt->componentId == hyperion::COMP_IMAGE))
emit signalTimeTrigger(); // as signal to prevent Threading issues
++infoIt;