Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
agdl opened this issue Jul 12, 2016 · 0 comments
Assignees
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@agdl
Copy link
Member

agdl commented Jul 12, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

3 participants