Library to control a QVGA TFT connected to SPI. You can use printf to print text The lib can handle different fonts, draw lines, circles, rect and bmp

Committer:
dreschpe
Date:
Tue Sep 11 20:44:49 2012 +0000
Revision:
13:d525819cb601
Parent:
0:cccc5726bdf3
Switch back to io mode CS. The automatic spi cs can cause problems with interrupts or RTOS.

Who changed what in which revision?

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