diff --git a/control.go b/control.go index 589dcab..7372176 100644 --- a/control.go +++ b/control.go @@ -41,6 +41,6 @@ var offCmd = &cobra.Command{ } defer led.ws.Fini() - _ = led.fade(off, 0) + _ = led.fade(off, minBrightness) }, } diff --git a/homekit.go b/homekit.go index cf1cea6..288335a 100644 --- a/homekit.go +++ b/homekit.go @@ -49,13 +49,13 @@ func startHomekit() { ac.Lightbulb.On.OnValueRemoteUpdate(func(on bool) { if on { klog.Infof("Switch is on") - err = led.fade(colors["white"], 150) + err = led.fade(colors["white"], maxBrightness) if err != nil { klog.Error(err) } } else { klog.Infof("Switch is off") - err = led.fade(off, 0) + err = led.fade(off, minBrightness) if err != nil { klog.Error(err) } @@ -80,7 +80,7 @@ func startHomekit() { hc.OnTermination(func() { klog.Info("terminated. turning off lights") - err = led.fade(off, 0) + err = led.fade(off, minBrightness) if err != nil { klog.Error(err) } diff --git a/main.go b/main.go index b3c813b..346304e 100644 --- a/main.go +++ b/main.go @@ -28,8 +28,8 @@ func init() { // Flags rootCmd.PersistentFlags().IntVarP(&ledCount, "led-count", "l", 12, "The number of LEDs in the array.") rootCmd.PersistentFlags().IntVar(&maxBrightness, "max-brightness", 200, "The maximum brightness that will work within the 0-250 range.") - rootCmd.PersistentFlags().IntVar(&minBrightness, "min-brightness", 30, "The minimum brightness that will work within the 0-250 range.") - rootCmd.PersistentFlags().IntVarP(&fadeDuration, "fade-duration", "f", 30, "The duration of fade-ins and fade-outs in ms.") + rootCmd.PersistentFlags().IntVar(&minBrightness, "min-brightness", 25, "The minimum brightness that will work within the 0-250 range.") + rootCmd.PersistentFlags().IntVarP(&fadeDuration, "fade-duration", "f", 100, "The duration of fade-ins and fade-outs in ms.") //Commands rootCmd.AddCommand(versionCmd) diff --git a/neopixel.go b/neopixel.go index 5ee72a8..0f5264a 100644 --- a/neopixel.go +++ b/neopixel.go @@ -58,7 +58,7 @@ func newLEDArray() (*LEDArray, error) { return nil, err } // Start off - led.brightness = 0 + led.brightness = minBrightness led.color = off return led, nil } @@ -143,13 +143,13 @@ func (led *LEDArray) fade(color uint32, target int) error { // stepRamp returns a list of steps in a brightness ramp up func stepRamp(start float64, stop float64, duration float64) []int { slope := (stop - start) / duration - klog.V(10).Infof("slope of ramp: %f", slope) + klog.V(7).Infof("slope of ramp: %f", slope) var ramp []int for i := 0; i < int(duration); i++ { point := start + (slope * float64(i)) ramp = append(ramp, int(point)) } - klog.V(10).Infof("calculated ramp: %v", ramp) + klog.V(7).Infof("calculated ramp: %v", ramp) return ramp }