Permalink
Browse files

init

  • Loading branch information...
0 parents commit e9468cc21a8ca7061aeae422e106bca033f74fbd hideyukisaito committed Mar 2, 2012
1,356 Doxyfile

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,90 @@
+/* Copyright (c) 2009 by Alex Leone <acleone ~AT~ gmail.com>
+
+ This file is part of the Arduino TLC5940 Library.
+
+ The Arduino TLC5940 Library is free software: you can redistribute it
+ and/or modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ The Arduino TLC5940 Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with The Arduino TLC5940 Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef TLC5940_H
+#define TLC5940_H
+
+/** \file
+ Tlc5940 library header file. */
+
+#include <stdint.h>
+#include "tlc_config.h"
+
+#ifdef TLC_ATMEGA_8_H
+
+/** Enables the Timer1 Overflow interrupt, which will fire after an XLAT
+ pulse */
+#define set_XLAT_interrupt() TIFR |= _BV(TOV1); TIMSK = _BV(TOIE1)
+/** Disables any Timer1 interrupts */
+#define clear_XLAT_interrupt() TIMSK = 0
+
+#else
+
+/** Enables the Timer1 Overflow interrupt, which will fire after an XLAT
+ pulse */
+#define set_XLAT_interrupt() TIFR1 |= _BV(TOV1); TIMSK1 = _BV(TOIE1)
+/** Disables any Timer1 interrupts */
+#define clear_XLAT_interrupt() TIMSK1 = 0
+
+#endif
+
+/** Enables the output of XLAT pulses */
+#define enable_XLAT_pulses() TCCR1A = _BV(COM1A1) | _BV(COM1B1)
+/** Disables the output of XLAT pulses */
+#define disable_XLAT_pulses() TCCR1A = _BV(COM1B1)
+
+extern volatile uint8_t tlc_needXLAT;
+extern volatile void (*tlc_onUpdateFinished)(void);
+extern uint8_t tlc_GSData[NUM_TLCS * 24];
+
+/** The main Tlc5940 class for the entire library. An instance of this class
+ will be preinstantiated as Tlc. */
+class Tlc5940
+{
+ public:
+ void init(uint16_t initialValue = 0);
+ void clear(void);
+ uint8_t update(void);
+ void set(TLC_CHANNEL_TYPE channel, uint16_t value);
+ uint16_t get(TLC_CHANNEL_TYPE channel);
+ void setAll(uint16_t value);
+#if VPRG_ENABLED
+ void setAllDC(uint8_t value);
+ void setDC(TLC_CHANNEL_TYPE channel, uint8_t dc);
+ uint8_t getDC(TLC_CHANNEL_TYPE channel);
+ void updateDC();
+#endif
+#if XERR_ENABLED
+ uint8_t readXERR(void);
+#endif
+
+};
+
+void tlc_shift8_init(void);
+void tlc_shift8(uint8_t byte);
+
+#if VPRG_ENABLED
+void tlc_dcModeStart(void);
+void tlc_dcModeStop(void);
+#endif
+
+// for the preinstantiated Tlc variable.
+extern Tlc5940 Tlc;
+
+#endif
+
@@ -0,0 +1,48 @@
+2009-05-07
+ - Added support for the Arduino Mega
+
+2009-04-19
+ - Bug fix in tlc_fades.h (incrementing a pointer after removing something
+ from the fadeBuffer array). Also tlc_updateFades() will wait till after
+ an update if it's just removed the last fade.
+ - Updated the core function documentation.
+
+2009-03-05
+ - Fixed the missing pin definitions for the ATmega328p
+
+2009-02-16
+ - Added tlc_servos.h and example (thank you Steve Pomeroy)
+ - Cleaned up some older documentation
+ - Added trailing newlines to c, h, cpp, and pde files
+
+2009-02-03
+ - Added support for the Sanguino (ATmega xx4 series)
+ - Added support for the ATmega 8
+ - Moved the project to Google Code:
+ http://code.google.com/p/tlc5940arduino/
+ - Fixed a bug in tlc_fades.h: assignment of struct arrays
+ - Cleaned up the whitespace in the library: 4 spaces instead of tabs
+
+2009-01-25
+ - Added tlc_fades.h
+ - Added include "tlc_config.h" to Tlc5940.h so it's not required
+ in the sketch
+ - Added Tlc.setAll(value)
+ - Changed a few for loops in Tlc5940.cpp: used *p++ instead of having
+ p++ in the increment section of the for loop; changed to while loops
+
+2008-11-26
+ - Tlc.init() sets all channels to zero and updates.
+ - Added TLC_PWM_PERIOD and TLC_GSCLK_PERIOD to tlc_config.h
+ - Added TLC_CHANNEL_TYPE to tlc_config.h - Adds support for up to 4096 TLCs.
+ (if TLC_CHANNEL_TYPE is uint16_t)
+ - Changed the examples to use TLC_CHANNEL_TYPE
+ - set DATA_TRANSFER_MODE default to TLC_SPI
+
+2008-11-11
+ - Added tlc_animations.h and examples
+ - Fixed SPI mode - (don't use enums as constants
+ "#if A == 1" doesn't work)
+
+2008-10-31
+ - Initial Release
Binary file not shown.
@@ -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();
+ }
+
+
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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);
+
+ }
+
+}
+
@@ -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,
+};
+
Oops, something went wrong.

0 comments on commit e9468cc

Please sign in to comment.