My controller identifies as an ILI9328, but only works if initialised as an ILI9325. This fork includes a fix to force 9325 initialization when a 9328 is detected.

Dependents:   TouchScreenCalibrate TouchScreenGUIDemo

Fork of UniGraphic by GraphicsDisplay

Committer:
Duncan McIntyre
Date:
Sun Jun 21 15:23:02 2020 +0100
Revision:
34:091b954c3205
Parent:
33:5743f9c16aa2
Updated to include latest changes from upstream
Added a class to provide an interface for my MINI-STM32-V3.0 board.
This class uses direct GPIO access to achieve decent update speeds.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 0:75ec1b3cde17 1 /* mbed TextDisplay Library Base Class
Geremia 0:75ec1b3cde17 2 * Copyright (c) 2007-2009 sford
Geremia 0:75ec1b3cde17 3 * Released under the MIT License: http://mbed.org/license/mit
Geremia 0:75ec1b3cde17 4 *
Geremia 0:75ec1b3cde17 5 * A common base class for Text displays
Geremia 0:75ec1b3cde17 6 * To port a new display, derive from this class and implement
Geremia 0:75ec1b3cde17 7 * the constructor (setup the display), character (put a character
Geremia 0:75ec1b3cde17 8 * at a location), rows and columns (number of rows/cols) functions.
Geremia 0:75ec1b3cde17 9 * Everything else (locate, printf, putc, cls) will come for free
Geremia 0:75ec1b3cde17 10 *
Geremia 0:75ec1b3cde17 11 * The model is the display will wrap at the right and bottom, so you can
Geremia 0:75ec1b3cde17 12 * keep writing and will always get valid characters. The location is
Geremia 0:75ec1b3cde17 13 * maintained internally to the class to make this easy
Geremia 0:75ec1b3cde17 14 */
Geremia 0:75ec1b3cde17 15
Geremia 0:75ec1b3cde17 16 #ifndef MBED_TEXTDISPLAY_H
Geremia 0:75ec1b3cde17 17 #define MBED_TEXTDISPLAY_H
Geremia 0:75ec1b3cde17 18
Geremia 0:75ec1b3cde17 19 #include "mbed.h"
Duncan McIntyre 34:091b954c3205 20 #include "Stream.h"
Geremia 0:75ec1b3cde17 21
Geremia 0:75ec1b3cde17 22 /** A common base class for Text displays
Geremia 0:75ec1b3cde17 23 */
Geremia 0:75ec1b3cde17 24 class TextDisplay : public Stream {
Geremia 0:75ec1b3cde17 25 public:
Geremia 0:75ec1b3cde17 26
Geremia 0:75ec1b3cde17 27 // functions needing implementation in derived implementation class
Geremia 0:75ec1b3cde17 28 // ----------------------------------------------------------------
Geremia 0:75ec1b3cde17 29 /** Create a TextDisplay interface
Geremia 0:75ec1b3cde17 30 * @param name The name used in the path to access the strean through the filesystem
Geremia 0:75ec1b3cde17 31 */
Geremia 0:75ec1b3cde17 32 TextDisplay(const char *name = NULL);
Geremia 0:75ec1b3cde17 33
Geremia 0:75ec1b3cde17 34 /** output a character at the given position
Geremia 0:75ec1b3cde17 35 *
Geremia 0:75ec1b3cde17 36 * @param column column where charater must be written
Geremia 0:75ec1b3cde17 37 * @param row where character must be written
Geremia 0:75ec1b3cde17 38 * @param c the character to be written to the TextDisplay
Geremia 0:75ec1b3cde17 39 * @note this method may be overridden in a derived class.
Geremia 0:75ec1b3cde17 40 */
Geremia 0:75ec1b3cde17 41 virtual void character(int column, int row, int c) = 0;
Geremia 0:75ec1b3cde17 42
Geremia 0:75ec1b3cde17 43 /** return number of rows on TextDisplay
Geremia 0:75ec1b3cde17 44 * @result number of rows
Geremia 0:75ec1b3cde17 45 * @note this method must be supported in the derived class.
Geremia 0:75ec1b3cde17 46 */
Geremia 0:75ec1b3cde17 47 virtual int rows() = 0;
Geremia 0:75ec1b3cde17 48
Geremia 0:75ec1b3cde17 49 /** return number of columns on TextDisplay
Geremia 0:75ec1b3cde17 50 * @result number of columns
Geremia 0:75ec1b3cde17 51 * @note this method must be supported in the derived class.
Geremia 0:75ec1b3cde17 52 */
Geremia 0:75ec1b3cde17 53 virtual int columns() = 0;
Geremia 0:75ec1b3cde17 54
Geremia 0:75ec1b3cde17 55 // functions that come for free, but can be overwritten
Geremia 0:75ec1b3cde17 56 // ----------------------------------------------------
Geremia 0:75ec1b3cde17 57 /** redirect output from a stream (stoud, sterr) to display
Geremia 0:75ec1b3cde17 58 * @param stream stream that shall be redirected to the TextDisplay
Geremia 0:75ec1b3cde17 59 * @note this method may be overridden in a derived class.
Geremia 0:75ec1b3cde17 60 * @returns true if the claim succeeded.
Geremia 0:75ec1b3cde17 61 */
Geremia 0:75ec1b3cde17 62 virtual bool claim (FILE *stream);
Geremia 0:75ec1b3cde17 63
Geremia 0:75ec1b3cde17 64 /** clear the entire screen
Geremia 0:75ec1b3cde17 65 * @note this method may be overridden in a derived class.
Geremia 0:75ec1b3cde17 66 */
Geremia 0:75ec1b3cde17 67 virtual void cls();
Geremia 0:75ec1b3cde17 68
Geremia 0:75ec1b3cde17 69 /** locate the cursor at a character position.
Geremia 0:75ec1b3cde17 70 * Based on the currently active font, locate the cursor on screen.
Geremia 0:75ec1b3cde17 71 * @note this method may be overridden in a derived class.
Geremia 0:75ec1b3cde17 72 * @param column is the horizontal offset from the left side.
Geremia 0:75ec1b3cde17 73 * @param row is the vertical offset from the top.
Geremia 0:75ec1b3cde17 74 */
Geremia 0:75ec1b3cde17 75 virtual void locate(int column, int row);
Geremia 0:75ec1b3cde17 76
Geremia 0:75ec1b3cde17 77 /** set the foreground color
Geremia 0:75ec1b3cde17 78 * @note this method may be overridden in a derived class.
Geremia 0:75ec1b3cde17 79 * @param color is color to use for foreground drawing.
Geremia 0:75ec1b3cde17 80 */
duncanFrance 33:5743f9c16aa2 81 virtual void setForeground(uint16_t colour);
Geremia 0:75ec1b3cde17 82
Geremia 0:75ec1b3cde17 83 /** set the background color
Geremia 0:75ec1b3cde17 84 * @note this method may be overridden in a derived class.
Geremia 0:75ec1b3cde17 85 * @param color is color to use for background drawing.
Geremia 0:75ec1b3cde17 86 */
duncanFrance 33:5743f9c16aa2 87 virtual void setBackground(uint16_t colour);
duncanFrance 33:5743f9c16aa2 88 virtual uint16_t getForeground();
duncanFrance 33:5743f9c16aa2 89 virtual uint16_t getBackground();
duncanFrance 33:5743f9c16aa2 90
Geremia 0:75ec1b3cde17 91 // putc (from Stream)
Geremia 0:75ec1b3cde17 92 // printf (from Stream)
Geremia 0:75ec1b3cde17 93
Geremia 0:75ec1b3cde17 94 protected:
Geremia 0:75ec1b3cde17 95
Geremia 0:75ec1b3cde17 96 virtual int _putc(int value);
Geremia 0:75ec1b3cde17 97 virtual int _getc();
Geremia 0:75ec1b3cde17 98
Geremia 0:75ec1b3cde17 99 // character location
Geremia 0:75ec1b3cde17 100 int _column;
Geremia 0:75ec1b3cde17 101 int _row;
Geremia 0:75ec1b3cde17 102
Geremia 0:75ec1b3cde17 103 // colours
Geremia 4:12ba0ecc2c1f 104 volatile uint16_t _foreground;
Geremia 4:12ba0ecc2c1f 105 volatile uint16_t _background;
Geremia 0:75ec1b3cde17 106 char *_path;
Geremia 0:75ec1b3cde17 107 };
Geremia 0:75ec1b3cde17 108
Geremia 0:75ec1b3cde17 109 #endif