Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.

Offline Help Manual (Windows chm)

/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)

Committer:
WiredHome
Date:
Sun Jan 13 19:02:36 2019 +0000
Revision:
161:0215d0eec1a4
Parent:
125:7a0b70f56550
Child:
167:8aa3fb2a5a31
Readjusted font parameters - ; <space> width is 1/4 the character height,; '0' - '9' by default as sized to the width of the widest digit.; command line can still override digit width.

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
WiredHome 19:3f82c1161fd2 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"
dreschpe 0:de9d1462a835 20
WiredHome 31:c72e12cd5c67 21 #include "DisplayDefs.h"
WiredHome 19:3f82c1161fd2 22
WiredHome 37:f19b7e7449dc 23 /// A text display class that supports character based
WiredHome 37:f19b7e7449dc 24 /// presentation.
WiredHome 37:f19b7e7449dc 25 ///
WiredHome 19:3f82c1161fd2 26 class TextDisplay : public Stream
WiredHome 19:3f82c1161fd2 27 {
dreschpe 0:de9d1462a835 28 public:
dreschpe 0:de9d1462a835 29
WiredHome 19:3f82c1161fd2 30 // functions needing implementation in derived implementation class
WiredHome 37:f19b7e7449dc 31 /// Create a TextDisplay interface
WiredHome 37:f19b7e7449dc 32 ///
WiredHome 37:f19b7e7449dc 33 /// @param name The name used in the path to access the display through
WiredHome 37:f19b7e7449dc 34 /// the stdio stream.
WiredHome 37:f19b7e7449dc 35 ///
dreschpe 0:de9d1462a835 36 TextDisplay(const char *name = NULL);
dreschpe 0:de9d1462a835 37
WiredHome 103:7e0464ca6c5c 38 /// destructor to clean up
WiredHome 103:7e0464ca6c5c 39 ///
WiredHome 104:8d1d3832a215 40 //~TextDisplay();
WiredHome 103:7e0464ca6c5c 41
WiredHome 37:f19b7e7449dc 42 /// output a character at the given position
WiredHome 37:f19b7e7449dc 43 ///
WiredHome 37:f19b7e7449dc 44 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 45 ///
WiredHome 76:c981284eb513 46 /// @param[in] x position in pixels
WiredHome 76:c981284eb513 47 /// @param[in] y position in pixels
WiredHome 76:c981284eb513 48 /// @param[in] c the character to be written to the TextDisplay
WiredHome 37:f19b7e7449dc 49 /// @returns number of pixels to advance the cursor which could be the cell width
WiredHome 37:f19b7e7449dc 50 /// for non-proportional characters, or the actual character width for
WiredHome 37:f19b7e7449dc 51 /// proportional characters.
WiredHome 37:f19b7e7449dc 52 ///
WiredHome 29:422616aa04bd 53 virtual int character(int x, int y, int c) = 0;
dreschpe 0:de9d1462a835 54
WiredHome 37:f19b7e7449dc 55 /// return number of rows on TextDisplay
WiredHome 37:f19b7e7449dc 56 ///
WiredHome 37:f19b7e7449dc 57 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 58 ///
WiredHome 37:f19b7e7449dc 59 /// @returns number of text rows for the display for the currently
WiredHome 37:f19b7e7449dc 60 /// active font.
WiredHome 37:f19b7e7449dc 61 ///
dreschpe 0:de9d1462a835 62 virtual int rows() = 0;
dreschpe 0:de9d1462a835 63
WiredHome 37:f19b7e7449dc 64 /// return number if columns on TextDisplay
WiredHome 37:f19b7e7449dc 65 ///
WiredHome 37:f19b7e7449dc 66 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 67 ///
WiredHome 37:f19b7e7449dc 68 /// @returns number of text rows for the display for the currently
WiredHome 37:f19b7e7449dc 69 /// active font.
WiredHome 37:f19b7e7449dc 70 ///
dreschpe 0:de9d1462a835 71 virtual int columns() = 0;
WiredHome 19:3f82c1161fd2 72
dreschpe 0:de9d1462a835 73 // functions that come for free, but can be overwritten
dreschpe 0:de9d1462a835 74
WiredHome 37:f19b7e7449dc 75 /// redirect output from a stream (stoud, sterr) to display
WiredHome 37:f19b7e7449dc 76 ///
WiredHome 37:f19b7e7449dc 77 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 78 ///
WiredHome 76:c981284eb513 79 /// @param[in] stream that shall be redirected to the TextDisplay
WiredHome 37:f19b7e7449dc 80 /// @returns true if the claim succeeded.
WiredHome 37:f19b7e7449dc 81 ///
dreschpe 0:de9d1462a835 82 virtual bool claim (FILE *stream);
dreschpe 0:de9d1462a835 83
WiredHome 37:f19b7e7449dc 84 /// clear screen
WiredHome 37:f19b7e7449dc 85 ///
WiredHome 37:f19b7e7449dc 86 /// @note this method may be overridden in a derived class.
WiredHome 76:c981284eb513 87 ///
WiredHome 76:c981284eb513 88 /// @param[in] layers is ignored, but supports maintaining the same
WiredHome 61:8f3153bf0baa 89 /// API for the graphics layer.
WiredHome 37:f19b7e7449dc 90 /// @returns error code.
WiredHome 37:f19b7e7449dc 91 ///
WiredHome 61:8f3153bf0baa 92 virtual RetCode_t cls(uint16_t layers = 0) = 0;
WiredHome 37:f19b7e7449dc 93
WiredHome 37:f19b7e7449dc 94 /// locate the cursor at a character position.
WiredHome 37:f19b7e7449dc 95 ///
WiredHome 37:f19b7e7449dc 96 /// Based on the currently active font, locate the cursor on screen.
WiredHome 37:f19b7e7449dc 97 ///
WiredHome 37:f19b7e7449dc 98 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 99 ///
WiredHome 76:c981284eb513 100 /// @param[in] column is the horizontal offset from the left side.
WiredHome 76:c981284eb513 101 /// @param[in] row is the vertical offset from the top.
WiredHome 37:f19b7e7449dc 102 /// @returns error code.
WiredHome 37:f19b7e7449dc 103 ///
WiredHome 37:f19b7e7449dc 104 virtual RetCode_t locate(textloc_t column, textloc_t row) = 0;
WiredHome 37:f19b7e7449dc 105
WiredHome 37:f19b7e7449dc 106 /// set the foreground color
WiredHome 37:f19b7e7449dc 107 ///
WiredHome 37:f19b7e7449dc 108 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 109 ///
WiredHome 76:c981284eb513 110 /// @param[in] color is color to use for foreground drawing.
WiredHome 37:f19b7e7449dc 111 /// @returns error code.
WiredHome 37:f19b7e7449dc 112 ///
WiredHome 37:f19b7e7449dc 113 virtual RetCode_t foreground(color_t color) = 0;
WiredHome 37:f19b7e7449dc 114
WiredHome 37:f19b7e7449dc 115 /// set the background color
WiredHome 37:f19b7e7449dc 116 ///
WiredHome 37:f19b7e7449dc 117 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 118 ///
WiredHome 76:c981284eb513 119 /// @param[in] color is color to use for background drawing.
WiredHome 37:f19b7e7449dc 120 /// @returns error code.
WiredHome 37:f19b7e7449dc 121 ///
WiredHome 37:f19b7e7449dc 122 virtual RetCode_t background(color_t color) = 0;
dreschpe 0:de9d1462a835 123 // putc (from Stream)
dreschpe 0:de9d1462a835 124 // printf (from Stream)
dreschpe 0:de9d1462a835 125
WiredHome 125:7a0b70f56550 126 protected:
WiredHome 125:7a0b70f56550 127 /// a method to put a character to the display.
WiredHome 125:7a0b70f56550 128 ///
WiredHome 125:7a0b70f56550 129 /// @param value is the character value to send to the display
WiredHome 125:7a0b70f56550 130 /// @returns the character that was sent.
WiredHome 125:7a0b70f56550 131 ///
dreschpe 0:de9d1462a835 132 virtual int _putc(int value);
WiredHome 125:7a0b70f56550 133
WiredHome 125:7a0b70f56550 134 /// a method to get a character from the stdin
WiredHome 125:7a0b70f56550 135 ///
WiredHome 125:7a0b70f56550 136 /// @returns the fetched character.
WiredHome 125:7a0b70f56550 137 ///
dreschpe 0:de9d1462a835 138 virtual int _getc();
dreschpe 0:de9d1462a835 139
WiredHome 125:7a0b70f56550 140 uint16_t _column; ///< character column location
WiredHome 125:7a0b70f56550 141 uint16_t _row; ///< character row location
dreschpe 0:de9d1462a835 142
WiredHome 33:b6b710758ab3 143 // colors
WiredHome 125:7a0b70f56550 144 color_t _foreground; ///< presently set foreground color
WiredHome 125:7a0b70f56550 145 color_t _background; ///< presently set background color
WiredHome 125:7a0b70f56550 146 char *_path; ///< stream name when redirecting stdio
dreschpe 0:de9d1462a835 147 };
dreschpe 0:de9d1462a835 148
dreschpe 0:de9d1462a835 149 #endif