chroma-sdk / Colore

A powerful C# library for Razer Chroma's SDK
https://chroma-sdk.github.io/Colore/
MIT License
146 stars 30 forks source link

Color changes only in while(true) #273

Closed SidereusNox closed 5 years ago

SidereusNox commented 5 years ago

I am trying to change the color of one Key on my Razer BlackWidow Chroma. Its a console application. I use .NET 4.7.2 and build for x64. This is my code:

using System;
using System.Threading.Tasks;

using Corale.Colore.Core;
using Corale.Colore.Razer.Keyboard;
using Corale.Colore.Razer.Keyboard.Effects;

namespace MicVisual
{
    class Program
    {
        static void Main(string[] args)
        {
            Chroma.Instance.Initialize();
            Console.WriteLine(Chroma.SdkAvailable);
            Console.WriteLine(Chroma.Instance.Initialized);
            Chroma.Instance.Keyboard.SetKey(Key.Backspace, Color.Red);
            Console.ReadKey();
        }
    }
}

When I run the Program I cant see any changes on the keyboard. when it closes, all LED's turn off and on again. the console output is: true true For some reason it works if i place the SetKey in a while(true) loop. But it still needs a few seconds until it changes. Also every other LED is turned off in this scenario.

Sharparam commented 5 years ago

Is there any difference if you put a delay between setting the color and the call to ReadKey?

Like:

Chroma.Instance.Keyboard.SetKey(Key.Backspace, Color.Red);
System.Threading.Thread.Sleep(5000);
Console.ReadKey();
SidereusNox commented 5 years ago

No there is not. Also a while true after SetKey has no impact.

Sharparam commented 5 years ago

Hm, what about a delay before the call to SetKey? I'm wondering if there is a small delay between the init call and the SDK actually being ready.

SidereusNox commented 5 years ago

Very nice! That did help. Its about 1 Second you need to wait. 750ms was not enough 1000ms seems to do the trick.