Skip to content

Commit 8072a74

Browse files
committed
Merge branch 'develop'
2 parents fec5a42 + ea71b67 commit 8072a74

File tree

43 files changed

+393
-463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+393
-463
lines changed

Build/Build.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ class Build : NukeBuild
4949
ThirdPartyDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
5050

5151
// Clean service bin path but leave 'config.json' file
52-
ServiceBinPath.GlobDirectories("*").ForEach(DeleteDirectory);
53-
ServiceBinPath.GlobFiles("*").Where(f => !f.ToString().EndsWith("config.json")).ForEach(DeleteFile);
52+
if (Directory.Exists(ServiceBinPath))
53+
{
54+
ServiceBinPath.GlobDirectories("*").ForEach(DeleteDirectory);
55+
ServiceBinPath.GlobFiles("*").Where(f => !f.ToString().EndsWith("config.json")).ForEach(DeleteFile);
56+
}
5457

5558
EnsureCleanDirectory(ArtifactsDirectory);
5659
});

Plugins/Devices/TTController.Plugin.DpsgController/DpsgControllerProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public override PortData GetPortData(byte port)
6060
// WATTS = VVOut33 * VIOut33
6161
// EFF = (int)((VVOut12 * VIOut12 + VVOut5 * VIOut5 + VVOut33 * VIOut33) / 10.0)
6262

63-
byte[] GetData(byte b) => Device.WriteReadBytes(0x31, b).Take(2).ToArray();
64-
string GetDataAsString(byte b) => $"{string.Concat(GetData(b).Select(x => x.ToString("X2")))}";
63+
byte[] GetData(byte b) => Device.WriteReadBytes(0x31, b)?.Skip(3).Take(2).ToArray();
64+
string GetDataAsString(byte b) => $"{string.Concat(GetData(b)?.Select(x => $"{x:X2}") ?? Enumerable.Empty<string>())}";
6565

6666
var data = new PortData()
6767
{

Plugins/Devices/TTController.Plugin.RiingController/RiingControllerDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public class RiingControllerDefinition : IControllerDefinition
1111
public int VendorId => 0x264a;
1212
public IEnumerable<int> ProductIds => Enumerable.Range(0, 16).Select(x => 0x1f41 + x);
1313
public int PortCount => 5;
14-
public Type ControllerProxyType => typeof(DefaultControllerProxy);
14+
public Type ControllerProxyType => typeof(RiingControllerProxy);
1515
}
1616
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using TTController.Common;
7+
using TTController.Common.Plugin;
8+
9+
namespace TTController.Plugin.RiingController
10+
{
11+
public class RiingControllerProxy : DefaultControllerProxy
12+
{
13+
public RiingControllerProxy(IHidDeviceProxy device, IControllerDefinition definition)
14+
: base(device, definition)
15+
{ }
16+
17+
public override bool SetSpeed(byte port, byte speed) =>
18+
Device.WriteReadBytes(0x32, 0x51, port, 0x03, speed)?[3] == 0xfc;
19+
20+
protected override Dictionary<string, byte> GenerateAvailableEffects()
21+
{
22+
return new Dictionary<string, byte>()
23+
{
24+
["Flow"] = 0x01,
25+
["Full"] = 0x00
26+
};
27+
}
28+
}
29+
}

Plugins/Effects/TTController.Plugin.BlinkEffect/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

Plugins/Effects/TTController.Plugin.ByLedColorEffect/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

Plugins/Effects/TTController.Plugin.FlowEffect/FlowEffect.cs

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,56 @@ public override IDictionary<PortIdentifier, List<LedColor>> GenerateColors(List<
3636
{
3737
_fill = 0;
3838
_lastHue = _currentHue;
39-
_currentHue = (_currentHue + Config.HueStep) % 360;
39+
_currentHue = ((_currentHue + Config.HueStep) % 360 + 360) % 360;
4040
}
4141

42+
var lastColor = LedColor.FromHsv(_lastHue, Config.Saturation, Config.Brightness);
43+
var currentColor = LedColor.FromHsv(_currentHue, Config.Saturation, Config.Brightness);
44+
4245
var result = new Dictionary<PortIdentifier, List<LedColor>>();
43-
foreach (var port in ports)
46+
if(Config.ColorGenerationMethod == ColorGenerationMethod.PerPort)
4447
{
45-
var config = cache.GetPortConfig(port);
46-
if(config == null)
47-
continue;
48+
foreach (var port in ports)
49+
{
50+
var config = cache.GetPortConfig(port);
51+
if (config == null)
52+
continue;
4853

49-
var lastColor = LedColor.FromHsv(_lastHue, Config.Saturation, Config.Brightness);
50-
var currentColor = LedColor.FromHsv(_currentHue, Config.Saturation, Config.Brightness);
54+
var colors = new List<LedColor>();
55+
for (var i = 0; i < config.LedCount; i++)
56+
{
57+
if (i < (int)Math.Round(config.LedCount * _fill))
58+
colors.Add(currentColor);
59+
else
60+
colors.Add(lastColor);
61+
}
5162

52-
var colors = Enumerable.Range(0, config.LedCount).Select(_ => lastColor).ToList();
53-
for (var i = 0; i < (int) Math.Round(config.LedCount * _fill); i++)
63+
result.Add(port, colors);
64+
}
65+
}
66+
else if(Config.ColorGenerationMethod == ColorGenerationMethod.SpanPorts)
67+
{
68+
var totalLength = ports.Select(p => cache.GetPortConfig(p)).Sum(c => c?.LedCount ?? 0);
69+
70+
var colors = new List<LedColor>();
71+
for (var i = 0; i < totalLength; i++)
5472
{
55-
colors[i] = currentColor;
73+
if (i < (int)Math.Round(totalLength * _fill))
74+
colors.Add(currentColor);
75+
else
76+
colors.Add(lastColor);
5677
}
5778

58-
result.Add(port, colors);
79+
var offset = 0;
80+
foreach (var port in ports)
81+
{
82+
var config = cache.GetPortConfig(port);
83+
if (config == null)
84+
continue;
85+
86+
result.Add(port, colors.Skip(offset).Take(config.LedCount).ToList());
87+
offset += config.LedCount;
88+
}
5989
}
6090

6191
return result;

Plugins/Effects/TTController.Plugin.FlowEffect/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

Plugins/Effects/TTController.Plugin.FullColorEffect/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

Plugins/Effects/TTController.Plugin.PulseEffect/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)