C12832_lcd

Dependents:   Stopwatch_TINF

Committer:
Reichi19
Date:
Thu Nov 15 17:21:05 2018 +0000
Revision:
0:5c166367513c
Stopwatch

Who changed what in which revision?

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