a white square appears on SPI LCD which controlled by WII nunchuck on the other hand it outputs log mwessage on USBTX/RX incompatible with latest mbed library
TextDisplay.h@0:0c777a879891, 2013-08-27 (annotated)
- Committer:
- k4zuki
- Date:
- Tue Aug 27 14:31:22 2013 +0000
- Revision:
- 0:0c777a879891
p9 and p10 forI2C, p11,12,13,14,23 are for SPI, R/S select and reset
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
k4zuki | 0:0c777a879891 | 1 | /* mbed TextDisplay Library Base Class |
k4zuki | 0:0c777a879891 | 2 | * Copyright (c) 2007-2009 sford |
k4zuki | 0:0c777a879891 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
k4zuki | 0:0c777a879891 | 4 | * |
k4zuki | 0:0c777a879891 | 5 | * A common base class for Text displays |
k4zuki | 0:0c777a879891 | 6 | * To port a new display, derive from this class and implement |
k4zuki | 0:0c777a879891 | 7 | * the constructor (setup the display), character (put a character |
k4zuki | 0:0c777a879891 | 8 | * at a location), rows and columns (number of rows/cols) functions. |
k4zuki | 0:0c777a879891 | 9 | * Everything else (locate, printf, putc, cls) will come for free |
k4zuki | 0:0c777a879891 | 10 | * |
k4zuki | 0:0c777a879891 | 11 | * The model is the display will wrap at the right and bottom, so you can |
k4zuki | 0:0c777a879891 | 12 | * keep writing and will always get valid characters. The location is |
k4zuki | 0:0c777a879891 | 13 | * maintained internally to the class to make this easy |
k4zuki | 0:0c777a879891 | 14 | */ |
k4zuki | 0:0c777a879891 | 15 | |
k4zuki | 0:0c777a879891 | 16 | #ifndef MBED_TEXTDISPLAY_H |
k4zuki | 0:0c777a879891 | 17 | #define MBED_TEXTDISPLAY_H |
k4zuki | 0:0c777a879891 | 18 | |
k4zuki | 0:0c777a879891 | 19 | #include "mbed.h" |
k4zuki | 0:0c777a879891 | 20 | |
k4zuki | 0:0c777a879891 | 21 | class TextDisplay : public Stream { |
k4zuki | 0:0c777a879891 | 22 | public: |
k4zuki | 0:0c777a879891 | 23 | |
k4zuki | 0:0c777a879891 | 24 | // functions needing implementation in derived implementation class |
k4zuki | 0:0c777a879891 | 25 | /** Create a TextDisplay interface |
k4zuki | 0:0c777a879891 | 26 | * |
k4zuki | 0:0c777a879891 | 27 | * @param name The name used in the path to access the strean through the filesystem |
k4zuki | 0:0c777a879891 | 28 | */ |
k4zuki | 0:0c777a879891 | 29 | TextDisplay(const char *name = NULL); |
k4zuki | 0:0c777a879891 | 30 | |
k4zuki | 0:0c777a879891 | 31 | /** output a character at the given position |
k4zuki | 0:0c777a879891 | 32 | * |
k4zuki | 0:0c777a879891 | 33 | * @param column column where charater must be written |
k4zuki | 0:0c777a879891 | 34 | * @param row where character must be written |
k4zuki | 0:0c777a879891 | 35 | * @param c the character to be written to the TextDisplay |
k4zuki | 0:0c777a879891 | 36 | */ |
k4zuki | 0:0c777a879891 | 37 | virtual void character(int column, int row, int c) = 0; |
k4zuki | 0:0c777a879891 | 38 | |
k4zuki | 0:0c777a879891 | 39 | /** return number if rows on TextDisplay |
k4zuki | 0:0c777a879891 | 40 | * @result number of rows |
k4zuki | 0:0c777a879891 | 41 | */ |
k4zuki | 0:0c777a879891 | 42 | virtual int rows() = 0; |
k4zuki | 0:0c777a879891 | 43 | |
k4zuki | 0:0c777a879891 | 44 | /** return number if columns on TextDisplay |
k4zuki | 0:0c777a879891 | 45 | * @result number of rows |
k4zuki | 0:0c777a879891 | 46 | */ |
k4zuki | 0:0c777a879891 | 47 | virtual int columns() = 0; |
k4zuki | 0:0c777a879891 | 48 | |
k4zuki | 0:0c777a879891 | 49 | // functions that come for free, but can be overwritten |
k4zuki | 0:0c777a879891 | 50 | |
k4zuki | 0:0c777a879891 | 51 | /** redirect output from a stream (stoud, sterr) to display |
k4zuki | 0:0c777a879891 | 52 | * @param stream stream that shall be redirected to the TextDisplay |
k4zuki | 0:0c777a879891 | 53 | */ |
k4zuki | 0:0c777a879891 | 54 | virtual bool claim (FILE *stream); |
k4zuki | 0:0c777a879891 | 55 | |
k4zuki | 0:0c777a879891 | 56 | /** clear screen |
k4zuki | 0:0c777a879891 | 57 | */ |
k4zuki | 0:0c777a879891 | 58 | virtual void cls(); |
k4zuki | 0:0c777a879891 | 59 | virtual void locate(int column, int row); |
k4zuki | 0:0c777a879891 | 60 | virtual void foreground(uint16_t colour); |
k4zuki | 0:0c777a879891 | 61 | virtual void background(uint16_t colour); |
k4zuki | 0:0c777a879891 | 62 | // putc (from Stream) |
k4zuki | 0:0c777a879891 | 63 | // printf (from Stream) |
k4zuki | 0:0c777a879891 | 64 | |
k4zuki | 0:0c777a879891 | 65 | protected: |
k4zuki | 0:0c777a879891 | 66 | |
k4zuki | 0:0c777a879891 | 67 | virtual int _putc(int value); |
k4zuki | 0:0c777a879891 | 68 | virtual int _getc(); |
k4zuki | 0:0c777a879891 | 69 | |
k4zuki | 0:0c777a879891 | 70 | // character location |
k4zuki | 0:0c777a879891 | 71 | uint16_t _column; |
k4zuki | 0:0c777a879891 | 72 | uint16_t _row; |
k4zuki | 0:0c777a879891 | 73 | |
k4zuki | 0:0c777a879891 | 74 | // colours |
k4zuki | 0:0c777a879891 | 75 | uint16_t _foreground; |
k4zuki | 0:0c777a879891 | 76 | uint16_t _background; |
k4zuki | 0:0c777a879891 | 77 | char *_path; |
k4zuki | 0:0c777a879891 | 78 | }; |
k4zuki | 0:0c777a879891 | 79 | |
k4zuki | 0:0c777a879891 | 80 | #endif |