Finally decided to release this, I have a python version too but that is unimportant to me.
It is a text mode "Dual_VU.sh" meter.
It actually calls dash as the interpreter but change the shebang to suit yourselves.
It uses the bell character for overload per channel and looks like a dual vertical LED display.
It is written longhand to show how the image is built up per _frame_ and NOT as an exercise in algorithm building.
I suspect this is yet another first...
Enjoy...
Code:
#!/usr/local/bin/dash
# OR......
#!/bin/sh
# Dual_VU.sh
# Startup variable values here.
byteone=0
bytetwo=0
blank="(C)2016, issued as Public Domain, CC0 licence, B.Walker, G0LCU."
greenlines=blank
yellowlines=blank
redlines=blank
# Assuming pure ASCII only, primarily for CygWin.
unichar="**"
# Assuming UTF-8 is a default encoding, block graphics in HEX format.
#unichar="\xe2\x96\x88\xe2\x96\x88"
# Assuming UTF-8 is a default encoding, block graphics in octal format.
#unichar="\342\226\210\342\226\210"
spacer=" ____ "
# A default CygWin install does not have 'clear' nor 'tput', so rely on terminal escape codes instead.
# CygWin's 'mintty' conforms to a large subset of terminal escape codes.
clrscn()
{
printf "%b" "\033[0m\033[2J\033[H"
}
while true
do
# Run continuously and use Ctrl-C to STOP!
blank="\033[0m "
# Generate two byte values as though grabbed from a serial, parallel or USB port.
# E.G. The Arduino Diecimila Dev Board from USB as a multiple analogue source.
# byteone=$(( RANDOM % ( 256 / 16 ) )) # This is undefined in POSIX.
# bytetwo=$(( RANDOM % ( 256 / 16 ) )) # This is undefined in POSIX.
awk ' BEGIN \
{ srand()
while(1)
printf( "%d %d\n", ( 256 / 16 ) * rand(), ( 256 / 16 ) * rand() )
}' | while read -r byteone bytetwo
do
# Although this should never occur, don't allow any errors.
if [ "$byteone" -ge "15" ]
then
byteone=15
fi
if [ "$byteone" -le "0" ]
then
byteone=0
fi
if [ "$bytetwo" -ge "15" ]
then
bytetwo=15
fi
if [ "$bytetwo" -le "0" ]
then
bytetwo=0
fi
# Do a full, clean, clear screen and start looping.
clrscn
printf "%b\n" "\033[0mDual Four Bit Level Vertical Analogue Bar Graph Display, (VU meters)..."
echo ""
printf "Original copyright, (C)2016, now issued under the CC0 licence, B.Walker, G0LCU.\n"
echo ""
printf "%b\n" "$blank\033[1;31m15 __ __ ____ __ __ 15"
redlines="$blank\033[1;31m14 __ "
if [ "$byteone" -ge "15" ]
then
redlines="$redlines$unichar$spacer"
else
redlines="$redlines $spacer"
fi
if [ "$bytetwo" -ge "15" ]
then
redlines="$redlines$unichar __ 14"
else
redlines="$redlines __ 14"
fi
printf "%b\n" "$redlines"
redlines="$blank\033[1;31m13 __ "
if [ "$byteone" -ge "14" ]
then
redlines="$redlines$unichar$spacer"
else
redlines="$redlines $spacer"
fi
if [ "$bytetwo" -ge "14" ]
then
redlines="$redlines$unichar __ 13"
else
redlines="$redlines __ 13"
fi
printf "%b\n" "$redlines"
yellowlines="$blank\033[1;33m12 __ "
if [ "$byteone" -ge "13" ]
then
yellowlines="$yellowlines$unichar$spacer"
else
yellowlines="$yellowlines $spacer"
fi
if [ "$bytetwo" -ge "13" ]
then
yellowlines="$yellowlines$unichar __ 12"
else
yellowlines="$yellowlines __ 12"
fi
printf "%b\n" "$yellowlines"
yellowlines="$blank\033[1;33m11 __ "
if [ "$byteone" -ge "12" ]
then
yellowlines="$yellowlines$unichar$spacer"
else
yellowlines="$yellowlines $spacer"
fi
if [ "$bytetwo" -ge "12" ]
then
yellowlines="$yellowlines$unichar __ 11"
else
yellowlines="$yellowlines __ 11"
fi
printf "%b\n" "$yellowlines"
yellowlines="$blank\033[1;33m10 __ "
if [ "$byteone" -ge "11" ]
then
yellowlines="$yellowlines$unichar$spacer"
else
yellowlines="$yellowlines $spacer"
fi
if [ "$bytetwo" -ge "11" ]
then
yellowlines="$yellowlines$unichar __ 10"
else
yellowlines="$yellowlines __ 10"
fi
printf "%b\n" "$yellowlines"
greenlines="$blank\033[1;32m 9 __ "
if [ "$byteone" -ge "10" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "10" ]
then
greenlines="$greenlines$unichar __ 9"
else
greenlines="$greenlines __ 9"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 8 __ "
if [ "$byteone" -ge "9" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "9" ]
then
greenlines="$greenlines$unichar __ 8"
else
greenlines="$greenlines __ 8"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 7 __ "
if [ "$byteone" -ge "8" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "8" ]
then
greenlines="$greenlines$unichar __ 7"
else
greenlines="$greenlines __ 7"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 6 __ "
if [ "$byteone" -ge "7" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "7" ]
then
greenlines="$greenlines$unichar __ 6"
else
greenlines="$greenlines __ 6"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 5 __ "
if [ "$byteone" -ge "6" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "6" ]
then
greenlines="$greenlines$unichar __ 5"
else
greenlines="$greenlines __ 5"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 4 __ "
if [ "$byteone" -ge "5" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "5" ]
then
greenlines="$greenlines$unichar __ 4"
else
greenlines="$greenlines __ 4"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 3 __ "
if [ "$byteone" -ge "4" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "4" ]
then
greenlines="$greenlines$unichar __ 3"
else
greenlines="$greenlines __ 3"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 2 __ "
if [ "$byteone" -ge "3" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "3" ]
then
greenlines="$greenlines$unichar __ 2"
else
greenlines="$greenlines __ 2"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 1 __ "
if [ "$byteone" -ge "2" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines $spacer"
fi
if [ "$bytetwo" -ge "2" ]
then
greenlines="$greenlines$unichar __ 1"
else
greenlines="$greenlines __ 1"
fi
printf "%b\n" "$greenlines"
greenlines="$blank\033[1;32m 0 __ "
if [ "$byteone" -ge "1" ]
then
greenlines="$greenlines$unichar$spacer"
else
greenlines="$greenlines"'__'"$spacer"
fi
if [ "$bytetwo" -ge "1" ]
then
greenlines="$greenlines$unichar __ 0"
else
greenlines="$greenlines"'__ __ 0'
fi
printf "%b\n" "$greenlines"
# Print the two byte values onto the screen...
printf "\n%b %u%b %u... \n" "\033[1;34mByteone =" "$byteone" ", bytetwo =" "$bytetwo"
printf "%b" "\033[0mPress Ctrl-C to stop... "
# Ignore the 'sleep' command running in floating point mode and not being POSIX compliant,
# it is only here as a delay until......
# ......it can be removed if the code is modified to access real hardware to use these VU meters.
sleep 0.1
# Use the system bell(s) for either or both VU overloads.
if [ "$byteone" -eq "15" ] || [ "$bytetwo" -eq "15" ]
then
printf "\007"
fi
done
done
I am NOT uploading this anywhere else, so if there is any flak then I get it here... ;oD
Thanks to Don for his "POSIX random" input on another thread.
Last edited by wisecracker; 08-09-2016 at 07:33 AM..
Reason: Add image.
Well guys, this MUST be a first.
This is DEMO code only and has NO error detection or correction, nor out of bounds checking.
I have succumbed to Python and scipy to do the FFT heavy lifting as I have absolutely no idea where to start do such a thing using AWK. This is a taster for me to... (7 Replies)
This is a DEMO only...
Someone recently asked about creating a box to make something look nicer on screen.
I suggested that with careful colouring a 3D effect could be created...
Linux version; this also works on a Macbook Pro but is not as easy to see as the other code below:-
... (0 Replies)
Dear All,
i am trying to install the redhat linux using graphical mode...but it stucks while probing video card...i have installed linux using text mode it works fine and whole the installation goes fine. after installation if i give startx command it again stucks....looks like a vga card... (9 Replies)
Hi All,
I used to have my suse linux(VM) server in graphic mode but not anymore since morning. I cant rolback since i loose somuch work. Any idea how to it back to normal. Thanks (6 Replies)
Hi all
I have installed solaris 5.10 and it is loading in GUI mode by default.
I want to load in text mode by default. How to do this? How to switch from GUI to text mode and vise versa.?
Please help.. (2 Replies)
hello all
I saw somewhere there is some kind of version of emacs in full text mode ?
how can I get/download it? if I have ordenry emacs installed can I start it in text mode?
thanks (2 Replies)
Hi.
I need to run old full-screen text-mode application under X-Windows. (By the way it is touch-screen calibrator firmware). The screen resolution is to be 1280x1024 exactly. The program expect text-mode geometry 80x25. Running xterm (no window manager) I have adjusted the font pararameters to... (3 Replies)
Hi people... Is there any way to configure the conection i text mode ? I need to know how to make the modem work and how to configure a dial up conection in text mode by redhat 7.1 and if possible how to configure the email...
I use the workstation installation...any help will be welcome...... (2 Replies)