From b8333064e21bd49709692ac4f81dee9513154026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Fri, 11 Nov 2022 19:56:08 +0100 Subject: [PATCH] Add some simple PropertyGrid interface --- .gitignore | 1 + FanControl/FanControl.cs | 58 +++++++++ FanControl/FanControl.csproj | 2 +- FanControl/FanControl.ico | Bin 0 -> 2191 bytes FanControl/FanControlForm.Designer.cs | 176 ++++++++++++++++++++++++++ FanControl/FanControlForm.cs | 75 +++++++++++ FanControl/FanControlForm.resx | 155 +++++++++++++++++++++++ FanControl/Program.cs | 15 ++- FanControl/Vlv0100.cs | 6 +- 9 files changed, 483 insertions(+), 5 deletions(-) create mode 100644 FanControl/FanControl.cs create mode 100644 FanControl/FanControl.ico create mode 100644 FanControl/FanControlForm.Designer.cs create mode 100644 FanControl/FanControlForm.cs create mode 100644 FanControl/FanControlForm.resx diff --git a/.gitignore b/.gitignore index c302b91..0307020 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin/ obj/ /.vs/ +*.user diff --git a/FanControl/FanControl.cs b/FanControl/FanControl.cs new file mode 100644 index 0000000..e3619be --- /dev/null +++ b/FanControl/FanControl.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics.Metrics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FanControl +{ + [TypeConverter(typeof(ExpandableObjectConverter))] + internal class FanControl + { + public enum FanMode + { + Default, + MidWay, + Max + } + + [CategoryAttribute("Fan")] + public FanMode Mode { get; private set; } + + [CategoryAttribute("Fan")] + public ushort CurrentRPM { get; private set; } + + [CategoryAttribute("Fan")] + public ushort DesiredRPM { get; private set; } + + public void Update() + { + CurrentRPM = Vlv0100.GetFanRPM(); + DesiredRPM = Vlv0100.GetFanDesiredRPM(); + } + + public void SetMode(FanMode mode) + { + switch (mode) + { + case FanMode.Default: + Vlv0100.SetFanControl(false); + break; + + case FanMode.MidWay: + Vlv0100.SetFanControl(true); + Vlv0100.SetFanDesiredRPM(Vlv0100.MAX_FAN_RPM/2); + break; + + case FanMode.Max: + Vlv0100.SetFanControl(true); + Vlv0100.SetFanDesiredRPM(Vlv0100.MAX_FAN_RPM); + break; + } + + this.Mode = mode; + } + } +} diff --git a/FanControl/FanControl.csproj b/FanControl/FanControl.csproj index 1b245fc..73ca95a 100644 --- a/FanControl/FanControl.csproj +++ b/FanControl/FanControl.csproj @@ -1,7 +1,7 @@ - Exe + WinExe net6.0-windows enable enable diff --git a/FanControl/FanControl.ico b/FanControl/FanControl.ico new file mode 100644 index 0000000000000000000000000000000000000000..a5aef5b920cc03c6683a7021834cf345693e1b93 GIT binary patch literal 2191 zcmV;A2ypiR00962000000096X0C@-i02TlM0EtjeM-2)Z3IG5A4M|8uQUCw|KmY&$ zKnMl^0063Kaozv`00DDSM?wIu&K&6g00=WlL_t(|UgcYFY*W`2|Gj5yH)*1x#rZ(hY-NwFg>6Wf!ivO)rbt~Hfh9_t zeP9z^f)Xi{jgUh}lxSJPl&~o@33c#4IrF>IwQS3F{O3OVJuhhILq7PObM866d+#~- zoO{FJe?X0mjVIl1H@0rw`jfG-vCXL_Y}vBqZ{y?RAMe?-XLfja_!BKnfw1F?d|Ply}i9lYUtGz005r?_<RIDoQdq`2~P)YXyMaZm+f3Z23pks9~A`px5ht z%gf6~tpMok?0li8r)R2A{h9#)K+ENimX;R%;NakY{%-*QpvvT_q9nsCXtn~{+uNV( z>+72T6a z3#fSxI18X#ZRa%w;QaaXLRVLpUj?Hzb3P{kXV0Fkak*T)PN(~)!{G?$;fxnRX&!Ph zkzWD$WdZUzMOSQrj*bq~qeqWCgM)MnCsT8C^ZKEop|5gkjWP&=@JS#Lpf$W=Dk&+E zg2CWv#exb2QUTb_^ZbY`%Nfyrre3JwBiB$1J=t9-imllx6v%5}AB?;{X^8hWSt^RH;A_ zb6V2rbR-;B6hgGjPDw7t2I>Uxp#tY)tgI2b764P_W;7b-{C@v)EVkHeHoN zvSMLj;iWV(Gz-!8*(+JMfWcrOp-_lr%yc|VAk^2_e=s>Yd5mEYYB25lrKN#^fic_DE%(k*Zjz;6pw3WLEQ zb$56FT9Txs$V~`&xw^Xg^O>2MG644h{0=~Gy75dVQ^(TM61C^W>gsCW{rmU7UtV7R z7XZv#h|!NN045@nv3>jYFGoj5zsV@b!uBSB#0WkVo%vA!jVuZPxB+YjFkDwx_xGu( zDMeW%*BF~NZNkjVOeFr%Kbq9-RaI3eFE3x3oSZa8XP!C~C#%&eI2?{2(jVH|+HUsu z_op74DPS+=a;AXqk=rKC07xk(QdaFYYTu|zkdD6$B!Qud=Sb6fYE4N@caE$vF|+3ACqM{H3Os# zf`TA?6$k|4vRW+BSTUr@Ss=mSoN18f`PXGxE_ND>H%0TU2AL*>g%+0EP%5%MTtrux{J7ZIQuP)YjH6Pft&;Vc`W3*+LAwd4ZtQ>0S$m!;xyR zn8X~tD9D5mR{P!s@N-s2L{a?O>-APpe%1k4b!X#y1Hk)A6h&L=v~JHyJkLwAEVJGs zeK+>tvM2yZlEh1rq^K_*^Z5Gp>uU}lKFlOrRaGU;&(CKBA^Pk#>7iv&05BK~r$V7n zUe{bDB_(~qV2~D3Ow`uaR@L9%zvBAt;K75audgq=bm>yk1IuCnP-wdH0T7wIPhgTH zX^qF@sU8>@SaiGHUuTln8i2eabgHqpZr!RpaNqz_rcnx%mH?>YeAFS@8qavUqtxj{ zeyspdl$LTiP*G7a`sB$I)|PrMbxGe<2S60X_q<-O7SCB!w^j9XfXQS!wY0R9SF~rC zw$%-Q#bT*+I-T?`D6-(s-@olYk``$yjKXh~|XfVizjqp?%3*MI2oc$C_& z**{8a8U(X=`5gc+SuB=Lr_)I002ovPDHLkV1k;59N7Q> literal 0 HcmV?d00001 diff --git a/FanControl/FanControlForm.Designer.cs b/FanControl/FanControlForm.Designer.cs new file mode 100644 index 0000000..6887a68 --- /dev/null +++ b/FanControl/FanControlForm.Designer.cs @@ -0,0 +1,176 @@ +namespace FanControl +{ + partial class FanControlForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FanControlForm)); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); + this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.fanModeSelectNotifyMenu = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.propertyGrid1 = new System.Windows.Forms.PropertyGrid(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.fanModeSelectMenu = new System.Windows.Forms.ToolStripComboBox(); + this.controlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.contextMenu.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Interval = 200; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // notifyIcon1 + // + this.notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; + this.notifyIcon1.BalloonTipText = "Test"; + this.notifyIcon1.ContextMenuStrip = this.contextMenu; + this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); + this.notifyIcon1.Text = "notifyIcon1"; + this.notifyIcon1.Visible = true; + this.notifyIcon1.DoubleClick += new System.EventHandler(this.formShow_Event); + // + // contextMenu + // + this.contextMenu.ImageScalingSize = new System.Drawing.Size(32, 32); + this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fanModeSelectNotifyMenu, + this.toolStripSeparator1, + this.toolStripMenuItem1}); + this.contextMenu.Name = "fanModeSelectMenu"; + this.contextMenu.Size = new System.Drawing.Size(182, 96); + // + // fanModeSelectNotifyMenu + // + this.fanModeSelectNotifyMenu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.fanModeSelectNotifyMenu.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.fanModeSelectNotifyMenu.Name = "fanModeSelectNotifyMenu"; + this.fanModeSelectNotifyMenu.Size = new System.Drawing.Size(121, 40); + this.fanModeSelectNotifyMenu.SelectedIndexChanged += new System.EventHandler(this.fanModeSelect_SelectedValueChanged); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(178, 6); + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(181, 38); + this.toolStripMenuItem1.Text = "Exit"; + this.toolStripMenuItem1.Click += new System.EventHandler(this.formClose_Event); + // + // propertyGrid1 + // + this.propertyGrid1.DisabledItemForeColor = System.Drawing.SystemColors.ControlText; + this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill; + this.propertyGrid1.HelpVisible = false; + this.propertyGrid1.Location = new System.Drawing.Point(0, 44); + this.propertyGrid1.Name = "propertyGrid1"; + this.propertyGrid1.Size = new System.Drawing.Size(712, 599); + this.propertyGrid1.TabIndex = 0; + this.propertyGrid1.ToolbarVisible = false; + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(32, 32); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fanModeSelectMenu, + this.controlToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(712, 44); + this.menuStrip1.TabIndex = 3; + this.menuStrip1.Text = "menuStrip1"; + // + // fanModeSelectMenu + // + this.fanModeSelectMenu.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.fanModeSelectMenu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.fanModeSelectMenu.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.fanModeSelectMenu.Name = "fanModeSelectMenu"; + this.fanModeSelectMenu.Size = new System.Drawing.Size(121, 40); + this.fanModeSelectMenu.SelectedIndexChanged += new System.EventHandler(this.fanModeSelect_SelectedValueChanged); + // + // controlToolStripMenuItem + // + this.controlToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.exitToolStripMenuItem}); + this.controlToolStripMenuItem.Name = "controlToolStripMenuItem"; + this.controlToolStripMenuItem.Size = new System.Drawing.Size(113, 40); + this.controlToolStripMenuItem.Text = "&Control"; + // + // exitToolStripMenuItem + // + this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; + this.exitToolStripMenuItem.Size = new System.Drawing.Size(184, 44); + this.exitToolStripMenuItem.Text = "&Exit"; + this.exitToolStripMenuItem.Click += new System.EventHandler(this.formClose_Event); + // + // FanControlForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(712, 643); + this.Controls.Add(this.propertyGrid1); + this.Controls.Add(this.menuStrip1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip1; + this.Name = "FanControlForm"; + this.Text = "Steam Deck Fan Control"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FanControlForm_FormClosing); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FanControlForm_FormClosed); + this.contextMenu.ResumeLayout(false); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Timer timer1; + private NotifyIcon notifyIcon1; + private PropertyGrid propertyGrid1; + private ContextMenuStrip contextMenu; + private MenuStrip menuStrip1; + private ToolStripComboBox fanModeSelectNotifyMenu; + private ToolStripSeparator toolStripSeparator1; + private ToolStripMenuItem toolStripMenuItem1; + private ToolStripComboBox fanModeSelectMenu; + private ToolStripMenuItem controlToolStripMenuItem; + private ToolStripMenuItem exitToolStripMenuItem; + } +} \ No newline at end of file diff --git a/FanControl/FanControlForm.cs b/FanControl/FanControlForm.cs new file mode 100644 index 0000000..769464f --- /dev/null +++ b/FanControl/FanControlForm.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.Common; +using System.Drawing; +using System.Linq; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace FanControl +{ + public partial class FanControlForm : Form + { + private FanControl fanControl = new FanControl(); + + public FanControlForm() + { + InitializeComponent(); + + propertyGrid1.SelectedObject = fanControl; + + foreach(var item in Enum.GetValues(typeof(FanControl.FanMode))) + { + fanModeSelectMenu.Items.Add(item); + fanModeSelectNotifyMenu.Items.Add(item); + } + + fanModeSelectMenu.SelectedIndex = 0; + } + + private void timer1_Tick(object sender, EventArgs e) + { + fanControl.Update(); + propertyGrid1.Refresh(); + } + + private void fanModeSelect_SelectedValueChanged(object sender, EventArgs e) + { + var comboBox = (ToolStripComboBox)sender; + var selectedMode = (FanControl.FanMode)comboBox.SelectedItem; + fanControl.SetMode(selectedMode); + fanModeSelectMenu.SelectedItem = selectedMode; + fanModeSelectNotifyMenu.SelectedItem = selectedMode; + } + + private void FanControlForm_FormClosing(object sender, FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing && Visible) + { + e.Cancel = true; + Hide(); + } + } + + private void formShow_Event(object sender, EventArgs e) + { + Show(); + } + + private void formClose_Event(object sender, EventArgs e) + { + Hide(); + Close(); + } + + private void FanControlForm_FormClosed(object sender, FormClosedEventArgs e) + { + // Always revert to default on closing + fanControl.SetMode(FanControl.FanMode.Default); + } + } +} diff --git a/FanControl/FanControlForm.resx b/FanControl/FanControlForm.resx new file mode 100644 index 0000000..0d0c339 --- /dev/null +++ b/FanControl/FanControlForm.resx @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 159, 17 + + + 353, 17 + + + + + AAABAAEAAAAAAAEAIAB5CAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAABAAAAAQAgGAAAAqmlx3gAAAAFz + UkdCAK7OHOkAAAgzSURBVHhe5VtvbFPXFf+9Z2zlOQ8nIRG0E0RJGhQEW0kBW0QiJVoZAy2ZNiSDsvQD + SzdpoqLF+UDVbGWPrYVtSJjCisSHpkhdGoElSpt9YBNdghIpk42QQ0eUaFnClLApNAl18D8587vTtWzL + dvznPvs9L2jnQz74nXPuOb977zn3nHvD4X9AjY2NJ91uN7Zu3fqTsbGxzakmbNmy5W/j4+Mf79mzZ3Z4 + ePgTLU3ktFSeqruurs42NTV1XsmYOp0O4XD4NQA9SuRYeYsFQENNTc34w4cPWe1awWcwGBZDoVA7gD/n + rSSNYDEAqAPwDxWNbgLwV7X0aQrAiRMnnr9w4cK/1DKW6uF5Hu3t7WW9vb1LaujVFAAAnwL4gRqGJupo + aWnB4OCgKraroiSLg0Rt5xP0qWK7KkoyOPkFgG9rBYDdbq+12Wz5R9WoYZoBoNfrfcvLy0atAOjs7Hyh + p6dnqlD9mgEAQMvlj5aW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FcDAPqKQ5Zl+jRmOhAI + vLJz587PxsbGSqMrgcabtMUQAHr6e4vOvNlsDrpcrhUTQgjhBUF4JxgMMrXlcvgTOQckUsHvedauXfvR + 06dP6ZZKpVhRBFEUF71eb9L1liAIpxMC3nDizGdwgjZMTxU4YftXtJ66u7ufP3PmDA1GSp62+ARB6Pf7 + /a9yHJet9zUCYHcuoxsaGq5MTEz8LBcfgDMAmHqTqbpKS0vh8/kitUA2+kKv1+9OfehAu7YAhgghyw8e + PLBu27ZtkcFY1NbWLk9PT69h4QUQ2UIMvHmBoNPpXguHw5FqsJjEHL0oyIQQVvveBfBzVkdEUfza6/VW + UH7WAVh1Z+N7A8D7ShRFW+q0bs9JPM9Lsiyz3iJ9N/bgsigASJLES5KkqC8e8/j69etrDh8+zCRbVVUl + zc/PZwQh+uw26aFlUQAwGAynQqFQXtdcJSUlfcFgkBZRTNTW1lbV39+/4vru4MGDqK+vL7t06VLSA8ti + AFBouvIBEJm8T2CSJGmNx+OpHhgYWHS73V9nktcagLwidKqxt27dqjxw4ABTplEKlJYAqOJ81CHaGs94 + u6PU6UR+rQBQlJZyOVBRUTH65MkT1pZ6LnVJ31UHQBTF97xerxbPWVS3VfVzgMlkOrW0tJRXtGeYttUN + gMViqXQ6nfMMjuTLsroB0OqGKQGt1QuA1WrVORwOxU9hFC6F1QuA2Wyuc7lcav5fUHKk5jg/IaSQ12YZ + sVYF1aNHj9ZcvXqVpXRVOOlx9mfiHMBc6uaBgioTlW5c1RTv27eP3L59Ow/fcorcBBDpHmtBqgFw/Phx + 0+XLlz0KX4Pl9OnQoUPfuHHjRtK7npxCChhUAyA6Ju330b6fWpT0nkctpVrXAvtFUewr5F7fYrEEnU4n + PftH3vFoSWqvgLitRqOxU6/Xf+jxeJTar9k/SmsaBLN4+R0AL1kslk6n00kvX5KooaFhZmJi4vdHjhzx + XLt27YpStArl/y+pZ32X/qZ1gAAAAABJRU5ErkJggg== + + + \ No newline at end of file diff --git a/FanControl/Program.cs b/FanControl/Program.cs index 3886619..5622e47 100644 --- a/FanControl/Program.cs +++ b/FanControl/Program.cs @@ -62,8 +62,7 @@ namespace FanControl computer.Close(); } - - static void Main(string[] args) + static void ConsoleMain(string[] args) { // Monitor(); @@ -78,5 +77,17 @@ namespace FanControl Console.WriteLine("Fan Desired RPM: {0}", Vlv0100.GetFanDesiredRPM()); } } + + static void Main(string[] args) + { + if (Environment.UserInteractive && !Console.IsInputRedirected) + { + ConsoleMain(args); + } + else + { + Application.Run(new FanControlForm()); + } + } } } diff --git a/FanControl/Vlv0100.cs b/FanControl/Vlv0100.cs index cc83939..7300617 100644 --- a/FanControl/Vlv0100.cs +++ b/FanControl/Vlv0100.cs @@ -18,6 +18,8 @@ namespace FanControl static IntPtr FNCK = new IntPtr(0xFE700300 + 0x9F); static ushort IO6C = 0x6C; + public const ushort MAX_FAN_RPM = 0x1C84; + public static ushort GetFanDesiredRPM() { byte[] data = InpOut.ReadMemory(FSLO_FSHI, 2); @@ -39,8 +41,8 @@ namespace FanControl public static void SetFanDesiredRPM(ushort rpm) { - if (rpm > 0x1C84) - rpm = 0x1C84; + if (rpm > MAX_FAN_RPM) + rpm = MAX_FAN_RPM; byte[] data = BitConverter.GetBytes(rpm); InpOut.WriteMemory(FSLO_FSHI, data);