cléclé

Dependencies:   mbed

Committer:
Quentinou
Date:
Fri Dec 21 07:03:38 2018 +0000
Revision:
0:e25a8207e8a1
lcd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Quentinou 0:e25a8207e8a1 1 /* mbed TextLCD Library, for a 4-bit LCD based on HD44780
Quentinou 0:e25a8207e8a1 2 * Copyright (c) 2007-2010, sford, http://mbed.org
Quentinou 0:e25a8207e8a1 3 * 2013, v01: WH, Added LCD types, fixed LCD address issues, added Cursor and UDCs
Quentinou 0:e25a8207e8a1 4 * 2013, v02: WH, Added I2C and SPI bus interfaces
Quentinou 0:e25a8207e8a1 5 * 2013, v03: WH, Added support for LCD40x4 which uses 2 controllers
Quentinou 0:e25a8207e8a1 6 * 2013, v04: WH, Added support for Display On/Off, improved 4bit bootprocess
Quentinou 0:e25a8207e8a1 7 * 2013, v05: WH, Added support for 8x2B, added some UDCs
Quentinou 0:e25a8207e8a1 8 * 2013, v06: WH, Added support for devices that use internal DC/DC converters
Quentinou 0:e25a8207e8a1 9 * 2013, v07: WH, Added support for backlight and include portdefinitions for LCD2004 Module from DFROBOT
Quentinou 0:e25a8207e8a1 10 * 2014, v08: WH, Refactored in Base and Derived Classes to deal with mbed lib change regarding 'NC' defined DigitalOut pins
Quentinou 0:e25a8207e8a1 11 * 2014, v09: WH/EO, Added Class for Native SPI controllers such as ST7032
Quentinou 0:e25a8207e8a1 12 * 2014, v10: WH, Added Class for Native I2C controllers such as ST7032i, Added support for MCP23008 I2C portexpander, Added support for Adafruit module
Quentinou 0:e25a8207e8a1 13 * 2014, v11: WH, Added support for native I2C controllers such as PCF21XX, Improved the _initCtrl() method to deal with differences between all supported controllers
Quentinou 0:e25a8207e8a1 14 * 2014, v12: WH, Added support for native I2C controller PCF2119 and native I2C/SPI controllers SSD1803, ST7036, added setContrast method (by JH1PJL) for supported devices (eg ST7032i)
Quentinou 0:e25a8207e8a1 15 * 2014, v13: WH, Added support for controllers US2066/SSD1311 (OLED), added setUDCBlink method for supported devices (eg SSD1803), fixed issue in setPower()
Quentinou 0:e25a8207e8a1 16 *@Todo Add AC780S/KS0066i
Quentinou 0:e25a8207e8a1 17 *
Quentinou 0:e25a8207e8a1 18 * Permission is hereby granted, free of charge, to any person obtaining a copy
Quentinou 0:e25a8207e8a1 19 * of this software and associated documentation files (the "Software"), to deal
Quentinou 0:e25a8207e8a1 20 * in the Software without restriction, including without limitation the rights
Quentinou 0:e25a8207e8a1 21 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Quentinou 0:e25a8207e8a1 22 * copies of the Software, and to permit persons to whom the Software is
Quentinou 0:e25a8207e8a1 23 * furnished to do so, subject to the following conditions:
Quentinou 0:e25a8207e8a1 24 *
Quentinou 0:e25a8207e8a1 25 * The above copyright notice and this permission notice shall be included in
Quentinou 0:e25a8207e8a1 26 * all copies or substantial portions of the Software.
Quentinou 0:e25a8207e8a1 27 *
Quentinou 0:e25a8207e8a1 28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Quentinou 0:e25a8207e8a1 29 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Quentinou 0:e25a8207e8a1 30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Quentinou 0:e25a8207e8a1 31 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Quentinou 0:e25a8207e8a1 32 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Quentinou 0:e25a8207e8a1 33 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Quentinou 0:e25a8207e8a1 34 * THE SOFTWARE.
Quentinou 0:e25a8207e8a1 35 */
Quentinou 0:e25a8207e8a1 36
Quentinou 0:e25a8207e8a1 37 #ifndef MBED_TEXTLCD_H
Quentinou 0:e25a8207e8a1 38 #define MBED_TEXTLCD_H
Quentinou 0:e25a8207e8a1 39
Quentinou 0:e25a8207e8a1 40 #include "mbed.h"
Quentinou 0:e25a8207e8a1 41
Quentinou 0:e25a8207e8a1 42 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
Quentinou 0:e25a8207e8a1 43 *
Quentinou 0:e25a8207e8a1 44 * Currently supports 8x1, 8x2, 12x3, 12x4, 16x1, 16x2, 16x3, 16x4, 20x2, 20x4, 24x1, 24x2, 24x4, 40x2 and 40x4 panels
Quentinou 0:e25a8207e8a1 45 * Interface options include direct mbed pins, I2C portexpander (PCF8474/PCF8574A or MCP23008) or SPI bus shiftregister (74595).
Quentinou 0:e25a8207e8a1 46 * Supports some controllers with native I2C or SP interface. Supports some controllers that provide internal DC/DC converters for VLCD or VLED.
Quentinou 0:e25a8207e8a1 47 *
Quentinou 0:e25a8207e8a1 48 * @code
Quentinou 0:e25a8207e8a1 49 * #include "mbed.h"
Quentinou 0:e25a8207e8a1 50 * #include "TextLCD.h"
Quentinou 0:e25a8207e8a1 51 *
Quentinou 0:e25a8207e8a1 52 * // I2C Communication
Quentinou 0:e25a8207e8a1 53 * I2C i2c_lcd(p28,p27); // SDA, SCL
Quentinou 0:e25a8207e8a1 54 *
Quentinou 0:e25a8207e8a1 55 * // SPI Communication
Quentinou 0:e25a8207e8a1 56 * SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK
Quentinou 0:e25a8207e8a1 57 *
Quentinou 0:e25a8207e8a1 58 * //TextLCD lcd(p15, p16, p17, p18, p19, p20); // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780
Quentinou 0:e25a8207e8a1 59 * //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, 74595 expander, CS pin, LCD Type
Quentinou 0:e25a8207e8a1 60 * TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type
Quentinou 0:e25a8207e8a1 61 * //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type
Quentinou 0:e25a8207e8a1 62 * //TextLCD_SPI_N lcd(&spi_lcd, p8, p9); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3
Quentinou 0:e25a8207e8a1 63 * //TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=ST7032_3V3
Quentinou 0:e25a8207e8a1 64 *
Quentinou 0:e25a8207e8a1 65 * int main() {
Quentinou 0:e25a8207e8a1 66 * lcd.printf("Hello World!\n");
Quentinou 0:e25a8207e8a1 67 * }
Quentinou 0:e25a8207e8a1 68 * @endcode
Quentinou 0:e25a8207e8a1 69 */
Quentinou 0:e25a8207e8a1 70
Quentinou 0:e25a8207e8a1 71
Quentinou 0:e25a8207e8a1 72 //Pin Defines for I2C PCF8574/PCF8574A or MCP23008 and SPI 74595 bus expander interfaces
Quentinou 0:e25a8207e8a1 73 //LCD and serial portexpanders should be wired accordingly
Quentinou 0:e25a8207e8a1 74 //
Quentinou 0:e25a8207e8a1 75 //Select Hardware module (one option only)
Quentinou 0:e25a8207e8a1 76 #define DEFAULT 0
Quentinou 0:e25a8207e8a1 77 #define ADAFRUIT 0
Quentinou 0:e25a8207e8a1 78 #define DFROBOT 1
Quentinou 0:e25a8207e8a1 79
Quentinou 0:e25a8207e8a1 80 #if (DEFAULT==1)
Quentinou 0:e25a8207e8a1 81 //Definitions for default (WH) mapping between serial port expander pins and LCD controller
Quentinou 0:e25a8207e8a1 82 //This hardware supports the I2C bus expander (PCF8574/PCF8574A or MCP23008) and SPI bus expander (74595) interfaces
Quentinou 0:e25a8207e8a1 83 //See https://mbed.org/cookbook/Text-LCD-Enhanced
Quentinou 0:e25a8207e8a1 84 //
Quentinou 0:e25a8207e8a1 85 //Note: LCD RW pin must be connected to GND
Quentinou 0:e25a8207e8a1 86 // E2 is used for LCD40x4 (second controller)
Quentinou 0:e25a8207e8a1 87 // BL may be used to control backlight
Quentinou 0:e25a8207e8a1 88 #define D_LCD_PIN_D4 0
Quentinou 0:e25a8207e8a1 89 #define D_LCD_PIN_D5 1
Quentinou 0:e25a8207e8a1 90 #define D_LCD_PIN_D6 2
Quentinou 0:e25a8207e8a1 91 #define D_LCD_PIN_D7 3
Quentinou 0:e25a8207e8a1 92 #define D_LCD_PIN_RS 4
Quentinou 0:e25a8207e8a1 93 #define D_LCD_PIN_E 5
Quentinou 0:e25a8207e8a1 94 #define D_LCD_PIN_E2 6
Quentinou 0:e25a8207e8a1 95 #define D_LCD_PIN_BL 7
Quentinou 0:e25a8207e8a1 96
Quentinou 0:e25a8207e8a1 97 #define D_LCD_PIN_RW D_LCD_PIN_E2
Quentinou 0:e25a8207e8a1 98
Quentinou 0:e25a8207e8a1 99 //Select I2C Portexpander type (one option only)
Quentinou 0:e25a8207e8a1 100 #define PCF8574 1
Quentinou 0:e25a8207e8a1 101 #define MCP23008 0
Quentinou 0:e25a8207e8a1 102 #endif
Quentinou 0:e25a8207e8a1 103
Quentinou 0:e25a8207e8a1 104 #if (ADAFRUIT==1)
Quentinou 0:e25a8207e8a1 105 //Definitions for Adafruit i2cspilcdbackpack mapping between serial port expander pins and LCD controller
Quentinou 0:e25a8207e8a1 106 //This hardware supports both an I2C expander (MCP23008) and an SPI expander (74595) selectable by a jumper.
Quentinou 0:e25a8207e8a1 107 //See http://www.ladyada.net/products/i2cspilcdbackpack
Quentinou 0:e25a8207e8a1 108 //
Quentinou 0:e25a8207e8a1 109 //Note: LCD RW pin must be kept LOW
Quentinou 0:e25a8207e8a1 110 // E2 is not available on this hardware and so it does not support LCD40x4 (second controller)
Quentinou 0:e25a8207e8a1 111 // BL is used to control backlight
Quentinou 0:e25a8207e8a1 112 #define D_LCD_PIN_0 0
Quentinou 0:e25a8207e8a1 113 #define D_LCD_PIN_RS 1
Quentinou 0:e25a8207e8a1 114 #define D_LCD_PIN_E 2
Quentinou 0:e25a8207e8a1 115 #define D_LCD_PIN_D4 3
Quentinou 0:e25a8207e8a1 116 #define D_LCD_PIN_D5 4
Quentinou 0:e25a8207e8a1 117 #define D_LCD_PIN_D6 5
Quentinou 0:e25a8207e8a1 118 #define D_LCD_PIN_D7 6
Quentinou 0:e25a8207e8a1 119 #define D_LCD_PIN_BL 7
Quentinou 0:e25a8207e8a1 120
Quentinou 0:e25a8207e8a1 121 #define D_LCD_PIN_E2 D_LCD_PIN_0
Quentinou 0:e25a8207e8a1 122
Quentinou 0:e25a8207e8a1 123 //Force I2C portexpander type
Quentinou 0:e25a8207e8a1 124 #define PCF8574 0
Quentinou 0:e25a8207e8a1 125 #define MCP23008 1
Quentinou 0:e25a8207e8a1 126 #endif
Quentinou 0:e25a8207e8a1 127
Quentinou 0:e25a8207e8a1 128 #if (DFROBOT==1)
Quentinou 0:e25a8207e8a1 129 //Definitions for DFROBOT LCD2004 Module mapping between serial port expander pins and LCD controller
Quentinou 0:e25a8207e8a1 130 //This hardware uses PCF8574 and is different from earlier/different Arduino I2C LCD displays
Quentinou 0:e25a8207e8a1 131 //See http://arduino-info.wikispaces.com/LCD-Blue-I2C
Quentinou 0:e25a8207e8a1 132 //
Quentinou 0:e25a8207e8a1 133 //Note: LCD RW pin must be kept LOW
Quentinou 0:e25a8207e8a1 134 // E2 is not available on default Arduino hardware and so it does not support LCD40x4 (second controller)
Quentinou 0:e25a8207e8a1 135 // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight()
Quentinou 0:e25a8207e8a1 136 #define D_LCD_PIN_RS 0
Quentinou 0:e25a8207e8a1 137 #define D_LCD_PIN_RW 1
Quentinou 0:e25a8207e8a1 138 #define D_LCD_PIN_E 2
Quentinou 0:e25a8207e8a1 139 #define D_LCD_PIN_BL 3
Quentinou 0:e25a8207e8a1 140 #define D_LCD_PIN_D4 4
Quentinou 0:e25a8207e8a1 141 #define D_LCD_PIN_D5 5
Quentinou 0:e25a8207e8a1 142 #define D_LCD_PIN_D6 6
Quentinou 0:e25a8207e8a1 143 #define D_LCD_PIN_D7 7
Quentinou 0:e25a8207e8a1 144
Quentinou 0:e25a8207e8a1 145 #define D_LCD_PIN_E2 D_LCD_PIN_RW
Quentinou 0:e25a8207e8a1 146
Quentinou 0:e25a8207e8a1 147 //Force I2C portexpander type
Quentinou 0:e25a8207e8a1 148 #define PCF8574 1
Quentinou 0:e25a8207e8a1 149 #define MCP23008 0
Quentinou 0:e25a8207e8a1 150 #endif
Quentinou 0:e25a8207e8a1 151
Quentinou 0:e25a8207e8a1 152 //Bitpattern Defines for I2C PCF8574/PCF8574A, MCP23008 and SPI 74595 Bus expanders
Quentinou 0:e25a8207e8a1 153 //
Quentinou 0:e25a8207e8a1 154 #define D_LCD_D4 (1<<D_LCD_PIN_D4)
Quentinou 0:e25a8207e8a1 155 #define D_LCD_D5 (1<<D_LCD_PIN_D5)
Quentinou 0:e25a8207e8a1 156 #define D_LCD_D6 (1<<D_LCD_PIN_D6)
Quentinou 0:e25a8207e8a1 157 #define D_LCD_D7 (1<<D_LCD_PIN_D7)
Quentinou 0:e25a8207e8a1 158 #define D_LCD_RS (1<<D_LCD_PIN_RS)
Quentinou 0:e25a8207e8a1 159 #define D_LCD_E (1<<D_LCD_PIN_E)
Quentinou 0:e25a8207e8a1 160 #define D_LCD_E2 (1<<D_LCD_PIN_E2)
Quentinou 0:e25a8207e8a1 161 #define D_LCD_BL (1<<D_LCD_PIN_BL)
Quentinou 0:e25a8207e8a1 162 //#define D_LCD_RW (1<<D_LCD_PIN_RW)
Quentinou 0:e25a8207e8a1 163
Quentinou 0:e25a8207e8a1 164 #define D_LCD_BUS_MSK (D_LCD_D4 | D_LCD_D5 | D_LCD_D6 | D_LCD_D7)
Quentinou 0:e25a8207e8a1 165 #define D_LCD_BUS_DEF 0x00
Quentinou 0:e25a8207e8a1 166
Quentinou 0:e25a8207e8a1 167 /* PCF8574/PCF8574A I2C portexpander slave address */
Quentinou 0:e25a8207e8a1 168 #define PCF8574_SA0 0x40
Quentinou 0:e25a8207e8a1 169 #define PCF8574_SA1 0x42
Quentinou 0:e25a8207e8a1 170 #define PCF8574_SA2 0x44
Quentinou 0:e25a8207e8a1 171 #define PCF8574_SA3 0x46
Quentinou 0:e25a8207e8a1 172 #define PCF8574_SA4 0x48
Quentinou 0:e25a8207e8a1 173 #define PCF8574_SA5 0x4A
Quentinou 0:e25a8207e8a1 174 #define PCF8574_SA6 0x4C
Quentinou 0:e25a8207e8a1 175 #define PCF8574_SA7 0x4E
Quentinou 0:e25a8207e8a1 176
Quentinou 0:e25a8207e8a1 177 #define PCF8574A_SA0 0x70
Quentinou 0:e25a8207e8a1 178 #define PCF8574A_SA1 0x72
Quentinou 0:e25a8207e8a1 179 #define PCF8574A_SA2 0x74
Quentinou 0:e25a8207e8a1 180 #define PCF8574A_SA3 0x76
Quentinou 0:e25a8207e8a1 181 #define PCF8574A_SA4 0x78
Quentinou 0:e25a8207e8a1 182 #define PCF8574A_SA5 0x7A
Quentinou 0:e25a8207e8a1 183 #define PCF8574A_SA6 0x7C
Quentinou 0:e25a8207e8a1 184 #define PCF8574A_SA7 0x7E
Quentinou 0:e25a8207e8a1 185
Quentinou 0:e25a8207e8a1 186 /* MCP23008 I2C portexpander slave address */
Quentinou 0:e25a8207e8a1 187 #define MCP23008_SA0 0x40
Quentinou 0:e25a8207e8a1 188 #define MCP23008_SA1 0x42
Quentinou 0:e25a8207e8a1 189 #define MCP23008_SA2 0x44
Quentinou 0:e25a8207e8a1 190 #define MCP23008_SA3 0x46
Quentinou 0:e25a8207e8a1 191 #define MCP23008_SA4 0x48
Quentinou 0:e25a8207e8a1 192 #define MCP23008_SA5 0x4A
Quentinou 0:e25a8207e8a1 193 #define MCP23008_SA6 0x4C
Quentinou 0:e25a8207e8a1 194 #define MCP23008_SA7 0x4E
Quentinou 0:e25a8207e8a1 195
Quentinou 0:e25a8207e8a1 196 /* MCP23008 I2C portexpander internal registers */
Quentinou 0:e25a8207e8a1 197 #define IODIR 0x00
Quentinou 0:e25a8207e8a1 198 #define IPOL 0x01
Quentinou 0:e25a8207e8a1 199 #define GPINTEN 0x02
Quentinou 0:e25a8207e8a1 200 #define DEFVAL 0x03
Quentinou 0:e25a8207e8a1 201 #define INTCON 0x04
Quentinou 0:e25a8207e8a1 202 #define IOCON 0x05
Quentinou 0:e25a8207e8a1 203 #define GPPU 0x06
Quentinou 0:e25a8207e8a1 204 #define INTF 0x07
Quentinou 0:e25a8207e8a1 205 #define INTCAP 0x08
Quentinou 0:e25a8207e8a1 206 #define GPIO 0x09
Quentinou 0:e25a8207e8a1 207 #define OLAT 0x0A
Quentinou 0:e25a8207e8a1 208
Quentinou 0:e25a8207e8a1 209
Quentinou 0:e25a8207e8a1 210 /* ST7032i I2C slave address */
Quentinou 0:e25a8207e8a1 211 #define ST7032_SA 0x7C
Quentinou 0:e25a8207e8a1 212
Quentinou 0:e25a8207e8a1 213 /* ST7036i I2C slave address */
Quentinou 0:e25a8207e8a1 214 #define ST7036_SA0 0x78
Quentinou 0:e25a8207e8a1 215 #define ST7036_SA1 0x7A
Quentinou 0:e25a8207e8a1 216 #define ST7036_SA2 0x7C
Quentinou 0:e25a8207e8a1 217 #define ST7036_SA3 0x7E
Quentinou 0:e25a8207e8a1 218
Quentinou 0:e25a8207e8a1 219 /* PCF21XX I2C slave address */
Quentinou 0:e25a8207e8a1 220 #define PCF21XX_SA0 0x74
Quentinou 0:e25a8207e8a1 221 #define PCF21XX_SA1 0x76
Quentinou 0:e25a8207e8a1 222
Quentinou 0:e25a8207e8a1 223 /* AIP31068 I2C slave address */
Quentinou 0:e25a8207e8a1 224 #define AIP31068_SA 0x7C
Quentinou 0:e25a8207e8a1 225
Quentinou 0:e25a8207e8a1 226 /* SSD1803 I2C slave address */
Quentinou 0:e25a8207e8a1 227 #define SSD1803_SA0 0x78
Quentinou 0:e25a8207e8a1 228 #define SSD1803_SA1 0x7A
Quentinou 0:e25a8207e8a1 229
Quentinou 0:e25a8207e8a1 230 /* US2066/SSD1311 I2C slave address */
Quentinou 0:e25a8207e8a1 231 #define US2066_SA0 0x78
Quentinou 0:e25a8207e8a1 232 #define US2066_SA1 0x7A
Quentinou 0:e25a8207e8a1 233
Quentinou 0:e25a8207e8a1 234 /* AC780 I2C slave address */
Quentinou 0:e25a8207e8a1 235 #define AC780_SA0 0x78
Quentinou 0:e25a8207e8a1 236 #define AC780_SA1 0x7A
Quentinou 0:e25a8207e8a1 237 #define AC780_SA2 0x7C
Quentinou 0:e25a8207e8a1 238 #define AC780_SA3 0x7E
Quentinou 0:e25a8207e8a1 239
Quentinou 0:e25a8207e8a1 240 //Some native I2C controllers dont support ACK. Set define to '0' to allow code to proceed even without ACK
Quentinou 0:e25a8207e8a1 241 //#define LCD_I2C_ACK 0
Quentinou 0:e25a8207e8a1 242 #define LCD_I2C_ACK 1
Quentinou 0:e25a8207e8a1 243
Quentinou 0:e25a8207e8a1 244 /* LCD Type information on Rows, Columns and Variant. This information is encoded in
Quentinou 0:e25a8207e8a1 245 * an int and used for the LCDType enumerators in order to simplify code maintenance */
Quentinou 0:e25a8207e8a1 246 // Columns encoded in b7..b0
Quentinou 0:e25a8207e8a1 247 #define LCD_T_COL_MSK 0x000000FF
Quentinou 0:e25a8207e8a1 248 #define LCD_T_C6 0x00000006
Quentinou 0:e25a8207e8a1 249 #define LCD_T_C8 0x00000008
Quentinou 0:e25a8207e8a1 250 #define LCD_T_C10 0x0000000A
Quentinou 0:e25a8207e8a1 251 #define LCD_T_C12 0x0000000C
Quentinou 0:e25a8207e8a1 252 #define LCD_T_C16 0x00000010
Quentinou 0:e25a8207e8a1 253 #define LCD_T_C20 0x00000014
Quentinou 0:e25a8207e8a1 254 #define LCD_T_C24 0x00000018
Quentinou 0:e25a8207e8a1 255 #define LCD_T_C32 0x00000020
Quentinou 0:e25a8207e8a1 256 #define LCD_T_C40 0x00000028
Quentinou 0:e25a8207e8a1 257
Quentinou 0:e25a8207e8a1 258 // Rows encoded in b15..b8
Quentinou 0:e25a8207e8a1 259 #define LCD_T_ROW_MSK 0x0000FF00
Quentinou 0:e25a8207e8a1 260 #define LCD_T_R1 0x00000100
Quentinou 0:e25a8207e8a1 261 #define LCD_T_R2 0x00000200
Quentinou 0:e25a8207e8a1 262 #define LCD_T_R3 0x00000300
Quentinou 0:e25a8207e8a1 263 #define LCD_T_R4 0x00000400
Quentinou 0:e25a8207e8a1 264
Quentinou 0:e25a8207e8a1 265 // Addressing mode encoded in b19..b16
Quentinou 0:e25a8207e8a1 266 #define LCD_T_ADR_MSK 0x000F0000
Quentinou 0:e25a8207e8a1 267 #define LCD_T_A 0x00000000 /*Mode A Default 1, 2 or 4 line display */
Quentinou 0:e25a8207e8a1 268 #define LCD_T_B 0x00010000 /*Mode B, Alternate 8x2 (actually 16x1 display) */
Quentinou 0:e25a8207e8a1 269 #define LCD_T_C 0x00020000 /*Mode C, Alternate 16x1 (actually 8x2 display) */
Quentinou 0:e25a8207e8a1 270 #define LCD_T_D 0x00030000 /*Mode D, Alternate 3 or 4 line display (12x4, 20x4, 24x4) */
Quentinou 0:e25a8207e8a1 271 #define LCD_T_D1 0x00040000 /*Mode D1, Alternate 3 out of 4 line display (12x3, 20x3, 24x3) */
Quentinou 0:e25a8207e8a1 272 #define LCD_T_E 0x00050000 /*Mode E, 40x4 display (actually two 40x2) */
Quentinou 0:e25a8207e8a1 273 #define LCD_T_F 0x00060000 /*Mode F, 16x3 display (actually 24x2) */
Quentinou 0:e25a8207e8a1 274 #define LCD_T_G 0x00070000 /*Mode G, 16x3 display */
Quentinou 0:e25a8207e8a1 275
Quentinou 0:e25a8207e8a1 276 /* LCD Ctrl information on interface support and features. This information is encoded in
Quentinou 0:e25a8207e8a1 277 * an int and used for the LCDCtrl enumerators in order to simplify code maintenance */
Quentinou 0:e25a8207e8a1 278 // Interface encoded in b31..b24
Quentinou 0:e25a8207e8a1 279 #define LCD_C_BUS_MSK 0xFF000000
Quentinou 0:e25a8207e8a1 280 #define LCD_C_PAR 0x01000000 /*Parallel 4 or 8 bit data, E pin, RS pin, RW=GND */
Quentinou 0:e25a8207e8a1 281 #define LCD_C_SPI3_9 0x02000000 /*SPI 3 line (MOSI, SCL, CS pins), 9 bits (RS + 8 Data) */
Quentinou 0:e25a8207e8a1 282 #define LCD_C_SPI3_10 0x04000000 /*SPI 3 line (MOSI, SCL, CS pins), 10 bits (RS, RW + 8 Data) */
Quentinou 0:e25a8207e8a1 283 #define LCD_C_SPI3_16 0x08000000 /*SPI 3 line (MOSI, SCL, CS pins), 16 bits (RS, RW + 8 Data) */
Quentinou 0:e25a8207e8a1 284 #define LCD_C_SPI3_24 0x10000000 /*SPI 3 line (MOSI, SCL, CS pins), 24 bits (RS, RW + 8 Data) */
Quentinou 0:e25a8207e8a1 285 #define LCD_C_SPI4 0x20000000 /*SPI 4 line (MOSI, SCL, CS, RS pin), RS pin + 8 Data */
Quentinou 0:e25a8207e8a1 286 #define LCD_C_I2C 0x40000000 /*I2C (SDA, SCL pin), 8 control bits (Co, RS, RW) + 8 Data */
Quentinou 0:e25a8207e8a1 287 // Features encoded in b23..b16
Quentinou 0:e25a8207e8a1 288 #define LCD_C_FTR_MSK 0x00FF0000
Quentinou 0:e25a8207e8a1 289 #define LCD_C_BST 0x00010000 /*Booster */
Quentinou 0:e25a8207e8a1 290 #define LCD_C_CTR 0x00020000 /*Contrast Control */
Quentinou 0:e25a8207e8a1 291 #define LCD_C_ICN 0x00040000 /*Icons */
Quentinou 0:e25a8207e8a1 292 #define LCD_C_PDN 0x00080000 /*Power Down */
Quentinou 0:e25a8207e8a1 293
Quentinou 0:e25a8207e8a1 294
Quentinou 0:e25a8207e8a1 295 // Contrast setting, 6 significant bits (only supported for controllers with extended features)
Quentinou 0:e25a8207e8a1 296 // Voltage Multiplier setting, 2 or 3 significant bits (only supported for controllers with extended features)
Quentinou 0:e25a8207e8a1 297 #define LCD_DEF_CONTRAST 0x20
Quentinou 0:e25a8207e8a1 298
Quentinou 0:e25a8207e8a1 299 //ST7032 EastRising ERC1602FS-4 display
Quentinou 0:e25a8207e8a1 300 //Contrast setting 6 significant bits
Quentinou 0:e25a8207e8a1 301 //Voltage Multiplier setting 3 significant bits
Quentinou 0:e25a8207e8a1 302 #define LCD_ST7032_CONTRAST 0x18
Quentinou 0:e25a8207e8a1 303 #define LCD_ST7032_RAB 0x04
Quentinou 0:e25a8207e8a1 304
Quentinou 0:e25a8207e8a1 305 //ST7036 EA DOGM1603 display
Quentinou 0:e25a8207e8a1 306 //Contrast setting 6 significant bits
Quentinou 0:e25a8207e8a1 307 //Voltage Multiplier setting 3 significant bits
Quentinou 0:e25a8207e8a1 308 #define LCD_ST7036_CONTRAST 0x28
Quentinou 0:e25a8207e8a1 309 #define LCD_ST7036_RAB 0x04
Quentinou 0:e25a8207e8a1 310
Quentinou 0:e25a8207e8a1 311 //SSD1803 EA DOGM204 display
Quentinou 0:e25a8207e8a1 312 //Contrast setting 6 significant bits
Quentinou 0:e25a8207e8a1 313 //Voltage Multiplier setting 3 significant bits
Quentinou 0:e25a8207e8a1 314 #define LCD_SSD1_CONTRAST 0x28
Quentinou 0:e25a8207e8a1 315 #define LCD_SSD1_RAB 0x06
Quentinou 0:e25a8207e8a1 316
Quentinou 0:e25a8207e8a1 317 //US2066/SSD1311 EastRising ER-OLEDM2002-4 display
Quentinou 0:e25a8207e8a1 318 //Contrast setting 8 significant bits, use 6 for compatibility
Quentinou 0:e25a8207e8a1 319 #define LCD_US20_CONTRAST 0x3F
Quentinou 0:e25a8207e8a1 320 //#define LCD_US20_CONTRAST 0x1F
Quentinou 0:e25a8207e8a1 321
Quentinou 0:e25a8207e8a1 322 //PCF2113, PCF2119 display
Quentinou 0:e25a8207e8a1 323 //Contrast setting 6 significant bits
Quentinou 0:e25a8207e8a1 324 //Voltage Multiplier setting 2 significant bits
Quentinou 0:e25a8207e8a1 325 #define LCD_PCF2_CONTRAST 0x20
Quentinou 0:e25a8207e8a1 326 #define LCD_PCF2_S12 0x02
Quentinou 0:e25a8207e8a1 327
Quentinou 0:e25a8207e8a1 328 //PT6314 VFD display
Quentinou 0:e25a8207e8a1 329 //Contrast setting 2 significant bits
Quentinou 0:e25a8207e8a1 330 #define LCD_PT63_CONTRAST 0x00
Quentinou 0:e25a8207e8a1 331
Quentinou 0:e25a8207e8a1 332 /** Some sample User Defined Chars 5x7 dots */
Quentinou 0:e25a8207e8a1 333 //extern const char udc_ae[]; //æ
Quentinou 0:e25a8207e8a1 334 //extern const char udc_0e[]; //ø
Quentinou 0:e25a8207e8a1 335 //extern const char udc_ao[]; //å
Quentinou 0:e25a8207e8a1 336 //extern const char udc_AE[]; //Æ
Quentinou 0:e25a8207e8a1 337 //extern const char udc_0E[]; //Ø
Quentinou 0:e25a8207e8a1 338 //extern const char udc_Ao[]; //Å
Quentinou 0:e25a8207e8a1 339 //extern const char udc_PO[]; //Padlock Open
Quentinou 0:e25a8207e8a1 340 //extern const char udc_PC[]; //Padlock Closed
Quentinou 0:e25a8207e8a1 341
Quentinou 0:e25a8207e8a1 342 //extern const char udc_alpha[]; //alpha
Quentinou 0:e25a8207e8a1 343 //extern const char udc_ohm[]; //ohm
Quentinou 0:e25a8207e8a1 344 //extern const char udc_sigma[]; //sigma
Quentinou 0:e25a8207e8a1 345 //extern const char udc_pi[]; //pi
Quentinou 0:e25a8207e8a1 346 //extern const char udc_root[]; //root
Quentinou 0:e25a8207e8a1 347
Quentinou 0:e25a8207e8a1 348
Quentinou 0:e25a8207e8a1 349 extern const char udc_0[]; // |>
Quentinou 0:e25a8207e8a1 350 extern const char udc_1[]; // <|
Quentinou 0:e25a8207e8a1 351 extern const char udc_2[]; // |
Quentinou 0:e25a8207e8a1 352 extern const char udc_3[]; // ||
Quentinou 0:e25a8207e8a1 353 extern const char udc_4[]; // |||
Quentinou 0:e25a8207e8a1 354 extern const char udc_5[]; // =
Quentinou 0:e25a8207e8a1 355 extern const char udc_6[]; // checkerboard
Quentinou 0:e25a8207e8a1 356 extern const char udc_7[]; // \
Quentinou 0:e25a8207e8a1 357
Quentinou 0:e25a8207e8a1 358 extern const char udc_degr[]; // Degree symbol
Quentinou 0:e25a8207e8a1 359
Quentinou 0:e25a8207e8a1 360 extern const char udc_TM_T[]; // Trademark T
Quentinou 0:e25a8207e8a1 361 extern const char udc_TM_M[]; // Trademark M
Quentinou 0:e25a8207e8a1 362
Quentinou 0:e25a8207e8a1 363 //extern const char udc_Bat_Hi[]; // Battery Full
Quentinou 0:e25a8207e8a1 364 //extern const char udc_Bat_Ha[]; // Battery Half
Quentinou 0:e25a8207e8a1 365 //extern const char udc_Bat_Lo[]; // Battery Low
Quentinou 0:e25a8207e8a1 366 extern const char udc_Bat_Hi[]; // Battery Full
Quentinou 0:e25a8207e8a1 367 extern const char udc_Bat_Ha[]; // Battery Half
Quentinou 0:e25a8207e8a1 368 extern const char udc_Bat_Lo[]; // Battery Low
Quentinou 0:e25a8207e8a1 369 extern const char udc_AC[]; // AC Power
Quentinou 0:e25a8207e8a1 370
Quentinou 0:e25a8207e8a1 371 //extern const char udc_smiley[]; // Smiley
Quentinou 0:e25a8207e8a1 372 //extern const char udc_droopy[]; // Droopey
Quentinou 0:e25a8207e8a1 373 //extern const char udc_note[]; // Note
Quentinou 0:e25a8207e8a1 374
Quentinou 0:e25a8207e8a1 375 //extern const char udc_bar_1[]; // Bar 1
Quentinou 0:e25a8207e8a1 376 //extern const char udc_bar_2[]; // Bar 11
Quentinou 0:e25a8207e8a1 377 //extern const char udc_bar_3[]; // Bar 111
Quentinou 0:e25a8207e8a1 378 //extern const char udc_bar_4[]; // Bar 1111
Quentinou 0:e25a8207e8a1 379 //extern const char udc_bar_5[]; // Bar 11111
Quentinou 0:e25a8207e8a1 380
Quentinou 0:e25a8207e8a1 381 //extern const char udc_ch_1[]; // Hor bars 4
Quentinou 0:e25a8207e8a1 382 //extern const char udc_ch_2[]; // Hor bars 4 (inverted)
Quentinou 0:e25a8207e8a1 383 //extern const char udc_ch_3[]; // Ver bars 3
Quentinou 0:e25a8207e8a1 384 //extern const char udc_ch_4[]; // Ver bars 3 (inverted)
Quentinou 0:e25a8207e8a1 385 //extern const char udc_ch_yr[]; // Year (kana)
Quentinou 0:e25a8207e8a1 386 //extern const char udc_ch_mo[]; // Month (kana)
Quentinou 0:e25a8207e8a1 387 //extern const char udc_ch_dy[]; // Day (kana)
Quentinou 0:e25a8207e8a1 388 //extern const char udc_ch_mi[]; // minute (kana)
Quentinou 0:e25a8207e8a1 389 extern const char udc_None[];
Quentinou 0:e25a8207e8a1 390 extern const char udc_All[];
Quentinou 0:e25a8207e8a1 391
Quentinou 0:e25a8207e8a1 392 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
Quentinou 0:e25a8207e8a1 393 *
Quentinou 0:e25a8207e8a1 394 * @brief Currently supports 8x1, 8x2, 12x2, 12x3, 12x4, 16x1, 16x2, 16x3, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels
Quentinou 0:e25a8207e8a1 395 * Interface options include direct mbed pins, I2C portexpander (PCF8474/PCF8574A or MCP23008) or SPI bus shiftregister (74595) and some native I2C or SPI devices
Quentinou 0:e25a8207e8a1 396 *
Quentinou 0:e25a8207e8a1 397 */
Quentinou 0:e25a8207e8a1 398 class TextLCD_Base : public Stream {
Quentinou 0:e25a8207e8a1 399 public:
Quentinou 0:e25a8207e8a1 400
Quentinou 0:e25a8207e8a1 401 /** LCD panel format */
Quentinou 0:e25a8207e8a1 402 // The commented out types exist but have not yet been tested with the library
Quentinou 0:e25a8207e8a1 403 enum LCDType {
Quentinou 0:e25a8207e8a1 404 // LCD6x1 = (LCD_T_A | LCD_T_C6 | LCD_T_R1), /**< 6x1 LCD panel */
Quentinou 0:e25a8207e8a1 405 // LCD6x2 = (LCD_T_A | LCD_T_C6 | LCD_T_R2), /**< 6x2 LCD panel */
Quentinou 0:e25a8207e8a1 406 LCD8x1 = (LCD_T_A | LCD_T_C8 | LCD_T_R1), /**< 8x1 LCD panel */
Quentinou 0:e25a8207e8a1 407 LCD8x2 = (LCD_T_A | LCD_T_C8 | LCD_T_R2), /**< 8x2 LCD panel */
Quentinou 0:e25a8207e8a1 408 LCD8x2B = (LCD_T_D | LCD_T_C8 | LCD_T_R2), /**< 8x2 LCD panel (actually 16x1) */
Quentinou 0:e25a8207e8a1 409 // LCD12x1 = (LCD_T_A | LCD_T_C12 | LCD_T_R1), /**< 12x1 LCD panel */
Quentinou 0:e25a8207e8a1 410 LCD12x2 = (LCD_T_A | LCD_T_C12 | LCD_T_R2), /**< 12x2 LCD panel */
Quentinou 0:e25a8207e8a1 411 LCD12x3D = (LCD_T_D | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode PCF21XX */
Quentinou 0:e25a8207e8a1 412 LCD12x3D1 = (LCD_T_D1 | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode PCF21XX */
Quentinou 0:e25a8207e8a1 413 // LCD12x3G = (LCD_T_G | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode ST7036 */
Quentinou 0:e25a8207e8a1 414 LCD12x4 = (LCD_T_A | LCD_T_C12 | LCD_T_R4), /**< 12x4 LCD panel */
Quentinou 0:e25a8207e8a1 415 LCD12x4D = (LCD_T_B | LCD_T_C12 | LCD_T_R4), /**< 12x4 LCD panel, special mode PCF21XX */
Quentinou 0:e25a8207e8a1 416 LCD16x1 = (LCD_T_A | LCD_T_C16 | LCD_T_R1), /**< 16x1 LCD panel */
Quentinou 0:e25a8207e8a1 417 LCD16x1C = (LCD_T_C | LCD_T_C16 | LCD_T_R1), /**< 16x1 LCD panel (actually 8x2) */
Quentinou 0:e25a8207e8a1 418 LCD16x2 = (LCD_T_A | LCD_T_C16 | LCD_T_R2), /**< 16x2 LCD panel (default) */
Quentinou 0:e25a8207e8a1 419 // LCD16x2B = (LCD_T_B | LCD_T_C16 | LCD_T_R2), /**< 16x2 LCD panel, alternate addressing, wrong.. */
Quentinou 0:e25a8207e8a1 420 LCD16x3D = (LCD_T_D | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode SSD1803 */
Quentinou 0:e25a8207e8a1 421 // LCD16x3D1 = (LCD_T_D1 | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode SSD1803 */
Quentinou 0:e25a8207e8a1 422 LCD16x3F = (LCD_T_F | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel (actually 24x2) */
Quentinou 0:e25a8207e8a1 423 LCD16x3G = (LCD_T_G | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode ST7036 */
Quentinou 0:e25a8207e8a1 424 LCD16x4 = (LCD_T_A | LCD_T_C16 | LCD_T_R4), /**< 16x4 LCD panel */
Quentinou 0:e25a8207e8a1 425 // LCD16x4D = (LCD_T_D | LCD_T_C16 | LCD_T_R4), /**< 16x4 LCD panel, special mode SSD1803 */
Quentinou 0:e25a8207e8a1 426 // LCD20x1 = (LCD_T_A | LCD_T_C20 | LCD_T_R1), /**< 20x1 LCD panel */
Quentinou 0:e25a8207e8a1 427 LCD20x2 = (LCD_T_A | LCD_T_C20 | LCD_T_R2), /**< 20x2 LCD panel */
Quentinou 0:e25a8207e8a1 428 // LCD20x3 = (LCD_T_A | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel */
Quentinou 0:e25a8207e8a1 429 // LCD20x3D = (LCD_T_D | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel, special mode SSD1803 */
Quentinou 0:e25a8207e8a1 430 // LCD20x3D1 = (LCD_T_D1 | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel, special mode SSD1803 */
Quentinou 0:e25a8207e8a1 431 LCD20x4 = (LCD_T_A | LCD_T_C20 | LCD_T_R4), /**< 20x4 LCD panel */
Quentinou 0:e25a8207e8a1 432 LCD20x4D = (LCD_T_D | LCD_T_C20 | LCD_T_R4), /**< 20x4 LCD panel, special mode SSD1803 */
Quentinou 0:e25a8207e8a1 433 LCD24x1 = (LCD_T_A | LCD_T_C24 | LCD_T_R1), /**< 24x1 LCD panel */
Quentinou 0:e25a8207e8a1 434 LCD24x2 = (LCD_T_A | LCD_T_C24 | LCD_T_R2), /**< 24x2 LCD panel */
Quentinou 0:e25a8207e8a1 435 // LCD24x3D = (LCD_T_D | LCD_T_C24 | LCD_T_R3), /**< 24x3 LCD panel */
Quentinou 0:e25a8207e8a1 436 // LCD24x3D1 = (LCD_T_D | LCD_T_C24 | LCD_T_R3), /**< 24x3 LCD panel */
Quentinou 0:e25a8207e8a1 437 LCD24x4D = (LCD_T_D | LCD_T_C24 | LCD_T_R4), /**< 24x4 LCD panel, special mode KS0078 */
Quentinou 0:e25a8207e8a1 438 // LCD32x1 = (LCD_T_A | LCD_T_C32 | LCD_T_R1), /**< 32x1 LCD panel */
Quentinou 0:e25a8207e8a1 439 // LCD32x1C = (LCD_T_C | LCD_T_C32 | LCD_T_R1), /**< 32x1 LCD panel (actually 16x2) */
Quentinou 0:e25a8207e8a1 440 // LCD32x2 = (LCD_T_A | LCD_T_C32 | LCD_T_R2), /**< 32x2 LCD panel */
Quentinou 0:e25a8207e8a1 441 // LCD32x4 = (LCD_T_A | LCD_T_C32 | LCD_T_R4), /**< 32x4 LCD panel */
Quentinou 0:e25a8207e8a1 442 // LCD40x1 = (LCD_T_A | LCD_T_C40 | LCD_T_R1), /**< 40x1 LCD panel */
Quentinou 0:e25a8207e8a1 443 // LCD40x1C = (LCD_T_C | LCD_T_C40 | LCD_T_R1), /**< 40x1 LCD panel (actually 20x2) */
Quentinou 0:e25a8207e8a1 444 LCD40x2 = (LCD_T_A | LCD_T_C40 | LCD_T_R2), /**< 40x2 LCD panel */
Quentinou 0:e25a8207e8a1 445 LCD40x4 = (LCD_T_E | LCD_T_C40 | LCD_T_R4) /**< 40x4 LCD panel, Two controller version */
Quentinou 0:e25a8207e8a1 446 };
Quentinou 0:e25a8207e8a1 447
Quentinou 0:e25a8207e8a1 448
Quentinou 0:e25a8207e8a1 449 /** LCD Controller Device */
Quentinou 0:e25a8207e8a1 450 enum LCDCtrl {
Quentinou 0:e25a8207e8a1 451 HD44780 = 0 | LCD_C_PAR, /**< HD44780 or full equivalent (default) */
Quentinou 0:e25a8207e8a1 452 WS0010 = 1 | (LCD_C_PAR | LCD_C_SPI3_10 | LCD_C_BST), /**< WS0010 OLED Controller, 4/8 bit, SPI3 */
Quentinou 0:e25a8207e8a1 453 ST7036_3V3 = 2 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7036 3V3 with Booster, 4/8 bit, SPI4, I2C */
Quentinou 0:e25a8207e8a1 454 ST7036_5V = 3 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7036 5V no Booster, 4/8 bit, SPI4, I2C */
Quentinou 0:e25a8207e8a1 455 ST7032_3V3 = 4 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7032 3V3 with Booster, 4/8 bit, SPI4, I2C */
Quentinou 0:e25a8207e8a1 456 ST7032_5V = 5 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_CTR), /**< ST7032 5V no Booster, 4/8 bit, SPI4, I2C */
Quentinou 0:e25a8207e8a1 457 KS0078 = 6 | (LCD_C_PAR | LCD_C_SPI3_24), /**< KS0078 24x4 support, 4/8 bit, SPI3 */
Quentinou 0:e25a8207e8a1 458 PCF2113_3V3 = 7 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< PCF2113 3V3 with Booster, 4/8 bit, I2C */
Quentinou 0:e25a8207e8a1 459 PCF2116_3V3 = 8 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST), /**< PCF2116 3V3 with Booster, 4/8 bit, I2C */
Quentinou 0:e25a8207e8a1 460 PCF2116_5V = 9 | (LCD_C_PAR | LCD_C_I2C), /**< PCF2116 5V no Booster, 4/8 bit, I2C */
Quentinou 0:e25a8207e8a1 461 PCF2119_3V3 = 10 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< PCF2119 3V3 with Booster, 4/8 bit, I2C */
Quentinou 0:e25a8207e8a1 462 // PCF2119_5V = 11 | (LCD_C_PAR | LCD_C_I2C), /**< PCF2119 5V no Booster, 4/8 bit, I2C */
Quentinou 0:e25a8207e8a1 463 AIP31068 = 12 | (LCD_C_SPI3_9 | LCD_C_I2C | LCD_C_BST), /**< AIP31068 I2C, SPI3 */
Quentinou 0:e25a8207e8a1 464 SSD1803_3V3 = 13 | (LCD_C_PAR | LCD_C_SPI3_24 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR | LCD_C_PDN), /**< SSD1803 3V3 with Booster, 4/8 bit, I2C, SPI3 */
Quentinou 0:e25a8207e8a1 465 // SSD1803_5V = 14 | (LCD_C_PAR | LCD_C_SPI3_24 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR | LCD_C_PDN), /**< SSD1803 3V3 with Booster, 4/8 bit, I2C, SPI3 */
Quentinou 0:e25a8207e8a1 466 US2066_3V3 = 15 | (LCD_C_PAR | LCD_C_SPI3_24 | LCD_C_I2C | LCD_C_CTR | LCD_C_PDN), /**< US2066/SSD1311 3V3, 4/8 bit, I2C, SPI3 */
Quentinou 0:e25a8207e8a1 467 // PT6314 = 16 | (LCD_C_PAR | LCD_C_SPI3_16 | LCD_C_CTR | LCD_C_PDN), /**< PT6314 VFD, 4/8 bit, SPI3 */
Quentinou 0:e25a8207e8a1 468 // AC780 = 17 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_PDN), /**< AC780 4/8 bit, SPI, I2C */
Quentinou 0:e25a8207e8a1 469 // KS0066 = 18 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_PDN) /**< KS0066i == AC780 4/8 bit, SPI, I2C */
Quentinou 0:e25a8207e8a1 470 };
Quentinou 0:e25a8207e8a1 471
Quentinou 0:e25a8207e8a1 472
Quentinou 0:e25a8207e8a1 473 /** LCD Cursor control */
Quentinou 0:e25a8207e8a1 474 enum LCDCursor {
Quentinou 0:e25a8207e8a1 475 CurOff_BlkOff = 0x00, /**< Cursor Off, Blinking Char Off */
Quentinou 0:e25a8207e8a1 476 CurOn_BlkOff = 0x02, /**< Cursor On, Blinking Char Off */
Quentinou 0:e25a8207e8a1 477 CurOff_BlkOn = 0x01, /**< Cursor Off, Blinking Char On */
Quentinou 0:e25a8207e8a1 478 CurOn_BlkOn = 0x03 /**< Cursor On, Blinking Char On */
Quentinou 0:e25a8207e8a1 479 };
Quentinou 0:e25a8207e8a1 480
Quentinou 0:e25a8207e8a1 481 /** LCD Display control */
Quentinou 0:e25a8207e8a1 482 enum LCDMode {
Quentinou 0:e25a8207e8a1 483 DispOff = 0x00, /**< Display Off */
Quentinou 0:e25a8207e8a1 484 DispOn = 0x04 /**< Display On */
Quentinou 0:e25a8207e8a1 485 };
Quentinou 0:e25a8207e8a1 486
Quentinou 0:e25a8207e8a1 487 /** LCD Backlight control */
Quentinou 0:e25a8207e8a1 488 enum LCDBacklight {
Quentinou 0:e25a8207e8a1 489 LightOff, /**< Backlight Off */
Quentinou 0:e25a8207e8a1 490 LightOn /**< Backlight On */
Quentinou 0:e25a8207e8a1 491 };
Quentinou 0:e25a8207e8a1 492
Quentinou 0:e25a8207e8a1 493 /** LCD Blink control (UDC), supported for some Controllers */
Quentinou 0:e25a8207e8a1 494 enum LCDBlink {
Quentinou 0:e25a8207e8a1 495 BlinkOff, /**< Blink Off */
Quentinou 0:e25a8207e8a1 496 BlinkOn /**< Blink On */
Quentinou 0:e25a8207e8a1 497 };
Quentinou 0:e25a8207e8a1 498
Quentinou 0:e25a8207e8a1 499 /** LCD Orientation control, supported for some Controllers */
Quentinou 0:e25a8207e8a1 500 enum LCDOrient {
Quentinou 0:e25a8207e8a1 501 Top, /**< Top view */
Quentinou 0:e25a8207e8a1 502 Bottom /**< Upside down view */
Quentinou 0:e25a8207e8a1 503 };
Quentinou 0:e25a8207e8a1 504
Quentinou 0:e25a8207e8a1 505
Quentinou 0:e25a8207e8a1 506 #if DOXYGEN_ONLY
Quentinou 0:e25a8207e8a1 507 /** Write a character to the LCD
Quentinou 0:e25a8207e8a1 508 *
Quentinou 0:e25a8207e8a1 509 * @param c The character to write to the display
Quentinou 0:e25a8207e8a1 510 */
Quentinou 0:e25a8207e8a1 511 int putc(int c);
Quentinou 0:e25a8207e8a1 512
Quentinou 0:e25a8207e8a1 513 /** Write a formated string to the LCD
Quentinou 0:e25a8207e8a1 514 *
Quentinou 0:e25a8207e8a1 515 * @param format A printf-style format string, followed by the
Quentinou 0:e25a8207e8a1 516 * variables to use in formating the string.
Quentinou 0:e25a8207e8a1 517 */
Quentinou 0:e25a8207e8a1 518 int printf(const char* format, ...);
Quentinou 0:e25a8207e8a1 519 #endif
Quentinou 0:e25a8207e8a1 520
Quentinou 0:e25a8207e8a1 521 /** Locate cursor to a screen column and row
Quentinou 0:e25a8207e8a1 522 *
Quentinou 0:e25a8207e8a1 523 * @param column The horizontal position from the left, indexed from 0
Quentinou 0:e25a8207e8a1 524 * @param row The vertical position from the top, indexed from 0
Quentinou 0:e25a8207e8a1 525 */
Quentinou 0:e25a8207e8a1 526 void locate(int column, int row);
Quentinou 0:e25a8207e8a1 527
Quentinou 0:e25a8207e8a1 528 /** Return the memoryaddress of screen column and row location
Quentinou 0:e25a8207e8a1 529 *
Quentinou 0:e25a8207e8a1 530 * @param column The horizontal position from the left, indexed from 0
Quentinou 0:e25a8207e8a1 531 * @param row The vertical position from the top, indexed from 0
Quentinou 0:e25a8207e8a1 532 * @param return The memoryaddress of screen column and row location
Quentinou 0:e25a8207e8a1 533 */
Quentinou 0:e25a8207e8a1 534 int getAddress(int column, int row);
Quentinou 0:e25a8207e8a1 535
Quentinou 0:e25a8207e8a1 536 /** Set the memoryaddress of screen column and row location
Quentinou 0:e25a8207e8a1 537 *
Quentinou 0:e25a8207e8a1 538 * @param column The horizontal position from the left, indexed from 0
Quentinou 0:e25a8207e8a1 539 * @param row The vertical position from the top, indexed from 0
Quentinou 0:e25a8207e8a1 540 */
Quentinou 0:e25a8207e8a1 541 void setAddress(int column, int row);
Quentinou 0:e25a8207e8a1 542
Quentinou 0:e25a8207e8a1 543 /** Clear the screen and locate to 0,0
Quentinou 0:e25a8207e8a1 544 */
Quentinou 0:e25a8207e8a1 545 void cls();
Quentinou 0:e25a8207e8a1 546
Quentinou 0:e25a8207e8a1 547 /** Return the number of rows
Quentinou 0:e25a8207e8a1 548 *
Quentinou 0:e25a8207e8a1 549 * @param return The number of rows
Quentinou 0:e25a8207e8a1 550 */
Quentinou 0:e25a8207e8a1 551 int rows();
Quentinou 0:e25a8207e8a1 552
Quentinou 0:e25a8207e8a1 553 /** Return the number of columns
Quentinou 0:e25a8207e8a1 554 *
Quentinou 0:e25a8207e8a1 555 * @param return The number of columns
Quentinou 0:e25a8207e8a1 556 */
Quentinou 0:e25a8207e8a1 557 int columns();
Quentinou 0:e25a8207e8a1 558
Quentinou 0:e25a8207e8a1 559 /** Set the Cursormode
Quentinou 0:e25a8207e8a1 560 *
Quentinou 0:e25a8207e8a1 561 * @param cursorMode The Cursor mode (CurOff_BlkOff, CurOn_BlkOff, CurOff_BlkOn, CurOn_BlkOn)
Quentinou 0:e25a8207e8a1 562 */
Quentinou 0:e25a8207e8a1 563 void setCursor(LCDCursor cursorMode);
Quentinou 0:e25a8207e8a1 564
Quentinou 0:e25a8207e8a1 565 /** Set the Displaymode
Quentinou 0:e25a8207e8a1 566 *
Quentinou 0:e25a8207e8a1 567 * @param displayMode The Display mode (DispOff, DispOn)
Quentinou 0:e25a8207e8a1 568 */
Quentinou 0:e25a8207e8a1 569 void setMode(LCDMode displayMode);
Quentinou 0:e25a8207e8a1 570
Quentinou 0:e25a8207e8a1 571 /** Set the Backlight mode
Quentinou 0:e25a8207e8a1 572 *
Quentinou 0:e25a8207e8a1 573 * @param backlightMode The Backlight mode (LightOff, LightOn)
Quentinou 0:e25a8207e8a1 574 */
Quentinou 0:e25a8207e8a1 575 void setBacklight(LCDBacklight backlightMode);
Quentinou 0:e25a8207e8a1 576
Quentinou 0:e25a8207e8a1 577 /** Set User Defined Characters (UDC)
Quentinou 0:e25a8207e8a1 578 *
Quentinou 0:e25a8207e8a1 579 * @param unsigned char c The Index of the UDC (0..7)
Quentinou 0:e25a8207e8a1 580 * @param char *udc_data The bitpatterns for the UDC (8 bytes of 5 significant bits)
Quentinou 0:e25a8207e8a1 581 */
Quentinou 0:e25a8207e8a1 582 void setUDC(unsigned char c, char *udc_data);
Quentinou 0:e25a8207e8a1 583
Quentinou 0:e25a8207e8a1 584 /** Set UDC Blink
Quentinou 0:e25a8207e8a1 585 * setUDCBlink method is supported by some compatible devices (eg SSD1803)
Quentinou 0:e25a8207e8a1 586 *
Quentinou 0:e25a8207e8a1 587 * @param blinkMode The Blink mode (BlinkOff, BlinkOn)
Quentinou 0:e25a8207e8a1 588 */
Quentinou 0:e25a8207e8a1 589 void setUDCBlink(LCDBlink blinkMode);
Quentinou 0:e25a8207e8a1 590
Quentinou 0:e25a8207e8a1 591 /** Set Contrast
Quentinou 0:e25a8207e8a1 592 * setContrast method is supported by some compatible devices (eg ST7032i) that have onboard LCD voltage generation
Quentinou 0:e25a8207e8a1 593 * Code imported from fork by JH1PJL
Quentinou 0:e25a8207e8a1 594 *
Quentinou 0:e25a8207e8a1 595 * @param unsigned char c contrast data (6 significant bits, valid range 0..63, Value 0 will disable the Vgen)
Quentinou 0:e25a8207e8a1 596 * @return none
Quentinou 0:e25a8207e8a1 597 */
Quentinou 0:e25a8207e8a1 598 void setContrast(unsigned char c = LCD_DEF_CONTRAST);
Quentinou 0:e25a8207e8a1 599
Quentinou 0:e25a8207e8a1 600 /** Set Power
Quentinou 0:e25a8207e8a1 601 * setPower method is supported by some compatible devices (eg SSD1803) that have power down modes
Quentinou 0:e25a8207e8a1 602 *
Quentinou 0:e25a8207e8a1 603 * @param bool powerOn Power on/off
Quentinou 0:e25a8207e8a1 604 * @return none
Quentinou 0:e25a8207e8a1 605 */
Quentinou 0:e25a8207e8a1 606 void setPower(bool powerOn = true);
Quentinou 0:e25a8207e8a1 607
Quentinou 0:e25a8207e8a1 608 /** Set Orient
Quentinou 0:e25a8207e8a1 609 * setOrient method is supported by some compatible devices (eg SSD1803, US2066) that have top/bottom view modes
Quentinou 0:e25a8207e8a1 610 *
Quentinou 0:e25a8207e8a1 611 * @param LCDOrient orient Orientation
Quentinou 0:e25a8207e8a1 612 * @return none
Quentinou 0:e25a8207e8a1 613 */
Quentinou 0:e25a8207e8a1 614 void setOrient(LCDOrient orient = Top);
Quentinou 0:e25a8207e8a1 615
Quentinou 0:e25a8207e8a1 616
Quentinou 0:e25a8207e8a1 617 //test
Quentinou 0:e25a8207e8a1 618 // void _initCtrl();
Quentinou 0:e25a8207e8a1 619
Quentinou 0:e25a8207e8a1 620 protected:
Quentinou 0:e25a8207e8a1 621
Quentinou 0:e25a8207e8a1 622 /** LCD controller select, mainly used for LCD40x4
Quentinou 0:e25a8207e8a1 623 */
Quentinou 0:e25a8207e8a1 624 enum _LCDCtrl_Idx {
Quentinou 0:e25a8207e8a1 625 _LCDCtrl_0, /*< Primary */
Quentinou 0:e25a8207e8a1 626 _LCDCtrl_1, /*< Secondary */
Quentinou 0:e25a8207e8a1 627 };
Quentinou 0:e25a8207e8a1 628
Quentinou 0:e25a8207e8a1 629 /** Create a TextLCD_Base interface
Quentinou 0:e25a8207e8a1 630 * @brief Base class, can not be instantiated
Quentinou 0:e25a8207e8a1 631 *
Quentinou 0:e25a8207e8a1 632 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 633 * @param ctrl LCD controller (default = HD44780)
Quentinou 0:e25a8207e8a1 634 */
Quentinou 0:e25a8207e8a1 635 TextLCD_Base(LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
Quentinou 0:e25a8207e8a1 636
Quentinou 0:e25a8207e8a1 637 // Stream implementation functions
Quentinou 0:e25a8207e8a1 638 virtual int _putc(int value);
Quentinou 0:e25a8207e8a1 639 virtual int _getc();
Quentinou 0:e25a8207e8a1 640
Quentinou 0:e25a8207e8a1 641 /** Low level method for LCD controller
Quentinou 0:e25a8207e8a1 642 */
Quentinou 0:e25a8207e8a1 643 void _init();
Quentinou 0:e25a8207e8a1 644
Quentinou 0:e25a8207e8a1 645 /** Low level initialisation method for LCD controller
Quentinou 0:e25a8207e8a1 646 */
Quentinou 0:e25a8207e8a1 647 void _initCtrl();
Quentinou 0:e25a8207e8a1 648
Quentinou 0:e25a8207e8a1 649 /** Low level character address set method
Quentinou 0:e25a8207e8a1 650 */
Quentinou 0:e25a8207e8a1 651 int _address(int column, int row);
Quentinou 0:e25a8207e8a1 652
Quentinou 0:e25a8207e8a1 653 /** Low level cursor enable or disable method
Quentinou 0:e25a8207e8a1 654 */
Quentinou 0:e25a8207e8a1 655 void _setCursor(LCDCursor show);
Quentinou 0:e25a8207e8a1 656
Quentinou 0:e25a8207e8a1 657 /** Low level method to store user defined characters for current controller
Quentinou 0:e25a8207e8a1 658 */
Quentinou 0:e25a8207e8a1 659 void _setUDC(unsigned char c, char *udc_data);
Quentinou 0:e25a8207e8a1 660
Quentinou 0:e25a8207e8a1 661 /** Low level method to restore the cursortype and display mode for current controller
Quentinou 0:e25a8207e8a1 662 */
Quentinou 0:e25a8207e8a1 663 void _setCursorAndDisplayMode(LCDMode displayMode, LCDCursor cursorType);
Quentinou 0:e25a8207e8a1 664
Quentinou 0:e25a8207e8a1 665 /** Low level nibble write operation to LCD controller (serial or parallel)
Quentinou 0:e25a8207e8a1 666 */
Quentinou 0:e25a8207e8a1 667 void _writeNibble(int value);
Quentinou 0:e25a8207e8a1 668
Quentinou 0:e25a8207e8a1 669 /** Low level command byte write operation to LCD controller.
Quentinou 0:e25a8207e8a1 670 * Methods resets the RS bit and provides the required timing for the command.
Quentinou 0:e25a8207e8a1 671 */
Quentinou 0:e25a8207e8a1 672 void _writeCommand(int command);
Quentinou 0:e25a8207e8a1 673
Quentinou 0:e25a8207e8a1 674 /** Low level data byte write operation to LCD controller (serial or parallel).
Quentinou 0:e25a8207e8a1 675 * Methods sets the RS bit and provides the required timing for the data.
Quentinou 0:e25a8207e8a1 676 */
Quentinou 0:e25a8207e8a1 677 void _writeData(int data);
Quentinou 0:e25a8207e8a1 678
Quentinou 0:e25a8207e8a1 679 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
Quentinou 0:e25a8207e8a1 680 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 681 */
Quentinou 0:e25a8207e8a1 682 virtual void _setEnable(bool value) = 0;
Quentinou 0:e25a8207e8a1 683
Quentinou 0:e25a8207e8a1 684 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
Quentinou 0:e25a8207e8a1 685 * Set the RS pin ( 0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 686 */
Quentinou 0:e25a8207e8a1 687 virtual void _setRS(bool value) = 0;
Quentinou 0:e25a8207e8a1 688
Quentinou 0:e25a8207e8a1 689 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
Quentinou 0:e25a8207e8a1 690 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 691 */
Quentinou 0:e25a8207e8a1 692 virtual void _setBL(bool value) = 0;
Quentinou 0:e25a8207e8a1 693
Quentinou 0:e25a8207e8a1 694 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
Quentinou 0:e25a8207e8a1 695 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 696 */
Quentinou 0:e25a8207e8a1 697 virtual void _setData(int value) = 0;
Quentinou 0:e25a8207e8a1 698
Quentinou 0:e25a8207e8a1 699 /** Low level byte write operation to LCD controller (serial or parallel)
Quentinou 0:e25a8207e8a1 700 * Depending on the RS pin this byte will be interpreted as data or command
Quentinou 0:e25a8207e8a1 701 */
Quentinou 0:e25a8207e8a1 702 virtual void _writeByte(int value);
Quentinou 0:e25a8207e8a1 703
Quentinou 0:e25a8207e8a1 704 //Display type
Quentinou 0:e25a8207e8a1 705 LCDType _type;
Quentinou 0:e25a8207e8a1 706 int _nr_cols;
Quentinou 0:e25a8207e8a1 707 int _nr_rows;
Quentinou 0:e25a8207e8a1 708 int _addr_mode;
Quentinou 0:e25a8207e8a1 709
Quentinou 0:e25a8207e8a1 710 //Display mode
Quentinou 0:e25a8207e8a1 711 LCDMode _currentMode;
Quentinou 0:e25a8207e8a1 712
Quentinou 0:e25a8207e8a1 713 //Controller type
Quentinou 0:e25a8207e8a1 714 LCDCtrl _ctrl;
Quentinou 0:e25a8207e8a1 715
Quentinou 0:e25a8207e8a1 716 //Controller select, mainly used for LCD40x4
Quentinou 0:e25a8207e8a1 717 _LCDCtrl_Idx _ctrl_idx;
Quentinou 0:e25a8207e8a1 718
Quentinou 0:e25a8207e8a1 719 // Cursor
Quentinou 0:e25a8207e8a1 720 int _column;
Quentinou 0:e25a8207e8a1 721 int _row;
Quentinou 0:e25a8207e8a1 722 LCDCursor _currentCursor;
Quentinou 0:e25a8207e8a1 723
Quentinou 0:e25a8207e8a1 724 // Function mode saved to allow switch between Instruction sets after initialisation time
Quentinou 0:e25a8207e8a1 725 // Icon, Booster mode and contrast saved to allow contrast change at later time
Quentinou 0:e25a8207e8a1 726 // Only available for controllers with added features
Quentinou 0:e25a8207e8a1 727 int _function, _function_1, _function_x;
Quentinou 0:e25a8207e8a1 728 int _icon_power;
Quentinou 0:e25a8207e8a1 729 int _contrast;
Quentinou 0:e25a8207e8a1 730
Quentinou 0:e25a8207e8a1 731 };
Quentinou 0:e25a8207e8a1 732
Quentinou 0:e25a8207e8a1 733 //--------- End TextLCD_Base -----------
Quentinou 0:e25a8207e8a1 734
Quentinou 0:e25a8207e8a1 735
Quentinou 0:e25a8207e8a1 736
Quentinou 0:e25a8207e8a1 737 //--------- Start TextLCD Bus -----------
Quentinou 0:e25a8207e8a1 738
Quentinou 0:e25a8207e8a1 739 /** Create a TextLCD interface for using regular mbed pins
Quentinou 0:e25a8207e8a1 740 *
Quentinou 0:e25a8207e8a1 741 */
Quentinou 0:e25a8207e8a1 742 class TextLCD : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 743 public:
Quentinou 0:e25a8207e8a1 744 /** Create a TextLCD interface for using regular mbed pins
Quentinou 0:e25a8207e8a1 745 *
Quentinou 0:e25a8207e8a1 746 * @param rs Instruction/data control line
Quentinou 0:e25a8207e8a1 747 * @param e Enable line (clock)
Quentinou 0:e25a8207e8a1 748 * @param d4-d7 Data lines for using as a 4-bit interface
Quentinou 0:e25a8207e8a1 749 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 750 * @param bl Backlight control line (optional, default = NC)
Quentinou 0:e25a8207e8a1 751 * @param e2 Enable2 line (clock for second controller, LCD40x4 only)
Quentinou 0:e25a8207e8a1 752 * @param ctrl LCD controller (default = HD44780)
Quentinou 0:e25a8207e8a1 753 */
Quentinou 0:e25a8207e8a1 754 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);
Quentinou 0:e25a8207e8a1 755
Quentinou 0:e25a8207e8a1 756 /** Destruct a TextLCD interface for using regular mbed pins
Quentinou 0:e25a8207e8a1 757 *
Quentinou 0:e25a8207e8a1 758 * @param none
Quentinou 0:e25a8207e8a1 759 * @return none
Quentinou 0:e25a8207e8a1 760 */
Quentinou 0:e25a8207e8a1 761 virtual ~TextLCD();
Quentinou 0:e25a8207e8a1 762
Quentinou 0:e25a8207e8a1 763 private:
Quentinou 0:e25a8207e8a1 764
Quentinou 0:e25a8207e8a1 765 /** Implementation of pure Virtual Low level writes to LCD Bus (parallel)
Quentinou 0:e25a8207e8a1 766 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 767 */
Quentinou 0:e25a8207e8a1 768 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 769
Quentinou 0:e25a8207e8a1 770 /** Implementation of pure Virtual Low level writes to LCD Bus (parallel)
Quentinou 0:e25a8207e8a1 771 * Set the RS pin (0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 772 */
Quentinou 0:e25a8207e8a1 773 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 774
Quentinou 0:e25a8207e8a1 775 /** Implementation of pure Virtual Low level writes to LCD Bus (parallel)
Quentinou 0:e25a8207e8a1 776 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 777 */
Quentinou 0:e25a8207e8a1 778 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 779
Quentinou 0:e25a8207e8a1 780 /** Implementation of pure Virtual Low level writes to LCD Bus (parallel)
Quentinou 0:e25a8207e8a1 781 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 782 */
Quentinou 0:e25a8207e8a1 783 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 784
Quentinou 0:e25a8207e8a1 785
Quentinou 0:e25a8207e8a1 786 /** Regular mbed pins bus
Quentinou 0:e25a8207e8a1 787 */
Quentinou 0:e25a8207e8a1 788 DigitalOut _rs, _e;
Quentinou 0:e25a8207e8a1 789 BusOut _d;
Quentinou 0:e25a8207e8a1 790
Quentinou 0:e25a8207e8a1 791 /** Optional Hardware pins for the Backlight and LCD40x4 device
Quentinou 0:e25a8207e8a1 792 * Default PinName value is NC, must be used as pointer to avoid issues with mbed lib and DigitalOut pins
Quentinou 0:e25a8207e8a1 793 */
Quentinou 0:e25a8207e8a1 794 DigitalOut *_bl, *_e2;
Quentinou 0:e25a8207e8a1 795 };
Quentinou 0:e25a8207e8a1 796
Quentinou 0:e25a8207e8a1 797
Quentinou 0:e25a8207e8a1 798 //----------- End TextLCD ---------------
Quentinou 0:e25a8207e8a1 799
Quentinou 0:e25a8207e8a1 800
Quentinou 0:e25a8207e8a1 801 //--------- Start TextLCD_I2C -----------
Quentinou 0:e25a8207e8a1 802
Quentinou 0:e25a8207e8a1 803
Quentinou 0:e25a8207e8a1 804 /** Create a TextLCD interface using an I2C PCF8574 (or PCF8574A) or MCP23008 portexpander
Quentinou 0:e25a8207e8a1 805 *
Quentinou 0:e25a8207e8a1 806 */
Quentinou 0:e25a8207e8a1 807 class TextLCD_I2C : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 808 public:
Quentinou 0:e25a8207e8a1 809 /** Create a TextLCD interface using an I2C PCF8574 (or PCF8574A) or MCP23008 portexpander
Quentinou 0:e25a8207e8a1 810 *
Quentinou 0:e25a8207e8a1 811 * @param i2c I2C Bus
Quentinou 0:e25a8207e8a1 812 * @param deviceAddress I2C slave address (PCF8574 or PCF8574A, default = PCF8574_SA0 = 0x40)
Quentinou 0:e25a8207e8a1 813 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 814 * @param ctrl LCD controller (default = HD44780)
Quentinou 0:e25a8207e8a1 815 */
Quentinou 0:e25a8207e8a1 816 TextLCD_I2C(I2C *i2c, char deviceAddress = PCF8574_SA0, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
Quentinou 0:e25a8207e8a1 817
Quentinou 0:e25a8207e8a1 818 private:
Quentinou 0:e25a8207e8a1 819
Quentinou 0:e25a8207e8a1 820 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 821 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 822 */
Quentinou 0:e25a8207e8a1 823 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 824
Quentinou 0:e25a8207e8a1 825 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 826 * Set the RS pin (0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 827 */
Quentinou 0:e25a8207e8a1 828 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 829
Quentinou 0:e25a8207e8a1 830 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 831 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 832 */
Quentinou 0:e25a8207e8a1 833 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 834
Quentinou 0:e25a8207e8a1 835 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 836 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 837 */
Quentinou 0:e25a8207e8a1 838 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 839
Quentinou 0:e25a8207e8a1 840 /** Write data to MCP23008 I2C portexpander
Quentinou 0:e25a8207e8a1 841 * @param reg register to write
Quentinou 0:e25a8207e8a1 842 * @param value data to write
Quentinou 0:e25a8207e8a1 843 * @return none
Quentinou 0:e25a8207e8a1 844 *
Quentinou 0:e25a8207e8a1 845 */
Quentinou 0:e25a8207e8a1 846 void _write_register (int reg, int value);
Quentinou 0:e25a8207e8a1 847
Quentinou 0:e25a8207e8a1 848 //I2C bus
Quentinou 0:e25a8207e8a1 849 I2C *_i2c;
Quentinou 0:e25a8207e8a1 850 char _slaveAddress;
Quentinou 0:e25a8207e8a1 851
Quentinou 0:e25a8207e8a1 852 // Internal bus mirror value for serial bus only
Quentinou 0:e25a8207e8a1 853 char _lcd_bus;
Quentinou 0:e25a8207e8a1 854 };
Quentinou 0:e25a8207e8a1 855
Quentinou 0:e25a8207e8a1 856 //---------- End TextLCD_I2C ------------
Quentinou 0:e25a8207e8a1 857
Quentinou 0:e25a8207e8a1 858
Quentinou 0:e25a8207e8a1 859 //--------- Start TextLCD_SPI -----------
Quentinou 0:e25a8207e8a1 860
Quentinou 0:e25a8207e8a1 861 /** Create a TextLCD interface using an SPI 74595 portexpander
Quentinou 0:e25a8207e8a1 862 *
Quentinou 0:e25a8207e8a1 863 */
Quentinou 0:e25a8207e8a1 864 class TextLCD_SPI : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 865 public:
Quentinou 0:e25a8207e8a1 866 /** Create a TextLCD interface using an SPI 74595 portexpander
Quentinou 0:e25a8207e8a1 867 *
Quentinou 0:e25a8207e8a1 868 * @param spi SPI Bus
Quentinou 0:e25a8207e8a1 869 * @param cs chip select pin (active low)
Quentinou 0:e25a8207e8a1 870 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 871 * @param ctrl LCD controller (default = HD44780)
Quentinou 0:e25a8207e8a1 872 */
Quentinou 0:e25a8207e8a1 873 TextLCD_SPI(SPI *spi, PinName cs, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
Quentinou 0:e25a8207e8a1 874
Quentinou 0:e25a8207e8a1 875 private:
Quentinou 0:e25a8207e8a1 876
Quentinou 0:e25a8207e8a1 877 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 878 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 879 */
Quentinou 0:e25a8207e8a1 880 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 881
Quentinou 0:e25a8207e8a1 882 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 883 * Set the RS pin (0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 884 */
Quentinou 0:e25a8207e8a1 885 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 886
Quentinou 0:e25a8207e8a1 887 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 888 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 889 */
Quentinou 0:e25a8207e8a1 890 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 891
Quentinou 0:e25a8207e8a1 892 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 893 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 894 */
Quentinou 0:e25a8207e8a1 895 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 896
Quentinou 0:e25a8207e8a1 897 /** Implementation of Low level writes to LCD Bus (serial expander)
Quentinou 0:e25a8207e8a1 898 * Set the CS pin (0 = select, 1 = deselect).
Quentinou 0:e25a8207e8a1 899 */
Quentinou 0:e25a8207e8a1 900 virtual void _setCS(bool value);
Quentinou 0:e25a8207e8a1 901
Quentinou 0:e25a8207e8a1 902 ///** Low level writes to LCD serial bus only (serial expander)
Quentinou 0:e25a8207e8a1 903 // */
Quentinou 0:e25a8207e8a1 904 // void _writeBus();
Quentinou 0:e25a8207e8a1 905
Quentinou 0:e25a8207e8a1 906 // SPI bus
Quentinou 0:e25a8207e8a1 907 SPI *_spi;
Quentinou 0:e25a8207e8a1 908 DigitalOut _cs;
Quentinou 0:e25a8207e8a1 909
Quentinou 0:e25a8207e8a1 910 // Internal bus mirror value for serial bus only
Quentinou 0:e25a8207e8a1 911 char _lcd_bus;
Quentinou 0:e25a8207e8a1 912 };
Quentinou 0:e25a8207e8a1 913
Quentinou 0:e25a8207e8a1 914 //---------- End TextLCD_SPI ------------
Quentinou 0:e25a8207e8a1 915
Quentinou 0:e25a8207e8a1 916
Quentinou 0:e25a8207e8a1 917 //--------- Start TextLCD_SPI_N -----------
Quentinou 0:e25a8207e8a1 918
Quentinou 0:e25a8207e8a1 919 /** Create a TextLCD interface using a controller with native SPI4 interface
Quentinou 0:e25a8207e8a1 920 *
Quentinou 0:e25a8207e8a1 921 */
Quentinou 0:e25a8207e8a1 922 class TextLCD_SPI_N : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 923 public:
Quentinou 0:e25a8207e8a1 924 /** Create a TextLCD interface using a controller with native SPI4 interface
Quentinou 0:e25a8207e8a1 925 *
Quentinou 0:e25a8207e8a1 926 * @param spi SPI Bus
Quentinou 0:e25a8207e8a1 927 * @param cs chip select pin (active low)
Quentinou 0:e25a8207e8a1 928 * @param rs Instruction/data control line
Quentinou 0:e25a8207e8a1 929 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 930 * @param bl Backlight control line (optional, default = NC)
Quentinou 0:e25a8207e8a1 931 * @param ctrl LCD controller (default = ST7032_3V3)
Quentinou 0:e25a8207e8a1 932 */
Quentinou 0:e25a8207e8a1 933 TextLCD_SPI_N(SPI *spi, PinName cs, PinName rs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7032_3V3);
Quentinou 0:e25a8207e8a1 934 virtual ~TextLCD_SPI_N(void);
Quentinou 0:e25a8207e8a1 935
Quentinou 0:e25a8207e8a1 936 private:
Quentinou 0:e25a8207e8a1 937
Quentinou 0:e25a8207e8a1 938 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 939 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 940 */
Quentinou 0:e25a8207e8a1 941 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 942
Quentinou 0:e25a8207e8a1 943 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 944 * Set the RS pin (0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 945 */
Quentinou 0:e25a8207e8a1 946 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 947
Quentinou 0:e25a8207e8a1 948 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 949 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 950 */
Quentinou 0:e25a8207e8a1 951 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 952
Quentinou 0:e25a8207e8a1 953 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 954 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 955 */
Quentinou 0:e25a8207e8a1 956 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 957
Quentinou 0:e25a8207e8a1 958 /** Low level writes to LCD serial bus only (serial native)
Quentinou 0:e25a8207e8a1 959 */
Quentinou 0:e25a8207e8a1 960 virtual void _writeByte(int value);
Quentinou 0:e25a8207e8a1 961
Quentinou 0:e25a8207e8a1 962 // SPI bus
Quentinou 0:e25a8207e8a1 963 SPI *_spi;
Quentinou 0:e25a8207e8a1 964 DigitalOut _cs;
Quentinou 0:e25a8207e8a1 965 DigitalOut _rs;
Quentinou 0:e25a8207e8a1 966
Quentinou 0:e25a8207e8a1 967 //Backlight
Quentinou 0:e25a8207e8a1 968 DigitalOut *_bl;
Quentinou 0:e25a8207e8a1 969 };
Quentinou 0:e25a8207e8a1 970
Quentinou 0:e25a8207e8a1 971 //---------- End TextLCD_SPI_N ------------
Quentinou 0:e25a8207e8a1 972
Quentinou 0:e25a8207e8a1 973
Quentinou 0:e25a8207e8a1 974 #if(1)
Quentinou 0:e25a8207e8a1 975 //Code checked out on logic analyser. Not yet tested on hardware..
Quentinou 0:e25a8207e8a1 976
Quentinou 0:e25a8207e8a1 977 //------- Start TextLCD_SPI_N_3_9 ---------
Quentinou 0:e25a8207e8a1 978
Quentinou 0:e25a8207e8a1 979 /** Create a TextLCD interface using a controller with native SPI3 9 bits interface
Quentinou 0:e25a8207e8a1 980 * Note: current mbed libs only support SPI 9 bit mode for NXP platforms
Quentinou 0:e25a8207e8a1 981 *
Quentinou 0:e25a8207e8a1 982 */
Quentinou 0:e25a8207e8a1 983 class TextLCD_SPI_N_3_9 : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 984 public:
Quentinou 0:e25a8207e8a1 985 /** Create a TextLCD interface using a controller with native SPI3 9 bits interface
Quentinou 0:e25a8207e8a1 986 * Note: current mbed libs only support SPI 9 bit mode for NXP platforms
Quentinou 0:e25a8207e8a1 987 *
Quentinou 0:e25a8207e8a1 988 * @param spi SPI Bus
Quentinou 0:e25a8207e8a1 989 * @param cs chip select pin (active low)
Quentinou 0:e25a8207e8a1 990 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 991 * @param bl Backlight control line (optional, default = NC)
Quentinou 0:e25a8207e8a1 992 * @param ctrl LCD controller (default = AIP31068)
Quentinou 0:e25a8207e8a1 993 */
Quentinou 0:e25a8207e8a1 994 TextLCD_SPI_N_3_9(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = AIP31068);
Quentinou 0:e25a8207e8a1 995 virtual ~TextLCD_SPI_N_3_9(void);
Quentinou 0:e25a8207e8a1 996
Quentinou 0:e25a8207e8a1 997 private:
Quentinou 0:e25a8207e8a1 998
Quentinou 0:e25a8207e8a1 999 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1000 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 1001 */
Quentinou 0:e25a8207e8a1 1002 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 1003
Quentinou 0:e25a8207e8a1 1004 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1005 * Set the RS pin (0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 1006 */
Quentinou 0:e25a8207e8a1 1007 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 1008
Quentinou 0:e25a8207e8a1 1009 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1010 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 1011 */
Quentinou 0:e25a8207e8a1 1012 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 1013
Quentinou 0:e25a8207e8a1 1014 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1015 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 1016 */
Quentinou 0:e25a8207e8a1 1017 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 1018
Quentinou 0:e25a8207e8a1 1019 /** Low level writes to LCD serial bus only (serial native)
Quentinou 0:e25a8207e8a1 1020 */
Quentinou 0:e25a8207e8a1 1021 virtual void _writeByte(int value);
Quentinou 0:e25a8207e8a1 1022
Quentinou 0:e25a8207e8a1 1023 // SPI bus
Quentinou 0:e25a8207e8a1 1024 SPI *_spi;
Quentinou 0:e25a8207e8a1 1025 DigitalOut _cs;
Quentinou 0:e25a8207e8a1 1026
Quentinou 0:e25a8207e8a1 1027
Quentinou 0:e25a8207e8a1 1028 // controlbyte to select between data and command. Internal value for serial bus only
Quentinou 0:e25a8207e8a1 1029 char _controlbyte;
Quentinou 0:e25a8207e8a1 1030
Quentinou 0:e25a8207e8a1 1031 //Backlight
Quentinou 0:e25a8207e8a1 1032 DigitalOut *_bl;
Quentinou 0:e25a8207e8a1 1033 };
Quentinou 0:e25a8207e8a1 1034
Quentinou 0:e25a8207e8a1 1035 //-------- End TextLCD_SPI_N_3_9 ----------
Quentinou 0:e25a8207e8a1 1036 #endif
Quentinou 0:e25a8207e8a1 1037
Quentinou 0:e25a8207e8a1 1038
Quentinou 0:e25a8207e8a1 1039 #if(1)
Quentinou 0:e25a8207e8a1 1040 //------- Start TextLCD_SPI_N_3_10 ---------
Quentinou 0:e25a8207e8a1 1041
Quentinou 0:e25a8207e8a1 1042 /** Create a TextLCD interface using a controller with native SPI3 10 bits interface
Quentinou 0:e25a8207e8a1 1043 * Note: current mbed libs only support SPI 10 bit mode for NXP platforms
Quentinou 0:e25a8207e8a1 1044 *
Quentinou 0:e25a8207e8a1 1045 */
Quentinou 0:e25a8207e8a1 1046 class TextLCD_SPI_N_3_10 : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 1047 public:
Quentinou 0:e25a8207e8a1 1048 /** Create a TextLCD interface using a controller with native SPI3 10 bits interface
Quentinou 0:e25a8207e8a1 1049 * Note: current mbed libs only support SPI 10 bit mode for NXP platforms
Quentinou 0:e25a8207e8a1 1050 *
Quentinou 0:e25a8207e8a1 1051 * @param spi SPI Bus
Quentinou 0:e25a8207e8a1 1052 * @param cs chip select pin (active low)
Quentinou 0:e25a8207e8a1 1053 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 1054 * @param bl Backlight control line (optional, default = NC)
Quentinou 0:e25a8207e8a1 1055 * @param ctrl LCD controller (default = AIP31068)
Quentinou 0:e25a8207e8a1 1056 */
Quentinou 0:e25a8207e8a1 1057 TextLCD_SPI_N_3_10(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = AIP31068);
Quentinou 0:e25a8207e8a1 1058 virtual ~TextLCD_SPI_N_3_10(void);
Quentinou 0:e25a8207e8a1 1059
Quentinou 0:e25a8207e8a1 1060 private:
Quentinou 0:e25a8207e8a1 1061
Quentinou 0:e25a8207e8a1 1062 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1063 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 1064 */
Quentinou 0:e25a8207e8a1 1065 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 1066
Quentinou 0:e25a8207e8a1 1067 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1068 * Set the RS pin (0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 1069 */
Quentinou 0:e25a8207e8a1 1070 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 1071
Quentinou 0:e25a8207e8a1 1072 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1073 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 1074 */
Quentinou 0:e25a8207e8a1 1075 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 1076
Quentinou 0:e25a8207e8a1 1077 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1078 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 1079 */
Quentinou 0:e25a8207e8a1 1080 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 1081
Quentinou 0:e25a8207e8a1 1082 /** Low level writes to LCD serial bus only (serial native)
Quentinou 0:e25a8207e8a1 1083 */
Quentinou 0:e25a8207e8a1 1084 virtual void _writeByte(int value);
Quentinou 0:e25a8207e8a1 1085
Quentinou 0:e25a8207e8a1 1086 // SPI bus
Quentinou 0:e25a8207e8a1 1087 SPI *_spi;
Quentinou 0:e25a8207e8a1 1088 DigitalOut _cs;
Quentinou 0:e25a8207e8a1 1089
Quentinou 0:e25a8207e8a1 1090
Quentinou 0:e25a8207e8a1 1091 // controlbyte to select between data and command. Internal value for serial bus only
Quentinou 0:e25a8207e8a1 1092 char _controlbyte;
Quentinou 0:e25a8207e8a1 1093
Quentinou 0:e25a8207e8a1 1094 //Backlight
Quentinou 0:e25a8207e8a1 1095 DigitalOut *_bl;
Quentinou 0:e25a8207e8a1 1096 };
Quentinou 0:e25a8207e8a1 1097
Quentinou 0:e25a8207e8a1 1098 //-------- End TextLCD_SPI_N_3_10 ----------
Quentinou 0:e25a8207e8a1 1099 #endif
Quentinou 0:e25a8207e8a1 1100
Quentinou 0:e25a8207e8a1 1101 #if(0)
Quentinou 0:e25a8207e8a1 1102 //Code not yet checked out on logic analyser. Not yet tested on hardware..
Quentinou 0:e25a8207e8a1 1103
Quentinou 0:e25a8207e8a1 1104 //------- Start TextLCD_SPI_N_3_16 ---------
Quentinou 0:e25a8207e8a1 1105
Quentinou 0:e25a8207e8a1 1106 /** Create a TextLCD interface using a controller with native SPI3 16 bits interface
Quentinou 0:e25a8207e8a1 1107 *
Quentinou 0:e25a8207e8a1 1108 */
Quentinou 0:e25a8207e8a1 1109 class TextLCD_SPI_N_3_16 : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 1110 public:
Quentinou 0:e25a8207e8a1 1111 /** Create a TextLCD interface using a controller with native SPI3 16 bits interface
Quentinou 0:e25a8207e8a1 1112 *
Quentinou 0:e25a8207e8a1 1113 * @param spi SPI Bus
Quentinou 0:e25a8207e8a1 1114 * @param cs chip select pin (active low)
Quentinou 0:e25a8207e8a1 1115 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 1116 * @param bl Backlight control line (optional, default = NC)
Quentinou 0:e25a8207e8a1 1117 * @param ctrl LCD controller (default = PT6314)
Quentinou 0:e25a8207e8a1 1118 */
Quentinou 0:e25a8207e8a1 1119 TextLCD_SPI_N_3_16(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = PT6314);
Quentinou 0:e25a8207e8a1 1120 virtual ~TextLCD_SPI_N_3_16(void);
Quentinou 0:e25a8207e8a1 1121
Quentinou 0:e25a8207e8a1 1122 private:
Quentinou 0:e25a8207e8a1 1123
Quentinou 0:e25a8207e8a1 1124 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1125 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 1126 */
Quentinou 0:e25a8207e8a1 1127 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 1128
Quentinou 0:e25a8207e8a1 1129 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1130 * Set the RS pin (0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 1131 */
Quentinou 0:e25a8207e8a1 1132 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 1133
Quentinou 0:e25a8207e8a1 1134 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1135 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 1136 */
Quentinou 0:e25a8207e8a1 1137 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 1138
Quentinou 0:e25a8207e8a1 1139 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1140 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 1141 */
Quentinou 0:e25a8207e8a1 1142 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 1143
Quentinou 0:e25a8207e8a1 1144 /** Low level writes to LCD serial bus only (serial native)
Quentinou 0:e25a8207e8a1 1145 */
Quentinou 0:e25a8207e8a1 1146 virtual void _writeByte(int value);
Quentinou 0:e25a8207e8a1 1147
Quentinou 0:e25a8207e8a1 1148 // SPI bus
Quentinou 0:e25a8207e8a1 1149 SPI *_spi;
Quentinou 0:e25a8207e8a1 1150 DigitalOut _cs;
Quentinou 0:e25a8207e8a1 1151
Quentinou 0:e25a8207e8a1 1152 // controlbyte to select between data and command. Internal value for serial bus only
Quentinou 0:e25a8207e8a1 1153 char _controlbyte;
Quentinou 0:e25a8207e8a1 1154
Quentinou 0:e25a8207e8a1 1155 //Backlight
Quentinou 0:e25a8207e8a1 1156 DigitalOut *_bl;
Quentinou 0:e25a8207e8a1 1157 };
Quentinou 0:e25a8207e8a1 1158
Quentinou 0:e25a8207e8a1 1159 //-------- End TextLCD_SPI_N_3_16 ----------
Quentinou 0:e25a8207e8a1 1160 #endif
Quentinou 0:e25a8207e8a1 1161
Quentinou 0:e25a8207e8a1 1162 #if(1)
Quentinou 0:e25a8207e8a1 1163 //------- Start TextLCD_SPI_N_3_24 ---------
Quentinou 0:e25a8207e8a1 1164
Quentinou 0:e25a8207e8a1 1165 /** Create a TextLCD interface using a controller with native SPI3 24 bits interface
Quentinou 0:e25a8207e8a1 1166 * Note: lib uses SPI 8 bit mode
Quentinou 0:e25a8207e8a1 1167 *
Quentinou 0:e25a8207e8a1 1168 */
Quentinou 0:e25a8207e8a1 1169 class TextLCD_SPI_N_3_24 : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 1170 public:
Quentinou 0:e25a8207e8a1 1171 /** Create a TextLCD interface using a controller with native SPI3 24 bits interface
Quentinou 0:e25a8207e8a1 1172 * Note: lib uses SPI 8 bit mode
Quentinou 0:e25a8207e8a1 1173 *
Quentinou 0:e25a8207e8a1 1174 * @param spi SPI Bus
Quentinou 0:e25a8207e8a1 1175 * @param cs chip select pin (active low)
Quentinou 0:e25a8207e8a1 1176 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 1177 * @param bl Backlight control line (optional, default = NC)
Quentinou 0:e25a8207e8a1 1178 * @param ctrl LCD controller (default = SSD1803)
Quentinou 0:e25a8207e8a1 1179 */
Quentinou 0:e25a8207e8a1 1180 TextLCD_SPI_N_3_24(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = SSD1803_3V3);
Quentinou 0:e25a8207e8a1 1181 virtual ~TextLCD_SPI_N_3_24(void);
Quentinou 0:e25a8207e8a1 1182
Quentinou 0:e25a8207e8a1 1183 private:
Quentinou 0:e25a8207e8a1 1184
Quentinou 0:e25a8207e8a1 1185 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1186 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 1187 */
Quentinou 0:e25a8207e8a1 1188 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 1189
Quentinou 0:e25a8207e8a1 1190 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1191 * Set the RS pin (0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 1192 */
Quentinou 0:e25a8207e8a1 1193 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 1194
Quentinou 0:e25a8207e8a1 1195 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1196 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 1197 */
Quentinou 0:e25a8207e8a1 1198 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 1199
Quentinou 0:e25a8207e8a1 1200 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1201 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 1202 */
Quentinou 0:e25a8207e8a1 1203 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 1204
Quentinou 0:e25a8207e8a1 1205 /** Low level writes to LCD serial bus only (serial native)
Quentinou 0:e25a8207e8a1 1206 */
Quentinou 0:e25a8207e8a1 1207 virtual void _writeByte(int value);
Quentinou 0:e25a8207e8a1 1208
Quentinou 0:e25a8207e8a1 1209 // SPI bus
Quentinou 0:e25a8207e8a1 1210 SPI *_spi;
Quentinou 0:e25a8207e8a1 1211 DigitalOut _cs;
Quentinou 0:e25a8207e8a1 1212
Quentinou 0:e25a8207e8a1 1213 // controlbyte to select between data and command. Internal value for serial bus only
Quentinou 0:e25a8207e8a1 1214 char _controlbyte;
Quentinou 0:e25a8207e8a1 1215
Quentinou 0:e25a8207e8a1 1216 //Backlight
Quentinou 0:e25a8207e8a1 1217 DigitalOut *_bl;
Quentinou 0:e25a8207e8a1 1218 };
Quentinou 0:e25a8207e8a1 1219
Quentinou 0:e25a8207e8a1 1220 //-------- End TextLCD_SPI_N_3_24 ----------
Quentinou 0:e25a8207e8a1 1221 #endif
Quentinou 0:e25a8207e8a1 1222
Quentinou 0:e25a8207e8a1 1223
Quentinou 0:e25a8207e8a1 1224 //--------- Start TextLCD_I2C_N -----------
Quentinou 0:e25a8207e8a1 1225
Quentinou 0:e25a8207e8a1 1226 /** Create a TextLCD interface using a controller with native I2C interface
Quentinou 0:e25a8207e8a1 1227 *
Quentinou 0:e25a8207e8a1 1228 */
Quentinou 0:e25a8207e8a1 1229 class TextLCD_I2C_N : public TextLCD_Base {
Quentinou 0:e25a8207e8a1 1230 public:
Quentinou 0:e25a8207e8a1 1231 /** Create a TextLCD interface using a controller with native I2C interface
Quentinou 0:e25a8207e8a1 1232 *
Quentinou 0:e25a8207e8a1 1233 * @param i2c I2C Bus
Quentinou 0:e25a8207e8a1 1234 * @param deviceAddress I2C slave address (default = ST7032_SA = 0x7C)
Quentinou 0:e25a8207e8a1 1235 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Quentinou 0:e25a8207e8a1 1236 * @param bl Backlight control line (optional, default = NC)
Quentinou 0:e25a8207e8a1 1237 * @param ctrl LCD controller (default = ST7032_3V3)
Quentinou 0:e25a8207e8a1 1238 */
Quentinou 0:e25a8207e8a1 1239 TextLCD_I2C_N(I2C *i2c, char deviceAddress = ST7032_SA, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7032_3V3);
Quentinou 0:e25a8207e8a1 1240 virtual ~TextLCD_I2C_N(void);
Quentinou 0:e25a8207e8a1 1241
Quentinou 0:e25a8207e8a1 1242 private:
Quentinou 0:e25a8207e8a1 1243
Quentinou 0:e25a8207e8a1 1244 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1245 * Set the Enable pin.
Quentinou 0:e25a8207e8a1 1246 */
Quentinou 0:e25a8207e8a1 1247 virtual void _setEnable(bool value);
Quentinou 0:e25a8207e8a1 1248
Quentinou 0:e25a8207e8a1 1249 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1250 * Set the RS pin ( 0 = Command, 1 = Data).
Quentinou 0:e25a8207e8a1 1251 */
Quentinou 0:e25a8207e8a1 1252 virtual void _setRS(bool value);
Quentinou 0:e25a8207e8a1 1253
Quentinou 0:e25a8207e8a1 1254 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1255 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
Quentinou 0:e25a8207e8a1 1256 */
Quentinou 0:e25a8207e8a1 1257 virtual void _setBL(bool value);
Quentinou 0:e25a8207e8a1 1258
Quentinou 0:e25a8207e8a1 1259 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
Quentinou 0:e25a8207e8a1 1260 * Set the databus value (4 bit).
Quentinou 0:e25a8207e8a1 1261 */
Quentinou 0:e25a8207e8a1 1262 virtual void _setData(int value);
Quentinou 0:e25a8207e8a1 1263
Quentinou 0:e25a8207e8a1 1264 /** Low level writes to LCD serial bus only (serial native)
Quentinou 0:e25a8207e8a1 1265 */
Quentinou 0:e25a8207e8a1 1266 virtual void _writeByte(int value);
Quentinou 0:e25a8207e8a1 1267
Quentinou 0:e25a8207e8a1 1268 //I2C bus
Quentinou 0:e25a8207e8a1 1269 I2C *_i2c;
Quentinou 0:e25a8207e8a1 1270 char _slaveAddress;
Quentinou 0:e25a8207e8a1 1271
Quentinou 0:e25a8207e8a1 1272 // controlbyte to select between data and command. Internal value for serial bus only
Quentinou 0:e25a8207e8a1 1273 char _controlbyte;
Quentinou 0:e25a8207e8a1 1274
Quentinou 0:e25a8207e8a1 1275 //Backlight
Quentinou 0:e25a8207e8a1 1276 DigitalOut *_bl;
Quentinou 0:e25a8207e8a1 1277
Quentinou 0:e25a8207e8a1 1278 };
Quentinou 0:e25a8207e8a1 1279
Quentinou 0:e25a8207e8a1 1280 //---------- End TextLCD_I2C_N ------------
Quentinou 0:e25a8207e8a1 1281
Quentinou 0:e25a8207e8a1 1282
Quentinou 0:e25a8207e8a1 1283 #endif