Ejemplo n.º 1
0
/* initializes lcd for use, this or lcd_init_wo_ir MUST be called first
 *
 * Note: this function does NOT assume internel reset circuit power 
 * conditions were met
 */
void lcd_init(void) 
{
	int i; 

	/* set control pins as output */
	DDR(EN_PORT) |= _BV(EN_PIN);
	DDR(RW_PORT) |= _BV(RW_PIN);
	DDR(RS_PORT) |= _BV(RS_PIN); 

	/* set data pins as output */
	data_pins_out();

	/* wait until lcd is finished booting */
	_delay_us(BOOT_DELAY);	

	/* set control pins for function set */
	for (i = 0; i < 3; i++) {
		set_rs_low();
		set_rw_low();
		set_data_pins(F_SET_INITIAL);
		toggle_e(); 
		_delay_us(INIT_DELAY); 
	}

	/* final function set, set's 8bit operation, 2-line disp, 5x8 font */
	set_data_pins(F_SET_DEFAULT);
	toggle_e(); 
	_delay_us(INIT_DELAY); 

	lcd_command(DISP_OFF);		/* display off */
	lcd_command(CLEAR_DISP);	/* display clear*/
	lcd_command(ENTRY_DEFAULT); 	/* set entry mode to INC, no shift */
	lcd_command(DISP_ON);		/* display on */
}
Ejemplo n.º 2
0
/* writes byte to controller
 * Input	data	byte to write to LCD
 * 		rs	1: write data
 * 			0: write instruction
 */
static void lcd_write(uint8_t data, uint8_t rs) 
{
	if (rs)
		set_rs_high(); 
	else
		set_rs_low(); 
	set_rw_low(); 		/* RW=0 for all write operations */
	data_pins_out(); 	/* set's data pins for output */

	set_data_pins(data); 
	
	toggle_e(); 
}
Ejemplo n.º 3
0
// rs = TRUE to write data, FALSE to write to command
static void lcd_write(const HD44780* device,uint8_t data,boolean rs){

    lcd_waitbusy(device);

    pin_set(device->ctrlRS, rs);
    pin_low(device->ctrlRW);		// write mode

	/* configure data pins as output */
    databus_output(device);

    if(device->fourBit){
    	// High nibble first
    	writeNibble(device,data>>4,4);
    	toggle_e(device);
    	// Low nibble last
    	writeNibble(device,data,4);
    	toggle_e(device);

    	/* all data pins high (inactive) */
    	for(uint8_t pin=4; pin<8; pin++){
    		pin_high(device->data[pin]);
    	}
    }else{