Skip to content

Commit

Permalink
[hydro] return liquid temperature with fractional degrees
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanMulawski committed Mar 11, 2023
1 parent f8f3f35 commit f518e23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/CorsairLink/HydroDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,14 @@ internal State ReadState(ReadOnlySpan<byte> stateResponse)
var fwMajor = response[2] >> 4;
var fwMinor = response[2] & 15;
var fwRevision = (int)response[3];
var liquidTempRaw = (double)BinaryPrimitives.ReadInt16LittleEndian(response.Slice(7, 2));

var state = new State
{
FirmwareVersionMajor = fwMajor,
FirmwareVersionMinor = fwMinor,
FirmwareVersionRevision = fwRevision,
LiquidTempCelsius = (int)((BinaryPrimitives.ReadInt16LittleEndian(response.Slice(7, 2)) / 25.6 + 0.5) / 10.0),
LiquidTempCelsius = (int)(liquidTempRaw / 25.6 + 0.5) / 10f,
PumpMode = (PumpMode)response[24],
PumpRpm = BinaryPrimitives.ReadInt16LittleEndian(response.Slice(29, 2)),
FanRpm = new int[_fanCount]
Expand Down Expand Up @@ -382,7 +383,7 @@ internal sealed class State
public int[] FanRpm { get; set; }
public PumpMode PumpMode { get; set; }
public int PumpRpm { get; set; }
public int LiquidTempCelsius { get; set; }
public float LiquidTempCelsius { get; set; }

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion test/CorsairLink.Tests/HydroDeviceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void ReadState_ShouldReturnExpectedStateValues()
Assert.Equal(1, state.FirmwareVersionMajor);
Assert.Equal(1, state.FirmwareVersionMinor);
Assert.Equal(31, state.FirmwareVersionRevision);
Assert.Equal(31, state.LiquidTempCelsius);
Assert.Equal(31.3, state.LiquidTempCelsius, 0.00001);
Assert.Equal(HydroDevice.PumpMode.Balanced, state.PumpMode);
Assert.Equal(2336, state.PumpRpm);
Assert.Equal(0, state.FanRpm[0]);
Expand Down

0 comments on commit f518e23

Please sign in to comment.