-
Notifications
You must be signed in to change notification settings - Fork 0
/
light_node.cpp.diff
221 lines (198 loc) · 4.55 KB
/
light_node.cpp.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
--- ./deconz-rest-plugin/light_node.cpp 2017-03-04 23:50:14.983712234 +0100
+++ ./light_node.cpp 2017-02-28 20:36:29.672921727 +0100
@@ -9,6 +9,7 @@
*/
#include "de_web_plugin_private.h"
+#include "colorspace.h"
/*! Constructor.
*/
@@ -37,6 +38,7 @@
m_sceneCapacity(16)
{
+ pushCode ( m_pushType = PUSH_TYPE_LIGHT );
}
/*! Returns the LightNode state.
@@ -68,6 +70,8 @@
{
if (m_manufacturerCode != code)
{
+ pushSetNodeInfoCompName1 ( m_manufacturerCode, code, "manufacturerCode" );
+
m_manufacturerCode = code;
if (!m_manufacturer.isEmpty() && (m_manufacturer != QLatin1String("Unknown")))
@@ -148,6 +152,8 @@
*/
void LightNode::setName(const QString &name)
{
+ pushSetNodeInfoMemComp ( name );
+
m_name = name;
}
@@ -184,6 +190,8 @@
*/
void LightNode::setOtauClusterId(uint16_t clusterId)
{
+ pushSetNodeInfoComp ( m_otauClusterId, clusterId );
+
m_otauClusterId = clusterId;
}
@@ -220,11 +228,17 @@
case DEV_ID_ZLL_ONOFF_LIGHT:
case DEV_ID_ZLL_ONOFF_PLUGIN_UNIT:
m_level = (m_isOn ? 255 : 0);
+ pushSetNodeInfoMem ( level );
+
+ pushSetNodeInfoName ( ( int ) m_level, "bri" );
+ pushSetNodeInfoName ( ( int ) ( ( m_level * 100 ) / 253 ), "pct" );
break;
default:
break;
}
+
+ pushSetNodeState ( on, (int) m_level );
}
/*! Returns the light dimm level (0..255).
@@ -258,6 +272,16 @@
DBG_Assert(level <= 255);
if (level <= 255)
{
+ if ( m_level != level ) {
+ pushSetNodeInfo ( level );
+ pushSetNodeInfoName ( ( int ) level, "bri" );
+ if ( m_isOn ) {
+ pushSetNodeInfoName ( ( int ) ( ( level * 100 ) / 253 ), "pct" );
+ }
+ else {
+ pushSetNodeInfoName ( 0, "pct" );
+ }
+ }
m_level = level;
}
}
@@ -277,6 +301,8 @@
DBG_Assert(hue <= 254);
if (hue <= 254)
{
+ pushSetNodeInfoMemComp1 ( hue );
+
m_hue = hue;
m_normHue = ((double)hue * 360.0f / 254.0f) / 360.0f;
@@ -324,6 +350,7 @@
m_hue = m_normHue * 254.0f;
DBG_Assert(m_hue <= 254);
+ pushSetNodeInfoMemComp ( ehue );
m_ehue = ehue;
}
@@ -339,6 +366,8 @@
*/
void LightNode::setSaturation(uint8_t sat)
{
+ pushSetNodeInfoMemComp ( sat );
+
m_sat = sat;
}
@@ -361,6 +390,33 @@
y = 65279;
}
+#ifdef ENABLE_PUSH
+ float x_ = ( float ) x / ( float ) 65279;
+ float y_ = ( float ) y / ( float ) 65279;
+
+ char xy [ 64 ];
+
+ snprintf ( xy, 64, "%.6f,%.6f", x_, y_ );
+ pushSetNodeInfoName ( xy, "xy" );
+
+ pushSetNodeInfoCompName1 ( m_colorX, x, "colorX" );
+ pushSetNodeInfoCompName1 ( m_colorY, y, "colorY" );
+
+ /*num R, G, B;
+ num X = x_, Y = y_, Z = 1;
+
+ Xyz2Rgb ( &R, &G, &B, X, Y, Z );
+
+ unsigned int rgb = 0;
+ rgb |= ( unsigned int ) R; rgb <<= 8;
+ rgb |= ( unsigned int ) G; rgb <<= 8;
+ rgb |= ( unsigned int ) B;
+
+ snprintf ( xy, 64, "%06x", rgb );
+
+ pushSetNodeInfoName ( xy, "rgb" );*/
+#endif
+
m_colorX = x;
m_colorY = y;
}
@@ -393,6 +449,8 @@
*/
void LightNode::setColorTemperature(uint16_t colorTemperature)
{
+ pushSetNodeInfoMemComp ( colorTemperature );
+
m_colorTemperature = colorTemperature;
}
@@ -410,6 +468,8 @@
{
DBG_Assert((colorMode == "hs") || (colorMode == "xy") || (colorMode == "ct"));
m_colorMode = colorMode;
+
+ pushSetNodeInfoName ( colorMode, "colormode" );
}
/*! Sets the nodes color loop active state.
@@ -417,6 +477,8 @@
*/
void LightNode::setColorLoopActive(bool colorLoopActive)
{
+ pushSetNodeInfoMemComp ( colorLoopActive );
+
m_colorLoopActive = colorLoopActive;
}
@@ -431,6 +493,8 @@
*/
void LightNode::setColorLoopSpeed(uint8_t speed)
{
+ pushSetNodeInfoCompName ( m_colorLoopSpeed, speed, "colorLoopSpeed" );
+
m_colorLoopSpeed = speed;
}
@@ -527,6 +591,8 @@
*/
void LightNode::setGroupCapacity(uint8_t capacity)
{
+ pushSetNodeInfoCompName ( m_groupCapacity, capacity, "groupCapacity" );
+
m_groupCapacity = capacity;
}
@@ -542,6 +608,8 @@
*/
void LightNode::setResetRetryCount(uint8_t resetRetryCount)
{
+ pushSetNodeInfoMemComp ( resetRetryCount );
+
m_resetRetryCount = resetRetryCount;
}
@@ -557,6 +625,8 @@
*/
void LightNode::setZdpResetSeq(uint8_t zdpResetSeq)
{
+ pushSetNodeInfoMemComp ( zdpResetSeq );
+
m_zdpResetSeq = zdpResetSeq;
}
@@ -572,6 +642,8 @@
*/
void LightNode::setGroupCount(uint8_t groupCount)
{
+ pushSetNodeInfoMemComp ( groupCount );
+
m_groupCount = groupCount;
}
@@ -587,6 +659,8 @@
*/
void LightNode::setSceneCapacity(uint8_t sceneCapacity)
{
+ pushSetNodeInfoMemComp ( sceneCapacity );
+
m_sceneCapacity = sceneCapacity;
}