Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Pointmatrix16x12 mbed
main.cpp
00001 #include "mbed.h" 00002 #include "TLC59711.h" 00003 #define NUM_TLC59711 1 00004 #define t1 10000 00005 00006 TLC59711 tlc(NUM_TLC59711, p7, p5); 00007 Serial pc(USBTX, USBRX); // tx, rx 00008 Serial device(p9, p10); // tx, rx 00009 00010 //Define functions 00011 //====================== 00012 void letter_o(); 00013 void _16_columns(uint16_t col); 00014 void _12_filas(uint16_t f0, uint16_t f1, uint16_t f2, uint16_t f3, uint16_t f4, uint16_t f5, uint16_t f6, uint16_t f7, uint16_t f8, uint16_t f9, uint16_t f10, uint16_t f11); 00015 void fila_off(uint8_t num_tlc); void fila_0(uint8_t num_tlc); void fila_1(uint8_t num_tlc); void fila_2(uint8_t num_tlc); 00016 void fila_3(uint8_t num_tlc); void fila_4(uint8_t num_tlc); void fila_5(uint8_t num_tlc); void fila_6(uint8_t num_tlc); 00017 void fila_7(uint8_t num_tlc); void fila_8(uint8_t num_tlc); void fila_9(uint8_t num_tlc); void fila_10(uint8_t num_tlc); 00018 void fila_11(uint8_t num_tlc); 00019 //====================== 00020 00021 00022 00023 int repit = 8; 00024 uint16_t on = 65535; 00025 uint16_t off = 0; 00026 uint16_t column; 00027 uint8_t column_h, column_l; 00028 uint8_t dato[4]; 00029 00030 00031 int main() 00032 { 00033 device.baud(38400); 00034 00035 while( 1 ) 00036 { 00037 letter_o(); 00038 } 00039 } 00040 00041 00042 void _12_filas(uint8_t n_tlc, uint16_t f0, uint16_t f1, uint16_t f2, uint16_t f3, uint16_t f4, uint16_t f5, uint16_t f6, uint16_t f7, uint16_t f8, uint16_t f9, uint16_t f10, uint16_t f11) 00043 { 00044 uint8_t channel[5]; 00045 switch (n_tlc) 00046 { 00047 case 0: 00048 channel[0] = 0; 00049 channel[1] = 1; 00050 channel[2] = 2; 00051 channel[3] = 3; 00052 break; 00053 case 1: 00054 channel[0] = 4; 00055 channel[1] = 5; 00056 channel[2] = 6; 00057 channel[3] = 7; 00058 break; 00059 default: 00060 break; 00061 } 00062 tlc.setLED(channel[0], f0, f1, f2); 00063 tlc.write(); 00064 tlc.setLED(channel[1], f3, f4, f5); 00065 tlc.write(); 00066 tlc.setLED(channel[2], f6, f7, f8); 00067 tlc.write(); 00068 tlc.setLED(channel[3], f9, f10, f11); 00069 tlc.write(); 00070 } 00071 00072 void _32_columns(uint8_t n_uc, uint16_t col) 00073 { 00074 column_h = (col >> 8); 00075 column_l = col; 00076 device.putc('#'); 00077 device.putc(n_uc); 00078 device.putc(column_h); 00079 device.putc(column_l); 00080 device.putc('%'); 00081 00082 if(device.readable()) { 00083 dato[0] = device.getc(); 00084 if(dato[0] == '#'){ 00085 dato[1] = device.getc(); 00086 dato[2] = device.getc(); 00087 dato[3] = device.getc(); 00088 } 00089 if(dato[1] == 'O' && dato[2] == 'K' && dato[3] == '%') 00090 { 00091 /*pc.printf("Column valid "); 00092 pc.putc(dato[0]); 00093 pc.putc(dato[1]); 00094 pc.putc(dato[2]); 00095 pc.putc(dato[3]); 00096 pc.printf(" "); 00097 pc.putc(column_h, BIN); 00098 pc.putc(column_l, BIN); 00099 pc.printf("\n");*/ 00100 } 00101 else 00102 { 00103 /* Serial.print("Column fail"); 00104 pc.putc(dato[0]); 00105 pc.putc(dato[1]); 00106 pc.putc(dato[2]); 00107 pc.putc(dato[3]); 00108 pc.putc(column_h, BIN); 00109 pc.putc(column_l, BIN); 00110 pc.printf("\n");*/ 00111 } 00112 } 00113 //wait(0.010); 00114 } 00115 00116 void letter_o() 00117 { 00118 for(int j = 0; j<=15; j++) 00119 { 00120 //**** first row ****** 00121 for(double k = 0; k < 16; k++) 00122 { 00123 for(int i =0; i<repit; i++) 00124 { 00125 double n_col = pow(2, k); 00126 uint16_t n_col_bin = n_col; 00127 //fila_0(); 00128 //_16_columns(n_col_bin); 00129 00130 fila_0(0); 00131 _32_columns(0, n_col_bin); 00132 wait_us(t1); 00133 } 00134 } 00135 //**** second row ****** 00136 for(double k = 0; k < 16; k++) 00137 { 00138 for(int i =0; i<repit; i++) 00139 { 00140 double n_col = pow(2, k); 00141 uint16_t n_col_bin = n_col; 00142 fila_1(0); 00143 _32_columns(0,n_col_bin); 00144 wait_us(t1); 00145 } 00146 } 00147 //**** third row ****** 00148 for(double k = 0; k < 16; k++) 00149 { 00150 for(int i =0; i<repit; i++) 00151 { 00152 double n_col = pow(2, k); 00153 uint16_t n_col_bin = n_col; 00154 fila_2(0); 00155 _32_columns(0,n_col_bin); 00156 wait_us(t1); 00157 } 00158 } 00159 //**** fourth row ****** 00160 for(double k = 0; k < 16; k++) 00161 { 00162 for(int i =0; i<repit; i++) 00163 { 00164 double n_col = pow(2, k); 00165 uint16_t n_col_bin = n_col; 00166 fila_3(0); 00167 _32_columns(0,n_col_bin); 00168 wait_us(t1); 00169 } 00170 } 00171 //**** fifth row ****** 00172 for(double k = 0; k < 16; k++) 00173 { 00174 for(int i =0; i<repit; i++) 00175 { 00176 double n_col = pow(2, k); 00177 uint16_t n_col_bin = n_col; 00178 fila_4(0); 00179 _32_columns(0,n_col_bin); 00180 wait_us(t1); 00181 } 00182 } 00183 //**** sixth row ****** 00184 for(double k = 0; k < 16; k++) 00185 { 00186 for(int i =0; i<repit; i++) 00187 { 00188 double n_col = pow(2, k); 00189 uint16_t n_col_bin = n_col; 00190 fila_5(0); 00191 _32_columns(0,n_col_bin); 00192 wait_us(t1); 00193 } 00194 } 00195 //**** seventh row ****** 00196 for(double k = 0; k < 16; k++) 00197 { 00198 for(int i =0; i<repit; i++) 00199 { 00200 double n_col = pow(2, k); 00201 uint16_t n_col_bin = n_col; 00202 fila_6(0); 00203 _32_columns(0, n_col_bin); 00204 wait_us(t1); 00205 } 00206 } 00207 //**** eight row ****** 00208 for(double k = 0; k < 16; k++) 00209 { 00210 for(int i =0; i<repit; i++) 00211 { 00212 double n_col = pow(2, k); 00213 uint16_t n_col_bin = n_col; 00214 fila_7(0); 00215 _32_columns(0, n_col_bin); 00216 wait_us(t1); 00217 } 00218 } 00219 //**** ninth row ****** 00220 for(double k = 0; k < 16; k++) 00221 { 00222 for(int i =0; i<repit; i++) 00223 { 00224 double n_col = pow(2, k); 00225 uint16_t n_col_bin = n_col; 00226 fila_8(0); 00227 _32_columns(0, n_col_bin); 00228 wait_us(t1); 00229 } 00230 } 00231 //**** tenth row ****** 00232 for(double k = 0; k < 16; k++) 00233 { 00234 for(int i =0; i<repit; i++) 00235 { 00236 double n_col = pow(2, k); 00237 uint16_t n_col_bin = n_col; 00238 fila_9(0); 00239 _32_columns(0, n_col_bin); 00240 wait_us(t1); 00241 } 00242 } 00243 //**** eleventh row ****** 00244 for(double k = 0; k < 16; k++) 00245 { 00246 for(int i =0; i<repit; i++) 00247 { 00248 double n_col = pow(2, k); 00249 uint16_t n_col_bin = n_col; 00250 fila_10(0); 00251 _32_columns(0, n_col_bin); 00252 wait_us(t1); 00253 } 00254 } 00255 //**** twelfth column ****** 00256 for(double k = 0; k < 16; k++) 00257 { 00258 for(int i =0; i<repit; i++) 00259 { 00260 double n_col = pow(2, k); 00261 uint16_t n_col_bin = n_col; 00262 fila_11(0); 00263 _32_columns(0, n_col_bin); 00264 wait_us(t1); 00265 } 00266 } 00267 } 00268 } 00269 void fila_off(uint8_t num_tlc) 00270 { 00271 _12_filas(num_tlc,off,off,off,off,off,off,off,off,off,off,off,off); 00272 } 00273 void fila_0(uint8_t num_tlc) 00274 { 00275 _12_filas(num_tlc,on,off,off,off,off,off,off,off,off,off,off,off); 00276 } 00277 void fila_1(uint8_t num_tlc) 00278 { 00279 _12_filas(num_tlc,off,on,off,off,off,off,off,off,off,off,off,off); 00280 } 00281 void fila_2(uint8_t num_tlc) 00282 { 00283 _12_filas(num_tlc,off,off,on,off,off,off,off,off,off,off,off,off); 00284 } 00285 void fila_3(uint8_t num_tlc) 00286 { 00287 _12_filas(num_tlc,off,off,off,on,off,off,off,off,off,off,off,off); 00288 } 00289 void fila_4(uint8_t num_tlc) 00290 { 00291 _12_filas(num_tlc,off,off,off,off,on,off,off,off,off,off,off,off); 00292 } 00293 void fila_5(uint8_t num_tlc) 00294 { 00295 _12_filas(num_tlc,off,off,off,off,off,on,off,off,off,off,off,off); 00296 } 00297 void fila_6(uint8_t num_tlc) 00298 { 00299 _12_filas(num_tlc,off,off,off,off,off,off,on,off,off,off,off,off); 00300 } 00301 void fila_7(uint8_t num_tlc) 00302 { 00303 _12_filas(num_tlc,off,off,off,off,off,off,off,on,off,off,off,off); 00304 } 00305 void fila_8(uint8_t num_tlc) 00306 { 00307 _12_filas(num_tlc,off,off,off,off,off,off,off,off,on,off,off,off); 00308 } 00309 void fila_9(uint8_t num_tlc) 00310 { 00311 _12_filas(num_tlc,off,off,off,off,off,off,off,off,off,on,off,off); 00312 } 00313 void fila_10(uint8_t num_tlc) 00314 { 00315 _12_filas(num_tlc,off,off,off,off,off,off,off,off,off,off,on,off); 00316 } 00317 void fila_11(uint8_t num_tlc) 00318 { 00319 _12_filas(num_tlc,off,off,off,off,off,off,off,off,off,off,off,on); 00320 }
Generated on Wed Jul 20 2022 23:53:03 by
 1.7.2
 1.7.2