GLCD AGM-12864K

Software e Hardware para uC PIC

Moderadores: andre_luis, 51, guest2003, Renie

GLCD AGM-12864K

Mensagempor ÁgioFelipe » 24 Mai 2011 08:54

Pessoal estou tentanto trabalhar com esse kit da mosaico:

http://www.mosaico.com.br/index.asp?can ... os&id=109#


Este é um exemplo básico disponibilizado pela mosaico:

Código: Selecionar todos
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                  Exemplo1  -  Kit Touch e McLab2 18F4550                *
 *                                                                         *
 *                                                                         *
 *                   LABTOOLS - MOSAICO DIDACTIC DIVISION                  *
 *                                                                         *
 *  TEL: (0XX11) 4992-8775               SITE: www.labtools.com.br         *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *   VERSÃO : 1.0                                                          *
 *   DATA : 04/01/2010                                                     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* * * * * * * * *  * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                             Descrição geral                             *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
   Este software está preparado para no LCD Gráfico. O software realiza
    uma sequência de instruções gráficas que ensinam como utilizar cada
    função específica da biblioteca.
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                DEFINIÇÃO DAS VARIÁVEIS INTERNAS DO PIC                  *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <p18F4550.h>            // Register definitions
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <delays.h>               //Delay library functions

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                         Configurações para gravação                   *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#pragma config FOSC    = HS
#pragma config CPUDIV    = OSC4_PLL6
#pragma config WDT       = OFF
#pragma config WDTPS    = 128
#pragma config LVP       = OFF
#pragma config PWRT       = ON
#pragma config BOR       = OFF
#pragma config BORV    = 0
#pragma config PBADEN    = OFF
#pragma config DEBUG    = OFF
#pragma config PLLDIV    = 1
#pragma config USBDIV    = 1
#pragma config FCMEN    = OFF
#pragma config IESO    = OFF
#pragma config VREGEN    = OFF
#pragma config MCLRE    = ON
#pragma config LPT1OSC    = OFF
#pragma config CCP2MX    = OFF
#pragma config STVREN    = OFF
#pragma config ICPRT    = OFF
#pragma config XINST    = OFF
#pragma config CP0       = OFF
#pragma config CP1       = OFF
#pragma config CP2       = OFF
#pragma config CP3       = OFF
#pragma config CPB       = OFF
#pragma config CPD       = OFF
#pragma config WRT0    = OFF
#pragma config WRT1    = OFF
#pragma config WRT2    = OFF
#pragma config WRT3    = OFF
#pragma config WRTB    = OFF
#pragma config WRTC    = OFF
#pragma config WRTD    = OFF
#pragma config EBTR0    = OFF
#pragma config EBTR1    = OFF
#pragma config EBTR2    = OFF
#pragma config EBTR3    = OFF
#pragma config EBTRB    = OFF

//
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                INCLUDES DAS FUNÇÕES DE PERIFÉRICOS DO PIC             *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                       PROTOTIPAGEM DE FUNÇÕES                         *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

void glcd_init(unsigned char mode);
void glcd_pixel(unsigned char x, unsigned char y, unsigned char color);
void glcd_line(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char color);
void glcd_rect(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char fill, unsigned char color);
void glcd_bar(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char width, unsigned char color);
void glcd_circle(unsigned char x, unsigned char y, unsigned char radius, unsigned char fill, unsigned char color);
void glcd_fillScreen(unsigned char color);
void glcd_writeByte(unsigned char chip, unsigned char data);
unsigned char glcd_readByte(unsigned char chip);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                           Constantes internas                           *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//A definição de constantes facilita a programação e a manutenção.

#define GLCD_WIDTH 128    // Used for text wrapping by glcd_text57 function

#define ON  1
#define OFF 0

#define YES 1
#define NO  0

#define   TRUE   1
#define FALSE  0

#define SEL_GLCD_CS1 0
#define SEL_GLCD_CS2 1

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                 Definição e inicialização das variáveis                 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//Neste bloco estão definidas as variáveis globais do programa.

unsigned char buffer_latch_controle,aux = 0;
unsigned char texto[4];

//   
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                    Declaração dos flags de software                     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//A definição de flags ajuda na programação e economiza memória RAM.

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                               ENTRADAS                                  *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// As entradas devem ser associadas a nomes para facilitar a programação e
//futuras alterações do hardware.

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                 SAÍDAS                              *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// AS SAÍDAS DEVEM SER ASSOCIADAS A NOMES PARA FACILITAR A PROGRAMAÇÃO E
//FUTURAS ALTERAÇÕES DO HARDWARE.

#define ENC    LATCbits.LATC2      // Sinal enable do latch
#define ENL    LATAbits.LATA2      // Sinal enable do LCD

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                          Configurações do Pic                           *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

void main()
{
   RCON = 0x7F;               // Reset CONtrol
                           // IPEN=0 modo compativel com
                            // 16F, toda int. no end. 0x0008

   PORTA = 0x00;                       //Limpa PORTA
   PORTB = 0x00;                       //Limpa PORTB
   PORTC = 0x00;                      //Limpa PORTC
   PORTD = 0x00;                       //Limpa LATD
   PORTE = 0x00;                       //Limpa PORTE

   LATA = 0x00;                         //Limpa PORTA
   LATB = 0x00;                        //Limpa PORTB
   LATC = 0x00;                      //Limpa PORTC e inicializa pinos OEx
   LATD = 0x00;                        //Limpa LATD
   LATE = 0x00;                        //Limpa PORTE

         //76543210
   TRISA = 0b11111011;                 //CONFIG DIREÇÃO DOS PINOS PORTA0
   TRISB = 0b00001111;                 //CONFIG DIREÇÃO DOS PINOS PORTB
   TRISC = 0b11111011;                  //CONFIG DIREÇÃO DOS PINOS PORTC
   TRISD = 0b00000000;                 //CONFIG DIREÇÃO DOS PINOS LATD
   TRISE = 0b00001111;                 //CONFIG DIREÇÃO DOS PINOS PORTE; DESABILITA PINOS LCD 16X2      

   ADCON1 = 0b00001111;                //DESLIGA CONVERSORES A/D
   CMCON  = 0x07;

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                        Inicialização do Sistema                     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
   
   Delay1KTCYx(200);      // Tempo de acomodação do LCD

   glcd_init(ON);         // Inicializa LCD

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                              Rotina principal                           *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

   while(1)
   {

   for (aux=0;aux<64;aux = aux + 7)      //gera tabuleiro
      glcd_line(0,aux,127,aux,ON);

   for (aux=0;aux<128;aux = aux + 7)
      glcd_line(aux,0,aux,63,ON);
      
   Delay1KTCYx(3000);   

   glcd_fillScreen(OFF);

   for (aux=0;aux<64;aux = aux + 7)      // efeito com linha
      glcd_line(0+aux,0+aux,127-aux,63-aux,ON);

   Delay1KTCYx(3000);   

   glcd_fillScreen(OFF);

   for (aux=0;aux<128;aux = aux + 15)      // sequência de barras
       glcd_rect(0+aux,0,7+aux,63,1,1);

   Delay1KTCYx(3000);   

   glcd_fillScreen(OFF);

   glcd_circle(10,10,10,1,ON);            // animação com círculos
   glcd_circle(117,53,10,1,ON);
   glcd_circle(10,53,10,1,ON);
   glcd_circle(117,10,10,1,ON);
   glcd_circle(63,31,20,0,ON);
   
   Delay1KTCYx(3000);   

   glcd_fillScreen(OFF);

   }


}
/*
**===========================================================================
**===========================================================================
**
**          FUNÇÕES DE CONTROLE DO LCD 128 X 64
**
**===========================================================================
**===========================================================================
*/

// Purpose:       Initialize a graphic LCD. This must be called before any
//                other glcd function is used.
// Inputs:        The initialization mode
//                OFF - Turns the LCD off
//                ON  - Turns the LCD on
// Date:          5/28/2003
void glcd_init(unsigned char mode)
{
//  Bits do latch - MSB .. LSB
//   CS2 - CS1 - D/I - R/W - CST - RST - BCK - XXX

   buffer_latch_controle = 0b00001000;                  //Inicializa pinos do LCD
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
   
   Delay1KTCYx(1);   
   
   buffer_latch_controle = buffer_latch_controle | 0b00000100;                  //Inicializa pinos do LCD
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
   
   glcd_writeByte(SEL_GLCD_CS1, 0xC0);     // Specify first RAM line at the top
      glcd_writeByte(SEL_GLCD_CS2, 0xC0);     // of the screen
      glcd_writeByte(SEL_GLCD_CS1, 0x40);     // Set the column address to 0
      glcd_writeByte(SEL_GLCD_CS2, 0x40);
      glcd_writeByte(SEL_GLCD_CS1, 0xB8);     // Set the page address to 0
      glcd_writeByte(SEL_GLCD_CS2, 0xB8);

   if(mode == ON)
      {
       glcd_writeByte(SEL_GLCD_CS1, 0x3F);   // Turn the display on
         glcd_writeByte(SEL_GLCD_CS2, 0x3F);
      }
      else
      {
       glcd_writeByte(SEL_GLCD_CS1, 0x3E);   // Turn the display off
         glcd_writeByte(SEL_GLCD_CS2, 0x3E);
      }

   glcd_fillScreen(OFF);                  // Clear the display

}
// Purpose:       Turn a pixel on a graphic LCD on or off
// Inputs:        x - the x coordinate of the pixel
//                y - the y coordinate of the pixel
//                color - ON or OFF
// Output:        1 if coordinate out of range, 0 if in range
void glcd_pixel(unsigned char x, unsigned char y, unsigned char color)
{
   unsigned char data;
   unsigned char tmp;
      unsigned char chip = SEL_GLCD_CS1;   // Stores which chip to use on the LCD

      if(x > 63)                    // Check for first or second display area
      {
      x -= 64;
         chip = SEL_GLCD_CS2;
      }

   // Set for instruction
    buffer_latch_controle = buffer_latch_controle & (0b11011111);
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
         
   x = x & 0b01111111;                              // Clear the MSB. Part of an instruction code                        
   x = x | 0b01000000;                              // Set bit 6. Also part of an instruction code
      glcd_writeByte(chip, x);                        // Set the horizontal address
      glcd_writeByte(chip, (y/8 & 0b10111111) | 0b10111000);   // Set the vertical page address

   // Set for data
   buffer_latch_controle = buffer_latch_controle | (0b00100000);
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
      
   data = glcd_readByte(chip);

   if(color == ON)
   {
      tmp = 0b00000001;                           // Turn the pixel on
      tmp = tmp << (y%8);
      data = data | tmp;
   }
   else
   {                                          // or
      tmp = 0b00000001;                           // turn the pixel off
      tmp = ~(tmp << (y%8));
      data = data & tmp;
    } 
   
   // Set for instruction
   buffer_latch_controle = buffer_latch_controle & (0b11011111);
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
   
   
      glcd_writeByte(chip, x);                        // Set the horizontal address

   // Set for data
   buffer_latch_controle = buffer_latch_controle | (0b00100000);
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
   
   
      glcd_writeByte(chip, data);                        // Write the pixel data

}


// Purpose:       Draw a line on a graphic LCD using Bresenham's
//                line drawing algorithm
// Inputs:        (x1, y1) - the start coordinate
//                (x2, y2) - the end coordinate
//                color - LCD_ON or LCD_OFF
// Dependencies:  glcd_pixel()
void glcd_line(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char color)
{
   signed char  x, y, addx, addy, dx, dy;
      signed long P;
      unsigned char i;
      
      if( x2 > x1 )
         dx = x2 - x1;
      else
         dx = x1 - x2;
         
      if( y2 > y1 )
         dy = y2 - y1;
      else
         dy = y1 - y2;

      x = x1;
      y = y1;

   if(x1 > x2)
      addx = -1;
      else
         addx = 1;
   
      if(y1 > y2)
         addy = -1;
      else
         addy = 1;

      if(dx >= dy)
      {
      P = 2*dy - dx;

         for(i=0; i<=dx; ++i)
         {
         glcd_pixel(x, y, color);

         if(P < 0)
            {
               P += 2*dy;
               x += addx;
         }
            else
         {
               P += 2*dy - 2*dx;
               x += addx;
               y += addy;
            }
      }
   }
      else
      {
      P = 2*dx - dy;

         for(i=0; i<=dy; ++i)
         {
         glcd_pixel(x, y, color);

         if(P < 0)
         {
               P += 2*dx;
               y += addy;
         }   
            else
            {
               P += 2*dx - 2*dy;
               x += addx;
               y += addy;
            }
         }
      }
}
// Purpose:       Draw a rectangle on a graphic LCD
// Inputs:        (x1, y1) - the start coordinate
//                (x2, y2) - the end coordinate
//                fill  - YES or NO
//                color - ON or OFF
// Dependencies:  glcd_pixel(), glcd_line()
void glcd_rect(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char fill, unsigned char color)
{
   if(fill)
      {
      unsigned char y, ymax;                        // Find the y min and max
         if(y1 < y2)
         {
         y = y1;
            ymax = y2;
      }
         else
         {
         y = y2;
            ymax = y1;
      }

      for(; y<=ymax; ++y) glcd_line(x1, y, x2, y, color);   // Draw lines to fill the rectangle
         
   }
      else
      {
      glcd_line(x1, y1, x2, y1, color);                  // Draw the 4 sides
      glcd_line(x1, y2, x2, y2, color);
      glcd_line(x1, y1, x1, y2, color);
      glcd_line(x2, y1, x2, y2, color);
      }
}


// Purpose:       Draw a bar (wide line) on a graphic LCD
// Inputs:        (x1, y1) - the start coordinate
//                (x2, y2) - the end coordinate
//                width  - The number of pixels wide
//                color - ON or OFF
void glcd_bar(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char width, unsigned char color)
{
   signed char  x, y, addx, addy, j;
      signed long P, dx, dy, c1, c2;
      unsigned char i;
      
      dx = fabs((signed char)(x2 - x1));
      dy = fabs((signed char)(y2 - y1));
      x = x1;
      y = y1;
      
      c1 = -dx*x1 - dy*y1;
      c2 = -dx*x2 - dy*y2;

      if(x1 > x2)
      {
      addx = -1;
         c1 = -dx*x2 - dy*y2;
         c2 = -dx*x1 - dy*y1;
      }
      else addx = 1;
   if(y1 > y2)
      {
      addy = -1;
         c1 = -dx*x2 - dy*y2;
         c2 = -dx*x1 - dy*y1;
      }
   else addy = 1;

   if(dx >= dy)
      {
      P = 2*dy - dx;

         for(i=0; i<=dx; ++i)
         {
         for(j=-(width/2); j<width/2+width%2; ++j)
            {
               if(dx*x+dy*(y+j)+c1 >= 0 && dx*x+dy*(y+j)+c2 <=0)
            glcd_pixel(x, y+j, color);
            }
            if(P < 0)
            {
               P += 2*dy;
               x += addx;
            }
            else
            {
               P += 2*dy - 2*dx;
               x += addx;
               y += addy;
            }
      }
      }
      else
      {
      P = 2*dx - dy;

         for(i=0; i<=dy; ++i)
         {
         if(P < 0)
            {
               P += 2*dx;
               y += addy;
            }
            else
            {
               P += 2*dx - 2*dy;
               x += addx;
               y += addy;
            }
            for(j=-(width/2); j<width/2+width%2; ++j)
            {
               if(dx*x+dy*(y+j)+c1 >= 0 && dx*x+dy*(y+j)+c2 <=0)
                  glcd_pixel(x+j, y, color);
            }
         }
      }
}

// Purpose:       Draw a circle on a graphic LCD
// Inputs:        (x,y) - the center of the circle
//                radius - the radius of the circle
//                fill - YES or NO
//                color - ON or OFF
void glcd_circle(unsigned char x, unsigned char y, unsigned char radius, unsigned char fill, unsigned char color)
{
   signed char a, b, P;
      
      a = 0;
      b = radius;
      P = 1 - radius;

      do
      {
      if(fill)
         {
         glcd_line(x-a, y+b, x+a, y+b, color);
            glcd_line(x-a, y-b, x+a, y-b, color);
            glcd_line(x-b, y+a, x+b, y+a, color);
            glcd_line(x-b, y-a, x+b, y-a, color);
         }
         else
         {
         glcd_pixel(a+x, b+y, color);
            glcd_pixel(b+x, a+y, color);
            glcd_pixel(x-a, b+y, color);
            glcd_pixel(x-b, a+y, color);
            glcd_pixel(b+x, y-a, color);
            glcd_pixel(a+x, y-b, color);
            glcd_pixel(x-a, y-b, color);
            glcd_pixel(x-b, y-a, color);
         }

         if(P < 0) P+= 3 + 2*a++;
      else P+= 5 + 2*(a++ - b--);
      
   }while(a <= b);
}

// Purpose:       Fill the LCD screen with the passed in color.
//                Works much faster than drawing a rectangle to fill the screen.
// Inputs:        ON - turn all the pixels on
//                OFF - turn all the pixels off
// Dependencies:  glcd_writeByte()
void glcd_fillScreen(unsigned char color)
{
   unsigned char i, j;

      // Loop through the vertical pages
      for(i = 0; i<8; i++)
      {

      // Set for instruction
      buffer_latch_controle = buffer_latch_controle & (0b11011111);
      LATD = buffer_latch_controle;
      Nop();
      ENC = 1;      
      Nop();
      ENC = 0;      
      Nop();
   
         glcd_writeByte(SEL_GLCD_CS2, 0b01000000);      // Set horizontal address to 0
      glcd_writeByte(SEL_GLCD_CS1, 0b01000000);
      glcd_writeByte(SEL_GLCD_CS2, i | 0b10111000);   // Set page address
      glcd_writeByte(SEL_GLCD_CS1, i | 0b10111000);

      // Set for data
      buffer_latch_controle = buffer_latch_controle | (0b00100000);
      LATD = buffer_latch_controle;
      Nop();
      ENC = 1;      
      Nop();
      ENC = 0;      
      Nop();
         
      // Loop through the horizontal sections
         for(j = 0; j < 64; j++)
         {
         glcd_writeByte(SEL_GLCD_CS1, 0xFF*color);   // Turn pixels on or off
         glcd_writeByte(SEL_GLCD_CS2, 0xFF*color);   // Turn pixels on or off
         }
      
      }
}

// Purpose:       Write a byte of data to the specified chip
// Inputs:        chipSelect - which chip to write the data to
//                data - the byte of data to write

void glcd_writeByte(unsigned char chip, unsigned char data)
{
   //  Bits do latch - MSB .. LSB
   //   CS2 - CS1 - D/I - R/W - CST - RST - BCK - XXX

   if(chip == SEL_GLCD_CS1) buffer_latch_controle = buffer_latch_controle | (0b01000000);       // Choose which chip to write to
      else buffer_latch_controle = buffer_latch_controle | (0b10000000);

   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
   
   // Set for writing
   buffer_latch_controle = buffer_latch_controle & (0b11101111);   
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
   
   // Sequência para pulso de enable LCD
   Nop();
   ENL = 1;
   Nop();

   LATD = data;

   ENL = 0;
   Nop();

   // Reset the chip select lines
   buffer_latch_controle = buffer_latch_controle & (0b00111111) ;
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
}

// Purpose:       Reads a byte of data from the specified chip
// Ouputs:        A byte of data read from the chip
unsigned char glcd_readByte(unsigned char chip)
{
   unsigned char data=0;                  // Stores the data read from the LCD

   //  Bits do latch - MSB .. LSB
   //   CS2 - CS1 - D/I - R/W - CST - RST - BCK - XXX

   if(chip == SEL_GLCD_CS1) buffer_latch_controle = buffer_latch_controle | (0b01000000);       // Choose which chip to write to
      else buffer_latch_controle = buffer_latch_controle | (0b10000000);

   // Set for reading
   buffer_latch_controle = buffer_latch_controle | (0b00010000);   
   LATD =  buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
   
   TRISD = 0xFF;
   
   // Get the data from the display's output register
   Nop();
     ENL= 1;                         // Pulse the enable pin
   Nop();
   ENL = 0;
   Nop();
   ENL = 1;                         // Pulse the enable pin
   Nop();
   // Get the data from the display's output register
   
   data = PORTD;

   Nop();
   ENL = 0;
   Nop();

   // Barramento como saida
   TRISD = 0x00;

   // Desliga o pino RW
   buffer_latch_controle = (buffer_latch_controle & (0b11101111) );
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
   
   // Reset the chip select lines
   buffer_latch_controle = buffer_latch_controle & (0b00111111);
   LATD = buffer_latch_controle;
   Nop();
   ENC = 1;      
   Nop();
   ENC = 0;      
   Nop();
      
     return data;                           // Return the read data
}


Encontrei essa biblioteca no qual as função do exemplo da mosaico estão inseridas:
http://www.eng.auburn.edu/~nelson/cours ... LCD/GLCD.C

Nessa mesma página existe essa outra biblioteca:
http://www.eng.auburn.edu/~nelson/cours ... DM64GS12.c

No meu entender o GLCD estou trabalhando não possui controlador como esse KS0108, eu trabalho diretamente com os pixels, estou certo?
Alguém pode me dar uma luz sobre esse GLCD.

Aqui está o datasheet dele fornecido pela mosaico:
http://pt.scribd.com/doc/56144190/AGM-12864K-203-T
ÁgioFelipe
Word
 
Mensagens: 626
Registrado em: 27 Out 2006 20:04

Mensagempor ze » 24 Mai 2011 10:22

serve lamparina? alguns cliques procê e...

pelo jeito ele usa controlador sim. O NT7108 (www.neotec.com.tw)
o mais desafiador e emocionante é voce aprender a conversar com ele sem usar as (talvez) dispendiosas libs prontas. Baixe o datasheet e verifique. O macete é conseguir plotar de desplotar UM PIXEL APENAS numa posiçao conhecida. Este seria seu único 'difícil' contato com o hw. Depois disso é só colocar a sela e chicote nele.

Tive experiencia desta com um ks0108. Usei um mc de 1k pra desenhar. 100% c. postei aqui os fontes há alguns anos. o probl é a memória... minha

sucessos!
Avatar do usuário
ze
Dword
 
Mensagens: 1655
Registrado em: 05 Jun 2007 14:32

Mensagempor ÁgioFelipe » 08 Jun 2011 12:04

Estudei o uso das funções do arquivo que postei antes, só estou tendo dificuldades na função glcd_bar, ela só funciona com a largura de 1, quer dizer, identica a função glcd_line.
Procurando na net, encontrei outras pessoas falando do mesmo problema mas nenhuma solução.
Alguém poderia ajudar?
ÁgioFelipe
Word
 
Mensagens: 626
Registrado em: 27 Out 2006 20:04

Mensagempor Jorge_Francisco » 08 Jun 2011 12:22

ÁgioFelipe escreveu:Estudei o uso das funções do arquivo que postei antes, só estou tendo dificuldades na função glcd_bar, ela só funciona com a largura de 1, quer dizer, identica a função glcd_line.
Procurando na net, encontrei outras pessoas falando do mesmo problema mas nenhuma solução.
Alguém poderia ajudar?


Se o resto está funcionando, cria uma função para vc com a largura da linha com o WIDTH como argumento da função. Tem mil exemplos de como fazer o desenho da linha no GLCD.
Avatar do usuário
Jorge_Francisco
Dword
 
Mensagens: 1009
Registrado em: 12 Out 2006 09:53
Localização: Rio de Janeiro


Voltar para PIC

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

x