mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	* move setvideomode to common place * implement more croping and 3d support * more api unification * more refactoring * osx fix * next step * add a mock for osx grabber. Now it is possible to test compile on none osx platforms. * more unifications ... * remove obsolete includes and grabbers are not dyn allocated. dispmanx needs rework an probaly not work atm * first version of dispmanx mock. it compiles, but outputs a black image * now dispmanx mock works! * activate mocks in travis linux build prepare dispmanx to rgb image out * dispmanx now with image rgb output fix deadlock with w/h -1 in grabber v4l cleanups * fix json * fix some runtime stuff * Update FramebufferWrapper.cpp fix missing code * unify grabframe * 3d and croping for amlogic * fix setimage not working * make use of templates save some codelines * save more code lines
		
			
				
	
	
		
			156 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			156 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#pragma once
 | 
						|
 | 
						|
// STL includes
 | 
						|
#include <vector>
 | 
						|
#include <map>
 | 
						|
#include <cstdint>
 | 
						|
#include <limits>
 | 
						|
 | 
						|
// QT includes
 | 
						|
#include <QMap>
 | 
						|
#include <QObject>
 | 
						|
#include <QTimer>
 | 
						|
 | 
						|
// Utils includes
 | 
						|
#include <utils/ColorRgb.h>
 | 
						|
#include <utils/Components.h>
 | 
						|
 | 
						|
// global defines
 | 
						|
#define SMOOTHING_MODE_DEFAULT 0
 | 
						|
#define SMOOTHING_MODE_PAUSE   1
 | 
						|
 | 
						|
 | 
						|
///
 | 
						|
/// The PriorityMuxer handles the priority channels. Led values input is written to the priority map
 | 
						|
/// and the muxer keeps track of all active priorities. The current priority can be queried and per
 | 
						|
/// priority the led colors.
 | 
						|
///
 | 
						|
class PriorityMuxer : public QObject
 | 
						|
{
 | 
						|
	Q_OBJECT
 | 
						|
public:
 | 
						|
	///
 | 
						|
	/// The information structure for a single priority channel
 | 
						|
	///
 | 
						|
	struct InputInfo
 | 
						|
	{
 | 
						|
		/// The priority of this channel
 | 
						|
		int priority;
 | 
						|
 | 
						|
		/// The absolute timeout of the channel
 | 
						|
		int64_t timeoutTime_ms;
 | 
						|
		/// The colors for each led of the channel
 | 
						|
		std::vector<ColorRgb> ledColors;
 | 
						|
		/// The component
 | 
						|
		hyperion::Components componentId;
 | 
						|
		/// Who set it
 | 
						|
		QString origin;
 | 
						|
		/// id fo smoothing config
 | 
						|
		unsigned smooth_cfg;
 | 
						|
	};
 | 
						|
 | 
						|
	/// The lowest possible priority, which is used when no priority channels are active
 | 
						|
	const static int LOWEST_PRIORITY = std::numeric_limits<uint8_t>::max();
 | 
						|
 | 
						|
	///
 | 
						|
	/// Constructs the PriorityMuxer for the given number of leds (used to switch to black when
 | 
						|
	/// there are no priority channels
 | 
						|
	///
 | 
						|
	/// @param ledCount The number of leds
 | 
						|
	///
 | 
						|
	PriorityMuxer(int ledCount);
 | 
						|
 | 
						|
	///
 | 
						|
	/// Destructor
 | 
						|
	///
 | 
						|
	~PriorityMuxer();
 | 
						|
 | 
						|
	///
 | 
						|
	/// Returns the current priority
 | 
						|
	///
 | 
						|
	/// @return The current priority
 | 
						|
	///
 | 
						|
	int getCurrentPriority() const;
 | 
						|
 | 
						|
	///
 | 
						|
	/// Returns the state (enabled/disabled) of a specific priority channel
 | 
						|
	/// @param priority The priority channel
 | 
						|
	/// @return True if the priority channel exists else false
 | 
						|
	///
 | 
						|
	bool hasPriority(const int priority) const;
 | 
						|
 | 
						|
	///
 | 
						|
	/// Returns the number of active priorities
 | 
						|
	///
 | 
						|
	/// @return The list with active priorities
 | 
						|
	///
 | 
						|
	QList<int> getPriorities() const;
 | 
						|
 | 
						|
	///
 | 
						|
	/// Returns the information of a specified priority channel
 | 
						|
	///
 | 
						|
	/// @param priority The priority channel
 | 
						|
	///
 | 
						|
	/// @return The information for the specified priority channel
 | 
						|
	///
 | 
						|
	/// @throws std::runtime_error if the priority channel does not exist
 | 
						|
	///
 | 
						|
	const InputInfo& getInputInfo(const int priority) const;
 | 
						|
 | 
						|
	///
 | 
						|
	/// Sets/Updates the data for a priority channel
 | 
						|
	///
 | 
						|
	/// @param[in] priority The priority of the channel
 | 
						|
	/// @param[in] ledColors The led colors of the priority channel
 | 
						|
	/// @param[in] timeoutTime_ms The absolute timeout time of the channel
 | 
						|
	/// @param[in] component The component of the channel
 | 
						|
	/// @param[in] origin Who set the channel
 | 
						|
	///
 | 
						|
	void setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms=-1, hyperion::Components component=hyperion::COMP_INVALID, const QString origin="System", unsigned smooth_cfg=SMOOTHING_MODE_DEFAULT);
 | 
						|
 | 
						|
	///
 | 
						|
	/// Clears the specified priority channel
 | 
						|
	///
 | 
						|
	/// @param[in] priority  The priority of the channel to clear
 | 
						|
	///
 | 
						|
	void clearInput(const int priority);
 | 
						|
 | 
						|
	///
 | 
						|
	/// Clears all priority channels
 | 
						|
	///
 | 
						|
	void clearAll(bool forceClearAll=false);
 | 
						|
 | 
						|
	///
 | 
						|
	/// Updates the current time. Channels with a configured time out will be checked and cleared if
 | 
						|
	/// required.
 | 
						|
	///
 | 
						|
	/// @param[in] now The current time
 | 
						|
	///
 | 
						|
	void setCurrentTime(const int64_t& now);
 | 
						|
 | 
						|
signals:
 | 
						|
	///
 | 
						|
	/// Signal which is called, when a effect or color with timeout is running, once per second
 | 
						|
	///
 | 
						|
	void timerunner();
 | 
						|
 | 
						|
private slots:
 | 
						|
	///
 | 
						|
	/// Slots which is called to adapt to 1s interval for signal timerunner()
 | 
						|
	///
 | 
						|
	void emitReq();
 | 
						|
 | 
						|
private:
 | 
						|
	/// The current priority (lowest value in _activeInputs)
 | 
						|
	int _currentPriority;
 | 
						|
 | 
						|
	/// The mapping from priority channel to led-information
 | 
						|
	QMap<int, InputInfo> _activeInputs;
 | 
						|
 | 
						|
	/// The information of the lowest priority channel
 | 
						|
	InputInfo _lowestPriorityInfo;
 | 
						|
 | 
						|
	QTimer _timer;
 | 
						|
	QTimer _blockTimer;
 | 
						|
};
 |