![](/media/cache/profiles/0996dd16b0020a17a26b94f4675fd3da.50x50_q85.png)
RC_reciever
Dependencies: mbed RC_reciever
TextLCD.h@2:8c428bae83a8, 2015-12-21 (annotated)
- Committer:
- higedura
- Date:
- Mon Dec 21 02:31:52 2015 +0000
- Revision:
- 2:8c428bae83a8
- Parent:
- 0:18d415e9d13b
RC receiver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
higedura | 0:18d415e9d13b | 1 | /* mbed TextLCD Library, for a 4-bit LCD based on HD44780 |
higedura | 0:18d415e9d13b | 2 | * Copyright (c) 2007-2010, sford, http://mbed.org |
higedura | 0:18d415e9d13b | 3 | * |
higedura | 0:18d415e9d13b | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
higedura | 0:18d415e9d13b | 5 | * of this software and associated documentation files (the "Software"), to deal |
higedura | 0:18d415e9d13b | 6 | * in the Software without restriction, including without limitation the rights |
higedura | 0:18d415e9d13b | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
higedura | 0:18d415e9d13b | 8 | * copies of the Software, and to permit persons to whom the Software is |
higedura | 0:18d415e9d13b | 9 | * furnished to do so, subject to the following conditions: |
higedura | 0:18d415e9d13b | 10 | * |
higedura | 0:18d415e9d13b | 11 | * The above copyright notice and this permission notice shall be included in |
higedura | 0:18d415e9d13b | 12 | * all copies or substantial portions of the Software. |
higedura | 0:18d415e9d13b | 13 | * |
higedura | 0:18d415e9d13b | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
higedura | 0:18d415e9d13b | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
higedura | 0:18d415e9d13b | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
higedura | 0:18d415e9d13b | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
higedura | 0:18d415e9d13b | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
higedura | 0:18d415e9d13b | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
higedura | 0:18d415e9d13b | 20 | * THE SOFTWARE. |
higedura | 0:18d415e9d13b | 21 | */ |
higedura | 0:18d415e9d13b | 22 | |
higedura | 0:18d415e9d13b | 23 | #ifndef MBED_TEXTLCD_H |
higedura | 0:18d415e9d13b | 24 | #define MBED_TEXTLCD_H |
higedura | 0:18d415e9d13b | 25 | |
higedura | 0:18d415e9d13b | 26 | #include "mbed.h" |
higedura | 0:18d415e9d13b | 27 | |
higedura | 0:18d415e9d13b | 28 | /** A TextLCD interface for driving 4-bit HD44780-based LCDs |
higedura | 0:18d415e9d13b | 29 | * |
higedura | 0:18d415e9d13b | 30 | * Currently supports 16x2, 20x2 and 20x4 panels |
higedura | 0:18d415e9d13b | 31 | * |
higedura | 0:18d415e9d13b | 32 | * @code |
higedura | 0:18d415e9d13b | 33 | * #include "mbed.h" |
higedura | 0:18d415e9d13b | 34 | * #include "TextLCD.h" |
higedura | 0:18d415e9d13b | 35 | * |
higedura | 0:18d415e9d13b | 36 | * TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d4-d7 |
higedura | 0:18d415e9d13b | 37 | * |
higedura | 0:18d415e9d13b | 38 | * int main() { |
higedura | 0:18d415e9d13b | 39 | * lcd.printf("Hello World!\n"); |
higedura | 0:18d415e9d13b | 40 | * } |
higedura | 0:18d415e9d13b | 41 | * @endcode |
higedura | 0:18d415e9d13b | 42 | */ |
higedura | 0:18d415e9d13b | 43 | class TextLCD : public Stream { |
higedura | 0:18d415e9d13b | 44 | public: |
higedura | 0:18d415e9d13b | 45 | |
higedura | 0:18d415e9d13b | 46 | /** LCD panel format */ |
higedura | 0:18d415e9d13b | 47 | enum LCDType { |
higedura | 0:18d415e9d13b | 48 | LCD16x2 /**< 16x2 LCD panel (default) */ |
higedura | 0:18d415e9d13b | 49 | , LCD16x2B /**< 16x2 LCD panel alternate addressing */ |
higedura | 0:18d415e9d13b | 50 | , LCD20x2 /**< 20x2 LCD panel */ |
higedura | 0:18d415e9d13b | 51 | , LCD20x4 /**< 20x4 LCD panel */ |
higedura | 0:18d415e9d13b | 52 | }; |
higedura | 0:18d415e9d13b | 53 | |
higedura | 0:18d415e9d13b | 54 | /** Create a TextLCD interface |
higedura | 0:18d415e9d13b | 55 | * |
higedura | 0:18d415e9d13b | 56 | * @param rs Instruction/data control line |
higedura | 0:18d415e9d13b | 57 | * @param e Enable line (clock) |
higedura | 0:18d415e9d13b | 58 | * @param d4-d7 Data lines for using as a 4-bit interface |
higedura | 0:18d415e9d13b | 59 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
higedura | 0:18d415e9d13b | 60 | */ |
higedura | 0:18d415e9d13b | 61 | TextLCD(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type = LCD16x2); |
higedura | 0:18d415e9d13b | 62 | |
higedura | 0:18d415e9d13b | 63 | #if DOXYGEN_ONLY |
higedura | 0:18d415e9d13b | 64 | /** Write a character to the LCD |
higedura | 0:18d415e9d13b | 65 | * |
higedura | 0:18d415e9d13b | 66 | * @param c The character to write to the display |
higedura | 0:18d415e9d13b | 67 | */ |
higedura | 0:18d415e9d13b | 68 | int putc(int c); |
higedura | 0:18d415e9d13b | 69 | |
higedura | 0:18d415e9d13b | 70 | /** Write a formated string to the LCD |
higedura | 0:18d415e9d13b | 71 | * |
higedura | 0:18d415e9d13b | 72 | * @param format A printf-style format string, followed by the |
higedura | 0:18d415e9d13b | 73 | * variables to use in formating the string. |
higedura | 0:18d415e9d13b | 74 | */ |
higedura | 0:18d415e9d13b | 75 | int printf(const char* format, ...); |
higedura | 0:18d415e9d13b | 76 | #endif |
higedura | 0:18d415e9d13b | 77 | |
higedura | 0:18d415e9d13b | 78 | /** Locate to a screen column and row |
higedura | 0:18d415e9d13b | 79 | * |
higedura | 0:18d415e9d13b | 80 | * @param column The horizontal position from the left, indexed from 0 |
higedura | 0:18d415e9d13b | 81 | * @param row The vertical position from the top, indexed from 0 |
higedura | 0:18d415e9d13b | 82 | */ |
higedura | 0:18d415e9d13b | 83 | void locate(int column, int row); |
higedura | 0:18d415e9d13b | 84 | |
higedura | 0:18d415e9d13b | 85 | /** Clear the screen and locate to 0,0 */ |
higedura | 0:18d415e9d13b | 86 | void cls(); |
higedura | 0:18d415e9d13b | 87 | |
higedura | 0:18d415e9d13b | 88 | int rows(); |
higedura | 0:18d415e9d13b | 89 | int columns(); |
higedura | 0:18d415e9d13b | 90 | |
higedura | 0:18d415e9d13b | 91 | protected: |
higedura | 0:18d415e9d13b | 92 | |
higedura | 0:18d415e9d13b | 93 | // Stream implementation functions |
higedura | 0:18d415e9d13b | 94 | virtual int _putc(int value); |
higedura | 0:18d415e9d13b | 95 | virtual int _getc(); |
higedura | 0:18d415e9d13b | 96 | |
higedura | 0:18d415e9d13b | 97 | int address(int column, int row); |
higedura | 0:18d415e9d13b | 98 | void character(int column, int row, int c); |
higedura | 0:18d415e9d13b | 99 | void writeByte(int value); |
higedura | 0:18d415e9d13b | 100 | void writeCommand(int command); |
higedura | 0:18d415e9d13b | 101 | void writeData(int data); |
higedura | 0:18d415e9d13b | 102 | |
higedura | 0:18d415e9d13b | 103 | DigitalOut _rs, _e; |
higedura | 0:18d415e9d13b | 104 | BusOut _d; |
higedura | 0:18d415e9d13b | 105 | LCDType _type; |
higedura | 0:18d415e9d13b | 106 | |
higedura | 0:18d415e9d13b | 107 | int _column; |
higedura | 0:18d415e9d13b | 108 | int _row; |
higedura | 0:18d415e9d13b | 109 | }; |
higedura | 0:18d415e9d13b | 110 | |
higedura | 0:18d415e9d13b | 111 | #endif |