diff --git a/hueplusplus/include/BrightnessStrategy.h b/hueplusplus/include/BrightnessStrategy.h index 9e0ce45..af0c7e1 100755 --- a/hueplusplus/include/BrightnessStrategy.h +++ b/hueplusplus/include/BrightnessStrategy.h @@ -24,11 +24,18 @@ class HueLight; +//! Virtual base class for all BrightnessStrategys class BrightnessStrategy { public: + //! \brief Virtual function for changing a lights brightness with a specified transition. + //! + //! \param bri The brightness raning from 0 = off to 255 = fully lit + //! \param transition The time it takes to fade to the new brightness in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light virtual bool setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const = 0; + //! \brief Virtual dtor virtual ~BrightnessStrategy() = default; }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/ColorHueStrategy.h b/hueplusplus/include/ColorHueStrategy.h index ba7022c..f4ca6b7 100755 --- a/hueplusplus/include/ColorHueStrategy.h +++ b/hueplusplus/include/ColorHueStrategy.h @@ -24,19 +24,84 @@ class HueLight; +//! Virtual base class for all ColorHueStrategys class ColorHueStrategy { public: + //! \brief Function for changing a lights color in hue with a specified transition. + //! + //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is green and 46920 is blue. + //! \param hue The hue of the color + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light virtual bool setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const = 0; - virtual bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const = 0; + //! \brief Function for changing a lights color in saturation with a specified transition. + //! + //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) and 254 is most saturated (vibrant). + //! \param sat The saturation of the color + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light + virtual bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const = 0; + //! \brief Function for changing a lights color in hue and saturation format with a specified transition. + //! + //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is green and 46920 is blue. + //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) and 254 is most saturated (vibrant). + //! \param hue The hue of the color + //! \param sat The saturation of the color + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light virtual bool setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const = 0; + //! \brief Function for changing a lights color in CIE format with a specified transition. + //! + //! \param x The x coordinate in CIE, ranging from 0 to 1 + //! \param y The y coordinate in CIE, ranging from 0 to 1 + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light virtual bool setColorXY(float x, float y, uint8_t transition, HueLight& light) const = 0; + //! \brief Function for changing a lights color in rgb format with a specified transition. + //! + //! Red, green and blue are ranging from 0 to 255. + //! \param r The red portion of the color + //! \param g The green portion of the color + //! \param b The blue portion of the color + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light virtual bool setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const = 0; + //! \brief Function for turning on/off the color loop feature of a light. + //! + //! Can be theoretically set for any light, but it only works for lights that support this feature. + //! When this feature is activated the light will fade through every color on the current hue and saturation settings. + //! Notice that none of the setter functions check whether this feature is enabled and + //! the colorloop can only be disabled with this function or by simply calling Off()/OffNoRefresh() + //! and then On()/OnNoRefresh(), so you could alternatively call Off() and + //! then use any of the setter functions. + //! \param on Boolean to turn this feature on or off, true/1 for on and false/0 for off + //! \param light A reference of the light virtual bool setColorLoop(bool on, HueLight& light) const = 0; + //! \brief Function that lets the light perform one breath cycle in the specified color. + //! + //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is green and 46920 is blue. + //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) and 254 is most saturated (vibrant). + //! \param hue The hue of the color + //! \param sat The saturation of the color + //! \param light A reference of the light virtual bool alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const = 0; + //! \brief Function that lets the light perform one breath cycle in the specified color. + //! + //! \param x The x coordinate in CIE, ranging from 0 to 1 + //! \param y The y coordinate in CIE, ranging from 0 to 1 + //! \param light A reference of the light virtual bool alertXY(float x, float y, HueLight& light) const = 0; + //! \brief Function that lets the light perform one breath cycle in the specified color. + //! + //! Red, green and blue are ranging from 0 to 255. + //! \param r The red portion of the color + //! \param g The green portion of the color + //! \param b The blue portion of the color + //! \param light A reference of the light virtual bool alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const = 0; + //! \brief Virtual dtor virtual ~ColorHueStrategy() = default; }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/ColorTemperatureStrategy.h b/hueplusplus/include/ColorTemperatureStrategy.h index 59d4e32..62f4681 100755 --- a/hueplusplus/include/ColorTemperatureStrategy.h +++ b/hueplusplus/include/ColorTemperatureStrategy.h @@ -24,12 +24,25 @@ class HueLight; +//! Virtual base class for all ColorTemperatureStrategys class ColorTemperatureStrategy { public: + //! \brief Virtual function for changing a lights color temperature in mired with a specified transition. + //! + //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm. + //! \param mired The color temperature in mired + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light virtual bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const = 0; - virtual bool alertTemperature(unsigned int mired, HueLight& light) const = 0; + //! \brief Virtual function that lets the light perform one breath cycle in the specified color. + //! + //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm. + //! \param mired The color temperature in mired + //! \param light A reference of the light + virtual bool alertTemperature(unsigned int mired, HueLight& light) const = 0; + //! \brief Virtual dtor virtual ~ColorTemperatureStrategy() = default; }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/ExtendedColorHueStrategy.h b/hueplusplus/include/ExtendedColorHueStrategy.h index 27319d8..de0a14e 100755 --- a/hueplusplus/include/ExtendedColorHueStrategy.h +++ b/hueplusplus/include/ExtendedColorHueStrategy.h @@ -22,12 +22,35 @@ #include "SimpleColorHueStrategy.h" +//! Class extending the implementation of SimpleColorHueStrategy class ExtendedColorHueStrategy : public SimpleColorHueStrategy { public: + //! \brief Function that lets the light perform one breath cycle in the specified color. + //! + //! It uses this_thread::sleep_for to accomodate for the time an \ref HueLight::alert() needs + //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is green and 46920 is blue. + //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) and 254 is most saturated (vibrant). + //! \param hue The hue of the color + //! \param sat The saturation of the color + //! \param light A reference of the light bool alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const; + //! \brief Function that lets the light perform one breath cycle in the specified color. + //! + //! It uses this_thread::sleep_for to accomodate for the time an \ref HueLight::alert() needs + //! \param x The x coordinate in CIE, ranging from 0 to 1 + //! \param y The y coordinate in CIE, ranging from 0 to 1 + //! \param light A reference of the light bool alertXY(float x, float y, HueLight& light) const; + //! \brief Function that lets the light perform one breath cycle in the specified color. + //! + //! It uses this_thread::sleep_for to accomodate for the time an \ref HueLight::alert() needs + //! Red, green and blue are ranging from 0 to 255. + //! \param r The red portion of the color + //! \param g The green portion of the color + //! \param b The blue portion of the color + //! \param light A reference of the light bool alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const; }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/ExtendedColorTemperatureStrategy.h b/hueplusplus/include/ExtendedColorTemperatureStrategy.h index 09ef140..f9396ea 100755 --- a/hueplusplus/include/ExtendedColorTemperatureStrategy.h +++ b/hueplusplus/include/ExtendedColorTemperatureStrategy.h @@ -18,16 +18,29 @@ **/ #ifndef _EXTENDED_COLOR_TEMPERATURE_STRATEGY_H -#define _EXTENDED_COLOR_TEMPERATURE_STRATEGY_H +#define _EXTENDED_COLOR_TEMPERATURE_STRATEGY_H #include "ColorTemperatureStrategy.h" #include "HueLight.h" +//! Class implementing the functions of ColorTemperatureStrategy class ExtendedColorTemperatureStrategy : public ColorTemperatureStrategy { public: + //! \brief Function for changing a lights color temperature in mired with a specified transition. + //! + //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm. + //! \param mired The color temperature in mired + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const; + //! \brief Function that lets the light perform one breath cycle in the specified color. + //! + //! It uses this_thread::sleep_for to accomodate for the time an \ref HueLight::alert() needs + //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm. + //! \param mired The color temperature in mired + //! \param light A reference of the light bool alertTemperature(unsigned int mired, HueLight& light) const; }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/HttpHandler.h b/hueplusplus/include/HttpHandler.h index 97e04a2..fc3f96d 100644 --- a/hueplusplus/include/HttpHandler.h +++ b/hueplusplus/include/HttpHandler.h @@ -27,30 +27,33 @@ class HttpHandler { public: - //! Function that sends a request to a specific address \ref adr on a specific \ref port. - //! It returns a string containing the answer of the host - //! \param msg String that contains the request that is sent to \ref adr - //! \param adr String that contains an ip or hostname - //! \param port Optional Integer that specifies the port to which the request is sent. Standard value is 80 - //! \return String containing the answer of the host - std::string sendRequest(const std::string &msg, const std::string &adr, int port=80); + //! \brief Function that sends a http request with the specified message and returns the response. + //! + //! It returns a string containing the response of the host. + //! \param msg String that contains the request that is sent to the specified address + //! \param adr String that contains an ip or hostname in dotted decimal notation like "192.168.2.1" + //! \param port Optional integer that specifies the port to which the request is sent to. Default is 80 + //! \return String containing the response of the host + std::string sendRequest(const std::string &msg, const std::string &adr, int port=80); - //! Function that sends a request to a specific address \ref adr on a specific \ref port. - //! It returns a string containing only the body of the answer of the host - //! \param msg String that contains the request that is sent to \ref adr - //! \param adr String that contains an ip or hostname - //! \param port Optional Integer that specifies the port to which the request is sent. Standard value is 80 - //! \return String containing the body of the answer of the host - std::string sendRequestGetBody(const std::string &msg, const std::string &adr, int port = 80); + //! \brief Function that sends a http request with the specified message and returns the body of the response. + //! + //! It returns a string containing only the body of the response of the host. + //! \param msg String that contains the request that is sent to the specified address + //! \param adr String that contains an ip or hostname in dotted decimal notation like "192.168.2.1" + //! \param port Optional integer that specifies the port to which the request is sent. Default is 80 + //! \return String containing the body of the response of the host + std::string sendRequestGetBody(const std::string &msg, const std::string &adr, int port = 80); - //! Function that sends a multicast request to a specific address \ref adr on a specific \ref port with a \ref timeout. - //! It returns a vector containing all answers the multicast request got - //! \param msg String that contains the request that is sent to \ref adr - //! \param adr Optional String that contains an ip or hostname. Standard value is "239.255.255.250" - //! \param port Optional Integer that specifies the port to which the request is sent. Standard value is 1900 - //! \param timeout Optional Integer that specifies the timeout of the request in seconds. Standard value is 5 - //! \return Vector containing strings of each answer received - std::vector sendMulticast(const std::string &msg, const std::string &adr = "239.255.255.250", int port = 1900, int timeout = 5); + //! \brief Function that sends a multicast request with the specified message. + //! + //! It returns a vector containing all responses the multicast request got back + //! \param msg String that contains the request that is sent to the specified address + //! \param adr Optional String that contains an ip or hostname in dotted decimal notation, default is "239.255.255.250" + //! \param port Optional integer that specifies the port to which the request is sent. Default is 1900 + //! \param timeout Optional Integer that specifies the timeout of the request in seconds. Default is 5 + //! \return Vector containing strings of each answer received + std::vector sendMulticast(const std::string &msg, const std::string &adr = "239.255.255.250", int port = 1900, int timeout = 5); }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/Hue.h b/hueplusplus/include/Hue.h index cbf9545..950e030 100755 --- a/hueplusplus/include/Hue.h +++ b/hueplusplus/include/Hue.h @@ -48,92 +48,107 @@ public: std::string mac; }; public: - //! Function that finds all bridges in the network and returns them.\n + //! \brief Function that finds all bridges in the network and returns them. + //! //! The user should be given the opportunity to select the correct one based on the mac address. //! \return vector containing ip and mac of all found bridges std::vector FindBridges() const; - //! Function that gets a \ref Hue bridge based on its identification + //! \brief Function that gets a \ref Hue bridge based on its identification + //! //! \param identification \ref HueIdentification that specifies a bridge //! \return \ref Hue class object Hue GetBridge(const HueIdentification& identification); - //! Function that adds a username to the \ref usernames map + //! \brief Function that adds a username to the \ref usernames map + //! //! \param mac MAC address of Hue bridge //! \param username Username that is used to control the Hue bridge void AddUsername(const std::string& mac, const std::string& username); - //! Function that returns a map of mac addresses and usernames. + //! \brief Function that returns a map of mac addresses and usernames. + //! //! These should be saved at the end and re-loaded next time, so only one username is generated per bridge. //! \returns A map mapping mac address to username for every bridge const std::map& GetAllUsernames() const; private: - //! Function that sends a username request to the Hue bridge for about 30 seconds, but you have 5 seconds to prepare.\n + //! \brief Function that sends a username request to the Hue bridge. + //! + //! It does that for about 30 seconds and you have 5 seconds to prepare. //! It returns the username received //! \param ip String that specifies the ip the request is send to //! \return String containing username std::string RequestUsername(const std::string& ip) const; private: - std::map usernames; + std::map usernames; //!< Maps all macs to usernames added by \ref HueFinder::AddUsername }; //! Hue class class Hue { public: - //! Constructor of Hue class - //! \param ip String that specifies the ip address of the Hue bridge + //! \brief Constructor of Hue class + //! + //! \param ip String that specifies the ip address of the Hue bridge in dotted decimal notation like "192.168.2.1" //! \param username String that specifies the username that is used to control the bridge. This needs to be acquired in \ref requestUsername Hue(const std::string& ip, const std::string& username); - //! Function to get the ip address of the hue bridge + //! \brief Function to get the ip address of the hue bridge + //! //! \return string containing ip std::string getBridgeIP(); - //! Function that sends a username request to the Hue bridge for about 30 seconds, but you have 5 seconds to prepare + //! \brief Function that sends a username request to the Hue bridge. + //! + //! It does that for about 30 seconds and you have 5 seconds to prepare //! It automatically sets the \ref username variable according to the username received //! This function should only be called once to acquire a username to control the bridge and the username should be saved for future use - //! \param ip String that specifies the ip the request is send to + //! \param ip String that specifies the ip (in dotted decimal notation like "192.168.2.1") the request is send to void requestUsername(const std::string& ip); - //! Function that returns the \ref username + //! \brief Function that returns the \ref username + //! //! \return String containing \ref username std::string getUsername(); - //! Function to set the ip address of the Hue bridge in this class - //! \param ip String that specifies the ip + //! \brief Function to set the ip address of this class representing a bridge + //! + //! \param ip String that specifies the ip in dotted decimal notation like "192.168.2.1" void setIP(const std::string ip); - // todo: some intelligence of finding light - //! Function that returns a \HueLight of specified \ref id + //! \todo add some intelligence of finding light + //! \brief Function that returns a \ref Hue::HueLight of specified id + //! //! \param id Integer that specifies the ID of a Hue light //! \return \ref HueLight that can be controlled HueLight& getLight(int id); - //! Function that returns all light types that are associated with this bridge + //! \brief Function that returns all light types that are associated with this bridge + //! //! \return A map mapping light id's to light types for every light //const std::map& getAllLightTypes(); - //! Function that returns all lights that are associated with this bridge + //! \brief Function that returns all lights that are associated with this bridge + //! //! \return A vector containing references to every HueLight std::vector> getAllLights(); private: - //! Function that refreshes the local \ref state of the Hue bridge + //! \brief Function that refreshes the local \ref state of the Hue bridge void refreshState(); private: - std::string ip; - std::string username; - Json::Value state; - std::map< uint8_t, HueLight > lights; - - std::shared_ptr simpleBrightnessStrategy; - std::shared_ptr simpleColorHueStrategy; - std::shared_ptr extendedColorHueStrategy; - std::shared_ptr simpleColorTemperatureStrategy; - std::shared_ptr extendedColorTemperatureStrategy; + std::string ip; //!< IP-Address of the hue bridge in dotted decimal notation like "192.168.2.1" + std::string username; //!< Username that is ussed to access the hue bridge + Json::Value state; //!< The state of the hue bridge as it is returned from it + std::map< uint8_t, HueLight > lights; //!< Maps ids to HueLights that are controlled by this bridge + + std::shared_ptr simpleBrightnessStrategy; //!< Strategy that is used for controlling the brightness of lights + std::shared_ptr simpleColorHueStrategy; //!< Strategy that is used for controlling the color of lights + std::shared_ptr extendedColorHueStrategy; //!< Strategy that is used for controlling the color of lights + std::shared_ptr simpleColorTemperatureStrategy; //!< Strategy that is used for controlling the color temperature of lights + std::shared_ptr extendedColorTemperatureStrategy; //!< Strategy that is used for controlling the color temperature of lights }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/HueLight.h b/hueplusplus/include/HueLight.h index 08bc671..7ef1f63 100755 --- a/hueplusplus/include/HueLight.h +++ b/hueplusplus/include/HueLight.h @@ -69,7 +69,7 @@ LTW014, // Hue Spot BR30, Color Gamut 2200K-6500K, CTL LLC020 // Hue Go, Color Gamut C, ECL };*/ -//! enum that specifies the color type of all Hue lights +//! enum that specifies the color type of all HueLights enum ColorType { UNDEFINED, //!< ColorType for this light is unknown or undefined @@ -96,69 +96,78 @@ class HueLight friend class ExtendedColorTemperatureStrategy; public: - //! std dtor + //! \brief std dtor ~HueLight() = default; - //! Function that turns the light on. + //! \brief Function that turns the light on. + //! //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms //! \return Bool that is true on success bool On(uint8_t transition = 4); - //! Function that turns the light off. + //! \brief Function that turns the light off. + //! //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms //! \return Bool that is true on success bool Off(uint8_t transition = 4); - //! Function that returns the name of the light. + //! \brief Function that returns the name of the light. + //! //! \return String containig the name of the light std::string getName(); - //! Function that returns the color type of the light. + //! \brief Function that returns the color type of the light. + //! //! \return ColorType containig the color type of the light ColorType getColorType(); - //! Function that converts Kelvin to Mired. + //! \brief Function that converts Kelvin to Mired. + //! //! \param kelvin Unsigned integer value in Kelvin //! \return Unsigned integer value in Mired unsigned int KelvinToMired(unsigned int kelvin); - //! Function that converts Mired to Kelvin. + //! \brief Function that converts Mired to Kelvin. + //! //! \param mired Unsigned integer value in Mired //! \return Unsigned integer value in Kelvin unsigned int MiredToKelvin(unsigned int mired); - //! Function that sets the brightness of this light if the - //! light has a reference to a specific \ref BrightnessStrategy. - //! The brightness can range from 0=off to 255=fully on. + //! \brief Function that sets the brightness of this light. + //! + //! Notice the brightness will only be set if the light has a reference to a specific \ref BrightnessStrategy. + //! The brightness can range from 0 = off to 255 = fully lit. //! \param bri Unsigned int that specifies the brightness //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms //! \return Bool that is true on success - bool setBrightness(unsigned int bri, uint8_t transition = 4) - { - if (brightnessStrategy) + bool setBrightness(unsigned int bri, uint8_t transition = 4) + { + if (brightnessStrategy) { return brightnessStrategy->setBrightness(bri, transition, *this); } return false; }; - //! Fucntion that sets the color temperature of this light in mired if the - //! light has a reference to a specific \ref ColorTemperatureStrategy. + //! \brief Fucntion that sets the color temperature of this light in mired. + //! + //! Notice the color temperature will only be set if the light has a reference to a specific \ref ColorTemperatureStrategy. //! The color temperature can range from 153 to 500. //! \param mired Unsigned int that specifies the color temperature in Mired //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms //! \return Bool that is true on success bool setColorTemperature(unsigned int mired, uint8_t transition = 4) - { + { if (colorTemperatureStrategy) - { - return colorTemperatureStrategy->setColorTemperature(mired, transition, *this); + { + return colorTemperatureStrategy->setColorTemperature(mired, transition, *this); } return false; }; - //! Function to set the color of this light with specified hue if the - //! light has a reference to a specific \ref ColorHueStrategy. + //! \brief Function to set the color of this light with specified hue. + //! + //! Notice the color will only be set if the light has a reference to a specific \ref ColorHueStrategy. //! The hue can range from 0 to 65535, whereas 65535 and 0 are red, 25500 is green and 46920 is blue. //! \param hue uint16_t that specifies the hue //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms @@ -172,8 +181,9 @@ public: return false; }; - //! Function to set the saturation of color of this light with specified saturation if the - //! light has a reference to a specific \ref ColorHueStrategy. + //! \brief Function to set the color of this light with specified saturation. + //! + //! Notice the color will only be set if the light has a reference to a specific \ref ColorHueStrategy. //! The saturation can range from 0 to 254, whereas 0 is least saturated (white) and 254 is most saturated. //! \param sat uint8_t that specifies the saturation //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms @@ -187,8 +197,9 @@ public: return false; }; - //! Function to set the color of this light with specified hue and saturation if the - //! light has a reference to a specific \ref ColorHueStrategy. + //! \brief Function to set the color of this light with specified hue and saturation. + //! + //! Notice the color will only be set if the light has a reference to a specific \ref ColorHueStrategy. //! \param hue uint16_t that specifies the hue //! \param sat uint8_t that specifies the saturation //! \param transition Optional parameter to set the transition from current state to new, standard is 4 = 400ms. @@ -202,8 +213,9 @@ public: return false; }; - //! Function to set the color of this light in CIE with specified x y if the - //! light has a reference to a specific \ref ColorHueStrategy. + //! \brief Function to set the color of this light in CIE with specified x y. + //! + //! Notice the color will only be set if the light has a reference to a specific \ref ColorHueStrategy. //! The values of x and y are ranging from 0 to 1. //! \param x float that specifies the x coordinate in CIE //! \param y float that specifies the y coordinate in CIE @@ -218,8 +230,9 @@ public: return false; }; - //! Function to set the color of this light with red green and blue values if the - //! light has a reference to a specific \ref ColorHueStrategy. + //! \brief Function to set the color of this light with red green and blue values. + //! + //! Notice the color will only be set if the light has a reference to a specific \ref ColorHueStrategy. //! The values of red, green and blue are ranging from 0 to 255. //! \param r uint8_t that specifies the red color value //! \param g uint8_t that specifies the green color value @@ -235,13 +248,15 @@ public: return false; }; - //! Function that lets the light perform one breath cycle. + //! \brief Function that lets the light perform one breath cycle. + //! + //! Can be used for locating a light. //! \return bool that is true on success virtual bool alert(); - //! Function that lets the light perform one breath cycle in specified color temperature - //! if the light has a reference to a specific \ref ColorTemperatureStrategy. - //! It uses this_thread::sleep_for to accomodate for the time an \ref alert() needs. + //! \brief Function that lets the light perform one breath cycle in specified color temperature. + //! + //! Notice the breath cylce will only be performed if the light has a reference to a specific \ref ColorTemperatureStrategy. //! \param mired Color temperature in mired //! \return Bool that is true on success bool alertTemperature(unsigned int mired) @@ -253,9 +268,9 @@ public: return false; }; - //! Function that lets the light perform one breath cycle in specified color if the - //! light has a reference to a specific \ref ColorHueStrategy. - //! It uses this_thread::sleep_for to accomodate for the time an \ref alert() needs + //! \brief Function that lets the light perform one breath cycle in specified color. + //! + //! Notice the breath cylce will only be performed if the light has a reference to a specific \ref ColorHueStrategy. //! \param hue uint16_t that specifies the hue //! \param sat uint8_t that specifies the saturation //! \return Bool that is true on success @@ -268,10 +283,10 @@ public: return false; }; - //! Function that lets the light perform one breath cycle in specified color if the - //! light has a reference to a specific \ref ColorHueStrategy. + //! \brief Function that lets the light perform one breath cycle in specified color. + //! + //! Notice the breath cylce will only be performed if the light has a reference to a specific \ref ColorHueStrategy. //! The values of x and y are ranging from 0 to 1. - //! It uses this_thread::sleep_for to accomodate for the time an \ref alert() needs //! \param x float that specifies the x coordinate in CIE //! \param y float that specifies the y coordinate in CIE //! \return Bool that is true on success @@ -284,10 +299,10 @@ public: return false; }; - //! Function that lets the light perform one breath cycle in specified color if the - //! light has a reference to a specific \ref ColorHueStrategy. + //! \brief Function that lets the light perform one breath cycle in specified color. + //! + //! Notice the breath cylce will only be performed if the light has a reference to a specific \ref ColorHueStrategy. //! The values of red, green and blue are ranging from 0 to 255. - //! It uses this_thread::sleep_for to accomodate for the time an \ref alert() needs //! \param r uint8_t that specifies the red color value //! \param g uint8_t that specifies the green color value //! \param b uint8_t that specifies the blue color value @@ -301,12 +316,13 @@ public: return false; }; - //! Function to enable colorloop effect if the - //! light has a reference to a specific \ref ColorHueStrategy. + //! \brief Function to turn colorloop effect on/off. + //! + //! Notice this function will only be performed light has a reference to a specific \ref ColorHueStrategy. //! The colorloop effect will loop through all colors on current hue and saturation levels. - //! Notice that none of the setter functions check whether this feature is enabled and - //! the colorloop can only be disabled with this function or by simply calling Off()/OffNoRefresh() - //! and then On()/OnNoRefresh(), so you could alternatively call Off() and + //! Notice that none of the setter functions check whether this feature is enabled and + //! the colorloop can only be disabled with this function or by simply calling Off()/OffNoRefresh() + //! and then On()/OnNoRefresh(), so you could alternatively call Off() and //! then use any of the setter functions. //! \param on bool that enables this feature when true and disables it when false //! \return Bool that is true on success @@ -320,15 +336,17 @@ public: }; protected: - //! protected ctor that is used by \ref Hue class. + //! \brief Protected ctor that is used by \ref Hue class. + //! //! \param ip String that specifies the ip of the Hue bridge //! \param username String that specifies the username used to control the bridge //! \param id Integer that specifies the id of this light //! //! leaves strategies unset HueLight(const std::string& ip, const std::string& username, int id); - - //! protected ctor that is used by \ref Hue class, also sets strategies. + + //! \brief Protected ctor that is used by \ref Hue class, also sets strategies. + //! //! \param ip String that specifies the ip of the Hue bridge //! \param username String that specifies the username used to control the bridge //! \param id Integer that specifies the id of this light @@ -337,37 +355,43 @@ protected: //! \param colorHueStrategy Strategy for color hue/saturation. May be nullptr. HueLight(const std::string& ip, const std::string& username, int id, std::shared_ptr brightnessStrategy, std::shared_ptr colorTempStrategy, std::shared_ptr colorHueStrategy); - //! protected function that sets the brightness strategy which defines how - //! specific commands that deal with brightness control are executed + //! \brief Protected function that sets the brightness strategy. + //! + //! The strategy defines how specific commands that deal with brightness control are executed //! \param strat a strategy of type \ref BrightnessStrategy void setBrightnessStrategy(std::shared_ptr strat) { brightnessStrategy = std::move(strat); }; - //! protected function that sets the colorTemperature strategy which defines how - //! specific commands that deal with colortemperature control are executed + //! \brief Protected function that sets the colorTemperature strategy. + //! + //! The strategy defines how specific commands that deal with colortemperature control are executed //! \param strat a strategy of type \ref ColorTemperatureStrategy void setColorTemperatureStrategy(std::shared_ptr strat) { colorTemperatureStrategy = std::move(strat); }; - //! protected function that sets the colorHue strategy which defines how - //! specific commands that deal with color control are executed + //! \brief Protected function that sets the colorHue strategy. + //! + //! The strategy defines how specific commands that deal with color control are executed //! \param strat a strategy of type \ref ColorHueStrategy void setColorHueStrategy(std::shared_ptr strat) { colorHueStrategy = std::move(strat); }; - //! Function that turns the light on without refreshing its state. + //! \brief Function that turns the light on without refreshing its state. + //! //! \param transition Optional parameter to set the transition from current state to new standard is 4 = 400ms //! \return Bool that is true on success bool OnNoRefresh(uint8_t transition = 4); - //! Function that turns the light off without refreshing its state. + //! \brief Function that turns the light off without refreshing its state. + //! //! \param transition Optional parameter to set the transition from current state to new standard is 4 = 400ms //! \return Bool that is true on success bool OffNoRefresh(uint8_t transition = 4); - //! utility function to send a put request to the light. + //! \brief Utility function to send a put request to the light. + //! //! \throws std::runtime_error if the reply could not be parsed //! \return The parsed reply Json::Value SendPutRequest(const Json::Value& request); - //! virtual function that refreshes the \ref state of the light. + //! \brief Virtual function that refreshes the \ref state of the light. virtual void refreshState(); protected: diff --git a/hueplusplus/include/SimpleBrightnessStrategy.h b/hueplusplus/include/SimpleBrightnessStrategy.h index f208647..401f74c 100755 --- a/hueplusplus/include/SimpleBrightnessStrategy.h +++ b/hueplusplus/include/SimpleBrightnessStrategy.h @@ -23,10 +23,16 @@ #include "BrightnessStrategy.h" #include "HueLight.h" +//! Class implementing the functions of BrightnessStrategy class SimpleBrightnessStrategy : public BrightnessStrategy { public: + //! \brief Function for changing a lights brightness with a specified transition. + //! + //! \param bri The brightness raning from 0 = off to 255 = fully lit + //! \param transition The time it takes to fade to the new brightness in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light bool setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const; }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/SimpleColorHueStrategy.h b/hueplusplus/include/SimpleColorHueStrategy.h index e40d46b..a5de0d1 100755 --- a/hueplusplus/include/SimpleColorHueStrategy.h +++ b/hueplusplus/include/SimpleColorHueStrategy.h @@ -22,18 +22,85 @@ #include "HueLight.h" +//! Class implementing the functions of ColorHueStrategy class SimpleColorHueStrategy : public ColorHueStrategy { public: + //! \brief Function for changing a lights color in hue with a specified transition. + //! + //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is green and 46920 is blue. + //! \param hue The hue of the color + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light bool setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const; - bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const; + //! \brief Virtual function for changing a lights color in saturation with a specified transition. + //! + //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) and 254 is most saturated (vibrant). + //! \param sat The saturation of the color + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light + bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const; + //! \brief Virtual function for changing a lights color in hue and saturation format with a specified transition. + //! + //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is green and 46920 is blue. + //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) and 254 is most saturated (vibrant). + //! \param hue The hue of the color + //! \param sat The saturation of the color + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light bool setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const; + //! \brief Virtual function for changing a lights color in CIE format with a specified transition. + //! + //! \param x The x coordinate in CIE, ranging from 0 to 1 + //! \param y The y coordinate in CIE, ranging from 0 to 1 + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light bool setColorXY(float x, float y, uint8_t transition, HueLight& light) const; + //! \brief Virtual function for changing a lights color in rgb format with a specified transition. + //! + //! Red, green and blue are ranging from 0 to 255. + //! \param r The red portion of the color + //! \param g The green portion of the color + //! \param b The blue portion of the color + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light bool setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const; + //! \brief Virtual function for turning on/off the color loop feature of a light. + //! + //! Can be theoretically set for any light, but it only works for lights that support this feature. + //! When this feature is activated the light will fade through every color on the current hue and saturation settings. + //! Notice that none of the setter functions check whether this feature is enabled and + //! the colorloop can only be disabled with this function or by simply calling Off()/OffNoRefresh() + //! and then On()/OnNoRefresh(), so you could alternatively call Off() and + //! then use any of the setter functions. + //! \param on Boolean to turn this feature on or off, true/1 for on and false/0 for off + //! \param light A reference of the light bool setColorLoop(bool on, HueLight& light) const; + //! \brief Virtual function that lets the light perform one breath cycle in the specified color. + //! + //! It uses this_thread::sleep_for to accomodate for the time an \ref HueLight::alert() needs + //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is green and 46920 is blue. + //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white) and 254 is most saturated (vibrant). + //! \param hue The hue of the color + //! \param sat The saturation of the color + //! \param light A reference of the light bool alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const; + //! \brief Virtual function that lets the light perform one breath cycle in the specified color. + //! + //! It uses this_thread::sleep_for to accomodate for the time an \ref HueLight::alert() needs + //! \param x The x coordinate in CIE, ranging from 0 to 1 + //! \param y The y coordinate in CIE, ranging from 0 to 1 + //! \param light A reference of the light bool alertXY(float x, float y, HueLight& light) const; + //! \brief Virtual function that lets the light perform one breath cycle in the specified color. + //! + //! It uses this_thread::sleep_for to accomodate for the time an \ref HueLight::alert() needs + //! Red, green and blue are ranging from 0 to 255. + //! \param r The red portion of the color + //! \param g The green portion of the color + //! \param b The blue portion of the color + //! \param light A reference of the light bool alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const; }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/SimpleColorTemperatureStrategy.h b/hueplusplus/include/SimpleColorTemperatureStrategy.h index 0fcf22f..2f865fe 100755 --- a/hueplusplus/include/SimpleColorTemperatureStrategy.h +++ b/hueplusplus/include/SimpleColorTemperatureStrategy.h @@ -23,11 +23,24 @@ #include "ColorTemperatureStrategy.h" #include "HueLight.h" +//! Class implementing the functions of ColorTemperatureStrategy class SimpleColorTemperatureStrategy : public ColorTemperatureStrategy { public: + //! \brief Function for changing a lights color temperature in mired with a specified transition. + //! + //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm. + //! \param mired The color temperature in mired + //! \param transition The time it takes to fade to the new color in multiples of 100ms, 4 = 400ms and should be seen as the default + //! \param light A reference of the light bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const; + //! \brief Function that lets the light perform one breath cycle in the specified color. + //! + //! It uses this_thread::sleep_for to accomodate for the time an \ref HueLight::alert() needs + //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold and 500 is warm. + //! \param mired The color temperature in mired + //! \param light A reference of the light bool alertTemperature(unsigned int mired, HueLight& light) const; }; -#endif \ No newline at end of file +#endif diff --git a/hueplusplus/include/UPnP.h b/hueplusplus/include/UPnP.h index 8d36823..1dd9fa3 100755 --- a/hueplusplus/include/UPnP.h +++ b/hueplusplus/include/UPnP.h @@ -20,13 +20,19 @@ #ifndef _UPNP_H #define _UPNP_H -#include +#include #include +//! Class that looks for UPnP devices using an m-search package class UPnP { public: + //! \brief Function that searches for UPnP devices and returns all found ones. + //! + //! It does it by sending an m-search packet and waits for all responses. + //! Since responses can be received multiple times this function conveniently removes all duplicates. + //! \return A vector containing pairs of address and name of all found devices std::vector> getDevices(); }; -#endif \ No newline at end of file +#endif