for

Dependents:   LV_FGSE_Controller_Interface

Committer:
wim
Date:
Sat Sep 27 12:38:27 2014 +0000
Revision:
34:e5a0dcb43ecc
Child:
35:311be6444a39
Added support for PT6314 (VFD), added setOrient() method for supported devices (eg SSD1803, US2066), added Double Height lines and 16 UDCs for supported devices. Added separate files for UDC defines and feature/footprint configuration.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 34:e5a0dcb43ecc 1 /* mbed TextLCD Library, for a 4-bit LCD based on HD44780
wim 34:e5a0dcb43ecc 2 * Copyright (c) 2014, WH
wim 34:e5a0dcb43ecc 3 * 2014, v01: WH, Extracted from TextLCD.h as of v14
wim 34:e5a0dcb43ecc 4 *
wim 34:e5a0dcb43ecc 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
wim 34:e5a0dcb43ecc 6 * of this software and associated documentation files (the "Software"), to deal
wim 34:e5a0dcb43ecc 7 * in the Software without restriction, including without limitation the rights
wim 34:e5a0dcb43ecc 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
wim 34:e5a0dcb43ecc 9 * copies of the Software, and to permit persons to whom the Software is
wim 34:e5a0dcb43ecc 10 * furnished to do so, subject to the following conditions:
wim 34:e5a0dcb43ecc 11 *
wim 34:e5a0dcb43ecc 12 * The above copyright notice and this permission notice shall be included in
wim 34:e5a0dcb43ecc 13 * all copies or substantial portions of the Software.
wim 34:e5a0dcb43ecc 14 *
wim 34:e5a0dcb43ecc 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
wim 34:e5a0dcb43ecc 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
wim 34:e5a0dcb43ecc 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
wim 34:e5a0dcb43ecc 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
wim 34:e5a0dcb43ecc 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wim 34:e5a0dcb43ecc 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
wim 34:e5a0dcb43ecc 21 * THE SOFTWARE.
wim 34:e5a0dcb43ecc 22 */
wim 34:e5a0dcb43ecc 23 #ifndef MBED_TEXTLCDCONFIG_H
wim 34:e5a0dcb43ecc 24 #define MBED_TEXTLCDCONFIG_H
wim 34:e5a0dcb43ecc 25
wim 34:e5a0dcb43ecc 26
wim 34:e5a0dcb43ecc 27 //Select hardware interface options to reduce memory footprint (multiple options allowed)
wim 34:e5a0dcb43ecc 28 #define LCD_I2C 1 /* I2C Expander PCF8574/MCP23008 */
wim 34:e5a0dcb43ecc 29 #define LCD_SPI 1 /* SPI Expander SN74595 */
wim 34:e5a0dcb43ecc 30 #define LCD_I2C_N 1 /* Native I2C bus */
wim 34:e5a0dcb43ecc 31 #define LCD_SPI_N_3_9 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 32 #define LCD_SPI_N_3_10 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 33 #define LCD_SPI_N_3_16 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 34 #define LCD_SPI_N_3_24 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 35 #define LCD_SPI_N_4 1 /* Native SPI bus */
wim 34:e5a0dcb43ecc 36
wim 34:e5a0dcb43ecc 37 //Select options to reduce memory footprint (multiple options allowed)
wim 34:e5a0dcb43ecc 38 #define LCD_UDC 1 /* Enable predefined UDC example*/
wim 34:e5a0dcb43ecc 39 #define LCD_PRINTF 1 /* Enable Stream implementation */
wim 34:e5a0dcb43ecc 40
wim 34:e5a0dcb43ecc 41 //Pin Defines for I2C PCF8574/PCF8574A or MCP23008 and SPI 74595 bus expander interfaces
wim 34:e5a0dcb43ecc 42 //LCD and serial portexpanders should be wired accordingly
wim 34:e5a0dcb43ecc 43 //
wim 34:e5a0dcb43ecc 44 //Select Hardware module (one option only)
wim 34:e5a0dcb43ecc 45 #define DEFAULT 1
wim 34:e5a0dcb43ecc 46 #define ADAFRUIT 0
wim 34:e5a0dcb43ecc 47 #define DFROBOT 0
wim 34:e5a0dcb43ecc 48
wim 34:e5a0dcb43ecc 49 //Select Hardware module (one option only)
wim 34:e5a0dcb43ecc 50 #if (DEFAULT==1)
wim 34:e5a0dcb43ecc 51 //Definitions for default (WH) mapping between serial port expander pins and LCD controller
wim 34:e5a0dcb43ecc 52 //This hardware supports the I2C bus expander (PCF8574/PCF8574A or MCP23008) and SPI bus expander (74595) interfaces
wim 34:e5a0dcb43ecc 53 //See https://mbed.org/cookbook/Text-LCD-Enhanced
wim 34:e5a0dcb43ecc 54 //
wim 34:e5a0dcb43ecc 55 //Note: LCD RW pin must be connected to GND
wim 34:e5a0dcb43ecc 56 // E2 is used for LCD40x4 (second controller)
wim 34:e5a0dcb43ecc 57 // BL may be used to control backlight
wim 34:e5a0dcb43ecc 58 #define D_LCD_PIN_D4 0
wim 34:e5a0dcb43ecc 59 #define D_LCD_PIN_D5 1
wim 34:e5a0dcb43ecc 60 #define D_LCD_PIN_D6 2
wim 34:e5a0dcb43ecc 61 #define D_LCD_PIN_D7 3
wim 34:e5a0dcb43ecc 62 #define D_LCD_PIN_RS 4
wim 34:e5a0dcb43ecc 63 #define D_LCD_PIN_E 5
wim 34:e5a0dcb43ecc 64 #define D_LCD_PIN_E2 6
wim 34:e5a0dcb43ecc 65 #define D_LCD_PIN_BL 7
wim 34:e5a0dcb43ecc 66
wim 34:e5a0dcb43ecc 67 #define D_LCD_PIN_RW D_LCD_PIN_E2
wim 34:e5a0dcb43ecc 68
wim 34:e5a0dcb43ecc 69 //Select I2C Portexpander type (one option only)
wim 34:e5a0dcb43ecc 70 #define PCF8574 1
wim 34:e5a0dcb43ecc 71 #define MCP23008 0
wim 34:e5a0dcb43ecc 72 #endif
wim 34:e5a0dcb43ecc 73
wim 34:e5a0dcb43ecc 74 #if (ADAFRUIT==1)
wim 34:e5a0dcb43ecc 75 //Definitions for Adafruit i2cspilcdbackpack mapping between serial port expander pins and LCD controller
wim 34:e5a0dcb43ecc 76 //This hardware supports both an I2C expander (MCP23008) and an SPI expander (74595) selectable by a jumper.
wim 34:e5a0dcb43ecc 77 //See http://www.ladyada.net/products/i2cspilcdbackpack
wim 34:e5a0dcb43ecc 78 //
wim 34:e5a0dcb43ecc 79 //Note: LCD RW pin must be kept LOW
wim 34:e5a0dcb43ecc 80 // E2 is not available on this hardware and so it does not support LCD40x4 (second controller)
wim 34:e5a0dcb43ecc 81 // BL is used to control backlight
wim 34:e5a0dcb43ecc 82 #define D_LCD_PIN_0 0
wim 34:e5a0dcb43ecc 83 #define D_LCD_PIN_RS 1
wim 34:e5a0dcb43ecc 84 #define D_LCD_PIN_E 2
wim 34:e5a0dcb43ecc 85 #define D_LCD_PIN_D4 3
wim 34:e5a0dcb43ecc 86 #define D_LCD_PIN_D5 4
wim 34:e5a0dcb43ecc 87 #define D_LCD_PIN_D6 5
wim 34:e5a0dcb43ecc 88 #define D_LCD_PIN_D7 6
wim 34:e5a0dcb43ecc 89 #define D_LCD_PIN_BL 7
wim 34:e5a0dcb43ecc 90
wim 34:e5a0dcb43ecc 91 #define D_LCD_PIN_E2 D_LCD_PIN_0
wim 34:e5a0dcb43ecc 92
wim 34:e5a0dcb43ecc 93 //Force I2C portexpander type
wim 34:e5a0dcb43ecc 94 #define PCF8574 0
wim 34:e5a0dcb43ecc 95 #define MCP23008 1
wim 34:e5a0dcb43ecc 96 #endif
wim 34:e5a0dcb43ecc 97
wim 34:e5a0dcb43ecc 98 #if (DFROBOT==1)
wim 34:e5a0dcb43ecc 99 //Definitions for DFROBOT LCD2004 Module mapping between serial port expander pins and LCD controller
wim 34:e5a0dcb43ecc 100 //This hardware uses PCF8574 and is different from earlier/different Arduino I2C LCD displays
wim 34:e5a0dcb43ecc 101 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C
wim 34:e5a0dcb43ecc 102 //
wim 34:e5a0dcb43ecc 103 //Note: LCD RW pin must be kept LOW
wim 34:e5a0dcb43ecc 104 // E2 is not available on default Arduino hardware and so it does not support LCD40x4 (second controller)
wim 34:e5a0dcb43ecc 105 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight()
wim 34:e5a0dcb43ecc 106 #define D_LCD_PIN_RS 0
wim 34:e5a0dcb43ecc 107 #define D_LCD_PIN_RW 1
wim 34:e5a0dcb43ecc 108 #define D_LCD_PIN_E 2
wim 34:e5a0dcb43ecc 109 #define D_LCD_PIN_BL 3
wim 34:e5a0dcb43ecc 110 #define D_LCD_PIN_D4 4
wim 34:e5a0dcb43ecc 111 #define D_LCD_PIN_D5 5
wim 34:e5a0dcb43ecc 112 #define D_LCD_PIN_D6 6
wim 34:e5a0dcb43ecc 113 #define D_LCD_PIN_D7 7
wim 34:e5a0dcb43ecc 114
wim 34:e5a0dcb43ecc 115 #define D_LCD_PIN_E2 D_LCD_PIN_RW
wim 34:e5a0dcb43ecc 116
wim 34:e5a0dcb43ecc 117 //Force I2C portexpander type
wim 34:e5a0dcb43ecc 118 #define PCF8574 1
wim 34:e5a0dcb43ecc 119 #define MCP23008 0
wim 34:e5a0dcb43ecc 120 #endif
wim 34:e5a0dcb43ecc 121
wim 34:e5a0dcb43ecc 122
wim 34:e5a0dcb43ecc 123 //Bitpattern Defines for I2C PCF8574/PCF8574A, MCP23008 and SPI 74595 Bus expanders
wim 34:e5a0dcb43ecc 124 //
wim 34:e5a0dcb43ecc 125 #define D_LCD_D4 (1<<D_LCD_PIN_D4)
wim 34:e5a0dcb43ecc 126 #define D_LCD_D5 (1<<D_LCD_PIN_D5)
wim 34:e5a0dcb43ecc 127 #define D_LCD_D6 (1<<D_LCD_PIN_D6)
wim 34:e5a0dcb43ecc 128 #define D_LCD_D7 (1<<D_LCD_PIN_D7)
wim 34:e5a0dcb43ecc 129 #define D_LCD_RS (1<<D_LCD_PIN_RS)
wim 34:e5a0dcb43ecc 130 #define D_LCD_E (1<<D_LCD_PIN_E)
wim 34:e5a0dcb43ecc 131 #define D_LCD_E2 (1<<D_LCD_PIN_E2)
wim 34:e5a0dcb43ecc 132 #define D_LCD_BL (1<<D_LCD_PIN_BL)
wim 34:e5a0dcb43ecc 133 //#define D_LCD_RW (1<<D_LCD_PIN_RW)
wim 34:e5a0dcb43ecc 134
wim 34:e5a0dcb43ecc 135 #define D_LCD_BUS_MSK (D_LCD_D4 | D_LCD_D5 | D_LCD_D6 | D_LCD_D7)
wim 34:e5a0dcb43ecc 136 #define D_LCD_BUS_DEF 0x00
wim 34:e5a0dcb43ecc 137
wim 34:e5a0dcb43ecc 138 /* PCF8574/PCF8574A I2C portexpander slave address */
wim 34:e5a0dcb43ecc 139 #define PCF8574_SA0 0x40
wim 34:e5a0dcb43ecc 140 #define PCF8574_SA1 0x42
wim 34:e5a0dcb43ecc 141 #define PCF8574_SA2 0x44
wim 34:e5a0dcb43ecc 142 #define PCF8574_SA3 0x46
wim 34:e5a0dcb43ecc 143 #define PCF8574_SA4 0x48
wim 34:e5a0dcb43ecc 144 #define PCF8574_SA5 0x4A
wim 34:e5a0dcb43ecc 145 #define PCF8574_SA6 0x4C
wim 34:e5a0dcb43ecc 146 #define PCF8574_SA7 0x4E
wim 34:e5a0dcb43ecc 147
wim 34:e5a0dcb43ecc 148 #define PCF8574A_SA0 0x70
wim 34:e5a0dcb43ecc 149 #define PCF8574A_SA1 0x72
wim 34:e5a0dcb43ecc 150 #define PCF8574A_SA2 0x74
wim 34:e5a0dcb43ecc 151 #define PCF8574A_SA3 0x76
wim 34:e5a0dcb43ecc 152 #define PCF8574A_SA4 0x78
wim 34:e5a0dcb43ecc 153 #define PCF8574A_SA5 0x7A
wim 34:e5a0dcb43ecc 154 #define PCF8574A_SA6 0x7C
wim 34:e5a0dcb43ecc 155 #define PCF8574A_SA7 0x7E
wim 34:e5a0dcb43ecc 156
wim 34:e5a0dcb43ecc 157 /* MCP23008 I2C portexpander slave address */
wim 34:e5a0dcb43ecc 158 #define MCP23008_SA0 0x40
wim 34:e5a0dcb43ecc 159 #define MCP23008_SA1 0x42
wim 34:e5a0dcb43ecc 160 #define MCP23008_SA2 0x44
wim 34:e5a0dcb43ecc 161 #define MCP23008_SA3 0x46
wim 34:e5a0dcb43ecc 162 #define MCP23008_SA4 0x48
wim 34:e5a0dcb43ecc 163 #define MCP23008_SA5 0x4A
wim 34:e5a0dcb43ecc 164 #define MCP23008_SA6 0x4C
wim 34:e5a0dcb43ecc 165 #define MCP23008_SA7 0x4E
wim 34:e5a0dcb43ecc 166
wim 34:e5a0dcb43ecc 167 /* MCP23008 I2C portexpander internal registers */
wim 34:e5a0dcb43ecc 168 #define IODIR 0x00
wim 34:e5a0dcb43ecc 169 #define IPOL 0x01
wim 34:e5a0dcb43ecc 170 #define GPINTEN 0x02
wim 34:e5a0dcb43ecc 171 #define DEFVAL 0x03
wim 34:e5a0dcb43ecc 172 #define INTCON 0x04
wim 34:e5a0dcb43ecc 173 #define IOCON 0x05
wim 34:e5a0dcb43ecc 174 #define GPPU 0x06
wim 34:e5a0dcb43ecc 175 #define INTF 0x07
wim 34:e5a0dcb43ecc 176 #define INTCAP 0x08
wim 34:e5a0dcb43ecc 177 #define GPIO 0x09
wim 34:e5a0dcb43ecc 178 #define OLAT 0x0A
wim 34:e5a0dcb43ecc 179
wim 34:e5a0dcb43ecc 180 /* ST7032i I2C slave address */
wim 34:e5a0dcb43ecc 181 #define ST7032_SA 0x7C
wim 34:e5a0dcb43ecc 182
wim 34:e5a0dcb43ecc 183 /* ST7036i I2C slave address */
wim 34:e5a0dcb43ecc 184 #define ST7036_SA0 0x78
wim 34:e5a0dcb43ecc 185 #define ST7036_SA1 0x7A
wim 34:e5a0dcb43ecc 186 #define ST7036_SA2 0x7C
wim 34:e5a0dcb43ecc 187 #define ST7036_SA3 0x7E
wim 34:e5a0dcb43ecc 188
wim 34:e5a0dcb43ecc 189 /* PCF21XX I2C slave address */
wim 34:e5a0dcb43ecc 190 #define PCF21XX_SA0 0x74
wim 34:e5a0dcb43ecc 191 #define PCF21XX_SA1 0x76
wim 34:e5a0dcb43ecc 192
wim 34:e5a0dcb43ecc 193 /* AIP31068 I2C slave address */
wim 34:e5a0dcb43ecc 194 #define AIP31068_SA 0x7C
wim 34:e5a0dcb43ecc 195
wim 34:e5a0dcb43ecc 196 /* SSD1803 I2C slave address */
wim 34:e5a0dcb43ecc 197 #define SSD1803_SA0 0x78
wim 34:e5a0dcb43ecc 198 #define SSD1803_SA1 0x7A
wim 34:e5a0dcb43ecc 199
wim 34:e5a0dcb43ecc 200 /* US2066/SSD1311 I2C slave address */
wim 34:e5a0dcb43ecc 201 #define US2066_SA0 0x78
wim 34:e5a0dcb43ecc 202 #define US2066_SA1 0x7A
wim 34:e5a0dcb43ecc 203
wim 34:e5a0dcb43ecc 204 /* AC780 I2C slave address */
wim 34:e5a0dcb43ecc 205 #define AC780_SA0 0x78
wim 34:e5a0dcb43ecc 206 #define AC780_SA1 0x7A
wim 34:e5a0dcb43ecc 207 #define AC780_SA2 0x7C
wim 34:e5a0dcb43ecc 208 #define AC780_SA3 0x7E
wim 34:e5a0dcb43ecc 209
wim 34:e5a0dcb43ecc 210 //Some native I2C controllers dont support ACK. Set define to '0' to allow code to proceed even without ACK
wim 34:e5a0dcb43ecc 211 //#define LCD_I2C_ACK 0
wim 34:e5a0dcb43ecc 212 #define LCD_I2C_ACK 1
wim 34:e5a0dcb43ecc 213
wim 34:e5a0dcb43ecc 214
wim 34:e5a0dcb43ecc 215 // Contrast setting, 6 significant bits (only supported for controllers with extended features)
wim 34:e5a0dcb43ecc 216 // Voltage Multiplier setting, 2 or 3 significant bits (only supported for controllers with extended features)
wim 34:e5a0dcb43ecc 217 #define LCD_DEF_CONTRAST 0x20
wim 34:e5a0dcb43ecc 218
wim 34:e5a0dcb43ecc 219 //ST7032 EastRising ERC1602FS-4 display
wim 34:e5a0dcb43ecc 220 //Contrast setting 6 significant bits
wim 34:e5a0dcb43ecc 221 //Voltage Multiplier setting 3 significant bits
wim 34:e5a0dcb43ecc 222 #define LCD_ST7032_CONTRAST 0x18
wim 34:e5a0dcb43ecc 223 #define LCD_ST7032_RAB 0x04
wim 34:e5a0dcb43ecc 224
wim 34:e5a0dcb43ecc 225 //ST7036 EA DOGM1603 display
wim 34:e5a0dcb43ecc 226 //Contrast setting 6 significant bits
wim 34:e5a0dcb43ecc 227 //Voltage Multiplier setting 3 significant bits
wim 34:e5a0dcb43ecc 228 #define LCD_ST7036_CONTRAST 0x28
wim 34:e5a0dcb43ecc 229 #define LCD_ST7036_RAB 0x04
wim 34:e5a0dcb43ecc 230
wim 34:e5a0dcb43ecc 231 //SSD1803 EA DOGM204 display
wim 34:e5a0dcb43ecc 232 //Contrast setting 6 significant bits
wim 34:e5a0dcb43ecc 233 //Voltage Multiplier setting 3 significant bits
wim 34:e5a0dcb43ecc 234 #define LCD_SSD1_CONTRAST 0x28
wim 34:e5a0dcb43ecc 235 #define LCD_SSD1_RAB 0x06
wim 34:e5a0dcb43ecc 236
wim 34:e5a0dcb43ecc 237 //US2066/SSD1311 EastRising ER-OLEDM2002-4 display
wim 34:e5a0dcb43ecc 238 //Contrast setting 8 significant bits, use 6 for compatibility
wim 34:e5a0dcb43ecc 239 #define LCD_US20_CONTRAST 0x3F
wim 34:e5a0dcb43ecc 240 //#define LCD_US20_CONTRAST 0x1F
wim 34:e5a0dcb43ecc 241
wim 34:e5a0dcb43ecc 242 //PCF2113, PCF2119 display
wim 34:e5a0dcb43ecc 243 //Contrast setting 6 significant bits
wim 34:e5a0dcb43ecc 244 //Voltage Multiplier setting 2 significant bits
wim 34:e5a0dcb43ecc 245 #define LCD_PCF2_CONTRAST 0x20
wim 34:e5a0dcb43ecc 246 #define LCD_PCF2_S12 0x02
wim 34:e5a0dcb43ecc 247
wim 34:e5a0dcb43ecc 248 //PT6314 VFD display
wim 34:e5a0dcb43ecc 249 //Contrast setting 2 significant bits, use 6 for compatibility
wim 34:e5a0dcb43ecc 250 #define LCD_PT63_CONTRAST 0x3F
wim 34:e5a0dcb43ecc 251
wim 34:e5a0dcb43ecc 252
wim 34:e5a0dcb43ecc 253 #endif //MBED_TEXTLCDCONFIG_H