LidClosed mode for Slash Lightning

This commit is contained in:
Serge
2024-02-24 12:02:43 +01:00
parent 61cc54b709
commit 34d2273ff5
4 changed files with 37 additions and 1 deletions

View File

@@ -56,6 +56,11 @@ namespace GHelper.AnimeMatrix
if (deviceSlash is not null) SetSlash(wakeUp);
}
public void SetLidMode()
{
if (deviceSlash is not null) deviceSlash.SetLidMode(AppConfig.Is("matrix_lid"));
}
public void SetSlash(bool wakeUp = false)
{

View File

@@ -127,6 +127,11 @@ namespace GHelper.AnimeMatrix
Set(Packet<SlashPacket>(0xD8, 0x01, 0x00, 0x01, status ? (byte)0x80 : (byte)0x00));
}
public void SetLidMode(bool status)
{
Set(Packet<SlashPacket>(0xD8, 0x00, 0x00, 0x02, 0xA5, status ? (byte)0x80 : (byte)0x00));
}
public void Set(Packet packet)
{
_usbProvider?.Set(packet.Data);

View File

@@ -126,6 +126,7 @@ namespace GHelper
labelGamma = new Label();
pictureGamma = new PictureBox();
labelGammaTitle = new Label();
checkMatrixLid = new CheckBox();
panelMatrix.SuspendLayout();
tableLayoutMatrix.SuspendLayout();
panelMatrixTitle.SuspendLayout();
@@ -174,6 +175,7 @@ namespace GHelper
panelMatrix.AccessibleRole = AccessibleRole.Grouping;
panelMatrix.AutoSize = true;
panelMatrix.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelMatrix.Controls.Add(checkMatrixLid);
panelMatrix.Controls.Add(tableLayoutMatrix);
panelMatrix.Controls.Add(panelMatrixTitle);
panelMatrix.Controls.Add(checkMatrix);
@@ -1709,6 +1711,19 @@ 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);
@@ -1896,5 +1911,6 @@ namespace GHelper
private Label labelGamma;
private PictureBox pictureGamma;
private Label labelGammaTitle;
private CheckBox checkMatrixLid;
}
}

View File

@@ -701,6 +701,11 @@ namespace GHelper
matrixControl.SetBatteryAuto();
}
private void CheckMatrixLid_CheckedChanged(object? sender, EventArgs e)
{
AppConfig.Set("matrix_lid", checkMatrixLid.Checked ? 1 : 0);
matrixControl.SetLidMode();
}
private void ButtonMatrix_Click(object? sender, EventArgs e)
@@ -929,7 +934,8 @@ 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);
comboMatrixRunning.SelectedIndex = Math.Min(AppConfig.Get("matrix_running", 0), comboMatrixRunning.Items.Count - 1);
@@ -938,6 +944,10 @@ namespace GHelper
checkMatrix.Checked = AppConfig.Is("matrix_auto");
checkMatrix.CheckedChanged += CheckMatrix_CheckedChanged;
checkMatrixLid.Checked = AppConfig.Is("matrix_lid");
checkMatrixLid.CheckedChanged += CheckMatrixLid_CheckedChanged;
}