Example #1
0
        /// <summary>
        /// Turns the laser on with the specified colors range 0 / 255
        /// </summary>
        /// <param name="colors"></param>
        public void On(LaserColors colors)
        {
            if (colors.Red > 255)
            {
                colors.Red = 255;
            }
            if (colors.Red < 0)
            {
                colors.Red = 0;
            }

            if (colors.Green > 255)
            {
                colors.Green = 255;
            }
            if (colors.Green < 0)
            {
                colors.Green = 0;
            }

            if (colors.Blue > 255)
            {
                colors.Blue = 255;
            }
            if (colors.Blue < 0)
            {
                colors.Blue = 0;
            }

            int audienceScanPower = 80;

            var checkedColors = new LaserColors
            {
                Red   = colors.Red,
                Green = colors.Green,
                Blue  = colors.Blue
            };

            if (_y < 0 && colors.Red > audienceScanPower + 10)
            {
                checkedColors.Red = audienceScanPower + 10;
            }

            if (_y < 0 && colors.Green > audienceScanPower)
            {
                checkedColors.Green = audienceScanPower;
            }

            if (_y < 0 && colors.Blue > audienceScanPower + 7)
            {
                checkedColors.Blue = audienceScanPower + 7;
            }

            _serialPortModel.SendCommand(new SerialCommand().Lasers(checkedColors));
        }
Example #2
0
        public void Project(PatternOptions options)
        {
            LaserColors colors  = _laserPatternHelper.GetRandomLaserColors();
            int         xCenter = (_settings.maxLeft + _settings.maxRight) / 2;

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            AnimationSpeed animationSpeed = options.AnimationSpeed;
            int            iterations     = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations < options.Total)
            {
                iterations++;
                if (options.AnimationSpeed == AnimationSpeed.NotSet)
                {
                    animationSpeed = _laserAnimationStatus.AnimationSpeed;
                }

                int left  = xCenter - 100;
                int right = xCenter + 100;

                int y = new Random(Guid.NewGuid().GetHashCode()).Next(_settings.minHeight, _settings.maxHeight);

                while (left > _settings.maxLeft || right < _settings.maxRight)
                {
                    if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                    {
                        break;
                    }

                    _laser.SendTo(left -= (int)animationSpeed / 2, y);
                    System.Threading.Thread.SpinWait(30000);
                    _laser.On(colors);

                    _laser.SendTo(right += (int)animationSpeed / 2, y);
                    System.Threading.Thread.SpinWait(30000);
                    _laser.Off();
                    System.Threading.Thread.SpinWait(100);
                }
            }

            _laser.Off();
        }
        public void Project(PatternOptions options)
        {
            LaserColors colors    = _laserPatternHelper.GetRandomLaserColors();
            var         stopwatch = new Stopwatch();

            stopwatch.Start();

            AnimationSpeed animationSpeed = options.AnimationSpeed;
            var            xPos           = new List <int> {
                _settings.maxLeft, _settings.maxRight
            };
            double iterations = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations / 6.3 < options.Total)
            {
                iterations += (double)animationSpeed / 1400;
                if (options.AnimationSpeed == AnimationSpeed.NotSet)
                {
                    animationSpeed = _laserAnimationStatus.AnimationSpeed;
                }

                for (int line = 0; line < 2; line++)
                {
                    if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                    {
                        break;
                    }

                    for (int j = 0; j < 3; j++)
                    {
                        int y = Convert.ToInt32(Math.Sin(iterations + line) * Math.Abs(2000));

                        _laser.SendTo(xPos[line], y);
                        System.Threading.Thread.SpinWait(15000);
                        _laser.On(colors);
                    }
                }
            }

            _laser.Off();
        }
Example #4
0
        public void Project(PatternOptions options)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            int iterations = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations < options.Total * 100)
            {
                iterations++;
                if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                {
                    break;
                }

                LaserColors colors = _laserPatternHelper.GetRandomLaserColors();

                _laser.SendTo(_laserPatternHelper.GetRandomXPosition(), _laserPatternHelper.GetRandomYPosition());
                _laser.On(colors);
                System.Threading.Thread.SpinWait(20000);
                _laser.Off();
            }
        }
        public void Project(PatternOptions options)
        {
            LaserColors colors    = _laserPatternHelper.GetRandomLaserColors();
            var         stopwatch = new Stopwatch();

            stopwatch.Start();

            AnimationSpeed animationSpeed = options.AnimationSpeed;
            int            iterations     = 0;

            while (stopwatch.ElapsedMilliseconds < options.DurationMilliseconds || iterations < options.Total)
            {
                iterations++;

                for (int i = _settings.maxHeight; i > _settings.minHeight; i -= (int)animationSpeed)
                {
                    if (stopwatch.ElapsedMilliseconds > options.DurationMilliseconds && options.DurationMilliseconds != 0 || _laserAnimationStatus.AnimationCanceled)
                    {
                        break;
                    }
                    if (options.AnimationSpeed == AnimationSpeed.NotSet)
                    {
                        animationSpeed = _laserAnimationStatus.AnimationSpeed;
                    }

                    _laser.SendTo(_settings.maxLeft, i);
                    System.Threading.Thread.SpinWait(30000);
                    _laser.On(colors);

                    _laser.SendTo(_settings.maxRight, i);
                    System.Threading.Thread.SpinWait(30000);
                }
            }

            _laser.Off();
        }