mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Added author tag, added missing return statement.
Former-commit-id: 4d0a29a8ba3d33de6f86b90a4eaf2f0de12ea59a
This commit is contained in:
parent
b055578759
commit
f76b5ffbd8
@ -12,7 +12,7 @@
|
||||
|
||||
#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) :
|
||||
host(output.c_str()), username("newdeveloper"), switchOffOnBlack(switchOffOnBlack) {
|
||||
@ -50,8 +50,8 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) {
|
||||
put(getStateRoute(lamp.id), QString("{\"on\": true}"));
|
||||
}
|
||||
// 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)
|
||||
.arg(qRound(xy.bri * 255.0f)));
|
||||
put(getStateRoute(lamp.id),
|
||||
QString("{\"xy\": [%1, %2], \"bri\": %1}").arg(xy.x).arg(xy.y).arg(qRound(xy.bri * 255.0f)));
|
||||
// Remember written color.
|
||||
lamp.color = xy;
|
||||
}
|
||||
@ -218,10 +218,11 @@ ColorPoint LedDevicePhilipsHue::rgbToXYBrightness(float red, float green, float
|
||||
if (isnan(cy)) {
|
||||
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.
|
||||
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 pAC = getClosestPointToPoint(lamp.colorSpace.blue, lamp.colorSpace.red, 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.y = closestPoint.y;
|
||||
}
|
||||
// Brightness is simply Y in the XYZ space.
|
||||
xy.bri = Y;
|
||||
return xy;
|
||||
}
|
||||
|
||||
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.
|
||||
* 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 {
|
||||
Q_OBJECT
|
||||
@ -187,7 +187,6 @@ private:
|
||||
///
|
||||
float crossProduct(ColorPoint p1, ColorPoint p2);
|
||||
|
||||
|
||||
///
|
||||
/// @param lamp the hue lamp instance
|
||||
///
|
||||
@ -197,7 +196,6 @@ private:
|
||||
///
|
||||
bool isPointInLampsReach(HueLamp lamp, ColorPoint p);
|
||||
|
||||
|
||||
///
|
||||
/// @param a reference point one
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user