File tree 4 files changed +19
-8
lines changed
Examples/Microsoft.PowerShell.IoT.Fan
4 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 11
11
FunctionsToExport = @ (' Enable-Fan' , ' Disable-Fan' )
12
12
CmdletsToExport = @ ()
13
13
AliasesToExport = @ ()
14
- NestedModules = @ (' Microsoft.PowerShell.IoT' , ' Microsoft.PowerShell.IoT.Fan.psm1' )
14
+ RootModule = ' Microsoft.PowerShell.IoT.Fan.psm1'
15
+ NestedModules = @ (' Microsoft.PowerShell.IoT' )
15
16
HelpInfoURI = ' https://github.com/PowerShell/PowerShell-IoT'
16
17
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
17
18
PrivateData = @ {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function Enable-Fan
5
5
(
6
6
[Parameter (Mandatory = $true , Position = 0 )]
7
7
[ValidateNotNullOrEmpty ()]
8
- [int ] $Pin = 17
8
+ [int ] $Pin
9
9
)
10
10
11
11
Set-GpioPin - Id $Pin - Value High
@@ -18,7 +18,7 @@ function Disable-Fan
18
18
(
19
19
[Parameter (Mandatory = $true , Position = 0 )]
20
20
[ValidateNotNullOrEmpty ()]
21
- [int ] $Pin = 17
21
+ [int ] $Pin
22
22
)
23
23
24
24
Set-GpioPin - Id $Pin - Value Low
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ Installation instructions can be found [here](https://github.com/PowerShell/Powe
26
26
### Start Powershell and install modules
27
27
28
28
``` powershell
29
- sudo pwsh
29
+ pwsh
30
30
31
31
Install-Module -Name Microsoft.PowerShell.IoT
32
32
@@ -37,7 +37,7 @@ git clone https://github.com/PowerShell/PowerShell-IoT.git
37
37
38
38
``` powershell
39
39
# Start monitoring CPU temperature and turn on the fan when it reaches 71 degrees; turn fan off when CPU temperature drops below 55 degrees
40
- pwsh ./PowerShell-IoT/Examples/Microsoft.PowerShell.IoT.Fan/SmartFan.ps1 -OnTemperatureC 71 -OffTemperatureC 55 -Pin 17
40
+ pwsh ./PowerShell-IoT/Examples/Microsoft.PowerShell.IoT.Fan/SmartFan.ps1 -Pin 17 -OnTemperature 71 -OffTemperature 55 -TemperatureScale Celsius
41
41
VERBOSE: 1:36:05 PM: CPU temperature = 71.575 C | 160.835 F
42
42
VERBOSE: Starting fan...
43
43
VERBOSE: 1:36:10 PM: CPU temperature = 70.601 C | 159.0818 F
Original file line number Diff line number Diff line change 1
1
param
2
2
(
3
3
[int ] $Pin = 17 ,
4
- [int ] $OnTemperatureC = 70 ,
5
- [int ] $OffTemperatureC = 50 ,
4
+ [int ] $OnTemperature = 70 ,
5
+ [int ] $OffTemperature = 50 ,
6
+ [ValidateSet (" Fahrenheit" , " Celsius" )]
7
+ [string ]$TemperatureScale = " Celsius" ,
6
8
[int ] $PollPeriodSeconds = 5
7
9
)
8
10
9
11
Import-Module $PSScriptRoot / Microsoft.PowerShell.IoT.Fan.psd1
10
12
13
+ $OnTemperatureC = $OnTemperature
14
+ $OffTemperatureC = $OffTemperature
15
+ if ($TemperatureScale -eq " Fahrenheit" )
16
+ {
17
+ $OnTemperatureC = ($OnTemperature - 32 ) * 5 / 9
18
+ $OffTemperatureC = ($OffTemperature - 32 ) * 5 / 9
19
+ }
20
+
11
21
while ($true )
12
22
{
13
23
$CpuTemperatureC = (Get-Content / sys/ class/ thermal/ thermal_zone0/ temp) / 1000
@@ -27,4 +37,4 @@ while($true)
27
37
}
28
38
29
39
Start-Sleep - Seconds $PollPeriodSeconds
30
- }
40
+ }
You can’t perform that action at this time.
0 commit comments