simracer-cz / iFlag

Race marshalling light board for iRacing.com motorsport simulation.
GNU General Public License v2.0
63 stars 23 forks source link

Draft: Add OpenRGB SDK support #9

Open CalcProgrammer1 opened 7 months ago

CalcProgrammer1 commented 7 months ago

My friend plays iRacing and asked if there was a way to sync his RGB peripherals/LED strips with the game. He found this project and I took a quick shot at integrating @diogotr7's OpenRGB.NET SDK. To do this, I had to retarget the project up to .NET Framework 4.8.

What I have implemented is that the program connects to the OpenRGB server immediately when opened and any updates to the flag that would get sent to the Arduino also updates OpenRGB. For single zone devices (usually having just a single LED) I just used one of the center pixels in the flag (4,4). For linear devices such as LED strips, I use row index 4 in the flag matrix and scale it to the LED strip length. For matrix devices such as keyboards, I scale both dimensions.

Animations are not supported at the moment as the animation would have to be handled by the iFlag software itself. OpenRGB does not support sending multiple animation frames at once as the Arduino side of this project does. A thread within iFlag to swap animation frames and send them to OpenRGB would be needed.

This is a quick hack and to properly integrate you would probably want a menu entry for entering the SDK server information, a toggle in the menu for connecting/disconnecting, and maybe to split the OpenRGB part out of the Arduino handling code. I mainly did this as a quick experiment for my friend.

image