|
1 | 1 | # CoyoteLibCSharp |
2 | | -## Nuget : [Meow.DGLablib](https://www.nuget.org/packages/Meow.DGLablib/) |
3 | | - |
4 | | - |
5 | | - |
6 | | -[](https://www.codefactor.io/repository/github/davidscimeow/dglab_coyote_csharp_library) |
7 | | -## 郊狼控制库 C#\[.NET\]版本 \(非跨平台/仅限Windows\) \(目前只有V3\) |
| 2 | +[](https://opensource.org/licenses/MIT) |
| 3 | + |
| 4 | +[](https://github.com/DavidSciMeow/DGLab_Coyote_CSharp_Library/issues) |
| 5 | +[](https://www.codefactor.io/repository/github/DavidSciMeow/DGLab_Coyote_CSharp_Library) |
| 6 | + |
| 7 | + |
| 8 | +## 详情使用方式请点击[Wiki](https://github.com/DavidSciMeow/DGLab_Coyote_CSharp_Library/wiki). |
| 9 | +### 本项目为学习交流之用, 请在使用时注意相关使用事项, 不要做出任何危险, 亦或伤害自己或他人的举动. |
8 | 10 |
|
9 | | -### 基础使用方式 |
10 | | -```csharp |
11 | | -static async Task Main(string[] args) |
12 | | -{ |
13 | | - |
14 | | - Console.WriteLine("Scanning for Coyote devices..."); |
15 | | - List<CoyoteDeviceV3> devices = await CoyoteDeviceV3.Scan(); //通用的扫描方法 |
| 11 | + |
16 | 12 |
|
17 | | - if (devices.Count == 0) |
18 | | - { |
19 | | - Console.WriteLine("No Coyote devices found."); |
20 | | - return; |
21 | | - } |
22 | 13 |
|
23 | | - Console.WriteLine($"Found {devices.Count} Coyote device(s):"); |
24 | | - for (int i = 0; i < devices.Count; i++) |
25 | | - { |
26 | | - Console.WriteLine($"{i + 1}. {devices[i].Name}"); |
27 | | - } |
28 | 14 |
|
29 | | - var coyoteDevice = devices[0]; //选择一个对的 |
30 | | -
|
31 | | - coyoteDevice.SetWaveBFAsync(new WaveformBF(200)).Wait(); //设置最大幅值 (BF命令) |
32 | | - coyoteDevice.Start(); //启动郊狼输出 |
33 | | -
|
34 | | - //coyoteDevice.NotificationReceived += (s, e) => //全局通知回调 |
35 | | - //{ |
36 | | - // Console.WriteLine($"Notification received: {BitConverter.ToString(e)}"); |
37 | | - //}; |
38 | | -
|
39 | | - //coyoteDevice.B1MessageReceived += (s, e) => //B1通知回调 |
40 | | - //{ |
41 | | - // Console.WriteLine($"Number:{s}, intA/B [{e[0]}][{e[1]}]"); |
42 | | - //}; |
43 | | -
|
44 | | - Console.WriteLine($"Connecting to {coyoteDevice.Name}..."); |
45 | | - Console.WriteLine($"Battery level: {coyoteDevice.BatteryLevel}%"); //读取电池电量 |
46 | | -
|
47 | | - // Example: Set waveform |
48 | | - WaveformV3 waveform = new(150, [100, 100, 100, 100], [60, 60, 60, 60]); //仅输出到A通道的波形 |
49 | | - WaveformV3 zeroform = new(); //零幅值波形 |
50 | | -
|
51 | | - Console.WriteLine("Press A / B to change waveform or ESC to stop"); |
52 | | - |
53 | | - while (true) |
54 | | - { |
55 | | - switch (Console.ReadKey().Key) |
56 | | - { |
57 | | - case ConsoleKey.A: |
58 | | - Console.WriteLine("set to wave"); |
59 | | - coyoteDevice.WaveNow = waveform; |
60 | | - break; |
61 | | - case ConsoleKey.B: |
62 | | - Console.WriteLine("set to zero"); |
63 | | - coyoteDevice.WaveNow = zeroform; |
64 | | - break; |
65 | | - case ConsoleKey.Escape: return; |
66 | | - } |
67 | | - } |
68 | | -} |
69 | | -``` |
0 commit comments