Import Tlc5940 version r014_2

This commit is contained in:
PaulStoffregen
2014-06-07 06:33:39 -07:00
commit d765d114e0
31 changed files with 4609 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,86 @@
/*
* First Attempt at generating the TLC output code from an image.
* Run this with "java AnimationCreator"
* It will read any image file in the current directory and create an animation for the TLC library.
*
* Right now this only works with 1 TLC with 16 LEDS connected to it, where
* output0 is the bottom and output15 is the top.
*
* For best results make your files 16 pixels high and as wide as you want. Each vertical pixel
* corresponds to an LED output.
*
* Alex Leone <acleone ~AT~ gmail.com>, 2008-11-12
*/
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
public class AnimationCreator {
public static void main(String[] args) throws IOException {
if (args.length == 0) {
autoProcess();
}
}
public static void autoProcess() throws IOException {
File currentDirectory = new File (".");
File[] files = currentDirectory.listFiles();
int animationCount = 1;
for (File file : files) {
if (!file.isFile())
continue;
String fileName = file.getName();
String suffix = fileName.substring(fileName.indexOf('.') + 1);
if(!canReadFormat(suffix))
continue;
String baseName = fileName.substring(0, fileName.indexOf('.'));
String varName = "ani_" + baseName.toLowerCase();
String outputName = varName + ".h";
System.out.println("Writing " + outputName);
BufferedImage image = ImageIO.read(file);
PrintStream output = new PrintStream(new File(outputName));
output.println("#define " + varName.toUpperCase() + "_FRAMES " + image.getWidth());
output.println("uint8_t " + varName + "[NUM_TLCS * 24 * " + varName.toUpperCase() + "_FRAMES] PROGMEM = {");
int[] rowRGB = new int[16];
for (int w = 0; w < image.getWidth(); w++) {
for (int h = 0; h < 16; h++) {
rowRGB[h] = image.getRGB(w, 15 - h);
}
parseRow(rowRGB, output);
}
output.println("};");
System.out.println("Wrote " + image.getWidth() + " frames to " + outputName);
animationCount++;
}
}
// Returns true if the specified format name can be read
public static boolean canReadFormat(String formatName) {
Iterator<ImageReader> iter = ImageIO.getImageReadersByFormatName(formatName);
return iter.hasNext();
}
public static double rgbToGrayscaleIntensity(int rgb) {
Color c = new Color(rgb);
return 0.2989 * c.getRed() + 0.5870 * c.getGreen() + 0.1140 * c.getBlue();
}
public static void parseRow(int[] rowRGB, PrintStream output) {
output.print("\t");
for (int i = rowRGB.length - 1; i >= 0; i -= 2) {
int a = (255 - (int)Math.round(rgbToGrayscaleIntensity(rowRGB[i])));
int b = (255 - (int)Math.round(rgbToGrayscaleIntensity(rowRGB[i - 1])));
output.print(((a >> 4) & 0xFF) + "," + (((a << 4) | (b >> 8)) & 0xFF) + "," + (b & 0xFF) + ",");
//System.out.print(
// "GS_DUO(" + (255 - Math.round(rgbToGrayscaleIntensity(rowRGB[i]))) + "," +
// (255 - Math.round(rgbToGrayscaleIntensity(rowRGB[i - 1]))) + "),");
}
output.println();
}
}

Binary file not shown.

View File

@@ -0,0 +1,52 @@
/*
Writes "Ardunio" with Persistance of Vision (POV) with 16 LEDs (output 0
is on bottom, output 15 is top). The animation below doesn't work with
more than 1 TLC.
I generated the animation with the included java code:
<arduino folder>/hardware/libraries/Tlc5940/examples/BasicAnimations
To use the code, run
java AnimationCreator
in the folder above and it will parse all images in the folder to
.h files. For best results use images that are 16 pixels high.
See the BasicUse example for hardware setup.
Alex Leone <acleone ~AT~ gmail.com>, 2009-02-03 */
#include "Tlc5940.h"
#include "tlc_animations.h"
#include "ani_arduino.h"
void setup()
{
Tlc.init();
}
void loop()
{
// checks to see if the animation is finished playing
if (!tlc_onUpdateFinished) {
delay(100);
/*
void tlc_playAnimation(prog_uint8_t *animation, uint16_t frames,
uint16_t periodsPerFrame);
periods per frame is PWM periods, 1.024ms per frame (0 is valid - this
will play the animation as fast as possible).
Plays an animation in the "background".
Don't call Tlc.update() while this is running.
You can check if this is done with !tlc_onUpdateFinished */
tlc_playAnimation(ani_arduino, ANI_ARDUINO_FRAMES, 3);
// If you don't want to do anything until it's finished, use:
// while (!tlc_onUpdateFinished);
}
}

View File

@@ -0,0 +1,84 @@
#define ANI_ARDUINO_FRAMES 80
uint8_t ani_arduino[NUM_TLCS * 24 * ANI_ARDUINO_FRAMES] PROGMEM = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,6,176,206,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,65,10,64,247,15,240,255,
0,0,0,0,0,0,0,0,0,0,0,0,1,160,122,13,192,255,15,240,254,11,192,89,
0,0,0,0,0,0,0,0,4,4,240,179,15,192,255,15,240,255,8,32,33,0,0,0,
0,0,0,0,0,37,8,128,231,15,240,255,15,144,169,15,240,255,0,0,0,0,0,0,
0,0,94,12,16,255,15,240,255,13,64,113,1,48,0,15,240,255,0,0,0,0,0,0,
0,0,255,15,240,243,9,192,56,0,0,0,0,0,0,15,240,255,0,0,0,0,0,0,
0,0,255,15,240,243,9,208,57,0,0,0,0,0,0,15,240,255,0,0,0,0,0,0,
0,0,93,12,0,255,15,240,255,13,80,114,1,64,0,15,240,255,0,0,0,0,0,0,
0,0,0,0,0,36,8,112,230,15,240,255,15,144,170,15,240,255,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,4,4,224,178,15,192,255,15,240,255,8,32,32,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,1,144,121,13,176,255,15,240,254,11,160,86,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,10,48,246,15,240,255,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,6,160,206,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,2,9,224,248,7,32,24,0,16,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,109,15,240,115,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,208,15,240,25,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,248,15,240,1,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,253,15,240,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,16,90,11,176,237,15,192,237,11,176,90,0,16,0,
0,0,0,0,0,0,0,0,6,11,0,255,15,240,255,15,240,255,15,240,255,11,16,6,
0,0,0,0,0,0,0,0,125,15,240,247,7,48,26,0,48,26,7,16,246,15,240,126,
0,0,0,0,0,0,0,0,221,15,240,100,0,0,0,0,0,0,0,0,98,15,240,222,
0,0,0,0,0,0,0,0,250,15,240,14,0,0,0,0,0,0,0,0,13,15,240,249,
0,0,0,0,0,0,0,0,226,15,240,14,0,0,0,0,0,0,0,0,13,15,240,223,
0,0,0,0,0,0,0,0,130,15,240,103,0,0,0,0,0,0,0,0,100,15,240,131,
0,0,0,0,0,0,0,0,5,10,112,248,7,96,27,0,64,27,7,64,247,10,112,6,
15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,255,15,240,255,15,240,255,15,240,253,14,144,173,3,32,0,
0,0,0,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,144,57,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,2,224,201,15,240,186,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,46,15,240,242,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,15,240,246,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,15,240,206,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,111,15,240,102,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,6,32,246,9,80,0,
0,0,0,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
15,240,255,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
15,240,255,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,255,15,240,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,0,9,64,246,6,48,13,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,100,15,240,111,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,208,15,240,24,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,250,15,240,4,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,241,15,240,47,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,186,15,240,202,2,240,3,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,57,15,144,255,15,240,255,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,0,3,32,173,14,144,253,15,240,255,15,240,255,15,240,255,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,73,11,80,235,15,176,235,11,80,74,0,0,0,
0,0,0,0,0,0,0,0,0,8,80,255,15,240,255,15,240,255,15,240,255,8,144,0,
0,0,0,0,0,0,0,0,72,15,240,254,8,128,31,0,64,31,8,128,254,15,240,74,
0,0,0,0,0,0,0,0,179,15,240,137,0,0,0,0,0,0,0,0,136,15,240,181,
0,0,0,0,0,0,0,0,234,15,240,32,0,0,0,0,0,0,0,0,31,15,240,235,
0,0,0,0,0,0,0,0,251,15,240,5,0,0,0,0,0,0,0,0,4,15,240,251,
0,0,0,0,0,0,0,0,234,15,240,33,0,0,0,0,0,0,0,0,32,15,240,235,
0,0,0,0,0,0,0,0,179,15,240,142,0,0,0,0,0,0,0,0,138,15,240,180,
0,0,0,0,0,0,0,0,69,15,240,255,8,224,33,0,80,32,8,176,254,15,240,72,
0,0,0,0,0,0,0,0,0,8,16,255,15,240,255,15,240,255,15,240,255,8,80,0,
0,0,0,0,0,0,0,0,0,0,0,70,11,48,234,15,176,234,11,48,72,0,0,0,
};