Class LcdDisplayComponent

java.lang.Object
com.pi4j.crowpi.components.Component
com.pi4j.crowpi.components.LcdDisplayComponent

public class LcdDisplayComponent extends Component
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 Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enumeration with most important and used symbols.
  • Field Summary

    Fields inherited from class com.pi4j.crowpi.components.Component

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    LcdDisplayComponent(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 Type
    Method
    Description
    void
    Clears the display and return the cursor to home
    void
    clearLine(int line)
    Clears a line of the display
    void
    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 commands
    protected MCP23008
    Get the current MCP instance
    void
    Initializes the LCD Display
    void
    Returns the Cursor to Home Position (First line, first character)
    void
    Moves the cursor 1 character left
    void
    Moves the cursor 1 character right
    void
    Moves the whole displayed text one character right
    void
    Moves the whole displayed text one character right
    void
    setCursorBlinking(boolean blink)
    Set the cursor to blinking or static
    void
    setCursorToLine(int line)
    Set the cursor to line 1 or 2
    void
    setCursorToPosition(int digit, int line)
    Sets the cursor to a target destination
    void
    setCursorVisibility(boolean show)
    Sets the display cursor to hidden or showing
    void
    setDisplayBacklight(boolean state)
    Enable and Disable the Backlight of the LCD Display
    protected void
    write(int c)
    Write a number (byte) to the LCD Display
    protected void
    write(int b, boolean charMode)
    Write a Number (byte) or character according to the LCD Display
    void
    Writes a character to the current cursor position
    void
    writeCharacter(char c, int digit, int line)
    Write a character to a specified place on the display.
    void
    writeLine(String text, int line)
    Write a Line of Text on the LCD Display
    void
    Write a text upto 32 characters to the display

    Methods inherited from class com.pi4j.crowpi.components.Component

    sleep, triggerSimpleEvent

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 context
      bus - Custom I2C bus address
      device - 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 write
      digit - Digit number on the line
      line - Line number on the display
    • writeLine

      public void writeLine(String text, int line)
      Write a Line of Text on the LCD Display
      Parameters:
      text - Text to display
      line - Select Line of Display
    • writeText

      public void writeText(String text)
      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 line
      line - 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 Command
      data - 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 display
      charMode - Select data is a number or character
    • getMcp

      protected MCP23008 getMcp()
      Get the current MCP instance
      Returns:
      MCP Instance of this LCD Display