From 1aae0aed0af18207204987bce46bf21cca09605e Mon Sep 17 00:00:00 2001 From: peteGSX Date: Tue, 11 Apr 2023 05:31:44 +1000 Subject: [PATCH] Working on config output --- installer.ps1 | 64 +++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/installer.ps1 b/installer.ps1 index 56eeec0..e1cd44a 100644 --- a/installer.ps1 +++ b/installer.ps1 @@ -76,7 +76,7 @@ $supportedDevices = @( ) <############################################ -List of supported displays and scroll modes +List of supported displays ############################################> $displayList = @( @{ @@ -97,19 +97,13 @@ $displayList = @( } ) -$scrollList = @( - @{ - mode = "Continuous - fill screen if possible" - configLine = "#define SCROLLMODE 0" - }, - @{ - mode = "Page (default) - alternate between pages" - configLine = "#define SCROLLMODE 1" - }, - @{ - mode = "Row - move up one row at a time" - configLine = "#define SCROLLMODE 2" - } +<############################################ +Basics of config.h +############################################> +$configLines = @( + "/*", + "This config.h file was generated by the DCC-EX PowerShell installer $version", + "*/`r`n" ) <############################################ @@ -447,37 +441,31 @@ If no config directory provided, prompt for display option, and WiFi if using Me ) if ($displayChoice -eq ($displayList.Count + 2)) { Exit - } elseif ($displayChoice -le ($displayList.Count + 1)) { - $displayLine = $displayList[$displayChoice - 1].configLine - $scrollSelect = 1 - $defaultScroll = 1 - Write-Host "`r`n Select a scroll option, or press to accept the default [$($defaultScroll)]" - foreach ($scroll in $scrollList) { - Write-Output "$scrollSelect - $($scrollList[$scrollSelect - 1].mode)" - $scrollSelect++ - } - Write-Output "$($scrollList.Count + 1) - Exit" - do { - [int]$displayScroll = Read-Host "`r`n Select a scroll option, or press to accept the default [$($defaultScroll)]" - } until ( - (($displayScroll -ge 1 -and $displayScroll -le ($scrollList.Count + 1)) -or $displayScroll -eq "") - ) - if ($displayScroll -eq ($scrollList.Count + 1)) { - Exit - } elseif ($displayScroll -eq "") { - $displayScroll = $defaultScroll - } - $scrollLine = $scrollList[$displayScroll - 1] + } elseif ($displayChoice -le 1 -and ($displayList.Count + 1)) { + $configLines.Add("// Display configuration") + $configLines.Add($displayList[$displayChoice - 1].configLine) + $configLines.Add("#define SCROLLMODE 1 // Alternate between pages") } if ($wifiBoards.Contains($deviceFQBN)) { # WiFi prompt } -} <############################################ -If display or WiFi options set, create config.h +Write out config.h to a file here only if config directory not provided ############################################> - + $configH = $commandStationDirectory + "\config.h" + foreach ($line in $configLines) { + Write-Output $line + } + Pause + try { + $configLines | Out-File -FilePath $configH + } + catch { + Write-Output "Error writing config file to $configH" + Exit + } +} <############################################ Install core libraries for the platform