Radu Radoveneanu / TextLCD

Dependents:   StormXalike

Fork of TextLCD by Wim Huiskamp

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TextLCD_Config.h Source File

TextLCD_Config.h

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