Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LcdWindow by
Diff: textlcdadapter.cpp
- Revision:
- 12:393329d0e050
- Parent:
- 10:d40c70908bf0
diff -r 85f30e1f19fc -r 393329d0e050 textlcdadapter.cpp
--- 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);
}
