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