Electgpl

PIC - Matrix 8x8 Navidad

Dec 19th, 2015
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.98 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 EstNavidad[16][8]={                      //Vector animado
  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. };
  43. byte const bitMask[8]={1,2,4,8,16,32,64,128};      //Mascara
  44. int i,j,k,x;                                       //Variables contadores
  45. void fraseNavidad(int1 Neg){
  46.    for(i=0;i<LARGO_FN+8;i++){                      //Recorrido de tabla
  47.       for(k=0;k<20;k++){                           //Refresco de matriz
  48.          for(j=0;j<8;j++){                         //Barrido de columnas
  49.             output_a(~bitMask[j]);                 //Columnas ponderadas
  50.             if(Neg)                                //Negativo
  51.                output_c(~FelizNavidad[j+i]);       //Desplazamiento de tabla
  52.             else                                   //Directo
  53.                output_c(FelizNavidad[j+i]);        //Desplazamiento de tabla
  54.             delay_us(500);                         //Demora de multiplexado
  55.          }  
  56.       }
  57.    }
  58. }
  59. void animNavidad(){
  60.    for(i=0;i<16;i++){                              //Cambia de subVector
  61.       for(k=0;k<30;k++){                           //Persistencia
  62.          for(j=0;j<8;j++){                         //Barrido de columnas
  63.             output_a(~bitMask[j]);                 //Columnas ponderadas
  64.             output_c(EstNavidad[i][j]);            //Desplazamiento de tabla
  65.             delay_us(600);                         //Demora de multiplexado
  66.          }  
  67.       }
  68.    }
  69. }  
  70. void dibujoArbol(int1 Neg){
  71.    for(k=0;k<50;k++){                              //Persistencia
  72.       for(j=0;j<8;j++){                            //Barrido de filas y columnas
  73.          output_a(~bitMask[j]);                    //Columnas ponderadas
  74.          if(Neg)                                   //Negativo
  75.             output_c(~ArbolNavidad[j]);            //Desplazamiento de tabla
  76.          else                                      //Directo
  77.             output_c(ArbolNavidad[j]);             //Desplazamiento de tabla
  78.          delay_us(700);                            //Demora de multiplexado
  79.       }  
  80.    }  
  81. }
  82. void main(){    
  83.    while(TRUE){                                    //Funcion Principal Repetitiva
  84.       for(x=0;x<3;x++){                            //Arbol de Navidad 3 veces
  85.          dibujoArbol(FALSE);                       //Arbol de Navidad
  86.          dibujoArbol(TRUE);                        //Arbol de Navidad Invertido
  87.       }
  88.       fraseNavidad(FALSE);                         //Frase de Navidad
  89.       for(x=0;x<3;x++){                            //Arbol de Navidad 3 veces
  90.          dibujoArbol(FALSE);                       //Arbol de Navidad
  91.          dibujoArbol(TRUE);                        //Arbol de Navidad Invertido
  92.       }
  93.       for(x=0;x<3;x++){                            //Animacion de Navidad 3 veces
  94.          animNavidad();                            //Animacion de Navidad
  95.       }      
  96.       fraseNavidad(TRUE);                          //Frase de Navidad Invertida
  97.    }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment