Enable fan curves

This commit is contained in:
Luke D. Jones
2024-03-14 17:17:55 +13:00
parent f6ad631a0f
commit 6b0edc6da1
8 changed files with 327 additions and 96 deletions

View File

@@ -5,7 +5,7 @@ import { Profile, FanType, FanPageData } from "../types/fan_types.slint";
component FanTab inherits Rectangle {
in-out property <bool> enabled: false;
in-out property <bool> tab_enabled: false;
in-out property <bool> tab_enabled: true;
in property <Profile> profile;
in property <FanType> fan_type;
callback apply();
@@ -15,22 +15,17 @@ component FanTab inherits Rectangle {
in property <string> title;
in-out property <[Node]> nodes;
if !root.tab_enabled: VerticalLayout {
alignment: center;
HorizontalLayout {
alignment: center;
Text {
font-size: 24px;
text: "WIP: Not enabled yet";
}
}
}
VerticalLayout {
HorizontalLayout {
Graph {
if root.tab_enabled: Graph {
nodes <=> root.nodes;
}
if !root.tab_enabled: Rectangle {
Text {
font-size: 24px;
text: @tr("This fan is not avilable on this machine");
}
}
}
HorizontalLayout {
@@ -61,7 +56,7 @@ component FanTab inherits Rectangle {
}
Button {
text: @tr("Factory Default");
text: @tr("Factory Default (all fans)");
enabled <=> root.tab_enabled;
clicked => {
root.default();
@@ -79,21 +74,54 @@ export component PageFans inherits VerticalLayout {
Tab {
title: @tr("CPU");
FanTab {
tab_enabled <=> FanPageData.cpu_fan_available;
enabled <=> FanPageData.balanced_cpu_enabled;
nodes <=> FanPageData.balanced_cpu;
apply => {
FanPageData.set_fan_data(FanType.CPU, Profile.Balanced, self.enabled, FanPageData.balanced_cpu);
}
toggled => {
FanPageData.set_fan_data(FanType.CPU, Profile.Balanced, self.enabled, FanPageData.balanced_cpu);
}
default => {
FanPageData.set_profile_default(Profile.Balanced);
}
}
}
Tab {
title: @tr("Mid");
FanTab {
tab_enabled <=> FanPageData.mid_fan_available;
enabled <=> FanPageData.balanced_mid_enabled;
nodes <=> FanPageData.balanced_mid;
apply => {
FanPageData.set_fan_data(FanType.Middle, Profile.Balanced, self.enabled, FanPageData.balanced_mid);
}
toggled => {
FanPageData.set_fan_data(FanType.Middle, Profile.Balanced, self.enabled, FanPageData.balanced_mid);
}
default => {
FanPageData.set_profile_default(Profile.Balanced);
}
}
}
Tab {
title: @tr("GPU");
FanTab {
tab_enabled <=> FanPageData.gpu_fan_available;
enabled <=> FanPageData.balanced_gpu_enabled;
nodes <=> FanPageData.balanced_gpu;
apply => {
FanPageData.set_fan_data(FanType.GPU, Profile.Balanced, self.enabled, FanPageData.balanced_gpu);
}
toggled => {
FanPageData.set_fan_data(FanType.GPU, Profile.Balanced, self.enabled, FanPageData.balanced_gpu);
}
default => {
FanPageData.set_profile_default(Profile.Balanced);
}
}
}
}
@@ -105,21 +133,54 @@ export component PageFans inherits VerticalLayout {
Tab {
title: @tr("CPU");
FanTab {
tab_enabled <=> FanPageData.cpu_fan_available;
enabled <=> FanPageData.performance_cpu_enabled;
nodes <=> FanPageData.performance_cpu;
apply => {
FanPageData.set_fan_data(FanType.CPU, Profile.Performance, self.enabled, FanPageData.performance_cpu);
}
toggled => {
FanPageData.set_fan_data(FanType.CPU, Profile.Performance, self.enabled, FanPageData.performance_cpu);
}
default => {
FanPageData.set_profile_default(Profile.Performance);
}
}
}
Tab {
title: @tr("Mid");
FanTab {
tab_enabled <=> FanPageData.mid_fan_available;
enabled <=> FanPageData.performance_mid_enabled;
nodes <=> FanPageData.performance_mid;
apply => {
FanPageData.set_fan_data(FanType.Middle, Profile.Performance, self.enabled, FanPageData.performance_mid);
}
toggled => {
FanPageData.set_fan_data(FanType.Middle, Profile.Performance, self.enabled, FanPageData.performance_mid);
}
default => {
FanPageData.set_profile_default(Profile.Performance);
}
}
}
Tab {
title: @tr("GPU");
FanTab {
tab_enabled <=> FanPageData.gpu_fan_available;
enabled <=> FanPageData.performance_gpu_enabled;
nodes <=> FanPageData.performance_gpu;
apply => {
FanPageData.set_fan_data(FanType.GPU, Profile.Performance, self.enabled, FanPageData.performance_gpu);
}
toggled => {
FanPageData.set_fan_data(FanType.GPU, Profile.Performance, self.enabled, FanPageData.performance_gpu);
}
default => {
FanPageData.set_profile_default(Profile.Performance);
}
}
}
}
@@ -131,21 +192,54 @@ export component PageFans inherits VerticalLayout {
Tab {
title: @tr("CPU");
FanTab {
tab_enabled <=> FanPageData.cpu_fan_available;
enabled <=> FanPageData.quiet_cpu_enabled;
nodes <=> FanPageData.quiet_cpu;
apply => {
FanPageData.set_fan_data(FanType.CPU, Profile.Quiet, self.enabled, FanPageData.quiet_cpu);
}
toggled => {
FanPageData.set_fan_data(FanType.CPU, Profile.Quiet, self.enabled, FanPageData.quiet_cpu);
}
default => {
FanPageData.set_profile_default(Profile.Quiet);
}
}
}
Tab {
title: @tr("Mid");
FanTab {
tab_enabled <=> FanPageData.mid_fan_available;
enabled <=> FanPageData.quiet_mid_enabled;
nodes <=> FanPageData.quiet_mid;
apply => {
FanPageData.set_fan_data(FanType.Middle, Profile.Quiet, self.enabled, FanPageData.quiet_mid);
}
toggled => {
FanPageData.set_fan_data(FanType.Middle, Profile.Quiet, self.enabled, FanPageData.quiet_mid);
}
default => {
FanPageData.set_profile_default(Profile.Quiet);
}
}
}
Tab {
title: @tr("GPU");
FanTab {
tab_enabled <=> FanPageData.gpu_fan_available;
enabled <=> FanPageData.quiet_gpu_enabled;
nodes <=> FanPageData.quiet_gpu;
apply => {
FanPageData.set_fan_data(FanType.GPU, Profile.Quiet, self.enabled, FanPageData.quiet_gpu);
}
toggled => {
FanPageData.set_fan_data(FanType.GPU, Profile.Quiet, self.enabled, FanPageData.quiet_gpu);
}
default => {
FanPageData.set_profile_default(Profile.Quiet);
}
}
}
}

View File

@@ -16,15 +16,25 @@ export global FanPageData {
in-out property <[Profile]> available_profiles: [Profile.Balanced, Profile.Performance, Profile.Quiet];
in-out property <[FanType]> available_fans: [FanType.CPU, FanType.Middle, FanType.GPU];
in-out property <bool> balanced_cpu_available: true;
in-out property <bool> balanced_gpu_available: true;
in-out property <bool> balanced_mid_available: false;
in-out property <bool> performance_cpu_available: true;
in-out property <bool> performance_gpu_available: true;
in-out property <bool> performance_mid_available: false;
in-out property <bool> quiet_cpu_available: true;
in-out property <bool> quiet_gpu_available: true;
in-out property <bool> quiet_mid_available: false;
in-out property <bool> cpu_fan_available: true;
in-out property <bool> gpu_fan_available: true;
in-out property <bool> mid_fan_available: false;
in-out property <bool> balanced_available: true;
in-out property <bool> performance_available: true;
in-out property <bool> quiet_available: false;
in-out property <bool> balanced_cpu_enabled: true;
in-out property <bool> balanced_gpu_enabled: true;
in-out property <bool> balanced_mid_enabled: false;
in-out property <bool> performance_cpu_enabled: true;
in-out property <bool> performance_gpu_enabled: true;
in-out property <bool> performance_mid_enabled: false;
in-out property <bool> quiet_cpu_enabled: true;
in-out property <bool> quiet_gpu_enabled: true;
in-out property <bool> quiet_mid_enabled: false;
callback set_fan_data(FanType, Profile, bool, [Node]);
callback set_profile_default(Profile);
in-out property <[Node]> balanced_cpu: [
{