-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlight.go
76 lines (65 loc) · 1.53 KB
/
light.go
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
package launchpad
// LightEffects are effects applied to pad lights and are one of:
// EffectOff, EffectStatic, EffectFlash, EffectPulse.
type LightEffect int64
const (
EffectOff LightEffect = 0x80
EffectStatic LightEffect = 0x90
EffectFlash LightEffect = 0x91
EffectPulse LightEffect = 0x92
)
// LightColor are palette-based colors used by the device for
// the pulse and flash effects, and for writing colors over the
// MIDI interface.
// LightColors are set by the devices, as colors may differ between
// devices.
type LightColor int64
// Light represents the state of a pad light
type Light struct {
Effect LightEffect
Color LightColor
Coord Coordinate
R int8
G int8
B int8
// DisplayLocked prevents Light redraws while true
DisplayLocked bool
}
// ToggleDisplayLock is used by HitFuncs to mark a light
// to not be updated by the Grid during redraw cycles.
// This is useful if you want a layer of lights to persist over
// another layer.
func (l *Light) ToggleDisplayLock() {
l.DisplayLocked = !l.DisplayLocked
}
// RGB sets RGB values on a Light
func (l *Light) RGB(r, g, b int8) {
if r < 0 {
r = -r
}
if g < 0 {
g = -g
}
if b < 0 {
b = -b
}
l.R = r
l.G = g
l.B = b
}
// Static uses static lights
func (l *Light) Static() {
l.Effect = EffectStatic
}
// Off turns a light off
func (l *Light) Off() {
l.Effect = EffectOff
}
// Pulse uses a pulsing light
func (l *Light) Pulse() {
l.Effect = EffectPulse
}
// Flash flashes between two colors
func (l *Light) Flash(a, b LightColor) {
//TODO
}