Example #1
0
        private static Color Random(List <ColorChannelShifter> shifters, LightsController lightControl, int goingUp, int randomRange)
        {
            shifters.ForEach(s => s.ShiftBy(new Random().Next(0, randomRange)));
            var color = ColorChannelShifter.FromShifters(shifters[0], shifters[1], shifters[2]);

            lightControl.GetLightsByPowerStatus(true).SetColors(color);
            Task.Delay(10);

            Debug.WriteLine(string.Format("{0};{1};{2}", color.R, color.G, color.B));
            //lightControl.GetLightsByPowerStatus(true).ForEach(l => Debug.WriteLine(l.ToString()));
            return(color);
        }
Example #2
0
        public static Color Flow(List <ColorChannelShifter> shifters, LightsController lightControl, int goingUp)
        {
            shifters.ForEach(s => s.ShiftBy(1));
            var color = ColorChannelShifter.FromShifters(shifters[0], shifters[1], shifters[2]);

            //lightControl.GetLightsByPowerStatus(true).SetColors(color);


            Debug.WriteLine(string.Format("{0};{1};{2}", color.R, color.G, color.B));
            //lightControl.GetLightsByPowerStatus(true).ForEach(l => Debug.WriteLine(l.ToString()));
            return(color);
        }
Example #3
0
        public void TestMethod1()
        {
            var lightControl = new LightsController();

            lightControl.Scan();

            lightControl.Lights.ForEach(l => Debug.WriteLine(l.ToString()));

            var  color          = lightControl.Lights[0].CurrentColor;
            var  goingUp        = 2;
            var  incRandomRange = 3;
            var  rand           = new Random();
            bool run            = true;
            var  r = new ColorChannelShifter(color.R);
            var  g = new ColorChannelShifter(color.G);
            var  b = new ColorChannelShifter(color.B);

            var shifters = new List <ColorChannelShifter> {
                r, g, b
            };



            var count    = 0;
            var type     = "flow";
            var lastType = "";

            while (run)
            {
                switch (type)
                {
                case "flow":
                    if (lastType != "flow")
                    {
                        r.Unit = 50;
                        g.Unit = 200;
                        b.Unit = 180;

                        goingUp = rand.Next(0, 2);
                        shifters[goingUp].GoingUp = true;
                    }
                    color    = Flow(shifters, lightControl, goingUp);
                    lastType = "flow";
                    break;

                case "increment":
                    if (lastType != "increment")
                    {
                        shifters.ForEach(s => s.Unit = 1);
                        shifters[goingUp].GoingUp    = true;
                    }
                    color    = Flow(shifters, lightControl, goingUp);
                    lastType = "increment";
                    break;

                case "random":
                    if (lastType != "random")
                    {
                        shifters.ForEach(s => s.Unit = 180);

                        goingUp                   = rand.Next(0, 2);
                        incRandomRange            = rand.Next(3, 10);
                        shifters[goingUp].GoingUp = true;
                    }

                    color    = Random(shifters, lightControl, goingUp, incRandomRange);
                    lastType = "random";
                    break;
                }


                count++;

                if (count > 10000000)
                {
                    run = false;
                }
            }


            lightControl.Dispose();
        }