diff --git a/app/AnimeMatrix/AniMatrixControl.cs b/app/AnimeMatrix/AniMatrixControl.cs index b2b7033e..d5498911 100644 --- a/app/AnimeMatrix/AniMatrixControl.cs +++ b/app/AnimeMatrix/AniMatrixControl.cs @@ -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) { diff --git a/app/AnimeMatrix/SlashDevice.cs b/app/AnimeMatrix/SlashDevice.cs index 04d6eff5..bcc9216d 100644 --- a/app/AnimeMatrix/SlashDevice.cs +++ b/app/AnimeMatrix/SlashDevice.cs @@ -127,6 +127,11 @@ namespace GHelper.AnimeMatrix Set(Packet(0xD8, 0x01, 0x00, 0x01, status ? (byte)0x80 : (byte)0x00)); } + public void SetLidMode(bool status) + { + Set(Packet(0xD8, 0x00, 0x00, 0x02, 0xA5, status ? (byte)0x80 : (byte)0x00)); + } + public void Set(Packet packet) { _usbProvider?.Set(packet.Data); diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index 35d73cb1..f163fa43 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -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; } } diff --git a/app/Settings.cs b/app/Settings.cs index 3d4291ae..a7152889 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -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; + + }