mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Created first draft of 'hyperion-d'.
This commit is contained in:
parent
b411b166ae
commit
7bdd10859e
@ -4,18 +4,30 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
// Forward class declaration
|
// Utils includes
|
||||||
class ImageProcessor;
|
#include <utils/RgbColor.h>
|
||||||
class DispmanxFrameGrabber;
|
|
||||||
|
|
||||||
|
// Forward class declaration
|
||||||
|
class DispmanxFrameGrabber;
|
||||||
|
class Hyperion;
|
||||||
|
class ImageProcessor;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The DispmanxWrapper uses an instance of the DispmanxFrameGrabber to obtain RgbImage's from the
|
||||||
|
/// displayed content. This RgbImage is processed to a RgbColor for each led and commmited to the
|
||||||
|
/// attached Hyperion.
|
||||||
|
///
|
||||||
class DispmanxWrapper: public QObject
|
class DispmanxWrapper: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DispmanxWrapper();
|
DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, Hyperion * hyperion);
|
||||||
|
|
||||||
virtual ~DispmanxWrapper();
|
virtual ~DispmanxWrapper();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void ledValues(const unsigned priority, const std::vector<RgbColor> ledColors, const unsigned timeout_ms);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
@ -24,9 +36,17 @@ public slots:
|
|||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const int _updateInterval_ms;
|
||||||
|
const int _timeout_ms;
|
||||||
|
|
||||||
|
|
||||||
QTimer _timer;
|
QTimer _timer;
|
||||||
|
|
||||||
DispmanxFrameGrabber* _frameGrabber;
|
DispmanxFrameGrabber * _frameGrabber;
|
||||||
ImageProcessor* _processor;
|
ImageProcessor * _processor;
|
||||||
|
|
||||||
|
std::vector<RgbColor> _ledColors;
|
||||||
|
|
||||||
|
Hyperion * _hyperion;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,9 @@ public:
|
|||||||
|
|
||||||
~Hyperion();
|
~Hyperion();
|
||||||
|
|
||||||
void setValue(int priority, std::vector<RgbColor> &ledColors);
|
unsigned getLedCount() const;
|
||||||
|
|
||||||
|
void setValue(int priority, std::vector<RgbColor> &ledColors, const int timeout_ms);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyTransform(std::vector<RgbColor>& colors) const;
|
void applyTransform(std::vector<RgbColor>& colors) const;
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
// Copyright (c) 2012 TNO, The Netherlands.
|
|
||||||
//
|
|
||||||
// This file contains information proprietary to TNO.
|
|
||||||
//
|
|
||||||
// Any disclosure or use of this information or any reproduction of this document or any part thereof for
|
|
||||||
// other than the specified purpose for which it is intended is expressly prohibited except as TNO may
|
|
||||||
// otherwise agree to in writing.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// stl includes
|
// stl includes
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
#include <hyperion/DispmanxWrapper.h>
|
#include <hyperion/DispmanxWrapper.h>
|
||||||
|
#include <hyperion/Hyperion.h>
|
||||||
#include <hyperion/ImageProcessorFactory.h>
|
#include <hyperion/ImageProcessorFactory.h>
|
||||||
#include <hyperion/ImageProcessor.h>
|
#include <hyperion/ImageProcessor.h>
|
||||||
|
|
||||||
@ -11,39 +12,53 @@
|
|||||||
// Local-Hyperion includes
|
// Local-Hyperion includes
|
||||||
#include "DispmanxFrameGrabber.h"
|
#include "DispmanxFrameGrabber.h"
|
||||||
|
|
||||||
DispmanxWrapper::DispmanxWrapper() :
|
DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, Hyperion * hyperion) :
|
||||||
|
_updateInterval_ms(1000/updateRate_Hz),
|
||||||
|
_timeout_ms(2 * _updateInterval_ms),
|
||||||
_timer(),
|
_timer(),
|
||||||
_frameGrabber(new DispmanxFrameGrabber(64, 64)),
|
_frameGrabber(new DispmanxFrameGrabber(grabWidth, grabHeight)),
|
||||||
_processor(ImageProcessorFactory::getInstance().newImageProcessor())
|
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
|
||||||
|
_ledColors(hyperion->getLedCount(), RgbColor::BLACK),
|
||||||
|
_hyperion(hyperion)
|
||||||
{
|
{
|
||||||
_timer.setInterval(100);
|
// Configure the timer to generate events every n milliseconds
|
||||||
|
_timer.setInterval(_updateInterval_ms);
|
||||||
_timer.setSingleShot(false);
|
_timer.setSingleShot(false);
|
||||||
|
|
||||||
_processor->setSize(64, 64);
|
_processor->setSize(grabWidth, grabHeight);
|
||||||
|
|
||||||
|
// Connect the QTimer to this
|
||||||
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(action()));
|
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(action()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DispmanxWrapper::~DispmanxWrapper()
|
DispmanxWrapper::~DispmanxWrapper()
|
||||||
{
|
{
|
||||||
|
// Cleanup used resources (ImageProcessor and FrameGrabber)
|
||||||
delete _processor;
|
delete _processor;
|
||||||
delete _frameGrabber;
|
delete _frameGrabber;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DispmanxWrapper::start()
|
void DispmanxWrapper::start()
|
||||||
{
|
{
|
||||||
|
// Start the timer with the pre configured interval
|
||||||
_timer.start();
|
_timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DispmanxWrapper::action()
|
void DispmanxWrapper::action()
|
||||||
{
|
{
|
||||||
qDebug() << "[" << QDateTime::currentDateTimeUtc() << "] Grabbing frame";
|
// Obtain reference of the buffer-image used by the processor
|
||||||
RgbImage image(64, 64);
|
RgbImage & image = _processor->image();
|
||||||
|
|
||||||
|
// Grab frame into the allocated image
|
||||||
_frameGrabber->grabFrame(image);
|
_frameGrabber->grabFrame(image);
|
||||||
|
|
||||||
//_processor->
|
_processor->inplace_process(_ledColors);
|
||||||
|
|
||||||
|
const int _priority = 100;
|
||||||
|
_hyperion->setValue(_priority, _ledColors, _timeout_ms);
|
||||||
}
|
}
|
||||||
void DispmanxWrapper::stop()
|
void DispmanxWrapper::stop()
|
||||||
{
|
{
|
||||||
|
// Stop the timer, effectivly stopping the process
|
||||||
_timer.stop();
|
_timer.stop();
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,12 @@ Hyperion::~Hyperion()
|
|||||||
delete mRedTransform;
|
delete mRedTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hyperion::setValue(int priority, std::vector<RgbColor>& ledColors)
|
unsigned Hyperion::getLedCount() const
|
||||||
|
{
|
||||||
|
return mLedString.leds().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Hyperion::setValue(int priority, std::vector<RgbColor>& ledColors, const int timeout_ms)
|
||||||
{
|
{
|
||||||
// Apply the transform to each led and color-channel
|
// Apply the transform to each led and color-channel
|
||||||
for (RgbColor& color : ledColors)
|
for (RgbColor& color : ledColors)
|
||||||
|
@ -2,15 +2,33 @@
|
|||||||
// QT includes
|
// QT includes
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
// Json-Schema includes
|
||||||
|
#include <utils/jsonschema/JsonFactory.h>
|
||||||
|
|
||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
#include <hyperion/DispmanxWrapper.h>
|
#include <hyperion/DispmanxWrapper.h>
|
||||||
|
#include <hyperion/Hyperion.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
|
// Select config and schema file
|
||||||
|
const std::string homeDir = getenv("RASPILIGHT_HOME");
|
||||||
|
const std::string schemaFile = homeDir + "/hyperion.schema.json";
|
||||||
|
const std::string configFile = homeDir + "/hyperion.config.json";
|
||||||
|
|
||||||
DispmanxWrapper dispmanx;
|
// Load configuration and check against the schema at the same time
|
||||||
|
Json::Value config;
|
||||||
|
if (JsonFactory::load(schemaFile, configFile, config) < 0)
|
||||||
|
{
|
||||||
|
std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Hyperion hyperion(config);
|
||||||
|
|
||||||
|
DispmanxWrapper dispmanx(64, 64, 10, &hyperion);
|
||||||
dispmanx.start();
|
dispmanx.start();
|
||||||
|
|
||||||
app.exec();
|
app.exec();
|
||||||
|
Loading…
Reference in New Issue
Block a user