-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
152 lines (119 loc) · 4.61 KB
/
Program.cs
File metadata and controls
152 lines (119 loc) · 4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using Driver.Corsair;
using Driver.RGBnet;
using Source.RainbowWave;
//you can either use nuget to get simple led or add the project to this solution. Solution will be in GIT as nuget.
using SimpleLed;
namespace MadLedSDK
{
class Program
{
static List<ControlDevice> devices = new List<ControlDevice>();
static Dictionary<int, ControlDevice> driv = new Dictionary<int, ControlDevice>();
static void ShowDevices()
{
try
{
driv = new Dictionary<int, ControlDevice>();
int ct = 1;
foreach (var controlDevice in devices.ToArray())
{
Console.WriteLine(ct + ": " + controlDevice.Driver.Name() + "-" + controlDevice.Name + " - " +
controlDevice.DeviceType + ", has configUI: " +
(controlDevice.Driver is ISimpleLedWithConfig));
driv.Add(ct, controlDevice);
ct++;
}
}
catch
{
}
}
static void Main(string[] args)
{
var apiClient = new SimpleLedApiClient();
var driverProps = apiClient.GetProductsByCategory(ProductCategory.Effect).Result;
try
{
Directory.CreateDirectory("SLSConfigs");
}
catch
{
}
DummyForm dummy = new DummyForm();
SLSManager ledManager = new SLSManager("SLSConfigs");
ledManager.DeviceAdded += LedManager_DeviceAdded;
ledManager.DeviceRemoved += LedManager_DeviceRemoved;
//Add drivers manually like the example below.
//you wll need to add the driver csproj too.
//you will need to add at LEAST two - one for source, one for dest
//ledManager.Drivers.Add(new CUEDriver());
ledManager.Drivers.Add(new RainbowWaveDriver());
ledManager.Drivers.Add(new RGBNetDriver());
ledManager.RescanRequired += LedManager_RescanRequired;
ledManager.Init();
Console.WriteLine("Getting devices");
string derp = "";
ControlDevice cycleFan = null;
var timer = new Timer((state) =>
{
if (cycleFan != null)
{
foreach (var t in devices.Where(xx =>
xx.Driver.GetProperties().SupportsPush && xx.LEDs != null && xx.LEDs.Length > 0))
{
if (cycleFan.Driver.GetProperties().SupportsPull)
{
cycleFan.Pull();
}
t.MapLEDs(cycleFan);
t.Push();
}
}
}, null, 0, 33);
while (true)
{
Console.WriteLine("Type Source Number (Q TO QUIT, S TO SAVE CFG, L TO LOAD CFG)");
derp = Console.ReadLine();
if (derp.ToUpper() == "Q")
{
return;
}
if (derp.ToUpper() == "S")
{
ledManager.SaveConfigs();
}
else if (derp.ToUpper() == "L")
{
ledManager.LoadConfigs();
}
else
{
cycleFan = driv[int.Parse(derp)];
}
}
}
private static void LedManager_DeviceRemoved(object sender, Events.DeviceChangeEventArgs e)
{
Console.WriteLine("Device Removed: " + e.ControlDevice.Name);
devices.Remove(e.ControlDevice);
ShowDevices();
}
private static void LedManager_DeviceAdded(object sender, Events.DeviceChangeEventArgs e)
{
Console.WriteLine("Device Added: "+e.ControlDevice.Name);
devices.Add(e.ControlDevice);
ShowDevices();
}
private static void LedManager_RescanRequired(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}