Skip to content

Enhance LCD methods 'scrollDisplayLeft' and 'scrollDisplayRight' to accept a parameter [imported] #10

Open
@agdl

Description

@agdl

From @cmaglie on November 15, 2012 18:47

This is Issue 726 moved from a Google Code project.
Added by 2011-11-22T16:22:34.000Z by Randall....@gmail.com.
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Enhancement, Priority-Medium

Original description

What change would like to see?
Currently scrollDisplayLeft and scrollDisplayRight do not accept parameters. I would to to proved an integer to indicate a scroll amount other than the default of '1'.

Why?
To simplify project code and make the function more versatile.
Seldom is it needed to shift the display only one positions. Therefore, it is necessary to put the function in a loop. This complicates the codes.
If I need to scroll my display 16 positions (a common display width) I currently need to write something like:

   for (uint8_t i=16; i--;) scrollDisplayLeft();

This is the most compact and efficient code I have been able to come up with.
A more efficient method would be:

   scrollDisplayLeft(16);

The compiler could better optimize the code since there is only one loop in one location rather than several loops in different locations.

Would this cause any incompatibilities with previous versions?
No.

This is my tested proposed code based on arduino-1.0-rc2:
LiquidCrystal.h

  void scrollDisplayLeft(uint8_t iCnt=1);
  void scrollDisplayRight(uint8_t iCnt=1);

LiquidCrystal.c

void LiquidCrystal::scrollDisplayLeft(uint8_t iCnt) {
  while (iCnt-- != 0)
    command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
}
void LiquidCrystal::scrollDisplayRight(uint8_t iCnt) {
  while (iCnt-- != 0)
    command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
}

Copied from original issue: arduino/Arduino#726

Metadata

Metadata

Assignees

Labels

topic: codeRelated to content of the project itselftype: enhancementProposed improvement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Enhance LCD methods 'scrollDisplayLeft' and 'scrollDisplayRight' to accept a parameter [imported] · Issue #10 · arduino-libraries/LiquidCrystal