Skip to content

Commit

Permalink
Config updates, including new Manufacturer field
Browse files Browse the repository at this point in the history
- Add required computer manufacturer field - if your config doesn't load anymore, try copying the value from one of the upstream configs

- Update computer model and manufacturer in config when using EC-to-config feature

- Change the default charge limit to disabled on all configs (accidentally left at 60% - the value I use on my laptop)

- Change default fan curve selection to Default (instead of Custom) on the GF63 Thin 11SC config
  • Loading branch information
Sparronator9999 committed Dec 8, 2024
1 parent aa3f8a6 commit c788410
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Configs/MSI-10th-gen-or-newer-nokeylight.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<YAMDCC_Config xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Ver="1">
<Model>MSI laptop - generic 10th-gen Intel (or newer), sans keyboard backlight control</Model>
<Manufacturer>Micro-Star International Co., Ltd.</Manufacturer>
<Model>~Generic: 10th-gen Intel (or newer) - no keyboard backlight support</Model>
<Author>Sparronator9999</Author>
<FanConfs>
<FanConf>
Expand Down
3 changes: 2 additions & 1 deletion Configs/MSI-10th-gen-or-newer.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<YAMDCC_Config xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Ver="1">
<Model>MSI laptop - generic 10th-gen Intel (or newer)</Model>
<Manufacturer>Micro-Star International Co., Ltd.</Manufacturer>
<Model>~Generic: 10th-gen Intel (or newer)</Model>
<Author>Sparronator9999</Author>
<FanConfs>
<FanConf>
Expand Down
5 changes: 3 additions & 2 deletions Configs/MSI-9th-gen-or-older.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<YAMDCC_Config xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Ver="1">
<Model>MSI laptop - generic 9th-gen Intel (or older)</Model>
<Manufacturer>Micro-Star International Co., Ltd.</Manufacturer>
<Model>~Generic: 9th-gen Intel (or older)</Model>
<Author>Sparronator9999</Author>
<FanConfs>
<FanConf>
Expand Down Expand Up @@ -180,7 +181,7 @@
<Reg>239</Reg>
<MinVal>128</MinVal>
<MaxVal>228</MaxVal>
<CurVal>60</CurVal>
<CurVal>0</CurVal>
</ChargeLimitConf>
<KeyLightConf>
<Reg>243</Reg>
Expand Down
9 changes: 5 additions & 4 deletions Configs/MSI-GF63-Thin-11SC.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<YAMDCC_Config xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Ver="1">
<Model>MSI GF63 Thin 11SC</Model>
<Manufacturer>Micro-Star International Co., Ltd.</Manufacturer>
<Model>GF63 Thin 11SC</Model>
<Author>Sparronator9999</Author>
<FanConfs>
<FanConf>
<Name>CPU Fan</Name>
<MinSpeed>0</MinSpeed>
<MaxSpeed>100</MaxSpeed>
<CurveSel>1</CurveSel>
<CurveSel>0</CurveSel>
<SpeedReadReg>113</SpeedReadReg>
<TempReadReg>104</TempReadReg>
<RPMConf>
Expand Down Expand Up @@ -132,7 +133,7 @@
<Name>GPU Fan</Name>
<MinSpeed>0</MinSpeed>
<MaxSpeed>100</MaxSpeed>
<CurveSel>1</CurveSel>
<CurveSel>0</CurveSel>
<SpeedReadReg>137</SpeedReadReg>
<TempReadReg>128</TempReadReg>
<RPMConf>
Expand Down Expand Up @@ -262,7 +263,7 @@
<Reg>215</Reg>
<MinVal>128</MinVal>
<MaxVal>228</MaxVal>
<CurVal>60</CurVal>
<CurVal>0</CurVal>
</ChargeLimitConf>
<PerfModeConf>
<Reg>210</Reg>
Expand Down
9 changes: 8 additions & 1 deletion YAMDCC.Config/YAMDCC_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public sealed class YAMDCC_Config
[XmlAttribute]
public int Ver { get; set; }

/// <summary>
/// The manufacturer of the laptop the config was made for.
/// </summary>
[XmlElement]
public string Manufacturer { get; set; }

/// <summary>
/// The laptop model the config was made for.
/// </summary>
Expand Down Expand Up @@ -173,7 +179,8 @@ private bool IsValid()
return false;
}

if (string.IsNullOrEmpty(Model) ||
if (string.IsNullOrEmpty(Manufacturer) ||
string.IsNullOrEmpty(Model) ||
string.IsNullOrEmpty(Author))
{
return false;
Expand Down
65 changes: 63 additions & 2 deletions YAMDCC.Service/FanControlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License along with
// YAMDCC. If not, see <https://www.gnu.org/licenses/>.

using Microsoft.Win32;
using System;
using System.ComponentModel;
using System.Globalization;
Expand Down Expand Up @@ -735,9 +736,32 @@ private void FanCurveECToConf()

try
{
Log.Info("Getting computer manufacturer and model...");

string pcManufacturer = GetComputerManufacturer(),
pcModel = GetComputerModel();

if (string.IsNullOrEmpty(pcManufacturer))
{
Log.Error("Failed to get computer manufacturer!");
}
else
{
Config.Manufacturer = pcManufacturer.Trim();
}

if (string.IsNullOrEmpty(pcModel))
{
Log.Error("Failed to get computer model!");
}
else
{
Config.Model = pcModel.Trim();
}

for (int i = 0; i < Config.FanConfs.Length; i++)
{
Log.Debug($"Getting fan curve from EC ({i + 1}/{Config.FanConfs.Length})...");
Log.Info($"Getting fan curve from EC ({i + 1}/{Config.FanConfs.Length})...");

FanConf cfg = Config.FanConfs[i];

Expand Down Expand Up @@ -785,7 +809,7 @@ private void FanCurveECToConf()
}
}

Log.Debug("Saving config...");
Log.Info("Saving config...");
Config.Save(Paths.CurrentConfig);

FileStream fs = File.Create(Paths.ECToConfSuccess);
Expand All @@ -797,5 +821,42 @@ private void FanCurveECToConf()
fs.Close();
}
}

/// <summary>
/// Gets the computer model name from registry.
/// </summary>
/// <returns>
/// The computer model if the function succeeds,
/// otherwise <c>null</c>.
/// </returns>
private static string GetComputerModel()
{
return GetBIOSRegValue("SystemProductName");
}

/// <summary>
/// Gets the computer manufacturer from registry.
/// </summary>
/// <returns>
/// The computer manufacturer if the function succeeds,
/// otherwise <c>null</c>.
/// </returns>
private static string GetComputerManufacturer()
{
return GetBIOSRegValue("SystemManufacturer");
}

private static string GetBIOSRegValue(string name)
{
RegistryKey biosKey = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\BIOS");
try
{
return (string)biosKey?.GetValue(name, null);
}
finally
{
biosKey?.Close();
}
}
}
}

2 comments on commit c788410

@porkmanager
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey. two latest builds doesent contains an app XD

@Sparronator9999
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit.

Please sign in to comment.