mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Animatrix tweaks
This commit is contained in:
@@ -62,26 +62,25 @@ namespace Starlight.AnimeMatrix
|
|||||||
Off = 0,
|
Off = 0,
|
||||||
Dim = 1,
|
Dim = 1,
|
||||||
Medium = 2,
|
Medium = 2,
|
||||||
Full = 3
|
Full = 3,
|
||||||
|
Super = 4, //test, doesn't work
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class AnimeMatrixDevice : Device
|
public class AnimeMatrixDevice : Device
|
||||||
{
|
{
|
||||||
private const int UpdatePageLength = 0x0278;
|
int UpdatePageLength = 490;
|
||||||
|
int LedCount = 1450;
|
||||||
|
|
||||||
public int LedCount => 1450;
|
byte[] _displayBuffer;
|
||||||
|
List<byte[]> frames = new List<byte[]>();
|
||||||
private byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
|
||||||
private List<byte[]> frames = new List<byte[]>();
|
|
||||||
|
|
||||||
private int pages = 3;
|
|
||||||
|
|
||||||
public int MaxColumns = 34;
|
public int MaxColumns = 34;
|
||||||
public int MaxRows = 61;
|
public int MaxRows = 61;
|
||||||
|
|
||||||
public int FullRows = 11;
|
public int FullRows = 11;
|
||||||
|
|
||||||
|
public int EmptyFirstRow = 0;
|
||||||
|
|
||||||
private int frameIndex = 0;
|
private int frameIndex = 0;
|
||||||
|
|
||||||
public AnimeMatrixDevice()
|
public AnimeMatrixDevice()
|
||||||
@@ -89,14 +88,19 @@ namespace Starlight.AnimeMatrix
|
|||||||
{
|
{
|
||||||
string model = GetModel();
|
string model = GetModel();
|
||||||
Debug.WriteLine(model);
|
Debug.WriteLine(model);
|
||||||
if (model is not null && model.Contains("401"))
|
|
||||||
{
|
|
||||||
pages = 2;
|
|
||||||
|
|
||||||
|
if (true || model is not null && model.Contains("401"))
|
||||||
|
{
|
||||||
|
EmptyFirstRow = 1;
|
||||||
FullRows = 6;
|
FullRows = 6;
|
||||||
MaxColumns = 33;
|
MaxColumns = 33;
|
||||||
MaxRows = 55;
|
MaxRows = 55;
|
||||||
|
LedCount = 1214;
|
||||||
|
UpdatePageLength = 410;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_displayBuffer = new byte[LedCount];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -145,6 +149,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
public int EmptyColumns(int row)
|
public int EmptyColumns(int row)
|
||||||
{
|
{
|
||||||
|
if (row == 0) return EmptyFirstRow;
|
||||||
return (int)Math.Ceiling(Math.Max(0, row - FullRows) / 2.0);
|
return (int)Math.Ceiling(Math.Max(0, row - FullRows) / 2.0);
|
||||||
}
|
}
|
||||||
public int Columns(int row)
|
public int Columns(int row)
|
||||||
@@ -175,13 +180,13 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
public void SetLedLinear(int address, byte value)
|
public void SetLedLinear(int address, byte value)
|
||||||
{
|
{
|
||||||
EnsureAddressableLed(address);
|
if (!IsAddressableLed(address)) return;
|
||||||
_displayBuffer[address] = value;
|
_displayBuffer[address] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLedLinearImmediate(int address, byte value)
|
public void SetLedLinearImmediate(int address, byte value)
|
||||||
{
|
{
|
||||||
EnsureAddressableLed(address);
|
if (!IsAddressableLed(address)) return;
|
||||||
_displayBuffer[address] = value;
|
_displayBuffer[address] = value;
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||||
@@ -214,26 +219,23 @@ namespace Starlight.AnimeMatrix
|
|||||||
public void Present()
|
public void Present()
|
||||||
{
|
{
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
int page = 0;
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 0 + 1)))
|
int start, end;
|
||||||
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
|
||||||
.AppendData(_displayBuffer[(UpdatePageLength * 0)..(UpdatePageLength * 1)])
|
|
||||||
);
|
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
while (page * UpdatePageLength < LedCount)
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 1 + 1)))
|
{
|
||||||
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
start = page * UpdatePageLength;
|
||||||
.AppendData(_displayBuffer[(UpdatePageLength * 1)..(UpdatePageLength * 2)])
|
end = Math.Min(LedCount, (page + 1) * UpdatePageLength);
|
||||||
);
|
|
||||||
|
|
||||||
if (pages > 2)
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 2 + 1)))
|
.AppendData(BitConverter.GetBytes((ushort)(start + 1)))
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(LedCount - UpdatePageLength * 2)))
|
.AppendData(BitConverter.GetBytes((ushort)(end - start)))
|
||||||
.AppendData(
|
.AppendData(_displayBuffer[start..end])
|
||||||
_displayBuffer[(UpdatePageLength * 2)..(UpdatePageLength * 2 + (LedCount - UpdatePageLength * 2))])
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,12 +315,9 @@ namespace Starlight.AnimeMatrix
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnsureAddressableLed(int address)
|
private bool IsAddressableLed(int address)
|
||||||
{
|
{
|
||||||
if (address < 0 || address >= LedCount)
|
return (address >= 0 && address < LedCount);
|
||||||
{
|
|
||||||
throw new IndexOutOfRangeException($"Linear LED address must be in range of [0, {LedCount - 1}].");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
case UserPreferenceCategory.General:
|
case UserPreferenceCategory.General:
|
||||||
Debug.WriteLine("Theme Changed");
|
Debug.WriteLine("Theme Changed");
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(500);
|
||||||
settingsForm.InitTheme(false);
|
settingsForm.InitTheme(false);
|
||||||
|
|
||||||
if (settingsForm.fans is not null && settingsForm.fans.Text != "")
|
if (settingsForm.fans is not null && settingsForm.fans.Text != "")
|
||||||
|
|||||||
21
app/Settings.Designer.cs
generated
21
app/Settings.Designer.cs
generated
@@ -186,11 +186,11 @@ namespace GHelper
|
|||||||
buttonMatrix.Location = new Point(390, 8);
|
buttonMatrix.Location = new Point(390, 8);
|
||||||
buttonMatrix.Margin = new Padding(4, 8, 4, 8);
|
buttonMatrix.Margin = new Padding(4, 8, 4, 8);
|
||||||
buttonMatrix.Name = "buttonMatrix";
|
buttonMatrix.Name = "buttonMatrix";
|
||||||
|
buttonMatrix.Secondary = true;
|
||||||
buttonMatrix.Size = new Size(185, 44);
|
buttonMatrix.Size = new Size(185, 44);
|
||||||
buttonMatrix.TabIndex = 43;
|
buttonMatrix.TabIndex = 43;
|
||||||
buttonMatrix.Text = "Picture / Gif";
|
buttonMatrix.Text = "Picture / Gif";
|
||||||
buttonMatrix.UseVisualStyleBackColor = false;
|
buttonMatrix.UseVisualStyleBackColor = false;
|
||||||
buttonMatrix.Secondary = true;
|
|
||||||
//
|
//
|
||||||
// comboMatrixRunning
|
// comboMatrixRunning
|
||||||
//
|
//
|
||||||
@@ -331,11 +331,11 @@ namespace GHelper
|
|||||||
buttonQuit.Location = new Point(578, 16);
|
buttonQuit.Location = new Point(578, 16);
|
||||||
buttonQuit.Margin = new Padding(8, 4, 8, 4);
|
buttonQuit.Margin = new Padding(8, 4, 8, 4);
|
||||||
buttonQuit.Name = "buttonQuit";
|
buttonQuit.Name = "buttonQuit";
|
||||||
|
buttonQuit.Secondary = true;
|
||||||
buttonQuit.Size = new Size(208, 44);
|
buttonQuit.Size = new Size(208, 44);
|
||||||
buttonQuit.TabIndex = 18;
|
buttonQuit.TabIndex = 18;
|
||||||
buttonQuit.Text = "Quit";
|
buttonQuit.Text = "Quit";
|
||||||
buttonQuit.UseVisualStyleBackColor = false;
|
buttonQuit.UseVisualStyleBackColor = false;
|
||||||
buttonQuit.Secondary = true;
|
|
||||||
//
|
//
|
||||||
// checkStartup
|
// checkStartup
|
||||||
//
|
//
|
||||||
@@ -436,6 +436,7 @@ namespace GHelper
|
|||||||
buttonSilent.Location = new Point(4, 4);
|
buttonSilent.Location = new Point(4, 4);
|
||||||
buttonSilent.Margin = new Padding(4);
|
buttonSilent.Margin = new Padding(4);
|
||||||
buttonSilent.Name = "buttonSilent";
|
buttonSilent.Name = "buttonSilent";
|
||||||
|
buttonSilent.Secondary = false;
|
||||||
buttonSilent.Size = new Size(185, 120);
|
buttonSilent.Size = new Size(185, 120);
|
||||||
buttonSilent.TabIndex = 0;
|
buttonSilent.TabIndex = 0;
|
||||||
buttonSilent.Text = "Silent";
|
buttonSilent.Text = "Silent";
|
||||||
@@ -456,6 +457,7 @@ namespace GHelper
|
|||||||
buttonBalanced.Location = new Point(197, 4);
|
buttonBalanced.Location = new Point(197, 4);
|
||||||
buttonBalanced.Margin = new Padding(4);
|
buttonBalanced.Margin = new Padding(4);
|
||||||
buttonBalanced.Name = "buttonBalanced";
|
buttonBalanced.Name = "buttonBalanced";
|
||||||
|
buttonBalanced.Secondary = false;
|
||||||
buttonBalanced.Size = new Size(185, 120);
|
buttonBalanced.Size = new Size(185, 120);
|
||||||
buttonBalanced.TabIndex = 1;
|
buttonBalanced.TabIndex = 1;
|
||||||
buttonBalanced.Text = "Balanced";
|
buttonBalanced.Text = "Balanced";
|
||||||
@@ -476,6 +478,7 @@ namespace GHelper
|
|||||||
buttonTurbo.Location = new Point(390, 4);
|
buttonTurbo.Location = new Point(390, 4);
|
||||||
buttonTurbo.Margin = new Padding(4);
|
buttonTurbo.Margin = new Padding(4);
|
||||||
buttonTurbo.Name = "buttonTurbo";
|
buttonTurbo.Name = "buttonTurbo";
|
||||||
|
buttonTurbo.Secondary = false;
|
||||||
buttonTurbo.Size = new Size(185, 120);
|
buttonTurbo.Size = new Size(185, 120);
|
||||||
buttonTurbo.TabIndex = 2;
|
buttonTurbo.TabIndex = 2;
|
||||||
buttonTurbo.Text = "Turbo";
|
buttonTurbo.Text = "Turbo";
|
||||||
@@ -495,12 +498,12 @@ namespace GHelper
|
|||||||
buttonFans.Location = new Point(583, 4);
|
buttonFans.Location = new Point(583, 4);
|
||||||
buttonFans.Margin = new Padding(4);
|
buttonFans.Margin = new Padding(4);
|
||||||
buttonFans.Name = "buttonFans";
|
buttonFans.Name = "buttonFans";
|
||||||
|
buttonFans.Secondary = true;
|
||||||
buttonFans.Size = new Size(185, 120);
|
buttonFans.Size = new Size(185, 120);
|
||||||
buttonFans.TabIndex = 35;
|
buttonFans.TabIndex = 35;
|
||||||
buttonFans.Text = "Fans + Power";
|
buttonFans.Text = "Fans + Power";
|
||||||
buttonFans.TextImageRelation = TextImageRelation.ImageAboveText;
|
buttonFans.TextImageRelation = TextImageRelation.ImageAboveText;
|
||||||
buttonFans.UseVisualStyleBackColor = false;
|
buttonFans.UseVisualStyleBackColor = false;
|
||||||
buttonFans.Secondary = true;
|
|
||||||
//
|
//
|
||||||
// panelGPU
|
// panelGPU
|
||||||
//
|
//
|
||||||
@@ -599,6 +602,7 @@ namespace GHelper
|
|||||||
buttonEco.Location = new Point(4, 4);
|
buttonEco.Location = new Point(4, 4);
|
||||||
buttonEco.Margin = new Padding(4);
|
buttonEco.Margin = new Padding(4);
|
||||||
buttonEco.Name = "buttonEco";
|
buttonEco.Name = "buttonEco";
|
||||||
|
buttonEco.Secondary = false;
|
||||||
buttonEco.Size = new Size(185, 120);
|
buttonEco.Size = new Size(185, 120);
|
||||||
buttonEco.TabIndex = 0;
|
buttonEco.TabIndex = 0;
|
||||||
buttonEco.Text = "Eco";
|
buttonEco.Text = "Eco";
|
||||||
@@ -619,6 +623,7 @@ namespace GHelper
|
|||||||
buttonStandard.Location = new Point(197, 4);
|
buttonStandard.Location = new Point(197, 4);
|
||||||
buttonStandard.Margin = new Padding(4);
|
buttonStandard.Margin = new Padding(4);
|
||||||
buttonStandard.Name = "buttonStandard";
|
buttonStandard.Name = "buttonStandard";
|
||||||
|
buttonStandard.Secondary = false;
|
||||||
buttonStandard.Size = new Size(185, 120);
|
buttonStandard.Size = new Size(185, 120);
|
||||||
buttonStandard.TabIndex = 1;
|
buttonStandard.TabIndex = 1;
|
||||||
buttonStandard.Text = "Standard";
|
buttonStandard.Text = "Standard";
|
||||||
@@ -639,6 +644,7 @@ namespace GHelper
|
|||||||
buttonOptimized.Location = new Point(583, 4);
|
buttonOptimized.Location = new Point(583, 4);
|
||||||
buttonOptimized.Margin = new Padding(4);
|
buttonOptimized.Margin = new Padding(4);
|
||||||
buttonOptimized.Name = "buttonOptimized";
|
buttonOptimized.Name = "buttonOptimized";
|
||||||
|
buttonOptimized.Secondary = false;
|
||||||
buttonOptimized.Size = new Size(185, 120);
|
buttonOptimized.Size = new Size(185, 120);
|
||||||
buttonOptimized.TabIndex = 3;
|
buttonOptimized.TabIndex = 3;
|
||||||
buttonOptimized.Text = "Optimized";
|
buttonOptimized.Text = "Optimized";
|
||||||
@@ -659,6 +665,7 @@ namespace GHelper
|
|||||||
buttonUltimate.Location = new Point(390, 4);
|
buttonUltimate.Location = new Point(390, 4);
|
||||||
buttonUltimate.Margin = new Padding(4);
|
buttonUltimate.Margin = new Padding(4);
|
||||||
buttonUltimate.Name = "buttonUltimate";
|
buttonUltimate.Name = "buttonUltimate";
|
||||||
|
buttonUltimate.Secondary = false;
|
||||||
buttonUltimate.Size = new Size(185, 120);
|
buttonUltimate.Size = new Size(185, 120);
|
||||||
buttonUltimate.TabIndex = 2;
|
buttonUltimate.TabIndex = 2;
|
||||||
buttonUltimate.Text = "Ultimate";
|
buttonUltimate.Text = "Ultimate";
|
||||||
@@ -723,6 +730,7 @@ namespace GHelper
|
|||||||
buttonScreenAuto.Location = new Point(4, 4);
|
buttonScreenAuto.Location = new Point(4, 4);
|
||||||
buttonScreenAuto.Margin = new Padding(4);
|
buttonScreenAuto.Margin = new Padding(4);
|
||||||
buttonScreenAuto.Name = "buttonScreenAuto";
|
buttonScreenAuto.Name = "buttonScreenAuto";
|
||||||
|
buttonScreenAuto.Secondary = false;
|
||||||
buttonScreenAuto.Size = new Size(185, 72);
|
buttonScreenAuto.Size = new Size(185, 72);
|
||||||
buttonScreenAuto.TabIndex = 0;
|
buttonScreenAuto.TabIndex = 0;
|
||||||
buttonScreenAuto.Text = "Auto";
|
buttonScreenAuto.Text = "Auto";
|
||||||
@@ -741,6 +749,7 @@ namespace GHelper
|
|||||||
button60Hz.Location = new Point(197, 4);
|
button60Hz.Location = new Point(197, 4);
|
||||||
button60Hz.Margin = new Padding(4);
|
button60Hz.Margin = new Padding(4);
|
||||||
button60Hz.Name = "button60Hz";
|
button60Hz.Name = "button60Hz";
|
||||||
|
button60Hz.Secondary = false;
|
||||||
button60Hz.Size = new Size(185, 72);
|
button60Hz.Size = new Size(185, 72);
|
||||||
button60Hz.TabIndex = 1;
|
button60Hz.TabIndex = 1;
|
||||||
button60Hz.Text = "60Hz";
|
button60Hz.Text = "60Hz";
|
||||||
@@ -758,6 +767,7 @@ namespace GHelper
|
|||||||
button120Hz.Location = new Point(390, 4);
|
button120Hz.Location = new Point(390, 4);
|
||||||
button120Hz.Margin = new Padding(4);
|
button120Hz.Margin = new Padding(4);
|
||||||
button120Hz.Name = "button120Hz";
|
button120Hz.Name = "button120Hz";
|
||||||
|
button120Hz.Secondary = false;
|
||||||
button120Hz.Size = new Size(185, 72);
|
button120Hz.Size = new Size(185, 72);
|
||||||
button120Hz.TabIndex = 2;
|
button120Hz.TabIndex = 2;
|
||||||
button120Hz.Text = "120Hz + OD";
|
button120Hz.Text = "120Hz + OD";
|
||||||
@@ -832,12 +842,11 @@ namespace GHelper
|
|||||||
buttonKeyboard.Location = new Point(390, 8);
|
buttonKeyboard.Location = new Point(390, 8);
|
||||||
buttonKeyboard.Margin = new Padding(4, 8, 4, 8);
|
buttonKeyboard.Margin = new Padding(4, 8, 4, 8);
|
||||||
buttonKeyboard.Name = "buttonKeyboard";
|
buttonKeyboard.Name = "buttonKeyboard";
|
||||||
|
buttonKeyboard.Secondary = true;
|
||||||
buttonKeyboard.Size = new Size(185, 44);
|
buttonKeyboard.Size = new Size(185, 44);
|
||||||
buttonKeyboard.TabIndex = 37;
|
buttonKeyboard.TabIndex = 37;
|
||||||
buttonKeyboard.Text = "Extra";
|
buttonKeyboard.Text = "Extra";
|
||||||
buttonKeyboard.UseVisualStyleBackColor = false;
|
buttonKeyboard.UseVisualStyleBackColor = false;
|
||||||
buttonKeyboard.Secondary = true;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// comboKeyboard
|
// comboKeyboard
|
||||||
//
|
//
|
||||||
@@ -900,6 +909,7 @@ namespace GHelper
|
|||||||
buttonKeyboardColor.Location = new Point(0, 0);
|
buttonKeyboardColor.Location = new Point(0, 0);
|
||||||
buttonKeyboardColor.Margin = new Padding(4, 8, 4, 8);
|
buttonKeyboardColor.Margin = new Padding(4, 8, 4, 8);
|
||||||
buttonKeyboardColor.Name = "buttonKeyboardColor";
|
buttonKeyboardColor.Name = "buttonKeyboardColor";
|
||||||
|
buttonKeyboardColor.Secondary = false;
|
||||||
buttonKeyboardColor.Size = new Size(185, 44);
|
buttonKeyboardColor.Size = new Size(185, 44);
|
||||||
buttonKeyboardColor.TabIndex = 39;
|
buttonKeyboardColor.TabIndex = 39;
|
||||||
buttonKeyboardColor.Text = "Color ";
|
buttonKeyboardColor.Text = "Color ";
|
||||||
@@ -940,6 +950,7 @@ namespace GHelper
|
|||||||
buttonMiniled.Location = new Point(197, 4);
|
buttonMiniled.Location = new Point(197, 4);
|
||||||
buttonMiniled.Margin = new Padding(4);
|
buttonMiniled.Margin = new Padding(4);
|
||||||
buttonMiniled.Name = "buttonMiniled";
|
buttonMiniled.Name = "buttonMiniled";
|
||||||
|
buttonMiniled.Secondary = false;
|
||||||
buttonMiniled.Size = new Size(185, 72);
|
buttonMiniled.Size = new Size(185, 72);
|
||||||
buttonMiniled.TabIndex = 3;
|
buttonMiniled.TabIndex = 3;
|
||||||
buttonMiniled.Text = "Miniled";
|
buttonMiniled.Text = "Miniled";
|
||||||
|
|||||||
@@ -532,8 +532,8 @@ namespace GHelper
|
|||||||
int brightness = Program.config.getConfig("matrix_brightness");
|
int brightness = Program.config.getConfig("matrix_brightness");
|
||||||
int running = Program.config.getConfig("matrix_running");
|
int running = Program.config.getConfig("matrix_running");
|
||||||
|
|
||||||
comboMatrix.SelectedIndex = (brightness != -1) ? brightness : 0;
|
comboMatrix.SelectedIndex = (brightness != -1) ? Math.Min(brightness, comboMatrix.Items.Count-1) : 0;
|
||||||
comboMatrixRunning.SelectedIndex = (running != -1) ? running : 0;
|
comboMatrixRunning.SelectedIndex = (running != -1) ? Math.Min(running, comboMatrixRunning.Items.Count - 1) : 0;
|
||||||
|
|
||||||
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
|
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user