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.
Fork of AdaFruit_RGBLCDShield by
Adafruit_RGBLCDShield.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_RGBLCDShield_h 00017 #define Adafruit_RGBLCDShield_h 00018 00019 #include <inttypes.h> 00020 #include <MCP23017.h> 00021 00022 // commands 00023 #define LCD_CLEARDISPLAY 0x01 00024 #define LCD_RETURNHOME 0x02 00025 #define LCD_ENTRYMODESET 0x04 00026 #define LCD_DISPLAYCONTROL 0x08 00027 #define LCD_CURSORSHIFT 0x10 00028 #define LCD_FUNCTIONSET 0x20 00029 #define LCD_SETCGRAMADDR 0x40 00030 #define LCD_SETDDRAMADDR 0x80 00031 00032 // flags for display entry mode 00033 #define LCD_ENTRYRIGHT 0x00 00034 #define LCD_ENTRYLEFT 0x02 00035 #define LCD_ENTRYSHIFTINCREMENT 0x01 00036 #define LCD_ENTRYSHIFTDECREMENT 0x00 00037 00038 // flags for display on/off control 00039 #define LCD_DISPLAYON 0x04 00040 #define LCD_DISPLAYOFF 0x00 00041 #define LCD_CURSORON 0x02 00042 #define LCD_CURSOROFF 0x00 00043 #define LCD_BLINKON 0x01 00044 #define LCD_BLINKOFF 0x00 00045 00046 // flags for display/cursor shift 00047 #define LCD_DISPLAYMOVE 0x08 00048 #define LCD_CURSORMOVE 0x00 00049 #define LCD_MOVERIGHT 0x04 00050 #define LCD_MOVELEFT 0x00 00051 00052 // flags for function set 00053 #define LCD_8BITMODE 0x10 00054 #define LCD_4BITMODE 0x00 00055 #define LCD_2LINE 0x08 00056 #define LCD_1LINE 0x00 00057 #define LCD_5x10DOTS 0x04 00058 #define LCD_5x8DOTS 0x00 00059 00060 #define BUTTON_UP 0x08 00061 #define BUTTON_DOWN 0x04 00062 #define BUTTON_LEFT 0x10 00063 #define BUTTON_RIGHT 0x02 00064 #define BUTTON_SELECT 0x01 00065 00066 class Adafruit_RGBLCDShield 00067 : public Serial // MBED was Print 00068 { 00069 public: 00070 // Updated constructor 00071 Adafruit_RGBLCDShield(MCP23017 & inMCP); 00072 Adafruit_RGBLCDShield 00073 ( 00074 MCP23017 & inMCP, 00075 uint8_t inRs, 00076 uint8_t inRw, 00077 uint8_t inEn, 00078 uint8_t inD4, 00079 uint8_t inD5, 00080 uint8_t inD6, 00081 uint8_t inD7 00082 ); 00083 00084 00085 void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, 00086 uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, 00087 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); 00088 00089 void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); 00090 uint8_t lines(); 00091 00092 void clear(); 00093 void home(); 00094 00095 void noDisplay(); 00096 void display(); 00097 void noBlink(); 00098 void blink(); 00099 void noCursor(); 00100 void cursor(); 00101 void scrollDisplayLeft(); 00102 void scrollDisplayRight(); 00103 void leftToRight(); 00104 void rightToLeft(); 00105 void autoscroll(); 00106 void noAutoscroll(); 00107 00108 // only if using backpack 00109 void setBacklight(uint8_t status); 00110 00111 void createChar(uint8_t, uint8_t[]); 00112 void setCursor(uint8_t, uint8_t); 00113 #if ARDUINO >= 100 00114 //virtual size_t write(uint8_t); 00115 #else 00116 //virtual void write(uint8_t); 00117 virtual int _putc(int c); 00118 #endif 00119 void command(uint8_t); 00120 uint8_t readButtons(); 00121 00122 private: 00123 void send(uint8_t, uint8_t); 00124 void write4bits(uint8_t); 00125 void write8bits(uint8_t); 00126 void pulseEnable(); 00127 void _digitalWrite(uint8_t, uint8_t); 00128 void _pinMode(uint8_t, uint8_t); 00129 00130 uint8_t _rs_pin; // LOW: command. HIGH: character. 00131 uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. 00132 uint8_t _enable_pin; // activated by a HIGH pulse. 00133 uint8_t _data_pins[8]; 00134 uint8_t _button_pins[5]; 00135 uint8_t _displayfunction; 00136 uint8_t _displaycontrol; 00137 uint8_t _displaymode; 00138 00139 uint8_t _initialized; 00140 00141 uint8_t _numlines,_currline; 00142 00143 uint8_t _i2cAddr; 00144 MCP23017 _i2c; 00145 }; 00146 00147 #endif
Generated on Wed Jul 13 2022 17:31:40 by
1.7.2
