Updated for more display types. Fixed memoryaddress confusion in address() method. Added new getAddress() method. Added support for UDCs, Backlight control and other features such as control through I2C and SPI port expanders and controllers with native I2C and SPI interfaces. Refactored to fix issue with pins that are default declared as NC.

Dependents:   GPSDevice TestTextLCD SD to Flash Data Transfer DrumMachine ... more

Fork of TextLCD by Simon Ford

Example

Hello World! for the TextLCD

#include "mbed.h"
#include "TextLCD.h"
 
// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx
 
// I2C Communication
I2C i2c_lcd(p28,p27); // SDA, SCL
 
// SPI Communication
SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK

//TextLCD lcd(p15, p16, p17, p18, p19, p20);                // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780
//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4);   // SPI bus, 74595 expander, CS pin, LCD Type  
TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4);  // I2C bus, PCF8574 Slaveaddress, LCD Type
//TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type
//TextLCD_SPI_N lcd(&spi_lcd, p8, p9);               // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3   
//TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=ST7032_3V3  

int main() {
    pc.printf("LCD Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows());
    
    for (int row=0; row<lcd.rows(); row++) {
      int col=0;
      
      pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));      
//      lcd.putc('-');
      lcd.putc('0' + row);      
      
      for (col=1; col<lcd.columns()-1; col++) {    
        lcd.putc('*');
      }
 
      pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));      
      lcd.putc('+');
        
    }    
    
// Show cursor as blinking character
    lcd.setCursor(TextLCD::CurOff_BlkOn);
 
// Set and show user defined characters. A maximum of 8 UDCs are supported by the HD44780.
// They are defined by a 5x7 bitpattern. 
    lcd.setUDC(0, (char *) udc_0);  // Show |>
    lcd.putc(0);    
    lcd.setUDC(1, (char *) udc_1);  // Show <|
    lcd.putc(1);    

}

Handbook page

More info is here

Committer:
wim
Date:
Fri Oct 10 15:47:56 2014 +0000
Revision:
35:311be6444a39
Parent:
34:e5a0dcb43ecc
Child:
36:9f5f86dfd44a
Added AC780 support, added I2C expander module types, fixed setBacklight() for inverted logic I2C expander modules. Fixed bug in LCD_SPI_N define.

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