Example program printing text to the LCD on the mbed application board

Dependencies:   C12832 mbed

Fork of lab1 by Peter Drescher

Committer:
dreschpe
Date:
Mon Oct 15 21:48:28 2012 +0000
Revision:
0:f6a57b843f79
first test of the lcd driver

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:f6a57b843f79 1 /* mbed TextDisplay Library Base Class
dreschpe 0:f6a57b843f79 2 * Copyright (c) 2007-2009 sford
dreschpe 0:f6a57b843f79 3 * Released under the MIT License: http://mbed.org/license/mit
dreschpe 0:f6a57b843f79 4 *
dreschpe 0:f6a57b843f79 5 * A common base class for Text displays
dreschpe 0:f6a57b843f79 6 * To port a new display, derive from this class and implement
dreschpe 0:f6a57b843f79 7 * the constructor (setup the display), character (put a character
dreschpe 0:f6a57b843f79 8 * at a location), rows and columns (number of rows/cols) functions.
dreschpe 0:f6a57b843f79 9 * Everything else (locate, printf, putc, cls) will come for free
dreschpe 0:f6a57b843f79 10 *
dreschpe 0:f6a57b843f79 11 * The model is the display will wrap at the right and bottom, so you can
dreschpe 0:f6a57b843f79 12 * keep writing and will always get valid characters. The location is
dreschpe 0:f6a57b843f79 13 * maintained internally to the class to make this easy
dreschpe 0:f6a57b843f79 14 */
dreschpe 0:f6a57b843f79 15
dreschpe 0:f6a57b843f79 16 #ifndef MBED_TEXTDISPLAY_H
dreschpe 0:f6a57b843f79 17 #define MBED_TEXTDISPLAY_H
dreschpe 0:f6a57b843f79 18
dreschpe 0:f6a57b843f79 19 #include "mbed.h"
dreschpe 0:f6a57b843f79 20
dreschpe 0:f6a57b843f79 21 class TextDisplay : public Stream {
dreschpe 0:f6a57b843f79 22 public:
dreschpe 0:f6a57b843f79 23
dreschpe 0:f6a57b843f79 24 // functions needing implementation in derived implementation class
dreschpe 0:f6a57b843f79 25 /** Create a TextDisplay interface
dreschpe 0:f6a57b843f79 26 *
dreschpe 0:f6a57b843f79 27 * @param name The name used in the path to access the strean through the filesystem
dreschpe 0:f6a57b843f79 28 */
dreschpe 0:f6a57b843f79 29 TextDisplay(const char *name = NULL);
dreschpe 0:f6a57b843f79 30
dreschpe 0:f6a57b843f79 31 /** output a character at the given position
dreschpe 0:f6a57b843f79 32 *
dreschpe 0:f6a57b843f79 33 * @param column column where charater must be written
dreschpe 0:f6a57b843f79 34 * @param row where character must be written
dreschpe 0:f6a57b843f79 35 * @param c the character to be written to the TextDisplay
dreschpe 0:f6a57b843f79 36 */
dreschpe 0:f6a57b843f79 37 virtual void character(int column, int row, int c) = 0;
dreschpe 0:f6a57b843f79 38
dreschpe 0:f6a57b843f79 39 /** return number if rows on TextDisplay
dreschpe 0:f6a57b843f79 40 * @result number of rows
dreschpe 0:f6a57b843f79 41 */
dreschpe 0:f6a57b843f79 42 virtual int rows() = 0;
dreschpe 0:f6a57b843f79 43
dreschpe 0:f6a57b843f79 44 /** return number if columns on TextDisplay
dreschpe 0:f6a57b843f79 45 * @result number of rows
dreschpe 0:f6a57b843f79 46 */
dreschpe 0:f6a57b843f79 47 virtual int columns() = 0;
dreschpe 0:f6a57b843f79 48
dreschpe 0:f6a57b843f79 49 // functions that come for free, but can be overwritten
dreschpe 0:f6a57b843f79 50
dreschpe 0:f6a57b843f79 51 /** redirect output from a stream (stoud, sterr) to display
dreschpe 0:f6a57b843f79 52 * @param stream stream that shall be redirected to the TextDisplay
dreschpe 0:f6a57b843f79 53 */
dreschpe 0:f6a57b843f79 54 virtual bool claim (FILE *stream);
dreschpe 0:f6a57b843f79 55
dreschpe 0:f6a57b843f79 56 /** clear screen
dreschpe 0:f6a57b843f79 57 */
dreschpe 0:f6a57b843f79 58 virtual void cls();
dreschpe 0:f6a57b843f79 59 virtual void locate(int column, int row);
dreschpe 0:f6a57b843f79 60 virtual void foreground(uint16_t colour);
dreschpe 0:f6a57b843f79 61 virtual void background(uint16_t colour);
dreschpe 0:f6a57b843f79 62 // putc (from Stream)
dreschpe 0:f6a57b843f79 63 // printf (from Stream)
dreschpe 0:f6a57b843f79 64
dreschpe 0:f6a57b843f79 65 protected:
dreschpe 0:f6a57b843f79 66
dreschpe 0:f6a57b843f79 67 virtual int _putc(int value);
dreschpe 0:f6a57b843f79 68 virtual int _getc();
dreschpe 0:f6a57b843f79 69
dreschpe 0:f6a57b843f79 70 // character location
dreschpe 0:f6a57b843f79 71 uint16_t _column;
dreschpe 0:f6a57b843f79 72 uint16_t _row;
dreschpe 0:f6a57b843f79 73
dreschpe 0:f6a57b843f79 74 // colours
dreschpe 0:f6a57b843f79 75 uint16_t _foreground;
dreschpe 0:f6a57b843f79 76 uint16_t _background;
dreschpe 0:f6a57b843f79 77 char *_path;
dreschpe 0:f6a57b843f79 78 };
dreschpe 0:f6a57b843f79 79
dreschpe 0:f6a57b843f79 80 #endif