Skip to content

Commit

Permalink
CPU power and fan control fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Aug 29, 2024
1 parent 023820e commit bf74b47
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 24 deletions.
4 changes: 2 additions & 2 deletions platforms/interface/ui/pages/onboarding.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<div class="step2 hidden justify-center rounded-2xl bg-black/30 p-10 py-10 shadow-md backdrop-blur-xl">
<div class="flex select-text flex-wrap items-center justify-between gap-10 px-20 sm:w-full sm:px-2 md:flex-nowrap">
<div class="flex w-full flex-col">
<div class="mb-10">
<h1 class="mb-1 bg-gradient-to-r bg-clip-text text-center font-extrabold text-white md:text-8xl">Activate Cores</h1>
<div class="mb-5">
<h1 class="bg-gradient-to-r bg-clip-text text-center font-extrabold text-white">Activate Cores</h1>
</div>

<div class="mt-1 flex flex-row justify-between gap-5 sm:flex-col">
Expand Down
75 changes: 53 additions & 22 deletions platforms/windows/lib/HardwareInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,20 @@ public void GetInfo() {

// CPU Power
for (int j = 0; j < powerSensors.Length; j++) {
var data2 = new Sensor {
Name = powerSensors[j].Name,
Value = (float)Math.Round(powerSensors[j].Value ?? 0),
Min = (float)Math.Round(powerSensors[j].Min ?? 0),
Max = (float)Math.Round(powerSensors[j].Max ?? 0),
};
// CPU power is buggy on wake from sleep
if (powerSensors[j].Max < 2000 && powerSensors[j].Value < 2000) {
var data2 = new Sensor {
Name = powerSensors[j].Name,
Value = (float)Math.Round(powerSensors[j].Value ?? 0),
Min = (float)Math.Round(powerSensors[j].Min ?? 0),
Max = (float)Math.Round(powerSensors[j].Max ?? 0),
};

if (firstRun) {
API.CPU.Power.Add(data2);
} else {
API.CPU.Power[j] = data2;
if (firstRun) {
API.CPU.Power.Add(data2);
} else {
API.CPU.Power[j] = data2;
}
}
}

Expand Down Expand Up @@ -531,6 +534,21 @@ public void GetInfo() {
}
}

for (int j = 0; j < fanControlSensors.Length; j++) {
var data = new Sensor {
Name = fanControlSensors[j].Name,
Value = (float)Math.Round(fanControlSensors[j].Value ?? 0),
Min = (float)Math.Round(fanControlSensors[j].Min ?? 0),
Max = (float)Math.Round(fanControlSensors[j].Max ?? 0),
};

if (firstRun) {
API.System.SuperIO.FanControl.Add(data);
} else {
API.System.SuperIO.FanControl[j] = data;
}
}

for (int j = 0; j < fanSensors.Length; j++) {
var data = new Sensor {
Name = fanSensors[j].Name,
Expand All @@ -544,20 +562,33 @@ public void GetInfo() {
} else {
API.System.SuperIO.Fan[j] = data;
}
}

for (int j = 0; j < fanControlSensors.Length; j++) {
var data = new Sensor {
Name = fanControlSensors[j].Name,
Value = (float)Math.Round(fanControlSensors[j].Value ?? 0),
Min = (float)Math.Round(fanControlSensors[j].Min ?? 0),
Max = (float)Math.Round(fanControlSensors[j].Max ?? 0),
};
try {
if (fanSensors[j].Value != 0 && fanControlSensors[j].Value == null) {
var maxRPM = 2000;

if (firstRun) {
API.System.SuperIO.FanControl.Add(data);
} else {
API.System.SuperIO.FanControl[j] = data;
if (j == 0) {
maxRPM = 1700;
} else if (j == 1) {
maxRPM = 2500;
}

var data2 = new Sensor {
Name = fanSensors[j].Name,
Value = (float)Math.Round(fanSensors[j].Value / maxRPM * 100 ?? 0),
Min = (float)Math.Round(fanSensors[j].Min / maxRPM * 100 ?? 0),
Max = (float)Math.Round(fanSensors[j].Max / maxRPM * 100 ?? 0),
};

if (firstRun) {
API.System.SuperIO.FanControl.Add(data2);
} else {
API.System.SuperIO.FanControl[j] = data2;
}
}
}
catch (Exception) {
Log.Error("Failed to calculate fan speed");
}
}
}
Expand Down

0 comments on commit bf74b47

Please sign in to comment.