A TextDisplay driver that supports graphical displays using on of the SED133x conrtrolers. Allows stdout and stderr output to be redirected to the display.
Diff: TextDisplay.cpp
- Revision:
- 2:8596e06f241f
- Parent:
- 1:18c56f038905
diff -r 18c56f038905 -r 8596e06f241f TextDisplay.cpp --- a/TextDisplay.cpp Sat Jan 15 16:02:56 2011 +0000 +++ b/TextDisplay.cpp Wed Jan 26 21:56:12 2011 +0000 @@ -8,6 +8,12 @@ TextDisplay::TextDisplay(const char *name) : Stream(name) { _row = 0; _column = 0; + if (name == NULL) { + _path = NULL; + } else { + _path = new char[strlen(name) + 2]; + sprintf(_path, "/%s", name); + } } int TextDisplay::_putc(int value) { @@ -55,3 +61,17 @@ void TextDisplay::background(uint32_t colour) { _background = colour; } + +bool TextDisplay::claim (FILE *stream) { + if ( _path == NULL) { + fprintf(stderr, "claim requires a name to be given in the instantioator of the TextDisplay instance!\r\n"); + return false; + } + if (freopen(_path, "w", stream) == NULL) { + // Failed, should not happen + return false; + } + // make sure we use line buffering + setvbuf(stdout, NULL, _IOLBF, columns()); + return true; +} \ No newline at end of file