Implemented timeout for restoring original state.

Former-commit-id: 925b063aba1a859b592ead9b75ce67d90fb81e28
This commit is contained in:
ntim
2014-05-03 10:12:41 +02:00
parent 9220c346bb
commit 8cca280fdc
3 changed files with 16 additions and 5 deletions

View File

@@ -4,8 +4,10 @@
#include <string>
// Qt includes
#include <QObject>
#include <QString>
#include <QHttp>
#include <QTimer>
// Leddevice includes
#include <leddevice/LedDevice.h>
@@ -18,7 +20,8 @@
* 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 {
class LedDevicePhilipsHue: public QObject, public LedDevice {
Q_OBJECT
public:
///
/// Constructs the device.
@@ -44,6 +47,10 @@ public:
/// Switch the leds off
virtual int switchOff();
private slots:
/// Restores the status of all lights.
void restoreStates();
private:
/// Array to save the light states.
std::vector<QString> states;
@@ -53,6 +60,8 @@ private:
QString username;
/// Qhttp object for sending requests.
QHttp* http;
/// Use timer to reset lights when we got into "GRABBINGMODE_OFF".
QTimer timer;
///
/// Sends a HTTP GET request (blocking).
@@ -93,9 +102,6 @@ private:
///
void saveStates(unsigned int nLights);
/// Restores the status of all lights.
void restoreStates();
///
/// @return true if light states have been saved.
///