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)
	})
}
Exemplo n.º 2
0
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)
	})
}
Exemplo n.º 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)
	})
}