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.
Dependents: Timer_TestOverflow
Fork of TextLCD by
TextLCD_Config.h
00001 /* mbed TextLCD Library, for LCDs based on HD44780 controllers 00002 * Copyright (c) 2014, WH 00003 * 2014, v01: WH, Extracted from TextLCD.h as of v14 00004 * 2014, v02: WH, Added AC780 support, added I2C expander modules, fixed setBacklight() for inverted logic modules. Fixed bug in LCD_SPI_N define 00005 * 2014, v03: WH, Added LCD_SPI_N_3_8 define for ST7070 00006 * 2015, v04: WH, Added support for alternative fonttables (eg PCF21XX) 00007 * 2015, v05: WH, Clean up low-level _writeCommand() and _writeData(), Added support for alt fonttables (eg PCF21XX), Added ST7066_ACM for ACM1602 module, fixed contrast for ST7032 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a copy 00010 * of this software and associated documentation files (the "Software"), to deal 00011 * in the Software without restriction, including without limitation the rights 00012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 * copies of the Software, and to permit persons to whom the Software is 00014 * furnished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included in 00017 * all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 * THE SOFTWARE. 00026 */ 00027 #ifndef MBED_TEXTLCDCONFIG_H 00028 #define MBED_TEXTLCDCONFIG_H 00029 00030 //Select hardware interface options to reduce memory footprint (multiple options allowed) 00031 #define LCD_I2C 1 /* I2C Expander PCF8574/MCP23008 */ 00032 #define LCD_SPI 1 /* SPI Expander SN74595 */ 00033 #define LCD_I2C_N 1 /* Native I2C bus */ 00034 #define LCD_SPI_N 1 /* Native SPI bus */ 00035 #define LCD_SPI_N_3_8 1 /* Native SPI bus */ 00036 #define LCD_SPI_N_3_9 1 /* Native SPI bus */ 00037 #define LCD_SPI_N_3_10 1 /* Native SPI bus */ 00038 #define LCD_SPI_N_3_16 1 /* Native SPI bus */ 00039 #define LCD_SPI_N_3_24 1 /* Native SPI bus */ 00040 00041 //Select options to reduce memory footprint (multiple options allowed) 00042 #define LCD_UDC 1 /* Enable predefined UDC example*/ 00043 #define LCD_PRINTF 1 /* Enable Stream implementation */ 00044 00045 //Select option to activate default fonttable or alternatively use conversion for specific controller versions (eg PCF2119C) 00046 #define LCD_DEFAULT_FONT 1 00047 00048 //Pin Defines for I2C PCF8574/PCF8574A or MCP23008 and SPI 74595 bus expander interfaces 00049 //Different commercially available LCD portexpanders use different wiring conventions. 00050 //LCD and serial portexpanders should be wired according to the tables below. 00051 // 00052 //Select Serial Port Expander Hardware module (one option only) 00053 #define DEFAULT 1 00054 #define ADAFRUIT 0 00055 #define DFROBOT 0 00056 #define YWROBOT 0 00057 #define GYLCD 0 00058 #define SYDZ 0 00059 00060 #if (DEFAULT==1) 00061 //Definitions for default (WH) mapping between serial port expander pins and LCD controller 00062 //This hardware supports the I2C bus expander (PCF8574/PCF8574A or MCP23008) and SPI bus expander (74595) interfaces 00063 //See https://mbed.org/cookbook/Text-LCD-Enhanced 00064 // 00065 //Note: LCD RW pin must be connected to GND 00066 // E2 is used for LCD40x4 (second controller) 00067 // BL may be used to control backlight 00068 #define D_LCD_PIN_D4 0 00069 #define D_LCD_PIN_D5 1 00070 #define D_LCD_PIN_D6 2 00071 #define D_LCD_PIN_D7 3 00072 #define D_LCD_PIN_RS 4 00073 #define D_LCD_PIN_E 5 00074 #define D_LCD_PIN_E2 6 00075 #define D_LCD_PIN_BL 7 00076 00077 #define D_LCD_PIN_RW D_LCD_PIN_E2 00078 00079 //Select I2C Portexpander type (one option only) 00080 #define PCF8574 1 00081 #define MCP23008 0 00082 00083 //Inverted Backlight control 00084 #define BACKLIGHT_INV 0 00085 #endif 00086 00087 #if (ADAFRUIT==1) 00088 //Definitions for Adafruit i2cspilcdbackpack mapping between serial port expander pins and LCD controller 00089 //This hardware supports both an I2C expander (MCP23008) and an SPI expander (74595) selectable by a jumper. 00090 //Slaveaddress may be set by solderbridges (default 0x40). SDA/SCL has pullup Resistors onboard. 00091 //See http://www.ladyada.net/products/i2cspilcdbackpack 00092 // 00093 //Note: LCD RW pin must be kept LOW 00094 // E2 is not available on this hardware and so it does not support LCD40x4 (second controller) 00095 // BL is used to control backlight 00096 #define D_LCD_PIN_0 0 00097 #define D_LCD_PIN_RS 1 00098 #define D_LCD_PIN_E 2 00099 #define D_LCD_PIN_D4 3 00100 #define D_LCD_PIN_D5 4 00101 #define D_LCD_PIN_D6 5 00102 #define D_LCD_PIN_D7 6 00103 #define D_LCD_PIN_BL 7 00104 00105 #define D_LCD_PIN_E2 D_LCD_PIN_0 00106 00107 //Force I2C portexpander type 00108 #define PCF8574 0 00109 #define MCP23008 1 00110 00111 //Inverted Backlight control 00112 #define BACKLIGHT_INV 0 00113 #endif 00114 00115 #if (DFROBOT==1) 00116 //Definitions for DFROBOT LCD2004 Module mapping between serial port expander pins and LCD controller 00117 //This hardware uses PCF8574 and is different from earlier/different Arduino I2C LCD displays 00118 //Slaveaddress hardwired to 0x4E. SDA/SCL has pullup Resistors onboard. 00119 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C 00120 // 00121 //Definitions for DFROBOT V1.1 00122 //This hardware uses PCF8574. Slaveaddress may be set by jumpers (default 0x40). 00123 //SDA/SCL has pullup Resistors onboard and features a voltage level converter 3V3 <-> 5V. 00124 //See http://www.dfrobot.com/index.php?route=product/product&product_id=135 00125 // 00126 // 00127 //Note: LCD RW pin must be kept LOW 00128 // E2 is not available on default Arduino hardware and so it does not support LCD40x4 (second controller) 00129 // BL is used to control backlight 00130 #define D_LCD_PIN_RS 0 00131 #define D_LCD_PIN_RW 1 00132 #define D_LCD_PIN_E 2 00133 #define D_LCD_PIN_BL 3 00134 #define D_LCD_PIN_D4 4 00135 #define D_LCD_PIN_D5 5 00136 #define D_LCD_PIN_D6 6 00137 #define D_LCD_PIN_D7 7 00138 00139 #define D_LCD_PIN_E2 D_LCD_PIN_RW 00140 00141 //Force I2C portexpander type 00142 #define PCF8574 1 00143 #define MCP23008 0 00144 00145 //Inverted Backlight control 00146 #define BACKLIGHT_INV 0 00147 #endif 00148 00149 #if (YWROBOT==1) 00150 //Definitions for YWROBOT LCM1602 V1 Module mapping between serial port expander pins and LCD controller. 00151 //Very similar to DFROBOT. This hardware uses PCF8574. 00152 //Slaveaddress may be set by solderbridges (default 0x4E). SDA/SCL has no pullup Resistors onboard. 00153 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C 00154 // 00155 //Note: LCD RW pin must be kept LOW 00156 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller) 00157 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight() 00158 #define D_LCD_PIN_RS 0 00159 #define D_LCD_PIN_RW 1 00160 #define D_LCD_PIN_E 2 00161 #define D_LCD_PIN_BL 3 00162 #define D_LCD_PIN_D4 4 00163 #define D_LCD_PIN_D5 5 00164 #define D_LCD_PIN_D6 6 00165 #define D_LCD_PIN_D7 7 00166 00167 #define D_LCD_PIN_E2 D_LCD_PIN_RW 00168 00169 //Force I2C portexpander type 00170 #define PCF8574 1 00171 #define MCP23008 0 00172 00173 //Inverted Backlight control 00174 #define BACKLIGHT_INV 0 00175 #endif 00176 00177 #if (GYLCD==1) 00178 //Definitions for Arduino-IIC-LCD GY-LCD-V1 Module mapping between serial port expander pins and LCD controller. 00179 //Very similar to DFROBOT. This hardware uses PCF8574. 00180 //Slaveaddress may be set by solderbridges (default 0x4E). SDA/SCL has pullup Resistors onboard. 00181 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C 00182 // 00183 //Note: LCD RW pin must be kept LOW 00184 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller) 00185 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight() 00186 #define D_LCD_PIN_D4 0 00187 #define D_LCD_PIN_D5 1 00188 #define D_LCD_PIN_D6 2 00189 #define D_LCD_PIN_D7 3 00190 #define D_LCD_PIN_EN 4 00191 #define D_LCD_PIN_RW 5 00192 #define D_LCD_PIN_RS 6 00193 #define D_LCD_PIN_BL 7 00194 00195 #define D_LCD_PIN_E2 D_LCD_PIN_RW 00196 00197 //Force I2C portexpander type 00198 #define PCF8574 1 00199 #define MCP23008 0 00200 00201 //Force Inverted Backlight control 00202 #define BACKLIGHT_INV 1 00203 #endif 00204 00205 #if (SYDZ==1) 00206 //Definitions for SYDZ Module mapping between serial port expander pins and LCD controller. 00207 //Very similar to DFROBOT. This hardware uses PCF8574A and uses inverted Backlight control 00208 //Slaveaddress may be set by switches (default 0x40). SDA/SCL has pullup Resistors onboard. 00209 //See ebay 00210 // 00211 //Note: LCD RW pin must be kept LOW 00212 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller) 00213 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight() 00214 #define D_LCD_PIN_RS 0 00215 #define D_LCD_PIN_RW 1 00216 #define D_LCD_PIN_E 2 00217 #define D_LCD_PIN_BL 3 00218 #define D_LCD_PIN_D4 4 00219 #define D_LCD_PIN_D5 5 00220 #define D_LCD_PIN_D6 6 00221 #define D_LCD_PIN_D7 7 00222 00223 #define D_LCD_PIN_E2 D_LCD_PIN_RW 00224 00225 //Force I2C portexpander type 00226 #define PCF8574 1 00227 #define MCP23008 0 00228 00229 //Force Inverted Backlight control 00230 #define BACKLIGHT_INV 1 00231 #endif 00232 00233 //Bitpattern Defines for I2C PCF8574/PCF8574A, MCP23008 and SPI 74595 Bus expanders 00234 //Don't change! 00235 // 00236 #define D_LCD_D4 (1<<D_LCD_PIN_D4) 00237 #define D_LCD_D5 (1<<D_LCD_PIN_D5) 00238 #define D_LCD_D6 (1<<D_LCD_PIN_D6) 00239 #define D_LCD_D7 (1<<D_LCD_PIN_D7) 00240 #define D_LCD_RS (1<<D_LCD_PIN_RS) 00241 #define D_LCD_E (1<<D_LCD_PIN_E) 00242 #define D_LCD_E2 (1<<D_LCD_PIN_E2) 00243 #define D_LCD_BL (1<<D_LCD_PIN_BL) 00244 //#define D_LCD_RW (1<<D_LCD_PIN_RW) 00245 00246 #define D_LCD_BUS_MSK (D_LCD_D4 | D_LCD_D5 | D_LCD_D6 | D_LCD_D7) 00247 #define D_LCD_BUS_DEF 0x00 00248 00249 /* PCF8574/PCF8574A I2C portexpander slave address */ 00250 #define PCF8574_SA0 0x40 00251 #define PCF8574_SA1 0x42 00252 #define PCF8574_SA2 0x44 00253 #define PCF8574_SA3 0x46 00254 #define PCF8574_SA4 0x48 00255 #define PCF8574_SA5 0x4A 00256 #define PCF8574_SA6 0x4C 00257 #define PCF8574_SA7 0x4E 00258 00259 #define PCF8574A_SA0 0x70 00260 #define PCF8574A_SA1 0x72 00261 #define PCF8574A_SA2 0x74 00262 #define PCF8574A_SA3 0x76 00263 #define PCF8574A_SA4 0x78 00264 #define PCF8574A_SA5 0x7A 00265 #define PCF8574A_SA6 0x7C 00266 #define PCF8574A_SA7 0x7E 00267 00268 /* MCP23008 I2C portexpander slave address */ 00269 #define MCP23008_SA0 0x40 00270 #define MCP23008_SA1 0x42 00271 #define MCP23008_SA2 0x44 00272 #define MCP23008_SA3 0x46 00273 #define MCP23008_SA4 0x48 00274 #define MCP23008_SA5 0x4A 00275 #define MCP23008_SA6 0x4C 00276 #define MCP23008_SA7 0x4E 00277 00278 /* MCP23008 I2C portexpander internal registers */ 00279 #define IODIR 0x00 00280 #define IPOL 0x01 00281 #define GPINTEN 0x02 00282 #define DEFVAL 0x03 00283 #define INTCON 0x04 00284 #define IOCON 0x05 00285 #define GPPU 0x06 00286 #define INTF 0x07 00287 #define INTCAP 0x08 00288 #define GPIO 0x09 00289 #define OLAT 0x0A 00290 00291 /* ST7032i I2C slave address */ 00292 #define ST7032_SA 0x7C 00293 00294 /* ST7036i I2C slave address */ 00295 #define ST7036_SA0 0x78 00296 #define ST7036_SA1 0x7A 00297 #define ST7036_SA2 0x7C 00298 #define ST7036_SA3 0x7E 00299 00300 /* ST7066_ACM I2C slave address, Added for ACM1602 module */ 00301 #define ST7066_SA0 0xA0 00302 00303 /* PCF21XX I2C slave address */ 00304 #define PCF21XX_SA0 0x74 00305 #define PCF21XX_SA1 0x76 00306 00307 /* AIP31068 I2C slave address */ 00308 #define AIP31068_SA 0x7C 00309 00310 /* SSD1803 I2C slave address */ 00311 #define SSD1803_SA0 0x78 00312 #define SSD1803_SA1 0x7A 00313 00314 /* US2066/SSD1311 I2C slave address */ 00315 #define US2066_SA0 0x78 00316 #define US2066_SA1 0x7A 00317 00318 /* AC780 I2C slave address */ 00319 #define AC780_SA0 0x78 00320 #define AC780_SA1 0x7A 00321 #define AC780_SA2 0x7C 00322 #define AC780_SA3 0x7E 00323 00324 //Some native I2C controllers dont support ACK. Set define to '0' to allow code to proceed even without ACK 00325 //#define LCD_I2C_ACK 0 00326 #define LCD_I2C_ACK 1 00327 00328 00329 // Contrast setting, 6 significant bits (only supported for controllers with extended features) 00330 // Voltage Multiplier setting, 2 or 3 significant bits (only supported for controllers with extended features) 00331 #define LCD_DEF_CONTRAST 0x20 00332 00333 //ST7032 EastRising ERC1602FS-4 display 00334 //Contrast setting 6 significant bits 00335 //Voltage Multiplier setting 3 significant bits 00336 #define LCD_ST7032_CONTRAST 0x28 00337 #define LCD_ST7032_RAB 0x04 00338 00339 //ST7036 EA DOGM1603 display 00340 //Contrast setting 6 significant bits 00341 //Voltage Multiplier setting 3 significant bits 00342 #define LCD_ST7036_CONTRAST 0x28 00343 #define LCD_ST7036_RAB 0x04 00344 00345 //SSD1803 EA DOGM204 display 00346 //Contrast setting 6 significant bits 00347 //Voltage Multiplier setting 3 significant bits 00348 #define LCD_SSD1_CONTRAST 0x28 00349 #define LCD_SSD1_RAB 0x06 00350 00351 //US2066/SSD1311 EastRising ER-OLEDM2002-4 display 00352 //Contrast setting 8 significant bits, use 6 for compatibility 00353 #define LCD_US20_CONTRAST 0x3F 00354 //#define LCD_US20_CONTRAST 0x1F 00355 00356 //PCF2113, PCF2119 display 00357 //Contrast setting 6 significant bits 00358 //Voltage Multiplier setting 2 significant bits 00359 #define LCD_PCF2_CONTRAST 0x20 00360 #define LCD_PCF2_S12 0x02 00361 00362 //PT6314 VFD display 00363 //Contrast setting 2 significant bits, use 6 for compatibility 00364 #define LCD_PT63_CONTRAST 0x3F 00365 00366 00367 #endif //MBED_TEXTLCDCONFIG_H
Generated on Sat Jul 23 2022 00:39:56 by
1.7.2
