Fix animatrix 2021 size

This commit is contained in:
seerge
2023-03-08 19:43:52 +01:00
parent 8c0d84b65b
commit 13f7c81689
2 changed files with 17 additions and 9 deletions

View File

@@ -71,13 +71,17 @@ namespace Starlight.AnimeMatrix
private const int UpdatePageLength = 0x0278; private const int UpdatePageLength = 0x0278;
public int LedCount => 1450; public int LedCount => 1450;
public int Rows => 61;
private byte[] _displayBuffer = new byte[UpdatePageLength * 3]; private byte[] _displayBuffer = new byte[UpdatePageLength * 3];
private List<byte[]> frames = new List<byte[]>(); private List<byte[]> frames = new List<byte[]>();
private int pages = 3; private int pages = 3;
public int MaxColumns = 34;
public int MaxRows = 61;
public int FullRows = 11;
private int frameIndex = 0; private int frameIndex = 0;
public AnimeMatrixDevice() public AnimeMatrixDevice()
@@ -88,6 +92,10 @@ namespace Starlight.AnimeMatrix
if (model is not null && model.Contains("401")) if (model is not null && model.Contains("401"))
{ {
pages = 2; pages = 2;
FullRows = 6;
MaxColumns = 33;
MaxRows = 55;
} }
} }
@@ -137,12 +145,12 @@ namespace Starlight.AnimeMatrix
public int EmptyColumns(int row) public int EmptyColumns(int row)
{ {
return (int)Math.Ceiling(Math.Max(0, row - 11) / 2.0); return (int)Math.Ceiling(Math.Max(0, row - FullRows) / 2.0);
} }
public int Columns(int row) public int Columns(int row)
{ {
EnsureRowInRange(row); EnsureRowInRange(row);
return 34 - EmptyColumns(row); return MaxColumns - EmptyColumns(row);
} }
public int RowToLinearAddress(int row) public int RowToLinearAddress(int row)
@@ -265,8 +273,8 @@ namespace Starlight.AnimeMatrix
public void GenerateFrame(Image image) public void GenerateFrame(Image image)
{ {
int width = 34 * 3; int width = MaxColumns * 3;
int height = 61; int height = MaxRows;
float scale; float scale;
Bitmap canvas = new Bitmap(width, height); Bitmap canvas = new Bitmap(width, height);
@@ -283,7 +291,7 @@ namespace Starlight.AnimeMatrix
graph.DrawImage(image, ((int)width - scaleWidth), ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight); graph.DrawImage(image, ((int)width - scaleWidth), ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight);
Bitmap bmp = new Bitmap(canvas, 34, 61); Bitmap bmp = new Bitmap(canvas, MaxColumns, MaxRows);
for (int y = 0; y < bmp.Height; y++) for (int y = 0; y < bmp.Height; y++)
{ {
@@ -299,9 +307,9 @@ namespace Starlight.AnimeMatrix
private void EnsureRowInRange(int row) private void EnsureRowInRange(int row)
{ {
if (row < 0 || row >= Rows) if (row < 0 || row >= MaxRows)
{ {
throw new IndexOutOfRangeException($"Y-coordinate should fall in range of [0, {Rows - 1}]."); throw new IndexOutOfRangeException($"Y-coordinate should fall in range of [0, {MaxRows - 1}].");
} }
} }

View File

@@ -15,7 +15,7 @@
<AssemblyName>GHelper</AssemblyName> <AssemblyName>GHelper</AssemblyName>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AssemblyVersion>0.18</AssemblyVersion> <AssemblyVersion>0.18.1</AssemblyVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>