upm  1.1.0
Sensor/Actuator repository for libmraa (v1.5.1)
 All Classes Functions Groups Pages
Public Member Functions | List of all members
Lcm1602 Class Reference

API for the LCM1602 I2C controller for HD44780-based displays. More...

Detailed Description

This supports all sizes of HD44780 displays, from 16x2 to 4x20. The controller has no idea of the actual display hardware, so it lets you write farther than you can see. These displays with such controllers are available from various manufacturers with different I2C addresses. Adafruit* TC1602A-01T seems to be a well-documented example. The driver also supports parallel GPIO connections directly to the HD44780 in case you are not using an I2C expander/backpack.

lcm1602.jpeg

Example for LCM1602 displays that use the I2C bus

lcd.setCursor(0, 0);
lcd.write("Hello World");
Thread.sleep(3000);
lcd.setCursor(1, 2);
lcd.write("Hello World");
Thread.sleep(3000);
lcd.setCursor(2, 4);
lcd.write("Hello World");
Thread.sleep(3000);
lcd.setCursor(3, 6);
lcd.write("Hello World");
Thread.sleep(3000);

Code sample for GPIO based LCM1602 displays

Public Member Functions

synchronized void delete ()
 
 Lcm1602 (int bus, int address, boolean isExpander, short numColumns, short numRows)
 
 Lcm1602 (int bus, int address, boolean isExpander, short numColumns)
 
 Lcm1602 (int bus, int address, boolean isExpander)
 
 Lcm1602 (int bus, int address)
 
 Lcm1602 (int bus)
 
 Lcm1602 (int rs, int enable, int d0, int d1, int d2, int d3, short numColumns, short numRows)
 
 Lcm1602 (int rs, int enable, int d0, int d1, int d2, int d3, short numColumns)
 
 Lcm1602 (int rs, int enable, int d0, int d1, int d2, int d3)
 
int write (String msg)
 
int setCursor (int row, int column)
 
int clear ()
 
int home ()
 
int createChar (short charSlot, byte[] charData)
 
int displayOn ()
 
int displayOff ()
 
int cursorOn ()
 
int cursorOff ()
 
int cursorBlinkOn ()
 
int cursorBlinkOff ()
 
int backlightOn ()
 
int backlightOff ()
 
int scrollDisplayLeft ()
 
int scrollDisplayRight ()
 
int entryLeftToRight ()
 
int entryRightToLeft ()
 
int autoscrollOn ()
 
int autoscrollOff ()
 
- Public Member Functions inherited from LCD
synchronized void delete ()
 
int write (int x, int y, String msg)
 
int write (String msg)
 
int setCursor (int row, int column)
 
int clear ()
 
int home ()
 
String name ()
 

Constructor & Destructor Documentation

Lcm1602 ( int  bus,
int  address,
boolean  isExpander,
short  numColumns,
short  numRows 
)

Lcm1602 constructor; calls libmraa initialisation functions

Parameters
busI2C bus to use. Default 0 (autodetect).
addressSlave address the LCD is registered on. Default 0x27
isExpanderTrue if we are dealing with an I2C expander, false otherwise. Default is true.
numColumnsNumber of columns the display has. Default 16.
numRowsNumber of rows the display has. Default 2.
Lcm1602 ( int  rs,
int  enable,
int  d0,
int  d1,
int  d2,
int  d3,
short  numColumns,
short  numRows 
)

Lcm1602 alternate constructor, used for GPIO based HD44780 controllers supporting RS, Enable, and 4 data pins in 4-bit mode.

Parameters
rsRegister select pin
enableEnable pin
d0Data 0 pin
d1Data 1 pin
d2Data 2 pin
d3Data 3 pin
numColumnsNumber of columns the display has. Default 16.
numRowsNumber of rows the display has. Default 2.

Member Function Documentation

int autoscrollOff ( )

Left justify text entered from the cursor

Returns
Result of operation
int autoscrollOn ( )

Right justify text entered from the cursor

Returns
Result of operation
int backlightOff ( )

Turn backlight off

Returns
Result of operation
int backlightOn ( )

Turn backlight on

Returns
Result of operation
int clear ( )

Clears the display of all characters

Returns
Result of the operation
int createChar ( short  charSlot,
byte[]  charData 
)

Create a custom character

Parameters
charSlotthe character slot to write, only 8 are available
charDataThe character data (8 bytes) making up the character
Returns
Result of operation
int cursorBlinkOff ( )

Turn cursor blink off

Returns
Result of operation
int cursorBlinkOn ( )

Turn cursor blink on

Returns
Result of operation
int cursorOff ( )

Turn the cursor off

Returns
Result of operation
int cursorOn ( )

Turn the cursor on

Returns
Result of operation
int displayOff ( )

Turn the display off

Returns
Result of operation
int displayOn ( )

Turn the display on

Returns
Result of operation
int entryLeftToRight ( )

set the entry mode so that characters are added left to right

Returns
Result of operation
int entryRightToLeft ( )

set the entry mode so that characters are added right to left

Returns
Result of operation
int home ( )

Returns to the original coordinates (0,0)

Returns
Result of the operation
int scrollDisplayLeft ( )

Scroll the display left, without changing the character RAM

Returns
Result of operation
int scrollDisplayRight ( )

Scroll the display right, without changing the character RAM

Returns
Result of operation
int setCursor ( int  row,
int  column 
)

Sets the cursor to specified coordinates

Parameters
rowRow to set the cursor to
columnColumn to set the cursor to
Returns
Result of the operation
int write ( String  msg)

Writes a string to the LCD

Parameters
msgstd::string to write to the display; note: only ASCII characters are supported
Returns
Result of the operation
Inheritance diagram for Lcm1602:
Inheritance graph
[legend]
Collaboration diagram for Lcm1602:
Collaboration graph
[legend]

The documentation for this class was generated from the following file: