From dca5a87ac9bad2a82c4ae59ff6ddd0fc3eaa5acd Mon Sep 17 00:00:00 2001 From: FMC Date: Tue, 21 Feb 2012 22:00:39 +0100 Subject: [PATCH] Added moveCursorRight and moveCursorLeft generic methods to interface as an extension to the library. --- LCD.cpp | 16 +++++++++++++++- LCD.h | 21 +++++++++++++++++++-- keywords.txt | 4 +++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/LCD.cpp b/LCD.cpp index 68c7a07..311805b 100644 --- a/LCD.cpp +++ b/LCD.cpp @@ -232,7 +232,8 @@ void LCD::scrollDisplayLeft(void) command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); } -void LCD::scrollDisplayRight(void) { +void LCD::scrollDisplayRight(void) +{ command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); } @@ -250,6 +251,19 @@ void LCD::rightToLeft(void) command(LCD_ENTRYMODESET | _displaymode); } +// This method moves the cursor one space to the right +void LCD::moveCursorRight(void) +{ + command(LCD_CURSORSHIFT | LCD_CURSORMOVE | LCD_MOVERIGHT); +} + +// This method moves the cursor one space to the left +void LCD::moveCursorLeft(void) +{ + command(LCD_CURSORSHIFT | LCD_CURSORMOVE | LCD_MOVELEFT); +} + + // This will 'right justify' text from the cursor void LCD::autoscroll(void) { diff --git a/LCD.h b/LCD.h index 02b490a..d04dc33 100644 --- a/LCD.h +++ b/LCD.h @@ -291,6 +291,23 @@ public: */ void rightToLeft(); + /*! + @function + @abstract Moves the cursor one space to the left. + @discussion + @param none + */ + void moveCursorLeft(); + + + /*! + @function + @abstract Moves the cursor one space to the right. + + @param none + */ + void moveCursorRight(); + /*! @function @abstract Turns on automatic scrolling of the LCD. @@ -433,9 +450,9 @@ protected: // Internal LCD variables to control the LCD shared between all derived // classes. uint8_t _displayfunction; // LCD_5x10DOTS or LCD_5x8DOTS, LCD_4BITMODE or - // LCD_8BITMODE, LCD_1LINE or LCD_2LINE + // LCD_8BITMODE, LCD_1LINE or LCD_2LINE uint8_t _displaycontrol; // LCD base control command LCD on/off, blink, cursor - // all commands are "ored" to its contents. + // all commands are "ored" to its contents. uint8_t _displaymode; // Text entry mode to the LCD uint8_t _numlines; // Number of lines of the LCD, initialized with begin() uint8_t _cols; // Number of columns in the LCD diff --git a/keywords.txt b/keywords.txt index bc9b31e..53d25ad 100755 --- a/keywords.txt +++ b/keywords.txt @@ -6,7 +6,7 @@ # Datatypes (KEYWORD1) ########################################### -LiquidCrystal_SR KEYWORD1 +LiquidCrystal_SR KEYWORD1 LiquidCrystal_I2C KEYWORD1 LiquidCrystal_SR_LCD3 KEYWORD1 LiquidCrystal KEYWORD1 @@ -29,6 +29,8 @@ scrollDisplayLeft KEYWORD2 scrollDisplayRight KEYWORD2 leftToRight KEYWORD2 rightToLeft KEYWORD2 +moveCursorLeft KEYWORD2 +moveCursorRight KEYWORD2 autoscroll KEYWORD2 noAutoscroll KEYWORD2 createChar KEYWORD2