Utility library for HSP SPo2 HR demo including user interface, board support adn accelerometer.
demoUI/screen/TextDisplay.h@0:a12d6976d64c, 2018-12-17 (annotated)
- Committer:
- gmehmet
- Date:
- Mon Dec 17 13:58:56 2018 +0300
- Revision:
- 0:a12d6976d64c
create and put source to HSP demo utility repo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gmehmet | 0:a12d6976d64c | 1 | /* mbed TextDisplay Library Base Class |
gmehmet | 0:a12d6976d64c | 2 | * Copyright (c) 2007-2009 sford |
gmehmet | 0:a12d6976d64c | 3 | * Released under the MIT License: http://mbed.org/license/mit |
gmehmet | 0:a12d6976d64c | 4 | * |
gmehmet | 0:a12d6976d64c | 5 | * A common base class for Text displays |
gmehmet | 0:a12d6976d64c | 6 | * To port a new display, derive from this class and implement |
gmehmet | 0:a12d6976d64c | 7 | * the constructor (setup the display), character (put a character |
gmehmet | 0:a12d6976d64c | 8 | * at a location), rows and columns (number of rows/cols) functions. |
gmehmet | 0:a12d6976d64c | 9 | * Everything else (locate, printf, putc, cls) will come for free |
gmehmet | 0:a12d6976d64c | 10 | * |
gmehmet | 0:a12d6976d64c | 11 | * The model is the display will wrap at the right and bottom, so you can |
gmehmet | 0:a12d6976d64c | 12 | * keep writing and will always get valid characters. The location is |
gmehmet | 0:a12d6976d64c | 13 | * maintained internally to the class to make this easy |
gmehmet | 0:a12d6976d64c | 14 | */ |
gmehmet | 0:a12d6976d64c | 15 | |
gmehmet | 0:a12d6976d64c | 16 | #ifndef MBED_TEXTDISPLAY_H |
gmehmet | 0:a12d6976d64c | 17 | #define MBED_TEXTDISPLAY_H |
gmehmet | 0:a12d6976d64c | 18 | |
gmehmet | 0:a12d6976d64c | 19 | #include "../screen/LCDSettings.h" |
gmehmet | 0:a12d6976d64c | 20 | #include "mbed.h" |
gmehmet | 0:a12d6976d64c | 21 | |
gmehmet | 0:a12d6976d64c | 22 | class TextDisplay { |
gmehmet | 0:a12d6976d64c | 23 | public: |
gmehmet | 0:a12d6976d64c | 24 | |
gmehmet | 0:a12d6976d64c | 25 | // functions needing implementation in derived implementation class |
gmehmet | 0:a12d6976d64c | 26 | /** Create a TextDisplay interface |
gmehmet | 0:a12d6976d64c | 27 | * |
gmehmet | 0:a12d6976d64c | 28 | * @param name The name used in the path to access the strean through the filesystem |
gmehmet | 0:a12d6976d64c | 29 | */ |
gmehmet | 0:a12d6976d64c | 30 | TextDisplay(const char *name = NULL); |
gmehmet | 0:a12d6976d64c | 31 | |
gmehmet | 0:a12d6976d64c | 32 | /** output a character at the given position |
gmehmet | 0:a12d6976d64c | 33 | * |
gmehmet | 0:a12d6976d64c | 34 | * @param column column where charater must be written |
gmehmet | 0:a12d6976d64c | 35 | * @param row where character must be written |
gmehmet | 0:a12d6976d64c | 36 | * @param c the character to be written to the TextDisplay |
gmehmet | 0:a12d6976d64c | 37 | */ |
gmehmet | 0:a12d6976d64c | 38 | virtual void character(int column, int row, int c) = 0; |
gmehmet | 0:a12d6976d64c | 39 | |
gmehmet | 0:a12d6976d64c | 40 | /** return number if rows on TextDisplay |
gmehmet | 0:a12d6976d64c | 41 | * @result number of rows |
gmehmet | 0:a12d6976d64c | 42 | */ |
gmehmet | 0:a12d6976d64c | 43 | virtual int rows() = 0; |
gmehmet | 0:a12d6976d64c | 44 | |
gmehmet | 0:a12d6976d64c | 45 | /** return number if columns on TextDisplay |
gmehmet | 0:a12d6976d64c | 46 | * @result number of rows |
gmehmet | 0:a12d6976d64c | 47 | */ |
gmehmet | 0:a12d6976d64c | 48 | virtual int columns() = 0; |
gmehmet | 0:a12d6976d64c | 49 | |
gmehmet | 0:a12d6976d64c | 50 | // Sets external font usage, eg. dispaly.set_font(Arial12x12); |
gmehmet | 0:a12d6976d64c | 51 | // This uses pixel positioning. |
gmehmet | 0:a12d6976d64c | 52 | // display.set_font(NULL); returns to internal default font. |
gmehmet | 0:a12d6976d64c | 53 | void set_font(const unsigned char * f); |
gmehmet | 0:a12d6976d64c | 54 | |
gmehmet | 0:a12d6976d64c | 55 | // set position of the next character or string print. |
gmehmet | 0:a12d6976d64c | 56 | // External font, set pixel x(column),y(row) position. |
gmehmet | 0:a12d6976d64c | 57 | // internal(default) font, set character column and row position |
gmehmet | 0:a12d6976d64c | 58 | virtual void locate(int column, int row); |
gmehmet | 0:a12d6976d64c | 59 | |
gmehmet | 0:a12d6976d64c | 60 | // functions that come for free, but can be overwritten |
gmehmet | 0:a12d6976d64c | 61 | |
gmehmet | 0:a12d6976d64c | 62 | /** clear screen |
gmehmet | 0:a12d6976d64c | 63 | */ |
gmehmet | 0:a12d6976d64c | 64 | virtual void cls(); |
gmehmet | 0:a12d6976d64c | 65 | virtual void foreground(uint16_t colour); |
gmehmet | 0:a12d6976d64c | 66 | virtual void background(uint16_t colour); |
gmehmet | 0:a12d6976d64c | 67 | // putc (from Stream) |
gmehmet | 0:a12d6976d64c | 68 | // printf (from Stream) |
gmehmet | 0:a12d6976d64c | 69 | virtual void printf(const char* format, ...); |
gmehmet | 0:a12d6976d64c | 70 | |
gmehmet | 0:a12d6976d64c | 71 | protected: |
gmehmet | 0:a12d6976d64c | 72 | |
gmehmet | 0:a12d6976d64c | 73 | virtual int _putc(int value); |
gmehmet | 0:a12d6976d64c | 74 | virtual int _getc(); |
gmehmet | 0:a12d6976d64c | 75 | |
gmehmet | 0:a12d6976d64c | 76 | // external font functions |
gmehmet | 0:a12d6976d64c | 77 | const unsigned char* font; |
gmehmet | 0:a12d6976d64c | 78 | int externalfont; |
gmehmet | 0:a12d6976d64c | 79 | |
gmehmet | 0:a12d6976d64c | 80 | // character location |
gmehmet | 0:a12d6976d64c | 81 | uint16_t _column; |
gmehmet | 0:a12d6976d64c | 82 | uint16_t _row; |
gmehmet | 0:a12d6976d64c | 83 | unsigned int char_x; |
gmehmet | 0:a12d6976d64c | 84 | unsigned int char_y; |
gmehmet | 0:a12d6976d64c | 85 | |
gmehmet | 0:a12d6976d64c | 86 | // colours |
gmehmet | 0:a12d6976d64c | 87 | uint16_t _foreground; |
gmehmet | 0:a12d6976d64c | 88 | uint16_t _background; |
gmehmet | 0:a12d6976d64c | 89 | char *_path; |
gmehmet | 0:a12d6976d64c | 90 | }; |
gmehmet | 0:a12d6976d64c | 91 | |
gmehmet | 0:a12d6976d64c | 92 | #endif |