Skip to content

Commit

Permalink
Template configs: the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparronator9999 committed Sep 25, 2024
1 parent bfcb5a2 commit 50dc064
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 3 deletions.
150 changes: 150 additions & 0 deletions Configs/MSI-10th-gen-or-newer.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?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 laptops (10th-gen Intel or newer) Template Config</Model>
<Author>Sparronator9999</Author>
<Template>true</Template>
<FanConfs>
<FanConf>
<Name>CPU Fan</Name>
<MinSpeed>0</MinSpeed>
<MaxSpeed>100</MaxSpeed>
<CurveSel>1</CurveSel>
<SpeedReadReg>113</SpeedReadReg>
<TempReadReg>104</TempReadReg>
<RPMConf>
<ReadReg>200</ReadReg>
<Is16Bit>true</Is16Bit>
<IsBigEndian>true</IsBigEndian>
<RPMMult>478000</RPMMult>
<DivideByMult>true</DivideByMult>
<Invert>true</Invert>
</RPMConf>
<UpThresholdRegs>
<unsignedByte>106</unsignedByte>
<unsignedByte>107</unsignedByte>
<unsignedByte>108</unsignedByte>
<unsignedByte>109</unsignedByte>
<unsignedByte>110</unsignedByte>
<unsignedByte>111</unsignedByte>
</UpThresholdRegs>
<DownThresholdRegs>
<unsignedByte>122</unsignedByte>
<unsignedByte>123</unsignedByte>
<unsignedByte>124</unsignedByte>
<unsignedByte>125</unsignedByte>
<unsignedByte>126</unsignedByte>
<unsignedByte>127</unsignedByte>
</DownThresholdRegs>
<FanCurveRegs>
<unsignedByte>114</unsignedByte>
<unsignedByte>115</unsignedByte>
<unsignedByte>116</unsignedByte>
<unsignedByte>117</unsignedByte>
<unsignedByte>118</unsignedByte>
<unsignedByte>119</unsignedByte>
<unsignedByte>120</unsignedByte>
</FanCurveRegs>
<FanCurveConfs/>
</FanConf>
<FanConf>
<Name>GPU Fan</Name>
<MinSpeed>0</MinSpeed>
<MaxSpeed>100</MaxSpeed>
<CurveSel>1</CurveSel>
<SpeedReadReg>137</SpeedReadReg>
<TempReadReg>128</TempReadReg>
<RPMConf>
<ReadReg>200</ReadReg>
<Is16Bit>true</Is16Bit>
<IsBigEndian>true</IsBigEndian>
<RPMMult>478000</RPMMult>
<DivideByMult>true</DivideByMult>
<Invert>true</Invert>
</RPMConf>
<UpThresholdRegs>
<unsignedByte>130</unsignedByte>
<unsignedByte>131</unsignedByte>
<unsignedByte>132</unsignedByte>
<unsignedByte>133</unsignedByte>
<unsignedByte>134</unsignedByte>
<unsignedByte>135</unsignedByte>
</UpThresholdRegs>
<DownThresholdRegs>
<unsignedByte>146</unsignedByte>
<unsignedByte>147</unsignedByte>
<unsignedByte>148</unsignedByte>
<unsignedByte>149</unsignedByte>
<unsignedByte>150</unsignedByte>
<unsignedByte>151</unsignedByte>
</DownThresholdRegs>
<FanCurveRegs>
<unsignedByte>138</unsignedByte>
<unsignedByte>139</unsignedByte>
<unsignedByte>140</unsignedByte>
<unsignedByte>141</unsignedByte>
<unsignedByte>142</unsignedByte>
<unsignedByte>143</unsignedByte>
<unsignedByte>144</unsignedByte>
</FanCurveRegs>
<FanCurveConfs/>
</FanConf>
</FanConfs>
<FullBlastConf>
<Reg>152</Reg>
<OnVal>134</OnVal>
<OffVal>6</OffVal>
</FullBlastConf>
<ChargeLimitConf>
<Reg>215</Reg>
<MinVal>128</MinVal>
<MaxVal>228</MaxVal>
<CurVal>60</CurVal>
</ChargeLimitConf>
<PerfModeConf>
<Reg>210</Reg>
<ModeSel>2</ModeSel>
<PerfModes>
<PerfMode>
<Name>Maximum battery life</Name>
<Desc>Optimises your laptop for maximum battery life.
Limits CPU power draw to 10W.
If set to default fan curve, uses an alternative fan curve.</Desc>
<Value>194</Value>
</PerfMode>
<PerfMode>
<Name>Silent</Name>
<Desc>Reduces the maximum fan speed to 60%.</Desc>
<Value>193</Value>
</PerfMode>
<PerfMode>
<Name>Balanced</Name>
<Desc>Balances battery life and performance.</Desc>
<Value>192</Value>
</PerfMode>
<PerfMode>
<Name>High performance</Name>
<Desc>Optimises your laptop for maximum performance.
Old (pre-alpha) versions of MSI Fan Control/YAMDCC set this setting.</Desc>
<Value>196</Value>
</PerfMode>
</PerfModes>
</PerfModeConf>
<KeySwapConf>
<Reg>232</Reg>
<Enabled>false</Enabled>
<OnVal>16</OnVal>
<OffVal>0</OffVal>
</KeySwapConf>
<KeyLightConf>
<Reg>211</Reg>
<MinVal>128</MinVal>
<MaxVal>131</MaxVal>
</KeyLightConf>
<RegConfs>
<RegConf>
<Desc>Set fan mode to Advanced. Fixes fans not working at all with certain fan settings.</Desc>
<Reg>212</Reg>
<Value>77</Value>
</RegConf>
</RegConfs>
</YAMDCC_Config>
115 changes: 115 additions & 0 deletions Configs/MSI-9th-gen-or-older.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?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 laptops (9th-gen Intel or earlier) Template Config</Model>
<Author>Sparronator9999</Author>
<Template>true</Template>
<FanConfs>
<FanConf>
<Name>CPU Fan</Name>
<MinSpeed>0</MinSpeed>
<MaxSpeed>100</MaxSpeed>
<CurveSel>0</CurveSel>
<SpeedReadReg>113</SpeedReadReg>
<TempReadReg>104</TempReadReg>
<RPMConf>
<ReadReg>200</ReadReg>
<Is16Bit>true</Is16Bit>
<IsBigEndian>true</IsBigEndian>
<RPMMult>478000</RPMMult>
<DivideByMult>true</DivideByMult>
<Invert>true</Invert>
</RPMConf>
<UpThresholdRegs>
<unsignedByte>106</unsignedByte>
<unsignedByte>107</unsignedByte>
<unsignedByte>108</unsignedByte>
<unsignedByte>109</unsignedByte>
<unsignedByte>110</unsignedByte>
<unsignedByte>111</unsignedByte>
</UpThresholdRegs>
<DownThresholdRegs>
<unsignedByte>122</unsignedByte>
<unsignedByte>123</unsignedByte>
<unsignedByte>124</unsignedByte>
<unsignedByte>125</unsignedByte>
<unsignedByte>126</unsignedByte>
<unsignedByte>127</unsignedByte>
</DownThresholdRegs>
<FanCurveRegs>
<unsignedByte>114</unsignedByte>
<unsignedByte>115</unsignedByte>
<unsignedByte>116</unsignedByte>
<unsignedByte>117</unsignedByte>
<unsignedByte>118</unsignedByte>
<unsignedByte>119</unsignedByte>
<unsignedByte>120</unsignedByte>
</FanCurveRegs>
<FanCurveConfs/>
</FanConf>
<FanConf>
<Name>GPU Fan</Name>
<MinSpeed>0</MinSpeed>
<MaxSpeed>100</MaxSpeed>
<CurveSel>0</CurveSel>
<SpeedReadReg>137</SpeedReadReg>
<TempReadReg>128</TempReadReg>
<RPMConf>
<ReadReg>200</ReadReg>
<Is16Bit>true</Is16Bit>
<IsBigEndian>true</IsBigEndian>
<RPMMult>478000</RPMMult>
<DivideByMult>true</DivideByMult>
<Invert>true</Invert>
</RPMConf>
<UpThresholdRegs>
<unsignedByte>130</unsignedByte>
<unsignedByte>131</unsignedByte>
<unsignedByte>132</unsignedByte>
<unsignedByte>133</unsignedByte>
<unsignedByte>134</unsignedByte>
<unsignedByte>135</unsignedByte>
</UpThresholdRegs>
<DownThresholdRegs>
<unsignedByte>146</unsignedByte>
<unsignedByte>147</unsignedByte>
<unsignedByte>148</unsignedByte>
<unsignedByte>149</unsignedByte>
<unsignedByte>150</unsignedByte>
<unsignedByte>151</unsignedByte>
</DownThresholdRegs>
<FanCurveRegs>
<unsignedByte>138</unsignedByte>
<unsignedByte>139</unsignedByte>
<unsignedByte>140</unsignedByte>
<unsignedByte>141</unsignedByte>
<unsignedByte>142</unsignedByte>
<unsignedByte>143</unsignedByte>
<unsignedByte>144</unsignedByte>
</FanCurveRegs>
<FanCurveConfs/>
</FanConf>
</FanConfs>
<FullBlastConf>
<Reg>152</Reg>
<OnVal>134</OnVal>
<OffVal>6</OffVal>
</FullBlastConf>
<ChargeLimitConf>
<Reg>239</Reg>
<MinVal>128</MinVal>
<MaxVal>228</MaxVal>
<CurVal>60</CurVal>
</ChargeLimitConf>
<KeyLightConf>
<Reg>243</Reg>
<MinVal>128</MinVal>
<MaxVal>131</MaxVal>
</KeyLightConf>
<RegConfs>
<RegConf>
<Desc>Set fan mode to Advanced. Fixes fans not working at all with certain fan settings.</Desc>
<Reg>244</Reg>
<Value>77</Value>
</RegConf>
</RegConfs>
</YAMDCC_Config>
4 changes: 4 additions & 0 deletions YAMDCC.Config/FanConf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public sealed class FanConf
/// <summary>
/// The list of <see cref="FanCurveConf"/>s associated with this fan.
/// </summary>
/// <remarks>
/// If the base config is a template, this may be <c>null</c>,
/// otherwise at least one fan curve (the "default" curve) must exist.
/// </remarks>
[XmlArray]
public FanCurveConf[] FanCurveConfs { get; set; }
}
Expand Down
7 changes: 7 additions & 0 deletions YAMDCC.Config/YAMDCC_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public sealed class YAMDCC_Config
[XmlElement]
public string Author { get; set; }

/// <summary>
/// Is this config a "template" config that is used
/// when generating other (non-template) configs?
/// </summary>
[XmlElement]
public bool Template { get; set; }

/// <summary>
/// The list of <see cref="FanConf"/>s associated with the laptop.
/// </summary>
Expand Down
19 changes: 16 additions & 3 deletions YAMDCC.GUI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,11 @@ private void LoadConf(string confPath)

try
{
Config = YAMDCC_Config.Load(confPath);
LoadConf(Config);
YAMDCC_Config tmpConf = YAMDCC_Config.Load(confPath);
if (LoadConf(tmpConf))
{
Config = tmpConf;
}
}
catch
{
Expand All @@ -695,9 +698,18 @@ private void LoadConf(string confPath)
tsiSaveConf.Enabled = true;
}

private void LoadConf(YAMDCC_Config config)
private bool LoadConf(YAMDCC_Config config)
{
lblStatus.Text = "Loading config, please wait...";
if (config.Template)
{
MessageBox.Show(
"This is a template config.\n" +
"Template configs are currently WIP and cannot be used yet.\n" +
"Please load a different config.");
return false;
}

tsiSaveConf.Enabled = true;

if (config.FullBlastConf is null)
Expand Down Expand Up @@ -768,6 +780,7 @@ private void LoadConf(YAMDCC_Config config)
tsiECMon.Enabled = true;

lblStatus.Text = "Ready";
return true;
}

private void ApplyConf()
Expand Down
9 changes: 9 additions & 0 deletions YAMDCC.Service/FanControlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@ private void LoadConf()
Log.Error(Strings.GetString("cfgInvalid"));
}

if (Config.Template)
{
Log.Error(
"Template configs are still WIP and unsupported for now.\n" +
"Please load another config using the configurator app.");
ConfigLoaded = false;
return;
}

ConfigLoaded = true;
Log.Info(Strings.GetString("cfgLoadSuccess"));
}
Expand Down

0 comments on commit 50dc064

Please sign in to comment.