Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 4d0a29a

Browse files
author
Tim Niggemann
committed
Added author tag, added missing return statement.
1 parent bb4f4bc commit 4d0a29a

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

libsrc/leddevice/LedDevicePhilipsHue.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <set>
1414

15-
const ColorPoint LedDevicePhilipsHue::BLACK = {0.0f, 0.0f, 0.0f};
15+
const ColorPoint LedDevicePhilipsHue::BLACK = { 0.0f, 0.0f, 0.0f };
1616

1717
LedDevicePhilipsHue::LedDevicePhilipsHue(const std::string& output, bool switchOffOnBlack) :
1818
host(output.c_str()), username("newdeveloper"), switchOffOnBlack(switchOffOnBlack) {
@@ -42,16 +42,16 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) {
4242
// Switch lamp off if switchOffOnBlack is enabled and the lamp is currently on.
4343
if (switchOffOnBlack && xy == BLACK && lamp.color != BLACK) {
4444
put(getStateRoute(lamp.id), QString("{\"on\": false}"));
45-
}
45+
}
4646
// Write color if color has been changed.
4747
else if (xy != lamp.color) {
4848
// Switch on if the lamp has been previously switched off.
4949
if (switchOffOnBlack && lamp.color == BLACK) {
5050
put(getStateRoute(lamp.id), QString("{\"on\": true}"));
5151
}
5252
// Send adjust color and brightness command in JSON format.
53-
put(getStateRoute(lamp.id), QString("{\"xy\": [%1, %2], \"bri\": %1}").arg(xy.x).arg(xy.y)
54-
.arg(qRound(xy.bri * 255.0f)));
53+
put(getStateRoute(lamp.id),
54+
QString("{\"xy\": [%1, %2], \"bri\": %1}").arg(xy.x).arg(xy.y).arg(qRound(xy.bri * 255.0f)));
5555
// Remember written color.
5656
lamp.color = xy;
5757
}
@@ -218,10 +218,11 @@ ColorPoint LedDevicePhilipsHue::rgbToXYBrightness(float red, float green, float
218218
if (isnan(cy)) {
219219
cy = 0.0f;
220220
}
221-
ColorPoint xy = {cx, cy};
221+
// Brightness is simply Y in the XYZ space.
222+
ColorPoint xy = { cx, cy, Y };
222223
// Check if the given XY value is within the color reach of our lamps.
223224
if (!isPointInLampsReach(lamp, xy)) {
224-
// 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.
225+
// 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.
225226
ColorPoint pAB = getClosestPointToPoint(lamp.colorSpace.red, lamp.colorSpace.green, xy);
226227
ColorPoint pAC = getClosestPointToPoint(lamp.colorSpace.blue, lamp.colorSpace.red, xy);
227228
ColorPoint pBC = getClosestPointToPoint(lamp.colorSpace.green, lamp.colorSpace.blue, xy);
@@ -243,8 +244,7 @@ ColorPoint LedDevicePhilipsHue::rgbToXYBrightness(float red, float green, float
243244
xy.x = closestPoint.x;
244245
xy.y = closestPoint.y;
245246
}
246-
// Brightness is simply Y in the XYZ space.
247-
xy.bri = Y;
247+
return xy;
248248
}
249249

250250
HueLamp::HueLamp(unsigned int id, QString originalState, QString modelId) :

libsrc/leddevice/LedDevicePhilipsHue.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class HueLamp {
6161
* Framegrabber must be limited to 10 Hz / numer of lights to avoid rate limitation by the hue bridge.
6262
* Create a new API user name "newdeveloper" on the bridge (http://developers.meethue.com/gettingstarted.html)
6363
*
64-
* @author ntim (github)
64+
* @author ntim (github), bimsarck (github)
6565
*/
6666
class LedDevicePhilipsHue: public QObject, public LedDevice {
6767
Q_OBJECT
@@ -187,7 +187,6 @@ private slots:
187187
///
188188
float crossProduct(ColorPoint p1, ColorPoint p2);
189189

190-
191190
///
192191
/// @param lamp the hue lamp instance
193192
///
@@ -197,7 +196,6 @@ private slots:
197196
///
198197
bool isPointInLampsReach(HueLamp lamp, ColorPoint p);
199198

200-
201199
///
202200
/// @param a reference point one
203201
///

0 commit comments

Comments
 (0)