Package com.diozero.devices
Class HD44780Lcd.GpioLcdConnection
- java.lang.Object
-
- com.diozero.devices.HD44780Lcd.GpioLcdConnection
-
- All Implemented Interfaces:
HD44780Lcd.LcdConnection
,AutoCloseable
- Enclosing class:
- HD44780Lcd
public static class HD44780Lcd.GpioLcdConnection extends Object implements HD44780Lcd.LcdConnection
Connect via individual GPIO pins, uses 4-bit mode (data pins D4-D7). Wiring (from left-to-right):Vss: GND Vdd: 5v V0: Contrast adjustment (connect to Vdd for full brightness) RS: Register Select - GPIO RW: Data read/write (not required, read mode not used - can connect to GND) E: Enable - GPIO D0-D3: Don't connect (currently only 4-bit mode is supported) D4-D7: Data pins - GPIO A: Backlight LED Cathode (+) - GPIO (need to check 3v3/5v) or Vdd (always on) K: Backlight LED Anode (-) - GND
-
-
Constructor Summary
Constructors Constructor Description GpioLcdConnection(int d4, int d5, int d6, int d7, int enableGpio, int registerSelectGpio)
Use the default device factory and specify GPIO numbers.GpioLcdConnection(int d4, int d5, int d6, int d7, int backlightGpio, int enableGpio, int registerSelectGpio)
Use the default device factory and specify GPIO numbers.GpioLcdConnection(int d4, int d5, int d6, int d7, int backlightGpio, int enableGpio, int dataRwGpio, int registerSelectGpio)
Use the default device factory and specify GPIO numbers.GpioLcdConnection(DigitalOutputDevice d4, DigitalOutputDevice d5, DigitalOutputDevice d6, DigitalOutputDevice d7, DigitalOutputDevice backlightPin, DigitalOutputDevice enablePin, DigitalOutputDevice dataRwPin, DigitalOutputDevice registerSelectPin)
Use the specified digital output devices.GpioLcdConnection(GpioDeviceFactoryInterface deviceFactory, int d4, int d5, int d6, int d7, int backlightGpio, int enableGpio, int dataRwGpio, int registerSelectGpio)
Use the specified device factory and specify GPIO numbers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
int
getBacklightBit()
Identify the bit in the byte payload that refers to the backlight control flag 1=on, 0=off.int
getDataReadWriteBit()
Identify the bit in the byte payload that refers to the read/write flag.int
getEnableBit()
Identify the bit in the byte payload that refers to the enable flag to start read/write.int
getRegisterSelectBit()
Identify the bit in the byte payload that refers to the register select flag.boolean
isDataInHighNibble()
Control whether the data bits in the first or last 4-bitsvoid
write(byte values)
-
-
-
Constructor Detail
-
GpioLcdConnection
public GpioLcdConnection(int d4, int d5, int d6, int d7, int enableGpio, int registerSelectGpio)
Use the default device factory and specify GPIO numbers. Assumes the RW pin is pulled low and the backlight pin pulled high.- Parameters:
d4
- GPIO number for d4 pind5
- GPIO number for d5 pind6
- GPIO number for d6 pind7
- GPIO number for d7 pinenableGpio
- enable GPIO numberregisterSelectGpio
- register select GPIO number
-
GpioLcdConnection
public GpioLcdConnection(int d4, int d5, int d6, int d7, int backlightGpio, int enableGpio, int registerSelectGpio)
Use the default device factory and specify GPIO numbers. Assumes the RW pin is pulled low.- Parameters:
d4
- GPIO number for d4 pind5
- GPIO number for d5 pind6
- GPIO number for d6 pind7
- GPIO number for d7 pinbacklightGpio
- backlight control GPIO number (set to -1 if not connected)enableGpio
- enable GPIO numberregisterSelectGpio
- register select GPIO number
-
GpioLcdConnection
public GpioLcdConnection(int d4, int d5, int d6, int d7, int backlightGpio, int enableGpio, int dataRwGpio, int registerSelectGpio)
Use the default device factory and specify GPIO numbers.- Parameters:
d4
- GPIO number for d4 pind5
- GPIO number for d5 pind6
- GPIO number for d6 pind7
- GPIO number for d7 pinbacklightGpio
- backlight control GPIO number (set to -1 if not connected)enableGpio
- enable GPIO numberdataRwGpio
- data read/write GPIO number (not used - connect to GND, set to -1 if not connected)registerSelectGpio
- register select GPIO number
-
GpioLcdConnection
public GpioLcdConnection(GpioDeviceFactoryInterface deviceFactory, int d4, int d5, int d6, int d7, int backlightGpio, int enableGpio, int dataRwGpio, int registerSelectGpio)
Use the specified device factory and specify GPIO numbers.- Parameters:
deviceFactory
- the device factory to use for provisioning the GPIOsd4
- GPIO number for d4 pind5
- GPIO number for d5 pind6
- GPIO number for d6 pind7
- GPIO number for d7 pinbacklightGpio
- backlight control GPIO number (set to -1 if not connected)enableGpio
- enable GPIO numberdataRwGpio
- data read/write GPIO number (not used - connect to GND, set to -1 if not connected)registerSelectGpio
- register select GPIO number
-
GpioLcdConnection
public GpioLcdConnection(DigitalOutputDevice d4, DigitalOutputDevice d5, DigitalOutputDevice d6, DigitalOutputDevice d7, DigitalOutputDevice backlightPin, DigitalOutputDevice enablePin, DigitalOutputDevice dataRwPin, DigitalOutputDevice registerSelectPin)
Use the specified digital output devices.- Parameters:
d4
- Digital output device for d4 pind5
- Digital output device for d5 pind6
- Digital output device for d6 pind7
- Digital output device for d7 pinbacklightPin
- backlight control digital output device (set to null if not connected)enablePin
- enable digital output devicedataRwPin
- data read/write digital output device (not used - connect to GND, set to null if not connected)registerSelectPin
- register select digital output device
-
-
Method Detail
-
write
public void write(byte values)
- Specified by:
write
in interfaceHD44780Lcd.LcdConnection
-
isDataInHighNibble
public boolean isDataInHighNibble()
Description copied from interface:HD44780Lcd.LcdConnection
Control whether the data bits in the first or last 4-bits- Specified by:
isDataInHighNibble
in interfaceHD44780Lcd.LcdConnection
- Returns:
- true if the data bits are in the high nibble (bits 4:7)
-
getBacklightBit
public int getBacklightBit()
Description copied from interface:HD44780Lcd.LcdConnection
Identify the bit in the byte payload that refers to the backlight control flag 1=on, 0=off.- Specified by:
getBacklightBit
in interfaceHD44780Lcd.LcdConnection
- Returns:
- the backlight control bit number
-
getEnableBit
public int getEnableBit()
Description copied from interface:HD44780Lcd.LcdConnection
Identify the bit in the byte payload that refers to the enable flag to start read/write. Falling edge triggered- Specified by:
getEnableBit
in interfaceHD44780Lcd.LcdConnection
- Returns:
- the enable flag bit number
-
getDataReadWriteBit
public int getDataReadWriteBit()
Description copied from interface:HD44780Lcd.LcdConnection
Identify the bit in the byte payload that refers to the read/write flag. Not implemented. R/W=0: Write, R/W=1: Read- Specified by:
getDataReadWriteBit
in interfaceHD44780Lcd.LcdConnection
- Returns:
- the read/write flag bit number
-
getRegisterSelectBit
public int getRegisterSelectBit()
Description copied from interface:HD44780Lcd.LcdConnection
Identify the bit in the byte payload that refers to the register select flag. RS=0: Command, RS=1: Data- Specified by:
getRegisterSelectBit
in interfaceHD44780Lcd.LcdConnection
- Returns:
- the register select flag bit number
-
close
public void close() throws RuntimeIOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceHD44780Lcd.LcdConnection
- Throws:
RuntimeIOException
-
-