Example #1
0
        public void ScrollTrail_FourRandomColorsSquareTrails_Works(int?sleepSeconds, float darkenFactor, int delayTime)
        {
            //act
            var zlm = new ZLM(false, false, false, zlmInner =>
            {
                var isv = new ISV();
                isv.Add("DarkenFactor", (float)darkenFactor);
                isv.Add("DelayTime", delayTime);
                isv.Add("ShareShape", true);
                isv.Add("TrailShapes", new List <TrailShape>()
                {
                    new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(0, 1, 2, 3, 11, 19, 27, 26, 25, 24, 16, 8)),
                    new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(27, 26, 25, 24, 16, 8, 0, 1, 2, 3, 11, 19)),
                    new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(4, 5, 6, 7, 15, 23, 31, 30, 29, 28, 20, 12)),
                    new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(31, 30, 29, 28, 20, 12, 4, 5, 6, 7, 15, 23)),
                    new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(32, 33, 34, 35, 43, 51, 59, 58, 57, 56, 48, 40)),
                    new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(59, 58, 57, 56, 48, 40, 32, 33, 34, 35, 43, 51)),
                    new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(36, 37, 38, 39, 47, 55, 63, 62, 61, 60, 52, 44)),
                    new TrailShape(new Trail(4, ProgramCommon.GetRandomColor().Darken(0.5)), new Shape(63, 62, 61, 60, 52, 44, 36, 37, 38, 39, 47, 55)),
                });
                var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlmInner.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel,
                                                                         64, 1);
                zlmInner.CreateSingularProgramSet("", new ScrollTrail(), isv, neomatrix);
            }, Config.Get("NeoMatrixOneZone"));

            //Thread.Sleep(Timeout.Infinite);
            Thread.Sleep((int)(sleepSeconds != null ? sleepSeconds * 1000 : Timeout.Infinite));

            //cleanup
            zlm.Dispose();
        }
Example #2
0
        // ReSharper disable once InconsistentNaming
        public ActionResult ZLMCommand(string Command, string programSetName, string programName)
        {
            var command = Command;

            dynamic isv = new ISV();

            if (command.ToLower() == "start" && programName == "Shimmer")
            {
                isv.Add("MaxFadeSpeed", 1);
                isv.Add("MaxFadeDelay", 20);
                isv.Add("Density", 1.0);
                isv.Add("Brightness", 0.3);
                isv.Add("Random", true);
            }

            if (command.ToUpperInvariant() == "START")
            {
                //TODO: Uncomment and fix
                //ZLMRPC.RestartProgramSet(programSetName, programName, new List<string>() { "all"} , isv);
            }
            else if (command.ToUpperInvariant() == "STOP")
            {
                ZLMRPC.StopProgramSet(programSetName);
            }
            else
            {
                throw new ArgumentException("No.");
            }

            return(ReturnZLMPartialView("ProgramSet"));
        }
Example #3
0
        public static void AddNeopixelZonesAndProgramsWithSyncMethod(ZLM zlm)
        {
            var notificationSyncContext = new SyncContext("NotificationContext");

            //add zones
            //var row12 = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "Row12", PixelType.FadeCandyWS2812Pixel, 16, 1, 0.5);
            //var row34 = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "Row34", PixelType.FadeCandyWS2812Pixel, 16, 2, 0.5);
            //var row56 = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "Row56", PixelType.FadeCandyWS2812Pixel, 16, 3, 0.5);
            //var row78 = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "Row78", PixelType.FadeCandyWS2812Pixel, 16, 4, 0.5);

            var neoMatrix = CreateNeoMatrixZone(zlm);

            var isv = new ISV();

            isv.Add("MaxFadeSpeed", 1);
            isv.Add("MaxFadeDelay", 20);
            isv.Add("Density", 1.0);
            isv.Add("Brightness", 0.3);
            isv.Add("Random", true);

            zlm.CreateProgramSet("ShimmerSet", "Shimmer", false, isv, zlm.Zones);

            //setup interrupting inputs - in the real code this method should not be used. The ZoneScaffolder.AddInterruptingProgram should be used.
            neoMatrix.AddInterruptingProgram(new BlinkColorReactive(), null, notificationSyncContext);

            //synchronize and start interrupting programs
            notificationSyncContext.Sync(neoMatrix.InterruptingPrograms[0]);

            neoMatrix.InterruptingPrograms[0].Start();
        }
Example #4
0
        public void RaindropsOnScrollTrail_Works(int?sleepSeconds)
        {
            //act
            var zlm = new ZLM(false, false, false, zlmInner =>
            {
                var isv = new ISV();
                isv.Add("DarkenFactor", (float)0.7);
                isv.Add("DelayTime", 70);
                isv.Add("ShareShape", false);
                isv.Add("TrailShapes", new List <TrailShape>()
                {
                    new TrailShape(new Trail(4, Color.Blue.Darken(0.5)), new Shape(0, 1, 2, 3, 4, 5, 6, 7)),
                    new TrailShape(new Trail(4, Color.Red.Darken(0.5)), new Shape(8, 9, 10, 11, 12, 13, 14, 15)),
                    new TrailShape(new Trail(4, Color.Blue.Darken(0.5)), new Shape(16, 17, 18, 19, 20, 21, 22, 23)),
                    new TrailShape(new Trail(4, Color.Red.Darken(0.5)), new Shape(24, 25, 26, 27, 28, 29, 30, 31)),
                    new TrailShape(new Trail(4, Color.Blue.Darken(0.5)), new Shape(32, 33, 34, 35, 36, 37, 38, 39)),
                    new TrailShape(new Trail(4, Color.Red.Darken(0.5)), new Shape(40, 41, 42, 43, 44, 45, 46, 47)),
                    new TrailShape(new Trail(4, Color.Blue.Darken(0.5)), new Shape(48, 49, 50, 51, 52, 53, 54, 55)),
                    new TrailShape(new Trail(4, Color.Red.Darken(0.5)), new Shape(56, 57, 58, 59, 60, 61, 62, 63)),
                });
                var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlmInner.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel,
                                                                         64, 1);
                zlmInner.CreateSingularProgramSet("", new ScrollTrail(), isv, neomatrix);
            }, Config.Get("NeoMatrixOneZone"));

            //Thread.Sleep(Timeout.Infinite);
            Thread.Sleep((int)(sleepSeconds != null ? sleepSeconds * 1000 : Timeout.Infinite));

            //cleanup
            zlm.Dispose();
        }
Example #5
0
        public static void RunRainbowOnNeoMatrix(ZLM zlm)
        {
            var isv = new ISV();

            isv.Add("Speed", 10);
            isv.Add("DelayTime", 10);
            var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel,
                                                                     64, 1, 0.5);

            zlm.CreateProgramSet("RainbowSet", "Rainbow", false, isv, zlm.Zones);
        }
        public void InputStartingValues_AddParameter_IsAccessibleUsingDotNotation()
        {
            dynamic isv = new ISV();

            isv.Add("Speed", 1);
            isv.Add("Color", Color.Red);
            isv.Add("Name", "Test");

            Assert.True(isv.Speed == 1);
            Assert.True(isv.Color == Color.Red);
            Assert.True(isv.Name == "Test");
        }
Example #7
0
        public static void RunShimmerOnNeoMatrixFourZones(ZLM zlm)
        {
            var isv = new ISV();

            isv.Add("MaxFadeSpeed", 1);
            isv.Add("MaxFadeDelay", 20);
            isv.Add("Density", 1.0);
            isv.Add("Brightness", 1.0);
            isv.Add("Random", true);
            var firstRow  = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "FirstRow", PixelType.FadeCandyWS2812Pixel, 16, 1);
            var secondRow = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "SecondRow", PixelType.FadeCandyWS2812Pixel, 16, 2);
            var thirdRow  = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "ThirdRow", PixelType.FadeCandyWS2812Pixel, 16, 3);
            var fourthRow = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "FourthRow", PixelType.FadeCandyWS2812Pixel, 16, 4);

            zlm.CreateProgramSet("ShimmerSet", "Shimmer", false, isv, zlm.Zones);
        }
Example #8
0
        public static void RunShimmerInBasement(ZLM zlm)
        {
            var isv = new ISV();

            isv.Add("MaxFadeSpeed", 1);
            isv.Add("MaxFadeDelay", 20);
            isv.Add("Density", 1.0);
            isv.Add("Brightness", 1.0);
            isv.Add("Random", true);
            var leftWing = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "LeftWing", PixelType.FadeCandyWS2812Pixel,
                                                                    6, 1);
            var rightwing = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "RightWing", PixelType.FadeCandyWS2812Pixel,
                                                                     12, 3);
            var center = ZoneScaffolder.Instance.AddFadeCandyZone(zlm.Zones, "Center", PixelType.FadeCandyWS2811Pixel,
                                                                  21, 2);

            zlm.CreateProgramSet("ShimmerSet", "Shimmer", false, isv, zlm.Zones);
        }
Example #9
0
        public static void RunShimmerOnNeoMatrix(ZLM zlm)
        {
            var isv = new ISV();

            isv.Add("MaxFadeSpeed", 1);
            isv.Add("MaxFadeDelay", 20);
            isv.Add("Density", 1.0);
            isv.Add("Brightness", 0.3);
            isv.Add("Random", true);
            //isv.Add("ColorScheme", ColorScheme.Primaries);

            dynamic startingParameters = new ExpandoObject();

            startingParameters.DeviceID = int.Parse(Config.Get("MIDIDeviceID"));

            CreateNeoMatrixZone(zlm);
            zlm.CreateProgramSet("ShimmerSet", "Shimmer", false, isv, zlm.Zones, startingParameters: startingParameters);
        }
Example #10
0
        public void Shimmer_Works(int sleepSeconds, bool random)
        {
            //act
            var zlm = new ZLM(false, false, false, zlmInner =>
            {
                var isv = new ISV();
                isv.Add("MaxFadeSpeed", 1);
                isv.Add("MaxFadeDelay", 20);
                isv.Add("Density", 0.5);
                isv.Add("Brightness", 0.5);
                isv.Add("Random", random);
                var neomatrix = ZoneScaffolder.Instance.AddFadeCandyZone(zlmInner.Zones, "NeoMatrix", PixelType.FadeCandyWS2812Pixel, 64, 1);
                zlmInner.CreateSingularProgramSet("", new Shimmer(), isv, neomatrix);
            }, Config.Get("NeoMatrixOneZone"));

            Thread.Sleep(sleepSeconds * 1000);

            //cleanup
            zlm.Dispose();
        }
Example #11
0
        public static void RunShimmerInLivingRoom(ZLM zlm)
        {
            var isv = new ISV();

            isv.Add("MaxFadeSpeed", 1);
            isv.Add("MaxFadeDelay", 20);
            isv.Add("Density", 1.0);
            isv.Add("Brightness", 1.0);
            isv.Add("Random", true);
            //isv.Add("ColorScheme", ColorScheme.Primaries);

            dynamic startingParameters = new ExpandoObject();

            startingParameters.DeviceID = int.Parse(Config.Get("MIDIDeviceID"));

            var zone = CreateLivingRoomZone(zlm);

            zlm.CreateProgramSet("ShimmerSet", "Shimmer", false, isv, zlm.Zones, startingParameters);
            //zone.AddInterruptingProgram(new BlinkColorReactive());
            //zone.InterruptingPrograms[0].Start();
        }
        public void MicroClockBlink_Works(int sleepSeconds, int interval)
        {
            //act
            var zlm = new ZLM(false, false, false, zlmInner =>
            {
                var neomatrix = RunnerHelpers.CreateNeoMatrixZone(zlmInner);
                var isv       = new ISV();
                isv.Add("Interval", interval);
                zlmInner.CreateSingularProgramSet("MicroClockBlinkSet", new MicroClockBlink(), isv, neomatrix);
            }, Config.Get("NeoMatrixOneZone"));

            Thread.Sleep(sleepSeconds * 1000);

            //cleanup
            zlm.Dispose();
        }
Example #13
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var result = new ISV();

            reader.Read();

            while (reader.TokenType == JsonToken.PropertyName)
            {
                var propertyName = (string)reader.Value;
                reader.Read();

                var value = reader.TokenType == JsonToken.Integer ? Convert.ToInt32(reader.Value) : serializer.Deserialize(reader);
                result.Add(propertyName, value);
                reader.Read();
            }

            return(result);
        }