Beispiel #1
0
        public static void PrintDeviceInfoBlock(AbstractBlinkstickHid device, byte blockId)
        {
            Console.Write (String.Format("    Info block{0}: ", blockId - 1));

            string deviceInfoBlock;
            if (device.GetInfoBlock(blockId, out deviceInfoBlock))
            {
                Console.WriteLine (deviceInfoBlock);
            }
            else
            {
                Console.WriteLine ("FAILED");
            }
        }
Beispiel #2
0
 private void changeColor(AbstractBlinkstickHid hid, string hexColor)
 {
     hid.OpenDevice();
     hid.SetLedColor(hexColor);
     hid.CloseDevice();
 }
Beispiel #3
0
        public static void PrintDeviceInfo(AbstractBlinkstickHid device, Boolean colorOnly)
        {
            byte cr;
            byte cg;
            byte cb;

            device.GetLedColor(out cr, out cg, out cb);

            Console.WriteLine (String.Format ("    Device color: #{0:X2}{1:X2}{2:X2}", cr, cg, cb));

            if (colorOnly)
                return;

            Console.WriteLine ("    Serial:       " + device.Serial);
            Console.WriteLine ("    Manufacturer: " + device.ManufacturerName);
            Console.WriteLine ("    Product Name: " + device.ProductName);
			PrintDeviceInfoBlock(device, 3);
        }
Beispiel #4
0
 private void StateChange(AbstractBlinkstickHid hid, decimal redModifier, decimal greenModifier, decimal blueModifier, int i, int sleepTimer)
 {
     int newRed = Convert.ToInt32(Math.Round(i * redModifier));
     int newGreen = Convert.ToInt32(Math.Round(i * greenModifier));
     int newBlue = Convert.ToInt32(Math.Round(i * blueModifier));
     System.Threading.Thread.Sleep(sleepTimer);
     string newColor = Operations.ColorToHexString(System.Drawing.Color.FromArgb(0, newRed, newGreen, newBlue));
     changeColor(hid, newColor);
 }
Beispiel #5
0
        /** <summary>A uniform pulse, modify pulse speed with animation speed and phaseSpeed</summary> */
        public void PulseStick(Blinker blinker, AbstractBlinkstickHid hid)
        {
            decimal redModifier;
            decimal greenModifier;
            decimal blueModifier;
            int phaseSpeed = blinker.PhaseSpeed;

            BuildModifiers(blinker, out redModifier, out greenModifier, out blueModifier);

            for (int loopTimes = 0; loopTimes < (blinker.BlinkCount); loopTimes++)
            {
                int sleepTime = blinker.AnimationSpeed;
                for (int i = 0; i < 255; i = i + phaseSpeed)
                {
                    StateChange(hid, redModifier, greenModifier, blueModifier, i, sleepTime);
                }
                for (int i = 255; i > 0; i = i - phaseSpeed)
                {
                    StateChange(hid, redModifier, greenModifier, blueModifier, i, sleepTime);
                }
                changeColor(hid, "#000000");
                System.Threading.Thread.Sleep(blinker.pauseLength);
            }
        }
Beispiel #6
0
        public void SirenBlink(Blinker blinker, AbstractBlinkstickHid hid)
        {
            List<Color> lightColors = new List<Color>()
            {
                System.Drawing.Color.Blue,
                System.Drawing.Color.Red,
                System.Drawing.Color.White
            };
            int sirenCount = blinker.BlinkCount;

            for (int i = 0; i < sirenCount; i++)
            {
                int colorChoice = new Random().Next(0,lightColors.Count);
                blinker.SetBlinkColor(lightColors[colorChoice]);
                int phaseSpeed = new Random().Next(20,100);
                blinker.PhaseSpeed = phaseSpeed;
                blinker.BlinkCount = 1;
                blinker.pauseLength = new Random().Next(0, 10);

                PulseStick(blinker, hid);
            }
            blinker.SetBlinkCount(sirenCount); //return the blink count for possible second runs
        }
Beispiel #7
0
 public void TurnOff(Blinker blinker, AbstractBlinkstickHid hid)
 {
     string color = "#000000";
     changeColor(hid, color);
 }
Beispiel #8
0
 public void TurnOn(Blinker blinker, AbstractBlinkstickHid hid)
 {
     string color = Operations.ColorToHexString(blinker.GetBlinkColor());
     changeColor(hid, color);
 }