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:
Mon May 25 16:08:50 2020 +0000
Revision:
206:83edda283d90
Parent:
198:9b6851107426
Pick up a change in the touch ISR to pick up the final release.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 167:8aa3fb2a5a31 1 /// @page TextDisplay_Copyright Text Display Library Base Class
WiredHome 167:8aa3fb2a5a31 2 ///
WiredHome 167:8aa3fb2a5a31 3 /// mbed TextDisplay Library Base Class
WiredHome 167:8aa3fb2a5a31 4 /// @copyright © 2007-2009 sford
WiredHome 167:8aa3fb2a5a31 5 /// Released under the MIT License: http://mbed.org/license/mit
WiredHome 167:8aa3fb2a5a31 6 ///
WiredHome 167:8aa3fb2a5a31 7 /// A common base class for Text displays
WiredHome 167:8aa3fb2a5a31 8 /// To port a new display, derive from this class and implement
WiredHome 167:8aa3fb2a5a31 9 /// the constructor (setup the display), character (put a character
WiredHome 167:8aa3fb2a5a31 10 /// at a location), rows and columns (number of rows/cols) functions.
WiredHome 167:8aa3fb2a5a31 11 /// Everything else (locate, printf, putc, cls) will come for free
WiredHome 167:8aa3fb2a5a31 12 ///
WiredHome 167:8aa3fb2a5a31 13 /// The model is the display will wrap at the right and bottom, so you can
WiredHome 167:8aa3fb2a5a31 14 /// keep writing and will always get valid characters. The location is
WiredHome 167:8aa3fb2a5a31 15 /// maintained internally to the class to make this easy
WiredHome 167:8aa3fb2a5a31 16 ///
dreschpe 0:de9d1462a835 17 #ifndef MBED_TEXTDISPLAY_H
dreschpe 0:de9d1462a835 18 #define MBED_TEXTDISPLAY_H
dreschpe 0:de9d1462a835 19
dreschpe 0:de9d1462a835 20 #include "mbed.h"
dreschpe 0:de9d1462a835 21
WiredHome 31:c72e12cd5c67 22 #include "DisplayDefs.h"
WiredHome 19:3f82c1161fd2 23
WiredHome 37:f19b7e7449dc 24 /// A text display class that supports character based
WiredHome 37:f19b7e7449dc 25 /// presentation.
WiredHome 37:f19b7e7449dc 26 ///
WiredHome 19:3f82c1161fd2 27 class TextDisplay : public Stream
WiredHome 19:3f82c1161fd2 28 {
dreschpe 0:de9d1462a835 29 public:
dreschpe 0:de9d1462a835 30
WiredHome 19:3f82c1161fd2 31 // functions needing implementation in derived implementation class
WiredHome 37:f19b7e7449dc 32 /// Create a TextDisplay interface
WiredHome 37:f19b7e7449dc 33 ///
WiredHome 198:9b6851107426 34 /// @param name The name used in the path to access the display through
WiredHome 198:9b6851107426 35
WiredHome 37:f19b7e7449dc 36 /// the stdio stream.
WiredHome 37:f19b7e7449dc 37 ///
dreschpe 0:de9d1462a835 38 TextDisplay(const char *name = NULL);
dreschpe 0:de9d1462a835 39
WiredHome 103:7e0464ca6c5c 40 /// destructor to clean up
WiredHome 103:7e0464ca6c5c 41 ///
WiredHome 182:8832d03a2a29 42 virtual ~TextDisplay();
WiredHome 103:7e0464ca6c5c 43
WiredHome 37:f19b7e7449dc 44 /// output a character at the given position
WiredHome 37:f19b7e7449dc 45 ///
WiredHome 37:f19b7e7449dc 46 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 47 ///
WiredHome 76:c981284eb513 48 /// @param[in] x position in pixels
WiredHome 76:c981284eb513 49 /// @param[in] y position in pixels
WiredHome 76:c981284eb513 50 /// @param[in] c the character to be written to the TextDisplay
WiredHome 37:f19b7e7449dc 51 /// @returns number of pixels to advance the cursor which could be the cell width
WiredHome 37:f19b7e7449dc 52 /// for non-proportional characters, or the actual character width for
WiredHome 37:f19b7e7449dc 53 /// proportional characters.
WiredHome 37:f19b7e7449dc 54 ///
WiredHome 29:422616aa04bd 55 virtual int character(int x, int y, int c) = 0;
dreschpe 0:de9d1462a835 56
WiredHome 37:f19b7e7449dc 57 /// return number of rows on TextDisplay
WiredHome 37:f19b7e7449dc 58 ///
WiredHome 37:f19b7e7449dc 59 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 60 ///
WiredHome 198:9b6851107426 61 /// @returns number of text rows for the display for the currently
WiredHome 198:9b6851107426 62
WiredHome 37:f19b7e7449dc 63 /// active font.
WiredHome 37:f19b7e7449dc 64 ///
dreschpe 0:de9d1462a835 65 virtual int rows() = 0;
dreschpe 0:de9d1462a835 66
WiredHome 37:f19b7e7449dc 67 /// return number if columns on TextDisplay
WiredHome 37:f19b7e7449dc 68 ///
WiredHome 37:f19b7e7449dc 69 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 70 ///
WiredHome 37:f19b7e7449dc 71 /// @returns number of text rows for the display for the currently
WiredHome 37:f19b7e7449dc 72 /// active font.
WiredHome 37:f19b7e7449dc 73 ///
dreschpe 0:de9d1462a835 74 virtual int columns() = 0;
WiredHome 19:3f82c1161fd2 75
dreschpe 0:de9d1462a835 76 // functions that come for free, but can be overwritten
dreschpe 0:de9d1462a835 77
WiredHome 37:f19b7e7449dc 78 /// redirect output from a stream (stoud, sterr) to display
WiredHome 37:f19b7e7449dc 79 ///
WiredHome 37:f19b7e7449dc 80 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 81 ///
WiredHome 76:c981284eb513 82 /// @param[in] stream that shall be redirected to the TextDisplay
WiredHome 37:f19b7e7449dc 83 /// @returns true if the claim succeeded.
WiredHome 37:f19b7e7449dc 84 ///
dreschpe 0:de9d1462a835 85 virtual bool claim (FILE *stream);
dreschpe 0:de9d1462a835 86
WiredHome 37:f19b7e7449dc 87 /// clear screen
WiredHome 37:f19b7e7449dc 88 ///
WiredHome 37:f19b7e7449dc 89 /// @note this method may be overridden in a derived class.
WiredHome 76:c981284eb513 90 ///
WiredHome 198:9b6851107426 91 /// @param[in] layers is ignored, but supports maintaining the same
WiredHome 198:9b6851107426 92
WiredHome 61:8f3153bf0baa 93 /// API for the graphics layer.
WiredHome 167:8aa3fb2a5a31 94 /// @returns @ref RetCode_t value.
WiredHome 37:f19b7e7449dc 95 ///
WiredHome 61:8f3153bf0baa 96 virtual RetCode_t cls(uint16_t layers = 0) = 0;
WiredHome 198:9b6851107426 97
WiredHome 198:9b6851107426 98
WiredHome 37:f19b7e7449dc 99 /// locate the cursor at a character position.
WiredHome 37:f19b7e7449dc 100 ///
WiredHome 37:f19b7e7449dc 101 /// Based on the currently active font, locate the cursor on screen.
WiredHome 37:f19b7e7449dc 102 ///
WiredHome 37:f19b7e7449dc 103 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 104 ///
WiredHome 76:c981284eb513 105 /// @param[in] column is the horizontal offset from the left side.
WiredHome 76:c981284eb513 106 /// @param[in] row is the vertical offset from the top.
WiredHome 198:9b6851107426 107 /// @returns @ref point_t value that was the last location.
WiredHome 37:f19b7e7449dc 108 ///
WiredHome 198:9b6851107426 109 virtual point_t locate(textloc_t column, textloc_t row) = 0;
WiredHome 198:9b6851107426 110
WiredHome 198:9b6851107426 111
WiredHome 37:f19b7e7449dc 112 /// set the foreground color
WiredHome 37:f19b7e7449dc 113 ///
WiredHome 37:f19b7e7449dc 114 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 115 ///
WiredHome 76:c981284eb513 116 /// @param[in] color is color to use for foreground drawing.
WiredHome 198:9b6851107426 117 /// @returns @ref color_t value that was the previous color.
WiredHome 37:f19b7e7449dc 118 ///
WiredHome 198:9b6851107426 119 virtual color_t foreground(color_t color) = 0;
WiredHome 37:f19b7e7449dc 120
WiredHome 37:f19b7e7449dc 121 /// set the background color
WiredHome 37:f19b7e7449dc 122 ///
WiredHome 37:f19b7e7449dc 123 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 124 ///
WiredHome 76:c981284eb513 125 /// @param[in] color is color to use for background drawing.
WiredHome 198:9b6851107426 126 /// @returns @ref color_t value that was the previous color.
WiredHome 37:f19b7e7449dc 127 ///
WiredHome 198:9b6851107426 128 virtual color_t background(color_t color) = 0;
dreschpe 0:de9d1462a835 129 // putc (from Stream)
dreschpe 0:de9d1462a835 130 // printf (from Stream)
dreschpe 0:de9d1462a835 131
WiredHome 125:7a0b70f56550 132 protected:
WiredHome 125:7a0b70f56550 133 /// a method to put a character to the display.
WiredHome 125:7a0b70f56550 134 ///
WiredHome 125:7a0b70f56550 135 /// @param value is the character value to send to the display
WiredHome 125:7a0b70f56550 136 /// @returns the character that was sent.
WiredHome 125:7a0b70f56550 137 ///
dreschpe 0:de9d1462a835 138 virtual int _putc(int value);
WiredHome 198:9b6851107426 139
WiredHome 198:9b6851107426 140
WiredHome 125:7a0b70f56550 141 /// a method to get a character from the stdin
WiredHome 198:9b6851107426 142 ///
WiredHome 198:9b6851107426 143
WiredHome 125:7a0b70f56550 144 /// @returns the fetched character.
WiredHome 125:7a0b70f56550 145 ///
dreschpe 0:de9d1462a835 146 virtual int _getc();
dreschpe 0:de9d1462a835 147
WiredHome 125:7a0b70f56550 148 uint16_t _column; ///< character column location
WiredHome 125:7a0b70f56550 149 uint16_t _row; ///< character row location
dreschpe 0:de9d1462a835 150
WiredHome 33:b6b710758ab3 151 // colors
WiredHome 125:7a0b70f56550 152 color_t _foreground; ///< presently set foreground color
WiredHome 125:7a0b70f56550 153 color_t _background; ///< presently set background color
WiredHome 125:7a0b70f56550 154 char *_path; ///< stream name when redirecting stdio
dreschpe 0:de9d1462a835 155 };
dreschpe 0:de9d1462a835 156
dreschpe 0:de9d1462a835 157 #endif