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