Matrix / Slash Lightning - Disable on Lid Close

This commit is contained in:
Serge
2024-02-26 12:30:43 +01:00
parent 25470ed579
commit c57a60079c
5 changed files with 154 additions and 29 deletions

View File

@@ -18,6 +18,8 @@ namespace GHelper.AnimeMatrix
public AnimeMatrixDevice? deviceMatrix;
public SlashDevice? deviceSlash;
public static bool lidClose = false;
double[]? AudioValues;
WasapiCapture? AudioDevice;
string? AudioDeviceId;
@@ -56,9 +58,13 @@ namespace GHelper.AnimeMatrix
if (deviceSlash is not null) SetSlash(wakeUp);
}
public void SetLidMode()
public void SetLidMode(bool force = false)
{
if (deviceSlash is not null) deviceSlash.SetLidMode(AppConfig.Is("matrix_lid"));
if (AppConfig.Is("matrix_lid") || force)
{
Logger.WriteLine($"Matrix LidClosed: {lidClose}");
SetDevice(true);
}
}
@@ -71,6 +77,7 @@ namespace GHelper.AnimeMatrix
int inteval = AppConfig.Get("matrix_interval", 0);
bool auto = AppConfig.Is("matrix_auto");
bool lid = AppConfig.Is("matrix_lid");
Task.Run(() =>
{
@@ -86,7 +93,7 @@ namespace GHelper.AnimeMatrix
if (wakeUp) deviceSlash.WakeUp();
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online) || (lid && lidClose))
{
deviceSlash.Init();
deviceSlash.SetOptions(false, 0, 0);
@@ -115,6 +122,7 @@ namespace GHelper.AnimeMatrix
int brightness = AppConfig.Get("matrix_brightness", 0);
int running = AppConfig.Get("matrix_running", 0);
bool auto = AppConfig.Is("matrix_auto");
bool lid = AppConfig.Is("matrix_lid");
StopMatrixTimer();
StopMatrixAudio();
@@ -133,7 +141,7 @@ namespace GHelper.AnimeMatrix
if (wakeUp) deviceMatrix.WakeUp();
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online) || (lid && lidClose))
{
deviceMatrix.SetDisplayState(false);
deviceMatrix.SetDisplayState(false); // some devices are dumb

103
app/Extra.Designer.cs generated
View File

@@ -127,6 +127,12 @@ namespace GHelper
comboCoresE = new RComboBox();
pictureCores = new PictureBox();
label1 = new Label();
panelACPI = new Panel();
textACPIParam = new TextBox();
textACPICommand = new TextBox();
buttonACPISend = new RButton();
pictureDebug = new PictureBox();
labelACPITitle = new Label();
panelServices.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureService).BeginInit();
panelBindingsHeader.SuspendLayout();
@@ -154,6 +160,8 @@ namespace GHelper
((System.ComponentModel.ISupportInitialize)pictureAPUMem).BeginInit();
panelCores.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureCores).BeginInit();
panelACPI.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureDebug).BeginInit();
SuspendLayout();
//
// panelServices
@@ -163,7 +171,7 @@ namespace GHelper
panelServices.Controls.Add(labelServices);
panelServices.Controls.Add(buttonServices);
panelServices.Dock = DockStyle.Top;
panelServices.Location = new Point(15, 1439);
panelServices.Location = new Point(15, 1508);
panelServices.Name = "panelServices";
panelServices.Size = new Size(983, 75);
panelServices.TabIndex = 5;
@@ -1085,7 +1093,7 @@ namespace GHelper
panelSettings.Controls.Add(checkGpuApps);
panelSettings.Controls.Add(checkGPUFix);
panelSettings.Dock = DockStyle.Top;
panelSettings.Location = new Point(15, 1039);
panelSettings.Location = new Point(15, 1108);
panelSettings.Name = "panelSettings";
panelSettings.Padding = new Padding(20, 5, 11, 5);
panelSettings.Size = new Size(983, 346);
@@ -1200,7 +1208,7 @@ namespace GHelper
panelPower.Controls.Add(labelHibernateAfter);
panelPower.Controls.Add(pictureHibernate);
panelPower.Dock = DockStyle.Top;
panelPower.Location = new Point(15, 1385);
panelPower.Location = new Point(15, 1454);
panelPower.Name = "panelPower";
panelPower.Size = new Size(983, 54);
panelPower.TabIndex = 4;
@@ -1243,7 +1251,7 @@ namespace GHelper
panelAPU.Controls.Add(pictureAPUMem);
panelAPU.Controls.Add(labelAPUMem);
panelAPU.Dock = DockStyle.Top;
panelAPU.Location = new Point(15, 982);
panelAPU.Location = new Point(15, 1051);
panelAPU.Name = "panelAPU";
panelAPU.Padding = new Padding(11, 5, 11, 0);
panelAPU.Size = new Size(983, 57);
@@ -1297,7 +1305,7 @@ namespace GHelper
panelCores.Controls.Add(pictureCores);
panelCores.Controls.Add(label1);
panelCores.Dock = DockStyle.Top;
panelCores.Location = new Point(15, 921);
panelCores.Location = new Point(15, 990);
panelCores.Name = "panelCores";
panelCores.Padding = new Padding(11, 5, 11, 0);
panelCores.Size = new Size(983, 61);
@@ -1373,6 +1381,79 @@ namespace GHelper
label1.TabIndex = 0;
label1.Text = "CPU Cores Configuration";
//
// panelACPI
//
panelACPI.AutoSize = true;
panelACPI.Controls.Add(textACPIParam);
panelACPI.Controls.Add(textACPICommand);
panelACPI.Controls.Add(buttonACPISend);
panelACPI.Controls.Add(pictureDebug);
panelACPI.Controls.Add(labelACPITitle);
panelACPI.Dock = DockStyle.Top;
panelACPI.Location = new Point(15, 921);
panelACPI.Name = "panelACPI";
panelACPI.Padding = new Padding(11, 5, 11, 0);
panelACPI.Size = new Size(983, 69);
panelACPI.TabIndex = 48;
panelACPI.Visible = false;
//
// textACPIParam
//
textACPIParam.Location = new Point(717, 18);
textACPIParam.Margin = new Padding(4, 3, 4, 3);
textACPIParam.Name = "textACPIParam";
textACPIParam.PlaceholderText = "Value";
textACPIParam.Size = new Size(127, 39);
textACPIParam.TabIndex = 22;
textACPIParam.TabStop = false;
//
// textACPICommand
//
textACPICommand.Location = new Point(467, 18);
textACPICommand.Margin = new Padding(4, 3, 4, 3);
textACPICommand.Name = "textACPICommand";
textACPICommand.PlaceholderText = "Address";
textACPICommand.Size = new Size(242, 39);
textACPICommand.TabIndex = 21;
textACPICommand.TabStop = false;
//
// buttonACPISend
//
buttonACPISend.Activated = false;
buttonACPISend.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonACPISend.BackColor = SystemColors.ButtonHighlight;
buttonACPISend.BorderColor = Color.Transparent;
buttonACPISend.BorderRadius = 2;
buttonACPISend.FlatStyle = FlatStyle.Flat;
buttonACPISend.Location = new Point(854, 13);
buttonACPISend.Margin = new Padding(4, 3, 4, 3);
buttonACPISend.Name = "buttonACPISend";
buttonACPISend.Secondary = false;
buttonACPISend.Size = new Size(106, 46);
buttonACPISend.TabIndex = 20;
buttonACPISend.Text = "Send";
buttonACPISend.UseVisualStyleBackColor = false;
//
// pictureDebug
//
pictureDebug.BackgroundImage = Resources.icons8_heartbeat_32;
pictureDebug.BackgroundImageLayout = ImageLayout.Zoom;
pictureDebug.Location = new Point(20, 20);
pictureDebug.Name = "pictureDebug";
pictureDebug.Size = new Size(32, 32);
pictureDebug.TabIndex = 1;
pictureDebug.TabStop = false;
//
// labelACPITitle
//
labelACPITitle.AutoSize = true;
labelACPITitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelACPITitle.Location = new Point(57, 20);
labelACPITitle.Name = "labelACPITitle";
labelACPITitle.Size = new Size(188, 32);
labelACPITitle.TabIndex = 0;
labelACPITitle.Text = "ACPI DEVS Test";
//
// Extra
//
AutoScaleDimensions = new SizeF(192F, 192F);
@@ -1380,12 +1461,13 @@ namespace GHelper
AutoScroll = true;
AutoSize = true;
AutoSizeMode = AutoSizeMode.GrowAndShrink;
ClientSize = new Size(1013, 1515);
ClientSize = new Size(1013, 1612);
Controls.Add(panelServices);
Controls.Add(panelPower);
Controls.Add(panelSettings);
Controls.Add(panelAPU);
Controls.Add(panelCores);
Controls.Add(panelACPI);
Controls.Add(panelSettingsHeader);
Controls.Add(panelBacklight);
Controls.Add(panelBacklightHeader);
@@ -1441,6 +1523,9 @@ namespace GHelper
panelCores.ResumeLayout(false);
panelCores.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureCores).EndInit();
panelACPI.ResumeLayout(false);
panelACPI.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureDebug).EndInit();
ResumeLayout(false);
PerformLayout();
}
@@ -1542,5 +1627,11 @@ namespace GHelper
private Label label1;
private RComboBox comboCoresP;
private RButton buttonCores;
private Panel panelACPI;
private TextBox textACPIParam;
private TextBox textACPICommand;
private RButton buttonACPISend;
private PictureBox pictureDebug;
private Label labelACPITitle;
}
}

View File

@@ -386,9 +386,6 @@ namespace GHelper
buttonServices.Click += ButtonServices_Click;
pictureLog.Click += PictureLog_Click;
pictureScan.Click += PictureScan_Click;
pictureScan.Visible = true;
checkGPUFix.Visible = Program.acpi.IsNVidiaGPU();
checkGPUFix.Checked = AppConfig.IsGPUFix();
@@ -400,8 +397,35 @@ namespace GHelper
InitVariBright();
InitServices();
InitHibernate();
InitACPITesting();
}
private void InitACPITesting()
{
pictureScan.Visible = true;
panelACPI.Visible = true;
textACPICommand.Text = "120075";
textACPIParam.Text = "1";
buttonACPISend.Click += ButtonACPISend_Click;
pictureScan.Click += PictureScan_Click;
}
private void ButtonACPISend_Click(object? sender, EventArgs e)
{
try {
int deviceID = Convert.ToInt32(textACPICommand.Text, 16);
int status = Convert.ToInt32(textACPIParam.Text, textACPIParam.Text.Contains("x") ? 16 : 10);
int result = Program.acpi.DeviceSet((uint)deviceID, status, "TestACPI " + deviceID.ToString("X8") + " " + status.ToString("X4"));
labelACPITitle.Text = "ACPI DEVS Test : " + result.ToString();
} catch (Exception ex)
{
Logger.WriteLine(ex.Message);
}
}
private void InitCores()
{

View File

@@ -31,6 +31,7 @@ namespace GHelper
private void InitializeComponent()
{
panelMatrix = new Panel();
checkMatrixLid = new CheckBox();
tableLayoutMatrix = new TableLayoutPanel();
comboMatrix = new RComboBox();
comboMatrixRunning = new RComboBox();
@@ -126,7 +127,6 @@ namespace GHelper
labelGamma = new Label();
pictureGamma = new PictureBox();
labelGammaTitle = new Label();
checkMatrixLid = new CheckBox();
panelMatrix.SuspendLayout();
tableLayoutMatrix.SuspendLayout();
panelMatrixTitle.SuspendLayout();
@@ -188,6 +188,18 @@ namespace GHelper
panelMatrix.TabIndex = 3;
panelMatrix.TabStop = true;
//
// checkMatrixLid
//
checkMatrixLid.AutoSize = true;
checkMatrixLid.ForeColor = SystemColors.GrayText;
checkMatrixLid.Location = new Point(286, 126);
checkMatrixLid.Margin = new Padding(8, 4, 8, 4);
checkMatrixLid.Name = "checkMatrixLid";
checkMatrixLid.Size = new Size(253, 36);
checkMatrixLid.TabIndex = 46;
checkMatrixLid.Text = "Disable on lid close";
checkMatrixLid.UseVisualStyleBackColor = true;
//
// tableLayoutMatrix
//
tableLayoutMatrix.AutoSize = true;
@@ -1711,19 +1723,6 @@ namespace GHelper
labelGammaTitle.TabIndex = 37;
labelGammaTitle.Text = "Flicker-free Dimming";
//
// checkMatrixLid
//
checkMatrixLid.AutoSize = true;
checkMatrixLid.ForeColor = SystemColors.GrayText;
checkMatrixLid.Location = new Point(286, 126);
checkMatrixLid.Margin = new Padding(8, 4, 8, 4);
checkMatrixLid.Name = "checkMatrixLid";
checkMatrixLid.Size = new Size(246, 36);
checkMatrixLid.TabIndex = 46;
checkMatrixLid.Text = "Enable on lid close";
checkMatrixLid.UseVisualStyleBackColor = true;
checkMatrixLid.Visible = false;
//
// SettingsForm
//
AutoScaleDimensions = new SizeF(192F, 192F);

View File

@@ -455,10 +455,14 @@ namespace GHelper
case 0:
Logger.WriteLine("Lid Closed");
Aura.ApplyBrightness(0, "Lid");
AniMatrixControl.lidClose = true;
matrixControl.SetLidMode();
break;
case 1:
Logger.WriteLine("Lid Open");
Aura.ApplyBrightness(InputDispatcher.GetBacklight(), "Lid");
AniMatrixControl.lidClose = false;
matrixControl.SetLidMode();
break;
}
@@ -704,7 +708,7 @@ namespace GHelper
private void CheckMatrixLid_CheckedChanged(object? sender, EventArgs e)
{
AppConfig.Set("matrix_lid", checkMatrixLid.Checked ? 1 : 0);
matrixControl.SetLidMode();
matrixControl.SetLidMode(true);
}
@@ -934,7 +938,6 @@ namespace GHelper
for (int i = 1; i <= 5; i++) comboInterval.Items.Add($"Interval {i}s");
buttonMatrix.Visible = false;
checkMatrixLid.Visible = true;
}
comboMatrix.SelectedIndex = Math.Min(AppConfig.Get("matrix_brightness", 0), comboMatrix.Items.Count - 1);