Vinícius Alves / Mbed 2 deprecated MenuLCD_copy

Dependencies:   MenuLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers menbedDisplayHD44780.h Source File

menbedDisplayHD44780.h

00001 /* This code based on mbed TextLCD Library, for a 4-bit LCD based on HD44780,
00002  * Copyright (c) 2007-2010, sford, http://mbed.org
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to deal
00006  * in the Software without restriction, including without limitation the rights
00007  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008  * copies of the Software, and to permit persons to whom the Software is 
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00017  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00019  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00020  * THE SOFTWARE.
00021  */
00022 
00023 #ifndef _MENBEDDISPLAYHD44780_H_
00024 #define _MENBEDDISPLAYHD44780_H_
00025 
00026 #include "mbed.h"
00027 #include "menbedDisplay.h"
00028 
00029 class MenbedDisplayHD44780 : public MenbedDisplay {
00030 public:
00031 
00032     /** LCD panel format */
00033     enum LCDSize {
00034         LCD16x2,   /**< 16x2 LCD panel */
00035         LCD16x2B,  /**< 16x2 LCD panel alternate addressing */
00036         LCD20x2,   /**< 20x2 LCD panel */
00037         LCD20x4,   /**< 20x4 LCD panel (default) */
00038     };
00039 
00040     MenbedDisplayHD44780 (PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDSize size = LCD20x4);
00041     
00042     virtual bool writeLine (const char *line, uint8_t row);
00043     virtual void showUpArrow (bool show);
00044     virtual void showDownArrow (bool show);
00045     virtual uint8_t getLines (void);
00046     virtual uint8_t getLineLength (void);
00047     
00048 protected:
00049     enum ArrowSelectorChar {
00050         CharUP,
00051         CharUP_SELECT,
00052         CharSELECT,
00053         CharDOWN_SELECT,
00054         CharDOWN
00055     };
00056 
00057     DigitalOut rs, e;
00058     BusOut d;
00059     LCDSize size;
00060     
00061     bool upArrowVisible, downArrowVisible;
00062     bool topLineSelected, bottomLineSelected;
00063     int cursorCol, cursorRow;
00064 
00065     bool gotoPosition(int row, int column);
00066     void clear();
00067     void cursorOn();
00068     void cursorOff();
00069 
00070     int address(int column, int row);
00071     void writeByte(int value);
00072     void writeCommand(int command);
00073     void writeData(int data);
00074     void loadCustomChars(void);
00075     int rows();
00076     int columns();
00077 };
00078 
00079 #endif /* _MENBEDDISPLAYHD44780_H_ */