A test example using the OLED display on the Embedded Artists Xpresso baseboard

Dependencies:   mbed

Committer:
simon
Date:
Sun Feb 28 16:04:59 2010 +0000
Revision:
0:f42b25503fd1

        

Who changed what in which revision?

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