Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Committer:
WiredHome
Date:
Sat Jan 25 19:47:33 2014 +0000
Revision:
37:f19b7e7449dc
Parent:
33:b6b710758ab3
Child:
61:8f3153bf0baa
major API tweak to use typedef's for pixel locations, dimensions, and text locations.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:de9d1462a835 1 /* mbed TextDisplay Library Base Class
dreschpe 0:de9d1462a835 2 * Copyright (c) 2007-2009 sford
dreschpe 0:de9d1462a835 3 * Released under the MIT License: http://mbed.org/license/mit
dreschpe 0:de9d1462a835 4 *
dreschpe 0:de9d1462a835 5 * A common base class for Text displays
dreschpe 0:de9d1462a835 6 * To port a new display, derive from this class and implement
dreschpe 0:de9d1462a835 7 * the constructor (setup the display), character (put a character
dreschpe 0:de9d1462a835 8 * at a location), rows and columns (number of rows/cols) functions.
dreschpe 0:de9d1462a835 9 * Everything else (locate, printf, putc, cls) will come for free
dreschpe 0:de9d1462a835 10 *
dreschpe 0:de9d1462a835 11 * The model is the display will wrap at the right and bottom, so you can
WiredHome 19:3f82c1161fd2 12 * keep writing and will always get valid characters. The location is
dreschpe 0:de9d1462a835 13 * maintained internally to the class to make this easy
dreschpe 0:de9d1462a835 14 */
dreschpe 0:de9d1462a835 15
dreschpe 0:de9d1462a835 16 #ifndef MBED_TEXTDISPLAY_H
dreschpe 0:de9d1462a835 17 #define MBED_TEXTDISPLAY_H
dreschpe 0:de9d1462a835 18
dreschpe 0:de9d1462a835 19 #include "mbed.h"
dreschpe 0:de9d1462a835 20
WiredHome 31:c72e12cd5c67 21 #include "DisplayDefs.h"
WiredHome 19:3f82c1161fd2 22
WiredHome 37:f19b7e7449dc 23 /// A text display class that supports character based
WiredHome 37:f19b7e7449dc 24 /// presentation.
WiredHome 37:f19b7e7449dc 25 ///
WiredHome 19:3f82c1161fd2 26 class TextDisplay : public Stream
WiredHome 19:3f82c1161fd2 27 {
dreschpe 0:de9d1462a835 28 public:
dreschpe 0:de9d1462a835 29
WiredHome 19:3f82c1161fd2 30 // functions needing implementation in derived implementation class
WiredHome 37:f19b7e7449dc 31 /// Create a TextDisplay interface
WiredHome 37:f19b7e7449dc 32 ///
WiredHome 37:f19b7e7449dc 33 /// @param name The name used in the path to access the display through
WiredHome 37:f19b7e7449dc 34 /// the stdio stream.
WiredHome 37:f19b7e7449dc 35 ///
dreschpe 0:de9d1462a835 36 TextDisplay(const char *name = NULL);
dreschpe 0:de9d1462a835 37
WiredHome 37:f19b7e7449dc 38 /// output a character at the given position
WiredHome 37:f19b7e7449dc 39 ///
WiredHome 37:f19b7e7449dc 40 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 41 ///
WiredHome 37:f19b7e7449dc 42 /// @param x position in pixels
WiredHome 37:f19b7e7449dc 43 /// @param y position in pixels
WiredHome 37:f19b7e7449dc 44 /// @param c the character to be written to the TextDisplay
WiredHome 37:f19b7e7449dc 45 /// @returns number of pixels to advance the cursor which could be the cell width
WiredHome 37:f19b7e7449dc 46 /// for non-proportional characters, or the actual character width for
WiredHome 37:f19b7e7449dc 47 /// proportional characters.
WiredHome 37:f19b7e7449dc 48 ///
WiredHome 29:422616aa04bd 49 virtual int character(int x, int y, int c) = 0;
dreschpe 0:de9d1462a835 50
WiredHome 37:f19b7e7449dc 51 /// return number of rows on TextDisplay
WiredHome 37:f19b7e7449dc 52 ///
WiredHome 37:f19b7e7449dc 53 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 54 ///
WiredHome 37:f19b7e7449dc 55 /// @returns number of text rows for the display for the currently
WiredHome 37:f19b7e7449dc 56 /// active font.
WiredHome 37:f19b7e7449dc 57 ///
dreschpe 0:de9d1462a835 58 virtual int rows() = 0;
dreschpe 0:de9d1462a835 59
WiredHome 37:f19b7e7449dc 60 /// return number if columns on TextDisplay
WiredHome 37:f19b7e7449dc 61 ///
WiredHome 37:f19b7e7449dc 62 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 63 ///
WiredHome 37:f19b7e7449dc 64 /// @returns number of text rows for the display for the currently
WiredHome 37:f19b7e7449dc 65 /// active font.
WiredHome 37:f19b7e7449dc 66 ///
dreschpe 0:de9d1462a835 67 virtual int columns() = 0;
WiredHome 19:3f82c1161fd2 68
dreschpe 0:de9d1462a835 69 // functions that come for free, but can be overwritten
dreschpe 0:de9d1462a835 70
WiredHome 37:f19b7e7449dc 71 /// redirect output from a stream (stoud, sterr) to display
WiredHome 37:f19b7e7449dc 72 ///
WiredHome 37:f19b7e7449dc 73 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 74 ///
WiredHome 37:f19b7e7449dc 75 /// @param stream that shall be redirected to the TextDisplay
WiredHome 37:f19b7e7449dc 76 /// @returns true if the claim succeeded.
WiredHome 37:f19b7e7449dc 77 ///
dreschpe 0:de9d1462a835 78 virtual bool claim (FILE *stream);
dreschpe 0:de9d1462a835 79
WiredHome 37:f19b7e7449dc 80 /// clear screen
WiredHome 37:f19b7e7449dc 81 ///
WiredHome 37:f19b7e7449dc 82 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 83 ///
WiredHome 37:f19b7e7449dc 84 /// @returns error code.
WiredHome 37:f19b7e7449dc 85 ///
WiredHome 29:422616aa04bd 86 virtual RetCode_t cls() = 0;
WiredHome 37:f19b7e7449dc 87
WiredHome 37:f19b7e7449dc 88 /// locate the cursor at a character position.
WiredHome 37:f19b7e7449dc 89 ///
WiredHome 37:f19b7e7449dc 90 /// Based on the currently active font, locate the cursor on screen.
WiredHome 37:f19b7e7449dc 91 ///
WiredHome 37:f19b7e7449dc 92 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 93 ///
WiredHome 37:f19b7e7449dc 94 /// @param column is the horizontal offset from the left side.
WiredHome 37:f19b7e7449dc 95 /// @param row is the vertical offset from the top.
WiredHome 37:f19b7e7449dc 96 /// @returns error code.
WiredHome 37:f19b7e7449dc 97 ///
WiredHome 37:f19b7e7449dc 98 virtual RetCode_t locate(textloc_t column, textloc_t row) = 0;
WiredHome 37:f19b7e7449dc 99
WiredHome 37:f19b7e7449dc 100 /// set the foreground color
WiredHome 37:f19b7e7449dc 101 ///
WiredHome 37:f19b7e7449dc 102 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 103 ///
WiredHome 37:f19b7e7449dc 104 /// @param color is color to use for foreground drawing.
WiredHome 37:f19b7e7449dc 105 /// @returns error code.
WiredHome 37:f19b7e7449dc 106 ///
WiredHome 37:f19b7e7449dc 107 virtual RetCode_t foreground(color_t color) = 0;
WiredHome 37:f19b7e7449dc 108
WiredHome 37:f19b7e7449dc 109 /// set the background color
WiredHome 37:f19b7e7449dc 110 ///
WiredHome 37:f19b7e7449dc 111 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 112 ///
WiredHome 37:f19b7e7449dc 113 /// @param color is color to use for background drawing.
WiredHome 37:f19b7e7449dc 114 /// @returns error code.
WiredHome 37:f19b7e7449dc 115 ///
WiredHome 37:f19b7e7449dc 116 virtual RetCode_t background(color_t color) = 0;
dreschpe 0:de9d1462a835 117 // putc (from Stream)
dreschpe 0:de9d1462a835 118 // printf (from Stream)
dreschpe 0:de9d1462a835 119
WiredHome 19:3f82c1161fd2 120 protected:
dreschpe 0:de9d1462a835 121 virtual int _putc(int value);
dreschpe 0:de9d1462a835 122 virtual int _getc();
dreschpe 0:de9d1462a835 123
dreschpe 0:de9d1462a835 124 // character location
dreschpe 0:de9d1462a835 125 uint16_t _column;
dreschpe 0:de9d1462a835 126 uint16_t _row;
dreschpe 0:de9d1462a835 127
WiredHome 33:b6b710758ab3 128 // colors
WiredHome 37:f19b7e7449dc 129 color_t _foreground;
WiredHome 37:f19b7e7449dc 130 color_t _background;
dreschpe 0:de9d1462a835 131 char *_path;
dreschpe 0:de9d1462a835 132 };
dreschpe 0:de9d1462a835 133
dreschpe 0:de9d1462a835 134 #endif