A C12832 LCD with generic interface

Dependents:   mbed_blinky HTTPClient_HelloWorld websocketandnode xbeerx ... more

Fork of C12832 by Chris Styles

Committer:
screamer
Date:
Mon Mar 17 19:47:39 2014 +0000
Revision:
17:1c3011afe95d
Parent:
0:4bbc531be6e2
Improved library documentation

Who changed what in which revision?

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