Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LiquidCrystal_I2C.h
00001 // YWROBOT 00002 #ifndef LiquidCrystal_I2C_h 00003 #define LiquidCrystal_I2C_h 00004 #include "Print.h" 00005 #include "mbed.h" 00006 #include <inttypes.h> 00007 00008 // commands 00009 #define LCD_CLEARDISPLAY 0x01 00010 #define LCD_RETURNHOME 0x02 00011 #define LCD_ENTRYMODESET 0x04 00012 #define LCD_DISPLAYCONTROL 0x08 00013 #define LCD_CURSORSHIFT 0x10 00014 #define LCD_FUNCTIONSET 0x20 00015 #define LCD_SETCGRAMADDR 0x40 00016 #define LCD_SETDDRAMADDR 0x80 00017 00018 // flags for display entry mode 00019 #define LCD_ENTRYRIGHT 0x00 00020 #define LCD_ENTRYLEFT 0x02 00021 #define LCD_ENTRYSHIFTINCREMENT 0x01 00022 #define LCD_ENTRYSHIFTDECREMENT 0x00 00023 00024 // flags for display on/off control 00025 #define LCD_DISPLAYON 0x04 00026 #define LCD_DISPLAYOFF 0x00 00027 #define LCD_CURSORON 0x02 00028 #define LCD_CURSOROFF 0x00 00029 #define LCD_BLINKON 0x01 00030 #define LCD_BLINKOFF 0x00 00031 00032 // flags for display/cursor shift 00033 #define LCD_DISPLAYMOVE 0x08 00034 #define LCD_CURSORMOVE 0x00 00035 #define LCD_MOVERIGHT 0x04 00036 #define LCD_MOVELEFT 0x00 00037 00038 // flags for function set 00039 #define LCD_8BITMODE 0x10 00040 #define LCD_4BITMODE 0x00 00041 #define LCD_2LINE 0x08 00042 #define LCD_1LINE 0x00 00043 #define LCD_5x10DOTS 0x04 00044 #define LCD_5x8DOTS 0x00 00045 00046 // flags for backlight control 00047 #define LCD_BACKLIGHT 0x08 00048 #define LCD_NOBACKLIGHT 0x00 00049 00050 #define En 0B00000100 // Enable bit 00051 #define Rw 0B00000010 // Read/Write bit 00052 #define Rs 0B00000001 // Register select bit 00053 00054 class LiquidCrystal_I2C : public Print { 00055 public: 00056 LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t lcd_cols, uint8_t lcd_rows, 00057 PinName sda, PinName scl); 00058 void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); 00059 void clear(); 00060 void home(); 00061 void noDisplay(); 00062 void display(); 00063 void noBlink(); 00064 void blink(); 00065 void noCursor(); 00066 void cursor(); 00067 void scrollDisplayLeft(); 00068 void scrollDisplayRight(); 00069 void printLeft(); 00070 void printRight(); 00071 void leftToRight(); 00072 void rightToLeft(); 00073 void shiftIncrement(); 00074 void shiftDecrement(); 00075 void noBacklight(); 00076 void backlight(); 00077 void autoscroll(); 00078 void noAutoscroll(); 00079 void createChar(uint8_t, uint8_t[]); 00080 void setCursor(uint8_t, uint8_t); 00081 00082 virtual size_t write(uint8_t); 00083 void command(uint8_t); 00084 void init(); 00085 00086 ////compatibility API function aliases 00087 void blink_on(); // alias for blink() 00088 void blink_off(); // alias for noBlink() 00089 void cursor_on(); // alias for cursor() 00090 void cursor_off(); // alias for noCursor() 00091 void setBacklight(uint8_t new_val); // alias for backlight() and nobacklight() 00092 void load_custom_character(uint8_t char_num, 00093 uint8_t *rows); // alias for createChar() 00094 void printstr(const char[]); 00095 00096 ////Unsupported API functions (not implemented in this library) 00097 uint8_t status(); 00098 void setContrast(uint8_t new_val); 00099 uint8_t keypad(); 00100 void setDelay(int, int); 00101 void on(); 00102 void off(); 00103 uint8_t init_bargraph(uint8_t graphtype); 00104 void draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len, 00105 uint8_t pixel_col_end); 00106 void draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len, 00107 uint8_t pixel_col_end); 00108 00109 private: 00110 mbed::I2C *i2c; 00111 void init_priv(); 00112 void begin_priv(uint8_t charsize = LCD_5x8DOTS); 00113 void send(uint8_t, uint8_t); 00114 void write4bits(uint8_t); 00115 void expanderWrite(uint8_t); 00116 void pulseEnable(uint8_t); 00117 uint8_t _Addr; 00118 uint8_t _displayfunction; 00119 uint8_t _displaycontrol; 00120 uint8_t _displaymode; 00121 uint8_t _numlines; 00122 uint8_t _cols; 00123 uint8_t _rows; 00124 uint8_t _backlightval; 00125 }; 00126 00127 #endif
Generated on Wed Aug 17 2022 02:55:29 by
1.7.2