Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 25 May 2016, 03:21
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Scripting an SVG Dot Matrix
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 5 [68 Posts]   Goto page: 1, 2, 3, 4, 5 Next
Author Message
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 10:57    Post subject:  Scripting an SVG Dot Matrix
Subject description: Moving Message Panels using Bash, Gtkdialog and SVG
 

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

Quote:

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/2015/12/24/programas-creados-con-arduino/
led_scroller_welcome-0.1.sfs.gz
Description 
gz

 Download 
Filename  led_scroller_welcome-0.1.sfs.gz 
Filesize  4 KB 
Downloaded  26 Time(s) 
led_scroller_v0.1.pet
Description 
pet

 Download 
Filename  led_scroller_v0.1.pet 
Filesize  3.01 KB 
Downloaded  28 Time(s) 
panel_running.jpg
 Description   
 Filesize   21.28 KB
 Viewed   313 Time(s)

panel_running.jpg


Last edited by mister_electronico on Sat 30 Jan 2016, 06:08; edited 9 times in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 11:00    Post subject: panel dot matrix Led running
Subject description: Making the most attractive programs
 

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”


<timer visible="false" milliseconds="true" interval="550">


Substituting the value of 550 for a higher value.

This may be necessary for slow computers.

If instead we lower this value and our PC supports it, the message may run faster.

We can see it working in:

https://www.youtube.com/watch?v=-B6hQdiPCaM


We can change the background color and foreground color of panel, we can also resize the panel creating a setting file:

/tmp/panel/setup.dat

If for example the file /tmp/panel/setup.dat is :

#FFFFFF
#000000
size2

It is need write only three lines.

first line foreground color panel.
second line bacground color panel.
size2 size bigger panel.
size1 size short by default.

If this file does not exist pane opens with the default settings.
__________________________________________

My Blog
https://misterelectronico.wordpress.com/2015/12/24/programas-creados-con-arduino/
000_img.jpg
 Description   Bigger size and diferent color with setup in /tmp/panel/setup.dat
 Filesize   24.84 KB
 Viewed   77 Time(s)

000_img.jpg

panel_running.tar.gz
Description 
gz

 Download 
Filename  panel_running.tar.gz 
Filesize  728 Bytes 
Downloaded  44 Time(s) 
panel_running.jpg
 Description   default panel size and colors without /tmp/panel/setup.dat file
 Filesize   21.28 KB
 Viewed   389 Time(s)

panel_running.jpg


Last edited by mister_electronico on Fri 29 Jan 2016, 12:56; edited 9 times in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 11:02    Post subject: The time
Subject description: Making the most attractive programs
 

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” script


<timer visible="false" milliseconds="true" interval="920">

Although in this case leaves a very large value considering that are second.





__________________________________________

My Blog
https://misterelectronico.wordpress.com/2015/12/24/programas-creados-con-arduino/
time_svg11.tar.gz
Description 
gz

 Download 
Filename  time_svg11.tar.gz 
Filesize  789 Bytes 
Downloaded  27 Time(s) 
time_svg.jpg
 Description   
 Filesize   21.14 KB
 Viewed   386 Time(s)

time_svg.jpg


Last edited by mister_electronico on Sat 23 Jan 2016, 19:22; edited 16 times in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 11:03    Post subject: The date
Subject description: Making the most attractive programs
 

The following program “date_svg” is the same as above but shows the date,
It is not necessary in this case to consider the delay.





__________________________________________

My Blog
https://misterelectronico.wordpress.com/2015/12/24/programas-creados-con-arduino/
date_svg22.tar.gz
Description 
gz

 Download 
Filename  date_svg22.tar.gz 
Filesize  782 Bytes 
Downloaded  29 Time(s) 
date_svg.jpg
 Description   
 Filesize   19.34 KB
 Viewed   384 Time(s)

date_svg.jpg


Last edited by mister_electronico on Sat 23 Jan 2016, 19:27; edited 8 times in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 11:05    Post subject: Time_table
Subject description: Making the most attractive programs
 

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/2015/12/24/programas-creados-con-arduino/
time_hour.tar.gz
Description 
gz

 Download 
Filename  time_hour.tar.gz 
Filesize  1.11 KB 
Downloaded  46 Time(s) 
time_hour.jpg
 Description   
 Filesize   47.81 KB
 Viewed   382 Time(s)

time_hour.jpg


Last edited by mister_electronico on Sat 23 Jan 2016, 11:18; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 11:09    Post subject:  

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”



produced on line 20 of the script code make_dot

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


It detected the blanks, but not by who gets to compare other characters.

* Well the following script that is installed with the pet is


-creator_svg This script does is get the file:


/tmp/panel/color.dat created by make_dot


and these data make the LED panel in a file called:

/tmp/panel/num.svg

Then we use that for our program.


* There is another script we install it:

The third:

-rotate

This script does is the displacement effect for panel_running program. And so we see our message scrolling left.

To do this program does is move the first column of the message to the last position of the file


/tmp/panel/color.dat

Example

0 1 1 0 0 0 0 - --- > this line moves to the last row of the file.
0 0 0 0 0 0 0
1 1 1 1 1 1 0
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
1 1 1 1 1 1 0
0 0 0 0 0 0 0
1 1 1 1 1 1 1

-------------
--------------
--------------

1 1 1 1 1 1 1
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
< --- moves here

Well this is all for now, I hope it interesting and sorry again for my English.






__________________________________________

My Blog
https://misterelectronico.wordpress.com/2015/12/24/programas-creados-con-arduino/

.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
slavvo67

Joined: 12 Oct 2012
Posts: 1035
Location: The other Mr. 305

PostPosted: Sat 23 Jan 2016, 16:08    Post subject:  

Confirmed; not working in QU 6.2.1
Back to top
View user's profile Send private message 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 16:40    Post subject: That is exactly what is not working?  

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/2015/12/24/programas-creados-con-arduino/

Last edited by mister_electronico on Fri 29 Jan 2016, 15:09; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 17:15    Post subject: the scripts  

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:

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:

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:
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/2015/12/24/programas-creados-con-arduino/

Last edited by mister_electronico on Fri 29 Jan 2016, 15:10; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 18:05    Post subject: Open Source.  

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/2015/12/24/programas-creados-con-arduino/

Last edited by mister_electronico on Fri 29 Jan 2016, 15:10; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
kjdixo

Joined: 13 Sep 2009
Posts: 105

PostPosted: Sat 23 Jan 2016, 19:10    Post subject:  

Very good
Thanks
It works.
See attached image.
What files and folders are installed by the pet in your first post please?
mister_e.jpg
 Description   
 Filesize   58.74 KB
 Viewed   250 Time(s)

mister_e.jpg

Back to top
View user's profile Send private message 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 19:21    Post subject: Yes...  

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/2015/12/24/programas-creados-con-arduino/

Last edited by mister_electronico on Fri 29 Jan 2016, 15:11; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
kjdixo

Joined: 13 Sep 2009
Posts: 105

PostPosted: Sat 23 Jan 2016, 19:24    Post subject:  

And the scrolling led display works too.
dfb.png
 Description   
 Filesize   23.62 KB
 Viewed   244 Time(s)

dfb.png

Back to top
View user's profile Send private message 
kjdixo

Joined: 13 Sep 2009
Posts: 105

PostPosted: Sat 23 Jan 2016, 19:28    Post subject:  

I am using quirky puppy tahr 6.05
Back to top
View user's profile Send private message 
mister_electronico


Joined: 20 Jan 2008
Posts: 929
Location: Asturias_ España

PostPosted: Sat 23 Jan 2016, 19:29    Post subject: Thanks  

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/2015/12/24/programas-creados-con-arduino/

Last edited by mister_electronico on Fri 29 Jan 2016, 15:11; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger 
Display posts from previous:   Sort by:   
Page 1 of 5 [68 Posts]   Goto page: 1, 2, 3, 4, 5 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1232s ][ Queries: 12 (0.0087s) ][ GZIP on ]