mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-01 06:04:41 +02:00
Added write-braille.ps1
This commit is contained in:
parent
cc399370af
commit
b719c3a575
@ -61,6 +61,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
|
|||||||
* [wakeup.ps1](Scripts/wakeup.ps1) - sends a magic packet to the given computer, waking him up
|
* [wakeup.ps1](Scripts/wakeup.ps1) - sends a magic packet to the given computer, waking him up
|
||||||
* [write-big.ps1](Scripts/write-big.ps1) - writes the given text in big letters
|
* [write-big.ps1](Scripts/write-big.ps1) - writes the given text in big letters
|
||||||
* [write-blue.ps1](Scripts/write-blue.ps1) - writes the given text in a blue foreground color
|
* [write-blue.ps1](Scripts/write-blue.ps1) - writes the given text in a blue foreground color
|
||||||
|
* [write-braille.ps1](Scripts/write-braille.ps1) - writes the given text in Braille
|
||||||
* [write-green.ps1](Scripts/write-green.ps1) - writes the given text in a green foreground color
|
* [write-green.ps1](Scripts/write-green.ps1) - writes the given text in a green foreground color
|
||||||
* [write-morse-code.ps1](Scripts/write-morse-code.ps1) - writes the given text in Morse code
|
* [write-morse-code.ps1](Scripts/write-morse-code.ps1) - writes the given text in Morse code
|
||||||
* [write-MOTD.ps1](Scripts/write-MOTD.ps1) - writes the message of the day (MOTD)
|
* [write-MOTD.ps1](Scripts/write-MOTD.ps1) - writes the message of the day (MOTD)
|
||||||
|
360
Scripts/write-braille.ps1
Executable file
360
Scripts/write-braille.ps1
Executable file
@ -0,0 +1,360 @@
|
|||||||
|
#!/snap/bin/powershell
|
||||||
|
|
||||||
|
# Syntax: ./write-braille.ps1 [<text>]
|
||||||
|
# Description: writes the given text in Braille
|
||||||
|
# Author: Markus Fleschutz
|
||||||
|
# Source: github.com/fleschutz/PowerShell
|
||||||
|
# License: CC0
|
||||||
|
|
||||||
|
param([String]$Text)
|
||||||
|
|
||||||
|
function BrailleA() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return "oo" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleB() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleC() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return "oo" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleD() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return "o." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleE() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return "o." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleF() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleG() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleH() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleI() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return "o." }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleJ() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return "o." }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleK() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return "oo" }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleL() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleM() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return "oo" }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleN() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return "o." }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleO() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return "o." }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleP() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleQ() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleR() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleS() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return "o." }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleT() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return "o." }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return ".o" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleU() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return "oo" }
|
||||||
|
3 { return ".." }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleV() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return ".." }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleW() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return "o." }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return "o." }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleX() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return "oo" }
|
||||||
|
3 { return ".." }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleY() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return "o." }
|
||||||
|
3 { return ".." }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleZ() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return "o." }
|
||||||
|
3 { return ".." }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille1() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return "oo" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille2() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille3() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return "oo" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille4() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return "o." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille5() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return "o." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille6() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille7() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".." }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille8() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return ".o" }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille9() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return "o." }
|
||||||
|
2 { return ".o" }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Braille0() { param([Int]$Row)
|
||||||
|
switch($Row) {
|
||||||
|
1 { return "o." }
|
||||||
|
2 { return ".." }
|
||||||
|
3 { return "oo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrailleChar() { param([String]$Char, [Int]$Row)
|
||||||
|
switch($Char) {
|
||||||
|
'A' { return BrailleA $Row }
|
||||||
|
'B' { return BrailleB $Row }
|
||||||
|
'C' { return BrailleC $Row }
|
||||||
|
'D' { return BrailleD $Row }
|
||||||
|
'E' { return BrailleE $Row }
|
||||||
|
'F' { return BrailleF $Row }
|
||||||
|
'G' { return BrailleG $Row }
|
||||||
|
'H' { return BrailleH $Row }
|
||||||
|
'I' { return BrailleI $Row }
|
||||||
|
'J' { return BrailleJ $Row }
|
||||||
|
'K' { return BrailleK $Row }
|
||||||
|
'L' { return BrailleL $Row }
|
||||||
|
'M' { return BrailleM $Row }
|
||||||
|
'N' { return BrailleN $Row }
|
||||||
|
'O' { return BrailleO $Row }
|
||||||
|
'P' { return BrailleP $Row }
|
||||||
|
'Q' { return BrailleQ $Row }
|
||||||
|
'R' { return BrailleR $Row }
|
||||||
|
'S' { return BrailleS $Row }
|
||||||
|
'T' { return BrailleT $Row }
|
||||||
|
'U' { return BrailleU $Row }
|
||||||
|
'V' { return BrailleV $Row }
|
||||||
|
'W' { return BrailleW $Row }
|
||||||
|
'X' { return BrailleX $Row }
|
||||||
|
'Y' { return BrailleY $Row }
|
||||||
|
'Z' { return BrailleZ $Row }
|
||||||
|
'1' { return Braille1 $Row }
|
||||||
|
'2' { return Braille2 $Row }
|
||||||
|
'3' { return Braille3 $Row }
|
||||||
|
'4' { return Braille4 $Row }
|
||||||
|
'5' { return Braille5 $Row }
|
||||||
|
'6' { return Braille6 $Row }
|
||||||
|
'7' { return Braille7 $Row }
|
||||||
|
'8' { return Braille8 $Row }
|
||||||
|
'9' { return Braille9 $Row }
|
||||||
|
'0' { return Braille0 $Row }
|
||||||
|
}
|
||||||
|
return " "
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($Text -eq "" ) {
|
||||||
|
[String]$Text = read-host "Enter text to write"
|
||||||
|
}
|
||||||
|
[char[]]$ArrayOfChars = $Text.ToUpper()
|
||||||
|
write-output ""
|
||||||
|
for ($Row = 1; $Row -lt 4; $Row++) {
|
||||||
|
$Line = ""
|
||||||
|
foreach($Char in $ArrayOfChars) {
|
||||||
|
$Line += BrailleChar $Char $Row
|
||||||
|
$Line += " "
|
||||||
|
}
|
||||||
|
write-output $Line
|
||||||
|
}
|
||||||
|
write-output ""
|
||||||
|
exit 0
|
||||||
|
} catch {
|
||||||
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
|
}
|
@ -7,61 +7,64 @@
|
|||||||
# License: CC0
|
# License: CC0
|
||||||
|
|
||||||
param([String]$Text)
|
param([String]$Text)
|
||||||
|
$OneTimeUnit = 100 # milliseconds
|
||||||
|
|
||||||
|
function gap() { param([Int]$Length)
|
||||||
|
for ($i = 1; $i -lt $Length; $i++) {
|
||||||
|
write-host " " -nonewline
|
||||||
|
}
|
||||||
|
start-sleep -milliseconds ($Length * $OneTimeUnit)
|
||||||
|
}
|
||||||
|
|
||||||
function dot() {
|
function dot() {
|
||||||
write-host "." -nonewline
|
write-host "." -nonewline
|
||||||
start-sleep -milliseconds 100
|
start-sleep -milliseconds $OneTimeUnit # signal
|
||||||
}
|
}
|
||||||
|
|
||||||
function dash() {
|
function dash() {
|
||||||
write-host "-" -nonewline
|
write-host "_" -nonewline
|
||||||
start-sleep -milliseconds 300
|
start-sleep -milliseconds (3 * $OneTimeUnit) # signal
|
||||||
}
|
|
||||||
|
|
||||||
function pause() {
|
|
||||||
write-host " " -nonewline
|
|
||||||
start-sleep -milliseconds 400
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Char2MorseCode() { param([String]$Char)
|
function Char2MorseCode() { param([String]$Char)
|
||||||
switch($Char) {
|
switch($Char) {
|
||||||
'A' { dot; dash }
|
'A' { dot; gap 1; dash; gap 3 }
|
||||||
'B' { dash; dot; dot; dot }
|
'B' { dash; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'C' { dash; dot; dash; dot }
|
'C' { dash; gap 1; dot; gap 1; dash; gap 1; dot; gap 3 }
|
||||||
'D' { dash; dot; dot }
|
'D' { dash; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'E' { dot }
|
'E' { dot; gap 3 }
|
||||||
'F' { dot; dot; dash; dot }
|
'F' { dot; gap 1; dot; gap 1; dash; gap 1; dot; gap 3 }
|
||||||
'G' { dash; dash; dot }
|
'G' { dash; gap 1; dash; gap 1; dot; gap 3 }
|
||||||
'H' { dot; dot; dot; dot }
|
'H' { dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'I' { dot; dot }
|
'I' { dot; gap 1; dot; gap 3 }
|
||||||
'J' { dot; dash; dash; dash }
|
'J' { dot; gap 1; dash; gap 1; dash; gap 1; dash; gap 3 }
|
||||||
'K' { dash; dot; dash }
|
'K' { dash; gap 1; dot; gap 1; dash; gap 3 }
|
||||||
'L' { dot; dash; dot; dot }
|
'L' { dot; gap 1; dash; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'M' { dash; dash }
|
'M' { dash; gap 1; dash; gap 3 }
|
||||||
'N' { dash; dot }
|
'N' { dash; gap 1; dot; gap 3 }
|
||||||
'O' { dash; dash; dash }
|
'O' { dash; gap 1; dash; gap 1; dash; gap 3 }
|
||||||
'P' { dot; dash; dash; dot }
|
'P' { dot; gap 1; dash; gap 1; dash; gap 1; dot; gap 3 }
|
||||||
'Q' { dash; dash; dot; dash }
|
'Q' { dash; gap 1; dash; gap 1; dot; gap 1; dash; gap 3 }
|
||||||
'R' { dot; dash; dot }
|
'R' { dot; gap 1; dash; gap 1; dot; gap 3 }
|
||||||
'S' { dot; dot; dot }
|
'S' { dot; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'T' { dash }
|
'T' { dash; gap 3 }
|
||||||
'U' { dot; dot; dash }
|
'U' { dot; gap 1; dot; gap 1; dash; gap 3 }
|
||||||
'V' { dot; dot; dot; dash }
|
'V' { dot; gap 1; dot; gap 1; dot; gap 1; dash; gap 3 }
|
||||||
'W' { dot; dash; dash }
|
'W' { dot; gap 1; dash; gap 1; dash; gap 3 }
|
||||||
'X' { dash; dot; dot; dash }
|
'X' { dash; gap 1; dot; gap 1; dot; gap 1; dash; gap 3 }
|
||||||
'Y' { dash; dot; dash; dash }
|
'Y' { dash; gap 1; dot; gap 1; dash; gap 1; dash; gap 3 }
|
||||||
'Z' { dash; dash; dot; dot }
|
'Z' { dash; gap 1; dash; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'1' { dot; dash; dash; dash; dash }
|
'1' { dot; gap 1; dash; gap 1; dash; gap 1; dash; gap 1; dash; gap 3 }
|
||||||
'2' { dot; dot; dash; dash; dash }
|
'2' { dot; gap 1; dot; gap 1; dash; gap 1; dash; gap 1; dash; gap 3 }
|
||||||
'3' { dot; dot; dot; dash; dash }
|
'3' { dot; gap 1; dot; gap 1; dot; gap 1; dash; gap 1; dash; gap 3 }
|
||||||
'4' { dot; dot; dot; dot; dash }
|
'4' { dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 1; dash; gap 3 }
|
||||||
'5' { dot; dot; dot; dot; dot }
|
'5' { dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'6' { dash; dot; dot; dot; dot }
|
'6' { dash; gap 1; dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'7' { dash; dash; dot; dot; dot }
|
'7' { dash; gap 1; dash; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'8' { dash; dash; dash; dot; dot }
|
'8' { dash; gap 1; dash; gap 1; dash; gap 1; dot; gap 1; dot; gap 3 }
|
||||||
'9' { dash; dash; dash; dash; dot }
|
'9' { dash; gap 1; dash; gap 1; dash; gap 1; dash; gap 1; dot; gap 3 }
|
||||||
'0' { dash; dash; dash; dash; dash }
|
'0' { dash; gap 1; dash; gap 1; dash; gap 1; dash; gap 1; dash; gap 3 }
|
||||||
default { pause }
|
default { gap 7 } # medium gap (between words)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +77,7 @@ try {
|
|||||||
Char2MorseCode $Char
|
Char2MorseCode $Char
|
||||||
}
|
}
|
||||||
write-host ""
|
write-host ""
|
||||||
|
write-host ""
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user