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
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration with most important and used symbols. -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionLcdDisplayComponent(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 TypeMethodDescriptionvoidClears the display and return the cursor to homevoidclearLine(int line) Clears a line of the displayvoidcreateCharacter(int location, byte[] character) Create a custom character by providing the single digit states of each pixel.protected voidexecuteCommand(byte command, byte data) Execute Display commandsprotected MCP23008getMcp()Get the current MCP instancevoidInitializes the LCD DisplayvoidReturns the Cursor to Home Position (First line, first character)voidMoves the cursor 1 character leftvoidMoves the cursor 1 character rightvoidMoves the whole displayed text one character rightvoidMoves the whole displayed text one character rightvoidsetCursorBlinking(boolean blink) Set the cursor to blinking or staticvoidsetCursorToLine(int line) Set the cursor to line 1 or 2voidsetCursorToPosition(int digit, int line) Sets the cursor to a target destinationvoidsetCursorVisibility(boolean show) Sets the display cursor to hidden or showingvoidsetDisplayBacklight(boolean state) Enable and Disable the Backlight of the LCD Displayprotected voidwrite(int c) Write a number (byte) to the LCD Displayprotected voidwrite(int b, boolean charMode) Write a Number (byte) or character according to the LCD DisplayvoidwriteCharacter(char c) Writes a character to the current cursor positionvoidwriteCharacter(char c, int digit, int line) Write a character to a specified place on the display.voidWrite a Line of Text on the LCD DisplayvoidWrite 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
-