void hd44780_init()
{
	// Setting lcd_port as output
	lcd_data_tris = 0x00;
	lcd_data = 0x00;
	// Delay for more than 15ms 
	__delay_ms(20);
	lcd_data = 0b00000011;
	hd44780_pulse();
	__delay_ms(5);
	lcd_data = 0b00000011;
	hd44780_pulse();
	__delay_us(120);
	lcd_data = 0b00000011;
	hd44780_pulse();
	//__delay_ms(5);
	hd44780_busy();
	// Setting function 4bit
	lcd_data = 0b00000010;
	hd44780_pulse();
	//__delay_ms(5);
	hd44780_busy();
	// Data is now to be sent as 4bit

	hd44780_write( 0b00101000 );
	//hd44780_write( 0b00001111 );
	hd44780_write( 0b00001100 );
	hd44780_write( 0b00000001 );
	hd44780_write( 0b00000110 );
}
void hd44780_printchr( char dta, unsigned char loc )
{
	// Placing cursor
	hd44780_write( 0x80 | loc );

	hd44780_char( dta );
}
Beispiel #3
0
void
hd44780_data(uint8_t byte)
{
//	printf("[%02hhx]",byte);
	hd44780_write(byte,HD44780_DATA);
	_delay_us(74); /* 37us (datasheet) */
}
void hd44780_char( unsigned char bt )
{
	// Writing to data register, not instruction register
	lcd_rs = 1;
	rs_flag = 1;
	hd44780_write( bt );
	lcd_rs = 0;
	rs_flag = 0;
}
void hd44780_block_erase( unsigned char start_loc, unsigned char length )
{
	int i;

	// Placing cursor
	for(i=0;i<length;i++){
		hd44780_write( 0x80 | (start_loc+i) );

		hd44780_char( ' ' );
	}
}
Beispiel #6
0
void
hd44780_cmd(uint8_t byte)
{
//	printf("<%02hhx>",byte);
	hd44780_write(byte,HD44780_CMD);

	if(byte == 0x01 || (byte & 0xfe) == 0x02){
		_delay_us(3040); /* 1,52 ms (datasheet) */
	} else {
		_delay_us(74);   /* 37 us (datasheet) */
	}
}
void hd44780_printstr( char *dta, unsigned char loc )
{
	// Placing cursor
	//hd44780_write( 0b10000001 );
	hd44780_write( 0x80 | loc );

	while( *dta != '\0' ){
		if( *dta != '\n' ){
			hd44780_char( *dta );
		}else{
			//hd44780_write( 0xC0 );
			hd44780_newline();
		}

		dta++;
	}
}
Beispiel #8
0
void hd44780_wr_data_noblock(const uint8_t data) {
	while (buttons_active) {}

	hd44780_RS_On();
	hd44780_write(data);
}
Beispiel #9
0
void hd44780_wr_cmd(const uint8_t cmd) {
	hd44780_RS_Off();
	hd44780_write(cmd);
}
Beispiel #10
0
void hd44780_wr_data( unsigned char data )
{
	hd44780_RS_On();
	hd44780_write( data );
}
Beispiel #11
0
void hd44780_wr_cmd( unsigned char cmd )
{
	hd44780_RS_Off();
	hd44780_write( cmd );
}
Beispiel #12
0
void hd44780_clear()
{
	// Writing to instruction register
	hd44780_write( 0b00000001 );
}
Beispiel #13
0
void hd44780_newline()
{
	hd44780_write( 0xC0 );
}