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:
parent
1d46664233
commit
ef0dbdd1f9
|
@ -4,3 +4,6 @@
|
||||||
[submodule "support/bme280"]
|
[submodule "support/bme280"]
|
||||||
path = support/bme280
|
path = support/bme280
|
||||||
url = https://github.com/catdog2/mpy_bme280_esp8266
|
url = https://github.com/catdog2/mpy_bme280_esp8266
|
||||||
|
[submodule "support/ws-epaper"]
|
||||||
|
path = support/ws-epaper
|
||||||
|
url = https://github.com/mcauser/micropython-waveshare-epaper
|
||||||
|
|
21
flash.ps1
21
flash.ps1
|
@ -2,6 +2,7 @@ param(
|
||||||
[String]$COMPort,
|
[String]$COMPort,
|
||||||
[switch]$Extras,
|
[switch]$Extras,
|
||||||
[switch]$ResetAfterFlash,
|
[switch]$ResetAfterFlash,
|
||||||
|
[switch]$Verbose,
|
||||||
[String[]]$Libs
|
[String[]]$Libs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ Function Find-LibraryFile {
|
||||||
[String]$Library,
|
[String]$Library,
|
||||||
[String]$SearchPath = $(Get-Location)
|
[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 {
|
Function Write-AmpyFile {
|
||||||
|
@ -23,6 +24,7 @@ Function Write-AmpyFile {
|
||||||
If ((Get-Command -Name ampy -ErrorAction SilentlyContinue) -eq $false) {
|
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-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
|
ampy -p $COMPort put $Filename
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +36,7 @@ Function Reset-AmpyDevice {
|
||||||
If ((Get-Command -Name ampy -ErrorAction SilentlyContinue) -eq $false) {
|
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-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
|
ampy -p $COMPort reset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,24 +54,24 @@ $CfgFiles = (
|
||||||
)
|
)
|
||||||
|
|
||||||
$BaseFiles | % {
|
$BaseFiles | % {
|
||||||
$Lib = Find-LibraryFile -Library $_
|
$Lib = Find-LibraryFile -Library $_ -Verbose:$Verbose
|
||||||
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
|
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort -Verbose:$Verbose
|
||||||
}
|
}
|
||||||
$CfgFiles | % {
|
$CfgFiles | % {
|
||||||
If (Get-ChildItem "$_.py" -ErrorAction SilentlyContinue) {
|
If (Get-ChildItem "$_.py" -ErrorAction SilentlyContinue) {
|
||||||
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort
|
Write-AmpyFile -Filename "$_.py" -COMPort $COMPort -Verbose:$Verbose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
If ($Extras) {
|
If ($Extras) {
|
||||||
$ExtraFiles | % {
|
$ExtraFiles | % {
|
||||||
$Lib = Find-LibraryFile -Library $_
|
$Lib = Find-LibraryFile -Library $_ -Verbose:$Verbose
|
||||||
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
|
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort -Verbose:$Verbose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
If ($Libs.Count -gt 0) {
|
If ($Libs.Count -gt 0) {
|
||||||
$Libs | % {
|
$Libs | % {
|
||||||
$Lib = Find-LibraryFile -Library $_
|
$Lib = Find-LibraryFile -Library $_ -Verbose:$Verbose
|
||||||
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort
|
Write-AmpyFile -Filename "$Lib" -COMPort $COMPort -Verbose:$Verbose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
If ($ResetAfterFlash) { Reset-AmpyDevice -COMPort $COMPort }
|
If ($ResetAfterFlash) { Reset-AmpyDevice -COMPort $COMPort -Verbose:$Verbose }
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 86759f43f126c6fd2bf125b10a30c742742b943b
|
Loading…
Reference in New Issue