mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	Added author tag, added missing return statement.
Former-commit-id: 4d0a29a8ba3d33de6f86b90a4eaf2f0de12ea59a
This commit is contained in:
		| @@ -12,7 +12,7 @@ | |||||||
|  |  | ||||||
| #include <set> | #include <set> | ||||||
|  |  | ||||||
| const ColorPoint LedDevicePhilipsHue::BLACK = {0.0f, 0.0f, 0.0f}; | const ColorPoint LedDevicePhilipsHue::BLACK = { 0.0f, 0.0f, 0.0f }; | ||||||
|  |  | ||||||
| LedDevicePhilipsHue::LedDevicePhilipsHue(const std::string& output, bool switchOffOnBlack) : | LedDevicePhilipsHue::LedDevicePhilipsHue(const std::string& output, bool switchOffOnBlack) : | ||||||
| 		host(output.c_str()), username("newdeveloper"), switchOffOnBlack(switchOffOnBlack) { | 		host(output.c_str()), username("newdeveloper"), switchOffOnBlack(switchOffOnBlack) { | ||||||
| @@ -42,7 +42,7 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) { | |||||||
| 		// Switch lamp off if switchOffOnBlack is enabled and the lamp is currently on. | 		// Switch lamp off if switchOffOnBlack is enabled and the lamp is currently on. | ||||||
| 		if (switchOffOnBlack && xy == BLACK && lamp.color != BLACK) { | 		if (switchOffOnBlack && xy == BLACK && lamp.color != BLACK) { | ||||||
| 			put(getStateRoute(lamp.id), QString("{\"on\": false}")); | 			put(getStateRoute(lamp.id), QString("{\"on\": false}")); | ||||||
| 		}  | 		} | ||||||
| 		// Write color if color has been changed. | 		// Write color if color has been changed. | ||||||
| 		else if (xy != lamp.color) { | 		else if (xy != lamp.color) { | ||||||
| 			// Switch on if the lamp has been previously switched off. | 			// Switch on if the lamp has been previously switched off. | ||||||
| @@ -50,8 +50,8 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) { | |||||||
| 				put(getStateRoute(lamp.id), QString("{\"on\": true}")); | 				put(getStateRoute(lamp.id), QString("{\"on\": true}")); | ||||||
| 			} | 			} | ||||||
| 			// Send adjust color and brightness command in JSON format. | 			// Send adjust color and brightness command in JSON format. | ||||||
| 			put(getStateRoute(lamp.id), QString("{\"xy\": [%1, %2], \"bri\": %1}").arg(xy.x).arg(xy.y) | 			put(getStateRoute(lamp.id), | ||||||
| 				.arg(qRound(xy.bri * 255.0f))); | 					QString("{\"xy\": [%1, %2], \"bri\": %1}").arg(xy.x).arg(xy.y).arg(qRound(xy.bri * 255.0f))); | ||||||
| 			// Remember written color. | 			// Remember written color. | ||||||
| 			lamp.color = xy; | 			lamp.color = xy; | ||||||
| 		} | 		} | ||||||
| @@ -218,10 +218,11 @@ ColorPoint LedDevicePhilipsHue::rgbToXYBrightness(float red, float green, float | |||||||
| 	if (isnan(cy)) { | 	if (isnan(cy)) { | ||||||
| 		cy = 0.0f; | 		cy = 0.0f; | ||||||
| 	} | 	} | ||||||
| 	ColorPoint xy = {cx, cy}; | 	// Brightness is simply Y in the XYZ space. | ||||||
|  | 	ColorPoint xy = { cx, cy, Y }; | ||||||
| 	// Check if the given XY value is within the color reach of our lamps. | 	// Check if the given XY value is within the color reach of our lamps. | ||||||
| 	if (!isPointInLampsReach(lamp, xy)) { | 	if (!isPointInLampsReach(lamp, xy)) { | ||||||
| 		// It seems the color is out of reach let's find the closes colour we can produce with our lamp and send this XY value out. | 		// It seems the color is out of reach let's find the closes color we can produce with our lamp and send this XY value out. | ||||||
| 		ColorPoint pAB = getClosestPointToPoint(lamp.colorSpace.red, lamp.colorSpace.green, xy); | 		ColorPoint pAB = getClosestPointToPoint(lamp.colorSpace.red, lamp.colorSpace.green, xy); | ||||||
| 		ColorPoint pAC = getClosestPointToPoint(lamp.colorSpace.blue, lamp.colorSpace.red, xy); | 		ColorPoint pAC = getClosestPointToPoint(lamp.colorSpace.blue, lamp.colorSpace.red, xy); | ||||||
| 		ColorPoint pBC = getClosestPointToPoint(lamp.colorSpace.green, lamp.colorSpace.blue, xy); | 		ColorPoint pBC = getClosestPointToPoint(lamp.colorSpace.green, lamp.colorSpace.blue, xy); | ||||||
| @@ -243,8 +244,7 @@ ColorPoint LedDevicePhilipsHue::rgbToXYBrightness(float red, float green, float | |||||||
| 		xy.x = closestPoint.x; | 		xy.x = closestPoint.x; | ||||||
| 		xy.y = closestPoint.y; | 		xy.y = closestPoint.y; | ||||||
| 	} | 	} | ||||||
| 	// Brightness is simply Y in the XYZ space. | 	return xy; | ||||||
| 	xy.bri = Y; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| HueLamp::HueLamp(unsigned int id, QString originalState, QString modelId) : | HueLamp::HueLamp(unsigned int id, QString originalState, QString modelId) : | ||||||
|   | |||||||
| @@ -61,7 +61,7 @@ public: | |||||||
|  * Framegrabber must be limited to 10 Hz / numer of lights to avoid rate limitation by the hue bridge. |  * Framegrabber must be limited to 10 Hz / numer of lights to avoid rate limitation by the hue bridge. | ||||||
|  * Create a new API user name "newdeveloper" on the bridge (http://developers.meethue.com/gettingstarted.html) |  * Create a new API user name "newdeveloper" on the bridge (http://developers.meethue.com/gettingstarted.html) | ||||||
|  * |  * | ||||||
|  * @author ntim (github) |  * @author ntim (github), bimsarck (github) | ||||||
|  */ |  */ | ||||||
| class LedDevicePhilipsHue: public QObject, public LedDevice { | class LedDevicePhilipsHue: public QObject, public LedDevice { | ||||||
| Q_OBJECT | Q_OBJECT | ||||||
| @@ -187,7 +187,6 @@ private: | |||||||
| 	/// | 	/// | ||||||
| 	float crossProduct(ColorPoint p1, ColorPoint p2); | 	float crossProduct(ColorPoint p1, ColorPoint p2); | ||||||
|  |  | ||||||
|  |  | ||||||
| 	/// | 	/// | ||||||
| 	/// @param lamp the hue lamp instance | 	/// @param lamp the hue lamp instance | ||||||
| 	/// | 	/// | ||||||
| @@ -197,7 +196,6 @@ private: | |||||||
| 	/// | 	/// | ||||||
| 	bool isPointInLampsReach(HueLamp lamp, ColorPoint p); | 	bool isPointInLampsReach(HueLamp lamp, ColorPoint p); | ||||||
|  |  | ||||||
|  |  | ||||||
| 	/// | 	/// | ||||||
| 	/// @param a reference point one | 	/// @param a reference point one | ||||||
| 	/// | 	/// | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user