MHVLib
20111011
An efficiency oriented runtime library for AVR microcontrollers
|
00001 /* 00002 * Copyright (c) 2011, Make, Hack, Void Inc 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * * Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * * Neither the name of the Make, Hack, Void nor the 00013 * names of its contributors may be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00017 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00018 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 * DISCLAIMED. IN NO EVENT SHALL MAKE, HACK, VOID BE LIABLE FOR ANY 00020 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00021 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00022 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00023 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00024 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00025 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 */ 00027 #ifndef MHV_DISPLAY_HD44780_H_ 00028 #define MHV_DISPLAY_HD44780_H_ 00029 00030 #include <MHV_Display_Character.h> 00031 00032 enum mhv_hd44780_command { 00033 MHV_44780_CMD_CLEAR = 0x001, 00034 MHV_44780_CMD_RETURN_HOME = 0x002, 00035 MHV_44780_CMD_SET_ENTRY_MODE = 0x004, 00036 MHV_44780_CMD_SET_DISPLAY_MODE = 0x008, 00037 MHV_44780_CMD_SET_CURSOR_MODE = 0x010, 00038 MHV_44780_CMD_SET_FUNCTION = 0x020, 00039 MHV_44780_CMD_SET_CG_ADDR = 0x040, 00040 MHV_44780_CMD_SET_DD_ADDR = 0x080, 00041 MHV_44780_WRITE_CHAR = 0xff 00042 }; 00043 typedef enum mhv_hd44780_command MHV_HD44780_COMMAND; 00044 00045 class MHV_Display_HD44780 : public MHV_Display_Character { 00046 protected: 00047 uint16_t _ticks; 00048 uint16_t _animateTicks; 00049 bool _mustDelay; 00050 bool _byteMode; 00051 00052 void writeCommand(MHV_HD44780_COMMAND command, uint8_t data); 00053 void function(bool byteMode, bool multiLine, bool bigFont); 00054 void addressCGRAM(uint8_t address); 00055 void addressDDRAM(uint8_t address); 00056 virtual void writeByte(uint8_t byte, bool rs)=0; 00057 virtual uint8_t readByte(bool rs)=0; 00058 void _setCursor(uint8_t col, uint8_t row); 00059 void _setCursor(uint16_t col, uint16_t row); 00060 void _writeChar(char character); 00061 char _readChar(); 00062 virtual bool isBusy()=0; 00063 virtual void delay(MHV_HD44780_COMMAND command)=0; 00064 00065 public: 00066 MHV_Display_HD44780(uint8_t colCount, uint16_t rowCount, MHV_RingBuffer *txBuffers); 00067 void init(bool byteMode, bool multiLine, bool bigFont, bool cursorOn, bool cursorBlink, 00068 bool left2right, bool scroll); 00069 void clear(); 00070 void entryMode(bool left2Right, bool scroll); 00071 void control(bool displayOn, bool cursorOn, bool cursorBlink); 00072 }; 00073 00074 #endif /* MHV_DISPLAY_HD44780_H_ */