Would any of you care to give this demo a workout...
It does NOTHING at the moment but is a pseudo-GUI using terminal codes. It is intended as a fully functional fixed frequency LF stereo function generator.
The A, B, C and D keys shift the cursor and ENTER will quit the program. The ENTER key will become a psuedo-LMB in due course but ATM it just quits the code.
The Cursor keys work the same for OSX but I have no idea if a multitude of Linux flavours will work... This is where you guys come in...
The bottom of the window updates when the cursor movement stops.
Thanks in advance...
EDIT: 23-03-2014, 23:05
Changed all foreground values of 97 to 37...
2nd EDIT: 24-03-2014, 9:56
Use "Q" to quit and added a small piece of extra code...
- Code: Select all
#!/bin/bash
# Function_Generator.sh
# This is a GUI style DEMO only and only tested on OSX 10.7.5, default bash terminal.
# $VER: Function_Generator.sh_Version_0.00.00_(C)2014_B.Walker_G0LCU.
# Variables...
ifs_str="$IFS"
ver="0.00.00"
# Reusable variables...
x=0
y=0
n=0
char=" "
text="(C)2014, B.Walker, G0LCU."
arr=$(text)
# Specific variables...
button_text="Not used yet."
cursor_x=1
cursor_y=1
# #########################################################
# Add the program tilte and version to the Terminal title bar...
# This may NOT work in every Terminal so just comment it out if it doesn't.
printf "\x1B]0;Shell Function Generator Version "$ver".\x07"
# #########################################################
# A clear screen function that does NOT use "clear".
# Set up as black on white.
clrscn()
{
printf "\x1B[H\x1B[0;30;47m"
printf "\x1B[2J\x1B[H"
}
# Use it to set up screen.
clrscn
# #########################################################
# A timing function that has keyboard override and does NOT use "sleep".
delay()
{
read -n1 -s -t$1
}
# #########################################################
# A simple INKEY$ function.
inkey() { char=" " ; read -n1 -s -t1 char ; }
# #########################################################
# Enable graphics mode.
graphics_on()
{
printf "\x1B(0"
}
# #########################################################
# Disable graphics mode.
graphics_off()
{
printf "\x1B(B"
}
# #########################################################
# Set up the 3D buttons as a pseudo-GUI.
button_off()
{
x=$1
y=$2
graphics_on
printf "\x1B["$y";"$x"f\x1B[1;37;47mlqqqqqqqqqqqq\x1B[1;30;47mk\x1B[0m"
y=$(( $y + 1 ))
printf "\x1B["$y";"$x"f\x1B[1;37;47mx \x1B[1;30;47mx\x1B[0m"
y=$(( $y + 1 ))
printf "\x1B["$y";"$x"f\x1B[1;37;47mm\x1B[1;30;47mqqqqqqqqqqqq\x1B[1;30;47mj\x1B[0m"
graphics_off
printf "\x1B[0m"
}
# #########################################################
# Set up a 3D button as a pressed on.
button_on()
{
x=$1
y=$2
graphics_on
printf "\x1B["$y";"$x"f\x1B[1;30;47mlqqqqqqqqqqqq\x1B[1;37;47mk\x1B[0m"
y=$(( $y + 1 ))
printf "\x1B["$y";"$x"f\x1B[1;30;47mx \x1B[1;37;47mx\x1B[0m"
y=$(( $y + 1 ))
printf "\x1B["$y";"$x"f\x1B[1;30;47mm\x1B[1;37;47mqqqqqqqqqqqq\x1B[1;37;47mj\x1B[0m"
graphics_off
printf "\x1B[0m"
}
# Set up a pseudo-3D display...
display()
{
clrscn
graphics_on
printf "\x1B[1;2f\x1B[1;30;47mlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\x1B[1;37;47mk\x1B[0m"
for y in {2..13}
do
printf "\x1B["$y";2f\x1B[1;30;47mx \x1B[1;37;47mx\x1B[0m"
done
printf "\x1B[14;2f\x1B[1;30;47mm\x1B[1;37;47mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\x1B[1;37;47mj\x1B[0m"
graphics_off
for x in $( seq 4 15 64 )
do
for y in $( seq 2 3 11 )
do
button_off $x $y
done
done
text="Sinewave\x1B[0m Squarewave Triangle Noise Sawtooth+ Sawtooth- Pulse+ Pulse- Quit/Exit Reset"
arr=($text)
n=0
for x in $( seq 6 15 66)
do
for y in $( seq 3 3 6 )
do
printf "\x1B[0;30;47m\x1B["$y";"$x"f${arr[$n]}"
n=$(( $n + 1 ))
done
done
text="20Hz 50Hz 100Hz 200Hz 500Hz 1000Hz 2000Hz 5000Hz Sweep Mono"
arr=($text)
n=0
for x in $( seq 6 15 66)
do
for y in $( seq 9 3 12 )
do
printf "\x1B[0;30;47m\x1B["$y";"$x"f${arr[$n]}"
n=$(( $n + 1 ))
done
done
}
display
while true
do
inkey
if [ "$char" == "Q" ]
then
printf "Quitting...\n\n"
break
fi
if [ "$char" == " " ] || [ "$char" == "" ]
then
printf "\x1B[22;2fPress Q, (uppercase), to Quit. (X = $cursor_x, Y = $cursor_y)..."
fi
# These are the same as the four cursor keys for OSX too.
# Cursor up...
if [ "$char" == "A" ]
then
cursor_y=$(( $cursor_y - 1 ))
fi
# Cursor down...
if [ "$char" == "B" ]
then
cursor_y=$(( $cursor_y + 1 ))
fi
# Cursor right...
if [ "$char" == "C" ]
then
cursor_x=$(( $cursor_x + 1 ))
fi
# Cursor left...
if [ "$char" == "D" ]
then
cursor_x=$(( $cursor_x - 1 ))
fi
if [ $cursor_x -le 1 ]
then
cursor_x=1
fi
if [ $cursor_x -ge 80 ]
then
cursor_x=80
fi
if [ $cursor_y -le 1 ]
then
cursor_y=1
fi
if [ $cursor_y -ge 24 ]
then
cursor_y=24
fi
printf "\x1B["$cursor_y";"$cursor_x"f"
done
exit 0