i2clcd: Add createChar method

LCDs based on the HD44780 allow for setting 8 custom characters.
This patch adds a method that exposes this capability.

Signed-off-by: Clark Scheff <clark@scheffsblend.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Clark Scheff
2015-02-25 05:17:59 +00:00
committed by Mihai Tudor Panu
parent 27a3a90d1f
commit 7bd7e80b2e
2 changed files with 18 additions and 0 deletions

View File

@ -47,6 +47,20 @@ I2CLcd::write (int row, int column, std::string msg) {
write (msg);
}
mraa_result_t
I2CLcd::createChar(uint8_t charSlot, uint8_t charData[]) {
mraa_result_t error = MRAA_SUCCESS;
charSlot &= 0x07; // only have 8 positions we can set
error = i2Cmd(m_i2c_lcd_control, LCD_SETCGRAMADDR | (charSlot << 3));
if (error == MRAA_SUCCESS) {
for (int i = 0; i < 8; i++) {
error = i2cData(m_i2c_lcd_control, charData[i]);
}
}
return error;
}
mraa_result_t
I2CLcd::close() {
return mraa_i2c_stop(m_i2c_lcd_control);