mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	* commit debug code to save it due to merge * migrate first devices to new device registry and configure on runtime * fadecandy and rs232 resets device if config is set * try to hunt crash on osx * test commit if this works with osx * refactor spi devices * cleanup * refactor leddevices file, tinkerforge and ws2812b * refactor raw usb devices * refactor udp devices * - add tpm2net driver - remove old udp driver from build (files left in place for reference for new udp driver) - json serverinfo shows available leddevices * finish rework part 2 of leddevices * add schemas for leddevices. currently only compiled in, but not usedx
		
			
				
	
	
		
			71 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| 
 | |
| #pragma once
 | |
| 
 | |
| // STL includes
 | |
| #include <cstdio>
 | |
| 
 | |
| // jsoncpp includes
 | |
| #include <json/json.h>
 | |
| 
 | |
| // Hyperion-Leddevice includes
 | |
| #include <leddevice/LedDevice.h>
 | |
| 
 | |
| class LedDevicePiBlaster : public LedDevice
 | |
| {
 | |
| public:
 | |
| 	///
 | |
| 	/// Constructs specific LedDevice
 | |
| 	///
 | |
| 	/// @param deviceConfig json device config
 | |
| 	///
 | |
| 	LedDevicePiBlaster(const Json::Value &deviceConfig);
 | |
| 
 | |
| 	virtual ~LedDevicePiBlaster();
 | |
| 
 | |
| 	///
 | |
| 	/// Sets configuration
 | |
| 	///
 | |
| 	/// @param deviceConfig the json device config
 | |
| 	/// @return true if success
 | |
| 	bool setConfig(const Json::Value &deviceConfig);
 | |
| 
 | |
| 	/// constructs leddevice
 | |
| 	static LedDevice* construct(const Json::Value &deviceConfig);
 | |
| 	
 | |
| 	///
 | |
| 	/// Attempts to open the piblaster-device. This will only succeed if the device is not yet open
 | |
| 	/// and the device is available.
 | |
| 	///
 | |
| 	/// @return Zero on succes else negative
 | |
| 	///
 | |
| 	int open();
 | |
| 
 | |
| 	///
 | |
| 	/// Writes the colors to the PiBlaster device
 | |
| 	///
 | |
| 	/// @param ledValues The color value for each led
 | |
| 	///
 | |
| 	/// @return Zero on success else negative
 | |
| 	///
 | |
| 	int write(const std::vector<ColorRgb> &ledValues);
 | |
| 
 | |
| 	///
 | |
| 	/// Switches off the leds
 | |
| 	///
 | |
| 	/// @return Zero on success else negative
 | |
| 	///
 | |
| 	int switchOff();
 | |
| 
 | |
| private:
 | |
| 
 | |
| 	/// The name of the output device (very likely '/dev/pi-blaster')
 | |
| 	std::string _deviceName;
 | |
| 
 | |
| 	int _gpio_to_led[64];
 | |
| 	char _gpio_to_color[64];
 | |
| 
 | |
| 	/// File-Pointer to the PiBlaster device
 | |
| 	FILE * _fid;
 | |
| 
 | |
| };
 |