Пример #1
0
        private void SetCurrentValues()
        {
            // Don't set the LEDs if we aren't active.
            if (!m_isActive)
            {
                return;
            }

            if (m_settings.CurrentLedStateList.Count > 0)
            {
                List <SerlizableLed> localList = m_settings.CurrentLedStateList[0];
                m_controller.GetLed(0).Animate(localList[0].Red, localList[0].Green, localList[0].Blue, localList[0].Intensity, TimeSpan.FromMilliseconds(m_isFirstSet ? 1000 : localList[0].ChangeSpeedMs), WindowsIotLedDriver.AnimationType.Linear);
                m_controller.GetLed(1).Animate(localList[1].Red, localList[1].Green, localList[1].Blue, localList[1].Intensity, TimeSpan.FromMilliseconds(m_isFirstSet ? 1000 : localList[1].ChangeSpeedMs), WindowsIotLedDriver.AnimationType.Linear);
                m_controller.GetLed(2).Animate(localList[2].Red, localList[2].Green, localList[2].Blue, localList[2].Intensity, TimeSpan.FromMilliseconds(m_isFirstSet ? 1000 : localList[2].ChangeSpeedMs), WindowsIotLedDriver.AnimationType.Linear);
                m_controller.GetLed(3).Animate(localList[3].Red, localList[3].Green, localList[3].Blue, localList[3].Intensity, TimeSpan.FromMilliseconds(m_isFirstSet ? 1000 : localList[3].ChangeSpeedMs), WindowsIotLedDriver.AnimationType.Linear);
                m_controller.GetLed(4).Animate(localList[4].Red, localList[4].Green, localList[4].Blue, localList[4].Intensity, TimeSpan.FromMilliseconds(m_isFirstSet ? 1000 : localList[4].ChangeSpeedMs), WindowsIotLedDriver.AnimationType.Linear);
            }
            else
            {
                // Reset them
                m_controller.GetLed(0).Animate(0, 0, 0, 1, TimeSpan.FromSeconds(1), WindowsIotLedDriver.AnimationType.Linear);
                m_controller.GetLed(1).Animate(0, 0, 0, 1, TimeSpan.FromSeconds(1), WindowsIotLedDriver.AnimationType.Linear);
                m_controller.GetLed(2).Animate(0, 0, 0, 1, TimeSpan.FromSeconds(1), WindowsIotLedDriver.AnimationType.Linear);
                m_controller.GetLed(3).Animate(0, 0, 0, 1, TimeSpan.FromSeconds(1), WindowsIotLedDriver.AnimationType.Linear);
                m_controller.GetLed(4).Animate(0, 0, 0, 1, TimeSpan.FromSeconds(1), WindowsIotLedDriver.AnimationType.Linear);
            }

            m_isFirstSet = false;
        }
Пример #2
0
        private void GoToSleepState()
        {
            // In the sleep state we want to turn off the balls...
            m_controller.GetLed(0).Animate(0.0, 0.0, 0.0, 1.0, new TimeSpan(0, 0, 5), WindowsIotLedDriver.AnimationType.Linear);
            m_controller.GetLed(1).Animate(0.0, 0.0, 0.0, 1.0, new TimeSpan(0, 0, 5), WindowsIotLedDriver.AnimationType.Linear);
            m_controller.GetLed(2).Animate(0.0, 0.0, 0.0, 1.0, new TimeSpan(0, 0, 5), WindowsIotLedDriver.AnimationType.Linear);
            m_controller.GetLed(3).Animate(0.0, 0.0, 0.0, 1.0, new TimeSpan(0, 0, 5), WindowsIotLedDriver.AnimationType.Linear);
            m_controller.GetLed(4).Animate(0.0, 0.0, 0.0, 1.0, new TimeSpan(0, 0, 5), WindowsIotLedDriver.AnimationType.Linear);

            // And slow down the work tick.
            m_controller.SetWorkRate(500);

            // Note the work tick will still fire which will cause us to keep listening for commands.
        }
Пример #3
0
        public void DoWork(uint timeElaspedMs)
        {
            for (int i = 0; i < m_expireTime.Length; i++)
            {
                m_expireTime[i] -= (int)timeElaspedMs;

                if (m_expireTime[i] < 0)
                {
                    // We need to update this LED, update the next time we will update this led
                    m_expireTime[i] = m_random.Next(m_settings.NextUpdateTimeMinMs, m_settings.NextUpdateTimeMaxMs);

                    // Create the animation time.
                    int animationTime = m_random.Next(m_settings.TransistionMinMs, m_settings.TransistionMaxMs);
                    SetColor(m_controller.GetLed(i), m_random.NextDouble(), TimeSpan.FromMilliseconds(animationTime));
                }
            }
        }
Пример #4
0
        public void Activate()
        {
            // Turn off the 5th ball since we don't use it.
            m_controller.GetLed(4).Animate(0, 0, 0, 1.0, new TimeSpan(0, 0, 1), AnimationType.Linear);

            // Set the work rate lower so we get faster callbacks.
            m_controller.SetWorkRate(100);
        }