upm  1.0.2
Sensor/Actuator repository for libmraa (v1.1.1)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes
Jhd1313m1 Class Reference

API for the JHD1313M1 I2C controller for HD44780-based displays with an RGB backlight, such as a Grove RGB I2C LCD display. More...

Detailed Description

JHD1313M1 has two I2C addreses: one belongs to a controller, very similar to the upm::Lcm1602 LCD driver, that controls the HD44780-based display, and the other controls only the backlight. This module was tested with the Seeed Grove LCD RGB Backlight v2.0 display that requires 5V to operate.

grovergblcd.jpg
// 0x62 RGB_ADDRESS, 0x3E LCD_ADDRESS
upm::Jhd1313m1 lcd(0, 0x3E, 0x62);
int ndx = 0;
uint8_t rgb[7][3] = {
{0xd1, 0x00, 0x00},
{0xff, 0x66, 0x22},
{0xff, 0xda, 0x21},
{0x33, 0xdd, 0x00},
{0x11, 0x33, 0xcc},
{0x22, 0x00, 0x66},
{0x33, 0x00, 0x44}};
while (shouldRun)
{
// Alternate rows on the LCD
lcd.setCursor(ndx%2,0);
// Change the color
uint8_t r = rgb[ndx%7][0];
uint8_t g = rgb[ndx%7][1];
uint8_t b = rgb[ndx%7][2];
lcd.setColor(r, g, b);
lcd.write("Hello World " + std::to_string(ndx));
// Echo via printf
printf("Hello World %d rgb: 0x%02x%02x%02x\n", ndx++, r, g, b);
sleep(1);
}

Public Member Functions

 Jhd1313m1 (int bus, int lcdAddress=0x3E, int rgbAddress=0x62)
 
 ~Jhd1313m1 ()
 
upm_result_t write (std::string msg)
 
upm_result_t scroll (bool direction)
 
upm_result_t setColor (uint8_t r, uint8_t g, uint8_t b)
 
upm_result_t setCursor (int row, int column)
 
upm_result_t clear ()
 
upm_result_t home ()
 
upm_result_t createChar (uint8_t charSlot, jhd1313m1_custom_char_t charData)
 
upm_result_t displayOn ()
 
upm_result_t displayOff ()
 
upm_result_t cursorOn ()
 
upm_result_t cursorOff ()
 
upm_result_t cursorBlinkOn ()
 
upm_result_t cursorBlinkOff ()
 
upm_result_t backlightOn ()
 
upm_result_t backlightOff ()
 
upm_result_t scrollDisplayLeft ()
 
upm_result_t scrollDisplayRight ()
 
upm_result_t entryLeftToRight ()
 
upm_result_t entryRightToLeft ()
 
upm_result_t autoscrollOn ()
 
upm_result_t autoscrollOff ()
 
 Jhd1313m1 (int bus, int lcdAddress=0x3E, int rgbAddress=0x62)
 
 ~Jhd1313m1 ()
 
mraa::Result scroll (bool direction)
 
mraa::Result setColor (uint8_t r, uint8_t g, uint8_t b)
 
mraa::Result backlightOn ()
 
mraa::Result backlightOff ()
 
- Public Member Functions inherited from Lcm1602
 Lcm1602 (int bus=0, int address=0x27, bool isExpander=true, uint8_t numColumns=16, uint8_t numRows=2)
 
 Lcm1602 (int rs, int enable, int d0, int d1, int d2, int d3, uint8_t numColumns=16, uint8_t numRows=2)
 
 ~Lcm1602 ()
 
mraa::Result write (std::string msg)
 
mraa::Result setCursor (int row, int column)
 
mraa::Result clear ()
 
mraa::Result home ()
 
mraa::Result createChar (uint8_t charSlot, uint8_t charData[])
 
mraa::Result displayOn ()
 
mraa::Result displayOff ()
 
mraa::Result cursorOn ()
 
mraa::Result cursorOff ()
 
mraa::Result cursorBlinkOn ()
 
mraa::Result cursorBlinkOff ()
 
mraa::Result backlightOn ()
 
mraa::Result backlightOff ()
 
mraa::Result scrollDisplayLeft ()
 
mraa::Result scrollDisplayRight ()
 
mraa::Result entryLeftToRight ()
 
mraa::Result entryRightToLeft ()
 
mraa::Result autoscrollOn ()
 
mraa::Result autoscrollOff ()
 
 Lcm1602 (int bus=0, int address=0x27, bool isExpander=true, uint8_t numColumns=16, uint8_t numRows=2)
 
 Lcm1602 (int rs, int enable, int d0, int d1, int d2, int d3, uint8_t numColumns=16, uint8_t numRows=2)
 
 ~Lcm1602 ()
 
upm_result_t write (std::string msg)
 
upm_result_t setCursor (int row, int column)
 
upm_result_t clear ()
 
upm_result_t home ()
 
upm_result_t createChar (uint8_t charSlot, lcm1602_custom_char_t charData)
 
upm_result_t displayOn ()
 
upm_result_t displayOff ()
 
upm_result_t cursorOn ()
 
upm_result_t cursorOff ()
 
upm_result_t cursorBlinkOn ()
 
upm_result_t cursorBlinkOff ()
 
upm_result_t backlightOn ()
 
upm_result_t backlightOff ()
 
upm_result_t scrollDisplayLeft ()
 
upm_result_t scrollDisplayRight ()
 
upm_result_t entryLeftToRight ()
 
upm_result_t entryRightToLeft ()
 
upm_result_t autoscrollOn ()
 
upm_result_t autoscrollOff ()
 
- Public Member Functions inherited from LCD
mraa::Result write (int x, int y, std::string msg)
 
std::string name ()
 

Protected Member Functions

upm_result_t command (uint8_t cmd)
 
upm_result_t data (uint8_t data)
 
virtual mraa::Result command (uint8_t cmd)
 
virtual mraa::Result data (uint8_t data)
 
- Protected Member Functions inherited from Lcm1602
mraa::Result send (uint8_t value, int mode)
 
mraa::Result write4bits (uint8_t value)
 
mraa::Result expandWrite (uint8_t value)
 
mraa::Result pulseEnable (uint8_t value)
 
upm_result_t command (uint8_t cmd)
 
upm_result_t data (uint8_t data)
 

Protected Attributes

jhd1313m1_context m_jhd1313m1
 
- Protected Attributes inherited from Lcm1602
uint8_t m_displayControl
 
uint8_t m_entryDisplayMode
 
uint8_t m_numColumns
 
uint8_t m_numRows
 
mraa::I2c * m_i2c_lcd_control
 
mraa::Gpio * m_gpioRS
 
mraa::Gpio * m_gpioEnable
 
mraa::Gpio * m_gpioD0
 
mraa::Gpio * m_gpioD1
 
mraa::Gpio * m_gpioD2
 
mraa::Gpio * m_gpioD3
 
uint8_t m_backlight
 
int m_lcd_control_address
 
lcm1602_context m_lcm1602
 
- Protected Attributes inherited from LCD
std::string m_name
 

Constructor & Destructor Documentation

Jhd1313m1 ( int  bus,
int  lcdAddress = 0x3E,
int  rgbAddress = 0x62 
)

Jhd1313m1 constructor

Parameters
busI2C bus to use
addressSlave address the LCD is registered on
addressSlave address the RGB backlight is registered on
~Jhd1313m1 ( )

Jhd1313m1 destructor

Here is the call graph for this function:

Jhd1313m1 ( int  bus,
int  lcdAddress = 0x3E,
int  rgbAddress = 0x62 
)

Jhd1313m1 constructor

Parameters
busI2C bus to use
addressSlave address the LCD is registered on
addressSlave address the RGB backlight is registered on
~Jhd1313m1 ( )

Jhd1313m1 destructor

Member Function Documentation

upm_result_t write ( std::string  msg)
virtual

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

Implements LCD.

Here is the call graph for this function:

mraa::Result scroll ( bool  direction)

Makes the LCD scroll text

Parameters
directionTrue if scrolling to the right, false otherwise
Returns
Result of the operation

Here is the call graph for this function:

mraa::Result setColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets the color of the backlight Can be used to change the color even when the backlight is off

Parameters
r0-255 value for red
g0-255 value for green
b0-255 value for blue
Returns
Result of the operation

Here is the call graph for this function:

upm_result_t setCursor ( int  row,
int  column 
)
virtual

Sets the cursor to specified coordinates

Parameters
rowRow to set the cursor to
columnColumn to set the cursor to
Returns
Result of the operation

Implements LCD.

Here is the call graph for this function:

upm_result_t clear ( )
virtual

Clears the display of all characters

Returns
Result of the operation

Implements LCD.

Here is the call graph for this function:

upm_result_t home ( )
virtual

Returns to the original coordinates (0,0)

Returns
Result of the operation

Implements LCD.

Here is the call graph for this function:

upm_result_t createChar ( uint8_t  charSlot,
jhd1313m1_custom_char_t  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

Here is the call graph for this function:

upm_result_t displayOn ( )

Turn the display on

Returns
Result of operation

Here is the call graph for this function:

upm_result_t displayOff ( )

Turn the display off

Returns
Result of operation

Here is the call graph for this function:

upm_result_t cursorOn ( )

Turn the cursor on

Returns
Result of operation

Here is the call graph for this function:

upm_result_t cursorOff ( )

Turn the cursor off

Returns
Result of operation

Here is the call graph for this function:

upm_result_t cursorBlinkOn ( )

Turn cursor blink on

Returns
Result of operation

Here is the call graph for this function:

upm_result_t cursorBlinkOff ( )

Turn cursor blink off

Returns
Result of operation

Here is the call graph for this function:

mraa::Result backlightOn ( )

Turn backlight on

Returns
Result of operation

Here is the call graph for this function:

mraa::Result backlightOff ( )

Turn backlight off

Returns
Result of operation

Here is the call graph for this function:

upm_result_t scrollDisplayLeft ( )

Scroll the display left, without changing the character RAM

Returns
Result of operation

Here is the call graph for this function:

upm_result_t scrollDisplayRight ( )

Scroll the display right, without changing the character RAM

Returns
Result of operation

Here is the call graph for this function:

upm_result_t entryLeftToRight ( )

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

Returns
Result of operation

Here is the call graph for this function:

upm_result_t entryRightToLeft ( )

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

Returns
Result of operation

Here is the call graph for this function:

upm_result_t autoscrollOn ( )

Right justify text entered from the cursor

Returns
Result of operation

Here is the call graph for this function:

upm_result_t autoscrollOff ( )

Left justify text entered from the cursor

Returns
Result of operation

Here is the call graph for this function:

mraa::Result scroll ( bool  direction)

Makes the LCD scroll text

Parameters
directionTrue if scrolling to the right
Returns
Result of the operation
mraa::Result setColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets the color of the backlight Can be used to change the color even when the backlight is off

Parameters
r0-255 value for red
g0-255 value for green
b0-255 value for blue
Returns
Result of the operation
mraa::Result backlightOn ( )

Turns backlight on

Returns
Result of operation
mraa::Result backlightOff ( )

Turns backlight off, background color is saved

Returns
Result of operation
Inheritance diagram for Jhd1313m1:
Inheritance graph
[legend]
Collaboration diagram for Jhd1313m1:
Collaboration graph
[legend]

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