Autor Tema: Librería para GLCD de 128x64 para controladores SED1565  (Leído 3999 veces)

0 Usuarios y 2 Visitantes están viendo este tema.

Desconectado SavageChicken

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 931
Librería para GLCD de 128x64 para controladores SED1565
« en: 07 de Noviembre de 2009, 15:08:42 »
Hola Amigos:
Me costó un mundo conseguir una librería para GLCD con este controlador, asique hice la mía juntando algunas funciones de aquí y de allá
Espero les sea útil, incluye laposibilidad de imprimir un texto con caracteres bien chiquitos de 3x5 pixeles.


Código: C++
  1. /////////////////////////////////////////////////////////////////////////
  2. // Conexiones de pines del GLCD GTK-281 de GEM-TECH                    //
  3. // El Patillaje esta indicado abajo, del lado del GLCD                 //
  4. // y del Lado del PIC 18F-4550                                         //
  5. // Sirve para Controladores como el NT7534 y el SED1565                //
  6. // (Tambien puede ocuparse con el GLCD 12864F3,                        //
  7. // Pero el patillaje es distinto)                                      //
  8. //                                                                     //
  9. //  ------------------------------------                               //
  10. //     GLCD GTK-281 --- PIC 18F4550                                    //
  11. //  ------------------------------------                               //
  12. //       17: Reset  <-> A4 :6                                          //
  13. //        4: A0     <-> C2 :17                                         //
  14. //        5: R/W    <-> C1 :16                                         //
  15. //        6: E      <-> C0 :15                                         //
  16. //    7..14: D0..D7 <-> B0..B7 :33..40                                 //
  17. //  ------------------------------------                               //
  18. //                                                                     //
  19. //  Los valores pueden cambiarse con los DEFINE que están más abajo    //
  20. //---------------------------------------------------------------------//
  21. //  > GLCD_clear(color)                                                //
  22. //   "Borra" la pantala, llenando la del color seleccionado.           //
  23. //   color = 0 : puntos apagados                                       //
  24. //   color = 1 : puntos encendidos                                     //
  25. //                                                                     //
  26. //---------------------------------------------------------------------//
  27. //  > GLCD_init(modo)                                                  //
  28. //   Inicializa el GLCD, y debe llamarse ANTES de cualquier otra.      //
  29. //   modo = 0 : GLCD en ON                                             //
  30. //   modo = 1 : GLCD en OFF                                            //
  31. //                                                                     //
  32. //   EN LAS SIGUIENTES FUNCIONES, SIEMPRE SE RESPETA QUE:              //
  33. //   color = 0 : puntos apagados                                       //
  34. //   color = 1 : puntos encendidos                                     //
  35. //   Tambien puede usarse directamente ON / OFF                        //
  36. //                                                                     //
  37. //  > GLCD_pixel(x,y,color)                                            //
  38. //   Dibuja un punto en x,y. 0,0 es la esquina superior izquierda.     //
  39. //                                                                     //
  40. //  > GLCD_line(x1,y1,x2,y2,color)                                     //
  41. //   Dibuja una linea desde (x1,y1) a (x2,y2)                          //
  42. //                                                                     //
  43. //  >GLCD_rectangle (x1,y1,x2,y2,color)                                //
  44. //  Dibuja un rectangulo con esquinas en (x1,y1) y (x2,y2)             //
  45. //                                                                     //
  46. //  >GLCD_box (x1,y1,x2,y2,color)                                      //
  47. //  Dibuja un rectangulo pintado con esquinas en (x1,y1) y (x2,y2)     //
  48. //                                                                     //
  49. //  >GLCD_circle (x1,y1,r,color)                                       //
  50. //  Dibuja un circulo con centro en (x1,y1) y radio R                  //
  51. //                                                                     //
  52. //  >GLCD_text35(x,y,textptr,color)                                    //
  53. // Escribe un texto de pequeñas dimensiones                            //
  54. // (x,y) - Coordenada superior izquierda del primer caracter           //
  55. // textptr - Puntero a una matriz de caracteres del texto a mostrar    //
  56. //                                                                     //
  57. /////////////////////////////////////////////////////////////////////////
  58.  
  59. #include <STDLIB.H>
  60.  
  61. //Pines a usar
  62. #define GLCD_RESET   PIN_C4
  63. #define GLCD_A0      PIN_C2
  64. #define GLCD_RW      PIN_C1
  65. #define GLCD_E       PIN_C0
  66. #define GLCD_TRIS    set_tris_b
  67. #define GLCD_SAL     output_b
  68. #define GLCD_ENT     input_b
  69.  
  70. //Definiciones varias
  71. #define GLCD_WIDTH   128
  72. #define ON  1
  73. #define OFF 0
  74.  
  75. // Declaracion de funciones
  76. void GLCD_Data(BYTE dato);
  77. void GLCD_Command(BYTE dato);
  78. BYTE GLCD_readBYTE();
  79. void GLCD_clear(int1 color);
  80. void GLCD_init(int1 modo);
  81. void GLCD_pixel(int8 x, int8 y, int1 color);
  82. void GLCD_line(int x1, int y1, int x2, int y2, int1 color);
  83. void GLCD_rectangle(int x1, int y1, int x2, int y2, int1 color);
  84. void GLCD_box(int x1, int y1, int x2, int y2, int1 color);
  85. void GLCD_circle(int x1, int y1, int radio, int1 color);
  86. void glcd_text35(int8 x, int8 y, char* textptr, int1 color);
  87.  
  88. const int8 TEXT35[95][5]={
  89.    0b00000000,   0b00000000,   0b00000000,   0b00000000,   0b00000000, //SPACE
  90.    0b01000100,   0b01000100,   0b01000100,   0b00000000,   0b01000100, //!
  91.    0b10101010,   0b10101010,   0b00000000,   0b00000000,   0b00000000, //"
  92.    0b10101010,   0b11101110,   0b10101010,   0b11101110,   0b10101010, //#
  93.    0b01100110,   0b11001100,   0b11001100,   0b01100110,   0b11101110, //$
  94.    0b10101010,   0b00100010,   0b01000100,   0b10001000,   0b10101010, //%
  95.    0b01000100,   0b10101010,   0b01000100,   0b10101010,   0b01100110, //&
  96.    0b01000100,   0b01000100,   0b00000000,   0b00000000,   0b00000000, //'
  97.    0b01000100,   0b10001000,   0b10001000,   0b10001000,   0b01000100, //(
  98.    0b01000100,   0b00100010,   0b00100010,   0b00100010,   0b01000100, //)
  99.    0b00000000,   0b10101010,   0b01000100,   0b10101010,   0b00000000, //*
  100.    0b00000000,   0b01000100,   0b11101110,   0b01000100,   0b00000000, //+
  101.    0b00000000,   0b00000000,   0b00000000,   0b01000100,   0b10001000, //,
  102.    0b00000000,   0b00000000,   0b11101110,   0b00000000,   0b00000000, //-
  103.    0b00000000,   0b00000000,   0b00000000,   0b00000000,   0b01000100, //.
  104.    0b00100010,   0b00100010,   0b01000100,   0b10001000,   0b10001000, ///
  105.    0b11101110,   0b10101010,   0b10101010,   0b10101010,   0b11101110, //0
  106.    0b01000100,   0b11001100,   0b01000100,   0b01000100,   0b11101110, //1
  107.    0b11101110,   0b00100010,   0b11101110,   0b10001000,   0b11101110, //2
  108.    0b11101110,   0b00100010,   0b11101110,   0b00100010,   0b11101110, //3
  109.    0b10101010,   0b10101010,   0b11101110,   0b00100010,   0b00100010, //4
  110.    0b11101110,   0b10001000,   0b11101110,   0b00100010,   0b11101110, //5
  111.    0b11001100,   0b10001000,   0b11101110,   0b10101010,   0b11101110, //6
  112.    0b11101110,   0b00100010,   0b01000100,   0b10001000,   0b10001000, //7
  113.    0b11101110,   0b10101010,   0b11101110,   0b10101010,   0b11101110, //8
  114.    0b11101110,   0b10101010,   0b11101110,   0b00100010,   0b01100110, //9
  115.    0b00000000,   0b01000100,   0b00000000,   0b01000100,   0b00000000, //:
  116.    0b00000000,   0b01000100,   0b00000000,   0b01000100,   0b10001000, //;
  117.    0b00100010,   0b01000100,   0b10001000,   0b01000100,   0b00100010, //<
  118.    0b00000000,   0b11101110,   0b00000000,   0b11101110,   0b00000000, //=
  119.    0b10001000,   0b01000100,   0b00100010,   0b01000100,   0b10001000, //>
  120.    0b11001100,   0b00100010,   0b01100110,   0b00000000,   0b01000100, //?
  121.    0b01000100,   0b10101010,   0b11101110,   0b10001000,   0b01100110, //@
  122.    0b11101110,   0b10101010,   0b11101110,   0b10101010,   0b10101010, //A
  123.    0b11001100,   0b10101010,   0b11101110,   0b10101010,   0b11001100, //B
  124.    0b11101110,   0b10001000,   0b10001000,   0b10001000,   0b11101110, //C
  125.    0b11001100,   0b10101010,   0b10101010,   0b10101010,   0b11001100, //D
  126.    0b11101110,   0b10001000,   0b11101110,   0b10001000,   0b11101110, //E
  127.    0b11101110,   0b10001000,   0b11101110,   0b10001000,   0b10001000, //F
  128.    0b11101110,   0b10001000,   0b10001000,   0b10101010,   0b11101110, //G
  129.    0b10101010,   0b10101010,   0b11101110,   0b10101010,   0b10101010, //H
  130.    0b11101110,   0b01000100,   0b01000100,   0b01000100,   0b11101110, //I
  131.    0b00100010,   0b00100010,   0b00100010,   0b10101010,   0b11101110, //J
  132.    0b10001000,   0b10101010,   0b11001100,   0b11001100,   0b10101010, //K
  133.    0b10001000,   0b10001000,   0b10001000,   0b10001000,   0b11101110, //L
  134.    0b10101010,   0b11101110,   0b11101110,   0b10101010,   0b10101010, //M
  135.    0b00000000,   0b11001100,   0b10101010,   0b10101010,   0b10101010, //N
  136.    0b01000100,   0b10101010,   0b10101010,   0b10101010,   0b01000100, //O
  137.    0b11101110,   0b10101010,   0b11101110,   0b10001000,   0b10001000, //P
  138.    0b01000100,   0b10101010,   0b10101010,   0b11101110,   0b01100110, //Q
  139.    0b11101110,   0b10101010,   0b11001100,   0b11101110,   0b10101010, //R
  140.    0b11101110,   0b10001000,   0b11101110,   0b00100010,   0b11101110, //S
  141.    0b11101110,   0b01000100,   0b01000100,   0b01000100,   0b01000100, //T
  142.    0b10101010,   0b10101010,   0b10101010,   0b10101010,   0b11101110, //U
  143.    0b10101010,   0b10101010,   0b10101010,   0b10101010,   0b01000100, //V
  144.    0b10101010,   0b10101010,   0b11101110,   0b11101110,   0b10101010, //W
  145.    0b00000000,   0b10101010,   0b01000100,   0b01000100,   0b10101010, //X
  146.    0b10101010,   0b10101010,   0b01000100,   0b01000100,   0b01000100, //Y
  147.    0b11101110,   0b00100010,   0b01000100,   0b10001000,   0b11101110, //Z
  148.    0b11101110,   0b10001000,   0b10001000,   0b10001000,   0b11101110, //[
  149.    0b10001000,   0b10001000,   0b01000100,   0b00100010,   0b00100010, //\
  150.    0b11101110,   0b00100010,   0b00100010,   0b00100010,   0b11101110, //]
  151.    0b01000100,   0b10101010,   0b00000000,   0b00000000,   0b00000000, //^
  152.    0b00000000,   0b00000000,   0b00000000,   0b00000000,   0b11101110, //_
  153.    0b10001000,   0b01000100,   0b00000000,   0b00000000,   0b00000000, //`
  154.    0b00000000,   0b01000100,   0b10101010,   0b10101010,   0b01100110, //a
  155.    0b10001000,   0b11001100,   0b10101010,   0b10101010,   0b11001100, //b
  156.    0b00000000,   0b01100110,   0b10001000,   0b10001000,   0b01100110, //c
  157.    0b00100010,   0b01100110,   0b10101010,   0b10101010,   0b01100110, //d
  158.    0b00000000,   0b01000100,   0b10101010,   0b11001100,   0b01100110, //e
  159.    0b01100110,   0b01000100,   0b11101110,   0b01000100,   0b01000100, //f
  160.    0b00000000,   0b01000100,   0b10101010,   0b01100110,   0b11001100, //g
  161.    0b10001000,   0b11001100,   0b10101010,   0b10101010,   0b10101010, //h
  162.    0b01000100,   0b00000000,   0b01000100,   0b01000100,   0b01000100, //i
  163.    0b01000100,   0b00000000,   0b01000100,   0b01000100,   0b10001000, //j
  164.    0b10001000,   0b10001000,   0b10101010,   0b11001100,   0b10101010, //k
  165.    0b01000100,   0b01000100,   0b01000100,   0b01000100,   0b01000100, //l
  166.    0b00000000,   0b11101110,   0b11101110,   0b10101010,   0b10101010, //m
  167.    0b00000000,   0b11001100,   0b10101010,   0b10101010,   0b10101010, //n
  168.    0b00000000,   0b01000100,   0b10101010,   0b10101010,   0b01000100, //o
  169.    0b00000000,   0b11001100,   0b10101010,   0b11001100,   0b10001000, //p
  170.    0b00000000,   0b01100110,   0b10101010,   0b01100110,   0b00100010, //q
  171.    0b00000000,   0b10001000,   0b11101110,   0b10001000,   0b10001000, //r
  172.    0b00000000,   0b01100110,   0b11001100,   0b00100010,   0b11001100, //s
  173.    0b01000100,   0b11101110,   0b01000100,   0b01000100,   0b01000100, //t
  174.    0b00000000,   0b10101010,   0b10101010,   0b10101010,   0b01000100, //u
  175.    0b00000000,   0b10101010,   0b10101010,   0b01000100,   0b01000100, //v
  176.    0b00000000,   0b10101010,   0b10101010,   0b11101110,   0b10101010, //w
  177.    0b00000000,   0b10101010,   0b01000100,   0b01000100,   0b10101010, //x
  178.    0b00000000,   0b10101010,   0b10101010,   0b01100110,   0b11001100, //y
  179.    0b00000000,   0b11101110,   0b01100110,   0b11001100,   0b11101110, //z
  180.    0b00100010,   0b01000100,   0b11001100,   0b01000100,   0b00100010, //{
  181.    0b01000100,   0b01000100,   0b01000100,   0b01000100,   0b01000100, //|
  182.    0b10001000,   0b01000100,   0b01100110,   0b01000100,   0b10001000, //}
  183.    0b00000000,   0b11001100,   0b10101010,   0b00000000,   0b00000000  //~
  184.    };
  185.  
  186. //-----------------------------------------------------------------------
  187. //Escribe un byte en la pantalla
  188. //-----------------------------------------------------------------------
  189. void GLCD_Data(BYTE dato)
  190. {
  191.    output_low (GLCD_RW);   // Modo escritura
  192.    output_high (GLCD_A0);  // Modo escritura
  193.    GLCD_SAL (dato);        // Coloco el dato a escribir
  194.    output_high (GLCD_E);   // Aviso que hay un dato a escribir
  195.    delay_cycles( 2 );      // Espero
  196.    output_low (GLCD_E);    // Termino la escritura del dato
  197.    delay_cycles( 2 );      // Espero
  198. }
  199.  
  200. //-----------------------------------------------------------------------
  201. //Envía un comando a GLCD
  202. //-----------------------------------------------------------------------
  203. void GLCD_Command(BYTE dato)
  204. {
  205.    output_low (GLCD_RW);   // Modo comando
  206.    output_low (GLCD_A0);   // Modo comando
  207.    GLCD_SAL (dato);        // Coloco el Comando a escribir
  208.    output_high (GLCD_E);   // Aviso que estoy enviado un comando
  209.    delay_cycles( 2 );      // Espero
  210.    output_low (GLCD_E);    // Termino el envío del comando
  211.    delay_cycles( 2 );      // Espero
  212. }
  213.  
  214. //-----------------------------------------------------------------------
  215. // Lee un byte de la pantalla
  216. //-----------------------------------------------------------------------
  217. BYTE GLCD_readBYTE()
  218. {
  219.    BYTE dato;
  220.    GLCD_TRIS (0xFF);       // Todo el Puerto como entrada de datos
  221.    output_high (GLCD_RW);  // Modo lectura
  222.    output_high (GLCD_A0);  // Modo lectura
  223.    output_high (GLCD_E);   // Activo la lectura
  224.    delay_cycles( 2 );      // Espero
  225.    output_low (GLCD_E);    // lectura tonta
  226.    delay_cycles( 2 );      // Espero
  227.    output_high (GLCD_E);   // Activo la lectura
  228.    delay_cycles( 2 );      // Espero
  229.    dato = GLCD_ENT();      // Guardo en "dato" el valor devuelto
  230.    output_low (GLCD_E);    // Termino la lectura
  231.    output_low (GLCD_RW);   // Modo comando
  232.    output_low (GLCD_A0);   // Modo comando
  233.    GLCD_SAL (0x00);        // Limpio el Puerto de salida
  234.    GLCD_TRIS (0x00);       // Todo el Puerto como salida de datos
  235.    return dato;            // Retorno de la rutina con el dato
  236. }
  237.  
  238. //-----------------------------------------------------------------------
  239. // Limpia el GLCD (pinta toda la pantalla de un color)
  240. //-----------------------------------------------------------------------
  241. void GLCD_clear(int1 color)
  242. {
  243.    int8 i, j;
  244.    for(i = 0; i < 7; ++i) // Recorre las 8 paginas (vertical)
  245.    {
  246.       for(j = 0; j < 127; ++j) // Recorre los 128 segmentos (horizontal)
  247.       {  GLCD_Data(0xFF * color);  // Enciende/apaga pixeles
  248.        }
  249.    }
  250. }
  251.  
  252.  
  253. //-----------------------------------------------------------------------
  254. //Esta funcion inicializa el LCD.
  255. //-----------------------------------------------------------------------
  256. void GLCD_init(int1 modo)
  257. {
  258.    // Pone los pines de control en el estado correcto.
  259.    output_low(GLCD_RESET);
  260.    delay_ms(1);
  261.    output_high(GLCD_RESET);
  262.    GLCD_Command(0x40);        // Linea Inicial = 0
  263.    GLCD_Command(0xA0);        // ADC = normal
  264.    GLCD_Command(0xA3);        // LCD-Bias = 1/7
  265.    GLCD_Command(0xC0);        // output mode
  266.    GLCD_Command(0xAC);        // static indicator = 0
  267.    GLCD_Command(0xA4);        // Todos los pixeles apagados
  268.    GLCD_Command(0xA6);        // Display no Invertido
  269.    GLCD_Command(0xE0);        // read/modify/write
  270.    // Si modo = 1 inicializa encendido. Sino, apagado.
  271.    if(modo == 1)
  272.    {  GLCD_Command(0xAF); }   // Enciendo el GLCD
  273.    else {
  274.       GLCD_Command(0xAE); }   // Apago el GLCD
  275. }
  276.  
  277.  
  278. //-----------------------------------------------------------------------
  279. // Dibuja un pixel
  280. //-----------------------------------------------------------------------
  281. void GLCD_pixel(int8 x, int8 y, int1 color)
  282. {
  283.    BYTE dato;
  284.    int8 Posicion_Y;
  285.    int8 Posicion_X;
  286.    x = 127-x;
  287.    y = 63-y;
  288. //Primero verificar que X e Y estan dentro de los límites
  289.    if ((x<=127)&(y<=63)){
  290.       Posicion_Y = y / 8;             // Calculo La página a donde pertenece el bit
  291.       Posicion_Y = 0xB0 + Posicion_Y;     // Genero el comando para ir a la página
  292.       GLCD_Command(Posicion_Y);                 // Ejecuto el comando
  293.       Posicion_X = x;
  294.       swap(Posicion_X);
  295.       Posicion_X &= 0x0F;
  296.       Posicion_X |= 0x10;
  297.       GLCD_Command(Posicion_X);
  298.       Posicion_X = x;
  299.       Posicion_X &= 0x0F;
  300.       GLCD_Command(Posicion_X);
  301.       dato = GLCD_ReadBYTE();
  302.    if(color == 1)
  303.       bit_set(dato, y%8);        // Turn the pixel on
  304.    else                          // or
  305.       bit_clear(dato, y%8);      // turn the pixel off
  306.       GLCD_Data(dato);
  307.    }
  308. }
  309.  
  310. //-----------------------------------------------------------------------
  311. // Dibuja una linea desde (x1,y1) a (x2,y2) de color (0 o 1)
  312. //-----------------------------------------------------------------------
  313. void GLCD_line(int x1, int y1, int x2, int y2, int1 color)
  314. {
  315.    //Declaro variables-------------------
  316.    signed int  x, y, incremento_x, incremento_y, distancia_x, distancia_y;
  317.    signed long P;
  318.    int i;
  319.  
  320.    //Calculo las diferencias entre las coordenadas de origen y destino
  321.    distancia_x = abs((signed int)(x2 - x1));
  322.    distancia_y = abs((signed int)(y2 - y1));
  323.  
  324.    //Inicializo x e y con las coordenadas de origen
  325.    x = x1;
  326.    y = y1;
  327.  
  328.    //Calculo el sentido de los incrementos (positivos o negativos)
  329.    //en funcion de la posicion del origen y el destino
  330.    if(x1 > x2) incremento_x = -1; else incremento_x = 1;
  331.    if(y1 > y2) incremento_y = -1; else incremento_y = 1;
  332.  
  333.    //Si la distancia horizontal es mayor a la vertical...
  334.    if(distancia_x >= distancia_y)
  335.    { P = 2 * distancia_y - distancia_x;
  336.       for(i=0; i<=distancia_x; ++i)
  337.       {
  338.          GLCD_pixel(x, y, color);
  339.  
  340.          if(P < 0)
  341.          { P += 2 * distancia_y;
  342.             x += incremento_x; }
  343.          else
  344.          { P += 2*distancia_y - 2*distancia_x;
  345.             x += incremento_x;
  346.             y += incremento_y;}
  347.       }
  348.    }
  349.  
  350.    //Si la distancia vertical es mayor a la horizontal...
  351.    else
  352.    { P = 2 * distancia_x - distancia_y;
  353.       for(i=0; i<=distancia_y; ++i)
  354.       { GLCD_pixel(x, y, color);
  355.          if(P < 0)
  356.          {  P += 2 * distancia_x;
  357.             y += incremento_y; }
  358.          else
  359.          {  P += 2 * distancia_x - 2 * distancia_y;
  360.             x += incremento_x;
  361.             y += incremento_y; }
  362.       }
  363.    }
  364. }
  365. //-----------------------------------------------------------------------
  366.  
  367.  
  368. //-----------------------------------------------------------------------
  369. // Dibuja un rectángulo desde (x1,y1) a (x2,y2) de color (0 o 1)
  370. //-----------------------------------------------------------------------
  371. void GLCD_rectangle(int x1, int y1, int x2, int y2, int1 color)
  372. {
  373.    GLCD_line(x1,y1,x2,y1,color);
  374.    GLCD_line(x1,y1,x1,y2,color);
  375.    GLCD_line(x1,y2,x2,y2,color);
  376.    GLCD_line(x2,y1,x2,y2,color);
  377. }
  378. //-----------------------------------------------------------------------
  379.  
  380. //-----------------------------------------------------------------------
  381. // Dibuja un rectángulo PINTADO desde (x1,y1) a (x2,y2) de color (0 o 1)
  382. //-----------------------------------------------------------------------
  383. void GLCD_box(int x1, int y1, int x2, int y2, int1 color)
  384. {
  385.    //Declaro variables-------------------
  386.    int i;
  387.  
  388.    for(i=y1;i<=y2;i++) {
  389.       GLCD_line(x1,i,x2,i,color); }
  390.  
  391. }
  392. //-----------------------------------------------------------------------
  393.  
  394. //-----------------------------------------------------------------------
  395. // Dibuja un circulo con centro en (x1,y1), radio y color (0 o 1)
  396. //-----------------------------------------------------------------------
  397. void GLCD_circle(int x1, int y1, int radio, int1 color)
  398.   {
  399.     signed int d, x, y;
  400.  
  401.     //Inicializo las variables.
  402.     d = 1 -  radio;
  403.     x = 0;
  404.     y = radio;
  405.  
  406.     //Dibujo los cuatro pixeles que "caen" sobre los ejes cartesianos.
  407.     GLCD_pixel(x1, y1 + radio, color);
  408.     GLCD_pixel(x1, y1 - radio, color);
  409.     GLCD_pixel(x1 + radio, y1, color);
  410.     GLCD_pixel(x1 - radio, y1, color);
  411.  
  412.     //Este es el bucle que pinta los octavos de la circunferencia.
  413.     while(x < y) {
  414.       if(d < 0) {d = d + 2 * x + 3;}
  415.            else  {d = d + 2 * (x - y ) + 5;
  416.                   y = y - 1 ;}
  417.       x = x + 1;
  418.  
  419.       //Pone el punto en cada uno de los "octantes".
  420.       GLCD_pixel(x1 + x, y1 + y, color);
  421.       GLCD_pixel(x1 - x, y1 + y, color);
  422.       GLCD_pixel(x1 + x, y1 - y, color);
  423.       GLCD_pixel(x1 - x, y1 - y, color);
  424.       GLCD_pixel(x1 + y, y1 + x, color);
  425.       GLCD_pixel(x1 - y, y1 + x, color);
  426.       GLCD_pixel(x1 + y, y1 - x, color);
  427.       GLCD_pixel(x1 - y, y1 - x, color);
  428.       }
  429.   }
  430.  
  431. //char characterSet[] = " !#$%&'()*+,-./0123456789:;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
  432. void GLCD_text35(int8 x, int8 y, char* textptr, int1 color)
  433. {
  434.    int i, j, k;                           // Loop counters
  435.    BYTE pixelData[5];                     // Stores character data
  436.  
  437.    for(i=0; textptr[i] != '\0'; ++i, ++x) // Loop through the passed string
  438.    {
  439.       if((textptr[i] >= ' ') && (textptr[i] <= '~'))
  440.         memcpy(pixelData, TEXT35[textptr[i]-' '], 5);
  441.       else
  442.          memcpy(pixelData, TEXT35[0], 5); // Default to space
  443.  
  444.       if(x+3 >= GLCD_WIDTH)          // Performs character wrapping
  445.       {
  446.          x = 0;                           // Set x at far left position
  447.          y += 5 + 1;                      // Set y at next position down
  448.       }
  449.       for(j=3; j>0; j--, x++)             // Loop through character byte data
  450.       {
  451.          for(k=0; k<5; k++)               // Loop through the vertical pixels
  452.          {
  453.             if(bit_test(pixelData[k], j)) // Check if the pixel should be set
  454.             {
  455.                glcd_pixel(x, y+k, color); // Draws the pixel
  456.             }
  457.          }
  458.       }
  459.    }
  460. }

Salud  8)
No hay preguntas tontas...
Solo hay tontos que no preguntan.


 

anything