Skip to content

Commit

Permalink
Fix durations, they are 500ths, not 50ths
Browse files Browse the repository at this point in the history
feature: Animation Sets
  • Loading branch information
ChadNedzlek committed Feb 11, 2024
1 parent 35945b0 commit b9207fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CmdLine/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static async Task Main(string[] args)
await die.SendAnimationSet(animationSet);
}

die.PlayInstantAnimation(2, 1, 0);
die.PlayInstantAnimation(3, 1, 0);
}

Console.WriteLine($"Found {found.Count} dice!");
Expand Down
4 changes: 2 additions & 2 deletions VaettirNet.PixelsDice.Net/Animations/Protocol/KeyFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ internal struct KeyFrame
public ushort Data;

public byte Intensity => (byte)(Data & 0x7F);
public int TimeMs => (Data >> 7) * 1000 / 50;
public int TimeMs => (Data >> 7) * 2;

public static KeyFrame Create(byte intensity, uint timeMs)
{
return new KeyFrame { Data = (ushort)((uint)(intensity & 0x7F) | ((timeMs * 50 / 1000) << 7)) };
return new KeyFrame { Data = (ushort)((ushort)(intensity & 0x7F) | ((timeMs / 2) << 7)) };
}
}
4 changes: 2 additions & 2 deletions VaettirNet.PixelsDice.Net/Animations/Protocol/RgbKeyFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ internal struct RgbKeyFrame
public ushort Data;

public byte ColorIndex => (byte)(Data & 0x7F);
public int DurationMs => (Data >> 7) * 1000 / 50;
public int DurationMs => (Data >> 7) * 2;

public static RgbKeyFrame Create(byte colorIndex, uint durationMs)
{
return new RgbKeyFrame { Data = (ushort)((uint)(colorIndex & 0x7F) | ((durationMs * 50 / 1000) << 7)) };
return new RgbKeyFrame { Data = (ushort)((uint)(colorIndex & 0x7F) | ((durationMs / 2) << 7)) };
}
}

0 comments on commit b9207fc

Please sign in to comment.