From ebb22cdc87799612bea0bdd2bf111250f0d03ce0 Mon Sep 17 00:00:00 2001 From: ntim Date: Sun, 27 Apr 2014 18:42:26 +0200 Subject: [PATCH] Removed rate limiting from code. Setting framegrabbing frequency of 10 Hz / number of lights is sufficient. Former-commit-id: 0686a8d18c780038eb017fdf26b5faf4b8053f3a --- libsrc/leddevice/LedDevicePhilipsHue.cpp | 19 ++++++------------- libsrc/leddevice/LedDevicePhilipsHue.h | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/libsrc/leddevice/LedDevicePhilipsHue.cpp b/libsrc/leddevice/LedDevicePhilipsHue.cpp index 01334403..11e99a21 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/LedDevicePhilipsHue.cpp @@ -18,11 +18,6 @@ LedDevicePhilipsHue::~LedDevicePhilipsHue() { } int LedDevicePhilipsHue::write(const std::vector & ledValues) { - // Due to rate limiting (max. 30 request per seconds), discard new values if - // the previous request have not been completed yet. - if (http->hasPendingRequests()) { - return -1; - } unsigned int lightId = 1; for (const ColorRgb& color : ledValues) { float x, y, b; @@ -50,8 +45,6 @@ void LedDevicePhilipsHue::put(QString route, QString content) { header.setValue("Content-Length", QString("%1").arg(content.size())); http->setHost(host); http->request(header, content.toAscii()); - // std::cout << "LedDevicePhilipsHue::put(): " << header.toString().toUtf8().constData() << std::endl; - // std::cout << "LedDevicePhilipsHue::put(): " << content.toUtf8().constData() << std::endl; } QString LedDevicePhilipsHue::getRoute(unsigned int lightId) { @@ -71,11 +64,11 @@ void LedDevicePhilipsHue::rgbToXYBrightness(float red, float green, float blue, x = X / (X + Y + Z); y = Y / (X + Y + Z); if (isnan(x)) { - x = 0.0f; - } - if (isnan(y)) { - y = 0.0f; - } - // Brightness is simply Y in the XYZ space. + x = 0.0f; + } + if (isnan(y)) { + y = 0.0f; + } + // Brightness is simply Y in the XYZ space. brightness = Y; } diff --git a/libsrc/leddevice/LedDevicePhilipsHue.h b/libsrc/leddevice/LedDevicePhilipsHue.h index e5710f40..a9155899 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.h +++ b/libsrc/leddevice/LedDevicePhilipsHue.h @@ -15,7 +15,7 @@ * * To use set the device to "philipshue". * Uses the official Philips Hue API (http://developers.meethue.com). - * Framegrabber should be limited to 30 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) */ class LedDevicePhilipsHue : public LedDevice