2013-08-13 11:10:45 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
// QT includes
|
|
|
|
#include <QMap>
|
|
|
|
|
|
|
|
// Utils includes
|
|
|
|
#include <utils/RgbColor.h>
|
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/LedDevice.h>
|
|
|
|
|
|
|
|
class PriorityMuxer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct InputInfo
|
|
|
|
{
|
|
|
|
int priority;
|
|
|
|
|
|
|
|
int64_t timeoutTime_ms;
|
|
|
|
std::vector<RgbColor> ledColors;
|
|
|
|
};
|
|
|
|
|
2013-08-18 13:33:56 +02:00
|
|
|
PriorityMuxer(int ledCount);
|
2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
~PriorityMuxer();
|
|
|
|
|
|
|
|
int getCurrentPriority() const;
|
|
|
|
|
|
|
|
bool hasPriority(const int priority) const;
|
|
|
|
|
|
|
|
QList<int> getPriorities() const;
|
|
|
|
|
|
|
|
const InputInfo& getInputInfo(const int priority) const;
|
|
|
|
|
|
|
|
void setInput(const int priority, const std::vector<RgbColor>& ledColors, const int64_t timeoutTime_ms=-1);
|
|
|
|
|
|
|
|
void clearInput(const int priority);
|
|
|
|
|
|
|
|
void clearAll();
|
|
|
|
|
|
|
|
void setCurrentTime(const int64_t& now);
|
|
|
|
|
|
|
|
private:
|
2013-08-18 13:33:56 +02:00
|
|
|
int _currentPriority;
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2013-08-18 13:33:56 +02:00
|
|
|
QMap<int, InputInfo> _activeInputs;
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2013-08-18 13:33:56 +02:00
|
|
|
InputInfo _lowestPriorityInfo;
|
|
|
|
|
|
|
|
const static int LOWEST_PRIORITY = std::numeric_limits<int>::max();
|
2013-08-13 11:10:45 +02:00
|
|
|
};
|