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