From 13f7c81689c9bc70c86cc512a6adef5368814d40 Mon Sep 17 00:00:00 2001 From: seerge Date: Wed, 8 Mar 2023 19:43:52 +0100 Subject: [PATCH] Fix animatrix 2021 size --- AnimeMatrix/AnimeMatrixDevice.cs | 24 ++++++++++++++++-------- GHelper.csproj | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/AnimeMatrix/AnimeMatrixDevice.cs b/AnimeMatrix/AnimeMatrixDevice.cs index 68c26a39..a3ed7578 100644 --- a/AnimeMatrix/AnimeMatrixDevice.cs +++ b/AnimeMatrix/AnimeMatrixDevice.cs @@ -71,13 +71,17 @@ namespace Starlight.AnimeMatrix private const int UpdatePageLength = 0x0278; public int LedCount => 1450; - public int Rows => 61; private byte[] _displayBuffer = new byte[UpdatePageLength * 3]; private List frames = new List(); private int pages = 3; + public int MaxColumns = 34; + public int MaxRows = 61; + + public int FullRows = 11; + private int frameIndex = 0; public AnimeMatrixDevice() @@ -88,6 +92,10 @@ namespace Starlight.AnimeMatrix if (model is not null && model.Contains("401")) { pages = 2; + + FullRows = 6; + MaxColumns = 33; + MaxRows = 55; } } @@ -137,12 +145,12 @@ namespace Starlight.AnimeMatrix 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) { EnsureRowInRange(row); - return 34 - EmptyColumns(row); + return MaxColumns - EmptyColumns(row); } public int RowToLinearAddress(int row) @@ -265,8 +273,8 @@ namespace Starlight.AnimeMatrix public void GenerateFrame(Image image) { - int width = 34 * 3; - int height = 61; + int width = MaxColumns * 3; + int height = MaxRows; float scale; 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); - Bitmap bmp = new Bitmap(canvas, 34, 61); + Bitmap bmp = new Bitmap(canvas, MaxColumns, MaxRows); for (int y = 0; y < bmp.Height; y++) { @@ -299,9 +307,9 @@ namespace Starlight.AnimeMatrix 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}]."); } } diff --git a/GHelper.csproj b/GHelper.csproj index 2aa07aa3..801854bd 100644 --- a/GHelper.csproj +++ b/GHelper.csproj @@ -15,7 +15,7 @@ GHelper x64 False - 0.18 + 0.18.1 True