gif2led tool for Led matrix in Ruby

Description

This gif2led project is used for generating C header file for LED matrix (5x7/8x8/10x8or more led matrix) from an animated gif file. It is primary designed for output an AVR C header file, but you can modify it for your own purpose.

Requirement

This program is written in Ruby language and using the great Rmagick library to manipulate the animated gif file. It works on Debian Linux, but it should be work with Mac OS X and also MS Windows.

To create the animated gif, I used the Macromedia Flash, it allows you to interpolate some simple animations.

Download

Demo Flash file: pattern.fla

Demo AVR source codes (using AVRtiny13, 4017 and 10x8 led matrix): gif2led_avr_sample.tar.gz or gif2led_avr_sample.zip

gif2led release 1.0: gif2led-release-1_0.tar.gz or gif2led-release-1_0.zip

You can also go to rubyforge project page, http://rubyforge.org/projects/gif2led/

Demonstration

Prepare the animated gif, please make sure the frame 0 is led matrix pattern for calibration in which the leds are all ON. The program would calcuate the LED size, e.g. 5x7 matrix or 8x8 matrix. Here is my animated gif file:




shell>ruby gif2led.rb pattern.gif 20 > pattern.h #The generated pattern.h: //selected ratio is 20.0% //Cal result: LED Matrix (row*col) = (10*8) #include const unsigned char pattern[63][10] PROGMEM = { //Frame 0 {0x42,0x00,0xa5,0x00,0x84,0x21,0x00,0x42,0x21,0x84} //Frame 1 ,{0x00,0xa5,0x00,0x84,0x21,0x00,0x42,0x21,0x84,0x42} //Frame 2 ,{0xa5,0x00,0x84,0x21,0x00,0x42,0x21,0x84,0x42,0x00} //Frame 3 ,{0x00,0x84,0x21,0x00,0x42,0x21,0x84,0x42,0x00,0xa5} //Frame 4 ,{0x84,0x21,0x00,0x42,0x21,0x84,0x42,0x00,0xa5,0x00} //Frame 5 ,{0x21,0x00,0x42,0x21,0x84,0x42,0x00,0xa5,0x00,0x00} //Frame 6 ,{0x00,0x42,0x21,0x84,0x42,0x00,0xa5,0x00,0x00,0x00} //Frame 7 ,{0x42,0x21,0x84,0x42,0x00,0xa5,0x00,0x00,0x00,0x00} //Frame 8 ,{0x21,0x84,0x42,0x00,0xa5,0x00,0x00,0x00,0x00,0x00} //Frame 9 ,{0x84,0x42,0x00,0xa5,0x00,0x00,0x00,0x00,0x00,0x00} //Frame 10 ,{0x42,0x00,0xa5,0x00,0x00,0x00,0x00,0x00,0x00,0x18} //Frame 11 ,{0x00,0xa5,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x3c} //Frame 12 ,{0x24,0x00,0x00,0x00,0x18,0x18,0x3c,0x18,0x00,0x00} //Frame 13 ,{0x00,0x00,0x18,0x18,0x3c,0x18,0x00,0x00,0x00,0x00} //Frame 14 ,{0x00,0x66,0x18,0x18,0x3c,0x18,0x00,0x00,0x00,0x00} //Frame 15 ,{0x00,0x66,0x99,0x99,0xbd,0x99,0x00,0x00,0x00,0x00} //Frame 16 ,{0x00,0x66,0x99,0x99,0xbd,0x99,0x42,0x24,0x18,0x00} //Frame 17 ,{0x00,0x66,0xff,0x99,0xbd,0x99,0x42,0x24,0x18,0x00} //Frame 18 ,{0x00,0x66,0xff,0xff,0xbd,0x99,0x42,0x24,0x18,0x00} //Frame 19 ,{0x00,0x66,0xff,0xff,0xff,0x99,0x42,0x24,0x18,0x00} //Frame 20 ,{0x00,0x66,0xff,0xff,0xff,0xff,0x42,0x24,0x18,0x00} //Frame 21 ,{0x00,0x66,0xff,0xff,0xff,0xff,0x7e,0x24,0x18,0x00} //Frame 22 ,{0x00,0x66,0xff,0xff,0xff,0xff,0x7e,0x3c,0x18,0x00} //Frame 23 ,{0x00,0x66,0x99,0x81,0x81,0x81,0x42,0x24,0x18,0x00} //Frame 24 ,{0x00,0x66,0xff,0xff,0xff,0xff,0x7e,0x3c,0x18,0x00} //Frame 25 ,{0x00,0x66,0x99,0x81,0x81,0x81,0x42,0x24,0x18,0x00} //Frame 26 ,{0x00,0x66,0xff,0xff,0xff,0xff,0x7e,0x3c,0x18,0x00} //Frame 27 ,{0x00,0x66,0x99,0x81,0x81,0x81,0x42,0x24,0x18,0x00} //Frame 28 ,{0x00,0x66,0x66,0x42,0x42,0x42,0x42,0x24,0x18,0x00} //Frame 29 ,{0x00,0x66,0x66,0x42,0x42,0x42,0x42,0x3c,0x18,0x00} //Frame 30 ,{0x00,0x66,0x66,0x66,0x42,0x42,0x42,0x3c,0x18,0x00} //Frame 31 ,{0x00,0x66,0x66,0x66,0x66,0x42,0x42,0x3c,0x18,0x00} //Frame 32 ,{0x00,0x66,0x66,0x66,0x66,0x66,0x42,0x3c,0x18,0x00} //Frame 33 ,{0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00} //Frame 34 ,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} //Frame 35 ,{0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00} //Frame 36 ,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} //Frame 37 ,{0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00} //Frame 38 ,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} //Frame 39 ,{0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00} //Frame 40 ,{0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00} //Frame 41 ,{0x00,0x00,0x66,0x66,0x00,0x66,0x66,0x3c,0x18,0x00} //Frame 42 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x3c,0x18,0x00} //Frame 43 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x42,0x3c,0x18,0x00} //Frame 44 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x42,0x24,0x18,0x00} //Frame 45 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x7e,0x24,0x18,0x00} //Frame 46 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x42,0x24,0x18,0x00} //Frame 47 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x7e,0x24,0x18,0x00} //Frame 48 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x42,0x24,0x18,0x00} //Frame 49 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x42,0x24,0x18,0x42} //Frame 50 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x42,0x66,0x18,0xa5} //Frame 51 ,{0x00,0x00,0x66,0x66,0x00,0x00,0x42,0x24,0xbd,0x00} //Frame 52 ,{0x00,0x00,0x66,0x66,0x42,0x00,0xe7,0x24,0x9c,0x21} //Frame 53 ,{0x00,0x00,0x66,0x66,0xa5,0x00,0x46,0x25,0x18,0x42} //Frame 54 ,{0x00,0x42,0x66,0xe7,0x00,0x84,0x63,0x24,0x5a,0x21} //Frame 55 ,{0x00,0xa5,0x66,0xe6,0x21,0x00,0x42,0x25,0x9c,0x42} //Frame 56 ,{0x00,0x84,0x67,0x66,0x42,0x21,0x46,0x66,0x18,0x24} //Frame 57 ,{0x84,0x21,0x00,0x42,0x21,0x84,0x42,0x00,0xa5,0x00} //Frame 58 ,{0x66,0x42,0x21,0xc6,0x66,0x18,0xa5,0x00,0x00,0x00} //Frame 59 ,{0x00,0x84,0x42,0x24,0xbd,0x00,0x00,0x00,0x00,0x00} //Frame 60 ,{0xc6,0x66,0x18,0xa5,0x00,0x00,0x00,0x00,0x00,0x00} //Frame 61 ,{0x24,0xbd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} //Frame 62 ,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} }; #define MAX_FRAME 63 #define ROWS 10