Advertisement
Electgpl

PIC - Matrix 8x8 Navidad Ani

Dec 20th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.79 KB | None | 0 0
  1. #include <16F883.h>
  2. #use delay(int=4000000)
  3. #define LARGO_FN 79                                //Longitud de Frase de Navidad
  4. int const FelizNavidad[LARGO_FN+16]={              //Vector de Frase de Navidad
  5. 0,0,0,0,0,0,0,0,                                   //    8 espacios          
  6. 0x7F, 0x09, 0x09, 0x01, 0x01, 0x00,                // F
  7. 0x38, 0x54, 0x54, 0x54, 0x18, 0x00,                // e
  8. 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00,                // l
  9. 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00,                // i
  10. 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00,                // z
  11. 0x00, 0x00, 0x00,                                  //    3 espacios
  12. 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00,                // N
  13. 0x20, 0x54, 0x54, 0x54, 0x78, 0x00,                // a
  14. 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00,                // v
  15. 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00,                // i
  16. 0x38, 0x44, 0x44, 0x48, 0x7F, 0x00,                // d
  17. 0x20, 0x54, 0x54, 0x54, 0x78, 0x00,                // a
  18. 0x38, 0x44, 0x44, 0x48, 0x7F, 0x00,                // d
  19. 0x00, 0x5F, 0x00, 0x00,                            // !
  20. 0,0,0,0,0,0,0,0,                                   //    8 espacios  
  21. };
  22. int const ArbolNavidad[8]={                        //Vector del dibujo Arbol
  23. 0x20, 0x30, 0x3C, 0xFF, 0xFF, 0x3C, 0x30, 0x20
  24. };
  25. int const EstNavidad1[25][8]={                     //Vector animado 1
  26. {0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81},
  27. {0x02, 0xc2, 0x24, 0x18, 0x18, 0x24, 0x43, 0x40},
  28. {0x04, 0x42, 0xa4, 0x18, 0x18, 0x25, 0x42, 0x20},
  29. {0x08, 0x04, 0x64, 0x98, 0x19, 0x26, 0x20, 0x10},
  30. {0x30, 0x08, 0x25, 0x59, 0x9a, 0xa4, 0x10, 0x0c},
  31. {0xe1, 0x11, 0x09, 0x3a, 0x5c, 0x90, 0x88, 0x87},
  32. {0x06, 0xf2, 0x8a, 0x3a, 0x5c, 0x51, 0x4f, 0x60},
  33. {0x08, 0x34, 0x4a, 0xba, 0x5d, 0x52, 0x2c, 0x10},
  34. {0x00, 0x18, 0x3c, 0x7e, 0x7e, 0x3c, 0x18, 0x00},
  35. {0x00, 0x3c, 0x34, 0x3c, 0x3c, 0x34, 0x3c, 0x00},
  36. {0x78, 0x3c, 0xf7, 0x3c, 0x3c, 0xf7, 0x3c, 0x78},
  37. {0x1e, 0xbc, 0x77, 0x3c, 0x3c, 0x77, 0xbc, 0x1e},
  38. {0x78, 0x3c, 0xf7, 0x3c, 0x3c, 0xf7, 0x3c, 0x78},
  39. {0x1e, 0xbc, 0x77, 0x3c, 0x3c, 0x77, 0xbc, 0x1e},
  40. {0x78, 0x3c, 0xf7, 0x3c, 0x3c, 0xf7, 0x3c, 0x78},
  41. {0x1e, 0xbc, 0x77, 0x3c, 0x3c, 0x77, 0xbc, 0x1e},
  42. {0x00, 0x16, 0x26, 0x20, 0x20, 0x26, 0x16, 0x00},
  43. {0x00, 0x16, 0x26, 0x40, 0x40, 0x26, 0x16, 0x00},
  44. {0x00, 0x16, 0x26, 0xc0, 0xc0, 0x26, 0x16, 0x00},
  45. {0x00, 0x16, 0x26, 0x40, 0x40, 0x26, 0x16, 0x00},
  46. {0x00, 0x16, 0x26, 0x20, 0x20, 0x26, 0x16, 0x00},
  47. {0x00, 0x16, 0x26, 0x40, 0x40, 0x26, 0x16, 0x00},
  48. {0x00, 0x16, 0x26, 0xc0, 0xc0, 0x26, 0x16, 0x00},
  49. {0x00, 0x16, 0x26, 0x40, 0x40, 0x26, 0x16, 0x00},
  50. {0x00, 0x16, 0x26, 0x20, 0x20, 0x26, 0x16, 0x00}
  51. };
  52. int const EstNavidad2[11][8]={                     //Vector animado 2
  53. {0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00},
  54. {0x00, 0x00, 0x10, 0x1c, 0x38, 0x08, 0x00, 0x00},
  55. {0x00, 0x10, 0x18, 0x3e, 0x7c, 0x18, 0x08, 0x00},
  56. {0x00, 0x14, 0x58, 0x3e, 0x7c, 0x1a, 0x28, 0x00},
  57. {0x10, 0x56, 0x58, 0x3f, 0xfc, 0x1a, 0x6a, 0x08},
  58. {0x91, 0x56, 0x58, 0x3f, 0xfc, 0x1a, 0x6a, 0x89},
  59. {0x10, 0x56, 0x58, 0x3f, 0xfc, 0x1a, 0x6a, 0x08},
  60. {0x00, 0x14, 0x58, 0x3e, 0x7c, 0x1a, 0x28, 0x00},
  61. {0x00, 0x10, 0x18, 0x3e, 0x7c, 0x18, 0x08, 0x00},
  62. {0x00, 0x00, 0x10, 0x1c, 0x38, 0x08, 0x00, 0x00},
  63. {0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00}
  64. };
  65. int const EstNavidad3[7][8]={                     //Vector animado 3
  66. {0x99, 0x5a, 0x3c, 0xff, 0xff, 0x3c, 0x5a, 0x99},
  67. {0x18, 0x5a, 0x3c, 0xff, 0xff, 0x3c, 0x5a, 0x18},
  68. {0x18, 0x18, 0x3c, 0xff, 0xff, 0x3c, 0x18, 0x18},
  69. {0x18, 0x18, 0x18, 0xff, 0xff, 0x18, 0x18, 0x18},
  70. {0x18, 0x18, 0x3c, 0xff, 0xff, 0x3c, 0x18, 0x18},
  71. {0x18, 0x5a, 0x3c, 0xff, 0xff, 0x3c, 0x5a, 0x18},
  72. {0x99, 0x5a, 0x3c, 0xff, 0xff, 0x3c, 0x5a, 0x99}
  73. };
  74. byte const bitMask[8]={1,2,4,8,16,32,64,128};      //Mascara
  75. int i,j,k,x;                                       //Variables contadores
  76. void fraseNavidad(int1 Neg){
  77.    for(i=0;i<LARGO_FN+8;i++){                      //Recorrido de tabla
  78.       for(k=0;k<20;k++){                           //Refresco de matriz
  79.          for(j=0;j<8;j++){                         //Barrido de columnas
  80.             output_a(~bitMask[j]);                 //Columnas ponderadas
  81.             if(Neg)                                //Negativo
  82.                output_c(~FelizNavidad[j+i]);       //Desplazamiento de tabla
  83.             else                                   //Directo
  84.                output_c(FelizNavidad[j+i]);        //Desplazamiento de tabla
  85.             delay_us(350);                         //Demora de multiplexado
  86.          }  
  87.       }
  88.    }
  89. }
  90. void animNavidad1(){
  91.    for(i=0;i<25;i++){                              //Cambia de subVector
  92.       for(k=0;k<30;k++){                           //Persistencia
  93.          for(j=0;j<8;j++){                         //Barrido de columnas
  94.             output_a(~bitMask[j]);                 //Columnas ponderadas
  95.             output_c(EstNavidad1[i][j]);           //Desplazamiento de tabla
  96.             delay_us(600);                         //Demora de multiplexado
  97.          }  
  98.       }
  99.    }
  100. }  
  101. void animNavidad2(){
  102.    for(i=0;i<11;i++){                              //Cambia de subVector
  103.       for(k=0;k<30;k++){                           //Persistencia
  104.          for(j=0;j<8;j++){                         //Barrido de columnas
  105.             output_a(~bitMask[j]);                 //Columnas ponderadas
  106.             output_c(EstNavidad2[i][j]);           //Desplazamiento de tabla
  107.             delay_us(600);                         //Demora de multiplexado
  108.          }  
  109.       }
  110.    }
  111. }  
  112. void animNavidad3(){
  113.    for(i=0;i<7;i++){                               //Cambia de subVector
  114.       for(k=0;k<30;k++){                           //Persistencia
  115.          for(j=0;j<8;j++){                         //Barrido de columnas
  116.             output_a(~bitMask[j]);                 //Columnas ponderadas
  117.             output_c(EstNavidad3[i][j]);           //Desplazamiento de tabla
  118.             delay_us(600);                         //Demora de multiplexado
  119.          }  
  120.       }
  121.    }
  122. }  
  123. void dibujoArbol(int1 Neg){
  124.    for(k=0;k<50;k++){                              //Persistencia
  125.       for(j=0;j<8;j++){                            //Barrido de filas y columnas
  126.          output_a(~bitMask[j]);                    //Columnas ponderadas
  127.          if(Neg)                                   //Negativo
  128.             output_c(~ArbolNavidad[j]);            //Desplazamiento de tabla
  129.          else                                      //Directo
  130.             output_c(ArbolNavidad[j]);             //Desplazamiento de tabla
  131.          delay_us(700);                            //Demora de multiplexado
  132.       }  
  133.    }  
  134. }
  135. void main(){    
  136.    while(TRUE){                                    //Funcion Principal Repetitiva
  137.       for(x=0;x<6;x++){                            //Animacion de Navidad 3 veces
  138.          animNavidad2();                           //Animacion de Navidad
  139.       }
  140.       for(x=0;x<10;x++){                           //Animacion de Navidad 3 veces
  141.          animNavidad3();                           //Animacion de Navidad
  142.       }      
  143.       for(x=0;x<3;x++){                            //Arbol de Navidad 3 veces
  144.          dibujoArbol(FALSE);                       //Arbol de Navidad
  145.          dibujoArbol(TRUE);                        //Arbol de Navidad Invertido
  146.       }
  147.       fraseNavidad(FALSE);                         //Frase de Navidad
  148.       for(x=0;x<3;x++){                            //Arbol de Navidad 3 veces
  149.          dibujoArbol(FALSE);                       //Arbol de Navidad
  150.          dibujoArbol(TRUE);                        //Arbol de Navidad Invertido
  151.       }
  152.       for(x=0;x<3;x++){                            //Animacion de Navidad 3 veces
  153.          animNavidad1();                           //Animacion de Navidad
  154.       }      
  155.       fraseNavidad(TRUE);                          //Frase de Navidad Invertida
  156.    }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement