Skip to content

Commit

Permalink
Small UI and code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
irusanov committed Sep 25, 2019
1 parent e95173f commit 86b78c7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 38 deletions.
58 changes: 28 additions & 30 deletions NotificationIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public NotificationIcon()
}
}


// Init tray icon
notifyIcon = new NotifyIcon
{
Expand All @@ -131,6 +130,10 @@ public NotificationIcon()
// Load service data interface
di = new DataInterface(false);

smuVersion = getSmuVersionString(di.MemRead(DataInterface.REG_SMU_VERSION));
cpuType = di.MemRead(DataInterface.REG_CPU_TYPE);
smuVersionInt = checkSmuVersion(di.MemRead(DataInterface.REG_SMU_VERSION));

// Load initial temp value + icon
tempTimerHandler(null, null);

Expand Down Expand Up @@ -177,6 +180,12 @@ public NotificationIcon()

notifyIcon.Visible = true;

if ((smuVersionInt <= 2583 && cpuType <= 4)
|| (smuVersionInt <= 4316 && cpuType > 4 && cpuType <= 6))
{
MessageBox.Show("Newer SMU version required. The application will most probably not work correctly. Please use version older than 0.8.0.");
}

MinimizeFootprint();

string[] args = Environment.GetCommandLineArgs();
Expand Down Expand Up @@ -271,7 +280,7 @@ public static void Main(string[] args)
{
Process process = Process.Start(info);
process.WaitForExit(10000);
svc.WaitForStatus(ServiceControllerStatus.Running, System.TimeSpan.FromSeconds(5));
svc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(5));
if (svc.Status != ServiceControllerStatus.Running) throw new Exception("ZenStatesSrv couldn't start.");
}
catch (Exception ex2)
Expand Down Expand Up @@ -350,6 +359,16 @@ private static string getSmuVersionString(UInt64 version)
return String.Join(".", versionString);
}

static int checkSmuVersion(UInt64 version)
{
// UInt64 version = di.MemRead(DataInterface.REG_SMU_VERSION);
int smuMajor = (int)((version & 0x00FF0000) >> 16);
int smuMinor = (int)((version & 0x0000FF00) >> 8);
int smu = smuMajor * 100 + smuMinor;

return smu;
}

void tempTimerHandler(object sender, ElapsedEventArgs e)
{
try
Expand Down Expand Up @@ -396,17 +415,6 @@ void tempTimerHandler(object sender, ElapsedEventArgs e)

ServiceVersion = di.MemRead(DataInterface.REG_SERVER_VERSION);

NotificationIcon.smuVersion = getSmuVersionString(di.MemRead(DataInterface.REG_SMU_VERSION));

NotificationIcon.cpuType = di.MemRead(DataInterface.REG_CPU_TYPE);
NotificationIcon.smuVersionInt = checkSmuVersion();

if ((smuVersionInt <= 2583 && cpuType <= 4)
|| (smuVersionInt <= 4316 && cpuType > 4 && cpuType <= 6))
{
MessageBox.Show("Newer SMU version required. The application will most probably not work correctly. Please use version older than 0.8.0.");
}

if ((di.MemRead(DataInterface.REG_SERVER_FLAGS) & DataInterface.FLAG_IS_AVAILABLE) == 0) isAvailable = false;
else isAvailable = true;

Expand Down Expand Up @@ -554,40 +562,30 @@ void GenTempIcons()
}
}

static int checkSmuVersion()
{
UInt64 version = di.MemRead(DataInterface.REG_SMU_VERSION);
int smuMajor = (int)((version & 0x00FF0000) >> 16);
int smuMinor = (int)((version & 0x0000FF00) >> 8);
int smu = smuMajor * 100 + smuMinor;

return smu;
}

static void initVendorInfo()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
foreach (ManagementObject obj in searcher.Get())
{
NotificationIcon.mbVendor = (string)obj["Manufacturer"];
NotificationIcon.mbName = (string)obj["Product"];
mbVendor = (string)obj["Manufacturer"];
mbName = (string)obj["Product"];
}
if (searcher != null) searcher.Dispose();

searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
foreach (ManagementObject obj in searcher.Get())
{
NotificationIcon.cpuName = (string)obj["Name"];
NotificationIcon.cpuName = NotificationIcon.cpuName.Replace("(R)", "");
NotificationIcon.cpuName = NotificationIcon.cpuName.Replace("(TM)", "");
cpuName = (string)obj["Name"];
cpuName = cpuName.Replace("(R)", "");
cpuName = cpuName.Replace("(TM)", "");
}
if (searcher != null) searcher.Dispose();

searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
foreach (ManagementObject obj in searcher.Get())
{
NotificationIcon.biosVersion = (string)obj["SMBIOSBIOSVersion"];
NotificationIcon.biosVersion = NotificationIcon.biosVersion.Trim();
biosVersion = (string)obj["SMBIOSBIOSVersion"];
biosVersion = biosVersion.Trim();
}
if (searcher != null) searcher.Dispose();
}
Expand Down
8 changes: 4 additions & 4 deletions SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public SettingsForm()

ResetValues();

MessageBox.Show(Convert.ToString(NotificationIcon.smuVersionInt));
//MessageBox.Show(Convert.ToString(NotificationIcon.smuVersionInt));

// if (isZen2)
if ((NotificationIcon.smuVersionInt > 2583 && NotificationIcon.cpuType <= 4)
Expand Down Expand Up @@ -173,6 +173,8 @@ public SettingsForm()
toolTip.SetToolTip(comboBoxPerfenh, "It's currently not working with Zen2 and new AGESA");
toolTip.SetToolTip(checkBoxSmuPL, "It's currently not working with Zen2 and new AGESA");
}

//MessageBox.Show("Cpu Type: " + NotificationIcon.cpuType);
}

public void PopulateAutoControls()
Expand Down Expand Up @@ -650,13 +652,11 @@ void ButtonApplyClick(object sender, EventArgs e)
NotificationIcon.di.MemWrite(DataInterface.REG_TDC, (UInt64)tdc);
NotificationIcon.di.MemWrite(DataInterface.REG_EDC, (UInt64)edc);
NotificationIcon.di.MemWrite(DataInterface.REG_SCALAR, (UInt64)scalar);

NotificationIcon.di.MemWrite(DataInterface.REG_PERF_BIAS, (UInt64)comboBoxPerfbias.SelectedIndex);

NotificationIcon.di.MemWrite(DataInterface.REG_CLIENT_FLAGS, flags);

// Send update flag command
NotificationIcon.Execute(DataInterface.NOTIFY_CLIENT_FLAGS, false);
NotificationIcon.Execute(DataInterface.NOTIFY_CLIENT_FLAGS, true);
}
catch (Exception ex)
{
Expand Down
4 changes: 3 additions & 1 deletion ZenStatesSrv/CPUHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public enum PerfBias { Auto = 0, None, Cinebench_R11p5, Cinebench_R15, Geekbench
public bool ApplyAtStart = false;
public bool P80Temp = false;

public UInt64[] Pstate = new UInt64[CPUHandler.NumPstates];
public UInt64[] Pstate = new UInt64[NumPstates];
public UInt64[] BoostFreq = new UInt64[3];
public UInt64 PstateOc = 0x0;

Expand Down Expand Up @@ -219,6 +219,8 @@ public CPUHandler()
break;
}

//this.cpuType = CPUType.Matisse;

// Get number of threads
this.Threads = Environment.ProcessorCount;

Expand Down
5 changes: 2 additions & 3 deletions ZenStatesSrv/ZenStatesSrv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,16 @@ private static void t1Handler(object source, ElapsedEventArgs e)
break;

case DataInterface.NOTIFY_APPLY:
applySettings();

P80Temp = cpuh.P80Temp;

applySettings();

// Notify done
di.MemWrite(DataInterface.REG_NOTIFY_STATUS, DataInterface.NOTIFY_DONE);

break;

case DataInterface.NOTIFY_SAVE:

cpuh.SaveSettings();

di.MemWrite(DataInterface.REG_NOTIFY_STATUS, DataInterface.NOTIFY_DONE);
Expand Down

0 comments on commit 86b78c7

Please sign in to comment.