asdasdasd

Dependencies:   mbed

Fork of FINAL_PROJECT_4180 by Gedeon Nyengele

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cryst_lcd.h Source File

cryst_lcd.h

00001 /**
00002  * Driver for LCD devices based on the HD44780 controller
00003  */
00004 
00005 /* Description
00006 
00007 LCD SIZES SUPPORTED:
00008 1-line displays: 8x1, 16x1, 20x1, 24x1, 32x1, 40x1
00009 2-line displays: 16x2, 20x2, 24x2, 32x2, 40x2
00010 4-line displays: 16x4, 20x4, 40x4
00011 
00012 SUPPORTED PLATFORM: mbed
00013 
00014 DISCLAIMER: The author does not warrant the functions contained in the
00015             program will meet your requirements or that the operation 
00016             of the program will be uninterrupted or error-free.
00017             In no event will the author (Gedeon Nyengele) be liable
00018             for any damages, including any lost profit, lost savings, 
00019             lost patience or other incidental or consequential damage.
00020 */
00021 
00022 #ifndef CRYST_LCD_H
00023 #define CRYST_LCD_H
00024 
00025 #include "mbed.h"
00026 
00027 class Cryst_LCD : public Stream
00028 {
00029 public:
00030     // LCD Size
00031     enum LCDSize {
00032         LCD8x1, LCD16x1, LCD20x1, LCD24x1, LCD32x1, LCD40x1,  // 1-line displays
00033         LCD16x2, LCD20x2, LCD24x2, LCD32x2, LCD40x2,          // 2-line displays
00034         LCD16x4, LCD20x4, LCD40x4                             // 4-line displays
00035     };
00036 
00037     Cryst_LCD(PinName rs, PinName en, PinName db4, PinName db5,
00038         PinName db6, PinName db7, LCDSize size = LCD16x2);
00039     void cls();                         // Clear entire LCD screen
00040     void locate(int row, int col);        // Move cursor to speficic location
00041     void display_off();                   // Turn display off (data conserved)
00042     void display_on();                    // Turn display on
00043     void cursor_on();                     // Show cursor
00044     void cursor_off();                    // Hide cursor
00045     void cursor_blink();                  // Make cursor blink
00046     void cursor_no_blink();               // Make cursor no to blink
00047     void clear_line();                    // Clear content on current line and put cursor at the
00048                                           // beginning of the line
00049     int cols() { return getMaxCols(); }   // Get max number or columns for the LCD module used
00050     int rows() { return getMaxRows(); }   // Get max number or rows for the LCD module used
00051     int getCursorRow() { return _row; }   // Get row number where cursor is currently located
00052     int getCursorCol() { return _col; }   // Get column number where cursor is currently located
00053 
00054 protected:
00055     virtual int _putc(int ch);
00056     virtual int _getc();    
00057 
00058 private:
00059     void reset();
00060     void init();
00061     int getAddress(int row, int col);
00062     void writeData(int ch, bool use_default_timing = true);
00063     void writeCommand(int cmd, bool use_default_timing = true);
00064     void writeNibble(int nib);    
00065     void getMaxDimensions(int* rowCount, int* colCount);
00066     int getMaxRows();
00067     int getMaxCols();
00068 
00069 private:
00070     DigitalOut _rs;
00071     DigitalOut _en;
00072     BusOut _data;
00073     int _row;
00074     int _col;
00075     LCDSize _size;
00076     int _displayStatus;
00077 };
00078 
00079 
00080 
00081 #endif // CRYST_LCD_H