Illumilib/Demo/Program.cs

69 lines
2.8 KiB
C#
Raw Normal View History

2021-05-01 20:49:58 +02:00
using System;
using System.Threading;
using Illumilib;
namespace Demo {
internal static class Program {
2021-05-02 19:34:21 +02:00
private static void Main(string[] args) {
IllumilibLighting.Initialize();
2021-05-01 20:49:58 +02:00
foreach (var type in Enum.GetValues<LightingType>()) {
if (IllumilibLighting.IsEnabled(type))
Console.WriteLine($"{type} lighting is enabled");
}
2021-05-03 00:53:54 +02:00
Console.WriteLine("Setting all lights to blue");
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetAllLighting(0, 0, 1);
2021-05-03 00:53:54 +02:00
Thread.Sleep(TimeSpan.FromSeconds(3));
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetAllLighting(0, 0, 0);
2021-05-03 00:53:54 +02:00
Console.WriteLine("Setting specific positions");
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetKeyboardLighting(6, 1, 1, 0, 1);
IllumilibLighting.SetKeyboardLighting(16, 5, 1, 0, 1);
Thread.Sleep(TimeSpan.FromSeconds(5));
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetKeyboardLighting(0, 0, 0);
IllumilibLighting.SetKeyboardLighting(8, 2, 2, 2, 0, 1, 0);
Thread.Sleep(TimeSpan.FromSeconds(5));
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetKeyboardLighting(0, 0, 0);
2021-05-01 20:49:58 +02:00
Console.WriteLine("Doing a fun effect");
for (var x = 0; x < IllumilibLighting.KeyboardWidth; x++) {
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetKeyboardLighting(x, 0, 1, IllumilibLighting.KeyboardHeight, 0, 0, 1);
Thread.Sleep(TimeSpan.FromSeconds(0.25F));
}
for (var x = IllumilibLighting.KeyboardWidth - 1; x >= 0; x--) {
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetKeyboardLighting(x, 0, 1, IllumilibLighting.KeyboardHeight, 0, 0, 0);
Thread.Sleep(TimeSpan.FromSeconds(0.25F));
}
2021-05-01 20:49:58 +02:00
Console.WriteLine("Going through the alphabet");
for (var i = 65; i <= 90; i++) {
var key = (KeyboardKeys) i;
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetKeyboardLighting(key, 0, 1, 0);
2021-05-01 20:49:58 +02:00
Thread.Sleep(TimeSpan.FromSeconds(0.25F));
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetKeyboardLighting(key, 0, 0, 0);
2021-05-01 20:49:58 +02:00
}
Thread.Sleep(TimeSpan.FromSeconds(1));
Console.WriteLine("Pulsing");
for (var i = 0; i < 500; i++) {
var value = (MathF.Sin(i / 50F * MathF.PI) + 1) / 2;
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetAllLighting(value, 0, value);
2021-05-01 20:49:58 +02:00
Thread.Sleep(10);
}
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetAllLighting(0, 0, 0);
2021-05-01 20:49:58 +02:00
Console.WriteLine("Setting all supported keys");
foreach (var key in Enum.GetValues<KeyboardKeys>()) {
2022-06-26 23:58:40 +02:00
IllumilibLighting.SetKeyboardLighting(key, 1, 0, 0);
2021-05-01 20:49:58 +02:00
Thread.Sleep(50);
}
Thread.Sleep(TimeSpan.FromSeconds(15));
Console.WriteLine("Done");
IllumilibLighting.Dispose();
}
}
}