Fixed flash.ps1 to work outside of Windows Powershell - for some reason Get-ChildItem returns an object with all attributes unpopulated but present

This commit is contained in:
Maff 2018-06-25 23:30:36 +01:00
parent 1d46664233
commit ef0dbdd1f9
3 changed files with 16 additions and 9 deletions

3
.gitmodules vendored
View File

@ -4,3 +4,6 @@
[submodule "support/bme280"]
path = support/bme280
url = https://github.com/catdog2/mpy_bme280_esp8266
[submodule "support/ws-epaper"]
path = support/ws-epaper
url = https://github.com/mcauser/micropython-waveshare-epaper

View File

@ -2,6 +2,7 @@ param(
[String]$COMPort,
[switch]$Extras,
[switch]$ResetAfterFlash,
[switch]$Verbose,
[String[]]$Libs
)
@ -11,7 +12,7 @@ Function Find-LibraryFile {
[String]$Library,
[String]$SearchPath = $(Get-Location)
)
return (Get-ChildItem -Path $SearchPath -Recurse -Name "$Library.py").FullName
return (Get-ChildItem -Path $SearchPath -Recurse -Verbose:$Verbose -Name "$Library.py"|Convert-Path -Verbose:$Verbose)
}
Function Write-AmpyFile {
@ -23,6 +24,7 @@ Function Write-AmpyFile {
If ((Get-Command -Name ampy -ErrorAction SilentlyContinue) -eq $false) {
Write-Error -Message "Couldn't locate ``ampy`` in environment paths - please run ``pip install adafruit-ampy``." -ErrorAction Stop
}
Write-Verbose "Writing $Filename to port $COMPort" -Verbose:$Verbose
ampy -p $COMPort put $Filename
}
@ -34,6 +36,7 @@ Function Reset-AmpyDevice {
If ((Get-Command -Name ampy -ErrorAction SilentlyContinue) -eq $false) {
Write-Error -Message "Couldn't locate ``ampy`` in environment paths - please run ``pip install adafruit-ampy``." -ErrorAction Stop
}
Write-Verbose "Resetting port $COMPort" -Verbose:$Verbose
ampy -p $COMPort reset
}
@ -51,24 +54,24 @@ $CfgFiles = (
)
$BaseFiles | % {
$Lib = Find-LibraryFile -Library $_
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
$Lib = Find-LibraryFile -Library $_ -Verbose:$Verbose
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort -Verbose:$Verbose
}
$CfgFiles | % {
If (Get-ChildItem "$_.py" -ErrorAction SilentlyContinue) {
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort -Verbose:$Verbose
}
}
If ($Extras) {
$ExtraFiles | % {
$Lib = Find-LibraryFile -Library $_
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
$Lib = Find-LibraryFile -Library $_ -Verbose:$Verbose
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort -Verbose:$Verbose
}
}
If ($Libs.Count -gt 0) {
$Libs | % {
$Lib = Find-LibraryFile -Library $_
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
$Lib = Find-LibraryFile -Library $_ -Verbose:$Verbose
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort -Verbose:$Verbose
}
}
If ($ResetAfterFlash) { Reset-AmpyDevice -COMPort $COMPort }
If ($ResetAfterFlash) { Reset-AmpyDevice -COMPort $COMPort -Verbose:$Verbose }

1
support/ws-epaper Submodule

@ -0,0 +1 @@
Subproject commit 86759f43f126c6fd2bf125b10a30c742742b943b