aboutsummaryrefslogtreecommitdiff
path: root/light.go
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-19 19:38:54 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-19 19:38:54 -0500
commit0e98a2544988b9e684eac3f79c953fce50cd4c0d (patch)
treef0c6a03e52783c5d98655cca84bbcd7412ba1f1d /light.go
parenta2235f5462fbcf5a663c6a81b1d5345a70c6b9fb (diff)
Implemented Light.SetColor with light color XY HSL values pre-defined.
Diffstat (limited to 'light.go')
-rw-r--r--light.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/light.go b/light.go
index 978a3ec..982938c 100644
--- a/light.go
+++ b/light.go
@@ -148,6 +148,30 @@ func (light *Light) ColorLoop(activate bool) error {
return light.SetState(LightState{On: true, Effect: state})
}
+// XY HSL colors used in `Light.SetColor`
+var (
+ RED = &[2]float32{0.6915, 0.3083}
+ YELLOW = &[2]float32{0.4023, 0.4725}
+ ORANGE = &[2]float32{0.4693, 0.4007}
+ GREEN = &[2]float32{0.1700, 0.7000}
+ CYAN = &[2]float32{0.1610, 0.3549}
+ BLUE = &[2]float32{0.1530, 0.0480}
+ PURPLE = &[2]float32{0.2363, 0.1154}
+ PINK = &[2]float32{0.3645, 0.1500}
+ WHITE = &[2]float32{0.3227, 0.3290}
+)
+
+// Light.SetColor requires a selection from the above light
+// color variable section and sets the light to that XY HSL color
+func (light *Light) SetColor(color *[2]float32) error {
+ lightState := LightState{On: true, XY: color}
+ err := light.SetState(lightState)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
// Light.SetState modifyies light attributes. See `LightState` struct for attributes.
// Brightness must be between 1 and 254 (inclusive)
// Hue must be between 0 and 65535 (inclusive)