Matthew Waddilove / TextLCD_Serial

Dependencies:   TextDisplays

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TextLCD_Serial.h Source File

TextLCD_Serial.h

00001 // Copyright (c) 2010 mwaddilove
00002 // Released under the MIT License: http://mbed.org/license/mit
00003 
00004 #pragma once
00005 
00006 #include "TextDisplay.h"
00007 
00008 //! class that implements TextDisplay, for a 2x16 (2x20 etc. to come) serial LCD, controlled by the HD44780
00009 class TextLCD_Serial : public TextDisplay
00010 {
00011 public:
00012     //! Constructor
00013     TextLCD_Serial(PinName tx, PinName rx, char const * name = NULL);
00014     
00015     virtual void character(int column, int row, int c);
00016     
00017     virtual int rows() 
00018     {
00019         return 2;
00020     }
00021     virtual int columns()
00022     {
00023         return 16;
00024     }
00025  
00026     /** Clear the screen and locate to 0,0 */
00027     virtual void cls();
00028 
00029     
00030 protected:
00031     //! Set the LCD's cursor position
00032     void setLCDCursor(int const column, int const row);
00033 
00034     //! write a byte to _lcd
00035     void writeByte(int const value);
00036     //!Send a command
00037     void writeCommand(int const command);
00038     //! write a regular char.
00039     void writeData(int const data);
00040 
00041     //! Enum with command codes.
00042     struct Codes
00043     {
00044         enum Enum
00045         {
00046             BackLight   = 0x7C,
00047             Command     = 0xFE,
00048             Clear       = 0x01,
00049             DisplayOn   = 0x0C,
00050             DisplayOff  = 0x08,
00051             UnderlineCursorOn  = 0x0E,
00052             UnderlineCursorOff = 0x0C,
00053             BlinkingCursorOn   = 0x0D,
00054             BlinkingCursorOff  = 0x0C,
00055             CursorLeft  = 0x10,
00056             CursorRight = 0x14,
00057             ScrollLeft  = 0x18,
00058             ScrollRight = 0x1C,
00059             
00060             Position    = 0x80
00061         };
00062     };
00063 
00064     Serial _lcd;
00065 };