From 1adec8b6c9884b02fef0d4a34bbe230d6f66b3f5 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:03:11 +0100 Subject: [PATCH] Slash Interval settings --- app/AnimeMatrix/AniMatrixControl.cs | 4 +- app/AnimeMatrix/SlashDevice.cs | 5 ++- app/Settings.Designer.cs | 65 +++++++++++++++++++---------- app/Settings.cs | 13 ++++++ 4 files changed, 61 insertions(+), 26 deletions(-) diff --git a/app/AnimeMatrix/AniMatrixControl.cs b/app/AnimeMatrix/AniMatrixControl.cs index 5349dd0d..663f734d 100644 --- a/app/AnimeMatrix/AniMatrixControl.cs +++ b/app/AnimeMatrix/AniMatrixControl.cs @@ -64,6 +64,8 @@ namespace GHelper.AnimeMatrix int brightness = AppConfig.Get("matrix_brightness", 0); int running = AppConfig.Get("matrix_running", 0); + int inteval = AppConfig.Get("matrix_interval", 0); + bool auto = AppConfig.Is("matrix_auto"); Task.Run(() => @@ -89,7 +91,7 @@ namespace GHelper.AnimeMatrix { deviceSlash.Init(); deviceSlash.SetMode((SlashMode)running); - deviceSlash.SetOptions(true, (byte)(brightness * 85.333), 0); + deviceSlash.SetOptions(true, brightness, inteval); deviceSlash.Save(); } }); diff --git a/app/AnimeMatrix/SlashDevice.cs b/app/AnimeMatrix/SlashDevice.cs index e470bb75..6ebbd194 100644 --- a/app/AnimeMatrix/SlashDevice.cs +++ b/app/AnimeMatrix/SlashDevice.cs @@ -44,9 +44,10 @@ namespace GHelper.AnimeMatrix Set(Packet(0xD3, 0x04, 0x00, 0x0C, 0x01, (mode == SlashMode.Bitstream) ? (byte)0x1D : (byte)0x1A, 0x02, 0x19, 0x03, 0x13, 0x04, 0x11, 0x05, 0x12, 0x06, 0x13)); } - public void SetOptions(bool status, byte brightness = 0xFF, byte interval = 0x00) + public void SetOptions(bool status, int brightness = 0, int interval = 0) { - Set(Packet(0xD3, 0x03, 0x01, 0x08, 0xAB, 0xFF, 0x01, status ? (byte)0x01 : (byte)0x00, 0x06, brightness, 0xFF, interval)); + byte brightnessByte = (byte)(brightness * 85.333); + Set(Packet(0xD3, 0x03, 0x01, 0x08, 0xAB, 0xFF, 0x01, status ? (byte)0x01 : (byte)0x00, 0x06, brightnessByte, 0xFF, (byte)interval)); Save(); } diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index d0b30d58..97941447 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -65,6 +65,7 @@ namespace GHelper panelGPU = new Panel(); labelTipGPU = new Label(); tableAMD = new TableLayoutPanel(); + buttonOverlay = new RButton(); buttonFPS = new RButton(); tableGPU = new TableLayoutPanel(); buttonStopGPU = new RButton(); @@ -118,7 +119,7 @@ namespace GHelper panelAllyTitle = new Panel(); pictureAlly = new PictureBox(); labelAlly = new Label(); - buttonOverlay = new RButton(); + comboInterval = new RComboBox(); panelMatrix.SuspendLayout(); tableLayoutMatrix.SuspendLayout(); panelMatrixTitle.SuspendLayout(); @@ -187,14 +188,16 @@ namespace GHelper tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutMatrix.Controls.Add(comboMatrix, 0, 0); tableLayoutMatrix.Controls.Add(comboMatrixRunning, 1, 0); + tableLayoutMatrix.Controls.Add(comboInterval, 2, 0); tableLayoutMatrix.Controls.Add(buttonMatrix, 2, 0); tableLayoutMatrix.Dock = DockStyle.Top; tableLayoutMatrix.Location = new Point(20, 60); tableLayoutMatrix.Margin = new Padding(8); tableLayoutMatrix.Name = "tableLayoutMatrix"; - tableLayoutMatrix.RowCount = 1; + tableLayoutMatrix.RowCount = 2; tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - tableLayoutMatrix.Size = new Size(787, 64); + tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); + tableLayoutMatrix.Size = new Size(787, 84); tableLayoutMatrix.TabIndex = 43; // // comboMatrix @@ -707,6 +710,28 @@ namespace GHelper tableAMD.TabIndex = 24; tableAMD.Visible = false; // + // buttonOverlay + // + buttonOverlay.Activated = false; + buttonOverlay.BackColor = SystemColors.ControlLightLight; + buttonOverlay.BorderColor = Color.Transparent; + buttonOverlay.BorderRadius = 5; + buttonOverlay.Dock = DockStyle.Fill; + buttonOverlay.FlatAppearance.BorderSize = 0; + buttonOverlay.FlatStyle = FlatStyle.Flat; + buttonOverlay.ForeColor = SystemColors.ControlText; + buttonOverlay.Image = Properties.Resources.icons8_heartbeat_32; + buttonOverlay.ImageAlign = ContentAlignment.MiddleRight; + buttonOverlay.Location = new Point(266, 4); + buttonOverlay.Margin = new Padding(4); + buttonOverlay.Name = "buttonOverlay"; + buttonOverlay.Secondary = false; + buttonOverlay.Size = new Size(254, 72); + buttonOverlay.TabIndex = 12; + buttonOverlay.Text = "AMD Overlay"; + buttonOverlay.TextImageRelation = TextImageRelation.ImageBeforeText; + buttonOverlay.UseVisualStyleBackColor = false; + // // buttonFPS // buttonFPS.Activated = false; @@ -1586,27 +1611,20 @@ namespace GHelper labelAlly.TabIndex = 26; labelAlly.Text = "Ally Controller"; // - // buttonOverlay + // comboInterval // - buttonOverlay.Activated = false; - buttonOverlay.BackColor = SystemColors.ControlLightLight; - buttonOverlay.BorderColor = Color.Transparent; - buttonOverlay.BorderRadius = 5; - buttonOverlay.Dock = DockStyle.Fill; - buttonOverlay.FlatAppearance.BorderSize = 0; - buttonOverlay.FlatStyle = FlatStyle.Flat; - buttonOverlay.ForeColor = SystemColors.ControlText; - buttonOverlay.Image = Properties.Resources.icons8_heartbeat_32; - buttonOverlay.ImageAlign = ContentAlignment.MiddleRight; - buttonOverlay.Location = new Point(266, 4); - buttonOverlay.Margin = new Padding(4); - buttonOverlay.Name = "buttonOverlay"; - buttonOverlay.Secondary = false; - buttonOverlay.Size = new Size(254, 72); - buttonOverlay.TabIndex = 12; - buttonOverlay.Text = "AMD Overlay"; - buttonOverlay.TextImageRelation = TextImageRelation.ImageBeforeText; - buttonOverlay.UseVisualStyleBackColor = false; + comboInterval.BorderColor = Color.White; + comboInterval.ButtonColor = Color.FromArgb(255, 255, 255); + comboInterval.Dock = DockStyle.Top; + comboInterval.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + comboInterval.FormattingEnabled = true; + comboInterval.ItemHeight = 32; + comboInterval.Location = new Point(7, 75); + comboInterval.Margin = new Padding(7, 11, 7, 8); + comboInterval.Name = "comboInterval"; + comboInterval.Size = new Size(248, 40); + comboInterval.TabIndex = 19; + comboInterval.Visible = false; // // SettingsForm // @@ -1784,5 +1802,6 @@ namespace GHelper private RButton buttonFPS; private RButton buttonController; private RButton buttonOverlay; + private RComboBox comboInterval; } } diff --git a/app/Settings.cs b/app/Settings.cs index 5f01a4aa..9094b3b5 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -173,9 +173,11 @@ namespace GHelper comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList; comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList; + comboInterval.DropDownStyle = ComboBoxStyle.DropDownList; comboMatrix.DropDownClosed += ComboMatrix_SelectedValueChanged; comboMatrixRunning.DropDownClosed += ComboMatrixRunning_SelectedValueChanged; + comboInterval.DropDownClosed += ComboInterval_DropDownClosed; buttonMatrix.Click += ButtonMatrix_Click; @@ -721,6 +723,12 @@ namespace GHelper }); } + private void ComboInterval_DropDownClosed(object? sender, EventArgs e) + { + AppConfig.Set("matrix_interval", comboInterval.SelectedIndex); + matrixControl.SetDevice(); + } + private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e) { AppConfig.Set("matrix_running", comboMatrixRunning.SelectedIndex); @@ -902,11 +910,16 @@ namespace GHelper comboMatrixRunning.Items.Clear(); comboMatrixRunning.Items.Add("Transmission"); comboMatrixRunning.Items.Add("Bitstream"); + + comboInterval.Visible = true; + for (int i = 0; i <= 5; i++) comboInterval.Items.Add($"Interval {i}s"); + buttonMatrix.Visible = false; } 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); + comboInterval.SelectedIndex = Math.Min(AppConfig.Get("matrix_interval", 0), comboInterval.Items.Count - 1); checkMatrix.Checked = AppConfig.Is("matrix_auto"); checkMatrix.CheckedChanged += CheckMatrix_CheckedChanged;