Improved version of Simon Ford's TextDisplay library, with addressing and timing fixes. Supports up to 20x4 text displays.
TextDisplay.cpp
00001 /* mbed TextDisplay Display Library Base Class 00002 * Copyright (c) 2007-2009 sford 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 */ 00005 00006 #include "TextDisplay.h" 00007 00008 TextDisplay::TextDisplay() { 00009 _row = 0; 00010 _column = 0; 00011 } 00012 00013 int TextDisplay::_putc(int value) { 00014 if(value == '\n') { 00015 _column = 0; 00016 _row++; 00017 if(_row >= rows()) { 00018 _row = 0; 00019 } 00020 } else { 00021 character(_column, _row, value); 00022 _column++; 00023 if(_column >= columns()) { 00024 _column = 0; 00025 _row++; 00026 if(_row >= rows()) { 00027 _row = 0; 00028 } 00029 } 00030 } 00031 return value; 00032 } 00033 00034 // crude cls implementation, should generally be overwritten in derived class 00035 void TextDisplay::cls() { 00036 locate(0, 0); 00037 for(int i=0; i<columns()*rows(); i++) { 00038 putc(' '); 00039 } 00040 } 00041 00042 void TextDisplay::locate(uint16_t column, uint16_t row) { 00043 _column = column; 00044 _row = row; 00045 } 00046 00047 int TextDisplay::_getc() { 00048 return -1; 00049 } 00050 00051 void TextDisplay::foreground(uint32_t colour) { 00052 _foreground = colour; 00053 } 00054 00055 void TextDisplay::background(uint32_t colour) { 00056 _background = colour; 00057 }
Generated on Thu Jul 14 2022 21:44:21 by 1.7.2