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