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 Aug 17 13:46:06 2014 +0000
Revision:
61:8f3153bf0baa
Parent:
37:f19b7e7449dc
Child:
76:c981284eb513
Revised cls( ) to support layers.; Added a few handy color definitions.

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 37:f19b7e7449dc 38 /// output a character at the given position
WiredHome 37:f19b7e7449dc 39 ///
WiredHome 37:f19b7e7449dc 40 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 41 ///
WiredHome 37:f19b7e7449dc 42 /// @param x position in pixels
WiredHome 37:f19b7e7449dc 43 /// @param y position in pixels
WiredHome 37:f19b7e7449dc 44 /// @param c the character to be written to the TextDisplay
WiredHome 37:f19b7e7449dc 45 /// @returns number of pixels to advance the cursor which could be the cell width
WiredHome 37:f19b7e7449dc 46 /// for non-proportional characters, or the actual character width for
WiredHome 37:f19b7e7449dc 47 /// proportional characters.
WiredHome 37:f19b7e7449dc 48 ///
WiredHome 29:422616aa04bd 49 virtual int character(int x, int y, int c) = 0;
dreschpe 0:de9d1462a835 50
WiredHome 37:f19b7e7449dc 51 /// return number of rows on TextDisplay
WiredHome 37:f19b7e7449dc 52 ///
WiredHome 37:f19b7e7449dc 53 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 54 ///
WiredHome 37:f19b7e7449dc 55 /// @returns number of text rows for the display for the currently
WiredHome 37:f19b7e7449dc 56 /// active font.
WiredHome 37:f19b7e7449dc 57 ///
dreschpe 0:de9d1462a835 58 virtual int rows() = 0;
dreschpe 0:de9d1462a835 59
WiredHome 37:f19b7e7449dc 60 /// return number if columns on TextDisplay
WiredHome 37:f19b7e7449dc 61 ///
WiredHome 37:f19b7e7449dc 62 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 63 ///
WiredHome 37:f19b7e7449dc 64 /// @returns number of text rows for the display for the currently
WiredHome 37:f19b7e7449dc 65 /// active font.
WiredHome 37:f19b7e7449dc 66 ///
dreschpe 0:de9d1462a835 67 virtual int columns() = 0;
WiredHome 19:3f82c1161fd2 68
dreschpe 0:de9d1462a835 69 // functions that come for free, but can be overwritten
dreschpe 0:de9d1462a835 70
WiredHome 37:f19b7e7449dc 71 /// redirect output from a stream (stoud, sterr) to display
WiredHome 37:f19b7e7449dc 72 ///
WiredHome 37:f19b7e7449dc 73 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 74 ///
WiredHome 37:f19b7e7449dc 75 /// @param stream that shall be redirected to the TextDisplay
WiredHome 37:f19b7e7449dc 76 /// @returns true if the claim succeeded.
WiredHome 37:f19b7e7449dc 77 ///
dreschpe 0:de9d1462a835 78 virtual bool claim (FILE *stream);
dreschpe 0:de9d1462a835 79
WiredHome 37:f19b7e7449dc 80 /// clear screen
WiredHome 37:f19b7e7449dc 81 ///
WiredHome 37:f19b7e7449dc 82 /// @note this method may be overridden in a derived class.
WiredHome 61:8f3153bf0baa 83 /// @param layers is ignored, but supports maintaining the same
WiredHome 61:8f3153bf0baa 84 /// API for the graphics layer.
WiredHome 37:f19b7e7449dc 85 /// @returns error code.
WiredHome 37:f19b7e7449dc 86 ///
WiredHome 61:8f3153bf0baa 87 virtual RetCode_t cls(uint16_t layers = 0) = 0;
WiredHome 37:f19b7e7449dc 88
WiredHome 37:f19b7e7449dc 89 /// locate the cursor at a character position.
WiredHome 37:f19b7e7449dc 90 ///
WiredHome 37:f19b7e7449dc 91 /// Based on the currently active font, locate the cursor on screen.
WiredHome 37:f19b7e7449dc 92 ///
WiredHome 37:f19b7e7449dc 93 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 94 ///
WiredHome 37:f19b7e7449dc 95 /// @param column is the horizontal offset from the left side.
WiredHome 37:f19b7e7449dc 96 /// @param row is the vertical offset from the top.
WiredHome 37:f19b7e7449dc 97 /// @returns error code.
WiredHome 37:f19b7e7449dc 98 ///
WiredHome 37:f19b7e7449dc 99 virtual RetCode_t locate(textloc_t column, textloc_t row) = 0;
WiredHome 37:f19b7e7449dc 100
WiredHome 37:f19b7e7449dc 101 /// set the foreground color
WiredHome 37:f19b7e7449dc 102 ///
WiredHome 37:f19b7e7449dc 103 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 104 ///
WiredHome 37:f19b7e7449dc 105 /// @param color is color to use for foreground drawing.
WiredHome 37:f19b7e7449dc 106 /// @returns error code.
WiredHome 37:f19b7e7449dc 107 ///
WiredHome 37:f19b7e7449dc 108 virtual RetCode_t foreground(color_t color) = 0;
WiredHome 37:f19b7e7449dc 109
WiredHome 37:f19b7e7449dc 110 /// set the background color
WiredHome 37:f19b7e7449dc 111 ///
WiredHome 37:f19b7e7449dc 112 /// @note this method may be overridden in a derived class.
WiredHome 37:f19b7e7449dc 113 ///
WiredHome 37:f19b7e7449dc 114 /// @param color is color to use for background drawing.
WiredHome 37:f19b7e7449dc 115 /// @returns error code.
WiredHome 37:f19b7e7449dc 116 ///
WiredHome 37:f19b7e7449dc 117 virtual RetCode_t background(color_t color) = 0;
dreschpe 0:de9d1462a835 118 // putc (from Stream)
dreschpe 0:de9d1462a835 119 // printf (from Stream)
dreschpe 0:de9d1462a835 120
WiredHome 19:3f82c1161fd2 121 protected:
dreschpe 0:de9d1462a835 122 virtual int _putc(int value);
dreschpe 0:de9d1462a835 123 virtual int _getc();
dreschpe 0:de9d1462a835 124
dreschpe 0:de9d1462a835 125 // character location
dreschpe 0:de9d1462a835 126 uint16_t _column;
dreschpe 0:de9d1462a835 127 uint16_t _row;
dreschpe 0:de9d1462a835 128
WiredHome 33:b6b710758ab3 129 // colors
WiredHome 37:f19b7e7449dc 130 color_t _foreground;
WiredHome 37:f19b7e7449dc 131 color_t _background;
dreschpe 0:de9d1462a835 132 char *_path;
dreschpe 0:de9d1462a835 133 };
dreschpe 0:de9d1462a835 134
dreschpe 0:de9d1462a835 135 #endif