Beispiel #1
0
        public void BuildColors(DreamClient dc, CancellationToken ct)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }
            startInt = 0;
            var startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

            LogUtil.WriteInc($@"Color builder started, animation time is {animationTime}...");
            while (!ct.IsCancellationRequested)
            {
                var curTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                var dTime   = curTime - startTime;
                // Check and set colors if time is greater than animation int, then reset time count...
                if (!(dTime > animationTime * 1000))
                {
                    continue;
                }
                startTime = curTime;
                dc.SendColors(RefreshColors(colors), animationTime);
            }

            LogUtil.WriteDec($@"DreamScene: Color Builder canceled. {startTime}");
        }
Beispiel #2
0
        public void BuildColors(DreamClient dc, CancellationToken ct)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }
            _startInt = 0;
            var startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

            LogUtil.WriteInc($@"Color builder started, animation time is {_animationTime}...");
            while (!ct.IsCancellationRequested)
            {
                var curTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                var dTime   = curTime - startTime;
                // Check and set colors if time is greater than animation int, then reset time count...
                if (!(dTime > _animationTime * 1000))
                {
                    continue;
                }
                startTime = curTime;
                var cols    = RefreshColors(_colors);
                var ledCols = new List <Color>();
                // Loop over r sectors and add to List
                var i = _vLedCount / 3;
                foreach (var v in new[] { 0, 1, 2 })
                {
                    while (i > 0)
                    {
                        ledCols.Add(cols[v]);
                        i--;
                    }
                }
                // Loop over t sectors and add to List
                i = _hLedCount / 5;
                foreach (var v in new[] { 2, 3, 4, 5, 6 })
                {
                    while (i > 0)
                    {
                        ledCols.Add(cols[v]);
                        i--;
                    }
                }
                // Loop over l sectors and add to List
                i = _vLedCount / 3;
                foreach (var v in new [] { 6, 7, 8 })
                {
                    while (i > 0)
                    {
                        ledCols.Add(cols[v]);
                        i--;
                    }
                }
                // Loop over b sectors and add to List
                i = _hLedCount / 5;
                foreach (var v in new [] { 8, 9, 10, 11, 0 })
                {
                    while (i > 0)
                    {
                        ledCols.Add(cols[v]);
                        i--;
                    }
                }
                dc.SendColors(ledCols, cols, _animationTime);
            }

            LogUtil.WriteDec($@"DreamScene: Color Builder canceled. {startTime}");
        }