diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-02-10 20:17:57 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-02-10 20:17:57 -0500 |
commit | 112202f1d77758cb8c3ed32c88bdfcfef4995f6c (patch) | |
tree | 7576c3aadeb9ac3f4f72a9e8daed09e983a3560e /light.go | |
parent | 5b7673cfc13876cde061d454982daac1bafacfd2 (diff) |
Simplified Light.ColorLoop to accept a boolean instead of having on/off/toggle modes.
Diffstat (limited to 'light.go')
-rw-r--r-- | light.go | 25 |
1 files changed, 7 insertions, 18 deletions
@@ -87,25 +87,14 @@ func (self *Light) Toggle() error { } } -// Light.ColorLoopOn will turn the light on and set the effect to "colorloop" -func (self *Light) ColorLoopOn() error { - return SetLightState(self, LightState{On: true, Effect: "colorloop"}) -} - -// Light.ColorLoopOn will turn the light on and set the effect to "none" -func (self *Light) ColorLoopOff() error { - return SetLightState(self, LightState{On: true, Effect: "none"}) -} - -// Light.ColorLoop will set the light state to a colorloop if there is no -// current effect in place or if the state is in colorloop then it will -// set it to "none". -func (self *Light) ColorLoop() error { - if self.State.Effect == "colorloop" { - return self.ColorLoopOff() - } else { - return self.ColorLoopOn() +// Light.ColorLoop will set the light state to 'colorloop' if `active` +// is true or it will set the light state to "none" if `activate` is false. +func (self *Light) ColorLoop(activate bool) error { + var state = "none" + if activate { + state = "colorloop" } + return SetLightState(self, LightState{On: true, Effect: state}) } // SetLightState will modify light attributes such as on/off, saturation, |