Exemplo n.º 1
0
        //write to the channel
        public bool WriteChannel(int[] colorChannel, string input, DmxDriver dmxControl)
        {
            int tempVal = 0;

            for (int i = 0; i < colorChannel.Length; i++)
            {
                if (int.TryParse(input, out tempVal))
                {
                    tempVal = Clamp(tempVal, 0, 255);
                    dmxControl.ChangeValue(colorChannel[i], (byte)tempVal);
                }
                else if (input.ToLower() == "on")
                {
                    dmxControl.ChangeValue(colorChannel[i], 255);//channel
                    tempVal = 255;
                }
                else if (input.ToLower() == "off")
                {
                    dmxControl.ChangeValue(colorChannel[i], 0);
                    tempVal = 0;
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                    return(false);
                }
            }
            dmxControl.SendData();
            return(true);
        }
Exemplo n.º 2
0
        private void Write(string[] args, DmxDriver dmxControl)
        {
            //arg 0 is base command, 1 is address, 2 is value
            int address = 0, value = 0;

            if (int.TryParse(args[1], out address))
            {
                if (int.TryParse(args[2], out value))
                {
                    dmxControl.ChangeValue(address, (byte)value);
                }
                else if (args[2].ToLower() == "on")
                {
                    dmxControl.ChangeValue(address, 255);//channel
                }
                else if (args[2].ToLower() == "off")
                {
                    dmxControl.ChangeValue(address, 0);
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                }
            }
            dmxControl.SendData();
        }
Exemplo n.º 3
0
        private bool WriteAll(string input, DmxDriver dmxControl)
        {
            int tempVal = 0;

            for (int i = 1; i < 512; i++)
            {
                if (int.TryParse(input, out tempVal))
                {
                    tempVal = Clamp(tempVal, 0, 255);
                    dmxControl.ChangeValue(i, (byte)tempVal);
                }
                else if (input.ToLower() == "on")
                {
                    dmxControl.ChangeValue(i, 255);//channel
                    tempVal = 255;
                }
                else if (input.ToLower() == "off")
                {
                    dmxControl.ChangeValue(i, 0);
                    tempVal = 0;
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                    return(false);
                }
            }
            dmxControl.SendData();
            return(true);
        }
Exemplo n.º 4
0
        public static void Pulse()
        {
            bool   canChange = false;
            int    i = 1;
            double a = 0.00, b = 0.00, c = 0.00, d = 0.00;

            while (true)
            {
                double t = ((Math.Sin(a += 0.01) * .5 + .5));
                if (t <= 0.01 && canChange)
                {
                    if (i < 4)
                    {
                        i++;
                    }
                    else
                    {
                        i = 1;
                    }
                    canChange = false;
                }

                if (t >= 0.99)
                {
                    canChange = true;
                }

                dmxControl.ChangeValue(i, (byte)(t * 255));
                dmxControl.SendData();
            }

            /*
             * //color strength
             *
             * /*
             * t = ((Math.Sin(b += 0.01) * .5 + .5)) * 255;
             *
             * dmxControl.ChangeValue(2, (byte)t);
             *
             * t = ((Math.Sin(c += 0.01) * .5 + .5)) * 255;
             * dmxControl.ChangeValue(3, (byte)t);
             *
             * t = ((Math.Sin(d += 0.01) * .5 + .5)) * 255;
             * dmxControl.ChangeValue(4, (byte)t);
             */
        }