Skip to content

Commit

Permalink
Added full fan speed toggle (#875)
Browse files Browse the repository at this point in the history
* Added full fan speed toggle

* Updated the code according to the suggestions

* Changed hidden visibility to collapsed
  • Loading branch information
m33ts4k0z authored Dec 13, 2023
1 parent 980c276 commit 25cc827
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
9 changes: 9 additions & 0 deletions HandheldCompanion/Devices/Lenovo/LegionGo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ public override void SetFanControl(bool enable, int mode = 0)
// do something
}

public void SetFanFullSpeed(bool enabled)
{
// Fan control: Default, Full (0, 1)
ECRAMWrite(0x8A, (byte)(enabled ? 1 : 0));
}

public override void SetFanDuty(double percent)
{
// do something
Expand Down Expand Up @@ -268,6 +274,9 @@ public override void Close()
device.CloseDevice();
}

// Reset the fan speed to default before device shutdown/restart
SetFanFullSpeed(false);

base.Close();
}

Expand Down
18 changes: 18 additions & 0 deletions HandheldCompanion/Properties/Resources.Designer.cs

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

6 changes: 6 additions & 0 deletions HandheldCompanion/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2667,4 +2667,10 @@ with motion input toggle, press selected button(s) to switch from enabled to dis
<data name="Hint_CoreIsolationCheckReadme" xml:space="preserve">
<value>You might want to turn off core isolation and restart your system to enable TDP manipulations</value>
</data>
<data name="DevicePage_FullFanSpeedDesc" xml:space="preserve">
<value>Sets the fan to max speed</value>
</data>
<data name="DevicePage_FullFanSpeedText" xml:space="preserve">
<value>Fan max speed override</value>
</data>
</root>
30 changes: 30 additions & 0 deletions HandheldCompanion/Views/QuickPages/QuickDevicePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,35 @@
</ComboBox>
</Border>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Spacing="6" Name="FullFanSpeedToggler">
<Border
Padding="15,12,12,12"
Background="{DynamicResource ExpanderHeaderBackground}"
CornerRadius="{DynamicResource ControlCornerRadius}">

<Grid>
<DockPanel>
<ui:FontIcon
Height="40"
HorizontalAlignment="Center"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
Glyph="&#xE7BC;" />

<ui:SimpleStackPanel Margin="12,0,0,0" VerticalAlignment="Center">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{x:Static resx:Resources.DevicePage_FullFanSpeedText}" />
<TextBlock
Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Static resx:Resources.DevicePage_FullFanSpeedDesc}"
TextWrapping="Wrap" />
</ui:SimpleStackPanel>
</DockPanel>
</Grid>
</Border>
<ui:ToggleSwitch
Name="Toggle_cFFanSpeed"
Style="{DynamicResource InvertedToggleSwitchStyle}"
Toggled="Toggle_cFFanSpeed_Toggled" Margin="436,-62,0,22" VerticalAlignment="Stretch" />
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
</Page>
14 changes: 13 additions & 1 deletion HandheldCompanion/Views/QuickPages/QuickDevicePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using HandheldCompanion.Managers;
using HandheldCompanion.Devices;
using HandheldCompanion.Managers;
using HandheldCompanion.Platforms;
using Inkore.UI.WPF.Modern.Controls;
using System;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -21,6 +23,7 @@ public QuickDevicePage()
{
InitializeComponent();

FullFanSpeedToggler.Visibility = MainWindow.CurrentDevice is LegionGo ? Visibility.Visible : Visibility.Collapsed;
SettingsManager.SettingValueChanged += SettingsManager_SettingValueChanged;

PlatformManager.RTSS.Updated += RTSS_Updated;
Expand Down Expand Up @@ -89,4 +92,13 @@ private void ComboBoxOverlayDisplayLevel_SelectionChanged(object sender, Selecti

SettingsManager.SetProperty("OnScreenDisplayLevel", ComboBoxOverlayDisplayLevel.SelectedIndex);
}

private void Toggle_cFFanSpeed_Toggled(object sender, RoutedEventArgs e)
{
if (MainWindow.CurrentDevice is LegionGo device)
{
ToggleSwitch toggleSwitch = (ToggleSwitch)sender;
device.SetFanFullSpeed(toggleSwitch.IsOn);
}
}
}

0 comments on commit 25cc827

Please sign in to comment.