更新时间:2021-12-16 03:31:39下载pdf
rhythmFormatter是一个类方法,用于照明生物节律dp点的解析和反解析。parse方法可以将固件上报的十六进制字符串解析成页面所需要的数据结构,format方法则是将对象数据反解析成遵循生物节律通用协议的十六进制字符串。
参数类型 | 是否必填 | 说明 |
---|---|---|
String | 是 | 十六进制字符串 |
参数类型 | 是否必填 | 说明 |
---|---|---|
Object | 是 | IRhythmData类型的对象 |
declare interface IRhythmData {
version: number;
power: boolean;
mode: number;
weeks: number[];
number: number;
rhythms: IRhythmItem[];
key?: number;
}
declare interface IRhythmItem {
power: boolean,
hour: number,
minute: number,
hue: number,
saturation: number,
value: number,
brightness: number,
temperature: number,
}
import { Utils, Formatter } from '@tuya/tuya-panel-lamp-sdk';
const { SupportUtils } = Utils;
const { RhythmFormatter } = Formatter;
const d = new RhythmFormatter(null,null,SupportUtils.isSupportTemp())
d.parse('0000007f0601060000000000006401061e000000006432010b1e00000000646401110000000000463201141e000000004632011500000000000000');
d.format({
version: 0,
power: false,
mode: 0,
weeks: [1, 1, 1, 1, 1, 1, 1, 0],
number: 6,
rhythms: [
{
power: true,
hour: 6,
minute: 0,
hue: 0,
saturation: 0,
value: 0,
brightness: 0,
temperature: 100,
},
{
power: true,
hour: 6,
minute: 30,
hue: 0,
saturation: 0,
value: 0,
brightness: 100,
temperature: 50,
},
{
power: true,
hour: 11,
minute: 30,
hue: 0,
saturation: 0,
value: 0,
brightness: 100,
temperature: 100,
},
{
power: true,
hour: 17,
minute: 0,
hue: 0,
saturation: 0,
value: 0,
brightness: 70,
temperature: 50,
},
{
power: true,
hour: 20,
minute: 30,
hue: 0,
saturation: 0,
value: 0,
brightness: 70,
temperature: 50,
},
{
power: true,
hour: 21,
minute: 0,
hue: 0,
saturation: 0,
value: 0,
brightness: 0,
temperature: 0,
},
],
});
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈