Skip to content

Commit

Permalink
[icue-link] add support for XD5 pump
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanMulawski committed Jul 12, 2024
1 parent af7a336 commit 8743848
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ Support for the iCUE LINK Hub was added in v1.5.0. The following LINK devices ar
| H150i (White) | `07` | `05` | Full Support || ✅ <sup>1</sup> ||
| XC7 (Stealth Gray) | `09` | `00` | Full Support | n/a | n/a ||
| XC7 (White) | `09` | `01` | Full Support | n/a | n/a ||
| XD5 (Stealth Gray) | `0c` | `00` | Full Support || ✅ <sup>1</sup> ||
| XD5 (White) | `0c` | `01` | Full Support || ✅ <sup>1</sup> ||
| RX RGB Fan | `0f` | `00` | Full Support ||| n/a |
| RX Fan | `13` | `00` | Full Support ||| n/a |

Expand Down
4 changes: 2 additions & 2 deletions src/devices/icue_link/ICueLinkHubDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private void InitializeChannels(EndpointResponse subDevicesResponse)
public override void SetChannelPower(int channel, int percent)
{
var clampMin = PERCENT_MIN;
if (_channels[channel].KnownDevice.Type == LinkDeviceType.LiquidCooler)
if (_channels[channel].KnownDevice.IsPump)
{
clampMin = _pumpPowerMinimum;
}
Expand All @@ -197,7 +197,7 @@ public override void SetChannelPower(int channel, int percent)
public override void ResetChannel(int channel)
{
var value = DEFAULT_SPEED_CHANNEL_POWER;
if (_channels[channel].KnownDevice.Type == LinkDeviceType.LiquidCooler)
if (_channels[channel].KnownDevice.IsPump)
{
value = DEFAULT_SPEED_CHANNEL_POWER_PUMP;
}
Expand Down
3 changes: 3 additions & 0 deletions src/devices/icue_link/KnownLinkDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ public KnownLinkDevice(LinkDeviceType type, byte model, string name, LinkDeviceF
public byte Model { get; }
public string Name { get; }
public LinkDeviceFlags Flags { get; }

public bool IsPump => Type == LinkDeviceType.LiquidCooler || Type == LinkDeviceType.Pump;
}

public enum LinkDeviceType : byte
{
FanQxSeries = 0x01,
LiquidCooler = 0x07,
WaterBlock = 0x09,
Pump = 0x0c,
FanRxRgbSeries = 0x0f,
FanRxSeries = 0x13,
}
Expand Down
2 changes: 2 additions & 0 deletions src/devices/icue_link/KnownLinkDevices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ static KnownLinkDevices()
_devices.Add(new KnownLinkDevice(LinkDeviceType.WaterBlock, 0x01, "XC7", LinkDeviceFlags.ReportsTemperature)); // white
_devices.Add(new KnownLinkDevice(LinkDeviceType.FanRxSeries, 0x00, "RX Fan", LinkDeviceFlags.ControlsSpeed | LinkDeviceFlags.ReportsSpeed));
_devices.Add(new KnownLinkDevice(LinkDeviceType.FanRxRgbSeries, 0x00, "RX RGB Fan", LinkDeviceFlags.ControlsSpeed | LinkDeviceFlags.ReportsSpeed));
_devices.Add(new KnownLinkDevice(LinkDeviceType.Pump, 0x00, "XD5", LinkDeviceFlags.ReportsTemperature | LinkDeviceFlags.ReportsSpeed)); // stealth gray
_devices.Add(new KnownLinkDevice(LinkDeviceType.Pump, 0x01, "XD5", LinkDeviceFlags.All)); // white

_deviceLookup = InitializeDeviceLookup();
}
Expand Down
19 changes: 19 additions & 0 deletions test/CorsairLink.Tests/ICueLink/LinkHubDataReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ public void GetDevices_ReturnsAllSubDevices__3()
Assert.Equal(0x00, devices.OnChannel(8).Model);
}

[Fact]
public void GetDevices_ReturnsAllSubDevices__4()
{
// Arrange
var data = TestUtils.ParseHexString("0000080021000d00000c000000051a303130303041303036313034363130463536303030303341364400000e00000005183433304341443539464632384145344133383530433932450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000051a303130303337423930323033353939354430303030303138393800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");

// Act
var devices = LinkHubDataReader.GetDevices(data);

// Assert
Assert.Equal(3, devices.Count);
Assert.Equal(0x0c, devices.OnChannel(1).Type);
Assert.Equal(0x00, devices.OnChannel(1).Model);
Assert.Equal(0x0e, devices.OnChannel(2).Type);
Assert.Equal(0x00, devices.OnChannel(2).Model);
Assert.Equal(0x09, devices.OnChannel(13).Type);
Assert.Equal(0x00, devices.OnChannel(13).Model);
}

[Fact]
public void GetFirmwareVersion_ReturnsHumanReadableVersionString()
{
Expand Down

0 comments on commit 8743848

Please sign in to comment.