Skip to content

Commit c69f2a6

Browse files
authored
Update README.md
Added a quickstart section and some example code
1 parent 9f5f697 commit c69f2a6

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,55 @@
22

33
StreamDeckSharp is a simple (unofficial) .NET interface for the Stream Deck (https://www.elgato.com/de/gaming/stream-deck).
44
This project is not related to _Elgato Systems GmbH_ in any way.
5+
6+
## Quickstart _(TL;DR)_
7+
***At the moment only Windows is supported (tested with 10, should also work with 7 and 8)***
8+
1. Add StreamDeckSharp reference (via nuget or download latest release)
9+
2. Add a using directive for StreamDeckSharp: `using StreamDeckSharp;`
10+
11+
I want to... | Code (C#)
12+
------------------------- | ---------------------------------------------------------
13+
create a device reference | `var deck = StreamDeck.FromHID();`
14+
set the brightness | `deck.SetBrightness(50);`
15+
create bitmap for key | `var bitmap = StreamDeckKeyBitmap.FromFile("icon.png")`
16+
set key image | `deck.SetKeyBitmap(keyId,bitmap)`
17+
clear key image | `deck.ClearKey(keyId)`
18+
process key events | `deck.KeyPressed += KeyHandler;`
19+
20+
**Make sure to dispose the device reference correctly** _(use `using` whenever possible)_
21+
22+
## Examples
23+
If you want to see some examples take a look at the example projects in the repo.
24+
Here is a short example called "Austria". Copy the code and start hacking ;-)
25+
26+
```C#
27+
using StreamDeckSharp;
28+
29+
namespace StreamDeckSharp.Examples.Austria
30+
{
31+
class Program
32+
{
33+
static void Main(string[] args)
34+
{
35+
//Create some color we use later to draw the flag of austria
36+
var red = StreamDeckKeyBitmap.FromRGBColor(237, 41, 57);
37+
var white = StreamDeckKeyBitmap.FromRGBColor(255, 255, 255);
38+
var rowColors = new StreamDeckKeyBitmap[] { red, white, red };
39+
40+
//Open the Stream Deck device
41+
using (var deck = StreamDeck.FromHID())
42+
{
43+
deck.SetBrightness(100);
44+
45+
//Send the bitmap informaton to the device
46+
for (int i = 0; i < deck.NumberOfKeys; i++)
47+
deck.SetKeyBitmap(i, rowColors[i / 5]);
48+
}
49+
}
50+
}
51+
}
52+
```
53+
54+
Here is what the "Rainbow" example looks like after pressing some keys
55+
56+
![Rainbow example photo](doc/images/rainbow_example.png?raw=true "Rainbow demo after pressing some keys")

0 commit comments

Comments
 (0)