mirror of
https://github.com/eclipse/upm.git
synced 2025-07-12 06:41:12 +03:00
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:

committed by
Mihai Tudor Panu

parent
27a3a90d1f
commit
7bd7e80b2e
@ -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);
|
||||
|
Reference in New Issue
Block a user