Fork of LCD-Window which works with Enhanced TextLCD from Wim

Fork of LcdWindow by Hendrik Lipka

Files at this revision

API Documentation at this revision

Comitter:
charly
Date:
Tue Jan 12 20:40:39 2016 +0000
Parent:
11:85f30e1f19fc
Child:
13:99b500b05716
Commit message:
honor display/window-boundaries

Changed in this revision

textlcdadapter.cpp Show annotated file Show diff for this revision Revisions of this file
textlcdadapter.h Show annotated file Show diff for this revision Revisions of this file
--- a/textlcdadapter.cpp	Mon Jan 04 21:20:43 2016 +0000
+++ b/textlcdadapter.cpp	Tue Jan 12 20:40:39 2016 +0000
@@ -27,28 +27,30 @@
 
 TextLCDAdapter::TextLCDAdapter(TextLCD_Base *lcd) {
     _lcd=lcd;
+    _columns = _lcd->columns();
+    _rows    = _lcd->rows();
 }
 void TextLCDAdapter::clear() {
     _lcd->cls();
 }
 
 void TextLCDAdapter::writeText(const unsigned int column, const unsigned int row, const char text[]){
+    if ((column > getColumns()) || (row > getRows())){
+        return;
+    }
     _lcd->locate(column,row);
     int i=0;
-    while(text[i]!=0)
+    while((text[i]!=0) && (column+i < getColumns()))
     {
         _lcd->putc(text[i]);
         i++;
     }
 }
 
-int TextLCDAdapter::getRows() {
-    return _lcd->rows();
-}
-int TextLCDAdapter::getColumns() {
-    return _lcd->columns();
-}
 void TextLCDAdapter::character(int column, int row, int c) {
+    if ((column > getColumns()) || (row > getRows())){
+        return;
+    }
     _lcd->locate(column,row);
     _lcd->putc(c);
 }
--- a/textlcdadapter.h	Mon Jan 04 21:20:43 2016 +0000
+++ b/textlcdadapter.h	Tue Jan 12 20:40:39 2016 +0000
@@ -36,15 +36,16 @@
     virtual void clear();
     virtual void writeText(const unsigned int column, const unsigned int row, const char text[]);
 
-    virtual int getRows();
-    virtual int getColumns();
+    virtual int getRows()   {return _rows;};
+    virtual int getColumns(){return _columns;};
     virtual void character(int column, int row, int c);
     int putc(int c);
     int printf(const char* format, ...);
     
     private:
         TextLCD_Base *_lcd;
-
+        int _columns;
+        int _rows;
 };
 
 #endif