Skip to content

Commit 030f3d0

Browse files
author
Andrew
committed
feedback
1 parent 4268315 commit 030f3d0

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

Examples/Microsoft.PowerShell.IoT.Fan/Microsoft.PowerShell.IoT.Fan.psd1

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
FunctionsToExport = @('Enable-Fan','Disable-Fan')
1212
CmdletsToExport = @()
1313
AliasesToExport = @()
14-
NestedModules=@('Microsoft.PowerShell.IoT','Microsoft.PowerShell.IoT.Fan.psm1')
14+
RootModule = 'Microsoft.PowerShell.IoT.Fan.psm1'
15+
NestedModules=@('Microsoft.PowerShell.IoT')
1516
HelpInfoURI = 'https://github.com/PowerShell/PowerShell-IoT'
1617
# 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.
1718
PrivateData = @{

Examples/Microsoft.PowerShell.IoT.Fan/Microsoft.PowerShell.IoT.Fan.psm1

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function Enable-Fan
55
(
66
[Parameter(Mandatory=$true, Position=0)]
77
[ValidateNotNullOrEmpty()]
8-
[int] $Pin = 17
8+
[int] $Pin
99
)
1010

1111
Set-GpioPin -Id $Pin -Value High
@@ -18,7 +18,7 @@ function Disable-Fan
1818
(
1919
[Parameter(Mandatory=$true, Position=0)]
2020
[ValidateNotNullOrEmpty()]
21-
[int] $Pin = 17
21+
[int] $Pin
2222
)
2323

2424
Set-GpioPin -Id $Pin -Value Low

Examples/Microsoft.PowerShell.IoT.Fan/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Installation instructions can be found [here](https://github.com/PowerShell/Powe
2626
### Start Powershell and install modules
2727

2828
```powershell
29-
sudo pwsh
29+
pwsh
3030
3131
Install-Module -Name Microsoft.PowerShell.IoT
3232
@@ -37,7 +37,7 @@ git clone https://github.com/PowerShell/PowerShell-IoT.git
3737

3838
```powershell
3939
# 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
4141
VERBOSE: 1:36:05 PM: CPU temperature = 71.575 C | 160.835 F
4242
VERBOSE: Starting fan...
4343
VERBOSE: 1:36:10 PM: CPU temperature = 70.601 C | 159.0818 F

Examples/Microsoft.PowerShell.IoT.Fan/SmartFan.ps1

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
param
22
(
33
[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",
68
[int] $PollPeriodSeconds = 5
79
)
810

911
Import-Module $PSScriptRoot/Microsoft.PowerShell.IoT.Fan.psd1
1012

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+
1121
while($true)
1222
{
1323
$CpuTemperatureC = (Get-Content /sys/class/thermal/thermal_zone0/temp) / 1000
@@ -27,4 +37,4 @@ while($true)
2737
}
2838

2939
Start-Sleep -Seconds $PollPeriodSeconds
30-
}
40+
}

0 commit comments

Comments
 (0)