Added author tag, added missing return statement.

Former-commit-id: 4d0a29a8ba3d33de6f86b90a4eaf2f0de12ea59a
This commit is contained in:
Tim Niggemann 2014-07-16 16:21:11 +02:00
parent b055578759
commit f76b5ffbd8
2 changed files with 9 additions and 11 deletions

View File

@ -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) {
@ -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.
if (switchOffOnBlack && xy == BLACK && lamp.color != BLACK) {
put(getStateRoute(lamp.id), QString("{\"on\": false}"));
}
}
// Write color if color has been changed.
else if (xy != lamp.color) {
// 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}"));
}
// 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) :

View File

@ -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
///