-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlyncLightByte.ts
41 lines (38 loc) · 969 Bytes
/
BlyncLightByte.ts
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
import {
BlyncLightLevelEnum,
BlyncLightStatusEnum,
BlyncBlinkSpeedEnum,
} from '../enums'
/**
* LightOptions byte => Bit5-Bit0
Bit0 Light Status:
- 0 : Light On
- 1 : Light Off
Bit1 Light Level:
- 0 : Full (Brightness)
- 1 : Dim (50% Brightness)
Bit2 Blink Status:
- 0 : No Flash
- 1 : Start Flash (Blink)
Bit5-Bit3 Blink speed:
- 001 : Slow
- 010 : Medium
- 100 : Fast
*/
export class BlyncLightByte {
private lightStatusBit: BlyncLightStatusEnum
private lightLevelBit: BlyncLightLevelEnum
private blinkSpeedBits: BlyncBlinkSpeedEnum
constructor(
lightStatusBit = BlyncLightStatusEnum.OFF,
lightLevelBit = BlyncLightLevelEnum.FULL,
blinkSpeedBits = BlyncBlinkSpeedEnum.OFF
) {
this.lightStatusBit = lightStatusBit
this.lightLevelBit = lightLevelBit
this.blinkSpeedBits = blinkSpeedBits
}
getByteValue(): number {
return this.lightStatusBit + this.lightLevelBit + this.blinkSpeedBits
}
}