This library creates the interface to operate the TLC5940. This device manages 16 PWM outputs.
Embed:
(wiki syntax)
Show/hide line numbers
tlc5940.h
00001 /* 00002 * tlc5940 - Interface to operate TI's IC TLC5940 00003 * Copyright (C) 2010 German Bassi. 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 #ifndef MBED_TLC5940_H 00021 #define MBED_TLC5940_H 00022 00023 #include "mbed.h" 00024 00025 /** TI's TLC5940 interface class 00026 * 00027 * Example: 00028 * @code 00029 * // Turn on all the outputs 00030 * # include "mbed.h" 00031 * # include "tlc5940.h" 00032 * 00033 * int main() { 00034 * int DC_data[2*96]; 00035 * int GS_data[2*16]; 00036 * 00037 * // Dot Correction Values 00038 * for (int i=0; i<2*96; i++) DC_data[i] = 1; 00039 * // Grayscale Values 00040 * for (int i=0; i<2*16; i++) GS_data[i] = 0xFF; 00041 * 00042 * // Create object 00043 * tlc5940 tlc_driver(2, DC_data); 00044 * // Send data 00045 * tlc_driver.send_data(GS_data); 00046 * 00047 * while (1) {} 00048 * } 00049 * @endcode 00050 */ 00051 class tlc5940 { 00052 private: 00053 bool first_cycle_flag; 00054 int GSCLK_counter, data_counter; 00055 int aux_value, aux_ind; 00056 int num_ic; 00057 00058 DigitalOut VPROG; 00059 DigitalOut SIN; 00060 DigitalOut SCLK; 00061 DigitalOut XLAT; 00062 DigitalOut BLANK; 00063 DigitalOut DCPROG; 00064 DigitalOut GSCLK; 00065 00066 DigitalIn SOUT; 00067 DigitalIn XERR; 00068 00069 public: 00070 /** Create a tlc5940 interface object connected to some specifics pins 00071 * 00072 * @param num_ics Number of TLC5940 connected in series 00073 * @param DC_data[] Dot Correction values for initialization 00074 */ 00075 tlc5940 (int num_ics, int DC_data[]); 00076 00077 /** Send the specified set of grayscale values 00078 * 00079 * @param data[] Array of 12-bit Grayscale values for transmission 00080 */ 00081 void send_data (int data[]); 00082 }; 00083 00084 #endif
Generated on Thu Jul 14 2022 21:35:46 by 1.7.2