Example #1
0
        //http://www.thephotonfactory.com/forum/viewtopic.php?f=5&t=104&p=169#p168
        //
        static void Main(string[] args)
        {
            var trims = PlasmaTrimController.GetPlasmatrims();

            if (trims.Count > 0)
            {
                using (var trim0 = trims[0])
                {
                    if (trim0.Open())
                    {
                        StopAnimating(trim0);
                        ColourChangeExample(trim0);
                        SetColourExample(trim0);
                        BlackoutExample(trim0);

                        StartAnimating(trim0);
                    }
                    else
                    {
                        Console.WriteLine("Failed to open.");
                    }
                }
            }
            else
            {
                Console.WriteLine("No plasmatrims detected.");
            }

            Console.WriteLine("done.");
            Console.ReadLine();
        }
Example #2
0
        static void BlackoutExample(PlasmaTrimController trim)
        {
            var blackState = new PlasmaTrimState()
            {
                Brightness = 170
            };                                                          //Retaining brightness as it affects sequence playback..

            Console.WriteLine("Blackout: {0}", trim.SetImmediateState(blackState)); Console.ReadLine();
        }
Example #3
0
        static void SetColourExample(PlasmaTrimController trim)
        {
            var state = new PlasmaTrimState {
                Brightness = 170, B4 = 255
            };

            Console.WriteLine("Set RGB4, to BLUE: {0}",
                              trim.SetImmediateState(state)
                              );
            Console.ReadLine();
        }
Example #4
0
        static void ColourChangeExample(PlasmaTrimController trim)
        {
            Console.WriteLine("Set RGB4, transition from green to red.");

            var state = new PlasmaTrimState
            {
                Brightness = 255
            };

            for (byte i = 0; i < 255; i++)
            {
                state.R4 = i;
                state.G4 = (byte)(255 - i);
                trim.SetImmediateState(state);
                Thread.Sleep(2); //wait 2 ms before advancing colour
            }

            Console.ReadLine();
        }
Example #5
0
        static void Main(string[] args)
        {
            // First, let's enumerate all the PlasmaTrim devices connected.
            var devices = PlasmaTrimEnumerator.FindConnected().ToArray();

            // List out all the devices we've located.
            Console.WriteLine("Located {0} PlasmaTrim devices:", devices.Length);

            // Iterate over 'em and display 'em.
            for (var i = 0; i < devices.Length; i++)
            {
                Console.WriteLine("[{0}] SN#{1}", i, devices[i].SerialNumber);
            }

            // Pause, wait for input.
            Console.WriteLine("Press any key to start!");
            Console.ReadKey();

            // We're going to operate on all attached devices.
            foreach (var device in devices)
            {
                try
                {
                    // Open a connection to this device.
                    Console.WriteLine("[{0}] Opening connection to {0}.", device.SerialNumber);
                    device.OpenDevice();

                    // Start off by stopping the animation.
                    Console.WriteLine("[{0}] Stopping animation.", device.SerialNumber);
                    device.StopStoredSequence();

                    // Wait for it...
                    Console.WriteLine("[{0}] Pausing 2 seconds.", device.SerialNumber);
                    Thread.Sleep(2000);

                    // Restart the animation.
                    Console.WriteLine("[{0}] Starting animation.", device.SerialNumber);
                    device.PlayStoredSequence();

                    // Wait for it...
                    Console.WriteLine("[{0}] Pausing 2 seconds.", device.SerialNumber);
                    Thread.Sleep(2000);

                    // Iterate over a few colors for the sake of testing.
                    Color[] testColors = new Color[] { Color.Red, Color.Blue, Color.Green, Color.White, Color.Pink, Color.Yellow, Color.Aquamarine, Color.Cyan };

                    foreach (var color in testColors)
                    {
                        Console.WriteLine("[{0}] Color Test.", device.SerialNumber);
                        device.SetColorsImmediate(PlasmaTrimController.GetArrayOfColor(color), PlasmaTrimController.MaxBrightness);

                        var requestedColors = device.GetColorsImmediate();

                        Console.WriteLine("[{0}] Color at position 1: {1}, {2}, {3}", device.SerialNumber, requestedColors[0].R, requestedColors[0].G, requestedColors[0].B);
                        Thread.Sleep(750);
                    }

                    // Test pulse
                    foreach (var color in testColors)
                    {
                        Console.WriteLine("[{0}] Pulse Test {1}, {2}, {3}.", device.SerialNumber, color.R, color.G, color.B);
                        device.PulseColor(color).Wait();
                    }

                    var seq = device.GetSequence().ToArray();
                    // write the sequence to a file
                    using (var sw = File.CreateText(@"d:\tmp\sequence.ptSeq"))
                    {
                        SequenceFile.WriteSequence(sw, seq);
                    }
                    // prove we can read it back again
                    using (var sr = new StreamReader(@"d:\tmp\sequence.ptSeq"))
                    {
                        var seq2 = SequenceFile.ReadSequence(sr, out var active).Take(active).ToArray();
                    }
                    // update the sequence on the device (this currently just sets it to the same sequence)
                    device.SetSequence(seq);

                    // Restart the animation.
                    Console.WriteLine("[{0}] Starting animation.", device.SerialNumber);
                    device.PlayStoredSequence();
                }
                finally
                {
                    // Close a connection to this device.
                    Console.WriteLine("[{0}] Closing connection to {0}.", device.SerialNumber);
                    device.CloseDevice();
                }
            }

            // Pause, wait for input.
            if (devices.Any())
            {
                Console.WriteLine("Finished - press any key to exit.");
                Console.ReadKey();
            }
        }
Example #6
0
        static void StartAnimating(PlasmaTrimController trim)
        {
            Console.WriteLine("Start playing: {0}", trim.StartPlayingSequence());

            Console.ReadLine();
        }