Christian Lerche
/
EAOLED
EA OLED (Orig. by SFord, retouched by Lerche)
TextDisplay.cpp@0:69334bd84891, 2010-10-03 (annotated)
- Committer:
- Lerche
- Date:
- Sun Oct 03 08:36:08 2010 +0000
- Revision:
- 0:69334bd84891
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lerche | 0:69334bd84891 | 1 | /* mbed TextDisplay Display Library Base Class |
Lerche | 0:69334bd84891 | 2 | * Copyright (c) 2007-2009 sford |
Lerche | 0:69334bd84891 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
Lerche | 0:69334bd84891 | 4 | */ |
Lerche | 0:69334bd84891 | 5 | |
Lerche | 0:69334bd84891 | 6 | #include "TextDisplay.h" |
Lerche | 0:69334bd84891 | 7 | |
Lerche | 0:69334bd84891 | 8 | TextDisplay::TextDisplay() { |
Lerche | 0:69334bd84891 | 9 | _row = 0; |
Lerche | 0:69334bd84891 | 10 | _column = 0; |
Lerche | 0:69334bd84891 | 11 | } |
Lerche | 0:69334bd84891 | 12 | |
Lerche | 0:69334bd84891 | 13 | int TextDisplay::_putc(int value) { |
Lerche | 0:69334bd84891 | 14 | if(value == '\n') { |
Lerche | 0:69334bd84891 | 15 | _column = 0; |
Lerche | 0:69334bd84891 | 16 | _row++; |
Lerche | 0:69334bd84891 | 17 | if(_row >= rows()) { |
Lerche | 0:69334bd84891 | 18 | _row = 0; |
Lerche | 0:69334bd84891 | 19 | } |
Lerche | 0:69334bd84891 | 20 | } else { |
Lerche | 0:69334bd84891 | 21 | character(_column, _row, value); |
Lerche | 0:69334bd84891 | 22 | _column++; |
Lerche | 0:69334bd84891 | 23 | if(_column >= columns()) { |
Lerche | 0:69334bd84891 | 24 | _column = 0; |
Lerche | 0:69334bd84891 | 25 | _row++; |
Lerche | 0:69334bd84891 | 26 | if(_row >= rows()) { |
Lerche | 0:69334bd84891 | 27 | _row = 0; |
Lerche | 0:69334bd84891 | 28 | } |
Lerche | 0:69334bd84891 | 29 | } |
Lerche | 0:69334bd84891 | 30 | } |
Lerche | 0:69334bd84891 | 31 | return value; |
Lerche | 0:69334bd84891 | 32 | } |
Lerche | 0:69334bd84891 | 33 | |
Lerche | 0:69334bd84891 | 34 | // crude cls implementation, should generally be overwritten in derived class |
Lerche | 0:69334bd84891 | 35 | void TextDisplay::cls() { |
Lerche | 0:69334bd84891 | 36 | locate(0, 0); |
Lerche | 0:69334bd84891 | 37 | for(int i=0; i<columns()*rows(); i++) { |
Lerche | 0:69334bd84891 | 38 | putc(' '); |
Lerche | 0:69334bd84891 | 39 | } |
Lerche | 0:69334bd84891 | 40 | } |
Lerche | 0:69334bd84891 | 41 | |
Lerche | 0:69334bd84891 | 42 | void TextDisplay::locate(int column, int row) { |
Lerche | 0:69334bd84891 | 43 | _column = column; |
Lerche | 0:69334bd84891 | 44 | _row = row; |
Lerche | 0:69334bd84891 | 45 | } |
Lerche | 0:69334bd84891 | 46 | |
Lerche | 0:69334bd84891 | 47 | int TextDisplay::_getc() { |
Lerche | 0:69334bd84891 | 48 | return -1; |
Lerche | 0:69334bd84891 | 49 | } |
Lerche | 0:69334bd84891 | 50 | |
Lerche | 0:69334bd84891 | 51 | void TextDisplay::foreground(int colour) { |
Lerche | 0:69334bd84891 | 52 | _foreground = colour; |
Lerche | 0:69334bd84891 | 53 | } |
Lerche | 0:69334bd84891 | 54 | |
Lerche | 0:69334bd84891 | 55 | void TextDisplay::background(int colour) { |
Lerche | 0:69334bd84891 | 56 | _background = colour; |
Lerche | 0:69334bd84891 | 57 | } |