From 731704eaac622dd7cdd12b6ba54092d9604b3f1a Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Mon, 14 Jul 2014 15:25:12 +0100 Subject: [PATCH] Jhd1313m1: add basic scroll functionality Signed-off-by: Brendan Le Foll --- src/lcd/i2clcd.h | 5 +++++ src/lcd/jhd1313m1.cxx | 8 ++++++++ src/lcd/jhd1313m1.h | 1 + 3 files changed, 14 insertions(+) diff --git a/src/lcd/i2clcd.h b/src/lcd/i2clcd.h index 460a2c41..d7ec3eaf 100644 --- a/src/lcd/i2clcd.h +++ b/src/lcd/i2clcd.h @@ -55,6 +55,11 @@ namespace upm { #define LCD_BLINKON 0x01 #define LCD_BLINKOFF 0x00 +// flags for display/cursor shift +#define LCD_DISPLAYMOVE 0x08 +#define LCD_MOVERIGHT 0x04 +#define LCD_MOVELEFT 0x00 + // flags for function set #define LCD_8BITMODE 0x10 #define LCD_4BITMODE 0x00 diff --git a/src/lcd/jhd1313m1.cxx b/src/lcd/jhd1313m1.cxx index d2f3aeb7..5f094f8a 100644 --- a/src/lcd/jhd1313m1.cxx +++ b/src/lcd/jhd1313m1.cxx @@ -84,6 +84,14 @@ Jhd1313m1::setColor(uint8_t r, uint8_t g, uint8_t b) return MRAA_SUCCESS; } +mraa_result_t +Jhd1313m1::scroll(bool direction) +{ + if (direction) + return i2Cmd (m_i2c_lcd_control, (LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT)); + return i2Cmd (m_i2c_lcd_control, (LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT)); +} + /* * ************** * virtual area diff --git a/src/lcd/jhd1313m1.h b/src/lcd/jhd1313m1.h index 5d637ca5..4c49f9be 100644 --- a/src/lcd/jhd1313m1.h +++ b/src/lcd/jhd1313m1.h @@ -37,6 +37,7 @@ class Jhd1313m1 : public I2CLcd { mraa_result_t setCursor (int row, int column); mraa_result_t clear (); mraa_result_t home (); + mraa_result_t scroll (bool direction); private: int m_rgb_address;