Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
TextDisplay.h
- Committer:
- llagendijk
- Date:
- 2011-01-29
- Revision:
- 7:d79600310cfe
- Parent:
- 4:0cbf500f8650
- Child:
- 8:66be6a696e4e
File content as of revision 7:d79600310cfe:
/* 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"
#include "mbed.h"
/** Text diaplay class, use one the derived classes
* Example:
* @code
/ simple test for TextDisplay class
#include "mbed.h"
#include "sed133xLCD.h"
sed133xLCD lcd(p5, p6, p7, p8, p9, p28, p27, p26, p25, p24, p23, p22, p21,256,128, 6,9, "lcd");
int main() {
lcd.printf("Hello TextDisplay world!\r\n");
lcd.claim(stdout);
printf("hello stream world\r\n");
}
* @endcode
*/
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(uint16_t column, uint16_t row, int c) = 0;
/** return number if rows on TextDisplay
* @result number of rows
*/
virtual uint16_t rows() = 0;
/** return number if columns on TextDisplay
* @result number of rows
*/
virtual uint16_t 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();
/** locate cursor on given position
* @param column horizontal position
* @paran row vertical positon
*/
virtual void locate(uint16_t column, uint16_t row);
/** set foreground colour
* @param colour
*/
virtual void foreground(uint32_t colour);
/** set background colour
* @param colour
*/
virtual void background(uint32_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
uint32_t _foreground;
uint32_t _background;
char *_path;
};
#endif