Library for the OLED display, as used on the mbed LPCXpresso Baseboard

Dependencies:   mbed

Dependents:   EAOLED_HelloWorld EA_BigBen NetClock_aitendoOLED_from_EA_and_nucho

Committer:
simon
Date:
Sun Jun 06 19:33:24 2010 +0000
Revision:
0:8fe8b0fe5134

        

Who changed what in which revision?

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