Led count info added to Effect script

Former-commit-id: 36e85b2a33a89f3d91605ff1c1466d52779c510c
This commit is contained in:
Johan 2013-11-28 14:38:07 +01:00
parent c82954d82a
commit c18920b59e
4 changed files with 21 additions and 4 deletions

View File

@ -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.

View File

@ -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 *)

View File

@ -6,6 +6,9 @@
// Python includes
#include <Python.h>
// Hyperion includes
#include <hyperion/ImageProcessor.h>
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;
};

View File

@ -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