@ledvance/ui-biz-bundle 1.1.55 → 1.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/modules/biorhythm/Router.ts +34 -0
- package/src/modules/fixedTime/Router.ts +26 -0
- package/src/modules/flags/FlagActions.ts +12 -4
- package/src/modules/flags/FlagPage.tsx +31 -11
- package/src/modules/flags/Router.ts +25 -0
- package/src/modules/history/Router.ts +16 -0
- package/src/modules/mood/FantasyRouter.ts +35 -0
- package/src/modules/mood/MixMood/Router.ts +44 -0
- package/src/modules/mood/Router.ts +53 -0
- package/src/modules/music/Router.ts +16 -0
- package/src/modules/powerOnBehavior/Router.ts +16 -0
- package/src/modules/randomTime/Router.ts +25 -0
- package/src/modules/sleepWakeup/Router.ts +25 -0
- package/src/modules/timeSchedule/Router.ts +25 -0
- package/src/modules/timer/Router.ts +16 -0
- package/src/navigation/Routers.d.ts +0 -7
- package/src/navigation/Routers.ts +15 -304
- package/src/newModules/childLock/ChildLockPage.tsx +97 -0
- package/src/newModules/childLock/Router.ts +16 -0
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -0
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -0
- package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +321 -0
- package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +392 -0
- package/src/newModules/energyConsumption/Router.ts +34 -0
- package/src/newModules/energyConsumption/co2Data.ts +23655 -0
- package/src/newModules/energyConsumption/component/BarChart.tsx +93 -0
- package/src/newModules/energyConsumption/component/EnergyModal.tsx +282 -0
- package/src/newModules/energyConsumption/component/Overview.tsx +116 -0
- package/src/newModules/fixedTime/FixedTimeActions.ts +234 -0
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +341 -0
- package/src/newModules/fixedTime/FixedTimePage.tsx +231 -0
- package/src/newModules/fixedTime/Router.ts +25 -0
- package/src/newModules/lightMode/LightModePage.tsx +204 -0
- package/src/newModules/lightMode/Router.ts +16 -0
- package/src/newModules/mood/AddMoodPage.tsx +178 -0
- package/src/newModules/mood/DynamicMoodEditorPage.tsx +653 -0
- package/src/newModules/mood/Interface.ts +219 -0
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +781 -0
- package/src/newModules/mood/MoodActions.ts +235 -0
- package/src/newModules/mood/MoodInfo.ts +2151 -0
- package/src/newModules/mood/MoodItem.tsx +148 -0
- package/src/newModules/mood/MoodPage.tsx +385 -0
- package/src/newModules/mood/MoodParse.ts +442 -0
- package/src/newModules/mood/RecommendMoodItem.tsx +68 -0
- package/src/newModules/mood/Router.ts +53 -0
- package/src/newModules/mood/StaticMoodEditorPage.tsx +343 -0
- package/src/newModules/mood/tools.ts +12 -0
- package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -0
- package/src/newModules/overchargeSwitch/Router.ts +16 -0
- package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -0
- package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -0
- package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -0
- package/src/newModules/powerOnBehavior/Router.ts +16 -0
- package/src/newModules/randomTime/RandomTimeActions.ts +232 -0
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +322 -0
- package/src/newModules/randomTime/RandomTimePage.tsx +230 -0
- package/src/newModules/randomTime/Router.ts +25 -0
- package/src/newModules/randomTime/Summary.tsx +116 -0
- package/src/newModules/swithInching/Router.ts +16 -0
- package/src/newModules/swithInching/SwithInching.tsx +231 -0
- package/src/newModules/swithInching/SwithInchingAction.ts +55 -0
- package/src/newModules/swithInching/pickerView.tsx +91 -0
- package/src/newModules/timeSchedule/Interface.ts +111 -0
- package/src/newModules/timeSchedule/Router.ts +25 -0
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -0
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +662 -0
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +222 -0
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +259 -0
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +109 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { hex2Int, spliceByStep } from '@ledvance/base/src/utils/common';
|
|
2
|
+
import { Utils } from '@tuya/tuya-panel-lamp-sdk';
|
|
3
|
+
import { MoodInfo, MoodNodeInfo } from './Interface';
|
|
4
|
+
import { getDefaultMood } from './MoodInfo';
|
|
5
|
+
const { nToHS, toFixed, sToN } = Utils;
|
|
6
|
+
|
|
7
|
+
// light source
|
|
8
|
+
export function dp2Obj(dp: string, isFan: boolean = false, isUVCFan?: boolean): MoodInfo {
|
|
9
|
+
if (!dp) return getDefaultMood();
|
|
10
|
+
let dpCopy = dp;
|
|
11
|
+
let fanEnable: undefined | boolean = undefined;
|
|
12
|
+
let fanSpeed: undefined | number = undefined;
|
|
13
|
+
let mode = 0;
|
|
14
|
+
let speed = 75;
|
|
15
|
+
const id = hex2Int(dpCopy.slice(0, 2));
|
|
16
|
+
dpCopy = dpCopy.slice(2);
|
|
17
|
+
if (isFan) {
|
|
18
|
+
fanEnable = hex2Int(dpCopy.slice(0, 2)) === 1;
|
|
19
|
+
dpCopy = dpCopy.slice(2);
|
|
20
|
+
fanSpeed = hex2Int(dpCopy.slice(0, 2));
|
|
21
|
+
dpCopy = dpCopy.slice(2);
|
|
22
|
+
}
|
|
23
|
+
const nodes: MoodNodeInfo[] = spliceByStep(dpCopy, 26).map(nodeHex => {
|
|
24
|
+
let hex = nodeHex;
|
|
25
|
+
speed = isUVCFan ? 101 - hex2Int(hex.slice(0, 2)) : hex2Int(hex.slice(0, 2));
|
|
26
|
+
hex = hex.slice(2);
|
|
27
|
+
speed = isUVCFan ? 101 - hex2Int(hex.slice(0, 2)) : hex2Int(hex.slice(0, 2));
|
|
28
|
+
hex = hex.slice(2);
|
|
29
|
+
mode = hex2Int(hex.slice(0, 2));
|
|
30
|
+
hex = hex.slice(2);
|
|
31
|
+
const h = hex2Int(hex.slice(0, 4));
|
|
32
|
+
hex = hex.slice(4);
|
|
33
|
+
const s = Math.round(hex2Int(hex.slice(0, 4)) / 10);
|
|
34
|
+
hex = hex.slice(4);
|
|
35
|
+
const v = Math.round(hex2Int(hex.slice(0, 4)) / 10);
|
|
36
|
+
hex = hex.slice(4);
|
|
37
|
+
const brightness = Math.round(hex2Int(hex.slice(0, 4)) / 10);
|
|
38
|
+
hex = hex.slice(4);
|
|
39
|
+
const colorTemp = Math.round(hex2Int(hex.slice(0, 4)) / 10);
|
|
40
|
+
const isColorNode = h !== 0 || s !== 0 || v !== 0;
|
|
41
|
+
return {
|
|
42
|
+
h,
|
|
43
|
+
s,
|
|
44
|
+
v,
|
|
45
|
+
brightness,
|
|
46
|
+
colorTemp,
|
|
47
|
+
isColorNode,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
id,
|
|
52
|
+
version: 0,
|
|
53
|
+
mainLamp: {
|
|
54
|
+
mode,
|
|
55
|
+
speed,
|
|
56
|
+
fanEnable,
|
|
57
|
+
fanSpeed,
|
|
58
|
+
nodes,
|
|
59
|
+
enable: true,
|
|
60
|
+
},
|
|
61
|
+
secondaryLamp: {
|
|
62
|
+
mode: 0,
|
|
63
|
+
speed: 100,
|
|
64
|
+
nodes: [],
|
|
65
|
+
enable: true,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function obj2Dp(mood: MoodInfo, isFan: boolean = false, isUVCFan?: boolean): string {
|
|
71
|
+
const { mainLamp } = mood;
|
|
72
|
+
let fanEnableHex = '';
|
|
73
|
+
let fanSpeedHex = '';
|
|
74
|
+
const idHex = mood.id.toString(16).padStart(2, '0');
|
|
75
|
+
if (isFan) {
|
|
76
|
+
fanEnableHex = (mainLamp.fanEnable ? 1 : 0).toString(16).padStart(2, '0');
|
|
77
|
+
fanSpeedHex = (mainLamp.fanSpeed || 1).toString(16).padStart(2, '0');
|
|
78
|
+
}
|
|
79
|
+
const hex =
|
|
80
|
+
idHex +
|
|
81
|
+
fanEnableHex +
|
|
82
|
+
fanSpeedHex +
|
|
83
|
+
mainLamp.nodes
|
|
84
|
+
?.map(node => {
|
|
85
|
+
const switchingIntervalHex = (isUVCFan ? 101 - mainLamp.speed : mainLamp.speed)
|
|
86
|
+
.toString(16)
|
|
87
|
+
.padStart(2, '0');
|
|
88
|
+
const transitionTimeHex = (isUVCFan ? 101 - mainLamp.speed : mainLamp.speed)
|
|
89
|
+
.toString(16)
|
|
90
|
+
.padStart(2, '0');
|
|
91
|
+
const transitionModeHex = mainLamp.mode.toString(16).padStart(2, '0');
|
|
92
|
+
const hHex = node.h.toString(16).padStart(4, '0');
|
|
93
|
+
const sHex = (node.s * 10).toString(16).padStart(4, '0');
|
|
94
|
+
const vHex = (node.v * 10).toString(16).padStart(4, '0');
|
|
95
|
+
const brightnessHex = (node.brightness * 10).toString(16).padStart(4, '0');
|
|
96
|
+
const colorTempHex = (node.colorTemp * 10).toString(16).padStart(4, '0');
|
|
97
|
+
return (
|
|
98
|
+
switchingIntervalHex +
|
|
99
|
+
transitionTimeHex +
|
|
100
|
+
transitionModeHex +
|
|
101
|
+
hHex +
|
|
102
|
+
sHex +
|
|
103
|
+
vHex +
|
|
104
|
+
brightnessHex +
|
|
105
|
+
colorTempHex
|
|
106
|
+
);
|
|
107
|
+
})
|
|
108
|
+
.join('');
|
|
109
|
+
return hex;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// strip,string light
|
|
113
|
+
export function stripDp2Obj(dp: string, isStringLight: boolean = false): MoodInfo {
|
|
114
|
+
if (!dp) return getDefaultMood();
|
|
115
|
+
const version = hex2Int(dp.slice(0, 2));
|
|
116
|
+
const id = hex2Int(dp.slice(2, 4));
|
|
117
|
+
const mode = hex2Int(dp.slice(4, 6));
|
|
118
|
+
const intervalTime = hex2Int(dp.slice(6, 8));
|
|
119
|
+
const changeTime = hex2Int(dp.slice(8, 10));
|
|
120
|
+
const speed = intervalTime || changeTime;
|
|
121
|
+
const optionA = hex2Int(dp.slice(10, 12)).toString(2).padStart(8, '0');
|
|
122
|
+
const segmented = sToN(optionA.slice(0, 1), 2);
|
|
123
|
+
const loop = sToN(optionA.slice(1, 2), 2);
|
|
124
|
+
const excessive = sToN(optionA.slice(2, 3), 2);
|
|
125
|
+
const direction = sToN(optionA.slice(3, 4), 2);
|
|
126
|
+
const expand = sToN(optionA.slice(4, 6), 2);
|
|
127
|
+
const reserved1 = sToN(optionA.slice(6, 7), 2);
|
|
128
|
+
const reserved2 = sToN(optionA.slice(7, 8), 2);
|
|
129
|
+
// 这两个目前灯具用不上
|
|
130
|
+
// const optionB = toN(dp.slice(12, 14))
|
|
131
|
+
// const optionC = toN(dp.slice(14, 16))
|
|
132
|
+
let nodes = [] as MoodNodeInfo[];
|
|
133
|
+
if (isStringLight) {
|
|
134
|
+
nodes = spliceByStep(dp.slice(16, dp.length), 16).map(nodeHex => {
|
|
135
|
+
const v = hex2Int(nodeHex.slice(0, 2));
|
|
136
|
+
const h = hex2Int(nodeHex.slice(2, 6));
|
|
137
|
+
const s = hex2Int(nodeHex.slice(6, 8));
|
|
138
|
+
const brightness = hex2Int(nodeHex.slice(8, 12)) / 10;
|
|
139
|
+
const colorTemp = hex2Int(nodeHex.slice(12, 16)) / 10;
|
|
140
|
+
const isColorNode = v > 0 && brightness === 0;
|
|
141
|
+
return { h, s, v, brightness, colorTemp, isColorNode };
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
const bright = hex2Int(dp.slice(16, 18));
|
|
145
|
+
nodes = spliceByStep(dp.slice(18, dp.length), 6).map(nodeHex => {
|
|
146
|
+
const h = hex2Int(nodeHex.slice(0, 4));
|
|
147
|
+
const s = hex2Int(nodeHex.slice(4, 6));
|
|
148
|
+
const v = bright;
|
|
149
|
+
const brightness = 0;
|
|
150
|
+
const colorTemp = 0;
|
|
151
|
+
const isColorNode = true;
|
|
152
|
+
return { h, s, v, brightness, colorTemp, isColorNode };
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
version,
|
|
158
|
+
id,
|
|
159
|
+
mainLamp: {
|
|
160
|
+
mode,
|
|
161
|
+
speed,
|
|
162
|
+
direction,
|
|
163
|
+
segmented,
|
|
164
|
+
loop,
|
|
165
|
+
excessive,
|
|
166
|
+
expand,
|
|
167
|
+
reserved1,
|
|
168
|
+
reserved2,
|
|
169
|
+
nodes,
|
|
170
|
+
enable: true,
|
|
171
|
+
},
|
|
172
|
+
secondaryLamp: {
|
|
173
|
+
mode,
|
|
174
|
+
speed,
|
|
175
|
+
nodes: [],
|
|
176
|
+
enable: true,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function stripObj2Dp(mood: MoodInfo, isStringLight: boolean = false) {
|
|
182
|
+
const {
|
|
183
|
+
expand = 0,
|
|
184
|
+
reserved1 = 0,
|
|
185
|
+
reserved2 = 0,
|
|
186
|
+
// mixedIds = [],
|
|
187
|
+
segmented = 0,
|
|
188
|
+
loop = 0,
|
|
189
|
+
excessive = 0,
|
|
190
|
+
direction = 0,
|
|
191
|
+
mode,
|
|
192
|
+
speed,
|
|
193
|
+
nodes,
|
|
194
|
+
} = mood.mainLamp;
|
|
195
|
+
const versionHex = nToHS(mood.version);
|
|
196
|
+
const idHex = nToHS(mood.id);
|
|
197
|
+
const modeHex = nToHS(mode);
|
|
198
|
+
const intervalTimeHex = nToHS(speed);
|
|
199
|
+
const changeTimeHex = nToHS(speed);
|
|
200
|
+
const optionAHex = nToHS(
|
|
201
|
+
parseInt(
|
|
202
|
+
`${segmented}${loop}${excessive}${direction}${toFixed(
|
|
203
|
+
expand.toString(2),
|
|
204
|
+
2
|
|
205
|
+
)}${reserved1}${reserved2}`,
|
|
206
|
+
2
|
|
207
|
+
)
|
|
208
|
+
);
|
|
209
|
+
const optionBHex = nToHS(0);
|
|
210
|
+
const optionCHex = nToHS(0);
|
|
211
|
+
let nodeHex = '';
|
|
212
|
+
if (isStringLight) {
|
|
213
|
+
nodeHex = nodes
|
|
214
|
+
.map(node => {
|
|
215
|
+
return `${nToHS(node.v)}${nToHS(node.h, 4)}${nToHS(node.s)}${nToHS(
|
|
216
|
+
node.brightness * 10,
|
|
217
|
+
4
|
|
218
|
+
)}${nToHS(node.colorTemp * 10, 4)}`;
|
|
219
|
+
})
|
|
220
|
+
.join('');
|
|
221
|
+
} else {
|
|
222
|
+
const brightHex = nToHS(nodes[0].v);
|
|
223
|
+
nodeHex =
|
|
224
|
+
brightHex +
|
|
225
|
+
nodes
|
|
226
|
+
.map(node => {
|
|
227
|
+
return `${nToHS(node.h, 4)}${nToHS(node.s)}`;
|
|
228
|
+
})
|
|
229
|
+
.join('');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
versionHex +
|
|
234
|
+
idHex +
|
|
235
|
+
modeHex +
|
|
236
|
+
intervalTimeHex +
|
|
237
|
+
changeTimeHex +
|
|
238
|
+
optionAHex +
|
|
239
|
+
optionBHex +
|
|
240
|
+
optionCHex +
|
|
241
|
+
nodeHex
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// mix light
|
|
246
|
+
export function MixObj2Dp(mood: MoodInfo) {
|
|
247
|
+
const { mainLamp, secondaryLamp } = mood;
|
|
248
|
+
const versionHex = nToHS(mood.version);
|
|
249
|
+
const idHex = nToHS(mood.id);
|
|
250
|
+
const lamps = [mainLamp, secondaryLamp];
|
|
251
|
+
const lampsHex = lamps
|
|
252
|
+
.map(lamp => {
|
|
253
|
+
let lampHex = lamp.enable ? '01' : '00';
|
|
254
|
+
const nodes = lamp.nodes || [];
|
|
255
|
+
lampHex += nToHS(nodes.length || 0);
|
|
256
|
+
if (nodes.length === 0 || !lamp.enable) {
|
|
257
|
+
return lampHex;
|
|
258
|
+
}
|
|
259
|
+
lampHex += nToHS(lamp.type);
|
|
260
|
+
lampHex += nodes
|
|
261
|
+
.map(node => {
|
|
262
|
+
let nodeHex = '';
|
|
263
|
+
nodeHex += nToHS(lamp.speed);
|
|
264
|
+
nodeHex += nToHS(lamp.speed);
|
|
265
|
+
nodeHex += nToHS(lamp.mode);
|
|
266
|
+
switch (
|
|
267
|
+
lamp.type // 1:W 只有亮度,2:CW 亮度+色温,3:RGB HSV,4:RGBC HSV+色温,5:RGBCW HSV+色温+亮度
|
|
268
|
+
) {
|
|
269
|
+
case 1:
|
|
270
|
+
nodeHex += nToHS(node.brightness * 10, 4);
|
|
271
|
+
break;
|
|
272
|
+
case 2:
|
|
273
|
+
nodeHex += nToHS(node.brightness * 10, 4);
|
|
274
|
+
nodeHex += nToHS(node.colorTemp * 10, 4);
|
|
275
|
+
break;
|
|
276
|
+
case 3:
|
|
277
|
+
nodeHex += nToHS(node.h, 4);
|
|
278
|
+
nodeHex += nToHS(node.s * 10, 4);
|
|
279
|
+
nodeHex += nToHS(node.v * 10, 4);
|
|
280
|
+
break;
|
|
281
|
+
case 4:
|
|
282
|
+
nodeHex += nToHS(node.h, 4);
|
|
283
|
+
nodeHex += nToHS(node.s * 10, 4);
|
|
284
|
+
nodeHex += nToHS(node.v * 10, 4);
|
|
285
|
+
nodeHex += nToHS(node.colorTemp * 10, 4);
|
|
286
|
+
break;
|
|
287
|
+
case 5:
|
|
288
|
+
nodeHex += nToHS(node.h, 4);
|
|
289
|
+
nodeHex += nToHS(node.s * 10, 4);
|
|
290
|
+
nodeHex += nToHS(node.v * 10, 4);
|
|
291
|
+
nodeHex += nToHS(node.brightness * 10, 4);
|
|
292
|
+
nodeHex += nToHS(node.colorTemp * 10, 4);
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
return nodeHex;
|
|
296
|
+
})
|
|
297
|
+
.join('');
|
|
298
|
+
return lampHex;
|
|
299
|
+
})
|
|
300
|
+
.join('');
|
|
301
|
+
return versionHex + idHex + lampsHex;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function MixDp2Obj(dp: string): MoodInfo {
|
|
305
|
+
if (!dp) return getDefaultMood();
|
|
306
|
+
const result = { mainLamp: {}, secondaryLamp: {} } as MoodInfo;
|
|
307
|
+
result.version = sToN(dp.slice(0, 2));
|
|
308
|
+
result.id = sToN(dp.slice(2, 4));
|
|
309
|
+
const mainEnable = sToN(dp.slice(4, 6)) === 1;
|
|
310
|
+
const mainNum = sToN(dp.slice(6, 8));
|
|
311
|
+
let sliceDp = dp.slice(8);
|
|
312
|
+
result.mainLamp.enable = mainEnable;
|
|
313
|
+
result.mainLamp.nodes = [];
|
|
314
|
+
if (mainEnable && mainNum) {
|
|
315
|
+
result.mainLamp.type = sToN(sliceDp.slice(0, 2));
|
|
316
|
+
sliceDp = sliceDp.slice(2);
|
|
317
|
+
for (let i = 0; i < mainNum; i++) {
|
|
318
|
+
result.mainLamp.speed = sToN(sliceDp.slice(0, 2));
|
|
319
|
+
result.mainLamp.mode = sToN(sliceDp.slice(4, 6));
|
|
320
|
+
sliceDp = sliceDp.slice(6);
|
|
321
|
+
const node = {} as MoodNodeInfo;
|
|
322
|
+
switch (result.mainLamp.type) {
|
|
323
|
+
case 1:
|
|
324
|
+
node.brightness = sToN(sliceDp.slice(0, 4)) / 10;
|
|
325
|
+
node.isColorNode = false;
|
|
326
|
+
sliceDp = sliceDp.slice(4);
|
|
327
|
+
break;
|
|
328
|
+
case 2:
|
|
329
|
+
node.brightness = sToN(sliceDp.slice(0, 4)) / 10;
|
|
330
|
+
node.colorTemp = sToN(sliceDp.slice(4, 8)) / 10;
|
|
331
|
+
node.isColorNode = false;
|
|
332
|
+
sliceDp = sliceDp.slice(8);
|
|
333
|
+
break;
|
|
334
|
+
case 3:
|
|
335
|
+
node.h = sToN(sliceDp.slice(0, 4));
|
|
336
|
+
node.s = sToN(sliceDp.slice(4, 8)) / 10;
|
|
337
|
+
node.v = sToN(sliceDp.slice(8, 12)) / 10;
|
|
338
|
+
node.isColorNode = true;
|
|
339
|
+
sliceDp = sliceDp.slice(12);
|
|
340
|
+
break;
|
|
341
|
+
case 4:
|
|
342
|
+
node.h = sToN(sliceDp.slice(0, 4));
|
|
343
|
+
node.s = sToN(sliceDp.slice(4, 8)) / 10;
|
|
344
|
+
node.v = sToN(sliceDp.slice(8, 12)) / 10;
|
|
345
|
+
node.colorTemp = sToN(sliceDp.slice(12, 16)) / 10;
|
|
346
|
+
node.isColorNode = true;
|
|
347
|
+
sliceDp = sliceDp.slice(16);
|
|
348
|
+
break;
|
|
349
|
+
case 5:
|
|
350
|
+
node.h = sToN(sliceDp.slice(0, 4));
|
|
351
|
+
node.s = sToN(sliceDp.slice(4, 8)) / 10;
|
|
352
|
+
node.v = sToN(sliceDp.slice(8, 12)) / 10;
|
|
353
|
+
node.brightness = sToN(sliceDp.slice(12, 16)) / 10;
|
|
354
|
+
node.colorTemp = sToN(sliceDp.slice(16, 20)) / 10;
|
|
355
|
+
node.isColorNode = true;
|
|
356
|
+
sliceDp = sliceDp.slice(20);
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
result.mainLamp.nodes.push(node);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const secondaryEnable = sToN(sliceDp.slice(0, 2)) === 1;
|
|
363
|
+
const secondaryNum = sToN(sliceDp.slice(2, 4));
|
|
364
|
+
result.secondaryLamp.enable = secondaryEnable;
|
|
365
|
+
result.secondaryLamp.nodes = [];
|
|
366
|
+
sliceDp = sliceDp.slice(4);
|
|
367
|
+
if (secondaryEnable && secondaryNum) {
|
|
368
|
+
result.secondaryLamp.type = sToN(sliceDp.slice(0, 2));
|
|
369
|
+
sliceDp = sliceDp.slice(2);
|
|
370
|
+
for (let i = 0; i < secondaryNum; i++) {
|
|
371
|
+
result.secondaryLamp.speed = sToN(sliceDp.slice(0, 2));
|
|
372
|
+
result.secondaryLamp.mode = sToN(sliceDp.slice(4, 6));
|
|
373
|
+
sliceDp = sliceDp.slice(6);
|
|
374
|
+
const node = {} as MoodNodeInfo;
|
|
375
|
+
switch (result.secondaryLamp.type) {
|
|
376
|
+
case 1:
|
|
377
|
+
node.brightness = sToN(sliceDp.slice(0, 4)) / 10;
|
|
378
|
+
node.isColorNode = true;
|
|
379
|
+
sliceDp = sliceDp.slice(4);
|
|
380
|
+
break;
|
|
381
|
+
case 2:
|
|
382
|
+
node.brightness = sToN(sliceDp.slice(0, 4)) / 10;
|
|
383
|
+
node.colorTemp = sToN(sliceDp.slice(4, 8)) / 10;
|
|
384
|
+
node.isColorNode = false;
|
|
385
|
+
sliceDp = sliceDp.slice(8);
|
|
386
|
+
break;
|
|
387
|
+
case 3:
|
|
388
|
+
node.h = sToN(sliceDp.slice(0, 4));
|
|
389
|
+
node.s = sToN(sliceDp.slice(4, 8)) / 10;
|
|
390
|
+
node.v = sToN(sliceDp.slice(8, 12)) / 10;
|
|
391
|
+
node.isColorNode = true;
|
|
392
|
+
sliceDp = sliceDp.slice(12);
|
|
393
|
+
break;
|
|
394
|
+
case 4:
|
|
395
|
+
node.h = sToN(sliceDp.slice(0, 4));
|
|
396
|
+
node.s = sToN(sliceDp.slice(4, 8)) / 10;
|
|
397
|
+
node.v = sToN(sliceDp.slice(8, 12)) / 10;
|
|
398
|
+
node.colorTemp = sToN(sliceDp.slice(12, 16)) / 10;
|
|
399
|
+
node.isColorNode = true;
|
|
400
|
+
sliceDp = sliceDp.slice(16);
|
|
401
|
+
break;
|
|
402
|
+
case 5:
|
|
403
|
+
node.h = sToN(sliceDp.slice(0, 4));
|
|
404
|
+
node.s = sToN(sliceDp.slice(4, 8)) / 10;
|
|
405
|
+
node.v = sToN(sliceDp.slice(8, 12)) / 10;
|
|
406
|
+
node.brightness = sToN(sliceDp.slice(12, 16)) / 10;
|
|
407
|
+
node.colorTemp = sToN(sliceDp.slice(16, 20)) / 10;
|
|
408
|
+
node.isColorNode = true;
|
|
409
|
+
sliceDp = sliceDp.slice(20);
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
result.secondaryLamp.nodes.push(node);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return result;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export function MixCeilingDpObj(mainDp: string, secondaryDp: string): MoodInfo {
|
|
420
|
+
const mainLamp = dp2Obj(mainDp);
|
|
421
|
+
const secondaryLamp = secondaryDp ? stripDp2Obj(secondaryDp) : '';
|
|
422
|
+
return {
|
|
423
|
+
id: 0,
|
|
424
|
+
version: 0,
|
|
425
|
+
mainLamp: {
|
|
426
|
+
id: mainLamp.id,
|
|
427
|
+
version: mainLamp.version,
|
|
428
|
+
...mainLamp.mainLamp,
|
|
429
|
+
},
|
|
430
|
+
secondaryLamp: secondaryLamp
|
|
431
|
+
? {
|
|
432
|
+
id: secondaryLamp.id,
|
|
433
|
+
version: secondaryLamp.version,
|
|
434
|
+
...secondaryLamp.secondaryLamp,
|
|
435
|
+
}
|
|
436
|
+
: {
|
|
437
|
+
mode: 0,
|
|
438
|
+
speed: 75,
|
|
439
|
+
nodes: [],
|
|
440
|
+
},
|
|
441
|
+
};
|
|
442
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Utils } from 'tuya-panel-kit';
|
|
3
|
+
import Card from '@ledvance/base/src/components/Card';
|
|
4
|
+
import { CellContent } from '@ledvance/base/src/components/Cell';
|
|
5
|
+
import { StyleSheet, View } from 'react-native';
|
|
6
|
+
import Spacer from '@ledvance/base/src/components/Spacer';
|
|
7
|
+
import { MoodUIInfo } from './Interface';
|
|
8
|
+
import { MixMoodColorsLine } from './MoodItem';
|
|
9
|
+
|
|
10
|
+
const cx = Utils.RatioUtils.convertX;
|
|
11
|
+
|
|
12
|
+
interface RecommendMixMoodItemProps {
|
|
13
|
+
title: string;
|
|
14
|
+
isMix: boolean;
|
|
15
|
+
mood: MoodUIInfo;
|
|
16
|
+
onPress: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const RecommendMixMoodItem = (props: RecommendMixMoodItemProps) => {
|
|
20
|
+
const { mood, isMix } = props;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Card style={styles.root} onPress={props.onPress}>
|
|
24
|
+
<CellContent
|
|
25
|
+
title={props.title}
|
|
26
|
+
value={''}
|
|
27
|
+
style={styles.content}
|
|
28
|
+
titleStyle={styles.title}
|
|
29
|
+
iconStyle={{
|
|
30
|
+
color: '#000',
|
|
31
|
+
size: cx(16),
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
{!!(mood.mainLamp) && (
|
|
35
|
+
<>
|
|
36
|
+
<View style={styles.lineStyle}>
|
|
37
|
+
<MixMoodColorsLine mixSubLight={mood?.mainLamp} isMix={isMix} />
|
|
38
|
+
<Spacer height={cx(7)} />
|
|
39
|
+
{isMix && <MixMoodColorsLine mixSubLight={mood.secondaryLamp} isMix={isMix} />}
|
|
40
|
+
</View>
|
|
41
|
+
<Spacer height={cx(24)} />
|
|
42
|
+
</>
|
|
43
|
+
)}
|
|
44
|
+
</Card>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const styles = StyleSheet.create({
|
|
49
|
+
root: {
|
|
50
|
+
flexDirection: 'row',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
marginHorizontal: cx(24),
|
|
53
|
+
},
|
|
54
|
+
content: {
|
|
55
|
+
height: cx(56),
|
|
56
|
+
marginHorizontal: cx(16),
|
|
57
|
+
},
|
|
58
|
+
title: {
|
|
59
|
+
color: '#000',
|
|
60
|
+
fontSize: cx(16),
|
|
61
|
+
fontFamily: 'helvetica_neue_lt_std_bd',
|
|
62
|
+
},
|
|
63
|
+
lineStyle: {
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export default RecommendMixMoodItem;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {NavigationRoute, TransitionPresets} from "tuya-panel-kit";
|
|
2
|
+
import DynamicMoodEditorPage from "../../modules/mood/DynamicMoodEditorPage";
|
|
3
|
+
import StaticMoodEditorPage from "../../modules/mood/StaticMoodEditorPage";
|
|
4
|
+
import AddMoodPage from "../../modules/mood/AddMoodPage";
|
|
5
|
+
import MoodPage from "../../modules/mood/MoodPage";
|
|
6
|
+
import SelectPage from "../../modules/select/SelectPage";
|
|
7
|
+
import {ui_biz_routerKey} from "../../navigation/Routers";
|
|
8
|
+
|
|
9
|
+
const MoodPageRouters: NavigationRoute[] = [
|
|
10
|
+
{
|
|
11
|
+
name: ui_biz_routerKey.ui_biz_dynamic_mood_edit,
|
|
12
|
+
component: DynamicMoodEditorPage,
|
|
13
|
+
options: {
|
|
14
|
+
hideTopbar: true,
|
|
15
|
+
showOfflineView: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: ui_biz_routerKey.ui_biz_static_mood_edit,
|
|
20
|
+
component: StaticMoodEditorPage,
|
|
21
|
+
options: {
|
|
22
|
+
hideTopbar: true,
|
|
23
|
+
showOfflineView: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: ui_biz_routerKey.ui_biz_mood_add,
|
|
28
|
+
component: AddMoodPage,
|
|
29
|
+
options: {
|
|
30
|
+
hideTopbar: true,
|
|
31
|
+
showOfflineView: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: ui_biz_routerKey.ui_biz_mood,
|
|
36
|
+
component: MoodPage,
|
|
37
|
+
options: {
|
|
38
|
+
hideTopbar: true,
|
|
39
|
+
showOfflineView: false,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: ui_biz_routerKey.ui_biz_select_page,
|
|
44
|
+
component: SelectPage,
|
|
45
|
+
options: {
|
|
46
|
+
gesture: true,
|
|
47
|
+
hideTopbar: true,
|
|
48
|
+
...TransitionPresets.ModalPresentationIOS,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
export default MoodPageRouters
|