Ejemplo n.º 1
0
func (display *HD44780) pulseEnable(data byte) {
	display.expanderWrite(data | display.en) // En high
	hwio.DelayMicroseconds(1)                // enable pulse must be >450ns

	display.expanderWrite(data & ^display.en) // En low
	hwio.DelayMicroseconds(50)                // commands need > 37us to settle
}
Ejemplo n.º 2
0
func (display *HD44780) Init(cols int, lines int) {
	display.displayFunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS

	if lines > 1 {
		display.displayFunction |= LCD_2LINE
	}
	display.numLines = lines

	// for some 1 line displays you can select a 10 pixel high font
	// if (dotsize != 0) && (lines == 1) {
	// 	_displayfunction |= LCD_5x10DOTS
	// }

	// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
	// according to datasheet, we need at least 40ms after power rises above 2.7V
	// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
	hwio.DelayMicroseconds(50000)

	// Now we pull both RS and R/W low to begin commands
	display.backlight = display.bl
	display.expanderWrite(display.backlight) // reset expander and turn backlight off (Bit 8 =1)
	hwio.Delay(1000)

	//put the LCD into 4 bit mode
	// this is according to the hitachi HD44780 datasheet
	// figure 24, pg 46

	// we start in 8bit mode, try to set 4 bit mode
	display.write4bits(0x03, 0)
	hwio.DelayMicroseconds(4500) // wait min 4.1ms

	// // second try
	display.write4bits(0x03, 0)
	hwio.DelayMicroseconds(4500) // wait min 4.1ms

	// // third go!
	display.write4bits(0x03, 0)
	hwio.DelayMicroseconds(150)

	// // finally, set to 4-bit interface
	display.write4bits(0x02, 0)

	// set # lines, font size, etc.
	display.Command(LCD_FUNCTIONSET | display.displayFunction)

	// turn the display on with no cursor or blinking default
	display.displayControl = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF
	display.Display()

	// clear it off
	display.Clear()

	// Initialize to default text direction (for roman languages)
	display.displayMode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT

	// set the entry mode
	display.Command(LCD_ENTRYMODESET | display.displayMode)

	display.Home()
}
Ejemplo n.º 3
0
func (display *HD44780) Home() {
	display.Command(LCD_RETURNHOME) // set cursor position to zero
	hwio.DelayMicroseconds(2000)    // this command takes a long time!
}
Ejemplo n.º 4
0
func (display *HD44780) Clear() {
	display.Command(LCD_CLEARDISPLAY) // clear display, set cursor position to zero
	hwio.DelayMicroseconds(2000)      // this command takes a long time!
}