From 8462e8ce52a63af0d735b6ff605fc8ed27859716 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Thu, 9 Jul 2015 14:12:20 -0600 Subject: [PATCH] jhd1313m1: add createChar() method, as it should be supported by this device Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/lcd/jhd1313m1.cxx | 15 +++++++++++++++ src/lcd/jhd1313m1.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/lcd/jhd1313m1.cxx b/src/lcd/jhd1313m1.cxx index 398a8a1a..86e8b636 100644 --- a/src/lcd/jhd1313m1.cxx +++ b/src/lcd/jhd1313m1.cxx @@ -125,6 +125,21 @@ Jhd1313m1::scroll(bool direction) } } +mraa_result_t +Jhd1313m1::createChar(uint8_t charSlot, uint8_t charData[]) +{ + mraa_result_t error = MRAA_SUCCESS; + charSlot &= 0x07; // only have 8 positions we can set + error = m_i2c_lcd_control.writeReg(LCD_CMD, LCD_SETCGRAMADDR | (charSlot << 3)); + if (error == MRAA_SUCCESS) { + for (int i = 0; i < 8; i++) { + error = m_i2c_lcd_control.writeReg(LCD_DATA, charData[i]); + } + } + + return error; +} + /* * ************** * virtual area diff --git a/src/lcd/jhd1313m1.h b/src/lcd/jhd1313m1.h index bd8a5f4e..687a3109 100644 --- a/src/lcd/jhd1313m1.h +++ b/src/lcd/jhd1313m1.h @@ -111,6 +111,15 @@ class Jhd1313m1 : public LCD */ mraa_result_t home(); + /** + * Create a custom character + * + * @param charSlot the character slot to write, only 8 are available + * @param charData The character data (8 bytes) making up the character + * @return Result of operation + */ + mraa_result_t createChar(uint8_t charSlot, uint8_t charData[]); + private: int m_rgb_address; mraa::I2c m_i2c_lcd_rgb;