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

Lcd oop extensions #11

Open
agdl opened this issue Jul 12, 2016 · 1 comment
Open

Lcd oop extensions #11

agdl opened this issue Jul 12, 2016 · 1 comment
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 @manfredjonsson on May 28, 2012 15:31

This Version of the Liquid Crystal Library can be inherited from other classes.
A possible usage is outlined in http://github.com/manfredjonsson/LiquidCrystalAddons

Because of the many changes, each commit contains one step of the improvements.

Commit 1: Fixes

  • Remove unneeded variables.
  • Make setCursor work for 16x2 and 16x4 displays.
  • I consider LCD_ENTRYSHIFTINCREMENT etc to be a missnomer. Use ...ENABLE and
    ...DISABLE instead.
  • Different variable names were used in definition and declaration of begin().
    Use the name "row" instead of "line" in all places to have a consistent
    wording.
  • Remove the begin() call from init() because some transport may not be
    initialized in a global constructor (Some versions of the Wire (I2C)
    library don't work when their begin() method is called inside a constructor
    of a global object).

Commit 2: Minimal set of changes for inheritance

  • Move functions and variables from private to protected.
  • Add the virtual keyword to all functions which may need an override in an
    derived class.

Commit 3: Make it smaller

  • Use the "-1" trick from rw for the data lines too. This enables the use of
    one writebits() function instead of two. Pay attention to the fact that
    pinMode is still in writebits(), this slows down each write to the LCD but
    code is smaller compared to an additional initialization loop.
  • Use the 4 upper bits of a byte in writebits() instead of the 4 lower bits
    for 4 bit writes. Leads to an almost identical initialization for 4 and 8
    bit mode.
  • Use the same code in 4 and 8 bit mode to force display to 8 bit mode and use
    a loop instead of three distinct calls to writebits().

Copied from original issue: arduino/Arduino/pull/87

@facchinm
Copy link
Contributor

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

4 participants