Skip to content

Commit

Permalink
Custom payloads for Slash Lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Apr 26, 2024
1 parent 7e523d0 commit e52ee20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion app/AnimeMatrix/AniMatrixControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ public void SetSlash(bool wakeUp = false)
switch ((SlashMode)running)
{
case SlashMode.Static:
deviceSlash.SetStatic(brightness);
var custom = AppConfig.GetString("slash_custom");
if (custom is not null && custom.Length > 0)
{
deviceSlash.SetCustom(AppConfig.StringToBytes(custom));
} else
{
deviceSlash.SetStatic(brightness);
}
break;
default:
deviceSlash.SetMode((SlashMode)running);
Expand Down
9 changes: 7 additions & 2 deletions app/AnimeMatrix/SlashDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,18 @@ public void SetMode(SlashMode mode)

public void SetStatic(int brightness = 0)
{
byte brightnessByte = (byte)(brightness * 85.333);
SetCustom(Enumerable.Repeat((byte)(brightness * 85.333), 7).ToArray());

}

public void SetCustom(byte[] data)
{
Set(Packet<SlashPacket>(0xD2, 0x02, 0x01, 0x08, 0xAC), "Static");
Set(Packet<SlashPacket>(0xD3, 0x03, 0x01, 0x08, 0xAC, 0xFF, 0xFF, 0x01, 0x05, 0xFF, 0xFF), "StaticSettings");
Set(Packet<SlashPacket>(0xD4, 0x00, 0x00, 0x01, 0xAC), "StaticSave");

Set(Packet<SlashPacket>(0xD3, 0x00, 0x00, 0x07, brightnessByte, brightnessByte, brightnessByte, brightnessByte, brightnessByte, brightnessByte, brightnessByte), "Static White");
byte[] payload = new byte[] { 0xD3, 0x00, 0x00, 0x07 };
Set(Packet<SlashPacket>(payload.Concat(data.Take(7)).ToArray()), "Static Data");
}

public void SetOptions(bool status, int brightness = 0, int interval = 0)
Expand Down

0 comments on commit e52ee20

Please sign in to comment.