Exemplo n.º 1
0
 private static void BuildModifiers(Blinker blinker, out decimal redModifier, out decimal greenModifier, out decimal blueModifier)
 {
     Decimal.TryParse(Convert.ToString(blinker.GetBlinkColor().R), out redModifier);
     redModifier = redModifier / 255;
     Decimal.TryParse(Convert.ToString(blinker.GetBlinkColor().G), out greenModifier);
     greenModifier = greenModifier / 255;
     Decimal.TryParse(Convert.ToString(blinker.GetBlinkColor().B), out blueModifier);
     blueModifier = blueModifier / 255;
 }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
 public void TurnOff(Blinker blinker, AbstractBlinkstickHid hid)
 {
     string color = "#000000";
     changeColor(hid, color);
 }
Exemplo n.º 4
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
        }
Exemplo n.º 5
0
 public void TurnOn(Blinker blinker, AbstractBlinkstickHid hid)
 {
     string color = Operations.ColorToHexString(blinker.GetBlinkColor());
     changeColor(hid, color);
 }