public CPUUsageIndicatorControlMode(int intervalMs)
        {
            timer          = new Timer();
            timer.Elapsed += new ElapsedEventHandler(Tick);
            timer.Interval = intervalMs;

            perfCounter   = new PerformanceCounter("Processor", "% Processor Time", "_Total");
            currentColour = LEDColour.getLEDColour("WHITE");
        }
        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;
            }
        }
        private void applyChanges(object sender, RoutedEventArgs e)
        {
            try
            {
                // Stop the current control mode if there is one
                if (currentControlMode != null)
                {
                    currentControlMode.Stop();
                }

                TabItem tabItem = tabControl.SelectedItem as TabItem;
                if (tabItem.Name.ToString() == "AUTO")
                {
                    if (radioButtonCycleColour.IsChecked ?? false)
                    {
                        currentControlMode = new BlinkColourCyclerControlMode((int)sliderCycleRate.Value);
                        currentControlMode.Start();
                        lableStatusText.Content = "Colour cycle mode enabled";
                    }
                    else if (radioButtonFadeColour.IsChecked ?? false)
                    {
                        currentControlMode = new FadeColourCyclerControlMode((int)sliderFadeRate.Value);
                        currentControlMode.Start();
                        lableStatusText.Content = "Colour fade mode enabled";
                    }
                    else if (radioButtonCPUUsage.IsChecked ?? false)
                    {
                        currentControlMode = new CPUUsageIndicatorControlMode(2000); //TODO make configurable
                        currentControlMode.Start();
                        lableStatusText.Content = "CPU utilisation indicator mode enabled";
                    }
                }
                else
                {
                    if (radioButtonDisableLed.IsChecked ?? false)
                    {
                        LEDController.DisableLED();
                        lableStatusText.Content = "LED disabled";
                    }
                    else
                    {
                        LEDTransition transition = comboBoxTransition.SelectedItem as LEDTransition;
                        LEDColour     colour     = comboBoxColour.SelectedItem as LEDColour;
                        LEDController.SetLEDState(transition, colour);
                        lableStatusText.Content = $"LED set: {colour.DisplayName} - {transition.DisplayName}";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error setting LED: {ex.Message.ToString()}", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
 // TODO add option to map usage to brighness
 private LEDColour mapUsageToColour(float utilisation)
 {
     if (utilisation <= 33)
     {
         return(LEDColour.getLEDColour("GREEN"));
     }
     else if (utilisation > 66)
     {
         return(LEDColour.getLEDColour("RED"));
     }
     else
     {
         return(LEDColour.getLEDColour("YELLOW"));
     }
 }