Go Down

Topic: LiquidCrystal: getNumCols(), getNumRows() (Read 373 times) previous topic - next topic

tuxduino

Hi,
   I've found I often need to know how many columns and rows a lcd object has.
The LiquidCrystal class doesn't provide methods to obtain those informations, although adding them is very simple.
So I post here my 4 lines of code hoping this feature (not necessarily my code) gets included in a future library version.

diff -Bub original modified

[font=Courier]
--- LiquidCrystal.h      2010-05-26 11:28:04.000000000 +0200
+++ LiquidCrystal_mod.h      2010-05-26 10:25:03.000000000 +0200
@@ -77,6 +77,9 @@
  void autoscroll();
  void noAutoscroll();

+  int getNumCols() { return _numcols; }
+  int getNumRows() { return _numlines; }
+
  void createChar(uint8_t, uint8_t[]);
  void setCursor(uint8_t, uint8_t);
  virtual void write(uint8_t);
@@ -98,7 +101,7 @@

  uint8_t _initialized;

-  uint8_t _numlines,_currline;
+  uint8_t _numcols,_numlines,_currline;
};

#endif



--- LiquidCrystal.cpp      2010-05-26 11:28:15.000000000 +0200
+++ LiquidCrystal_mod.cpp      2010-05-26 10:11:37.000000000 +0200
@@ -86,6 +86,7 @@
  if (lines > 1) {
    _displayfunction |= LCD_2LINE;
  }
+  _numcols  = cols;
  _numlines = lines;
  _currline = 0;
[/font]

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy