Пример #1
0
func New(rs, enable, d0, d1, d2, d3 uint8) *LCD {
	lcd := &LCD{
		rs:              rs,
		enable:          enable,
		data:            [...]uint8{d0, d1, d2, d3},
		displayfunction: LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS,
		displaymode:     LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT,
	}
	rpi.PinMode(lcd.rs, rpi.OUTPUT)
	rpi.PinMode(lcd.enable, rpi.OUTPUT)
	lcd.Begin(16, 1)
	return lcd
}
Пример #2
0
func (l *LCD) write4bits(v uint8) {
	for i := uint8(0); i < 4; i++ {
		b := (v>>i)&0x01 == 0x01
		rpi.PinMode(l.data[i], rpi.OUTPUT)
		rpi.DigitalWrite(l.data[i], b)
	}
	l.pulseEnable()
}