Vinícius Alves
/
MenuLCD_copy
Então PARA...
menbed/displays/include/menbedDisplayHD44780.h@0:92357d1220f3, 2017-05-19 (annotated)
- Committer:
- ViniR
- Date:
- Fri May 19 13:07:52 2017 +0000
- Revision:
- 0:92357d1220f3
Ent?o PARA...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ViniR | 0:92357d1220f3 | 1 | /* This code based on mbed TextLCD Library, for a 4-bit LCD based on HD44780, |
ViniR | 0:92357d1220f3 | 2 | * Copyright (c) 2007-2010, sford, http://mbed.org |
ViniR | 0:92357d1220f3 | 3 | * |
ViniR | 0:92357d1220f3 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
ViniR | 0:92357d1220f3 | 5 | * of this software and associated documentation files (the "Software"), to deal |
ViniR | 0:92357d1220f3 | 6 | * in the Software without restriction, including without limitation the rights |
ViniR | 0:92357d1220f3 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
ViniR | 0:92357d1220f3 | 8 | * copies of the Software, and to permit persons to whom the Software is |
ViniR | 0:92357d1220f3 | 9 | * furnished to do so, subject to the following conditions: |
ViniR | 0:92357d1220f3 | 10 | * |
ViniR | 0:92357d1220f3 | 11 | * The above copyright notice and this permission notice shall be included in |
ViniR | 0:92357d1220f3 | 12 | * all copies or substantial portions of the Software. |
ViniR | 0:92357d1220f3 | 13 | * |
ViniR | 0:92357d1220f3 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
ViniR | 0:92357d1220f3 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
ViniR | 0:92357d1220f3 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
ViniR | 0:92357d1220f3 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
ViniR | 0:92357d1220f3 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ViniR | 0:92357d1220f3 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
ViniR | 0:92357d1220f3 | 20 | * THE SOFTWARE. |
ViniR | 0:92357d1220f3 | 21 | */ |
ViniR | 0:92357d1220f3 | 22 | |
ViniR | 0:92357d1220f3 | 23 | #ifndef _MENBEDDISPLAYHD44780_H_ |
ViniR | 0:92357d1220f3 | 24 | #define _MENBEDDISPLAYHD44780_H_ |
ViniR | 0:92357d1220f3 | 25 | |
ViniR | 0:92357d1220f3 | 26 | #include "mbed.h" |
ViniR | 0:92357d1220f3 | 27 | #include "menbedDisplay.h" |
ViniR | 0:92357d1220f3 | 28 | |
ViniR | 0:92357d1220f3 | 29 | class MenbedDisplayHD44780 : public MenbedDisplay { |
ViniR | 0:92357d1220f3 | 30 | public: |
ViniR | 0:92357d1220f3 | 31 | |
ViniR | 0:92357d1220f3 | 32 | /** LCD panel format */ |
ViniR | 0:92357d1220f3 | 33 | enum LCDSize { |
ViniR | 0:92357d1220f3 | 34 | LCD16x2, /**< 16x2 LCD panel */ |
ViniR | 0:92357d1220f3 | 35 | LCD16x2B, /**< 16x2 LCD panel alternate addressing */ |
ViniR | 0:92357d1220f3 | 36 | LCD20x2, /**< 20x2 LCD panel */ |
ViniR | 0:92357d1220f3 | 37 | LCD20x4, /**< 20x4 LCD panel (default) */ |
ViniR | 0:92357d1220f3 | 38 | }; |
ViniR | 0:92357d1220f3 | 39 | |
ViniR | 0:92357d1220f3 | 40 | MenbedDisplayHD44780 (PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDSize size = LCD20x4); |
ViniR | 0:92357d1220f3 | 41 | |
ViniR | 0:92357d1220f3 | 42 | virtual bool writeLine (const char *line, uint8_t row); |
ViniR | 0:92357d1220f3 | 43 | virtual void showUpArrow (bool show); |
ViniR | 0:92357d1220f3 | 44 | virtual void showDownArrow (bool show); |
ViniR | 0:92357d1220f3 | 45 | virtual uint8_t getLines (void); |
ViniR | 0:92357d1220f3 | 46 | virtual uint8_t getLineLength (void); |
ViniR | 0:92357d1220f3 | 47 | |
ViniR | 0:92357d1220f3 | 48 | protected: |
ViniR | 0:92357d1220f3 | 49 | enum ArrowSelectorChar { |
ViniR | 0:92357d1220f3 | 50 | CharUP, |
ViniR | 0:92357d1220f3 | 51 | CharUP_SELECT, |
ViniR | 0:92357d1220f3 | 52 | CharSELECT, |
ViniR | 0:92357d1220f3 | 53 | CharDOWN_SELECT, |
ViniR | 0:92357d1220f3 | 54 | CharDOWN |
ViniR | 0:92357d1220f3 | 55 | }; |
ViniR | 0:92357d1220f3 | 56 | |
ViniR | 0:92357d1220f3 | 57 | DigitalOut rs, e; |
ViniR | 0:92357d1220f3 | 58 | BusOut d; |
ViniR | 0:92357d1220f3 | 59 | LCDSize size; |
ViniR | 0:92357d1220f3 | 60 | |
ViniR | 0:92357d1220f3 | 61 | bool upArrowVisible, downArrowVisible; |
ViniR | 0:92357d1220f3 | 62 | bool topLineSelected, bottomLineSelected; |
ViniR | 0:92357d1220f3 | 63 | int cursorCol, cursorRow; |
ViniR | 0:92357d1220f3 | 64 | |
ViniR | 0:92357d1220f3 | 65 | bool gotoPosition(int row, int column); |
ViniR | 0:92357d1220f3 | 66 | void clear(); |
ViniR | 0:92357d1220f3 | 67 | void cursorOn(); |
ViniR | 0:92357d1220f3 | 68 | void cursorOff(); |
ViniR | 0:92357d1220f3 | 69 | |
ViniR | 0:92357d1220f3 | 70 | int address(int column, int row); |
ViniR | 0:92357d1220f3 | 71 | void writeByte(int value); |
ViniR | 0:92357d1220f3 | 72 | void writeCommand(int command); |
ViniR | 0:92357d1220f3 | 73 | void writeData(int data); |
ViniR | 0:92357d1220f3 | 74 | void loadCustomChars(void); |
ViniR | 0:92357d1220f3 | 75 | int rows(); |
ViniR | 0:92357d1220f3 | 76 | int columns(); |
ViniR | 0:92357d1220f3 | 77 | }; |
ViniR | 0:92357d1220f3 | 78 | |
ViniR | 0:92357d1220f3 | 79 | #endif /* _MENBEDDISPLAYHD44780_H_ */ |