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