ColourDevice.h
Go to the documentation of this file.
1 
20 #pragma once
21 
22 #include "DimmableDevice.h"
23 
24 namespace Hue
25 {
27 {
28 public:
29  ColourDevice(ID id, const String& name) : DimmableDevice(id, name)
30  {
31  }
32 
33  bool getAttribute(Attribute attr, unsigned& value) const override
34  {
35  switch(attr) {
36  case Attribute::sat:
37  value = sat;
38  return true;
39  case Attribute::hue:
40  value = hue;
41  return true;
42  case Attribute::ct:
43  value = ct;
44  return true;
45  default:
46  return DimmableDevice::getAttribute(attr, value);
47  }
48  }
49 
50  Status setAttribute(Attribute attr, unsigned value, Callback callback) override
51  {
52  switch(attr) {
53  case Attribute::sat:
54  sat = value;
55  return Status::success;
56  case Attribute::hue:
57  hue = value;
58  return Status::success;
59  case Attribute::ct:
60  ct = value;
61  return Status::success;
62  default:
63  return DimmableDevice::setAttribute(attr, value, callback);
64  }
65  }
66 
67 private:
68  uint8_t sat = 0;
69  uint16_t hue = 0;
70  uint16_t ct = 234;
71 };
72 
73 } // namespace Hue
Definition: Bridge.h:29
bool getAttribute(Attribute attr, unsigned &value) const override
Get the (cached) device attribute value.
Definition: DimmableDevice.h:33
Definition: DimmableDevice.h:26
Status setAttribute(Attribute attr, unsigned value, Callback callback) override
Set a device attribute.
Definition: DimmableDevice.h:44
Definition: ColourDevice.h:26
The String class.
Definition: WString.h:136
Status
Status of a setAttribute request.
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:60
Status setAttribute(Attribute attr, unsigned value, Callback callback) override
Set a device attribute.
Definition: ColourDevice.h:50
Definition: Delegate.h:20
bool getAttribute(Attribute attr, unsigned &value) const override
Get the (cached) device attribute value.
Definition: ColourDevice.h:33
The action was performed immediately without error.
ColourDevice(ID id, const String &name)
Definition: ColourDevice.h:29
Attribute
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:97
uint32_t ID
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:95