Exemple #1
0
        private void SetEffect(LedEffect effect)
        {
            var color    = LedScoutColors.InitialColor;
            var interval = 0;

            switch (effect)
            {
            case LedEffect.None: break;

            case LedEffect.DroppingFast:
                interval = 100;
                color    = LedScoutColors.StateColors[BloodSugarState.VeryLow]; break;

            case LedEffect.Dropping:
                interval = 250;
                color    = LedScoutColors.StateColors[BloodSugarState.Low]; break;

            case LedEffect.Rising:
                interval = 250;
                color    = LedScoutColors.StateColors[BloodSugarState.High]; break;

            case LedEffect.RisingFast:
                interval = 100;
                color    = LedScoutColors.StateColors[BloodSugarState.VeryHigh]; break;
            }

            if (interval > 0)
            {
                LogitechGSDK.LogiLedFlashLighting(
                    color.Red.ToPct(), color.Green.ToPct(), color.Blue.ToPct(),
                    3000, interval);
                Thread.Sleep(3100);
            }
        }
        public static bool FlashLighting(LedSdk sdk, int red, int green, int blue, int duration, int interval)
        {
            bool set = false;

            CheckRgbValues(red, green, blue);

            if (sdk == LedSdk.Logitech)
            {
                set = LogitechGSDK.LogiLedFlashLighting(red, green, blue, duration, interval);
            }

            else if (sdk == LedSdk.Corsair)
            {
                CueSDK.HeadsetSDK.Brush.Effects.Clear();
                byte[]          rgb = ConvertPercentagesToRgbValues(red, green, blue);
                SolidColorBrush b   = new SolidColorBrush(new CorsairColor(rgb[0], rgb[1], rgb[2]));
                b.AddEffect(new FlashEffect()
                {
                    Attack      = 0f,
                    Sustain     = (float)interval / 2f,
                    Release     = 0f,
                    Interval    = (float)interval / 2f,
                    Repetitions = duration / interval
                });
                CueSDK.HeadsetSDK.Brush = b;
                b.UpdateEffects();
                set = true;
            }
            if (set)
            {
                Debug.WriteLine($"Lights flashing {red}, {green}, {blue} for {sdk}!");
            }
            return(set);
        }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKey(KeyCode.Mouse0))
     {
         //On mouse click set random color backlighting. In the monochrome backlighting devices it will change the brightness.
         System.Random random = new System.Random();
         red   = random.Next(0, 100);
         blue  = random.Next(0, 100);
         green = random.Next(0, 100);
         LogitechGSDK.LogiLedSetLighting(red, blue, green);
     }
     if (Input.GetKey(KeyCode.Mouse1))
     {
         byte []       bitmap = new byte[LogitechGSDK.LOGI_LED_BITMAP_SIZE];
         System.Random random = new System.Random();
         for (int i = 0; i < LogitechGSDK.LOGI_LED_BITMAP_SIZE; i++)
         {
             bitmap[i] = (byte)random.Next(0, 100);
         }
         LogitechGSDK.LogiLedSetLightingFromBitmap(bitmap);
     }
     if (Input.GetKey(KeyCode.F))
     {
         //Flashing preset effect
         System.Random random = new System.Random();
         red   = random.Next(0, 100);
         blue  = random.Next(0, 100);
         green = random.Next(0, 100);
         LogitechGSDK.LogiLedFlashLighting(red, blue, green, LogitechGSDK.LOGI_LED_DURATION_INFINITE, 200);
     }
     if (Input.GetKey(KeyCode.P))
     {
         //Pulsing preset effect
         System.Random random = new System.Random();
         red   = random.Next(0, 100);
         blue  = random.Next(0, 100);
         green = random.Next(0, 100);
         LogitechGSDK.LogiLedPulseLighting(red, blue, green, LogitechGSDK.LOGI_LED_DURATION_INFINITE, 100);
     }
     if (Input.GetKey(KeyCode.S))
     {
         LogitechGSDK.LogiLedStopEffects();
     }
 }
Exemple #4
0
        static Task DoWorkAsyncInfiniteLoop()
        {
            while (true)
            {
                //System.Diagnostics.Process.
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    // Initialize the LED SDK

                    if (!_ledInitialized)
                    {
                        _ledInitialized = LogitechGSDK.LogiLedInit();
                        if (!_ledInitialized)
                        {
                            Console.WriteLine("LogitechGSDK.LogiLedInit() failed.");
                        }
                        // Set all devices to Black
                        LogitechGSDK.LogiLedSetLighting(0, 0, 0);
                    }

                    LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_ALL);

                    // Set some keys on keyboard
                    LogitechGSDK.LogiLedFlashSingleKey(keyboardNames.L, 0, 100, 100, 500, 1000);
                    LogitechGSDK.LogiLedFlashLighting(0, 100, 100, 100, 1000);
                    LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.O, 0, 100, 100);
                    //LogitechGSDK.LogiLedFlashSingleKey(keyboardNames.G, 0, 100, 100);
                    //LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.I, 0, 100, 100);
                    //LogitechGSDK.LogiLedPulseLighting(0, 100, 100, 100, 500);
                }
                else
                {
                    //if not running debugger, if sdk is up, shut it down
                    if (_ledInitialized)
                    {
                        LogitechGSDK.LogiLedShutdown();
                    }
                }
                System.Threading.Thread.Sleep(500);
            }
        }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Mouse0))
        {
            //On mouse click set random color backlighting. In the monochrome backlighting devices it will change the brightness.
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            LogitechGSDK.LogiLedSetLighting(red, blue, green);
        }
        if (Input.GetKey(KeyCode.Mouse1))
        {
            byte[]        bitmap = new byte[LogitechGSDK.LOGI_LED_BITMAP_SIZE];
            System.Random random = new System.Random();
            for (int i = 0; i < LogitechGSDK.LOGI_LED_BITMAP_SIZE; i++)
            {
                bitmap[i] = (byte)random.Next(0, 255);
            }
            LogitechGSDK.LogiLedSetLightingFromBitmap(bitmap);
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            LogitechGSDK.LogiLedSetLightingForTargetZone(LogitechGSDK.DeviceType.Speaker, 0, red, blue, green);
        }
        if (Input.GetKey(KeyCode.F))
        {
            //Flashing preset effect
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            LogitechGSDK.LogiLedFlashLighting(red, blue, green, LogitechGSDK.LOGI_LED_DURATION_INFINITE, 200);
        }
        if (Input.GetKey(KeyCode.P))
        {
            //Pulsing preset effect
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            LogitechGSDK.LogiLedPulseLighting(red, blue, green, LogitechGSDK.LOGI_LED_DURATION_INFINITE, 100);
        }

        if (Input.GetKey(KeyCode.E))
        {
            //Pulsing preset effect
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            int finishRed   = random.Next(0, 100);
            int finishBlue  = random.Next(0, 100);
            int finishGreen = random.Next(0, 100);

            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F1, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F2, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F3, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F4, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);

            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            int duration = random.Next(50, 200);

            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F5, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F6, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F7, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F8, red, green, blue, 0, duration);
        }
        if (Input.GetKey(KeyCode.S))
        {
            LogitechGSDK.LogiLedStopEffects();
        }
    }