A C12832 LCD with generic interface

Dependents:   mbed_blinky HTTPClient_HelloWorld websocketandnode xbeerx ... more

Fork of C12832 by Chris Styles

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TextDisplay.h Source File

TextDisplay.h

00001 /* mbed TextDisplay Library Base Class
00002  * Copyright (c) 2007-2009 sford
00003  * Released under the MIT License: http://mbed.org/license/mit
00004  *
00005  * A common base class for Text displays
00006  * To port a new display, derive from this class and implement
00007  * the constructor (setup the display), character (put a character
00008  * at a location), rows and columns (number of rows/cols) functions.
00009  * Everything else (locate, printf, putc, cls) will come for free
00010  *
00011  * The model is the display will wrap at the right and bottom, so you can
00012  * keep writing and will always get valid characters. The location is 
00013  * maintained internally to the class to make this easy
00014  */
00015 
00016 #ifndef MBED_TEXTDISPLAY_H
00017 #define MBED_TEXTDISPLAY_H
00018 
00019 #include "mbed.h"
00020 
00021 /**
00022  * TextDisplay interface
00023  */
00024 class TextDisplay : public Stream {
00025 public:
00026 
00027     /**
00028      * Create a TextDisplay interface
00029      *
00030      * @param name The name used in the path to access the strean through the filesystem
00031      */
00032     TextDisplay(const char *name = NULL);
00033 
00034     /**
00035      * Output a character at the given position
00036      *
00037      * @param column column where charater must be written
00038      * @param  row where character must be written
00039      * @param c the character to be written to the TextDisplay
00040      */
00041     virtual void character(int column, int row, int c) = 0;
00042 
00043     /**
00044      * Return number of rows on TextDisplay
00045      *
00046      * @results number of rows
00047      */
00048     virtual int rows() = 0;
00049 
00050     /**
00051      * Return number if columns on TextDisplay\
00052      *
00053      * @results number of rows
00054      */
00055     virtual int columns() = 0;
00056     
00057     // functions that come for free, but can be overwritten
00058 
00059     /**
00060      * Redirect output from a stream (stoud, sterr) to  display
00061      *
00062      * @param stream stream that shall be redirected to the TextDisplay
00063      */
00064     virtual bool claim (FILE *stream);
00065 
00066     /**
00067      * Clear screen
00068      */
00069     virtual void cls();
00070     
00071     /**
00072      * Change the cursor position to column, row (in pixels)
00073      */
00074     virtual void locate(int column, int row);
00075     
00076     virtual void foreground(uint16_t colour);
00077     virtual void background(uint16_t colour);
00078     // putc (from Stream)
00079     // printf (from Stream)
00080     
00081 protected:
00082 
00083     virtual int _putc(int value);
00084     virtual int _getc();
00085 
00086     // character location
00087     uint16_t _column;
00088     uint16_t _row;
00089 
00090     // colours
00091     uint16_t _foreground;
00092     uint16_t _background;
00093     char *_path;
00094 };
00095 
00096 #endif