mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Timer fix
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|
||||||
public class ASUSWmi
|
public class ASUSWmi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// Source thanks to https://github.com/vddCore/Starlight :)
|
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
|
||||||
|
|
||||||
|
using Starlight.Communication;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Starlight.Communication;
|
|
||||||
|
|
||||||
namespace Starlight.AnimeMatrix
|
namespace Starlight.AnimeMatrix
|
||||||
{
|
{
|
||||||
@@ -89,6 +89,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
public void PresentNextFrame()
|
public void PresentNextFrame()
|
||||||
{
|
{
|
||||||
|
//Debug.WriteLine(frameIndex);
|
||||||
if (frameIndex >= frames.Count) frameIndex = 0;
|
if (frameIndex >= frames.Count) frameIndex = 0;
|
||||||
_displayBuffer = frames[frameIndex];
|
_displayBuffer = frames[frameIndex];
|
||||||
Present();
|
Present();
|
||||||
@@ -118,7 +119,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
}
|
}
|
||||||
public int Columns(int row)
|
public int Columns(int row)
|
||||||
{
|
{
|
||||||
EnsureRowInRange(row);
|
EnsureRowInRange(row);
|
||||||
return 34 - EmptyColumns(row);
|
return 34 - EmptyColumns(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +231,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
var enabled = enable ? (byte)0x00 : (byte)0x80;
|
var enabled = enable ? (byte)0x00 : (byte)0x80;
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC4, 0x01, enabled));
|
Set(Packet<AnimeMatrixPacket>(0xC4, 0x01, enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBuiltInAnimation(bool enable, BuiltInAnimation animation)
|
public void SetBuiltInAnimation(bool enable, BuiltInAnimation animation)
|
||||||
{
|
{
|
||||||
SetBuiltInAnimation(enable);
|
SetBuiltInAnimation(enable);
|
||||||
@@ -265,13 +266,13 @@ namespace Starlight.AnimeMatrix
|
|||||||
for (int x = 0; x < bmp.Width; x++)
|
for (int x = 0; x < bmp.Width; x++)
|
||||||
{
|
{
|
||||||
var pixel = bmp.GetPixel(x, y);
|
var pixel = bmp.GetPixel(x, y);
|
||||||
byte color = (byte)((pixel.R + pixel.G + pixel.B) / 3);
|
byte color = (byte)(Math.Max((pixel.R + pixel.G + pixel.B) / 3 - 10, 0));
|
||||||
SetLedPlanar(x, y, color);
|
SetLedPlanar(x, y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnsureRowInRange(int row)
|
private void EnsureRowInRange(int row)
|
||||||
{
|
{
|
||||||
if (row < 0 || row >= Rows)
|
if (row < 0 || row >= Rows)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
public class AppConfig
|
public class AppConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ namespace GHelper
|
|||||||
settingsForm.InitGPUMode();
|
settingsForm.InitGPUMode();
|
||||||
settingsForm.InitBoost();
|
settingsForm.InitBoost();
|
||||||
settingsForm.InitAura();
|
settingsForm.InitAura();
|
||||||
|
settingsForm.InitMatrix();
|
||||||
|
|
||||||
settingsForm.VisualiseGPUAuto(config.getConfig("gpu_auto"));
|
settingsForm.VisualiseGPUAuto(config.getConfig("gpu_auto"));
|
||||||
settingsForm.VisualiseScreenAuto(config.getConfig("screen_auto"));
|
settingsForm.VisualiseScreenAuto(config.getConfig("screen_auto"));
|
||||||
@@ -82,6 +83,9 @@ namespace GHelper
|
|||||||
settingsForm.AutoGPUMode(isPlugged);
|
settingsForm.AutoGPUMode(isPlugged);
|
||||||
settingsForm.AutoScreen(isPlugged);
|
settingsForm.AutoScreen(isPlugged);
|
||||||
settingsForm.AutoPerformance(isPlugged);
|
settingsForm.AutoPerformance(isPlugged);
|
||||||
|
|
||||||
|
settingsForm.SetAnimeMatrix();
|
||||||
|
|
||||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
Settings.cs
22
Settings.cs
@@ -18,7 +18,7 @@ namespace GHelper
|
|||||||
static int buttonActive = 5;
|
static int buttonActive = 5;
|
||||||
|
|
||||||
static System.Timers.Timer aTimer = default!;
|
static System.Timers.Timer aTimer = default!;
|
||||||
static System.Timers.Timer matrixTimer = new System.Timers.Timer(100);
|
static System.Timers.Timer matrixTimer = new System.Timers.Timer();
|
||||||
|
|
||||||
public string perfName = "Balanced";
|
public string perfName = "Balanced";
|
||||||
|
|
||||||
@@ -81,9 +81,6 @@ namespace GHelper
|
|||||||
labelCPUFan.Click += LabelCPUFan_Click;
|
labelCPUFan.Click += LabelCPUFan_Click;
|
||||||
labelGPUFan.Click += LabelCPUFan_Click;
|
labelGPUFan.Click += LabelCPUFan_Click;
|
||||||
|
|
||||||
|
|
||||||
InitMatrix();
|
|
||||||
|
|
||||||
comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboMatrix.SelectedValueChanged += ComboMatrix_SelectedValueChanged;
|
comboMatrix.SelectedValueChanged += ComboMatrix_SelectedValueChanged;
|
||||||
@@ -92,6 +89,7 @@ namespace GHelper
|
|||||||
buttonMatrix.Click += ButtonMatrix_Click;
|
buttonMatrix.Click += ButtonMatrix_Click;
|
||||||
|
|
||||||
matrixTimer.Enabled = false;
|
matrixTimer.Enabled = false;
|
||||||
|
matrixTimer.Interval = 100;
|
||||||
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
||||||
|
|
||||||
SetTimer();
|
SetTimer();
|
||||||
@@ -177,22 +175,25 @@ namespace GHelper
|
|||||||
|
|
||||||
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
|
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
|
||||||
SetAnimeMatrix();
|
SetAnimeMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e)
|
private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
|
||||||
SetAnimeMatrix();
|
SetAnimeMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetAnimeMatrix()
|
public void SetAnimeMatrix()
|
||||||
{
|
{
|
||||||
|
|
||||||
int brightness = comboMatrix.SelectedIndex;
|
int brightness = Program.config.getConfig("matrix_brightness");
|
||||||
int running = comboMatrixRunning.SelectedIndex;
|
int running = Program.config.getConfig("matrix_running");
|
||||||
|
|
||||||
//var mat = new AnimeMatrixDevice();
|
if (brightness < 0) brightness = 0;
|
||||||
|
if (running < 0) running = 0;
|
||||||
|
|
||||||
BuiltInAnimation animation = new BuiltInAnimation(
|
BuiltInAnimation animation = new BuiltInAnimation(
|
||||||
(BuiltInAnimation.Running)running,
|
(BuiltInAnimation.Running)running,
|
||||||
@@ -201,6 +202,7 @@ namespace GHelper
|
|||||||
BuiltInAnimation.Startup.StaticEmergence
|
BuiltInAnimation.Startup.StaticEmergence
|
||||||
);
|
);
|
||||||
|
|
||||||
|
matrixTimer.Enabled = false;
|
||||||
|
|
||||||
if (brightness == 0)
|
if (brightness == 0)
|
||||||
{
|
{
|
||||||
@@ -222,10 +224,6 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//mat.Dispose();
|
|
||||||
|
|
||||||
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
|
|
||||||
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user