diff --git a/include/hyperion/ImageProcessor.h b/include/hyperion/ImageProcessor.h index be87982e..6c4b4739 100644 --- a/include/hyperion/ImageProcessor.h +++ b/include/hyperion/ImageProcessor.h @@ -20,6 +20,11 @@ class ImageProcessor public: ~ImageProcessor(); + /// + /// Returns the number of attached leds + /// + unsigned getLedCount() const; + /// /// Specifies the width and height of 'incomming' images. This will resize the buffer-image to /// match the given size. diff --git a/libsrc/effectengine/Effect.cpp b/libsrc/effectengine/Effect.cpp index 498f0bde..791dd3b7 100644 --- a/libsrc/effectengine/Effect.cpp +++ b/libsrc/effectengine/Effect.cpp @@ -12,8 +12,8 @@ PyMethodDef Effect::effectMethods[] = { {"setColor", Effect::wrapSetColor, METH_VARARGS, "Set a new color for the leds."}, {"setImage", Effect::wrapSetImage, METH_VARARGS, "Set a new image to process and determine new led colors."}, - {"getLedCount", Effect::wrapGetLedCount, METH_VARARGS, "Get the number of avaliable led channels."}, - {"abort", Effect::wrapAbort, METH_NOARGS , "Check if the effect should abort execution."}, + {"getLedCount", Effect::wrapGetLedCount, METH_NOARGS, "Get the number of avaliable led channels."}, + {"abort", Effect::wrapAbort, METH_NOARGS, "Check if the effect should abort execution."}, {NULL, NULL, 0, NULL} }; @@ -24,7 +24,8 @@ Effect::Effect(int priority, int timeout) : _timeout(timeout), _endTime(-1), _interpreterThreadState(nullptr), - _abortRequested(false) + _abortRequested(false), + _imageProcessor(ImageProcessorFactory::getInstance().newImageProcessor()) { // connect the finished signal connect(this, SIGNAL(finished()), this, SLOT(effectFinished())); @@ -91,7 +92,7 @@ PyObject* Effect::wrapSetImage(PyObject *self, PyObject *args) PyObject* Effect::wrapGetLedCount(PyObject *self, PyObject *args) { Effect * effect = getEffect(self); - return Py_BuildValue("i", 42); + return Py_BuildValue("i", effect->_imageProcessor->getLedCount()); } PyObject* Effect::wrapAbort(PyObject *self, PyObject *) diff --git a/libsrc/effectengine/Effect.h b/libsrc/effectengine/Effect.h index 2521a967..0f45b1f8 100644 --- a/libsrc/effectengine/Effect.h +++ b/libsrc/effectengine/Effect.h @@ -6,6 +6,9 @@ // Python includes #include +// Hyperion includes +#include + class Effect : public QThread { Q_OBJECT @@ -46,4 +49,7 @@ private: PyThreadState * _interpreterThreadState; bool _abortRequested; + + /// The processor for translating images to led-values + ImageProcessor * _imageProcessor; }; diff --git a/libsrc/hyperion/ImageProcessor.cpp b/libsrc/hyperion/ImageProcessor.cpp index d3bfba3d..0c551b50 100644 --- a/libsrc/hyperion/ImageProcessor.cpp +++ b/libsrc/hyperion/ImageProcessor.cpp @@ -23,6 +23,11 @@ ImageProcessor::~ImageProcessor() delete _borderProcessor; } +unsigned ImageProcessor::getLedCount() const +{ + return mLedString.leds().size(); +} + void ImageProcessor::setSize(const unsigned width, const unsigned height) { // Check if the existing buffer-image is already the correct dimensions