Scripting an SVG Dot Matrix

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Scripting an SVG Dot Matrix

#1 Post by mister_electronico »

Special thanks to kjdixo, greengeek and 01micko for your help.

This project is an Dots Matrix leds, which can be given multiple uses and can be used to give a more attractive look for our programs.

It has taken a lot of work to develop, but finished tired and I do not take the final work of leaving well finished, so anyone with a minimum of knowledge surely be improved.

Besides that you can make many improvements as having the option to change the color of the sign and other much more.


There is an error in one of the lines of a script that will comment later does not affect the normal operation but it is a bit annoying if you run the program from the terminal.

This program consists of some executables that come with the program installation script that are about to be installed in the /usr/ bin

Programs require application of what I show in the following post.

Sorry for my bad English level


last updated pet 29_01_2016


The sfs package "led_scroller_welcome-0.1.sfs" built by greengeek wrote
That is appropriate for a message that says "Welcome to Puppy" . . . you installed the script in my Startup folder.
Every time I start my puppy linux I now get the welcome message panel.

Just remove the false .gz suffix then install the sfs. The rest is automatic.

__________________________________________

My Blog
https://misterelectronico.wordpress.com ... n-arduino/
Attachments
led_scroller_welcome-0.1.sfs.gz
(4 KiB) Downloaded 168 times
led_scroller_v0.1.pet
(3.01 KiB) Downloaded 173 times
panel_running.jpg
(21.28 KiB) Downloaded 382 times
Last edited by mister_electronico on Sat 30 Jan 2016, 10:08, edited 9 times in total.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

panel dot matrix Led running

#2 Post by mister_electronico »

Here I leave the script "panel_running" running Matrix LED, if we change the message all we have to go is to the line 15 of the script panel_running and change this line in the message.

echo " PUPPY IS GREAT " > $TEMPDIR/message.dat

PUPPY IS GREAT ---- by the message that we want, can in principle be all over you will, but if it is too long the program will slow.


May not run on some PCs that are a bit slow, increase the value for it on line 29 of the script “panel_running
Attachments
000_img.jpg
Bigger size and diferent color with setup in /tmp/panel/setup.dat
(24.84 KiB) Downloaded 140 times
panel_running.tar.gz
(728 Bytes) Downloaded 200 times
panel_running.jpg
default panel size and colors without /tmp/panel/setup.dat file
(21.28 KiB) Downloaded 458 times
Last edited by mister_electronico on Fri 29 Jan 2016, 16:56, edited 9 times in total.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

The time

#3 Post by mister_electronico »

I leave here simply a program that shows the current time.

As in the previous program may slow if the PC are necessary to vary the value of the line. 42 “time_svg
Attachments
time_svg11.tar.gz
(789 Bytes) Downloaded 193 times
time_svg.jpg
(21.14 KiB) Downloaded 445 times
Last edited by mister_electronico on Sat 23 Jan 2016, 23:22, edited 16 times in total.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

The date

#4 Post by mister_electronico »

The following program “date_svg
Attachments
date_svg22.tar.gz
(782 Bytes) Downloaded 178 times
date_svg.jpg
(19.34 KiB) Downloaded 451 times
Last edited by mister_electronico on Sat 23 Jan 2016, 23:27, edited 8 times in total.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Time_table

#5 Post by mister_electronico »

The following script "time hour" is just a sample of how to make some programs more attractive.
Note that according to the power of the computer can take 2, 3 or more seconds to open.
This program does not need delay.






__________________________________________

My Blog
https://misterelectronico.wordpress.com ... n-arduino/
Attachments
time_hour.tar.gz
(1.11 KiB) Downloaded 199 times
time_hour.jpg
(47.81 KiB) Downloaded 439 times
Last edited by mister_electronico on Sat 23 Jan 2016, 15:18, edited 1 time in total.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

#6 Post by mister_electronico »

As commenting at first pet we install script consists of 3 that are installed in the directory /usr/bin


-make_dot The first script will convert the message stored within the temporary directory /tmp/panel/message.dat and convert it to file type format as illustrated below.

Which are of zeros and ones and where are represented as the LEDs are illuminated panel, if zero is off and if one on.

This is saved in a file in the same temporary directory /tmp/panel/color.dat

Each row of the file corresponds to one of the columns of the light sign.
So the first row is the first column on the left of the neon sign and the second row the second column and so on.

If we see the first lines for the message "PUPPY IS GREAT" would be as follows.


0 0 0 0 0 0 0 ------ space

1 1 1 1 1 1 1 |
1 0 0 1 0 0 0 |
1 0 0 1 0 0 0 | ----- the letter P
1 0 0 1 0 0 0 |
0 1 1 0 0 0 0 |


0 0 0 0 0 0 0 ------ space

1 1 1 1 1 1 0 |
0 0 0 0 0 0 1 |
0 0 0 0 0 0 1 | --- the letter U
0 0 0 0 0 0 1 |
1 1 1 1 1 1 0 |

......
......
......

and so repeatedly, this is what translates into the bright points within the panel.


Here it is where I get the error mentioned at the beginning and I have not solved yet, but does not affect the operation of the panel, is annoying when running on terminal.

“./make_dot: line 20: [: P: unary operator expected

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#7 Post by slavvo67 »

Confirmed; not working in QU 6.2.1

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

That is exactly what is not working?

#8 Post by mister_electronico »

That is exactly what is not working?

You installed the pet?

What does it say when they run programs through the terminal?

1) Install Pet.

2) donwload panel_running.tar.gz and unzip and running by:

./panel_running

3) or download time_svg and do the same.

./time_svg

4) or download date_svge and do the same.

./date_svg

5) The same for time_hour

Maybe depend the power of you computer like I said in the second post.

Cheers




__________________________________________

My Blog
https://misterelectronico.wordpress.com ... n-arduino/
Last edited by mister_electronico on Fri 29 Jan 2016, 19:09, edited 1 time in total.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

the scripts

#9 Post by mister_electronico »

make_dot

the program is responsible for converting the text message to the 0 and 1 which then will those who are off or on in the LED panel.

its structure is as follows.

Code: Select all

INPUT="/tmp/panel/message.dat"

echo " " > "/tmp/panel.color.dat"
if [ -f "/tmp/panel/color.dat" ]; then
   rm "/tmp/panel/color.dat"
else
  m=1
fi

# while loop
while IFS= read -r -n1 char
do
       
      
 if  [ $char = ${x// /*} ];  then  echo '0 0 0 0 0 0 0' >> /tmp/panel/color.dat; echo '0 0 0 0 0 0 0' >> /tmp/panel/color.dat; echo '0 0 0 0 0 0 0' >> /tmp/panel/color.dat; char="#"; fi 
 
if  [ $char = 'A' ];  then  echo "0 1 1 1 1 1 1" >> "/tmp/panel/color.dat"; echo "1 0 0 1 0 0 0" >> "/tmp/panel/color.dat"; echo "1 0 0 1 0 0 0" >> "/tmp/panel/color.dat";  echo "1 0 0 1 0 0 0" >> "/tmp/panel/color.dat"; echo "0 1 1 1 1 1 1" >> "/tmp/panel/color.dat"; echo "0 0 0 0 0 0 0" >> "/tmp/panel/color.dat"; fi
  
  if  [ $char = "B" ];  then  echo '1 1 1 1 1 1 1' >> /tmp/panel/color.dat; echo '1 0 0 1 0 0 1' >> /tmp/panel/color.dat; echo '1 0 0 1 0 0 1' >> /tmp/panel/color.dat; 

.......
.......

done < "$INPUT"

creator_svg

color2.dat receives the file created by make_dot and makes it an SVG file will num.svg

The program is as follows

Code: Select all

export TEMPDIR
TEMPDIR=/tmp/panel
NUM=$TEMPDIR/num.svg
export NUM

foreground="red"
background="#2D2D2D"
num=568
tab1='    '
valX=-210
valY=-42
size=281
wid11=397
wid22=492

if [ -d /tmp/panel ]; then m=1; else mkdir /tmp/panel ; fi
if [ -f $TEMPDIR/num.svg ]; then rm $TEMPDIR/num.svg ; else m=1; fi
#if [ -f $TEMPDIR/color.dat ]; then rm $TEMPDIR/color.dat; else echo ""; fi

if [ -f $TEMPDIR/setup.dat ] # reads the file setup.dat if it exists if not leave the
							 #	default values
        then
			i=0
			for line in $(cat $TEMPDIR/setup.dat); do let i=i+1; a[i]=$line ; done
			foreground=${a[1]};background=${a[2]};
			if  [ ${a[3]} == "size1" ];  then size=281; wid11=397; wid22=497; fi
			if  [ ${a[3]} == "size2" ];  then size=492; wid11=574; wid22=720; fi 
        else
            i=0                 
fi


variable=$1

if [ $variable -eq "1" ]; then rotate ; fi
if [ $variable -eq "0" ]; then make_dot; fi

i=1

TEXT1='  <path'
TEXT2='sodipodi:type="arc"'
TEXT3='style="fill:'${strg}';fill-rule:evenodd;stroke:none;fill-opacity:0.75;stroke-opacity:1;stroke-width:3pt;stroke-linejoin:miter;stroke-linecap:butt;"'
TEXT4='id="path'${num}'"'
TEXT5='d="M 223.726501 48.851059 A 5.490585 5.309601 0 1 0 212.745331,48.851059 A 5.49058 5.3096 0 1 0 223.727 48.8511 L 218.235916 48.851059 z"'
TEXT6='sodipodi:cx="218.235916"'
TEXT7='sodipodi:cy="48.851059"'     
TEXT8='sodipodi:rx="5.490585"'
TEXT9='sodipodi:ry="5.309601"'
TEXT10='transform="translate('${valX}'.0000,'${valY}'.0000)" />'

echo '<svg
   id="svg1"
   sodipodi:version="0.32"
   inkscape:version="0.36"
   width="'${wid11}'.28pt"
   height="67.89pt"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs
     id="defs3" />
  <sodipodi:namedview
     id="base" />
  <rect
     style="font-size:12;fill:#000000;fill-opacity:1.00;fill-rule:evenodd;stroke-width:3pt;"
     id="rect956"
     width="'${wid22}'.415405"
     height="84.129562"
     x="0.357557"
     y="0.727407" />'  > $NUM

valor=1
# Rellena los huecos que no se rellenaron.
i=0

for line in $(cat $TEMPDIR/color.dat)
do 

let i=i+1
ch=$line 

if  [ $ch = "0" ];  then strg=$background; fi 
if  [ $ch = "1" ];  then strg=$foreground; fi 

if [ $valX -lt $size ]; then
	echo "$TEXT1"  >> $NUM
	echo "     $TEXT2"  >> $NUM
	echo ''"     "'style="fill:'${strg}';fill-rule:evenodd;stroke:none;fill-opacity:0.75;stroke-opacity:1;stroke-width:3pt;stroke-linejoin:miter;stroke-linecap:butt;"'  >> $NUM
	echo ''"     "'id="path'${num}'"'  >> $NUM
	echo "     $TEXT5"  >> $NUM
	echo "     $TEXT6"  >> $NUM
	echo "     $TEXT7"  >> $NUM
	echo "     $TEXT8"  >> $NUM
	echo "     $TEXT9"  >> $NUM
	echo ''"     "'transform="translate('${valX}'.0000,'${valY}'.0000)" />'  >> $NUM
	let num=num+1
	let valor=valor+1
fi

let "p = $size + 5"  

if [ $valX -lt $p ]; then let valY=valY+12 ; fi
if [ $valY -gt "30" ] && [ $valX -lt $p ]; then valY='-42'; let valX=valX+12 ; fi

done

echo  "$tab1 </svg>" >> $NUM
rotate


The last script that rotate only used to panel_running is responsible for the letters run on the panel.

As explained in previous post what it does is it takes the first column of the panel and takes you to the last position.

This gets the first row of color2.dat file and writes this front in the last position of the file

Code: Select all

TEMPDIR=/tmp/panel
cp $TEMPDIR/color.dat $TEMPDIR/color2.dat
for line in $(cat $TEMPDIR/color.dat)
do 
let i=i+1

a[i]=$line  
done


echo ${a[1]}" "${a[2]}" "${a[3]}" "${a[4]}" "${a[5]}" "${a[6]}" "${a[7]}  >> $TEMPDIR/color2.dat

sed '1d' $TEMPDIR/color2.dat > $TEMPDIR/color.dat
rm $TEMPDIR/color2.dat


__________________________________________

My Blog

https://misterelectronico.wordpress.com ... n-arduino/
Last edited by mister_electronico on Fri 29 Jan 2016, 19:10, edited 2 times in total.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Open Source.

#10 Post by mister_electronico »

This project is open source, everyone is invited and welcome to modify it, improve it or anything else you want to do.

See you.







__________________________________________

My Blog
https://misterelectronico.wordpress.com ... n-arduino/
Last edited by mister_electronico on Fri 29 Jan 2016, 19:10, edited 2 times in total.

kjdixo
Posts: 153
Joined: Sun 13 Sep 2009, 21:13

#11 Post by kjdixo »

Very good
Thanks
It works.
See attached image.
What files and folders are installed by the pet in your first post please?
Attachments
mister_e.jpg
(58.74 KiB) Downloaded 306 times

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Yes...

#12 Post by mister_electronico »

Yes is working this, I think the first too --- panel_running

But the time_svg I don't know why the server will not let me update files...

Is working for you the panel_running?

see you..







__________________________________________

My Blog
https://misterelectronico.wordpress.com ... n-arduino/
Last edited by mister_electronico on Fri 29 Jan 2016, 19:11, edited 1 time in total.

kjdixo
Posts: 153
Joined: Sun 13 Sep 2009, 21:13

#13 Post by kjdixo »

And the scrolling led display works too.
Attachments
dfb.png
(23.62 KiB) Downloaded 306 times

kjdixo
Posts: 153
Joined: Sun 13 Sep 2009, 21:13

#14 Post by kjdixo »

I am using quirky puppy tahr 6.05

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Thanks

#15 Post by mister_electronico »

Thanks at last I think I can upload all files right.

Can you check now time_svg and date_svg


Thanks for all.









__________________________________________

My Blog
https://misterelectronico.wordpress.com ... n-arduino/
Last edited by mister_electronico on Fri 29 Jan 2016, 19:11, edited 1 time in total.

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

#16 Post by mister_electronico »

Te file time_svg refresh the time ever 1 second.

see you.








__________________________________________

My Blog
https://misterelectronico.wordpress.com ... n-arduino/
Last edited by mister_electronico on Fri 29 Jan 2016, 19:12, edited 1 time in total.

kjdixo
Posts: 153
Joined: Sun 13 Sep 2009, 21:13

#17 Post by kjdixo »

Yes they work.
But only when they are each run alone.
When both are run together they conflict and the svg disappears.
Attachments
date.jpg
(45.96 KiB) Downloaded 196 times
time.jpg
(46.22 KiB) Downloaded 192 times

kjdixo
Posts: 153
Joined: Sun 13 Sep 2009, 21:13

#18 Post by kjdixo »

Yes the time is changing every second like a real digital clock

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Yes this is true.

#19 Post by mister_electronico »

Yes this is true, the programs are in testing mode, that happen because use the same temporal directory /tmp/panel

And the same files.

/tmp/panel/num.svg

and

/tmp/panel/color.dat

and

/tmp/panel/message.dat

But is easily change in the scripts.

kjdixo thank you very much for checking the script.

Greetings.



__________________________________________

My Blog
https://misterelectronico.wordpress.com ... n-arduino/
Last edited by mister_electronico on Fri 29 Jan 2016, 19:13, edited 3 times in total.

kjdixo
Posts: 153
Joined: Sun 13 Sep 2009, 21:13

#20 Post by kjdixo »

Thank you for the scripts

Post Reply