]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/mbed/freopen/TextDisplay.cpp
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / tests / mbed / freopen / TextDisplay.cpp
1 /* mbed TextDisplay Display Library Base Class
2 * Copyright (c) 2007-2009 sford
3 * Released under the MIT License: http://mbed.org/license/mit
4 */
5
6 #include "TextDisplay.h"
7
8 TextDisplay::TextDisplay(const char *name) : Stream(name) {
9 _row = 0;
10 _column = 0;
11 }
12
13 int TextDisplay::_putc(int value) {
14 if(value == '\n') {
15 _column = 0;
16 _row++;
17 if(_row >= rows()) {
18 _row = 0;
19 }
20 } else {
21 character(_column, _row, value);
22 _column++;
23 if(_column >= columns()) {
24 _column = 0;
25 _row++;
26 if(_row >= rows()) {
27 _row = 0;
28 }
29 }
30 }
31 return value;
32 }
33
34 // crude cls implementation, should generally be overwritten in derived class
35 void TextDisplay::cls() {
36 locate(0, 0);
37 for(int i=0; i<columns()*rows(); i++) {
38 putc(' ');
39 }
40 }
41
42 void TextDisplay::locate(int column, int row) {
43 _column = column;
44 _row = row;
45 }
46
47 int TextDisplay::_getc() {
48 return -1;
49 }
50
51 void TextDisplay::foreground(int colour) {
52 _foreground = colour;
53 }
54
55 void TextDisplay::background(int colour) {
56 _background = colour;
57 }
Imprint / Impressum