Skip to content

Commit

Permalink
TR
Browse files Browse the repository at this point in the history
  • Loading branch information
HamzaYslmn committed Mar 31, 2023
2 parents 8e8e2af + 3eeac03 commit a5cccdb
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 77 deletions.
41 changes: 24 additions & 17 deletions app/ASUSWmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,31 @@ protected byte[] CallMethod(uint MethodID, byte[] args)

}

public byte[] DeviceSet(uint DeviceID, int Status)
public int DeviceSet(uint DeviceID, int Status, string logName)
{
byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
return CallMethod(DEVS, args);

byte[] status = CallMethod(DEVS, args);
int result = BitConverter.ToInt32(status, 0);

Logger.WriteLine(logName + " = " + Status + " : " + (result == 1 ? "OK" : result));
return result;
}


public byte[] DeviceSet(uint DeviceID, byte[] Params)
public int DeviceSet(uint DeviceID, byte[] Params, string logName)
{
byte[] args = new byte[4 + Params.Length];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
Params.CopyTo(args, 4);
return CallMethod(DEVS, args);

byte[] status = CallMethod(DEVS, args);
int result = BitConverter.ToInt32(status, 0);

Logger.WriteLine(logName + " = " + BitConverter.ToString(Params) + " : " + (result == 1 ? "OK" : result));
return BitConverter.ToInt32(status, 0);
}


Expand All @@ -192,31 +202,28 @@ public byte[] DeviceGetBuffer(uint DeviceID, uint Status = 0)
}


public void SetFanCurve(int device, byte[] curve)
public int SetFanCurve(int device, byte[] curve)
{

if (curve.Length != 16) return;
if (curve.All(singleByte => singleByte == 0)) return;
if (curve.Length != 16) return -1;
if (curve.All(singleByte => singleByte == 0)) return -1;

string name;
int result;

switch (device)
{
case 1:
DeviceSet(DevsGPUFanCurve, curve);
name = "GPU";
result = DeviceSet(DevsGPUFanCurve, curve, "FanGPU");
break;
case 2:
DeviceSet(DevsMidFanCurve, curve);
name = "Mid";
result = DeviceSet(DevsMidFanCurve, curve, "FanMid");
break;
default:
DeviceSet(DevsCPUFanCurve, curve);
name = "CPU";
result = DeviceSet(DevsCPUFanCurve, curve, "FanCPU");
break;
}

Logger.WriteLine("Fans" + name + " " + BitConverter.ToString(curve));
return result;
}

public byte[] GetFanCurve(int device, int mode = 0)
Expand Down Expand Up @@ -254,7 +261,7 @@ public void TUFKeyboardRGB(int mode, Color color, int speed)
setting[4] = color.B;
setting[5] = (byte)speed;

DeviceSet(TUF_KB, setting);
DeviceSet(TUF_KB, setting, "TUF RGB");
//Debug.WriteLine(BitConverter.ToString(setting));

}
Expand All @@ -274,7 +281,7 @@ public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep =

state = state | 0x01 << 8;

DeviceSet(TUF_KB_STATE, state);
DeviceSet(TUF_KB_STATE, state, "TUF_KB");
}

public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
Expand Down
2 changes: 1 addition & 1 deletion app/AnimeMatrix/AnimeMatrixDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public void PresentText(string text1, string text2 = "")

}

public void GenerateFrame(Image image, InterpolationMode interpolation = InterpolationMode.HighQualityBicubic)
public void GenerateFrame(Image image, InterpolationMode interpolation = InterpolationMode.High)
{

int width = MaxColumns/2 * 6;
Expand Down
3 changes: 2 additions & 1 deletion app/ControlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ private static void AdjustControls(Control.ControlCollection controls)
combo.BackColor = backMain;
combo.ForeColor = foreMain;
combo.BorderColor = backMain;
combo.ButtonColor = buttonMain;
combo.ButtonColor = backMain;
combo.ArrowColor = foreMain;
}

var gb = control as GroupBox;
Expand Down
4 changes: 2 additions & 2 deletions app/CustomControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public Color BorderColor
}


private Color buttonColor = Color.FromArgb(255,230, 230, 230);
[DefaultValue(typeof(Color), "230, 230, 230")]
private Color buttonColor = Color.FromArgb(255, 255, 255, 255);
[DefaultValue(typeof(Color), "255, 255, 255")]
public Color ButtonColor
{
get { return buttonColor; }
Expand Down
14 changes: 8 additions & 6 deletions app/Fans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void LoadProfile(Series series, int device, int def = 0)

}

void ApplyProfile(Series series, int device)
void SaveProfile(Series series, int device)
{
byte[] curve = new byte[16];
int i = 0;
Expand All @@ -346,17 +346,19 @@ void ApplyProfile(Series series, int device)
}

Program.config.setFanConfig(device, curve);
Program.wmi.SetFanCurve(device, curve);
//Program.wmi.SetFanCurve(device, curve);

}


private void ButtonApply_Click(object? sender, EventArgs e)
{
ApplyProfile(seriesCPU, 0);
ApplyProfile(seriesGPU, 1);
SaveProfile(seriesCPU, 0);
SaveProfile(seriesGPU, 1);
if (Program.config.getConfig("mid_fan") == 1)
ApplyProfile(seriesMid, 2);
SaveProfile(seriesMid, 2);

Program.settingsForm.AutoFans(true);
}

private void ButtonReset_Click(object? sender, EventArgs e)
Expand All @@ -373,7 +375,7 @@ private void ButtonReset_Click(object? sender, EventArgs e)
Program.config.setConfigPerf("auto_apply", 0);
Program.config.setConfigPerf("auto_apply_power", 0);

Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"));
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");

ApplyLabel(false);
}
Expand Down
2 changes: 1 addition & 1 deletion app/GHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.43</AssemblyVersion>
<AssemblyVersion>0.44</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion app/HardwareMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static int GetFanMax()
int max = 58;
if (Program.config.ContainsModel("401")) max = 72;
else if (Program.config.ContainsModel("503")) max = 68;

return Math.Max(max, Program.config.getConfig("fan_max"));
}

Expand Down
1 change: 1 addition & 0 deletions app/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ public static int SetRefreshRate(int frequency = 120)
{
dm.dmDisplayFrequency = frequency;
int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet));
return iRet;
}

Expand Down
2 changes: 1 addition & 1 deletion app/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static void LaunchProcess(string fileName = "")
}
catch
{
Logger.WriteLine("Failed to run " + fileName);
Logger.WriteLine("Failed to run " + fileName);
}


Expand Down
3 changes: 0 additions & 3 deletions app/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a5cccdb

Please sign in to comment.