hyperion.ng/include/hyperion/Hyperion.h

172 lines
4.6 KiB
C
Raw Normal View History

#pragma once
// stl includes
#include <list>
// QT includes
#include <QObject>
#include <QTimer>
// hyperion-utils includes
#include <utils/Image.h>
// Hyperion includes
#include <hyperion/LedString.h>
#include <hyperion/LedDevice.h>
#include <hyperion/PriorityMuxer.h>
// Forward class declaration
class ColorTransform;
class HsvTransform;
class RgbChannelTransform;
class MultiColorTransform;
2013-09-06 21:26:58 +02:00
///
/// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through
/// the priority muxer.
///
class Hyperion : public QObject
{
Q_OBJECT
public:
2013-09-06 21:26:58 +02:00
/// Type definition of the info structure used by the priority muxer
typedef PriorityMuxer::InputInfo InputInfo;
2013-09-06 21:26:58 +02:00
///
/// RGB-Color channel enumeration
///
enum RgbChannel
{
RED, GREEN, BLUE, INVALID
};
2013-09-06 21:26:58 +02:00
///
/// Enumeration of the possible color (color-channel) transforms
///
enum Transform
{
SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
};
/// Enumeration containing the possible orders of device color byte data
enum ColorOrder
{
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR
};
2013-09-06 21:26:58 +02:00
///
/// Constructs the Hyperion instance based on the given Json configuration
///
/// @param[in] jsonConfig The Json configuration
///
Hyperion(const Json::Value& jsonConfig);
2013-09-06 21:26:58 +02:00
///
/// Destructor; cleans up resourcess
///
~Hyperion();
2013-09-06 21:26:58 +02:00
///
/// Returns the number of attached leds
///
2013-08-14 10:54:49 +02:00
unsigned getLedCount() const;
2013-09-06 21:26:58 +02:00
///
/// Writes a single color to all the leds for the given time and priority
///
/// @param[in] priority The priority of the written color
/// @param[in] ledColor The color to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
///
void setColor(int priority, const ColorRgb &ledColor, const int timeout_ms);
2013-08-18 13:33:56 +02:00
2013-09-06 21:26:58 +02:00
///
/// Writes the given colors to all leds for the given time and priority
///
/// @param[in] priority The priority of the written colors
/// @param[in] ledColors The colors to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
///
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms);
2013-08-18 13:33:56 +02:00
2013-09-06 21:26:58 +02:00
///
/// Returns the list with unique transform identifiers
/// @return The list with transform identifiers
2013-09-06 21:26:58 +02:00
///
const std::vector<std::string> & getTransformIds() const;
///
/// Returns the ColorTransform with the given identifier
/// @return The transform with the given identifier (or nullptr if the identifier does not exist)
2013-09-06 21:26:58 +02:00
///
ColorTransform * getTransform(const std::string& id);
2013-09-06 21:26:58 +02:00
///
/// Clears the given priority channel. This will switch the led-colors to the colors of the next
/// lower priority channel (or off if no more channels are set)
///
/// @param[in] priority The priority channel
///
2013-08-18 13:33:56 +02:00
void clear(int priority);
2013-09-06 21:26:58 +02:00
///
/// Clears all priority channels. This will switch the leds off until a new priority is written.
///
2013-08-18 13:33:56 +02:00
void clearall();
2013-09-06 21:26:58 +02:00
///
/// Returns a list of active priorities
///
/// @return The list with priorities
///
QList<int> getActivePriorities() const;
2013-09-06 21:26:58 +02:00
///
/// Returns the information of a specific priorrity channel
///
/// @param[in] priority The priority channel
///
/// @return The information of the given
///
/// @throw std::runtime_error when the priority channel does not exist
///
const InputInfo& getPriorityInfo(const int priority) const;
static LedDevice * createDevice(const Json::Value & deviceConfig);
static ColorOrder createColorOrder(const Json::Value & deviceConfig);
static LedString createLedString(const Json::Value & ledsConfig);
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorTransformConfig);
static ColorTransform * createColorTransform(const Json::Value & transformConfig);
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig);
static RgbChannelTransform * createRgbChannelTransform(const Json::Value& colorConfig);
static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice);
private slots:
2013-09-06 21:26:58 +02:00
///
/// Updates the priority muxer with the current time and (re)writes the led color with applied
/// transforms.
///
void update();
private:
2013-09-06 21:26:58 +02:00
/// The specifiation of the led frame construction and picture integration
2013-08-18 13:33:56 +02:00
LedString _ledString;
2013-09-06 21:26:58 +02:00
/// The priority muxer
2013-08-18 13:33:56 +02:00
PriorityMuxer _muxer;
/// The transformation from raw colors to led colors
MultiColorTransform * _raw2ledTransform;
/// Value with the desired color byte order
ColorOrder _colorOrder;
2013-09-06 21:26:58 +02:00
/// The actual LedDevice
LedDevice * _device;
2013-09-06 21:26:58 +02:00
/// The timer for handling priority channel timeouts
QTimer _timer;
};