i2c'li lcd ekran Mehmet Akif ARVAS

Committer:
wim
Date:
Fri Jun 13 19:02:26 2014 +0000
Revision:
27:22d5086f6ba6
Parent:
26:bd897a001012
Child:
28:30fa94f7341c
First test of native SPI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 1:ac48b187213c 1 /* mbed TextLCD Library, for a 4-bit LCD based on HD44780
simon 6:e4cb7ddee0d3 2 * Copyright (c) 2007-2010, sford, http://mbed.org
wim 13:24506ba22480 3 * 2013, v01: WH, Added LCD types, fixed LCD address issues, added Cursor and UDCs
wim 15:b70ebfffb258 4 * 2013, v02: WH, Added I2C and SPI bus interfaces
wim 15:b70ebfffb258 5 * 2013, v03: WH, Added support for LCD40x4 which uses 2 controllers
wim 17:652ab113bc2e 6 * 2013, v04: WH, Added support for Display On/Off, improved 4bit bootprocess
wim 18:bd65dc10f27f 7 * 2013, v05: WH, Added support for 8x2B, added some UDCs
wim 19:c747b9e2e7b8 8 * 2013, v06: WH, Added support for devices that use internal DC/DC converters
wim 20:e0da005a777f 9 * 2013, v07: WH, Added support for backlight and include portdefinitions for LCD2004 Module from DFROBOT
wim 21:9eb628d9e164 10 * 2014, v08: WH, Refactored in Base and Derived Classes to deal with mbed lib change regarding 'NC' defined DigitalOut pins
wim 25:6162b31128c9 11 * 2014, v09: WH/EO, Added Class for Native SPI controllers such as ST7032
wim 26:bd897a001012 12 * 2014, v10: WH, Added Class for Native I2C controllers such as ST7032i, Added support for MCP23008 I2C portexpander, Added support for Adafruit module
simon 1:ac48b187213c 13 *
simon 1:ac48b187213c 14 * Permission is hereby granted, free of charge, to any person obtaining a copy
simon 1:ac48b187213c 15 * of this software and associated documentation files (the "Software"), to deal
simon 1:ac48b187213c 16 * in the Software without restriction, including without limitation the rights
simon 1:ac48b187213c 17 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
simon 1:ac48b187213c 18 * copies of the Software, and to permit persons to whom the Software is
simon 1:ac48b187213c 19 * furnished to do so, subject to the following conditions:
simon 2:227356c7d12c 20 *
simon 1:ac48b187213c 21 * The above copyright notice and this permission notice shall be included in
simon 1:ac48b187213c 22 * all copies or substantial portions of the Software.
simon 2:227356c7d12c 23 *
simon 1:ac48b187213c 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
simon 1:ac48b187213c 25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
simon 1:ac48b187213c 26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
simon 1:ac48b187213c 27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
simon 1:ac48b187213c 28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 1:ac48b187213c 29 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
simon 1:ac48b187213c 30 * THE SOFTWARE.
simon 1:ac48b187213c 31 */
simon 1:ac48b187213c 32
simon 1:ac48b187213c 33 #ifndef MBED_TEXTLCD_H
simon 1:ac48b187213c 34 #define MBED_TEXTLCD_H
simon 1:ac48b187213c 35
simon 1:ac48b187213c 36 #include "mbed.h"
simon 2:227356c7d12c 37
simon 5:a53b3e2d6f1e 38 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
simon 2:227356c7d12c 39 *
wim 16:c276b75e6585 40 * Currently supports 8x1, 8x2, 12x4, 16x1, 16x2, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels
wim 27:22d5086f6ba6 41 * Interface options include direct mbed pins, I2C portexpander (PCF8474/PCF8574A or MCP23008) or SPI bus shiftregister (74595).
wim 27:22d5086f6ba6 42 * Supports some controllers with native I2C or SP interface. Supports some controllers that provide internal DC/DC converters for VLCD or VLED.
simon 2:227356c7d12c 43 *
simon 2:227356c7d12c 44 * @code
simon 2:227356c7d12c 45 * #include "mbed.h"
simon 2:227356c7d12c 46 * #include "TextLCD.h"
simon 5:a53b3e2d6f1e 47 *
wim 16:c276b75e6585 48 * // I2C Communication
wim 16:c276b75e6585 49 * I2C i2c_lcd(p28,p27); // SDA, SCL
wim 16:c276b75e6585 50 *
wim 16:c276b75e6585 51 * // SPI Communication
wim 16:c276b75e6585 52 * SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK
wim 16:c276b75e6585 53 *
wim 22:35742ec80c24 54 * //TextLCD lcd(p15, p16, p17, p18, p19, p20); // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780
wim 22:35742ec80c24 55 * //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type
wim 22:35742ec80c24 56 * TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type
wim 21:9eb628d9e164 57 * //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type
wim 27:22d5086f6ba6 58 * //TextLCD_SPI_N lcd(&spi_lcd, p8, p9); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3
simon 5:a53b3e2d6f1e 59 *
simon 2:227356c7d12c 60 * int main() {
wim 16:c276b75e6585 61 * lcd.printf("Hello World!\n");
simon 2:227356c7d12c 62 * }
simon 2:227356c7d12c 63 * @endcode
simon 2:227356c7d12c 64 */
wim 8:03116f75b66e 65
wim 26:bd897a001012 66
wim 26:bd897a001012 67 //Pin Defines for I2C PCF8574/PCF8574A or MCP23008 and SPI 74595 bus expander interfaces
wim 13:24506ba22480 68 //LCD and serial portexpanders should be wired accordingly
wim 20:e0da005a777f 69 //
wim 26:bd897a001012 70 //Select Hardware module (one option only)
wim 27:22d5086f6ba6 71 #define DEFAULT 0
wim 27:22d5086f6ba6 72 #define ADAFRUIT 1
wim 26:bd897a001012 73 #define DFROBOT 0
wim 26:bd897a001012 74
wim 26:bd897a001012 75
wim 26:bd897a001012 76 #if (DEFAULT==1)
wim 20:e0da005a777f 77 //Definitions for hardware used by WH
wim 26:bd897a001012 78 //This hardware supports the I2C bus expander (PCF8574/PCF8574A or MCP23008) and SPI bus expander (74595) interfaces
wim 26:bd897a001012 79 //
wim 13:24506ba22480 80 //Note: LCD RW pin must be connected to GND
wim 15:b70ebfffb258 81 // E2 is used for LCD40x4 (second controller)
wim 26:bd897a001012 82 // BL may be used to control backlight
wim 15:b70ebfffb258 83 #define D_LCD_PIN_D4 0
wim 15:b70ebfffb258 84 #define D_LCD_PIN_D5 1
wim 15:b70ebfffb258 85 #define D_LCD_PIN_D6 2
wim 15:b70ebfffb258 86 #define D_LCD_PIN_D7 3
wim 15:b70ebfffb258 87 #define D_LCD_PIN_RS 4
wim 15:b70ebfffb258 88 #define D_LCD_PIN_E 5
wim 15:b70ebfffb258 89 #define D_LCD_PIN_E2 6
wim 15:b70ebfffb258 90 #define D_LCD_PIN_BL 7
wim 13:24506ba22480 91
wim 20:e0da005a777f 92 #define D_LCD_PIN_RW D_LCD_PIN_E2
wim 20:e0da005a777f 93
wim 26:bd897a001012 94 //Select I2C Portexpander type (one option only)
wim 26:bd897a001012 95 #define PCF8574 1
wim 26:bd897a001012 96 #define MCP23008 0
wim 26:bd897a001012 97 #endif
wim 20:e0da005a777f 98
wim 26:bd897a001012 99 #if (ADAFRUIT==1)
wim 26:bd897a001012 100 //Definitions for i2cspilcdbackpack from Adafruit, See http://www.ladyada.net/products/i2cspilcdbackpack
wim 26:bd897a001012 101 //This hardware supports both an I2C expander (MCP23008) and an SPI expander (74595) selectable by a jumper.
wim 26:bd897a001012 102 //
wim 26:bd897a001012 103 //Note: LCD RW pin must be kept LOW
wim 26:bd897a001012 104 // E2 is not available on this hardware and so it does not support LCD40x4 (second controller)
wim 26:bd897a001012 105 // BL is used to control backlight
wim 26:bd897a001012 106 #define D_LCD_PIN_0 0
wim 26:bd897a001012 107 #define D_LCD_PIN_RS 1
wim 26:bd897a001012 108 #define D_LCD_PIN_E 2
wim 26:bd897a001012 109 #define D_LCD_PIN_D4 3
wim 26:bd897a001012 110 #define D_LCD_PIN_D5 4
wim 26:bd897a001012 111 #define D_LCD_PIN_D6 5
wim 26:bd897a001012 112 #define D_LCD_PIN_D7 6
wim 26:bd897a001012 113 #define D_LCD_PIN_BL 7
wim 26:bd897a001012 114
wim 26:bd897a001012 115 #define D_LCD_PIN_E2 D_LCD_PIN_0
wim 26:bd897a001012 116
wim 26:bd897a001012 117 //Force I2C portexpander type
wim 26:bd897a001012 118 #define PCF8574 0
wim 26:bd897a001012 119 #define MCP23008 1
wim 26:bd897a001012 120 #endif
wim 26:bd897a001012 121
wim 26:bd897a001012 122 #if (DFROBOT==1)
wim 20:e0da005a777f 123 //Definitions for LCD2004 Module from DFROBOT, See http://arduino-info.wikispaces.com/LCD-Blue-I2C
wim 26:bd897a001012 124 //This hardware uses PCF8574 and is different from earlier/different Arduino I2C LCD displays
wim 26:bd897a001012 125 //
wim 20:e0da005a777f 126 //Note: LCD RW pin must be kept LOW
wim 26:bd897a001012 127 // E2 is not available on default Arduino hardware and so it does not support LCD40x4 (second controller)
wim 20:e0da005a777f 128 // BL is used to control backlight
wim 20:e0da005a777f 129 #define D_LCD_PIN_RS 0
wim 20:e0da005a777f 130 #define D_LCD_PIN_RW 1
wim 20:e0da005a777f 131 #define D_LCD_PIN_E 2
wim 20:e0da005a777f 132 #define D_LCD_PIN_BL 3
wim 20:e0da005a777f 133 #define D_LCD_PIN_D4 4
wim 20:e0da005a777f 134 #define D_LCD_PIN_D5 5
wim 20:e0da005a777f 135 #define D_LCD_PIN_D6 6
wim 20:e0da005a777f 136 #define D_LCD_PIN_D7 7
wim 20:e0da005a777f 137
wim 20:e0da005a777f 138 #define D_LCD_PIN_E2 D_LCD_PIN_RW
wim 26:bd897a001012 139
wim 26:bd897a001012 140 //Force I2C portexpander type
wim 26:bd897a001012 141 #define PCF8574 1
wim 26:bd897a001012 142 #define MCP23008 0
wim 20:e0da005a777f 143 #endif
wim 13:24506ba22480 144
wim 26:bd897a001012 145 //Bitpattern Defines for I2C PCF8574/PCF8574A, MCP23008 and SPI 74595 Bus expanders
wim 13:24506ba22480 146 //
wim 13:24506ba22480 147 #define D_LCD_D4 (1<<D_LCD_PIN_D4)
wim 13:24506ba22480 148 #define D_LCD_D5 (1<<D_LCD_PIN_D5)
wim 13:24506ba22480 149 #define D_LCD_D6 (1<<D_LCD_PIN_D6)
wim 13:24506ba22480 150 #define D_LCD_D7 (1<<D_LCD_PIN_D7)
wim 13:24506ba22480 151 #define D_LCD_RS (1<<D_LCD_PIN_RS)
wim 13:24506ba22480 152 #define D_LCD_E (1<<D_LCD_PIN_E)
wim 13:24506ba22480 153 #define D_LCD_E2 (1<<D_LCD_PIN_E2)
wim 13:24506ba22480 154 #define D_LCD_BL (1<<D_LCD_PIN_BL)
wim 20:e0da005a777f 155 //#define D_LCD_RW (1<<D_LCD_PIN_RW)
wim 20:e0da005a777f 156
wim 20:e0da005a777f 157 #define D_LCD_BUS_MSK (D_LCD_D4 | D_LCD_D5 | D_LCD_D6 | D_LCD_D7)
wim 20:e0da005a777f 158 #define D_LCD_BUS_DEF 0x00
wim 13:24506ba22480 159
wim 26:bd897a001012 160 /* PCF8574/PCF8574A I2C portexpander slave address */
wim 26:bd897a001012 161 #define PCF8574_SA0 0x40
wim 26:bd897a001012 162 #define PCF8574_SA1 0x42
wim 26:bd897a001012 163 #define PCF8574_SA2 0x44
wim 26:bd897a001012 164 #define PCF8574_SA3 0x46
wim 26:bd897a001012 165 #define PCF8574_SA4 0x48
wim 26:bd897a001012 166 #define PCF8574_SA5 0x4A
wim 26:bd897a001012 167 #define PCF8574_SA6 0x4C
wim 26:bd897a001012 168 #define PCF8574_SA7 0x4E
wim 26:bd897a001012 169
wim 26:bd897a001012 170 #define PCF8574A_SA0 0x70
wim 26:bd897a001012 171 #define PCF8574A_SA1 0x72
wim 26:bd897a001012 172 #define PCF8574A_SA2 0x74
wim 26:bd897a001012 173 #define PCF8574A_SA3 0x76
wim 26:bd897a001012 174 #define PCF8574A_SA4 0x78
wim 26:bd897a001012 175 #define PCF8574A_SA5 0x7A
wim 26:bd897a001012 176 #define PCF8574A_SA6 0x7C
wim 26:bd897a001012 177 #define PCF8574A_SA7 0x7E
wim 26:bd897a001012 178
wim 26:bd897a001012 179 /* MCP23008 I2C portexpander slave address */
wim 26:bd897a001012 180 #define MCP23008_SA0 0x40
wim 26:bd897a001012 181 #define MCP23008_SA1 0x42
wim 26:bd897a001012 182 #define MCP23008_SA2 0x44
wim 26:bd897a001012 183 #define MCP23008_SA3 0x46
wim 26:bd897a001012 184 #define MCP23008_SA4 0x48
wim 26:bd897a001012 185 #define MCP23008_SA5 0x4A
wim 26:bd897a001012 186 #define MCP23008_SA6 0x4C
wim 26:bd897a001012 187 #define MCP23008_SA7 0x4E
wim 26:bd897a001012 188
wim 26:bd897a001012 189
wim 26:bd897a001012 190 /* MCP23008 I2C portexpander internal registers */
wim 26:bd897a001012 191 #define IODIR 0x00
wim 26:bd897a001012 192 #define IPOL 0x01
wim 26:bd897a001012 193 #define GPINTEN 0x02
wim 26:bd897a001012 194 #define DEFVAL 0x03
wim 26:bd897a001012 195 #define INTCON 0x04
wim 26:bd897a001012 196 #define IOCON 0x05
wim 26:bd897a001012 197 #define GPPU 0x06
wim 26:bd897a001012 198 #define INTF 0x07
wim 26:bd897a001012 199 #define INTCAP 0x08
wim 26:bd897a001012 200 #define GPIO 0x09
wim 26:bd897a001012 201 #define OLAT 0x0A
wim 26:bd897a001012 202
wim 26:bd897a001012 203
wim 26:bd897a001012 204 /* ST7032I I2C slave address */
wim 26:bd897a001012 205 #define ST7032_SA 0x7C
wim 26:bd897a001012 206
wim 13:24506ba22480 207
wim 13:24506ba22480 208 /** Some sample User Defined Chars 5x7 dots */
wim 11:9ec02df863a1 209 const char udc_ae[] = {0x00, 0x00, 0x1B, 0x05, 0x1F, 0x14, 0x1F, 0x00}; //æ
wim 11:9ec02df863a1 210 const char udc_0e[] = {0x00, 0x00, 0x0E, 0x13, 0x15, 0x19, 0x0E, 0x00}; //ø
wim 11:9ec02df863a1 211 const char udc_ao[] = {0x0E, 0x0A, 0x0E, 0x01, 0x0F, 0x11, 0x0F, 0x00}; //å
wim 11:9ec02df863a1 212 const char udc_AE[] = {0x0F, 0x14, 0x14, 0x1F, 0x14, 0x14, 0x17, 0x00}; //Æ
wim 11:9ec02df863a1 213 const char udc_0E[] = {0x0E, 0x13, 0x15, 0x15, 0x15, 0x19, 0x0E, 0x00}; //Ø
wim 18:bd65dc10f27f 214 const char udc_Ao[] = {0x0E, 0x0A, 0x0E, 0x11, 0x1F, 0x11, 0x11, 0x00}; //Å
wim 18:bd65dc10f27f 215 const char udc_PO[] = {0x04, 0x0A, 0x0A, 0x1F, 0x1B, 0x1B, 0x1F, 0x00}; //Padlock Open
wim 18:bd65dc10f27f 216 const char udc_PC[] = {0x1C, 0x10, 0x08, 0x1F, 0x1B, 0x1B, 0x1F, 0x00}; //Padlock Closed
wim 11:9ec02df863a1 217
wim 11:9ec02df863a1 218 const char udc_0[] = {0x18, 0x14, 0x12, 0x11, 0x12, 0x14, 0x18, 0x00}; // |>
wim 11:9ec02df863a1 219 const char udc_1[] = {0x03, 0x05, 0x09, 0x11, 0x09, 0x05, 0x03, 0x00}; // <|
wim 11:9ec02df863a1 220 const char udc_2[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00}; // |
wim 11:9ec02df863a1 221 const char udc_3[] = {0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00}; // ||
wim 11:9ec02df863a1 222 const char udc_4[] = {0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00}; // |||
wim 11:9ec02df863a1 223 const char udc_5[] = {0x00, 0x1f, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00}; // =
wim 11:9ec02df863a1 224 const char udc_6[] = {0x15, 0x0a, 0x15, 0x0a, 0x15, 0x0a, 0x15, 0x00}; // checkerboard
wim 11:9ec02df863a1 225 const char udc_7[] = {0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x10, 0x00}; // \
wim 11:9ec02df863a1 226
wim 13:24506ba22480 227 const char udc_degr[] = {0x06, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00}; // Degree symbol
wim 13:24506ba22480 228
wim 13:24506ba22480 229 const char udc_TM_T[] = {0x1F, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; // Trademark T
wim 13:24506ba22480 230 const char udc_TM_M[] = {0x11, 0x1B, 0x15, 0x11, 0x00, 0x00, 0x00, 0x00}; // Trademark M
wim 13:24506ba22480 231
wim 13:24506ba22480 232 //const char udc_Bat_Hi[] = {0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Full
wim 13:24506ba22480 233 //const char udc_Bat_Ha[] = {0x0E, 0x11, 0x13, 0x17, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Half
wim 13:24506ba22480 234 //const char udc_Bat_Lo[] = {0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x00}; // Battery Low
wim 13:24506ba22480 235 const char udc_Bat_Hi[] = {0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Full
wim 13:24506ba22480 236 const char udc_Bat_Ha[] = {0x0E, 0x11, 0x11, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Half
wim 13:24506ba22480 237 const char udc_Bat_Lo[] = {0x0E, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x1F, 0x00}; // Battery Low
wim 18:bd65dc10f27f 238 const char udc_AC[] = {0x0A, 0x0A, 0x1F, 0x11, 0x0E, 0x04, 0x04, 0x00}; // AC Power
wim 13:24506ba22480 239
wim 18:bd65dc10f27f 240 //const char udc_smiley[] = {0x00, 0x0A, 0x00, 0x04, 0x11, 0x0E, 0x00, 0x00}; // Smiley
wim 18:bd65dc10f27f 241 //const char udc_droopy[] = {0x00, 0x0A, 0x00, 0x04, 0x00, 0x0E, 0x11, 0x00}; // Droopey
wim 18:bd65dc10f27f 242 //const char udc_note[] = {0x01, 0x03, 0x05, 0x09, 0x0B, 0x1B, 0x18, 0x00}; // Note
wim 18:bd65dc10f27f 243
wim 18:bd65dc10f27f 244 //const char udc_bar_1[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00}; // Bar 1
wim 18:bd65dc10f27f 245 //const char udc_bar_2[] = {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00}; // Bar 11
wim 18:bd65dc10f27f 246 //const char udc_bar_3[] = {0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x00}; // Bar 111
wim 18:bd65dc10f27f 247 //const char udc_bar_4[] = {0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x00}; // Bar 1111
wim 18:bd65dc10f27f 248 //const char udc_bar_5[] = {0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Bar 11111
wim 13:24506ba22480 249
wim 11:9ec02df863a1 250
wim 11:9ec02df863a1 251 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
wim 11:9ec02df863a1 252 *
wim 22:35742ec80c24 253 * @brief Currently supports 8x1, 8x2, 12x2, 12x4, 16x1, 16x2, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels
wim 27:22d5086f6ba6 254 * Interface options include direct mbed pins, I2C portexpander (PCF8474/PCF8574A or MCP23008) or SPI bus shiftregister (74595) and some native I2C or SPI devices
wim 11:9ec02df863a1 255 *
wim 11:9ec02df863a1 256 */
wim 21:9eb628d9e164 257 class TextLCD_Base : public Stream {
simon 1:ac48b187213c 258 public:
simon 1:ac48b187213c 259
simon 2:227356c7d12c 260 /** LCD panel format */
simon 1:ac48b187213c 261 enum LCDType {
wim 8:03116f75b66e 262 LCD8x1, /**< 8x1 LCD panel */
wim 13:24506ba22480 263 LCD8x2, /**< 8x2 LCD panel */
wim 18:bd65dc10f27f 264 LCD8x2B, /**< 8x2 LCD panel (actually 16x1) */
wim 15:b70ebfffb258 265 LCD12x2, /**< 12x2 LCD panel */
wim 15:b70ebfffb258 266 LCD12x4, /**< 12x4 LCD panel */
wim 13:24506ba22480 267 LCD16x1, /**< 16x1 LCD panel (actually 8x2) */
wim 8:03116f75b66e 268 LCD16x2, /**< 16x2 LCD panel (default) */
wim 8:03116f75b66e 269 LCD16x2B, /**< 16x2 LCD panel alternate addressing */
wim 8:03116f75b66e 270 LCD16x4, /**< 16x4 LCD panel */
wim 8:03116f75b66e 271 LCD20x2, /**< 20x2 LCD panel */
wim 8:03116f75b66e 272 LCD20x4, /**< 20x4 LCD panel */
wim 9:0893d986e717 273 LCD24x2, /**< 24x2 LCD panel */
wim 10:dd9b3a696acd 274 LCD24x4, /**< 24x4 LCD panel, special mode KS0078 */
wim 15:b70ebfffb258 275 LCD40x2, /**< 40x2 LCD panel */
wim 15:b70ebfffb258 276 LCD40x4 /**< 40x4 LCD panel, Two controller version */
simon 1:ac48b187213c 277 };
simon 1:ac48b187213c 278
wim 19:c747b9e2e7b8 279 /** LCD Controller Device */
wim 19:c747b9e2e7b8 280 enum LCDCtrl {
wim 26:bd897a001012 281 HD44780, /**< HD44780 (default) */
wim 26:bd897a001012 282 WS0010, /**< WS0010 OLED Controller */
wim 26:bd897a001012 283 ST7036, /**< ST7036 */
wim 26:bd897a001012 284 ST7032_3V3, /**< ST7032 3V3 with Booster */
wim 26:bd897a001012 285 ST7032_5V /**< ST7032 5V no Booster */
wim 19:c747b9e2e7b8 286 };
wim 19:c747b9e2e7b8 287
wim 19:c747b9e2e7b8 288
wim 10:dd9b3a696acd 289 /** LCD Cursor control */
wim 10:dd9b3a696acd 290 enum LCDCursor {
wim 17:652ab113bc2e 291 CurOff_BlkOff = 0x00, /**< Cursor Off, Blinking Char Off */
wim 17:652ab113bc2e 292 CurOn_BlkOff = 0x02, /**< Cursor On, Blinking Char Off */
wim 17:652ab113bc2e 293 CurOff_BlkOn = 0x01, /**< Cursor Off, Blinking Char On */
wim 17:652ab113bc2e 294 CurOn_BlkOn = 0x03 /**< Cursor On, Blinking Char On */
wim 17:652ab113bc2e 295 };
wim 17:652ab113bc2e 296
wim 17:652ab113bc2e 297
wim 17:652ab113bc2e 298 /** LCD Display control */
wim 17:652ab113bc2e 299 enum LCDMode {
wim 17:652ab113bc2e 300 DispOff = 0x00, /**< Display Off */
wim 17:652ab113bc2e 301 DispOn = 0x04 /**< Display On */
wim 10:dd9b3a696acd 302 };
wim 10:dd9b3a696acd 303
wim 20:e0da005a777f 304 /** LCD Backlight control */
wim 20:e0da005a777f 305 enum LCDBacklight {
wim 20:e0da005a777f 306 LightOff, /**< Backlight Off */
wim 20:e0da005a777f 307 LightOn /**< Backlight On */
wim 20:e0da005a777f 308 };
wim 10:dd9b3a696acd 309
simon 2:227356c7d12c 310
simon 2:227356c7d12c 311 #if DOXYGEN_ONLY
simon 2:227356c7d12c 312 /** Write a character to the LCD
simon 2:227356c7d12c 313 *
simon 2:227356c7d12c 314 * @param c The character to write to the display
simon 2:227356c7d12c 315 */
simon 2:227356c7d12c 316 int putc(int c);
simon 2:227356c7d12c 317
simon 2:227356c7d12c 318 /** Write a formated string to the LCD
simon 2:227356c7d12c 319 *
simon 2:227356c7d12c 320 * @param format A printf-style format string, followed by the
simon 2:227356c7d12c 321 * variables to use in formating the string.
simon 2:227356c7d12c 322 */
simon 2:227356c7d12c 323 int printf(const char* format, ...);
simon 2:227356c7d12c 324 #endif
simon 2:227356c7d12c 325
simon 2:227356c7d12c 326 /** Locate to a screen column and row
simon 2:227356c7d12c 327 *
simon 2:227356c7d12c 328 * @param column The horizontal position from the left, indexed from 0
simon 2:227356c7d12c 329 * @param row The vertical position from the top, indexed from 0
simon 2:227356c7d12c 330 */
simon 1:ac48b187213c 331 void locate(int column, int row);
simon 2:227356c7d12c 332
wim 10:dd9b3a696acd 333
wim 10:dd9b3a696acd 334 /** Return the memoryaddress of screen column and row location
wim 10:dd9b3a696acd 335 *
wim 10:dd9b3a696acd 336 * @param column The horizontal position from the left, indexed from 0
wim 10:dd9b3a696acd 337 * @param row The vertical position from the top, indexed from 0
wim 10:dd9b3a696acd 338 * @param return The memoryaddress of screen column and row location
wim 10:dd9b3a696acd 339 */
wim 9:0893d986e717 340 int getAddress(int column, int row);
wim 10:dd9b3a696acd 341
wim 10:dd9b3a696acd 342
wim 10:dd9b3a696acd 343 /** Set the memoryaddress of screen column and row location
wim 10:dd9b3a696acd 344 *
wim 10:dd9b3a696acd 345 * @param column The horizontal position from the left, indexed from 0
wim 10:dd9b3a696acd 346 * @param row The vertical position from the top, indexed from 0
wim 10:dd9b3a696acd 347 */
wim 9:0893d986e717 348 void setAddress(int column, int row);
wim 9:0893d986e717 349
wim 10:dd9b3a696acd 350
wim 22:35742ec80c24 351 /** Clear the screen and locate to 0,0
wim 22:35742ec80c24 352 */
simon 1:ac48b187213c 353 void cls();
simon 2:227356c7d12c 354
wim 10:dd9b3a696acd 355 /** Return the number of rows
wim 10:dd9b3a696acd 356 *
wim 10:dd9b3a696acd 357 * @param return The number of rows
wim 10:dd9b3a696acd 358 */
simon 1:ac48b187213c 359 int rows();
wim 10:dd9b3a696acd 360
wim 10:dd9b3a696acd 361 /** Return the number of columns
wim 10:dd9b3a696acd 362 *
wim 10:dd9b3a696acd 363 * @param return The number of columns
wim 10:dd9b3a696acd 364 */
wim 10:dd9b3a696acd 365 int columns();
simon 2:227356c7d12c 366
wim 11:9ec02df863a1 367 /** Set the Cursormode
wim 11:9ec02df863a1 368 *
wim 17:652ab113bc2e 369 * @param cursorMode The Cursor mode (CurOff_BlkOff, CurOn_BlkOff, CurOff_BlkOn, CurOn_BlkOn)
wim 11:9ec02df863a1 370 */
wim 17:652ab113bc2e 371 void setCursor(LCDCursor cursorMode);
wim 17:652ab113bc2e 372
wim 17:652ab113bc2e 373
wim 17:652ab113bc2e 374 /** Set the Displaymode
wim 17:652ab113bc2e 375 *
wim 17:652ab113bc2e 376 * @param displayMode The Display mode (DispOff, DispOn)
wim 17:652ab113bc2e 377 */
wim 21:9eb628d9e164 378 void setMode(LCDMode displayMode);
wim 11:9ec02df863a1 379
wim 20:e0da005a777f 380 /** Set the Backlight mode
wim 20:e0da005a777f 381 *
wim 21:9eb628d9e164 382 * @param backlightMode The Backlight mode (LightOff, LightOn)
wim 20:e0da005a777f 383 */
wim 21:9eb628d9e164 384 void setBacklight(LCDBacklight backlightMode);
wim 20:e0da005a777f 385
wim 11:9ec02df863a1 386
wim 11:9ec02df863a1 387 /** Set User Defined Characters
wim 11:9ec02df863a1 388 *
wim 11:9ec02df863a1 389 * @param unsigned char c The Index of the UDC (0..7)
wim 12:6bf9d9957d31 390 * @param char *udc_data The bitpatterns for the UDC (8 bytes of 5 significant bits)
wim 11:9ec02df863a1 391 */
wim 11:9ec02df863a1 392 void setUDC(unsigned char c, char *udc_data);
wim 11:9ec02df863a1 393
wim 20:e0da005a777f 394
simon 1:ac48b187213c 395 protected:
wim 13:24506ba22480 396
wim 21:9eb628d9e164 397 /** LCD controller select, mainly used for LCD40x4
wim 21:9eb628d9e164 398 */
wim 19:c747b9e2e7b8 399 enum _LCDCtrl_Idx {
wim 15:b70ebfffb258 400 _LCDCtrl_0, /*< Primary */
wim 15:b70ebfffb258 401 _LCDCtrl_1, /*< Secondary */
wim 15:b70ebfffb258 402 };
wim 21:9eb628d9e164 403
wim 21:9eb628d9e164 404 /** Create a TextLCD_Base interface
wim 21:9eb628d9e164 405 * @brief Base class, can not be instantiated
wim 21:9eb628d9e164 406 *
wim 21:9eb628d9e164 407 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 21:9eb628d9e164 408 * @param ctrl LCD controller (default = HD44780)
wim 21:9eb628d9e164 409 */
wim 21:9eb628d9e164 410 TextLCD_Base(LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
wim 21:9eb628d9e164 411
wim 15:b70ebfffb258 412
simon 1:ac48b187213c 413 // Stream implementation functions
simon 1:ac48b187213c 414 virtual int _putc(int value);
simon 1:ac48b187213c 415 virtual int _getc();
simon 1:ac48b187213c 416
wim 21:9eb628d9e164 417 /** Low level methods for LCD controller
wim 21:9eb628d9e164 418 */
wim 13:24506ba22480 419 void _init();
wim 15:b70ebfffb258 420 void _initCtrl();
wim 13:24506ba22480 421 int _address(int column, int row);
wim 21:9eb628d9e164 422 void _setCursor(LCDCursor show);
wim 17:652ab113bc2e 423 void _setUDC(unsigned char c, char *udc_data);
wim 21:9eb628d9e164 424 void _setCursorAndDisplayMode(LCDMode displayMode, LCDCursor cursorType);
wim 13:24506ba22480 425
wim 21:9eb628d9e164 426 /** Low level write operations to LCD controller
wim 21:9eb628d9e164 427 */
wim 17:652ab113bc2e 428 void _writeNibble(int value);
Sissors 24:fb3399713710 429 virtual void _writeByte(int value);
wim 15:b70ebfffb258 430 void _writeCommand(int command);
wim 15:b70ebfffb258 431 void _writeData(int data);
wim 15:b70ebfffb258 432
wim 21:9eb628d9e164 433 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
wim 21:9eb628d9e164 434 */
wim 21:9eb628d9e164 435 virtual void _setEnable(bool value) = 0;
wim 21:9eb628d9e164 436 virtual void _setRS(bool value) = 0;
wim 21:9eb628d9e164 437 virtual void _setBL(bool value) = 0;
wim 21:9eb628d9e164 438 virtual void _setData(int value) = 0;
wim 13:24506ba22480 439
wim 13:24506ba22480 440
wim 13:24506ba22480 441 //Display type
simon 1:ac48b187213c 442 LCDType _type;
simon 1:ac48b187213c 443
wim 21:9eb628d9e164 444 //Display mode
wim 17:652ab113bc2e 445 LCDMode _currentMode;
wim 17:652ab113bc2e 446
wim 19:c747b9e2e7b8 447 //Controller type
wim 19:c747b9e2e7b8 448 LCDCtrl _ctrl;
wim 19:c747b9e2e7b8 449
wim 15:b70ebfffb258 450 //Controller select, mainly used for LCD40x4
wim 19:c747b9e2e7b8 451 _LCDCtrl_Idx _ctrl_idx;
wim 15:b70ebfffb258 452
wim 13:24506ba22480 453 // Cursor
simon 1:ac48b187213c 454 int _column;
simon 1:ac48b187213c 455 int _row;
wim 15:b70ebfffb258 456 LCDCursor _currentCursor;
simon 1:ac48b187213c 457 };
simon 1:ac48b187213c 458
wim 23:d47f226efb24 459 //--------- End TextLCD_Base -----------
wim 22:35742ec80c24 460
wim 22:35742ec80c24 461
wim 22:35742ec80c24 462
wim 23:d47f226efb24 463 //--------- Start TextLCD Bus -----------
wim 21:9eb628d9e164 464
wim 21:9eb628d9e164 465 /** Create a TextLCD interface for using regular mbed pins
wim 21:9eb628d9e164 466 *
wim 21:9eb628d9e164 467 */
wim 21:9eb628d9e164 468 class TextLCD : public TextLCD_Base {
wim 21:9eb628d9e164 469 public:
wim 21:9eb628d9e164 470 /** Create a TextLCD interface for using regular mbed pins
wim 21:9eb628d9e164 471 *
wim 21:9eb628d9e164 472 * @param rs Instruction/data control line
wim 21:9eb628d9e164 473 * @param e Enable line (clock)
wim 21:9eb628d9e164 474 * @param d4-d7 Data lines for using as a 4-bit interface
wim 21:9eb628d9e164 475 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 21:9eb628d9e164 476 * @param bl Backlight control line (optional, default = NC)
wim 21:9eb628d9e164 477 * @param e2 Enable2 line (clock for second controller, LCD40x4 only)
wim 21:9eb628d9e164 478 * @param ctrl LCD controller (default = HD44780)
wim 21:9eb628d9e164 479 */
wim 21:9eb628d9e164 480 TextLCD(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type = LCD16x2, PinName bl = NC, PinName e2 = NC, LCDCtrl ctrl = HD44780);
wim 21:9eb628d9e164 481
wim 22:35742ec80c24 482
wim 22:35742ec80c24 483 /** Destruct a TextLCD interface for using regular mbed pins
wim 22:35742ec80c24 484 *
wim 22:35742ec80c24 485 * @param none
wim 22:35742ec80c24 486 * @return none
wim 22:35742ec80c24 487 */
wim 22:35742ec80c24 488 virtual ~TextLCD();
wim 22:35742ec80c24 489
wim 21:9eb628d9e164 490 private:
wim 21:9eb628d9e164 491 //Low level writes to LCD Bus (serial or parallel)
wim 21:9eb628d9e164 492 virtual void _setEnable(bool value);
wim 21:9eb628d9e164 493 virtual void _setRS(bool value);
wim 21:9eb628d9e164 494 virtual void _setBL(bool value);
wim 21:9eb628d9e164 495 virtual void _setData(int value);
wim 21:9eb628d9e164 496
wim 22:35742ec80c24 497 /** Regular mbed pins bus
wim 22:35742ec80c24 498 */
wim 22:35742ec80c24 499 DigitalOut _rs, _e;
wim 22:35742ec80c24 500 BusOut _d;
wim 22:35742ec80c24 501
wim 22:35742ec80c24 502 /** Optional Hardware pins for the Backlight and LCD40x4 device
wim 22:35742ec80c24 503 * Default PinName value is NC, must be used as pointer to avoid issues with mbed lib and DigitalOut pins
wim 22:35742ec80c24 504 */
wim 22:35742ec80c24 505 DigitalOut *_bl, *_e2;
wim 21:9eb628d9e164 506 };
wim 21:9eb628d9e164 507
wim 22:35742ec80c24 508
wim 23:d47f226efb24 509 //----------- End TextLCD ---------------
wim 21:9eb628d9e164 510
wim 21:9eb628d9e164 511
wim 23:d47f226efb24 512 //--------- Start TextLCD_I2C -----------
wim 22:35742ec80c24 513
wim 22:35742ec80c24 514
wim 26:bd897a001012 515 /** Create a TextLCD interface using an I2C PCF8574 (or PCF8574A) or MCP23008 portexpander
wim 21:9eb628d9e164 516 *
wim 21:9eb628d9e164 517 */
wim 21:9eb628d9e164 518 class TextLCD_I2C : public TextLCD_Base {
wim 21:9eb628d9e164 519 public:
wim 26:bd897a001012 520 /** Create a TextLCD interface using an I2C PCF8574 (or PCF8574A) or MCP23008 portexpander
wim 21:9eb628d9e164 521 *
wim 21:9eb628d9e164 522 * @param i2c I2C Bus
wim 26:bd897a001012 523 * @param deviceAddress I2C slave address (PCF8574 or PCF8574A, default = PCF8574_SA0 = 0x40)
wim 21:9eb628d9e164 524 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 21:9eb628d9e164 525 * @param ctrl LCD controller (default = HD44780)
wim 21:9eb628d9e164 526 */
wim 26:bd897a001012 527 TextLCD_I2C(I2C *i2c, char deviceAddress = PCF8574_SA0, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
wim 21:9eb628d9e164 528
wim 21:9eb628d9e164 529 private:
wim 21:9eb628d9e164 530 //Low level writes to LCD Bus (serial or parallel)
wim 21:9eb628d9e164 531 virtual void _setEnable(bool value);
wim 21:9eb628d9e164 532 virtual void _setRS(bool value);
wim 21:9eb628d9e164 533 virtual void _setBL(bool value);
wim 26:bd897a001012 534 virtual void _setData(int value);
wim 26:bd897a001012 535
wim 26:bd897a001012 536 // Write data to MCP23008 I2C portexpander
wim 26:bd897a001012 537 void _write_register (int reg, int value);
wim 21:9eb628d9e164 538
wim 21:9eb628d9e164 539 //I2C bus
wim 21:9eb628d9e164 540 I2C *_i2c;
wim 21:9eb628d9e164 541 char _slaveAddress;
wim 21:9eb628d9e164 542
wim 21:9eb628d9e164 543 // Internal bus mirror value for serial bus only
wim 21:9eb628d9e164 544 char _lcd_bus;
wim 21:9eb628d9e164 545
wim 21:9eb628d9e164 546 };
wim 21:9eb628d9e164 547
wim 21:9eb628d9e164 548
wim 23:d47f226efb24 549 //---------- End TextLCD_I2C ------------
wim 22:35742ec80c24 550
wim 22:35742ec80c24 551
wim 22:35742ec80c24 552
wim 23:d47f226efb24 553 //--------- Start TextLCD_SPI -----------
wim 22:35742ec80c24 554
wim 21:9eb628d9e164 555
wim 21:9eb628d9e164 556 /** Create a TextLCD interface using an SPI 74595 portexpander
wim 21:9eb628d9e164 557 *
wim 21:9eb628d9e164 558 */
wim 21:9eb628d9e164 559 class TextLCD_SPI : public TextLCD_Base {
wim 21:9eb628d9e164 560 public:
wim 21:9eb628d9e164 561 /** Create a TextLCD interface using an SPI 74595 portexpander
wim 21:9eb628d9e164 562 *
wim 21:9eb628d9e164 563 * @param spi SPI Bus
wim 21:9eb628d9e164 564 * @param cs chip select pin (active low)
wim 21:9eb628d9e164 565 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 21:9eb628d9e164 566 * @param ctrl LCD controller (default = HD44780)
wim 21:9eb628d9e164 567 */
wim 21:9eb628d9e164 568 TextLCD_SPI(SPI *spi, PinName cs, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
wim 21:9eb628d9e164 569
wim 21:9eb628d9e164 570
wim 21:9eb628d9e164 571 private:
wim 21:9eb628d9e164 572 //Low level writes to LCD Bus (serial or parallel)
wim 21:9eb628d9e164 573 virtual void _setEnable(bool value);
wim 21:9eb628d9e164 574 virtual void _setRS(bool value);
wim 21:9eb628d9e164 575 virtual void _setBL(bool value);
wim 21:9eb628d9e164 576 virtual void _setData(int value);
wim 21:9eb628d9e164 577 virtual void _setCS(bool value);
wim 21:9eb628d9e164 578
wim 21:9eb628d9e164 579 //Low level writes to LCD serial bus only
wim 21:9eb628d9e164 580 void _writeBus();
wim 21:9eb628d9e164 581
wim 21:9eb628d9e164 582 // SPI bus
wim 21:9eb628d9e164 583 SPI *_spi;
wim 21:9eb628d9e164 584 DigitalOut _cs;
wim 21:9eb628d9e164 585
wim 21:9eb628d9e164 586 // Internal bus mirror value for serial bus only
wim 21:9eb628d9e164 587 char _lcd_bus;
wim 21:9eb628d9e164 588
wim 21:9eb628d9e164 589 };
wim 21:9eb628d9e164 590
wim 23:d47f226efb24 591 //---------- End TextLCD_SPI ------------
wim 21:9eb628d9e164 592
Sissors 24:fb3399713710 593
Sissors 24:fb3399713710 594
wim 26:bd897a001012 595 //--------- Start TextLCD_SPI_N -----------
Sissors 24:fb3399713710 596
wim 25:6162b31128c9 597 /** Create a TextLCD interface using a controller with native SPI interface
Sissors 24:fb3399713710 598 *
Sissors 24:fb3399713710 599 */
wim 25:6162b31128c9 600 class TextLCD_SPI_N : public TextLCD_Base {
Sissors 24:fb3399713710 601 public:
wim 25:6162b31128c9 602 /** Create a TextLCD interface using a controller with native SPI interface
Sissors 24:fb3399713710 603 *
Sissors 24:fb3399713710 604 * @param spi SPI Bus
Sissors 24:fb3399713710 605 * @param cs chip select pin (active low)
Sissors 24:fb3399713710 606 * @param rs Instruction/data control line
Sissors 24:fb3399713710 607 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Sissors 24:fb3399713710 608 * @param bl Backlight control line (optional, default = NC)
wim 26:bd897a001012 609 * @param ctrl LCD controller (default = ST7032_3V3)
Sissors 24:fb3399713710 610 */
wim 26:bd897a001012 611 TextLCD_SPI_N(SPI *spi, PinName cs, PinName rs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7032_3V3);
wim 25:6162b31128c9 612 virtual ~TextLCD_SPI_N(void);
Sissors 24:fb3399713710 613
Sissors 24:fb3399713710 614 private:
Sissors 24:fb3399713710 615 virtual void _setEnable(bool value);
Sissors 24:fb3399713710 616 virtual void _setRS(bool value);
Sissors 24:fb3399713710 617 virtual void _setBL(bool value);
Sissors 24:fb3399713710 618 virtual void _setData(int value);
Sissors 24:fb3399713710 619 virtual void _writeByte(int value);
Sissors 24:fb3399713710 620
Sissors 24:fb3399713710 621 // SPI bus
Sissors 24:fb3399713710 622 SPI *_spi;
Sissors 24:fb3399713710 623 DigitalOut _cs;
Sissors 24:fb3399713710 624 DigitalOut _rs;
Sissors 24:fb3399713710 625 DigitalOut *_bl;
Sissors 24:fb3399713710 626
Sissors 24:fb3399713710 627 };
Sissors 24:fb3399713710 628
wim 25:6162b31128c9 629 //---------- End TextLCD_SPI_N ------------
Sissors 24:fb3399713710 630
wim 26:bd897a001012 631
wim 26:bd897a001012 632 //--------- Start TextLCD_I2C_N -----------
wim 26:bd897a001012 633
wim 26:bd897a001012 634 /** Create a TextLCD interface using a controller with native I2C interface
wim 26:bd897a001012 635 *
wim 26:bd897a001012 636 */
wim 26:bd897a001012 637 class TextLCD_I2C_N : public TextLCD_Base {
wim 26:bd897a001012 638 public:
wim 26:bd897a001012 639 /** Create a TextLCD interface using a controller with native I2C interface
wim 26:bd897a001012 640 *
wim 26:bd897a001012 641 * @param i2c I2C Bus
wim 26:bd897a001012 642 * @param deviceAddress I2C slave address (default = 0x)
wim 26:bd897a001012 643 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 26:bd897a001012 644 * @param ctrl LCD controller (default = ST7032_3V3)
wim 26:bd897a001012 645 */
wim 26:bd897a001012 646 TextLCD_I2C_N(I2C *i2c, char deviceAddress = 0x40, LCDType type = LCD16x2, LCDCtrl ctrl = ST7032_3V3);
wim 26:bd897a001012 647 virtual ~TextLCD_I2C_N(void);
wim 26:bd897a001012 648
wim 26:bd897a001012 649 private:
wim 26:bd897a001012 650 virtual void _setEnable(bool value);
wim 26:bd897a001012 651 virtual void _setRS(bool value);
wim 26:bd897a001012 652 virtual void _setBL(bool value);
wim 26:bd897a001012 653 virtual void _setData(int value);
wim 26:bd897a001012 654 virtual void _writeByte(int value);
wim 26:bd897a001012 655
wim 26:bd897a001012 656 //I2C bus
wim 26:bd897a001012 657 I2C *_i2c;
wim 26:bd897a001012 658 char _slaveAddress;
wim 26:bd897a001012 659
wim 26:bd897a001012 660 // Internal bus mirror value for serial bus only
wim 26:bd897a001012 661 char _lcd_bus;
wim 26:bd897a001012 662 };
wim 26:bd897a001012 663
wim 26:bd897a001012 664 //---------- End TextLCD_I2C_N ------------
wim 26:bd897a001012 665
wim 26:bd897a001012 666
simon 1:ac48b187213c 667 #endif