1 #ifndef PHILIPS_HUE_DEVICE_H 2 #define PHILIPS_HUE_DEVICE_H 3 4 #include <SFML/System.hpp> 5 #include <SFML/Network.hpp> 6 #include <stdint.h> 7 #include "hardware/hardwareOutputDevice.h" 8 9 //The PhilipsHueDevice talks to a philips hue bridge. 10 //Documentation of the philips hue API is at: 11 // https://www.developers.meethue.com/documentation/getting-started 12 //The PhilipsHueDevice device creates 4 channels for each connected light. 13 //So the amount of available channels is amount of lights x4. 14 //The channels are: 15 // Brightness 16 // Saturation 17 // Hue 18 // Transition Time 19 class PhilipsHueDevice : public HardwareOutputDevice 20 { 21 public: 22 PhilipsHueDevice(); 23 virtual ~PhilipsHueDevice(); 24 25 //Configure the device. 26 // Parameter: "ip": IP address of the bridge. 27 // Parameter: "username": API username to use. If not set, will request a username from the bridge. 28 // Parameter: "userfile": Filename to store the username API in, if not set with the user parameter and username is requested from the bridge. 29 virtual bool configure(std::unordered_map<string, string> settings); 30 31 //Set a hardware channel output. Value is 0.0 to 1.0 for no to max output. 32 virtual void setChannelData(int channel, float value); 33 34 //Return the number of output channels supported by this device. 35 virtual int getChannelCount(); 36 37 private: 38 class LightInfo 39 { 40 public: LightInfo()41 LightInfo() : dirty(true), brightness(0), saturation(0), hue(0), transitiontime(0), laststate(0) {} 42 43 bool dirty; 44 int brightness; 45 int saturation; 46 int hue; 47 int transitiontime; 48 string laststate; 49 }; 50 51 sf::Thread update_thread; 52 sf::Mutex mutex; 53 std::vector<LightInfo> lights; 54 55 bool run_thread; 56 57 void updateLoop(); 58 59 string ip_address; 60 int port = 80; 61 string username; 62 string userfile; 63 int light_count; 64 }; 65 66 #endif//S_ACN_DMX_DEVICE_H 67