public class LCM1602 extends I2CComponent
Datasheet: LCM_MODULE (part 1), LCM_MODULE (part 2)
To use this display, we use the 4-Bit interface (cfr. [datasheet - p.13]).
Example of use: LCM1602Example
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LCM1602_ADDRESS
Default i2c LCM1602 address.
|
static int |
MAX_COL_NB
Maximum index used for columns on the LCD.
|
static int |
MAX_LINE_NB
Maximum index used for the lines on the LCD.
|
static int |
MIN_COL_NB
Minimum index used for columns on the LCD.
|
static int |
MIN_LINE_NB
Minimum index used for the lines on the LCD.
|
static int |
NB_COL
Number of columns on the LCD.
|
static int |
NB_LINES
Number of lines on the LCD.
|
device, MAX_I2C_ADDRESS, MIN_I2C_ADDRESS
Constructor and Description |
---|
LCM1602()
Default constructor for an LCM1602 using the default LCM i2c address.
|
LCM1602(int i2cAddress)
Constructor for an LCM1602 using a specific i2cAddress.
|
Modifier and Type | Method and Description |
---|---|
void |
clearDisplay()
Clears the content of the display and move the cursor to the (0,0) position.
|
void |
disableDisplay()
Disable the display.
|
void |
moveCursor(int line,
int col)
Moves the cursor to the given position.
|
void |
returnHome()
The cursor is shifted to its original position (0, 0) if shifted,
and the content of the display is not changed.
|
void |
setDisplay(boolean enableDisplay,
boolean enableCursor,
boolean enableBlinkingCursor)
Sets the display according to the specified parameters.
|
void |
setEntryMode(boolean cursorMovingFromLeftToRight,
boolean enableEntireDisplayShift)
Assigns cursor moving direction and enable the shift of entire display.
|
void |
setFunction(boolean heightBitsInterface,
boolean twoLines,
boolean fiveTenDots)
Sets the interface data length (8bit/4bit),
the number of display lines (2-line/1-line) and
the display font type (5x10 dots/5x8 dots).
|
void |
writeText(int line,
int col,
java.lang.String text)
Sets the current cursor position to (line, col),
and writes a text starting at this position.
|
void |
writeText(java.lang.String text)
Writes a text on the display, starting at the current cursor position.
|
void |
writeTextRightAlign(int line,
java.lang.String text)
Writes a text from left to right.
|
getDevice, getType, readSignedRegisterValue, readTwoSignedRegsiters, readTwoUnsignedRegisters, readUnsignedRegisterValue, writeUnsignedValueDirectlyToI2CDevice, writeUnsignedValueToRegister
public static final int DEFAULT_LCM1602_ADDRESS
public static final int NB_LINES
public static final int NB_COL
public static final int MAX_LINE_NB
public static final int MIN_LINE_NB
public static final int MAX_COL_NB
public static final int MIN_COL_NB
public LCM1602()
public LCM1602(int i2cAddress)
i2cAddress
- the i2c address of the LCM1602.public void clearDisplay()
public void returnHome()
public void setEntryMode(boolean cursorMovingFromLeftToRight, boolean enableEntireDisplayShift)
cursorMovingFromLeftToRight
- true for a cursor moving from left to right.
False for a cursor moving from right to left.enableEntireDisplayShift
- true to enable the entire display shift. False to disable.public void setDisplay(boolean enableDisplay, boolean enableCursor, boolean enableBlinkingCursor)
Note: the cursor position can't be changed.
enableDisplay
- the display is enabled/disabled (on/off).enableCursor
- a cursor is displayed at the current cursor position "_".enableBlinkingCursor
- a plein cursor is displayed and blinking at the current cursor position.public void disableDisplay()
The content of the display is deleted and the cursor is moved to (0,0).
public void setFunction(boolean heightBitsInterface, boolean twoLines, boolean fiveTenDots)
heightBitsInterface
- 8bit if true, 4bit if false.twoLines
- 2-line if true, 1-line if false.fiveTenDots
- 5x10 if true, 5x8 if false.public void moveCursor(int line, int col)
line
- the new line of the cursor, in the MIN_LINE_NB
..MAX_LINE_NB
interval.col
- the new column of the cursor, in the MIN_COL_NB
..MAX_COL_NB
interval.public void writeText(java.lang.String text)
text
- the text to print on the display.public void writeText(int line, int col, java.lang.String text)
line
- the new line for the cursor.col
- the new column for the cursor.text
- the text to print on the display.public void writeTextRightAlign(int line, java.lang.String text)
NB_COL
.
Pay attention to the length of the text. The screen is only 2x16 chars. If the text is too long, some chars may not be displayed. It is for you to manage.
line
- the line to print the text.text
- the text to print on the display.