java.lang.Object
com.pi4j.crowpi.components.Component
com.pi4j.crowpi.components.LcdDisplayComponent
This class provides a simple usage of a LCD Display with Pi4J and the CrowPi.
There are different ways possible to use this functionalities from pretty simple to a bit more basic and advanced. *
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumeration with most important and used symbols. -
Field Summary
-
Constructor Summary
ConstructorDescriptionLcdDisplayComponent
(com.pi4j.context.Context pi4j) Creates a new LCD Display component using the default setup.LcdDisplayComponent
(com.pi4j.context.Context pi4j, int bus, int device) Creates a new LCD Display component with custom bus, device address -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the display and return the cursor to homevoid
clearLine
(int line) Clears a line of the displayvoid
createCharacter
(int location, byte[] character) Create a custom character by providing the single digit states of each pixel.protected void
executeCommand
(byte command, byte data) Execute Display commandsprotected MCP23008
getMcp()
Get the current MCP instancevoid
Initializes the LCD Displayvoid
Returns the Cursor to Home Position (First line, first character)void
Moves the cursor 1 character leftvoid
Moves the cursor 1 character rightvoid
Moves the whole displayed text one character rightvoid
Moves the whole displayed text one character rightvoid
setCursorBlinking
(boolean blink) Set the cursor to blinking or staticvoid
setCursorToLine
(int line) Set the cursor to line 1 or 2void
setCursorToPosition
(int digit, int line) Sets the cursor to a target destinationvoid
setCursorVisibility
(boolean show) Sets the display cursor to hidden or showingvoid
setDisplayBacklight
(boolean state) Enable and Disable the Backlight of the LCD Displayprotected void
write
(int c) Write a number (byte) to the LCD Displayprotected void
write
(int b, boolean charMode) Write a Number (byte) or character according to the LCD Displayvoid
writeCharacter
(char c) Writes a character to the current cursor positionvoid
writeCharacter
(char c, int digit, int line) Write a character to a specified place on the display.void
Write a Line of Text on the LCD Displayvoid
Write a text upto 32 characters to the displayMethods inherited from class com.pi4j.crowpi.components.Component
sleep, triggerSimpleEvent
-
Constructor Details
-
LcdDisplayComponent
public LcdDisplayComponent(com.pi4j.context.Context pi4j) Creates a new LCD Display component using the default setup.- Parameters:
pi4j
- Pi4J context
-
LcdDisplayComponent
public LcdDisplayComponent(com.pi4j.context.Context pi4j, int bus, int device) Creates a new LCD Display component with custom bus, device address- Parameters:
pi4j
- Pi4J contextbus
- Custom I2C bus addressdevice
- Custom device address on I2C
-
-
Method Details
-
initialize
public void initialize()Initializes the LCD Display -
writeCharacter
public void writeCharacter(char c) Writes a character to the current cursor position- Parameters:
c
- Character which is written to the LCD Display
-
writeCharacter
public void writeCharacter(char c, int digit, int line) Write a character to a specified place on the display.- Parameters:
c
- Character to writedigit
- Digit number on the lineline
- Line number on the display
-
writeLine
Write a Line of Text on the LCD Display- Parameters:
text
- Text to displayline
- Select Line of Display
-
writeText
Write a text upto 32 characters to the display- Parameters:
text
- Text to write to the display
-
moveCursorHome
public void moveCursorHome()Returns the Cursor to Home Position (First line, first character) -
moveCursorRight
public void moveCursorRight()Moves the cursor 1 character right -
moveCursorLeft
public void moveCursorLeft()Moves the cursor 1 character left -
setCursorToPosition
public void setCursorToPosition(int digit, int line) Sets the cursor to a target destination- Parameters:
digit
- Selects the character of the lineline
- Selects the line of the display
-
setCursorToLine
public void setCursorToLine(int line) Set the cursor to line 1 or 2- Parameters:
line
- Sets the cursor to this line. Only Range 1-2 allowed.
-
setCursorVisibility
public void setCursorVisibility(boolean show) Sets the display cursor to hidden or showing- Parameters:
show
- Set the state of the cursor
-
setCursorBlinking
public void setCursorBlinking(boolean blink) Set the cursor to blinking or static- Parameters:
blink
- Blink = true means the cursor will change to blinking mode. False let's the cursor stay static
-
moveDisplayRight
public void moveDisplayRight()Moves the whole displayed text one character right -
moveDisplayLeft
public void moveDisplayLeft()Moves the whole displayed text one character right -
createCharacter
public void createCharacter(int location, byte[] character) Create a custom character by providing the single digit states of each pixel. Simply pass an Array of bytes which will be translated to a character.- Parameters:
location
- Set the memory location of the character. 1 - 7 is possible.character
- Byte array representing the pixels of a character
-
setDisplayBacklight
public void setDisplayBacklight(boolean state) Enable and Disable the Backlight of the LCD Display- Parameters:
state
- Set Backlight ON or OFF
-
clearDisplay
public void clearDisplay()Clears the display and return the cursor to home -
clearLine
public void clearLine(int line) Clears a line of the display- Parameters:
line
- Select line to clear
-
executeCommand
protected void executeCommand(byte command, byte data) Execute Display commands- Parameters:
command
- Select the LCD Commanddata
- Setup command data
-
write
protected void write(int c) Write a number (byte) to the LCD Display- Parameters:
c
- Number to write to the Display
-
write
protected void write(int b, boolean charMode) Write a Number (byte) or character according to the LCD Display- Parameters:
b
- Data to write to the displaycharMode
- Select data is a number or character
-
getMcp
Get the current MCP instance- Returns:
- MCP Instance of this LCD Display
-