Example #1
0
File: lcd_4b.c Project: cukier/SPI
void lcd (char c) {
	switch(c)  {
		case '\f' : lcd_envia_byte(0,1);
								delay_ms(2);
								break;
		case '\n' : 
		case '\r' : lcd_pos_xy(1,2);
								break;
		case '\b' : lcd_envia_byte(0,0x10);
								break;
		default    : lcd_envia_byte(1,c);
								break;
	}
}  
Example #2
0
// posiciona cursor do display lcd
void lcd_pos_xy(int x, int y)
{
	int endereco;

	if(y <= 2)
	{
		lcd_modulo = 1;
	}
	else
	{
		lcd_modulo = 2;
	}

	if((y == 2) || (y == 4))
	{
		endereco = lcd_seg_lin;
	}
	else
	{
		endereco = 0;
	}

	endereco += x - 1;
	lcd_x = x;
	lcd_y = y;

	lcd_envia_byte(0, 0x80 | endereco);
}
Example #3
0
void lcd_ini()
// rotina de inicialização do display
{
   byte conta;
   output_low(lcd_d4);
   output_low(lcd_d5);
   output_low(lcd_d6);
   output_low(lcd_d7);
   output_low(lcd_rs);
   #ifdef lcd_rw
      output_high(lcd_rw);
   #endif
   output_low(lcd_enable);
   delay_ms(15);
   // envia uma seqüência de 3 vezes 0x03
   // e depois 0x02 para configurar o módulo
   // para modo de 4 bits
   for(conta=1;conta<=3;++conta)
   {
      lcd_envia_nibble(3);
      delay_ms(5);
   }
   lcd_envia_nibble(2);
   // envia string de inicialização do display
   for(conta=0;conta<=3;++conta) lcd_envia_byte(0,INI_LCD[conta]);
}
Example #4
0
void lcd_escreve( char c)
// envia caractere para o display
{
   switch (c)
   {
     case '\f'    :   lcd_envia_byte(0,1);
              delay_ms(2);
            break;
     case '\n'   :
     case '\r'    :   lcd_pos_xy(1,2);
              break;
     case '\b'    :   lcd_envia_byte(0,0x10);
              break;
     default   :   lcd_envia_byte(1,c);
              break;
   }
}
Example #5
0
// rotina de inicialização do display
void lcd_ini(void)
{
	int cont;

	output_low(lcd_d4);
	output_low(lcd_d5);
	output_low(lcd_d6);
	output_low(lcd_d7);
	output_low(lcd_rs);
	output_low(lcd_en);
	#ifdef lcd_en2
	output_low(lcd_en2);
	#endif

	delay_ms(15);

	lcd_modulo = 0;

	// envia uma seqüência de 3 vezes 0x03
	// e depois 0x02 para configurar o módulo
	// para modo de 4 bits
	for(cont = 1; cont <= 3; ++cont)
	{
		lcd_envia_nibble(3);
		delay_ms(4);
	}
	lcd_envia_nibble(2);

	// envia string de inicialização do display
	for(cont = 0; cont <= 3; ++cont)
	{
		lcd_envia_byte(0, ini_lcd[cont]);
	}

	// aguarda tempo de processamento do módulo lcd
	delay_ms(5);

	// desbilita cursor do lcd
	lcd_envia_byte(0, 0x0c);

	// Inicializa ponteiros de posição
	lcd_modulo = 1;
	lcd_x = 1;
	lcd_y = 1;
}
Example #6
0
File: lcd_4b.c Project: cukier/SPI
void lcd_pos_xy(byte x, byte y) {
	byte endereco;
	if (y!=1)
		endereco = 0xc0;
	else
		endereco = 0x80;
	endereco += x-1;         
	lcd_envia_byte(0,endereco);
}
Example #7
0
void lcd_pos_xy( byte x, byte y)
{
   byte endereco;
   if(y!=1)
      endereco = lcd_seg_lin;
   else
      endereco = 0;
   endereco += x-1;
   lcd_envia_byte(0,0x80|endereco);
}
void lcd_ini(void)
{
    TRISD = 0x00;
    TRISCbits.TRISC0 = 0;
    TRISCbits.TRISC1 = 0;

    LCD_RS = 0;        //Command Register
    LCD_EN = 0;

    LCD_DATA = 0x30;

    LCD_EN = 1;
    tempo_ms(1);
    LCD_EN = 0;
    tempo_ms(1);

    LCD_EN = 1;
    tempo_ms(1);
    LCD_EN = 0;
    tempo_ms(1);

    LCD_EN = 1;
    tempo_ms(1);
    LCD_EN = 0;
    tempo_ms(1);

    tempo_ms(1);
    LCD_DATA = 0x20;    // Four bit mode
    LCD_EN = 1;
    tempo_ms(1);
    LCD_EN = 0;
    tempo_ms(1);

    lcd_envia_byte(0x28);// 4-bit, 2 line, 5x7 mode
    tempo_ms(5);
    lcd_envia_byte(0x0C);// Turn on display
    tempo_ms(5);
    lcd_envia_byte(0x01);// Clear & home display
    tempo_ms(5);
    lcd_envia_byte(0x06);// Left to Right
   tempo_ms(5);
}
void
main(void) {
   clock_int_48MHz();
   
   TRISB=0;
    lcd_ini();
    lcd_envia_byte(LCD_CLEAR);
    lcd_envia_byte(LCD_CURSOR_OFF);
    lcd_envia_byte(LCD_CLEAR);
    
    CopyConstToRAM(ram_msg,text);
    Lcd4_Write_Text(ram_msg);
    tempo_ms(10);

    //Store Heart in CGRAM of LCD
    lcd_envia_byte(0x40); ////64 Envia o comando de escrita na CGRAM 4-bit mode, Padrao 5 x 7 
    for (i=0;i<=7;i++)
    {
        Lcd4_Write(character[i]);
    }

    lcd_envia_byte(SECOND_ROW);
    //Lcd4_Write('I');
    //Lcd4_Write(' ');
    
   Lcd4_Write(0);        //Custom Character
    
   //Lcd4_Write(' ');
   
   //CopyConstToRAM(ram_msg,love);
    //Lcd4_Write_Text(ram_msg);

    while(1){
        inverte_saida(pin_b7); inverte_saida(pin_d7);
        tempo_ms(500);
            }
}
Example #10
0
// envia caractere para o display
void lcd_escreve(char c)
{
	switch (c)
	{
    	case '\f':
			lcd_modulo = 0;
			lcd_envia_byte(0, 1);
	  		delay_ms(2);
			lcd_modulo = 1;
			lcd_x = 1;
			lcd_y = 1;
			break;

    	case '\n':
		case '\r':
			if(lcd_y < 4)
			{
				lcd_y ++;
			}
			lcd_x = 1;
			lcd_pos_xy(1, lcd_y);
			break;

    	case '\b':
			if(lcd_x > 0)
			{
				lcd_x --;
				lcd_envia_byte(0, 0x10);
			}
			break;

    	default:
			lcd_envia_byte(1, c);
			break;
   }
}
Example #11
0
File: lcd_4b.c Project: cukier/SPI
void lcd_init() {

	byte conta;

	output_low(rs);
	output_low(en);
	output_low(d4);
	output_low(d5);
	output_low(d6);
	output_low(d7);

	delay_ms(15);

	for (conta=1;conta<=3;conta++) {
		lcd_cmd(0x03);
		delay_ms(5);
	}
	lcd_cmd(0x02);          //escreve comando para interface de 4 vias de dados
	lcd_envia_byte(0,0x28); //escreve comando informando lcd de 2 linhas (5x7) em 4bits
	lcd_envia_byte(0,0x0c); //escreve comando para limpar todo o display
	lcd_envia_byte(0,0x01); //escreve comando para ligar o display **com cursor piscante
	lcd_envia_byte(0,0x06); //escreve comando para incrementar automaticamente á direita
	delay_ms(5);
} 
void lcd_pos_xy(char x, char y) {
    char address;
    address = (y != 1)? 0x40 : 0;
    address += x-1;
    lcd_envia_byte( 0x80 | address);
}