From e8f668643d9441cad586a730ce6bcdf378ed25f1 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sat, 26 Jul 2025 19:13:15 +0200 Subject: [PATCH] Updated write-value.ps1 --- scripts/write-value.ps1 | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/scripts/write-value.ps1 b/scripts/write-value.ps1 index 9944ba2f..abf20c48 100755 --- a/scripts/write-value.ps1 +++ b/scripts/write-value.ps1 @@ -17,26 +17,27 @@ param([float]$value = 0.5, [string]$unit = "Mach", [float]$redMin, [float]$yellowMin, [float]$yellowMax, [float]$redMax) function WriteValueInRange([float]$value, [string]$unit, [float]$redMin, [float]$yellowMin, [float]$yellowMax, [float]$redMax) { - $line = "------------------------------------------------" - $text = "[$redMin$($value)$unit $redMax]" - [float]$total = 20.0 - $text.Length + $line = "--------------------------------------" + $text = "[$redMin$value$unit$redMax]" + [float]$both = 20.0 - $text.Length if ($value -gt $redMax) { - Write-Host "[$redMin$($line.Substring(0, $total))$redMax]" -noNewline - Write-Host "$($value)$unit " -noNewline -foregroundColor red + Write-Host "[$redMin$($line.Substring(0,$both))$redMax]" -noNewline + Write-Host "$value$unit" -noNewline -foregroundColor red } elseif ($value -lt $redMin) { - Write-Host "$($value)$unit" -noNewline -foregroundColor red - Write-Host "[$redMin$($line.Substring(0, $total))$redMax] " -noNewline + Write-Host "$value$unit" -noNewline -foregroundColor red + Write-Host "[$redMin$($line.Substring(0,$both))$redMax] " -noNewline } else { - [float]$leftSide = (($value - $redMin) * $total) / ($redMax - $redMin) - if ($leftSide -lt 1.0) { $leftSide = 1.0 } - if ($leftSide -gt ($total - 1.0)) { $leftSide = $total - 1.0 } - Write-Host "[$redMin$($line.Substring(0, $leftSide))" -noNewline + [float]$left = (($value - $redMin) * $both) / ($redMax - $redMin) + if ($left -lt 1.0) { $left = 1.0 } + elseif ($left -gt ($both - 1.0)) { $left = $both - 1.0 } + [float]$right = $both - $left + Write-Host "[$redMin$($line.Substring(0,$left))" -noNewline if (($value -le $yellowMin) -or ($value -ge $yellowMax)) { - Write-Host "$($value)$unit" -noNewline -foregroundColor yellow + Write-Host "$value$unit" -noNewline -foregroundColor yellow } else { - Write-Host "$($value)$unit" -noNewline -foregroundColor green + Write-Host "$value$unit" -noNewline -foregroundColor green } - Write-Host "$($line.Substring(0, $total - $leftSide + 0.49))$redMax] " -noNewline + Write-Host "$($line.Substring(0,$right))$redMax]" -noNewline } } @@ -50,11 +51,11 @@ WriteValueInRange 800 "m" 0 0 6000 8000 Write-Host "" Write-Host " SPEED " -noNewline -WriteValueInRange 190 "km/h" 0 0 180 200 +WriteValueInRange 230 "km/h" 0 0 180 200 Write-Host "" Write-Host " BANK " -noNewline -WriteValueInRange 3.3 "°" -30 -10 10 30 +WriteValueInRange -30.3 "°" -30 -10 10 30 Write-Host "" Write-Host " ENG " -noNewline @@ -73,4 +74,8 @@ Write-Host " FREQ " -noNewline WriteValueInRange 104.4 "MHz" 80 80 108 108 Write-Host "" +Write-Host " BRAKE " -noNewline +WriteValueInRange 0.0 "%" 0 -1 90 100 +Write-Host "" + exit 0 # success