1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 01:56:14 +01:00

0.0.7 Ready for testing

This commit is contained in:
peteGSX 2023-04-11 08:55:04 +10:00
parent 1aae0aed0a
commit 6199cecd42

View File

@ -89,11 +89,11 @@ $displayList = @(
}, },
@{ @{
option = "OLED 128 x 32" option = "OLED 128 x 32"
configLine = "#define OLED_DRIVER 128,32,0x3c" configLine = "#define OLED_DRIVER 128,32"
}, },
@{ @{
option = "OLED 128 x 64" option = "OLED 128 x 64"
configLine = "#define OLED_DRIVER 128,64,0x3c" configLine = "#define OLED_DRIVER 128,64"
} }
) )
@ -102,8 +102,12 @@ Basics of config.h
############################################> ############################################>
$configLines = @( $configLines = @(
"/*", "/*",
"This config.h file was generated by the DCC-EX PowerShell installer $version", "This config.h file was generated by the DCC-EX PowerShell installer $installerVersion",
"*/`r`n" "*/",
"",
"// Define standard motor shield",
"#define MOTOR_SHIELD_TYPE STANDARD_MOTOR_SHIELD",
""
) )
<############################################ <############################################
@ -148,8 +152,6 @@ Prompt user to confirm all is ready to proceed
$confirmation = Read-Host "Enter 'Y' or 'y' then press <Enter> to confirm you are ready to proceed, any other key to exit" $confirmation = Read-Host "Enter 'Y' or 'y' then press <Enter> to confirm you are ready to proceed, any other key to exit"
if ($confirmation -ne "Y" -and $confirmation -ne "y") { if ($confirmation -ne "Y" -and $confirmation -ne "y") {
Exit Exit
} else {
Write-Output "Proceeding to obtain the Arduino CLI..."
} }
<############################################ <############################################
@ -165,7 +167,7 @@ if (!(Test-Path -PathType Leaf -Path $arduinoCLI)) {
Exit Exit
} }
} }
Write-Output "Downloading and extracting Arduino CLI" Write-Output "`r`nDownloading and extracting Arduino CLI"
try { try {
Invoke-WebRequest -Uri $arduinoCLIURL -OutFile $arduinoCLIZip Invoke-WebRequest -Uri $arduinoCLIURL -OutFile $arduinoCLIZip
} }
@ -179,6 +181,8 @@ if (!(Test-Path -PathType Leaf -Path $arduinoCLI)) {
catch { catch {
Write-Output "Failed to extract Arduino CLI" Write-Output "Failed to extract Arduino CLI"
} }
} else {
Write-Output "`r`nArduino CLI already downloaded, ensuring it is up to date and you have a board connected"
} }
<############################################ <############################################
@ -424,7 +428,7 @@ if ($PSBoundParameters.ContainsKey('configDirectory')) {
} else { } else {
<############################################ <############################################
If no config directory provided, prompt for display option, and WiFi if using Mega If no config directory provided, prompt for display option
############################################> ############################################>
Write-Output "`r`nIf you have an LCD or OLED display connected, you can configure it here`r`n" Write-Output "`r`nIf you have an LCD or OLED display connected, you can configure it here`r`n"
$displaySelect = 1 $displaySelect = 1
@ -441,25 +445,49 @@ If no config directory provided, prompt for display option, and WiFi if using Me
) )
if ($displayChoice -eq ($displayList.Count + 2)) { if ($displayChoice -eq ($displayList.Count + 2)) {
Exit Exit
} elseif ($displayChoice -le 1 -and ($displayList.Count + 1)) { } elseif ($displayChoice -le ($displayList.Count)) {
$configLines.Add("// Display configuration") $configLines+= "// Display configuration"
$configLines.Add($displayList[$displayChoice - 1].configLine) $configLines+= "$($displayList[$displayChoice - 1].configLine)"
$configLines.Add("#define SCROLLMODE 1 // Alternate between pages") $configLines+= "#define SCROLLMODE 1 // Alternate between pages"
} }
<############################################
If device supports WiFi, prompt to configure
############################################>
if ($wifiBoards.Contains($deviceFQBN)) { if ($wifiBoards.Contains($deviceFQBN)) {
# WiFi prompt Write-Output "`r`nYour chosen board supports WiFi`r`n"
Write-Output "1 - I don't want WiFi, skip this step
2 - Configure my device as an access point I will connect to directly
3 - Configure my device to connect to my home WiFi network
4 - Exit"
do {
[int]$wifiChoice = Read-Host "`r`nSelect a WiFi option"
} until (
($wifiChoice -ge 1 -and $wifiChoice -le 4)
)
if ($wifiChoice -eq 4) {
Exit
} elseif ($wifiChoice -ne 1) {
$configLines+= ""
$configLines+= "// WiFi configuration"
$configLines+= "#define ENABLE_WIFI true"
$configLines+= "#define IP_PORT 2560"
$configLines+= "#define WIFI_HOSTNAME ""dccex"""
$configLines+= "#define WIFI_CHANNEL 1"
if ($wifiChoice -eq 3) {
$wifiSSID = Read-Host "Please enter the SSID of your home network here"
$wifiPassword = Read-Host "Please enter your home network WiFi password here"
$configLines+= "#define WIFI_SSID ""$($wifiSSID)"""
$configLines+= "#define WIFI_PASSWORD ""$($wifiPassword)"""
}
}
} }
<############################################ <############################################
Write out config.h to a file here only if config directory not provided Write out config.h to a file here only if config directory not provided
############################################> ############################################>
$configH = $commandStationDirectory + "\config.h" $configH = $commandStationDirectory + "\config.h"
foreach ($line in $configLines) {
Write-Output $line
}
Pause
try { try {
$configLines | Out-File -FilePath $configH $configLines | Out-File -FilePath $configH -Encoding ascii
} }
catch { catch {
Write-Output "Error writing config file to $configH" Write-Output "Error writing config file to $configH"