test

Fork of UniGraphic by GraphicsDisplay

Committer:
Geremia
Date:
Thu Feb 12 22:22:47 2015 +0000
Revision:
0:75ec1b3cde17
Child:
4:12ba0ecc2c1f
Initial tests, LCD par and spi ok

Who changed what in which revision?

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