Animatrix tweaks

This commit is contained in:
seerge
2023-03-26 19:31:41 +02:00
parent c1d23159a0
commit ea2dc7b75d
4 changed files with 30 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me // Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
using Starlight.Communication; using Starlight.Communication;
using System.Diagnostics;
using System.Management; using System.Management;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
@@ -86,6 +87,7 @@ namespace Starlight.AnimeMatrix
//public int FullRows = 11; //public int FullRows = 11;
//public int FullEvenRows = -1; //public int FullEvenRows = -1;
public int dx = 0;
public int MaxColumns = 34; public int MaxColumns = 34;
private int frameIndex = 0; private int frameIndex = 0;
@@ -102,6 +104,7 @@ namespace Starlight.AnimeMatrix
_model = AnimeType.GA401; _model = AnimeType.GA401;
MaxColumns = 33; MaxColumns = 33;
dx = 0;
//FullRows = 7; //FullRows = 7;
//FullEvenRows = 3; //FullEvenRows = 3;
@@ -211,7 +214,7 @@ namespace Starlight.AnimeMatrix
return 33; return 33;
case 1: case 1:
case 3: case 3:
return 35; // Some rows are padded return 35;
default: default:
return 36 - y / 2; return 36 - y / 2;
} }
@@ -257,7 +260,8 @@ namespace Starlight.AnimeMatrix
if (x >= FirstX(y) && x < Width(y)) if (x >= FirstX(y) && x < Width(y))
{ {
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x, value); SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx, value);
//Debug.Write((RowToLinearAddress(y) - FirstX(y) + x + dx).ToString() + " ");
} }
} }
@@ -389,36 +393,35 @@ namespace Starlight.AnimeMatrix
int width = MaxColumns * 3; int width = MaxColumns * 3;
int height = MaxRows; int height = MaxRows;
int targetWidth = MaxColumns * 2;
float scale; float scale;
using (Bitmap canvas = new Bitmap(width, height)) using (Bitmap bmp = new Bitmap(targetWidth, height))
{ {
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height); scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
using (var graph = Graphics.FromImage(canvas)) using (var graph = Graphics.FromImage(bmp))
{ {
var scaleWidth = (int)(image.Width * scale); var scaleWidth = (int)(image.Width * scale);
var scaleHeight = (int)(image.Height * scale); var scaleHeight = (int)(image.Height * scale);
graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
graph.DrawImage(image, ((int)width - scaleWidth), 0, scaleWidth, scaleHeight); graph.DrawImage(image, (int)Math.Round(targetWidth - scaleWidth/1.5), 0, (int)Math.Round(scaleWidth/1.5), scaleHeight);
} }
using (Bitmap bmp = new Bitmap(canvas, MaxColumns * 2, MaxRows)) for (int y = 0; y < bmp.Height; y++)
{ {
for (int y = 0; y < bmp.Height; y++) for (int x = 0; x < bmp.Width; x++)
{ if (x % 2 == y % 2)
for (int x = 0; x < bmp.Width; x++) {
if (x % 2 == y % 2) var pixel = bmp.GetPixel(x, y);
{ SetLedPlanar(x / 2, y, (byte)((pixel.R + pixel.G + pixel.B) / 3));
var pixel = bmp.GetPixel(x, y); }
SetLedPlanar(x / 2, y, (byte)((pixel.R + pixel.G + pixel.B) / 3));
}
}
} }
} }

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.39</AssemblyVersion> <AssemblyVersion>0.40</AssemblyVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -32,6 +32,15 @@ namespace GHelper
// The main entry point for the application // The main entry point for the application
public static void Main() public static void Main()
{ {
if (Process.GetProcesses().Count(p => p.ProcessName == "GHelper") > 1)
{
MessageBox.Show("G-Helper is already running. Check system tray for an icon.", "App already running", MessageBoxButtons.OK);
Application.Exit();
return;
}
try try
{ {
wmi = new ASUSWmi(); wmi = new ASUSWmi();

View File

@@ -272,6 +272,7 @@ namespace GHelper
{ {
case 0: case 0:
Logger.WriteLine("Monitor Power Off"); Logger.WriteLine("Monitor Power Off");
SetBatteryChargeLimit(Program.config.getConfig("charge_limit"));
break; break;
case 1: case 1:
Logger.WriteLine("Monitor Power On"); Logger.WriteLine("Monitor Power On");