Skip to content

Commit

Permalink
Add slowest state.
Browse files Browse the repository at this point in the history
  • Loading branch information
t-miyake committed Aug 17, 2017
1 parent 58f34ce commit c556c79
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 21 deletions.
13 changes: 7 additions & 6 deletions PocketFanController/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PocketFanController"
mc:Ignorable="d"
Title="Pocket Fan Controller" Height="105" Width="310" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen">
Title="Pocket Fan Controller" Height="100" Width="352" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen">
<Window.DataContext>
<local:ViewModel />
</Window.DataContext>
<StackPanel>
<Label x:Name="CurrentStatus" Content="{Binding CurrentStateText,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"/>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" HorizontalAlignment="Center">
<Button x:Name="SetDefault" Content="Auto (Default)" HorizontalAlignment="Left" VerticalAlignment="Center" Width="100" Command="{Binding SetDefault}" Margin="0,0,5,0" />
<Button x:Name="SetLow" Content="Slow" HorizontalAlignment="Left" VerticalAlignment="Center" Width="45" Command="{Binding SetLow}" Margin="10,0"/>
<Button x:Name="SetMiddle" Content="Fast" HorizontalAlignment="Left" VerticalAlignment="Center" Width="45" Command="{Binding SetMiddle}"/>
<Button x:Name="SetFast" Content="Fastest" HorizontalAlignment="Left" VerticalAlignment="Center" Width="45" Command="{Binding SetFast}" Margin="10,0,0,0"/>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0" HorizontalAlignment="Left">
<Button x:Name="SetDefault" Content="Auto (Default)" HorizontalAlignment="Left" VerticalAlignment="Center" Width="100" Command="{Binding SetDefault}" Margin="5,0,10,0" HorizontalContentAlignment="Center" />
<Button x:Name="SetSlowest" Content="Slowest" HorizontalAlignment="Left" VerticalAlignment="Center" Width="45" Command="{Binding SetSlowest}" Margin="5,0"/>
<Button x:Name="SetSlow" Content="Slow" HorizontalAlignment="Left" VerticalAlignment="Center" Width="45" Command="{Binding SetSlow}" Margin="5,0"/>
<Button x:Name="SetFast" Content="Fast" HorizontalAlignment="Left" VerticalAlignment="Center" Width="45" Command="{Binding SetFast}" Margin="5,0"/>
<Button x:Name="SetFastest" Content="Fastest" HorizontalAlignment="Left" VerticalAlignment="Center" Width="45" Command="{Binding SetFastest}" Margin="5,0,0,0"/>
</StackPanel>
</StackPanel>
</Window>
19 changes: 15 additions & 4 deletions PocketFanController/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public void GetCurrentStatus()
var state1 = new[] {99, 99, 10};
var state2 = new[] {99, 10, 99};
var state3 = new[] {10, 99, 99};
var states = new[] {state0, state1, state2, state3};
var state4 = new[] {99, 99, 80};
var states = new[] {state0, state1, state2, state3,state4};

var t0 = ReadReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t0");
var t1 = ReadReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t1");
Expand All @@ -43,30 +44,40 @@ public void SetDefault()
RestartService();
}

public void SetLow()
public void SetSlow()
{
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t0", 10);
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t1", 99);
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t2", 99);
RestartService();
}

public void SetMiddle()
public void SetFast()
{
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t0", 99);
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t1", 10);
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t2", 99);
RestartService();
}

public void SetFast()
public void SetFastest()
{
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t0", 99);
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t1", 99);
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t2", 10);
RestartService();
}

public void SetSlowest()
{
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t0", 99);
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t1", 99);
//熱くなりすぎたらファンを全開にする。
WriteReg(@"SYSTEM\CurrentControlSet\Services\wfan0109", "t2", 85);
RestartService();
}


public void WriteReg(string subKey, string keyName, int value)
{
var key = Registry.LocalMachine.CreateSubKey(subKey);
Expand Down
4 changes: 2 additions & 2 deletions PocketFanController/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: NeutralResourcesLanguage("en")]

25 changes: 17 additions & 8 deletions PocketFanController/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ public class ViewModel:ViewModelBase
private Model Model = Model.Instance;

public ICommand SetDefault { get; }
public ICommand SetLow { get; }
public ICommand SetMiddle { get; }
public ICommand SetSlow { get; }
public ICommand SetFast { get; }
public ICommand SetFastest { get; }
public ICommand SetSlowest { get; }

public ViewModel()
{
Expand All @@ -19,24 +20,30 @@ public ViewModel()
CurrentState = 0;
});

SetLow = new RelayCommand(() =>
SetSlow = new RelayCommand(() =>
{
Model.SetLow();
Model.SetSlow();
CurrentState = 3;
});

SetMiddle = new RelayCommand(() =>
SetFast = new RelayCommand(() =>
{
Model.SetMiddle();
Model.SetFast();
CurrentState = 2;
});

SetFast = new RelayCommand(() =>
SetFastest = new RelayCommand(() =>
{
Model.SetFast();
Model.SetFastest();
CurrentState = 1;
});

SetSlowest = new RelayCommand(() =>
{
Model.SetSlowest();
CurrentState = 4;
});

Model.GetCurrentStatus();
}

Expand Down Expand Up @@ -64,6 +71,8 @@ public string CurrentStateText
return "Current status : Fast";
case 3:
return "Current status : Slow";
case 4:
return "Current status : Slowest";
default:
return "Current status : Auto (Default)";
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Pocket Fan Controller

Manually set the fan speed of "GPD Pocket".
It can be set in 3 stages.
It can be set in 4 stages.
For safety reasons, it returns to the default (automatic) at the end of the application.

In the unlikely event the hardware may break down.
Expand Down
Binary file modified Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c556c79

Please sign in to comment.