func BrightnessScalingEffectFactory(l devices.DimLamp) deviceapi.Effect {
	return deviceapi.EffectFunc(func(config deviceapi.Config) error {
		c, ok := config.(*BrightnessConfig)
		if !ok {
			return errors.New("Not a BrightnessConfig")
		}
		return l.BrightnessScaling(c.Brightness)
	})
}
func NewWhiteFadeEffect(l devices.DimLamp) deviceapi.Effect {
	return deviceapi.EffectFunc(func(config deviceapi.Config) error {
		strobeConf, ok := config.(*deviceapi.DelayConfig)
		if !ok {
			return errors.New("Not a WhiteFadeConfig")
		}
		delay, err := time.ParseDuration(strobeConf.Delay)
		if err != nil {
			return err
		}
		return l.Fade(delay, 255)
	})
}
Example #3
0
func StrobeEffectFactory(l devices.DimLamp) deviceapi.Effect {
	return deviceapi.EffectFunc(func(config deviceapi.Config) error {
		strobeConf, ok := config.(*deviceapi.DelayConfig)
		if !ok {
			return errors.New("Not a StrobeConfig")
		}
		delay, err := time.ParseDuration(strobeConf.Delay)
		if err != nil {
			return err
		}
		return l.Stroboscope(delay)
	})
}