private void Tick(object source, ElapsedEventArgs e)
        {
            float cpuUtilisation = perfCounter.NextValue();

            LEDColour targetColour = mapUsageToColour(cpuUtilisation);

            if (currentColour != targetColour)
            {
                LEDController.SetLEDState(LEDTransition.getLEDTransition("ALWAYS_ON"), targetColour);
                currentColour = targetColour;
            }
        }
Exemple #2
0
 private void Tick(object source, ElapsedEventArgs e)
 {
     LEDController.SetLEDState(LEDTransition.getLEDTransition("ALWAYS_ON"), LEDColour.AvailableColours.ElementAt(currentColourIndex));
     if (currentColourIndex == maxColourIndex)
     {
         currentColourIndex = 0;
     }
     else
     {
         currentColourIndex++;
     }
 }
        private void Tick(object source, ElapsedEventArgs e)
        {
            LEDController.SetLEDState(LEDTransition.getLEDTransition("ALWAYS_ON"), LEDColour.AvailableColours.ElementAt(currentColourIndex), currentBrightness);

            // TODO more of the fade duration should be spent at the lower brightness levels, since the perceived change in brightness is much more apparent at the bottom end.
            // e.g. the perceived difference between 0x10 and 0x20 is much larger than 0x50 and 0x60, so scaling up linearly wastes a lot of time increasing imperceivable brightness changes at the top of the range.
            // presumably its logarithmic, like with sound?
            if (fadeDirection == FadeDirection.Up)
            {
                if (currentBrightness == maxBrightness)
                {
                    // Fade up finished, start fading down
                    fadeDirection = FadeDirection.Down;
                }
                else
                {
                    // Continue fading up
                    currentBrightness += brightnessStepping;
                }
            }
            else // Fading down
            {
                if (currentBrightness == minBrightness)
                {
                    // Fade cycle complete. Change colour and fade up
                    fadeDirection = FadeDirection.Up;

                    if (currentColourIndex == maxColourIndex)
                    {
                        currentColourIndex = 0;
                    }
                    else
                    {
                        currentColourIndex++;
                    }
                }
                else
                {
                    // Continue fading down
                    currentBrightness -= brightnessStepping;
                }
            }
        }