EA OLED Hello World (Runs through the different possibilities with the OLED software

Dependencies:   mbed

Committer:
Lerche
Date:
Sun Oct 03 08:40:47 2010 +0000
Revision:
0:ff072ee9597c

        

Who changed what in which revision?

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