Librería para LCD

Fork of TextLCD by Wim Huiskamp

Committer:
wim
Date:
Sat Apr 18 11:33:02 2015 +0000
Revision:
38:cbe275b0b647
Parent:
37:ce348c002929
Child:
39:e9c2319de9c5
Fixed Adafruit I2C/SPI portexpander pinmappings, fixed SYDZ Backlight control

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