public HalloweenFrankGhost( IReceivesColor light, DigitalOutput2 air, AudioPlayer audioPlayer, [System.Runtime.CompilerServices.CallerMemberName] string name = "") : base(name) { pulsatingLow.ConnectTo(light); levelsPlayback.Output.Controls(b => light.SetBrightness(b, this.controlToken)); OutputPower.Subscribe(x => { if (x) { LockDevices(air, light); air.SetValue(true, this.controlToken); light.SetColor(Color.Red, this.controlToken); pulsatingLow.Start(token: this.controlToken); } else { pulsatingLow.Stop(); UnlockDevices(); } }); PowerOn .SetLoop(true) .SetMaxRuntime(S(60)) .SetUp(ins => { pulsatingLow.Stop(); }) .RunAction(ins => { audioPlayer.PlayEffect("Thriller2.wav", levelsPlayback); // The control token is optional since it's passed in via the Subroutine light.SetColor(Color.Purple); var cts = levelsPlayback.Start(this.controlToken); ins.WaitFor(S(45)); cts.Cancel(); }) .TearDown(ins => { light.SetColor(Color.Red); pulsatingLow.Start(token: this.controlToken); }); PowerOff.RunAction(ins => { audioPlayer.PlayEffect("Happy Halloween.wav", 0.15); ins.WaitFor(S(5)); }); }
public override void Execute(IReceivesColor device, ChannelEffectInstance.DeviceType deviceType, IControlToken token) { var currentColor = device.GetCurrentColor(); switch (deviceType) { case ChannelEffectInstance.DeviceType.ColorR: device.SetColor(Color.FromArgb((int)(Brightness * 255), currentColor.G, currentColor.B), 1, token); break; case ChannelEffectInstance.DeviceType.ColorG: device.SetColor(Color.FromArgb(currentColor.R, (int)(Brightness * 255), currentColor.B), 1, token); break; case ChannelEffectInstance.DeviceType.ColorB: device.SetColor(Color.FromArgb(currentColor.R, currentColor.G, (int)(Brightness * 255)), 1, token); break; } }
public override void Execute(IReceivesColor device, ChannelEffectInstance.DeviceType deviceType, IControlToken token) { Executor.Current.MasterEffect.Shimmer(new LogicalDevice.VirtualDevice(b => { var currentColor = device.GetCurrentColor(); switch (deviceType) { case ChannelEffectInstance.DeviceType.ColorR: device.SetColor(Color.FromArgb((int)(b * 255), currentColor.G, currentColor.B), 1, token); break; case ChannelEffectInstance.DeviceType.ColorG: device.SetColor(Color.FromArgb(currentColor.R, (int)(b * 255), currentColor.B), 1, token); break; case ChannelEffectInstance.DeviceType.ColorB: device.SetColor(Color.FromArgb(currentColor.R, currentColor.G, (int)(b * 255)), 1, token); break; } }), StartBrightness, EndBrightness, DurationMs, token: token); }
public override void Execute(IReceivesColor device, ChannelEffectInstance.DeviceType deviceType, IControlToken token) { Executor.Current.MasterEffect.Shimmer(new LogicalDevice.VirtualDevice(b => { var currentColor = device.Color; switch (deviceType) { case ChannelEffectInstance.DeviceType.ColorR: device.SetColor(Color.FromArgb((int)(b * 255), currentColor.G, currentColor.B), 1, token); break; case ChannelEffectInstance.DeviceType.ColorG: device.SetColor(Color.FromArgb(currentColor.R, (int)(b * 255), currentColor.B), 1, token); break; case ChannelEffectInstance.DeviceType.ColorB: device.SetColor(Color.FromArgb(currentColor.R, currentColor.G, (int)(b * 255)), 1, token); break; } }), StartBrightness, EndBrightness, DurationMs, token: token); }
public override void Execute(IReceivesColor device, ChannelEffectInstance.DeviceType deviceType, IControlToken token) { var currentColor = device.Color; switch (deviceType) { case ChannelEffectInstance.DeviceType.ColorR: device.SetColor(Color.FromArgb((int)(Brightness * 255), currentColor.G, currentColor.B), 1, token); break; case ChannelEffectInstance.DeviceType.ColorG: device.SetColor(Color.FromArgb(currentColor.R, (int)(Brightness * 255), currentColor.B), 1, token); break; case ChannelEffectInstance.DeviceType.ColorB: device.SetColor(Color.FromArgb(currentColor.R, currentColor.G, (int)(Brightness * 255)), 1, token); break; } }
public static void SetColor(this IReceivesColor device, Color color, IControlToken token = null) { device.SetColor(color, null, token); }