From b0738480b559d0bdb661b98926d3175351eab436 Mon Sep 17 00:00:00 2001 From: Jens True Date: Fri, 31 Dec 2021 17:04:00 +0100 Subject: [PATCH] Add project files. --- LEDNotifier.csproj | 22 +++++++++++ LEDNotifier.sln | 22 +++++++++++ Program.cs | 70 ++++++++++++++++++++++++++++++++++ Properties/launchSettings.json | 8 ++++ 4 files changed, 122 insertions(+) create mode 100644 LEDNotifier.csproj create mode 100644 LEDNotifier.sln create mode 100644 Program.cs create mode 100644 Properties/launchSettings.json diff --git a/LEDNotifier.csproj b/LEDNotifier.csproj new file mode 100644 index 0000000..28f38f0 --- /dev/null +++ b/LEDNotifier.csproj @@ -0,0 +1,22 @@ + + + + Exe + net6.0 + disable + enable + False + none + Release + False + + + + False + + + + + + + diff --git a/LEDNotifier.sln b/LEDNotifier.sln new file mode 100644 index 0000000..81e744f --- /dev/null +++ b/LEDNotifier.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31919.166 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEDNotifier", "LEDNotifier.csproj", "{108A185D-35DB-4319-A2A7-39E5CB5D133B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {108A185D-35DB-4319-A2A7-39E5CB5D133B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {108A185D-35DB-4319-A2A7-39E5CB5D133B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3B8A9864-C644-4081-A4E7-750E3B46E4BF} + EndGlobalSection +EndGlobal diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..74cc981 --- /dev/null +++ b/Program.cs @@ -0,0 +1,70 @@ +using HidSharp; +using System; + +byte color_code = 0x0; + +if (args.Length != 1) +{ + Console.WriteLine("No or too many arguments"); + return 1; +} + +Random rnd = new Random(); +switch (args[0]) +{ + case "off": + color_code = 0; + break; + case "blue": + color_code = 1; + break; + case "red": + color_code = 2; + break; + case "green": + color_code = 3; + break; + case "aqua": + color_code = 4; + break; + case "purple": + color_code = 5; + break; + case "yellow": + color_code = 6; + break; + case "white": + color_code = 7; + break; + case "random": + color_code = (byte)rnd.Next(1, 7); + break; + default: + Console.WriteLine("Invalid argument"); + return 1; +} + + +HidDevice hidDevice; +var ret = DeviceList.Local.TryGetHidDevice(out hidDevice, vendorID: 0x1294, productID: 0x1320); + +if(ret == false) +{ + Console.WriteLine("Device not found"); + return 1; +} + +DeviceStream deviceStream; +ret = hidDevice.TryOpen(out deviceStream); + +if (ret == false) +{ + Console.WriteLine("Failed to open stream"); + return 1; +} + + +byte[] data = { 0xff, color_code }; +deviceStream.Write(data, 0, data.Length); + +return 0; \ No newline at end of file diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..1287345 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "LEDNotifier": { + "commandName": "Project", + "commandLineArgs": "random" + } + } +} \ No newline at end of file