Wim Huiskamp / TextLCD

Committer:
wim
Date:
Wed May 20 18:46:51 2015 +0000
Revision:
40:d3496c3ea301
Parent:
39:e9c2319de9c5
Child:
41:111ca62e8a59
Fixed an occasional init problem. Added PCF2119R support, added HD66712 support, added some more I2C portexpander types.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 37:ce348c002929 1 /* mbed TextLCD Library, for LCDs based on HD44780 controllers
wim 34:e5a0dcb43ecc 2 * Copyright (c) 2014, WH
wim 34:e5a0dcb43ecc 3 * 2014, v01: WH, Extracted from TextLCD.h as of v14
wim 35:311be6444a39 4 * 2014, v02: WH, Added AC780 support, added I2C expander modules, fixed setBacklight() for inverted logic modules. Fixed bug in LCD_SPI_N define
wim 36:9f5f86dfd44a 5 * 2014, v03: WH, Added LCD_SPI_N_3_8 define for ST7070
wim 37:ce348c002929 6 * 2015, v04: WH, Added support for alternative fonttables (eg PCF21XX)
wim 37:ce348c002929 7 * 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
wim 38:cbe275b0b647 8 * 2015, v06: WH, Performance improvement I2C portexpander
wim 38:cbe275b0b647 9 * 2015, v07: WH, Fixed Adafruit I2C/SPI portexpander pinmappings, fixed SYDZ Backlight
wim 39:e9c2319de9c5 10 * 2015, v08: WH, Added defines to reduce memory footprint (eg LCD_ICON), added some I2C portexpander defines
wim 34:e5a0dcb43ecc 11 *
wim 34:e5a0dcb43ecc 12 * Permission is hereby granted, free of charge, to any person obtaining a copy
wim 34:e5a0dcb43ecc 13 * of this software and associated documentation files (the "Software"), to deal
wim 34:e5a0dcb43ecc 14 * in the Software without restriction, including without limitation the rights
wim 34:e5a0dcb43ecc 15 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
wim 34:e5a0dcb43ecc 16 * copies of the Software, and to permit persons to whom the Software is
wim 34:e5a0dcb43ecc 17 * furnished to do so, subject to the following conditions:
wim 34:e5a0dcb43ecc 18 *
wim 34:e5a0dcb43ecc 19 * The above copyright notice and this permission notice shall be included in
wim 34:e5a0dcb43ecc 20 * all copies or substantial portions of the Software.
wim 34:e5a0dcb43ecc 21 *
wim 34:e5a0dcb43ecc 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
wim 34:e5a0dcb43ecc 23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
wim 34:e5a0dcb43ecc 24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
wim 34:e5a0dcb43ecc 25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
wim 34:e5a0dcb43ecc 26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wim 34:e5a0dcb43ecc 27 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
wim 34:e5a0dcb43ecc 28 * THE SOFTWARE.
wim 34:e5a0dcb43ecc 29 */
wim 34:e5a0dcb43ecc 30 #ifndef MBED_TEXTLCDCONFIG_H
wim 34:e5a0dcb43ecc 31 #define MBED_TEXTLCDCONFIG_H
wim 34:e5a0dcb43ecc 32
wim 34:e5a0dcb43ecc 33 //Select hardware interface options to reduce memory footprint (multiple options allowed)
wim 34:e5a0dcb43ecc 34 #define LCD_I2C 1 /* I2C Expander PCF8574/MCP23008 */
wim 34:e5a0dcb43ecc 35 #define LCD_SPI 1 /* SPI Expander SN74595 */
wim 34:e5a0dcb43ecc 36 #define LCD_I2C_N 1 /* Native I2C bus */
wim 35:311be6444a39 37 #define LCD_SPI_N 1 /* Native SPI bus */
wim 36:9f5f86dfd44a 38 #define LCD_SPI_N_3_8 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 39 #define LCD_SPI_N_3_9 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 40 #define LCD_SPI_N_3_10 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 41 #define LCD_SPI_N_3_16 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 42 #define LCD_SPI_N_3_24 1 /* Native SPI bus */
wim 35:311be6444a39 43
wim 34:e5a0dcb43ecc 44 //Select options to reduce memory footprint (multiple options allowed)
wim 39:e9c2319de9c5 45 #define LCD_UDC 1 /* Enable predefined UDC example*/
wim 39:e9c2319de9c5 46 #define LCD_PRINTF 1 /* Enable Stream implementation */
wim 39:e9c2319de9c5 47 #define LCD_ICON 1 /* Enable Icon implementation -2.0K codesize*/
wim 39:e9c2319de9c5 48 #define LCD_ORIENT 1 /* Enable Orientation switch implementation -0.9K codesize*/
wim 40:d3496c3ea301 49 #define LCD_BIGFONT 1 /* Enable Big Font implementation -0.6K codesize */
wim 40:d3496c3ea301 50 #define LCD_INVERT 1 /* Enable display Invert implementation -0.5K codesize*/
wim 40:d3496c3ea301 51 #define LCD_POWER 1 /* Enable Power control implementation -0.1K codesize*/
wim 39:e9c2319de9c5 52 #define LCD_BLINK 1 /* Enable UDC and Icon Blink control implementation -0.8K codesize*/
wim 34:e5a0dcb43ecc 53
wim 40:d3496c3ea301 54 //Select option to activate default fonttable or alternatively use conversion for specific controller versions (eg PCF2116C, PCF2119R)
wim 40:d3496c3ea301 55 #define LCD_DEF_FONT 1
wim 37:ce348c002929 56
wim 34:e5a0dcb43ecc 57 //Pin Defines for I2C PCF8574/PCF8574A or MCP23008 and SPI 74595 bus expander interfaces
wim 37:ce348c002929 58 //Different commercially available LCD portexpanders use different wiring conventions.
wim 37:ce348c002929 59 //LCD and serial portexpanders should be wired according to the tables below.
wim 34:e5a0dcb43ecc 60 //
wim 37:ce348c002929 61 //Select Serial Port Expander Hardware module (one option only)
wim 40:d3496c3ea301 62 #define DEFAULT 1
wim 34:e5a0dcb43ecc 63 #define ADAFRUIT 0
wim 34:e5a0dcb43ecc 64 #define DFROBOT 0
wim 39:e9c2319de9c5 65 #define LCM1602 0
wim 35:311be6444a39 66 #define YWROBOT 0
wim 35:311be6444a39 67 #define GYLCD 0
wim 39:e9c2319de9c5 68 #define MJKDZ 0
wim 40:d3496c3ea301 69 #define SYDZ 0
wim 39:e9c2319de9c5 70 #define WIDEHK 0
wim 39:e9c2319de9c5 71 #define LCDPLUG 0
wim 34:e5a0dcb43ecc 72
wim 34:e5a0dcb43ecc 73 #if (DEFAULT==1)
wim 34:e5a0dcb43ecc 74 //Definitions for default (WH) mapping between serial port expander pins and LCD controller
wim 34:e5a0dcb43ecc 75 //This hardware supports the I2C bus expander (PCF8574/PCF8574A or MCP23008) and SPI bus expander (74595) interfaces
wim 34:e5a0dcb43ecc 76 //See https://mbed.org/cookbook/Text-LCD-Enhanced
wim 34:e5a0dcb43ecc 77 //
wim 34:e5a0dcb43ecc 78 //Note: LCD RW pin must be connected to GND
wim 34:e5a0dcb43ecc 79 // E2 is used for LCD40x4 (second controller)
wim 34:e5a0dcb43ecc 80 // BL may be used to control backlight
wim 38:cbe275b0b647 81
wim 38:cbe275b0b647 82 //I2C bus expander (PCF8574/PCF8574A or MCP23008) interface
wim 38:cbe275b0b647 83 #define LCD_BUS_I2C_D4 (1 << 0)
wim 38:cbe275b0b647 84 #define LCD_BUS_I2C_D5 (1 << 1)
wim 38:cbe275b0b647 85 #define LCD_BUS_I2C_D6 (1 << 2)
wim 38:cbe275b0b647 86 #define LCD_BUS_I2C_D7 (1 << 3)
wim 38:cbe275b0b647 87 #define LCD_BUS_I2C_RS (1 << 4)
wim 38:cbe275b0b647 88 #define LCD_BUS_I2C_E (1 << 5)
wim 38:cbe275b0b647 89 #define LCD_BUS_I2C_E2 (1 << 6)
wim 38:cbe275b0b647 90 #define LCD_BUS_I2C_BL (1 << 7)
wim 34:e5a0dcb43ecc 91
wim 38:cbe275b0b647 92 #define LCD_BUS_I2C_RW (1 << 6)
wim 38:cbe275b0b647 93
wim 38:cbe275b0b647 94 //SPI bus expander (74595) interface, same as I2C
wim 38:cbe275b0b647 95 #define LCD_BUS_SPI_D4 LCD_BUS_I2C_D4
wim 38:cbe275b0b647 96 #define LCD_BUS_SPI_D5 LCD_BUS_I2C_D5
wim 38:cbe275b0b647 97 #define LCD_BUS_SPI_D6 LCD_BUS_I2C_D6
wim 38:cbe275b0b647 98 #define LCD_BUS_SPI_D7 LCD_BUS_I2C_D7
wim 38:cbe275b0b647 99 #define LCD_BUS_SPI_RS LCD_BUS_I2C_RS
wim 38:cbe275b0b647 100 #define LCD_BUS_SPI_E LCD_BUS_I2C_E
wim 38:cbe275b0b647 101 #define LCD_BUS_SPI_E2 LCD_BUS_I2C_E2
wim 38:cbe275b0b647 102 #define LCD_BUS_SPI_BL LCD_BUS_I2C_BL
wim 38:cbe275b0b647 103
wim 38:cbe275b0b647 104 #define LCD_BUS_SPI_RW LCD_BUS_I2C_RW
wim 34:e5a0dcb43ecc 105
wim 34:e5a0dcb43ecc 106 //Select I2C Portexpander type (one option only)
wim 34:e5a0dcb43ecc 107 #define PCF8574 1
wim 34:e5a0dcb43ecc 108 #define MCP23008 0
wim 35:311be6444a39 109
wim 35:311be6444a39 110 //Inverted Backlight control
wim 35:311be6444a39 111 #define BACKLIGHT_INV 0
wim 34:e5a0dcb43ecc 112 #endif
wim 34:e5a0dcb43ecc 113
wim 34:e5a0dcb43ecc 114 #if (ADAFRUIT==1)
wim 34:e5a0dcb43ecc 115 //Definitions for Adafruit i2cspilcdbackpack mapping between serial port expander pins and LCD controller
wim 34:e5a0dcb43ecc 116 //This hardware supports both an I2C expander (MCP23008) and an SPI expander (74595) selectable by a jumper.
wim 35:311be6444a39 117 //Slaveaddress may be set by solderbridges (default 0x40). SDA/SCL has pullup Resistors onboard.
wim 34:e5a0dcb43ecc 118 //See http://www.ladyada.net/products/i2cspilcdbackpack
wim 34:e5a0dcb43ecc 119 //
wim 34:e5a0dcb43ecc 120 //Note: LCD RW pin must be kept LOW
wim 34:e5a0dcb43ecc 121 // E2 is not available on this hardware and so it does not support LCD40x4 (second controller)
wim 34:e5a0dcb43ecc 122 // BL is used to control backlight
wim 38:cbe275b0b647 123 //Note: The pinmappings are different for the MCP23008 and the 74595!
wim 38:cbe275b0b647 124
wim 38:cbe275b0b647 125 //I2C bus expander (MCP23008) interface
wim 38:cbe275b0b647 126 #define LCD_BUS_I2C_0 (1 << 0)
wim 38:cbe275b0b647 127 #define LCD_BUS_I2C_RS (1 << 1)
wim 38:cbe275b0b647 128 #define LCD_BUS_I2C_E (1 << 2)
wim 38:cbe275b0b647 129 #define LCD_BUS_I2C_D4 (1 << 3)
wim 38:cbe275b0b647 130 #define LCD_BUS_I2C_D5 (1 << 4)
wim 38:cbe275b0b647 131 #define LCD_BUS_I2C_D6 (1 << 5)
wim 38:cbe275b0b647 132 #define LCD_BUS_I2C_D7 (1 << 6)
wim 38:cbe275b0b647 133 #define LCD_BUS_I2C_BL (1 << 7)
wim 34:e5a0dcb43ecc 134
wim 38:cbe275b0b647 135 #define LCD_BUS_I2C_E2 (1 << 0)
wim 38:cbe275b0b647 136 #define LCD_BUS_I2C_RW (1 << 0)
wim 38:cbe275b0b647 137
wim 38:cbe275b0b647 138 //SPI bus expander (74595) interface
wim 38:cbe275b0b647 139 #define LCD_BUS_SPI_0 (1 << 0)
wim 38:cbe275b0b647 140 #define LCD_BUS_SPI_RS (1 << 1)
wim 38:cbe275b0b647 141 #define LCD_BUS_SPI_E (1 << 2)
wim 38:cbe275b0b647 142 #define LCD_BUS_SPI_D7 (1 << 3)
wim 38:cbe275b0b647 143 #define LCD_BUS_SPI_D6 (1 << 4)
wim 38:cbe275b0b647 144 #define LCD_BUS_SPI_D5 (1 << 5)
wim 38:cbe275b0b647 145 #define LCD_BUS_SPI_D4 (1 << 6)
wim 38:cbe275b0b647 146 #define LCD_BUS_SPI_BL (1 << 7)
wim 38:cbe275b0b647 147
wim 38:cbe275b0b647 148 #define LCD_BUS_SPI_E2 (1 << 0)
wim 38:cbe275b0b647 149 #define LCD_BUS_SPI_RW (1 << 0)
wim 34:e5a0dcb43ecc 150
wim 34:e5a0dcb43ecc 151 //Force I2C portexpander type
wim 34:e5a0dcb43ecc 152 #define PCF8574 0
wim 34:e5a0dcb43ecc 153 #define MCP23008 1
wim 35:311be6444a39 154
wim 35:311be6444a39 155 //Inverted Backlight control
wim 35:311be6444a39 156 #define BACKLIGHT_INV 0
wim 34:e5a0dcb43ecc 157 #endif
wim 34:e5a0dcb43ecc 158
wim 34:e5a0dcb43ecc 159 #if (DFROBOT==1)
wim 34:e5a0dcb43ecc 160 //Definitions for DFROBOT LCD2004 Module mapping between serial port expander pins and LCD controller
wim 34:e5a0dcb43ecc 161 //This hardware uses PCF8574 and is different from earlier/different Arduino I2C LCD displays
wim 35:311be6444a39 162 //Slaveaddress hardwired to 0x4E. SDA/SCL has pullup Resistors onboard.
wim 35:311be6444a39 163 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C
wim 35:311be6444a39 164 //
wim 35:311be6444a39 165 //Definitions for DFROBOT V1.1
wim 35:311be6444a39 166 //This hardware uses PCF8574. Slaveaddress may be set by jumpers (default 0x40).
wim 35:311be6444a39 167 //SDA/SCL has pullup Resistors onboard and features a voltage level converter 3V3 <-> 5V.
wim 35:311be6444a39 168 //See http://www.dfrobot.com/index.php?route=product/product&product_id=135
wim 35:311be6444a39 169 //
wim 35:311be6444a39 170 //
wim 35:311be6444a39 171 //Note: LCD RW pin must be kept LOW
wim 35:311be6444a39 172 // E2 is not available on default Arduino hardware and so it does not support LCD40x4 (second controller)
wim 35:311be6444a39 173 // BL is used to control backlight
wim 38:cbe275b0b647 174
wim 38:cbe275b0b647 175 //I2C bus expander PCF8574 interface
wim 38:cbe275b0b647 176 #define LCD_BUS_I2C_RS (1 << 0)
wim 38:cbe275b0b647 177 #define LCD_BUS_I2C_RW (1 << 1)
wim 38:cbe275b0b647 178 #define LCD_BUS_I2C_E (1 << 2)
wim 38:cbe275b0b647 179 #define LCD_BUS_I2C_BL (1 << 3)
wim 38:cbe275b0b647 180 #define LCD_BUS_I2C_D4 (1 << 4)
wim 38:cbe275b0b647 181 #define LCD_BUS_I2C_D5 (1 << 5)
wim 38:cbe275b0b647 182 #define LCD_BUS_I2C_D6 (1 << 6)
wim 38:cbe275b0b647 183 #define LCD_BUS_I2C_D7 (1 << 7)
wim 38:cbe275b0b647 184
wim 38:cbe275b0b647 185 #define LCD_BUS_I2C_E2 (1 << 1)
wim 35:311be6444a39 186
wim 38:cbe275b0b647 187 //SPI bus expander (74595) interface, same as I2C
wim 38:cbe275b0b647 188 #define LCD_BUS_SPI_RS LCD_BUS_I2C_RS
wim 38:cbe275b0b647 189 #define LCD_BUS_SPI_RW LCD_BUS_I2C_RW
wim 38:cbe275b0b647 190 #define LCD_BUS_SPI_E LCD_BUS_I2C_E
wim 38:cbe275b0b647 191 #define LCD_BUS_SPI_BL LCD_BUS_I2C_BL
wim 38:cbe275b0b647 192 #define LCD_BUS_SPI_D4 LCD_BUS_I2C_D4
wim 38:cbe275b0b647 193 #define LCD_BUS_SPI_D5 LCD_BUS_I2C_D5
wim 38:cbe275b0b647 194 #define LCD_BUS_SPI_D6 LCD_BUS_I2C_D6
wim 38:cbe275b0b647 195 #define LCD_BUS_SPI_D7 LCD_BUS_I2C_D7
wim 38:cbe275b0b647 196
wim 38:cbe275b0b647 197 #define LCD_BUS_SPI_E2 LCD_BUS_I2C_E2
wim 38:cbe275b0b647 198
wim 35:311be6444a39 199
wim 35:311be6444a39 200 //Force I2C portexpander type
wim 35:311be6444a39 201 #define PCF8574 1
wim 35:311be6444a39 202 #define MCP23008 0
wim 35:311be6444a39 203
wim 35:311be6444a39 204 //Inverted Backlight control
wim 35:311be6444a39 205 #define BACKLIGHT_INV 0
wim 35:311be6444a39 206 #endif
wim 35:311be6444a39 207
wim 39:e9c2319de9c5 208 #if ((YWROBOT==1) || (LCM1602==1))
wim 35:311be6444a39 209 //Definitions for YWROBOT LCM1602 V1 Module mapping between serial port expander pins and LCD controller.
wim 39:e9c2319de9c5 210 //Very similar to DFROBOT. Also marked as 'Funduino'. This hardware uses PCF8574.
wim 35:311be6444a39 211 //Slaveaddress may be set by solderbridges (default 0x4E). SDA/SCL has no pullup Resistors onboard.
wim 34:e5a0dcb43ecc 212 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C
wim 34:e5a0dcb43ecc 213 //
wim 34:e5a0dcb43ecc 214 //Note: LCD RW pin must be kept LOW
wim 35:311be6444a39 215 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller)
wim 39:e9c2319de9c5 216 // BL is used to control backlight.
wim 38:cbe275b0b647 217
wim 38:cbe275b0b647 218 //I2C bus expander PCF8574 interface
wim 38:cbe275b0b647 219 #define LCD_BUS_I2C_RS (1 << 0)
wim 38:cbe275b0b647 220 #define LCD_BUS_I2C_RW (1 << 1)
wim 38:cbe275b0b647 221 #define LCD_BUS_I2C_E (1 << 2)
wim 38:cbe275b0b647 222 #define LCD_BUS_I2C_BL (1 << 3)
wim 38:cbe275b0b647 223 #define LCD_BUS_I2C_D4 (1 << 4)
wim 38:cbe275b0b647 224 #define LCD_BUS_I2C_D5 (1 << 5)
wim 38:cbe275b0b647 225 #define LCD_BUS_I2C_D6 (1 << 6)
wim 38:cbe275b0b647 226 #define LCD_BUS_I2C_D7 (1 << 7)
wim 34:e5a0dcb43ecc 227
wim 38:cbe275b0b647 228 #define LCD_BUS_I2C_E2 (1 << 1)
wim 38:cbe275b0b647 229
wim 38:cbe275b0b647 230 //SPI bus expander (74595) interface, same as I2C
wim 38:cbe275b0b647 231 #define LCD_BUS_SPI_RS LCD_BUS_I2C_RS
wim 38:cbe275b0b647 232 #define LCD_BUS_SPI_RW LCD_BUS_I2C_RW
wim 38:cbe275b0b647 233 #define LCD_BUS_SPI_E LCD_BUS_I2C_E
wim 38:cbe275b0b647 234 #define LCD_BUS_SPI_BL LCD_BUS_I2C_BL
wim 38:cbe275b0b647 235 #define LCD_BUS_SPI_D4 LCD_BUS_I2C_D4
wim 38:cbe275b0b647 236 #define LCD_BUS_SPI_D5 LCD_BUS_I2C_D5
wim 38:cbe275b0b647 237 #define LCD_BUS_SPI_D6 LCD_BUS_I2C_D6
wim 38:cbe275b0b647 238 #define LCD_BUS_SPI_D7 LCD_BUS_I2C_D7
wim 38:cbe275b0b647 239
wim 38:cbe275b0b647 240 #define LCD_BUS_SPI_E2 LCD_BUS_I2C_E2
wim 34:e5a0dcb43ecc 241
wim 34:e5a0dcb43ecc 242 //Force I2C portexpander type
wim 34:e5a0dcb43ecc 243 #define PCF8574 1
wim 34:e5a0dcb43ecc 244 #define MCP23008 0
wim 35:311be6444a39 245
wim 35:311be6444a39 246 //Inverted Backlight control
wim 35:311be6444a39 247 #define BACKLIGHT_INV 0
wim 34:e5a0dcb43ecc 248 #endif
wim 34:e5a0dcb43ecc 249
wim 39:e9c2319de9c5 250 #if ((GYLCD==1) || (MJKDZ==1))
wim 39:e9c2319de9c5 251 //Definitions for Arduino-IIC-LCD GY-LCD-V1, for GY-IICLCD and for MJKDZ Module mapping between serial port expander pins and LCD controller.
wim 35:311be6444a39 252 //Very similar to DFROBOT. This hardware uses PCF8574.
wim 35:311be6444a39 253 //Slaveaddress may be set by solderbridges (default 0x4E). SDA/SCL has pullup Resistors onboard.
wim 35:311be6444a39 254 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C
wim 35:311be6444a39 255 //
wim 35:311be6444a39 256 //Note: LCD RW pin must be kept LOW
wim 35:311be6444a39 257 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller)
wim 35:311be6444a39 258 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight()
wim 38:cbe275b0b647 259
wim 38:cbe275b0b647 260 //I2C bus expander PCF8574 interface
wim 38:cbe275b0b647 261 #define LCD_BUS_I2C_D4 (1 << 0)
wim 38:cbe275b0b647 262 #define LCD_BUS_I2C_D5 (1 << 1)
wim 38:cbe275b0b647 263 #define LCD_BUS_I2C_D6 (1 << 2)
wim 38:cbe275b0b647 264 #define LCD_BUS_I2C_D7 (1 << 3)
wim 38:cbe275b0b647 265 #define LCD_BUS_I2C_E (1 << 4)
wim 38:cbe275b0b647 266 #define LCD_BUS_I2C_RW (1 << 5)
wim 38:cbe275b0b647 267 #define LCD_BUS_I2C_RS (1 << 6)
wim 38:cbe275b0b647 268 #define LCD_BUS_I2C_BL (1 << 7)
wim 35:311be6444a39 269
wim 38:cbe275b0b647 270 #define LCD_BUS_I2C_E2 (1 << 5)
wim 38:cbe275b0b647 271
wim 38:cbe275b0b647 272 //SPI bus expander (74595) interface
wim 38:cbe275b0b647 273 #define LCD_BUS_SPI_D4 LCD_BUS_I2C_D4
wim 38:cbe275b0b647 274 #define LCD_BUS_SPI_D5 LCD_BUS_I2C_D5
wim 38:cbe275b0b647 275 #define LCD_BUS_SPI_D6 LCD_BUS_I2C_D6
wim 38:cbe275b0b647 276 #define LCD_BUS_SPI_D7 LCD_BUS_I2C_D7
wim 38:cbe275b0b647 277 #define LCD_BUS_SPI_E LCD_BUS_I2C_E
wim 38:cbe275b0b647 278 #define LCD_BUS_SPI_RW LCD_BUS_I2C_RW
wim 38:cbe275b0b647 279 #define LCD_BUS_SPI_RS LCD_BUS_I2C_RS
wim 38:cbe275b0b647 280 #define LCD_BUS_SPI_BL LCD_BUS_I2C_BL
wim 38:cbe275b0b647 281
wim 38:cbe275b0b647 282 #define LCD_BUS_SPI_E2 LCD_BUS_I2C_E2
wim 35:311be6444a39 283
wim 35:311be6444a39 284 //Force I2C portexpander type
wim 35:311be6444a39 285 #define PCF8574 1
wim 35:311be6444a39 286 #define MCP23008 0
wim 35:311be6444a39 287
wim 35:311be6444a39 288 //Force Inverted Backlight control
wim 35:311be6444a39 289 #define BACKLIGHT_INV 1
wim 35:311be6444a39 290 #endif
wim 35:311be6444a39 291
wim 35:311be6444a39 292 #if (SYDZ==1)
wim 35:311be6444a39 293 //Definitions for SYDZ Module mapping between serial port expander pins and LCD controller.
wim 38:cbe275b0b647 294 //Very similar to DFROBOT. This hardware uses PCF8574A.
wim 38:cbe275b0b647 295 //Slaveaddress may be set by switches (default 0x70). SDA/SCL has pullup Resistors onboard.
wim 35:311be6444a39 296 //See ebay
wim 35:311be6444a39 297 //
wim 35:311be6444a39 298 //Note: LCD RW pin must be kept LOW
wim 35:311be6444a39 299 // E2 is not available on default hardware and so it does not support LCD40x4 (second controller)
wim 38:cbe275b0b647 300 // BL is used to control backlight
wim 38:cbe275b0b647 301
wim 38:cbe275b0b647 302 //I2C bus expander PCF8574A interface
wim 38:cbe275b0b647 303 #define LCD_BUS_I2C_RS (1 << 0)
wim 38:cbe275b0b647 304 #define LCD_BUS_I2C_RW (1 << 1)
wim 38:cbe275b0b647 305 #define LCD_BUS_I2C_E (1 << 2)
wim 38:cbe275b0b647 306 #define LCD_BUS_I2C_BL (1 << 3)
wim 38:cbe275b0b647 307 #define LCD_BUS_I2C_D4 (1 << 4)
wim 38:cbe275b0b647 308 #define LCD_BUS_I2C_D5 (1 << 5)
wim 38:cbe275b0b647 309 #define LCD_BUS_I2C_D6 (1 << 6)
wim 38:cbe275b0b647 310 #define LCD_BUS_I2C_D7 (1 << 7)
wim 35:311be6444a39 311
wim 38:cbe275b0b647 312 #define LCD_BUS_I2C_E2 (1 << 1)
wim 38:cbe275b0b647 313
wim 38:cbe275b0b647 314 //SPI bus expander (74595) interface, same as I2C
wim 38:cbe275b0b647 315 #define LCD_BUS_SPI_RS LCD_BUS_I2C_RS
wim 38:cbe275b0b647 316 #define LCD_BUS_SPI_RW LCD_BUS_I2C_RW
wim 38:cbe275b0b647 317 #define LCD_BUS_SPI_E LCD_BUS_I2C_E
wim 38:cbe275b0b647 318 #define LCD_BUS_SPI_BL LCD_BUS_I2C_BL
wim 38:cbe275b0b647 319 #define LCD_BUS_SPI_D4 LCD_BUS_I2C_D4
wim 38:cbe275b0b647 320 #define LCD_BUS_SPI_D5 LCD_BUS_I2C_D5
wim 38:cbe275b0b647 321 #define LCD_BUS_SPI_D6 LCD_BUS_I2C_D6
wim 38:cbe275b0b647 322 #define LCD_BUS_SPI_D7 LCD_BUS_I2C_D7
wim 38:cbe275b0b647 323
wim 38:cbe275b0b647 324 #define LCD_BUS_SPI_E2 LCD_BUS_I2C_E2
wim 35:311be6444a39 325
wim 35:311be6444a39 326 //Force I2C portexpander type
wim 35:311be6444a39 327 #define PCF8574 1
wim 35:311be6444a39 328 #define MCP23008 0
wim 35:311be6444a39 329
wim 35:311be6444a39 330 //Force Inverted Backlight control
wim 38:cbe275b0b647 331 #define BACKLIGHT_INV 0
wim 35:311be6444a39 332 #endif
wim 34:e5a0dcb43ecc 333
wim 39:e9c2319de9c5 334 #if (WIDEHK==1)
wim 39:e9c2319de9c5 335 //Definitions for WIDE.HK I2C backpack mapping between serial port expander pins and LCD controller
wim 39:e9c2319de9c5 336 //This hardware uses an MCP23008 I2C expander.
wim 39:e9c2319de9c5 337 //Slaveaddress is hardcoded at 0x4E. SDA/SCL has pullup Resistors onboard (3k3).
wim 39:e9c2319de9c5 338 //See http://www.wide.hk
wim 39:e9c2319de9c5 339 //
wim 39:e9c2319de9c5 340 //Note: LCD RW pin must be kept LOW
wim 39:e9c2319de9c5 341 // E2 is not available on this hardware and so it does not support LCD40x4 (second controller)
wim 39:e9c2319de9c5 342 // BL is used to control backlight
wim 39:e9c2319de9c5 343 //
wim 39:e9c2319de9c5 344
wim 39:e9c2319de9c5 345 //I2C bus expander (MCP23008) interface
wim 39:e9c2319de9c5 346 #define LCD_BUS_I2C_D4 (1 << 0)
wim 39:e9c2319de9c5 347 #define LCD_BUS_I2C_D5 (1 << 1)
wim 39:e9c2319de9c5 348 #define LCD_BUS_I2C_D6 (1 << 2)
wim 39:e9c2319de9c5 349 #define LCD_BUS_I2C_D7 (1 << 3)
wim 39:e9c2319de9c5 350 #define LCD_BUS_I2C_RS (1 << 4)
wim 39:e9c2319de9c5 351 #define LCD_BUS_I2C_RW (1 << 5)
wim 39:e9c2319de9c5 352 #define LCD_BUS_I2C_BL (1 << 6)
wim 39:e9c2319de9c5 353 #define LCD_BUS_I2C_E (1 << 7)
wim 39:e9c2319de9c5 354
wim 39:e9c2319de9c5 355 #define LCD_BUS_I2C_E2 (1 << 5)
wim 39:e9c2319de9c5 356
wim 39:e9c2319de9c5 357 //SPI bus expander (74595) interface, same as I2C
wim 39:e9c2319de9c5 358 #define LCD_BUS_SPI_D4 LCD_BUS_I2C_D4
wim 39:e9c2319de9c5 359 #define LCD_BUS_SPI_D5 LCD_BUS_I2C_D5
wim 39:e9c2319de9c5 360 #define LCD_BUS_SPI_D6 LCD_BUS_I2C_D6
wim 39:e9c2319de9c5 361 #define LCD_BUS_SPI_D7 LCD_BUS_I2C_D7
wim 39:e9c2319de9c5 362 #define LCD_BUS_SPI_RS LCD_BUS_I2C_RS
wim 39:e9c2319de9c5 363 #define LCD_BUS_SPI_RW LCD_BUS_I2C_RW
wim 39:e9c2319de9c5 364 #define LCD_BUS_SPI_BL LCD_BUS_I2C_BL
wim 39:e9c2319de9c5 365 #define LCD_BUS_SPI_E LCD_BUS_I2C_E
wim 39:e9c2319de9c5 366
wim 39:e9c2319de9c5 367 #define LCD_BUS_SPI_E2 LCD_BUS_I2C_E2
wim 39:e9c2319de9c5 368
wim 39:e9c2319de9c5 369 //Force I2C portexpander type
wim 39:e9c2319de9c5 370 #define PCF8574 0
wim 39:e9c2319de9c5 371 #define MCP23008 1
wim 39:e9c2319de9c5 372
wim 39:e9c2319de9c5 373 //Inverted Backlight control
wim 39:e9c2319de9c5 374 #define BACKLIGHT_INV 0
wim 39:e9c2319de9c5 375 #endif
wim 39:e9c2319de9c5 376
wim 39:e9c2319de9c5 377 #if (LCDPLUG==1)
wim 39:e9c2319de9c5 378 //Definitions for Jeelabs LCD_Plug I2C backpack mapping between serial port expander pins and LCD controller
wim 39:e9c2319de9c5 379 //This hardware uses an MCP23008 I2C expander.
wim 39:e9c2319de9c5 380 //Slaveaddress is hardcoded at 0x48. SDA/SCL has no pullup Resistors onboard.
wim 39:e9c2319de9c5 381 //See http://jeelabs.net/projects/hardware/wiki/lcd_plug
wim 39:e9c2319de9c5 382 //
wim 39:e9c2319de9c5 383 //Note: LCD RW pin must be kept LOW
wim 39:e9c2319de9c5 384 // E2 is available on a plug and so it does support LCD40x4 (second controller)
wim 39:e9c2319de9c5 385 // BL is used to control backlight
wim 39:e9c2319de9c5 386 //
wim 39:e9c2319de9c5 387
wim 39:e9c2319de9c5 388 //I2C bus expander (MCP23008) interface
wim 39:e9c2319de9c5 389 #define LCD_BUS_I2C_D4 (1 << 0)
wim 39:e9c2319de9c5 390 #define LCD_BUS_I2C_D5 (1 << 1)
wim 39:e9c2319de9c5 391 #define LCD_BUS_I2C_D6 (1 << 2)
wim 39:e9c2319de9c5 392 #define LCD_BUS_I2C_D7 (1 << 3)
wim 39:e9c2319de9c5 393 #define LCD_BUS_I2C_RS (1 << 4)
wim 39:e9c2319de9c5 394 #define LCD_BUS_I2C_E2 (1 << 5)
wim 39:e9c2319de9c5 395 #define LCD_BUS_I2C_E (1 << 6)
wim 39:e9c2319de9c5 396 #define LCD_BUS_I2C_BL (1 << 7)
wim 39:e9c2319de9c5 397
wim 39:e9c2319de9c5 398 #define LCD_BUS_I2C_RW (1 << 5)
wim 39:e9c2319de9c5 399
wim 39:e9c2319de9c5 400 //SPI bus expander (74595) interface, same as I2C
wim 39:e9c2319de9c5 401 #define LCD_BUS_SPI_D4 LCD_BUS_I2C_D4
wim 39:e9c2319de9c5 402 #define LCD_BUS_SPI_D5 LCD_BUS_I2C_D5
wim 39:e9c2319de9c5 403 #define LCD_BUS_SPI_D6 LCD_BUS_I2C_D6
wim 39:e9c2319de9c5 404 #define LCD_BUS_SPI_D7 LCD_BUS_I2C_D7
wim 39:e9c2319de9c5 405 #define LCD_BUS_SPI_RS LCD_BUS_I2C_RS
wim 39:e9c2319de9c5 406 #define LCD_BUS_SPI_E2 LCD_BUS_I2C_E2
wim 39:e9c2319de9c5 407 #define LCD_BUS_SPI_E LCD_BUS_I2C_E
wim 39:e9c2319de9c5 408 #define LCD_BUS_SPI_BL LCD_BUS_I2C_BL
wim 39:e9c2319de9c5 409
wim 39:e9c2319de9c5 410 #define LCD_BUS_SPI_RW LCD_BUS_I2C_RW
wim 39:e9c2319de9c5 411
wim 39:e9c2319de9c5 412 //Force I2C portexpander type
wim 39:e9c2319de9c5 413 #define PCF8574 0
wim 39:e9c2319de9c5 414 #define MCP23008 1
wim 39:e9c2319de9c5 415
wim 39:e9c2319de9c5 416 //Inverted Backlight control
wim 39:e9c2319de9c5 417 #define BACKLIGHT_INV 0
wim 39:e9c2319de9c5 418 #endif
wim 39:e9c2319de9c5 419
wim 39:e9c2319de9c5 420
wim 34:e5a0dcb43ecc 421 //Bitpattern Defines for I2C PCF8574/PCF8574A, MCP23008 and SPI 74595 Bus expanders
wim 37:ce348c002929 422 //Don't change!
wim 38:cbe275b0b647 423 #define LCD_BUS_I2C_MSK (LCD_BUS_I2C_D4 | LCD_BUS_I2C_D5 | LCD_BUS_I2C_D6 | LCD_BUS_I2C_D7)
wim 38:cbe275b0b647 424 #if (BACKLIGHT_INV == 1)
wim 38:cbe275b0b647 425 #define LCD_BUS_I2C_DEF (0x00 | LCD_BUS_I2C_BL)
wim 38:cbe275b0b647 426 #else
wim 38:cbe275b0b647 427 #define LCD_BUS_I2C_DEF 0x00
wim 38:cbe275b0b647 428 #endif
wim 34:e5a0dcb43ecc 429
wim 38:cbe275b0b647 430 #define LCD_BUS_SPI_MSK (LCD_BUS_SPI_D4 | LCD_BUS_SPI_D5 | LCD_BUS_SPI_D6 | LCD_BUS_SPI_D7)
wim 38:cbe275b0b647 431 #if (BACKLIGHT_INV == 1)
wim 38:cbe275b0b647 432 #define LCD_BUS_SPI_DEF (0x00 | LCD_BUS_SPI_BL)
wim 38:cbe275b0b647 433 #else
wim 38:cbe275b0b647 434 #define LCD_BUS_SPI_DEF 0x00
wim 38:cbe275b0b647 435 #endif
wim 38:cbe275b0b647 436
wim 34:e5a0dcb43ecc 437
wim 34:e5a0dcb43ecc 438 /* PCF8574/PCF8574A I2C portexpander slave address */
wim 34:e5a0dcb43ecc 439 #define PCF8574_SA0 0x40
wim 34:e5a0dcb43ecc 440 #define PCF8574_SA1 0x42
wim 34:e5a0dcb43ecc 441 #define PCF8574_SA2 0x44
wim 34:e5a0dcb43ecc 442 #define PCF8574_SA3 0x46
wim 34:e5a0dcb43ecc 443 #define PCF8574_SA4 0x48
wim 34:e5a0dcb43ecc 444 #define PCF8574_SA5 0x4A
wim 34:e5a0dcb43ecc 445 #define PCF8574_SA6 0x4C
wim 34:e5a0dcb43ecc 446 #define PCF8574_SA7 0x4E
wim 34:e5a0dcb43ecc 447
wim 34:e5a0dcb43ecc 448 #define PCF8574A_SA0 0x70
wim 34:e5a0dcb43ecc 449 #define PCF8574A_SA1 0x72
wim 34:e5a0dcb43ecc 450 #define PCF8574A_SA2 0x74
wim 34:e5a0dcb43ecc 451 #define PCF8574A_SA3 0x76
wim 34:e5a0dcb43ecc 452 #define PCF8574A_SA4 0x78
wim 34:e5a0dcb43ecc 453 #define PCF8574A_SA5 0x7A
wim 34:e5a0dcb43ecc 454 #define PCF8574A_SA6 0x7C
wim 34:e5a0dcb43ecc 455 #define PCF8574A_SA7 0x7E
wim 34:e5a0dcb43ecc 456
wim 34:e5a0dcb43ecc 457 /* MCP23008 I2C portexpander slave address */
wim 34:e5a0dcb43ecc 458 #define MCP23008_SA0 0x40
wim 34:e5a0dcb43ecc 459 #define MCP23008_SA1 0x42
wim 34:e5a0dcb43ecc 460 #define MCP23008_SA2 0x44
wim 34:e5a0dcb43ecc 461 #define MCP23008_SA3 0x46
wim 34:e5a0dcb43ecc 462 #define MCP23008_SA4 0x48
wim 34:e5a0dcb43ecc 463 #define MCP23008_SA5 0x4A
wim 34:e5a0dcb43ecc 464 #define MCP23008_SA6 0x4C
wim 34:e5a0dcb43ecc 465 #define MCP23008_SA7 0x4E
wim 34:e5a0dcb43ecc 466
wim 34:e5a0dcb43ecc 467 /* MCP23008 I2C portexpander internal registers */
wim 34:e5a0dcb43ecc 468 #define IODIR 0x00
wim 34:e5a0dcb43ecc 469 #define IPOL 0x01
wim 34:e5a0dcb43ecc 470 #define GPINTEN 0x02
wim 34:e5a0dcb43ecc 471 #define DEFVAL 0x03
wim 34:e5a0dcb43ecc 472 #define INTCON 0x04
wim 34:e5a0dcb43ecc 473 #define IOCON 0x05
wim 34:e5a0dcb43ecc 474 #define GPPU 0x06
wim 34:e5a0dcb43ecc 475 #define INTF 0x07
wim 34:e5a0dcb43ecc 476 #define INTCAP 0x08
wim 34:e5a0dcb43ecc 477 #define GPIO 0x09
wim 34:e5a0dcb43ecc 478 #define OLAT 0x0A
wim 34:e5a0dcb43ecc 479
wim 34:e5a0dcb43ecc 480 /* ST7032i I2C slave address */
wim 34:e5a0dcb43ecc 481 #define ST7032_SA 0x7C
wim 34:e5a0dcb43ecc 482
wim 34:e5a0dcb43ecc 483 /* ST7036i I2C slave address */
wim 34:e5a0dcb43ecc 484 #define ST7036_SA0 0x78
wim 34:e5a0dcb43ecc 485 #define ST7036_SA1 0x7A
wim 34:e5a0dcb43ecc 486 #define ST7036_SA2 0x7C
wim 34:e5a0dcb43ecc 487 #define ST7036_SA3 0x7E
wim 34:e5a0dcb43ecc 488
wim 37:ce348c002929 489 /* ST7066_ACM I2C slave address, Added for ACM1602 module */
wim 37:ce348c002929 490 #define ST7066_SA0 0xA0
wim 37:ce348c002929 491
wim 34:e5a0dcb43ecc 492 /* PCF21XX I2C slave address */
wim 34:e5a0dcb43ecc 493 #define PCF21XX_SA0 0x74
wim 34:e5a0dcb43ecc 494 #define PCF21XX_SA1 0x76
wim 34:e5a0dcb43ecc 495
wim 34:e5a0dcb43ecc 496 /* AIP31068 I2C slave address */
wim 34:e5a0dcb43ecc 497 #define AIP31068_SA 0x7C
wim 34:e5a0dcb43ecc 498
wim 34:e5a0dcb43ecc 499 /* SSD1803 I2C slave address */
wim 34:e5a0dcb43ecc 500 #define SSD1803_SA0 0x78
wim 34:e5a0dcb43ecc 501 #define SSD1803_SA1 0x7A
wim 34:e5a0dcb43ecc 502
wim 34:e5a0dcb43ecc 503 /* US2066/SSD1311 I2C slave address */
wim 34:e5a0dcb43ecc 504 #define US2066_SA0 0x78
wim 34:e5a0dcb43ecc 505 #define US2066_SA1 0x7A
wim 34:e5a0dcb43ecc 506
wim 34:e5a0dcb43ecc 507 /* AC780 I2C slave address */
wim 34:e5a0dcb43ecc 508 #define AC780_SA0 0x78
wim 34:e5a0dcb43ecc 509 #define AC780_SA1 0x7A
wim 34:e5a0dcb43ecc 510 #define AC780_SA2 0x7C
wim 34:e5a0dcb43ecc 511 #define AC780_SA3 0x7E
wim 34:e5a0dcb43ecc 512
wim 34:e5a0dcb43ecc 513 //Some native I2C controllers dont support ACK. Set define to '0' to allow code to proceed even without ACK
wim 34:e5a0dcb43ecc 514 //#define LCD_I2C_ACK 0
wim 34:e5a0dcb43ecc 515 #define LCD_I2C_ACK 1
wim 34:e5a0dcb43ecc 516
wim 34:e5a0dcb43ecc 517
wim 34:e5a0dcb43ecc 518 // Contrast setting, 6 significant bits (only supported for controllers with extended features)
wim 34:e5a0dcb43ecc 519 // Voltage Multiplier setting, 2 or 3 significant bits (only supported for controllers with extended features)
wim 34:e5a0dcb43ecc 520 #define LCD_DEF_CONTRAST 0x20
wim 34:e5a0dcb43ecc 521
wim 34:e5a0dcb43ecc 522 //ST7032 EastRising ERC1602FS-4 display
wim 34:e5a0dcb43ecc 523 //Contrast setting 6 significant bits
wim 34:e5a0dcb43ecc 524 //Voltage Multiplier setting 3 significant bits
wim 37:ce348c002929 525 #define LCD_ST7032_CONTRAST 0x28
wim 34:e5a0dcb43ecc 526 #define LCD_ST7032_RAB 0x04
wim 34:e5a0dcb43ecc 527
wim 34:e5a0dcb43ecc 528 //ST7036 EA DOGM1603 display
wim 34:e5a0dcb43ecc 529 //Contrast setting 6 significant bits
wim 34:e5a0dcb43ecc 530 //Voltage Multiplier setting 3 significant bits
wim 34:e5a0dcb43ecc 531 #define LCD_ST7036_CONTRAST 0x28
wim 34:e5a0dcb43ecc 532 #define LCD_ST7036_RAB 0x04
wim 34:e5a0dcb43ecc 533
wim 34:e5a0dcb43ecc 534 //SSD1803 EA DOGM204 display
wim 34:e5a0dcb43ecc 535 //Contrast setting 6 significant bits
wim 34:e5a0dcb43ecc 536 //Voltage Multiplier setting 3 significant bits
wim 34:e5a0dcb43ecc 537 #define LCD_SSD1_CONTRAST 0x28
wim 34:e5a0dcb43ecc 538 #define LCD_SSD1_RAB 0x06
wim 34:e5a0dcb43ecc 539
wim 34:e5a0dcb43ecc 540 //US2066/SSD1311 EastRising ER-OLEDM2002-4 display
wim 34:e5a0dcb43ecc 541 //Contrast setting 8 significant bits, use 6 for compatibility
wim 34:e5a0dcb43ecc 542 #define LCD_US20_CONTRAST 0x3F
wim 34:e5a0dcb43ecc 543 //#define LCD_US20_CONTRAST 0x1F
wim 34:e5a0dcb43ecc 544
wim 34:e5a0dcb43ecc 545 //PCF2113, PCF2119 display
wim 34:e5a0dcb43ecc 546 //Contrast setting 6 significant bits
wim 34:e5a0dcb43ecc 547 //Voltage Multiplier setting 2 significant bits
wim 34:e5a0dcb43ecc 548 #define LCD_PCF2_CONTRAST 0x20
wim 34:e5a0dcb43ecc 549 #define LCD_PCF2_S12 0x02
wim 34:e5a0dcb43ecc 550
wim 34:e5a0dcb43ecc 551 //PT6314 VFD display
wim 34:e5a0dcb43ecc 552 //Contrast setting 2 significant bits, use 6 for compatibility
wim 34:e5a0dcb43ecc 553 #define LCD_PT63_CONTRAST 0x3F
wim 34:e5a0dcb43ecc 554
wim 34:e5a0dcb43ecc 555
wim 34:e5a0dcb43ecc 556 #endif //MBED_TEXTLCDCONFIG_H