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.
Adafruit_I2C_LCD.h
00001 /*************************************************** 00002 This is a library for the Adafruit RGB 16x2 LCD Shield 00003 Pick one up at the Adafruit shop! 00004 ---------> http://http://www.adafruit.com/products/714 00005 00006 The shield uses I2C to communicate, 2 pins are required to 00007 interface 00008 Adafruit invests time and resources providing this open source code, 00009 please support Adafruit and open-source hardware by purchasing 00010 products from Adafruit! 00011 00012 Written by Limor Fried/Ladyada for Adafruit Industries. 00013 BSD license, all text above must be included in any redistribution 00014 ****************************************************/ 00015 00016 #ifndef ADAFRUIT_I2C_LCD_H 00017 #define ADAFRUIT_I2C_LCD_H 00018 00019 #include "Adafruit_MCP23017.h" 00020 00021 // commands 00022 #define LCD_CLEARDISPLAY 0x01 00023 #define LCD_RETURNHOME 0x02 00024 #define LCD_ENTRYMODESET 0x04 00025 #define LCD_DISPLAYCONTROL 0x08 00026 #define LCD_CURSORSHIFT 0x10 00027 #define LCD_FUNCTIONSET 0x20 00028 #define LCD_SETCGRAMADDR 0x40 00029 #define LCD_SETDDRAMADDR 0x80 00030 00031 // flags for display entry mode 00032 #define LCD_ENTRYRIGHT 0x00 00033 #define LCD_ENTRYLEFT 0x02 00034 #define LCD_ENTRYSHIFTINCREMENT 0x01 00035 #define LCD_ENTRYSHIFTDECREMENT 0x00 00036 00037 // flags for display on/off control 00038 #define LCD_DISPLAYON 0x04 00039 #define LCD_DISPLAYOFF 0x00 00040 #define LCD_CURSORON 0x02 00041 #define LCD_CURSOROFF 0x00 00042 #define LCD_BLINKON 0x01 00043 #define LCD_BLINKOFF 0x00 00044 00045 // flags for display/cursor shift 00046 #define LCD_DISPLAYMOVE 0x08 00047 #define LCD_CURSORMOVE 0x00 00048 #define LCD_MOVERIGHT 0x04 00049 #define LCD_MOVELEFT 0x00 00050 00051 // flags for function set 00052 #define LCD_8BITMODE 0x10 00053 #define LCD_4BITMODE 0x00 00054 #define LCD_2LINE 0x08 00055 #define LCD_1LINE 0x00 00056 #define LCD_5x10DOTS 0x04 00057 #define LCD_5x8DOTS 0x00 00058 00059 #define BUTTON_UP 0x08 00060 #define BUTTON_DOWN 0x04 00061 #define BUTTON_LEFT 0x10 00062 #define BUTTON_RIGHT 0x02 00063 #define BUTTON_SELECT 0x01 00064 00065 #define HIGH true 00066 #define LOW false 00067 00068 #include "mbed.h" 00069 00070 class Adafruit_I2C_LCD 00071 { 00072 public: 00073 Adafruit_I2C_LCD(I2C *master, uint8_t cols, uint8_t lines, uint8_t dotsize = LCD_5x8DOTS); 00074 ~Adafruit_I2C_LCD(); 00075 00076 void clear(); 00077 void home(); 00078 00079 void noDisplay(); 00080 void display(); 00081 void noBlink(); 00082 void blink(); 00083 void noCursor(); 00084 void cursor(); 00085 void scrollDisplayLeft(); 00086 void scrollDisplayRight(); 00087 void leftToRight(); 00088 void rightToLeft(); 00089 void autoscroll(); 00090 void noAutoscroll(); 00091 00092 // only if using backpack 00093 void setBacklight(uint8_t status); 00094 00095 void createChar(uint8_t, uint8_t[]); 00096 void setCursor(uint8_t, uint8_t); 00097 void write(uint8_t); 00098 void print(char *, size_t); 00099 void command(uint8_t); 00100 uint8_t readButtons(); 00101 00102 private: 00103 void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); 00104 00105 void send(uint8_t, uint8_t); 00106 void write4bits(uint8_t); 00107 void write8bits(uint8_t); 00108 void pulseEnable(); 00109 void _digitalWrite(uint8_t, uint8_t); 00110 void _pinMode(uint8_t, uint8_t); 00111 00112 uint8_t _rs_pin; // LOW: command. HIGH: character. 00113 uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. 00114 uint8_t _enable_pin; // activated by a HIGH pulse. 00115 uint8_t _data_pins[8]; 00116 uint8_t _button_pins[5]; 00117 uint8_t _displayfunction; 00118 uint8_t _displaycontrol; 00119 uint8_t _displaymode; 00120 00121 uint8_t _initialized; 00122 00123 uint8_t _numlines,_currline; 00124 00125 uint8_t _i2cAddr; 00126 Adafruit_MCP23017 *_i2c; 00127 }; 00128 00129 #endif 00130
Generated on Mon Jul 18 2022 20:57:22 by
