func (l *LCD) pulseEnable() { rpi.DigitalWrite(l.enable, LOW) rpi.DelayMicroseconds(1) rpi.DigitalWrite(l.enable, HIGH) rpi.DelayMicroseconds(1) rpi.DigitalWrite(l.enable, LOW) rpi.DelayMicroseconds(100) }
func (l *LCD) Begin(cols, lines int) { if lines > 1 { l.displayfunction |= LCD_2LINE } rpi.DelayMicroseconds(50000) // Now we pull both RS and R/W low to begin commands rpi.DigitalWrite(l.rs, LOW) rpi.DigitalWrite(l.enable, LOW) // we start in 8bit mode, try to set 4 bit mode l.write4bits(0x03) rpi.DelayMicroseconds(4500) // wait min 4.1ms // we start in 8bit mode, try to set 4 bit mode l.write4bits(0x03) rpi.DelayMicroseconds(4500) // wait min 4.1ms // we start in 8bit mode, try to set 4 bit mode l.write4bits(0x03) rpi.DelayMicroseconds(150) // finally, set to 8-bit interface l.write4bits(0x02) // finally, set # lines, font size, etc. l.command(LCD_FUNCTIONSET | l.displayfunction) // turn the display on with no cursor or blinking default l.displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF l.Display() // clear it off l.Clear() // Initialize to default text direction (for romance languages) l.displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT // set the entry mode l.command(LCD_ENTRYMODESET | l.displaymode) }
func (l *LCD) Clear() { l.command(LCD_CLEARDISPLAY) // clear display, set cursor position to zero rpi.DelayMicroseconds(2000) // this command takes a long time! }