Library for TFT via SPI

Dependents:   mbed_projekt_tetris Ejemplo_TFT

Committer:
2018US_HarisSoljic
Date:
Mon Jun 18 20:01:55 2018 +0000
Revision:
0:b8956708b92f
revi?n;

Who changed what in which revision?

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