Esempio n. 1
0
        public async Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken)
        {
            if (!color.HasValue)
            {
                color = RGBColor.Random();
            }

            layer.SetState(cancellationToken, color, 1, waitTime(), false);

            //Wait for other events to finish and set state again
            await Task.Delay(waitTime(), cancellationToken);

            layer.SetState(cancellationToken, color, 1, waitTime(), false);
        }
 public void Update(Color currentColor)
 {
     if (IsConnected && !IsTesting && entertainmentLayer != null)
     {
         entertainmentLayer.SetState(CancellationToken.None, new RGBColor(currentColor.ScR, currentColor.ScG, currentColor.ScB), currentColor.ScA);
     }
 }
Esempio n. 3
0
        public static async Task SendCommandA(BeatmapEventData data, HSB hsbColor, double brightness, HSB inithsbColor, HSB endhsbColor, double time, bool gradient)
        {
            CancellationToken  token    = LightInfo.token;
            EntertainmentLayer entLayer = LightInfo.layer;

            if (gradient == true)
            {
                switch (data.value)
                {
                case 0: entLayer.SetState(token, null, brightness); break;

                case 1: entLayer.SetState(token, inithsbColor.GetRGB(), 1); await Task.Delay(TimeSpan.FromMilliseconds(20), token); entLayer.SetState(token, endhsbColor.GetRGB(), 1, TimeSpan.FromSeconds(time)); break;

                case 5: entLayer.SetState(token, inithsbColor.GetRGB(), 1); await Task.Delay(TimeSpan.FromMilliseconds(20), token); entLayer.SetState(token, endhsbColor.GetRGB(), 1, TimeSpan.FromSeconds(time)); break;
                }
            }
            else
            {
                switch (data.value)
                {
                case 0: entLayer.SetState(token, null, brightness); break;

                case 1: entLayer.SetState(token, hsbColor.GetRGB(), 1); break;

                case 2: entLayer.SetState(token, hsbColor.GetRGB(), 1); await Task.Delay(TimeSpan.FromMilliseconds(20), token); entLayer.SetState(token, hsbColor.GetRGB(), brightness, TimeSpan.FromSeconds(1)); break;

                case 3: entLayer.SetState(token, hsbColor.GetRGB(), 1); await Task.Delay(TimeSpan.FromMilliseconds(20), token); entLayer.SetState(token, hsbColor.GetRGB(), brightness, TimeSpan.FromSeconds(1)); break;

                case 5: entLayer.SetState(token, hsbColor.GetRGB(), 1); break;

                case 6: entLayer.SetState(token, hsbColor.GetRGB(), 1); await Task.Delay(TimeSpan.FromMilliseconds(20), token); entLayer.SetState(token, hsbColor.GetRGB(), brightness, TimeSpan.FromSeconds(1)); break;

                case 7: entLayer.SetState(token, hsbColor.GetRGB(), 1); await Task.Delay(TimeSpan.FromMilliseconds(20), token); entLayer.SetState(token, hsbColor.GetRGB(), brightness, TimeSpan.FromSeconds(1)); break;
                }
            }
        }
Esempio n. 4
0
        public async Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken)
        {
            HSB hsb = new HSB(0, 255, 255);

            while (!cancellationToken.IsCancellationRequested)
            {
                layer.SetState(cancellationToken, hsb.GetRGB(), 1);

                await Task.Delay(waitTime() / 10);

                hsb.Hue += 100;

                if (hsb.Hue >= HSB.HueMaxValue)
                {
                    hsb.Hue = 0;
                }
            }
        }