diff --git a/app/AnimeMatrix/AnimeMatrixDevice.cs b/app/AnimeMatrix/AnimeMatrixDevice.cs index ac6fa870..a47ef52b 100644 --- a/app/AnimeMatrix/AnimeMatrixDevice.cs +++ b/app/AnimeMatrix/AnimeMatrixDevice.cs @@ -295,6 +295,17 @@ namespace Starlight.AnimeMatrix SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x, value); } + public void SetLedDiagonal(int x, int y, byte color, int deltaX = 0, int deltaY = 0) + { + x += deltaX; + y -= deltaY; + + int plX = (x - y) / 2; + int plY = x + y; + SetLedPlanar(plX, plY, color); + } + + public void WakeUp() { Set(Packet(Encoding.ASCII.GetBytes("ASUS Tech.Inc."))); @@ -388,18 +399,6 @@ namespace Starlight.AnimeMatrix } - public void PresentClock() - { - string second = (DateTime.Now.Second % 2 == 0) ? ":" : " "; - string time = DateTime.Now.ToString("HH" + second + "mm"); - - Clear(); - Text(time, 15, 0, 24); - Text(DateTime.Now.ToString("yy'. 'MM'. 'dd"), 11F, 0, 14); - Present(); - - } - private void SetBitmapDiagonal(Bitmap bmp, int deltaX = 0, int deltaY = 0) { for (int y = 0; y < bmp.Height; y++) @@ -458,7 +457,17 @@ namespace Starlight.AnimeMatrix } } + public void PresentClock() + { + string second = (DateTime.Now.Second % 2 == 0) ? ":" : " "; + string time = DateTime.Now.ToString("HH" + second + "mm"); + Clear(); + Text(time, 15, 0, 24); + Text(DateTime.Now.ToString("yy'. 'MM'. 'dd"), 11F, 0, 14); + Present(); + + } public void GenerateFrame(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default) { int width = MaxColumns / 2 * 6; @@ -519,18 +528,6 @@ namespace Starlight.AnimeMatrix } - - public void SetLedDiagonal(int x, int y, byte color, int deltaX = 0, int deltaY = 0) - { - x += deltaX; - y -= deltaY; - - int plX = (x - y) / 2; - int plY = x + y; - SetLedPlanar(plX, plY, color); - } - - private bool IsRowInRange(int row) { return (row >= 0 && row < MaxRows); diff --git a/app/AsusACPI.cs b/app/AsusACPI.cs index 92d78e76..f2d1abed 100644 --- a/app/AsusACPI.cs +++ b/app/AsusACPI.cs @@ -287,7 +287,7 @@ public class AsusACPI } - public int DeviceSet(uint DeviceID, int Status, string logName) + public int DeviceSet(uint DeviceID, int Status, string? logName) { byte[] args = new byte[8]; BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0); @@ -296,7 +296,9 @@ public class AsusACPI byte[] status = CallMethod(DEVS, args); int result = BitConverter.ToInt32(status, 0); - Logger.WriteLine(logName + " = " + Status + " : " + (result == 1 ? "OK" : result)); + if (logName is not null) + Logger.WriteLine(logName + " = " + Status + " : " + (result == 1 ? "OK" : result)); + return result; } @@ -378,6 +380,10 @@ public class AsusACPI public int SetFanRange(AsusFan device, byte[] curve) { + + if (curve.Length != 16) return -1; + if (curve.All(singleByte => singleByte == 0)) return -1; + byte min = (byte)(curve[8] * 255 / 100); byte max = (byte)(curve[15] * 255 / 100); byte[] range = { min, max}; @@ -392,6 +398,7 @@ public class AsusACPI result = DeviceSet(DevsCPUFan, range, "FanRangeCPU"); break; } + return result; } diff --git a/app/GHelper.csproj b/app/GHelper.csproj index 5db6da27..a9d436bc 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -15,7 +15,7 @@ AnyCPU False True - 0.126 + 0.127