Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesCJ60 committed Feb 5, 2023
1 parent 1deed19 commit 2d1dfd8
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 136 deletions.
136 changes: 0 additions & 136 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,142 +289,6 @@ private void OnPowerChange(object s, PowerModeChangedEventArgs e)
case PowerModes.Suspend:
break;
}

if (e.Mode == Microsoft.Win32.PowerModes.StatusChange)
{
BatteryInfo.getBattery();

if(SystemInformation.PowerStatus.BatteryChargeStatus != BatteryChargeStatus.NoSystemBattery || BatteryInfo.statuscode != 9999)
{
if (SystemInformation.PowerStatus.BatteryChargeStatus != BatteryChargeStatus.Charging || BatteryInfo.statuscode == 2 || BatteryInfo.statuscode == 6 || BatteryInfo.statuscode == 7 || BatteryInfo.statuscode == 8)
{
if (Settings.Default.ChargingPreset != "None")
{
RyzenAdj_To_UXTU.Translate(Settings.Default.ChargingPreset);
Settings.Default.RyzenAdjArguments = Settings.Default.ChargingPreset;
Settings.Default.Save();
}
}
else
{
if (Settings.Default.BatteryPreset != "None")
{
RyzenAdj_To_UXTU.Translate(Settings.Default.BatteryPreset);
Settings.Default.RyzenAdjArguments = Settings.Default.BatteryPreset;
Settings.Default.Save();
}
}
}

if ((bool)Settings.Default.isCPUCO == true)
{
if ((int)Settings.Default.COCPU >= 0)
{
SendCommand.set_coall((uint)Settings.Default.COCPU);
}
else
{
SendCommand.set_coall(Convert.ToUInt32(0x100000 - (uint)(-1 * (int)Settings.Default.COCPU)));
}
i++;
}

if ((bool)Settings.Default.isGPUCO == true)
{
if ((int)Settings.Default.COiGPU >= 0)
{
SendCommand.set_cogfx((uint)Settings.Default.COiGPU);
}
else
{
SendCommand.set_cogfx(Convert.ToUInt32(0x100000 - (uint)(-1 * (int)Settings.Default.COiGPU)));
}
i++;
}

string CCD1output = Settings.Default.PerCOCCD1;
string[] CCD1 = CCD1output.Split(',');

string CCD2output = Settings.Default.PerCOCCD2;
string[] CCD2 = CCD2output.Split(',');

if (Settings.Default.isPerCO == true)
{
int x = 0;
do
{
int CCD, CCX, CORE, magnitude, magnitude2;

CCD = 0;
CCX = 0;
CORE = x;

magnitude = Convert.ToInt32(CCD1[x]);
magnitude2 = Convert.ToInt32(CCD2[x]);

if (Families.FAMID == 3 || Families.FAMID == 7 || Families.FAMID == 8)
{
int value = (CORE << 20) | (magnitude & 0xFFFF);
SendCommand.set_coper(Convert.ToUInt32(value));
}
else if (magnitude >= 0)
{
uint CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);
}
else
{
magnitude = magnitude * -1;
uint CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude) & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude) & 0xFFFFF);
SendCommand.set_coper(CO);
}

if (magnitude2 >= 0)
{
uint CO;
if (Families.FAMID == 6 || Families.FAMID == 10)
{
CCD = 1;
CCX = 0;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);
}
}
else
{
magnitude2 = magnitude2 * -1;
uint CO;
if (Families.FAMID == 6 || Families.FAMID == 10)
{
CCX = 0;
CCD = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude2) & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude2) & 0xFFFFF);
SendCommand.set_coper(CO);
}
}

x++;
}
while (x < 8);
i++;
}
}
}
catch { }
}
Expand Down
139 changes: 139 additions & 0 deletions Windows/OverlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,147 @@ void Adaptive_Tick(object sender, EventArgs e)
public int cpuLoad = 0;
public int gpuLoad = 0;

public UInt16 lastStatus = 0;

void AutoReapply_Tick(object sender, EventArgs e)
{
BatteryInfo.getBattery();
int i = 0;
if (lastStatus != BatteryInfo.statuscode)
{
lastStatus = BatteryInfo.statuscode;
if (System.Windows.Forms.SystemInformation.PowerStatus.BatteryChargeStatus != BatteryChargeStatus.NoSystemBattery || BatteryInfo.statuscode != 9999)
{
if (System.Windows.Forms.SystemInformation.PowerStatus.BatteryChargeStatus == BatteryChargeStatus.Charging || BatteryInfo.statuscode == 2 || BatteryInfo.statuscode == 6 || BatteryInfo.statuscode == 7 || BatteryInfo.statuscode == 8)
{
if (Settings.Default.ChargingPreset != "None")
{
RyzenAdj_To_UXTU.Translate(Settings.Default.ChargingPreset);
Settings.Default.RyzenAdjArguments = Settings.Default.ChargingPreset;
Settings.Default.Save();
}
}
else
{
if (Settings.Default.BatteryPreset != "None")
{
RyzenAdj_To_UXTU.Translate(Settings.Default.BatteryPreset);
Settings.Default.RyzenAdjArguments = Settings.Default.BatteryPreset;
Settings.Default.Save();
}
}
}

if ((bool)Settings.Default.isCPUCO == true)
{
if ((int)Settings.Default.COCPU >= 0)
{
SendCommand.set_coall((uint)Settings.Default.COCPU);
}
else
{
SendCommand.set_coall(Convert.ToUInt32(0x100000 - (uint)(-1 * (int)Settings.Default.COCPU)));
}
i++;
}

if ((bool)Settings.Default.isGPUCO == true)
{
if ((int)Settings.Default.COiGPU >= 0)
{
SendCommand.set_cogfx((uint)Settings.Default.COiGPU);
}
else
{
SendCommand.set_cogfx(Convert.ToUInt32(0x100000 - (uint)(-1 * (int)Settings.Default.COiGPU)));
}
i++;
}

string CCD1output = Settings.Default.PerCOCCD1;
string[] CCD1 = CCD1output.Split(',');

string CCD2output = Settings.Default.PerCOCCD2;
string[] CCD2 = CCD2output.Split(',');

if (Settings.Default.isPerCO == true)
{
int x = 0;
do
{
int CCD, CCX, CORE, magnitude, magnitude2;

CCD = 0;
CCX = 0;
CORE = x;

magnitude = Convert.ToInt32(CCD1[x]);
magnitude2 = Convert.ToInt32(CCD2[x]);

if (Families.FAMID == 3 || Families.FAMID == 7 || Families.FAMID == 8)
{
int value = (CORE << 20) | (magnitude & 0xFFFF);
SendCommand.set_coper(Convert.ToUInt32(value));
}
else if (magnitude >= 0)
{
uint CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);
}
else
{
magnitude = magnitude * -1;
uint CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude) & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude) & 0xFFFFF);
SendCommand.set_coper(CO);
}

if (magnitude2 >= 0)
{
uint CO;
if (Families.FAMID == 6 || Families.FAMID == 10)
{
CCD = 1;
CCX = 0;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);
}
}
else
{
magnitude2 = magnitude2 * -1;
uint CO;
if (Families.FAMID == 6 || Families.FAMID == 10)
{
CCX = 0;
CCD = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude2) & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude2) & 0xFFFFF);
SendCommand.set_coper(CO);
}
}

x++;
}
while (x < 8);
i++;
}
}

if ((bool)Settings.Default.AutoReapply == true && GlobalVariables.AdaptivePerf == false)
{
string commands = (string)Settings.Default.RyzenAdjArguments;
Expand Down

0 comments on commit 2d1dfd8

Please sign in to comment.