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 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 00069 00070 00071 00072 00073 00074 00075 #define D_LCD_PIN_D4 0 00076 #define D_LCD_PIN_D5 1 00077 #define D_LCD_PIN_D6 2 00078 #define D_LCD_PIN_D7 3 00079 #define D_LCD_PIN_RS 4 00080 #define D_LCD_PIN_E 5 00081 #define D_LCD_PIN_E2 6 00082 #define D_LCD_PIN_BL 7 00083 00084 #define D_LCD_PIN_RW D_LCD_PIN_E2 00085 00086 //Select I2C Portexpander type (one option only) 00087 #define PCF8574 1 00088 #define MCP23008 0 00089 00090 //Inverted Backlight control 00091 #define BACKLIGHT_INV 0 00092 #endif 00093 00094 #if (ADAFRUIT==1) 00095 //Definitions for Adafruit i2cspilcdbackpack mapping between serial port expander pins and LCD controller 00096 //This hardware supports both an I2C expander (MCP23008) and an SPI expander (74595) selectable by a jumper. 00097 //Slaveaddress may be set by solderbridges (default 0x40). SDA/SCL has pullup Resistors onboard. 00098 //See http://www.ladyada.net/products/i2cspilcdbackpack 00099 // 00100 //Note: LCD RW pin must be kept LOW 00101 // E2 is not available on this hardware and so it does not support LCD40x4 (second controller) 00102 // BL is used to control backlight 00103 #define D_LCD_PIN_0 0 00104 #define D_LCD_PIN_RS 1 00105 #define D_LCD_PIN_E 2 00106 #define D_LCD_PIN_D4 3 00107 #define D_LCD_PIN_D5 4 00108 #define D_LCD_PIN_D6 5 00109 #define D_LCD_PIN_D7 6 00110 #define D_LCD_PIN_BL 7 00111 00112 #define D_LCD_PIN_E2 D_LCD_PIN_0 00113 00114 //Force I2C portexpander type 00115 #define PCF8574 0 00116 #define MCP23008 1 00117 00118 //Inverted Backlight control 00119 #define BACKLIGHT_INV 0 00120 #endif 00121 00122 #if (DFROBOT==1) 00123 //Definitions for DFROBOT LCD2004 Module mapping between serial port expander pins and LCD controller 00124 //This hardware uses PCF8574 and is different from earlier/different Arduino I2C LCD displays 00125 //Slaveaddress hardwired to 0x4E. SDA/SCL has pullup Resistors onboard. 00126 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C 00127 // 00128 //Definitions for DFROBOT V1.1 00129 //This hardware uses PCF8574. Slaveaddress may be set by jumpers (default 0x40). 00130 //SDA/SCL has pullup Resistors onboard and features a voltage level converter 3V3 <-> 5V. 00131 //See http://www.dfrobot.com/index.php?route=product/product&product_id=135 00132 // 00133 // 00134 //Note: LCD RW pin must be kept LOW 00135 // E2 is not available on default Arduino hardware and so it does not support LCD40x4 (second controller) 00136 // BL is used to control backlight 00137 #define D_LCD_PIN_RS 0 00138 #define D_LCD_PIN_RW 1 00139 #define D_LCD_PIN_E 2 00140 #define D_LCD_PIN_BL 3 00141 #define D_LCD_PIN_D4 4 00142 #define D_LCD_PIN_D5 5 00143 #define D_LCD_PIN_D6 6 00144 #define D_LCD_PIN_D7 7 00145 00146 #define D_LCD_PIN_E2 D_LCD_PIN_RW 00147 00148 //Force I2C portexpander type 00149 #define PCF8574 1 00150 #define MCP23008 0 00151 00152 //Inverted Backlight control 00153 #define BACKLIGHT_INV 0 00154 #endif 00155 00156 #if (YWROBOT==1) 00157 //Definitions for YWROBOT LCM1602 V1 Module mapping between serial port expander pins and LCD controller. 00158 //Very similar to DFROBOT. This hardware uses PCF8574. 00159 //Slaveaddress may be set by solderbridges (default 0x4E). SDA/SCL has no pullup Resistors onboard. 00160 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C 00161 // 00162 //Note: LCD RW pin must be kept LOW 00163 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller) 00164 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight() 00165 #define D_LCD_PIN_RS 0 00166 #define D_LCD_PIN_RW 1 00167 #define D_LCD_PIN_E 2 00168 #define D_LCD_PIN_BL 3 00169 #define D_LCD_PIN_D4 4 00170 #define D_LCD_PIN_D5 5 00171 #define D_LCD_PIN_D6 6 00172 #define D_LCD_PIN_D7 7 00173 00174 #define D_LCD_PIN_E2 D_LCD_PIN_RW 00175 00176 //Force I2C portexpander type 00177 #define PCF8574 1 00178 #define MCP23008 0 00179 00180 //Inverted Backlight control 00181 #define BACKLIGHT_INV 0 00182 #endif 00183 00184 #if (GYLCD==1) 00185 //Definitions for Arduino-IIC-LCD GY-LCD-V1 Module mapping between serial port expander pins and LCD controller. 00186 //Very similar to DFROBOT. This hardware uses PCF8574. 00187 //Slaveaddress may be set by solderbridges (default 0x4E). SDA/SCL has pullup Resistors onboard. 00188 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C 00189 // 00190 //Note: LCD RW pin must be kept LOW 00191 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller) 00192 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight() 00193 #define D_LCD_PIN_D4 0 00194 #define D_LCD_PIN_D5 1 00195 #define D_LCD_PIN_D6 2 00196 #define D_LCD_PIN_D7 3 00197 #define D_LCD_PIN_EN 4 00198 #define D_LCD_PIN_RW 5 00199 #define D_LCD_PIN_RS 6 00200 #define D_LCD_PIN_BL 7 00201 00202 #define D_LCD_PIN_E2 D_LCD_PIN_RW 00203 00204 //Force I2C portexpander type 00205 #define PCF8574 1 00206 #define MCP23008 0 00207 00208 //Force Inverted Backlight control 00209 #define BACKLIGHT_INV 1 00210 #endif 00211 00212 #if (SYDZ==1) 00213 //Definitions for SYDZ Module mapping between serial port expander pins and LCD controller. 00214 //Very similar to DFROBOT. This hardware uses PCF8574A and uses inverted Backlight control 00215 //Slaveaddress may be set by switches (default 0x40). SDA/SCL has pullup Resistors onboard. 00216 //See ebay 00217 // 00218 //Note: LCD RW pin must be kept LOW 00219 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller) 00220 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight() 00221 #define D_LCD_PIN_RS 0 00222 #define D_LCD_PIN_RW 1 00223 #define D_LCD_PIN_E 2 00224 #define D_LCD_PIN_BL 3 00225 #define D_LCD_PIN_D4 4 00226 #define D_LCD_PIN_D5 5 00227 #define D_LCD_PIN_D6 6 00228 #define D_LCD_PIN_D7 7 00229 00230 #define D_LCD_PIN_E2 D_LCD_PIN_RW 00231 00232 //Force I2C portexpander type 00233 #define PCF8574 1 00234 #define MCP23008 0 00235 00236 //Force Inverted Backlight control 00237 #define BACKLIGHT_INV 1 00238 #endif 00239 00240 //Bitpattern Defines for I2C PCF8574/PCF8574A, MCP23008 and SPI 74595 Bus expanders 00241 //Don't change! 00242 // 00243 00244 /* 00245 / Achtung: geänderter Header für sunfounder 20 * 4 Display! 00246 00247 #define LCD_BUS_I2C_D4 (1 << 4) 00248 #define LCD_BUS_I2C_D5 (1 << 5) 00249 #define LCD_BUS_I2C_D6 (1 << 6) 00250 #define LCD_BUS_I2C_D7 (1 << 7) 00251 #define LCD_BUS_I2C_RS (1 << 0) 00252 #define LCD_BUS_I2C_E (1 << 2) 00253 #define LCD_BUS_I2C_E2 (1 << 1) 00254 #define LCD_BUS_I2C_BL (1 << 3) 00255 00256 #define LCD_BUS_I2C_RW (1 << 1) 00257 00258 */ 00259 00260 00261 00262 /* Original 00263 00264 #define D_LCD_D4 (1<<D_LCD_PIN_D4) 00265 #define D_LCD_D5 (1<<D_LCD_PIN_D5) 00266 #define D_LCD_D6 (1<<D_LCD_PIN_D6) 00267 #define D_LCD_D7 (1<<D_LCD_PIN_D7) 00268 #define D_LCD_RS (1<<D_LCD_PIN_RS) 00269 #define D_LCD_E (1<<D_LCD_PIN_E) 00270 #define D_LCD_E2 (1<<D_LCD_PIN_E2) 00271 #define D_LCD_BL (1<<D_LCD_PIN_BL) 00272 00273 */ 00274 // Kopie 00275 00276 #define D_LCD_D4 (1<< 4) 00277 #define D_LCD_D5 (1<< 5) 00278 #define D_LCD_D6 (1<< 6) 00279 #define D_LCD_D7 (1<< 7) 00280 #define D_LCD_RS (1<< 0) 00281 #define D_LCD_E (1<< 2) 00282 #define D_LCD_E2 (1<< 1) 00283 #define D_LCD_BL (1<< 3) 00284 00285 00286 #define D_LCD_RW (1<< 1) 00287 00288 #define D_LCD_BUS_MSK (D_LCD_D4 | D_LCD_D5 | D_LCD_D6 | D_LCD_D7) 00289 #define D_LCD_BUS_DEF 0x00 00290 00291 /* PCF8574/PCF8574A I2C portexpander slave address */ 00292 #define PCF8574_SA0 0x40 00293 #define PCF8574_SA1 0x42 00294 #define PCF8574_SA2 0x44 00295 #define PCF8574_SA3 0x46 00296 #define PCF8574_SA4 0x48 00297 #define PCF8574_SA5 0x4A 00298 #define PCF8574_SA6 0x4C 00299 #define PCF8574_SA7 0x4E 00300 00301 #define PCF8574A_SA0 0x70 00302 #define PCF8574A_SA1 0x72 00303 #define PCF8574A_SA2 0x74 00304 #define PCF8574A_SA3 0x76 00305 #define PCF8574A_SA4 0x78 00306 #define PCF8574A_SA5 0x7A 00307 #define PCF8574A_SA6 0x7C 00308 #define PCF8574A_SA7 0x7E 00309 00310 /* MCP23008 I2C portexpander slave address */ 00311 #define MCP23008_SA0 0x40 00312 #define MCP23008_SA1 0x42 00313 #define MCP23008_SA2 0x44 00314 #define MCP23008_SA3 0x46 00315 #define MCP23008_SA4 0x48 00316 #define MCP23008_SA5 0x4A 00317 #define MCP23008_SA6 0x4C 00318 #define MCP23008_SA7 0x4E 00319 00320 /* MCP23008 I2C portexpander internal registers */ 00321 #define IODIR 0x00 00322 #define IPOL 0x01 00323 #define GPINTEN 0x02 00324 #define DEFVAL 0x03 00325 #define INTCON 0x04 00326 #define IOCON 0x05 00327 #define GPPU 0x06 00328 #define INTF 0x07 00329 #define INTCAP 0x08 00330 #define GPIO 0x09 00331 #define OLAT 0x0A 00332 00333 /* ST7032i I2C slave address */ 00334 #define ST7032_SA 0x7C 00335 00336 /* ST7036i I2C slave address */ 00337 #define ST7036_SA0 0x78 00338 #define ST7036_SA1 0x7A 00339 #define ST7036_SA2 0x7C 00340 #define ST7036_SA3 0x7E 00341 00342 /* ST7066_ACM I2C slave address, Added for ACM1602 module */ 00343 #define ST7066_SA0 0xA0 00344 00345 /* PCF21XX I2C slave address */ 00346 #define PCF21XX_SA0 0x74 00347 #define PCF21XX_SA1 0x76 00348 00349 /* AIP31068 I2C slave address */ 00350 #define AIP31068_SA 0x7C 00351 00352 /* SSD1803 I2C slave address */ 00353 #define SSD1803_SA0 0x78 00354 #define SSD1803_SA1 0x7A 00355 00356 /* US2066/SSD1311 I2C slave address */ 00357 #define US2066_SA0 0x78 00358 #define US2066_SA1 0x7A 00359 00360 /* AC780 I2C slave address */ 00361 #define AC780_SA0 0x78 00362 #define AC780_SA1 0x7A 00363 #define AC780_SA2 0x7C 00364 #define AC780_SA3 0x7E 00365 00366 //Some native I2C controllers dont support ACK. Set define to '0' to allow code to proceed even without ACK 00367 //#define LCD_I2C_ACK 0 00368 #define LCD_I2C_ACK 1 00369 00370 00371 // Contrast setting, 6 significant bits (only supported for controllers with extended features) 00372 // Voltage Multiplier setting, 2 or 3 significant bits (only supported for controllers with extended features) 00373 #define LCD_DEF_CONTRAST 0x20 00374 00375 //ST7032 EastRising ERC1602FS-4 display 00376 //Contrast setting 6 significant bits 00377 //Voltage Multiplier setting 3 significant bits 00378 #define LCD_ST7032_CONTRAST 0x28 00379 #define LCD_ST7032_RAB 0x04 00380 00381 //ST7036 EA DOGM1603 display 00382 //Contrast setting 6 significant bits 00383 //Voltage Multiplier setting 3 significant bits 00384 #define LCD_ST7036_CONTRAST 0x28 00385 #define LCD_ST7036_RAB 0x04 00386 00387 //SSD1803 EA DOGM204 display 00388 //Contrast setting 6 significant bits 00389 //Voltage Multiplier setting 3 significant bits 00390 #define LCD_SSD1_CONTRAST 0x28 00391 #define LCD_SSD1_RAB 0x06 00392 00393 //US2066/SSD1311 EastRising ER-OLEDM2002-4 display 00394 //Contrast setting 8 significant bits, use 6 for compatibility 00395 #define LCD_US20_CONTRAST 0x3F 00396 //#define LCD_US20_CONTRAST 0x1F 00397 00398 //PCF2113, PCF2119 display 00399 //Contrast setting 6 significant bits 00400 //Voltage Multiplier setting 2 significant bits 00401 #define LCD_PCF2_CONTRAST 0x20 00402 #define LCD_PCF2_S12 0x02 00403 00404 //PT6314 VFD display 00405 //Contrast setting 2 significant bits, use 6 for compatibility 00406 #define LCD_PT63_CONTRAST 0x3F 00407 00408 00409 #endif //MBED_TEXTLCDCONFIG_H
Generated on Tue Jul 12 2022 13:32:09 by
1.7.2
