John Durrell / SPI_TFT
Committer:
jhd25
Date:
Mon Jul 06 10:57:10 2020 +0100
Revision:
26:231a28b27a76
Parent:
20:275bf616ceb7
Working BMP from SD

Who changed what in which revision?

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