Fork for Seoul Hackathon

Dependents:   TextLCD_FC113 Kviz

Committer:
wim
Date:
Wed May 20 18:46:51 2015 +0000
Revision:
40:d3496c3ea301
Parent:
39:e9c2319de9c5
Child:
41:111ca62e8a59
Fixed an occasional init problem. Added PCF2119R support, added HD66712 support, added some more I2C portexpander types.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 37:ce348c002929 1 /* mbed TextLCD Library, for LCDs based on HD44780 controllers
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
wim 30:033048611c01 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
wim 32:59c4b8f648d4 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)
wim 34:e5a0dcb43ecc 15 * 2014, v13: WH, Added support for controllers US2066/SSD1311 (OLED), added setUDCBlink() method for supported devices (eg SSD1803), fixed issue in setPower()
wim 34:e5a0dcb43ecc 16 * 2014, v14: WH, Added support for PT6314 (VFD), added setOrient() method for supported devices (eg SSD1803, US2066), added Double Height lines for supported devices,
wim 34:e5a0dcb43ecc 17 * added 16 UDCs for supported devices (eg PCF2103), moved UDC defines to TextLCD_UDC file, added TextLCD_Config.h for feature and footprint settings.
wim 35:311be6444a39 18 * 2014, v15: WH, Added AC780 support, added I2C expander modules, fixed setBacklight() for inverted logic modules. Fixed bug in LCD_SPI_N define
wim 36:9f5f86dfd44a 19 * 2014, v16: WH, Added ST7070 and KS0073 support, added setIcon(), clrIcon() and setInvert() method for supported devices
wim 37:ce348c002929 20 * 2015, v17: WH, Clean up low-level _writeCommand() and _writeData(), Added support for alternative fonttables (eg PCF21XX), Added ST7066_ACM controller for ACM1602 module
wim 38:cbe275b0b647 21 * 2015, v18: WH, Performance improvement I2C portexpander
wim 39:e9c2319de9c5 22 * 2015, v19: WH, Added 10x2D and 10x4D type for SSD1803
wim 39:e9c2319de9c5 23 * 2015, v20: WH, Fixed occasional Init fail caused by insufficient wait time after ReturnHome command (0x02), Added defines to reduce memory footprint (eg LCD_ICON),
wim 40:d3496c3ea301 24 * Fixed and Added more fonttable support for PCF2119R_3V3, Added HD66712 controller.
simon 1:ac48b187213c 25 *
simon 1:ac48b187213c 26 * Permission is hereby granted, free of charge, to any person obtaining a copy
simon 1:ac48b187213c 27 * of this software and associated documentation files (the "Software"), to deal
simon 1:ac48b187213c 28 * in the Software without restriction, including without limitation the rights
simon 1:ac48b187213c 29 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
simon 1:ac48b187213c 30 * copies of the Software, and to permit persons to whom the Software is
simon 1:ac48b187213c 31 * furnished to do so, subject to the following conditions:
simon 2:227356c7d12c 32 *
simon 1:ac48b187213c 33 * The above copyright notice and this permission notice shall be included in
simon 1:ac48b187213c 34 * all copies or substantial portions of the Software.
simon 2:227356c7d12c 35 *
simon 1:ac48b187213c 36 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
simon 1:ac48b187213c 37 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
simon 1:ac48b187213c 38 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
simon 1:ac48b187213c 39 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
simon 1:ac48b187213c 40 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 1:ac48b187213c 41 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
simon 1:ac48b187213c 42 * THE SOFTWARE.
simon 1:ac48b187213c 43 */
simon 1:ac48b187213c 44
simon 1:ac48b187213c 45 #ifndef MBED_TEXTLCD_H
simon 1:ac48b187213c 46 #define MBED_TEXTLCD_H
simon 1:ac48b187213c 47
simon 1:ac48b187213c 48 #include "mbed.h"
wim 34:e5a0dcb43ecc 49 #include "TextLCD_Config.h"
wim 34:e5a0dcb43ecc 50 #include "TextLCD_UDC.h"
simon 2:227356c7d12c 51
simon 5:a53b3e2d6f1e 52 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
simon 2:227356c7d12c 53 *
wim 34:e5a0dcb43ecc 54 * Currently supports 8x1, 8x2, 12x3, 12x4, 16x1, 16x2, 16x3, 16x4, 20x2, 20x4, 24x1, 24x2, 24x4, 40x2 and 40x4 panels.
wim 27:22d5086f6ba6 55 * Interface options include direct mbed pins, I2C portexpander (PCF8474/PCF8574A or MCP23008) or SPI bus shiftregister (74595).
wim 34:e5a0dcb43ecc 56 * Supports some controllers with native I2C or SPI interface. Supports some controllers that provide internal DC/DC converters for VLCD or VLED.
wim 34:e5a0dcb43ecc 57 * Supports some controllers that feature programmable contrast control, powerdown, blinking UDCs and/or top/down orientation modes.
simon 2:227356c7d12c 58 *
simon 2:227356c7d12c 59 * @code
simon 2:227356c7d12c 60 * #include "mbed.h"
simon 2:227356c7d12c 61 * #include "TextLCD.h"
simon 5:a53b3e2d6f1e 62 *
wim 16:c276b75e6585 63 * // I2C Communication
wim 16:c276b75e6585 64 * I2C i2c_lcd(p28,p27); // SDA, SCL
wim 16:c276b75e6585 65 *
wim 16:c276b75e6585 66 * // SPI Communication
wim 16:c276b75e6585 67 * SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK
wim 16:c276b75e6585 68 *
wim 22:35742ec80c24 69 * //TextLCD lcd(p15, p16, p17, p18, p19, p20); // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780
wim 28:30fa94f7341c 70 * //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, 74595 expander, CS pin, LCD Type
wim 34:e5a0dcb43ecc 71 * TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type
wim 34:e5a0dcb43ecc 72 * //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type (OLED)
wim 27:22d5086f6ba6 73 * //TextLCD_SPI_N lcd(&spi_lcd, p8, p9); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3
wim 34:e5a0dcb43ecc 74 * //TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=ST7032_3V3
wim 34:e5a0dcb43ecc 75 * //TextLCD_SPI_N_3_24 lcd(&spi_lcd, p8, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // SPI bus, CS pin, LCDType=LCD20x4D, BL=NC, LCDTCtrl=SSD1803
wim 34:e5a0dcb43ecc 76 * //TextLCD_SPI_N_3_24 lcd(&spi_lcd, p8, TextLCD::LCD20x2, NC, TextLCD::US2066_3V3); // SPI bus, CS pin, LCDType=LCD20x2, BL=NC, LCDTCtrl=US2066 (OLED)
wim 34:e5a0dcb43ecc 77 *
simon 2:227356c7d12c 78 * int main() {
wim 16:c276b75e6585 79 * lcd.printf("Hello World!\n");
simon 2:227356c7d12c 80 * }
simon 2:227356c7d12c 81 * @endcode
simon 2:227356c7d12c 82 */
wim 8:03116f75b66e 83
wim 34:e5a0dcb43ecc 84 //The TextLCD_Config.h file selects hardware interface options to reduce memory footprint
wim 34:e5a0dcb43ecc 85 //and provides Pin Defines for I2C PCF8574/PCF8574A or MCP23008 and SPI 74595 bus expander interfaces.
wim 34:e5a0dcb43ecc 86 //The LCD and serial portexpanders should be wired accordingly.
wim 32:59c4b8f648d4 87
wim 30:033048611c01 88 /* LCD Type information on Rows, Columns and Variant. This information is encoded in
wim 30:033048611c01 89 * an int and used for the LCDType enumerators in order to simplify code maintenance */
wim 30:033048611c01 90 // Columns encoded in b7..b0
wim 30:033048611c01 91 #define LCD_T_COL_MSK 0x000000FF
wim 32:59c4b8f648d4 92 #define LCD_T_C6 0x00000006
wim 30:033048611c01 93 #define LCD_T_C8 0x00000008
wim 30:033048611c01 94 #define LCD_T_C10 0x0000000A
wim 30:033048611c01 95 #define LCD_T_C12 0x0000000C
wim 30:033048611c01 96 #define LCD_T_C16 0x00000010
wim 30:033048611c01 97 #define LCD_T_C20 0x00000014
wim 30:033048611c01 98 #define LCD_T_C24 0x00000018
wim 30:033048611c01 99 #define LCD_T_C32 0x00000020
wim 30:033048611c01 100 #define LCD_T_C40 0x00000028
wim 30:033048611c01 101
wim 30:033048611c01 102 // Rows encoded in b15..b8
wim 30:033048611c01 103 #define LCD_T_ROW_MSK 0x0000FF00
wim 30:033048611c01 104 #define LCD_T_R1 0x00000100
wim 30:033048611c01 105 #define LCD_T_R2 0x00000200
wim 30:033048611c01 106 #define LCD_T_R3 0x00000300
wim 30:033048611c01 107 #define LCD_T_R4 0x00000400
wim 39:e9c2319de9c5 108 #define LCD_T_R6 0x00000600
wim 30:033048611c01 109
wim 30:033048611c01 110 // Addressing mode encoded in b19..b16
wim 30:033048611c01 111 #define LCD_T_ADR_MSK 0x000F0000
wim 32:59c4b8f648d4 112 #define LCD_T_A 0x00000000 /*Mode A Default 1, 2 or 4 line display */
wim 32:59c4b8f648d4 113 #define LCD_T_B 0x00010000 /*Mode B, Alternate 8x2 (actually 16x1 display) */
wim 32:59c4b8f648d4 114 #define LCD_T_C 0x00020000 /*Mode C, Alternate 16x1 (actually 8x2 display) */
wim 32:59c4b8f648d4 115 #define LCD_T_D 0x00030000 /*Mode D, Alternate 3 or 4 line display (12x4, 20x4, 24x4) */
wim 32:59c4b8f648d4 116 #define LCD_T_D1 0x00040000 /*Mode D1, Alternate 3 out of 4 line display (12x3, 20x3, 24x3) */
wim 32:59c4b8f648d4 117 #define LCD_T_E 0x00050000 /*Mode E, 40x4 display (actually two 40x2) */
wim 32:59c4b8f648d4 118 #define LCD_T_F 0x00060000 /*Mode F, 16x3 display (actually 24x2) */
wim 32:59c4b8f648d4 119 #define LCD_T_G 0x00070000 /*Mode G, 16x3 display */
wim 30:033048611c01 120
wim 30:033048611c01 121 /* LCD Ctrl information on interface support and features. This information is encoded in
wim 30:033048611c01 122 * an int and used for the LCDCtrl enumerators in order to simplify code maintenance */
wim 30:033048611c01 123 // Interface encoded in b31..b24
wim 30:033048611c01 124 #define LCD_C_BUS_MSK 0xFF000000
wim 32:59c4b8f648d4 125 #define LCD_C_PAR 0x01000000 /*Parallel 4 or 8 bit data, E pin, RS pin, RW=GND */
wim 36:9f5f86dfd44a 126 #define LCD_C_SPI3_8 0x02000000 /*SPI 3 line (MOSI, SCL, CS pins), 8 bits (Count Command initiates Data transfer) */
wim 36:9f5f86dfd44a 127 #define LCD_C_SPI3_9 0x04000000 /*SPI 3 line (MOSI, SCL, CS pins), 9 bits (RS + 8 Data) */
wim 36:9f5f86dfd44a 128 #define LCD_C_SPI3_10 0x08000000 /*SPI 3 line (MOSI, SCL, CS pins), 10 bits (RS, RW + 8 Data) */
wim 36:9f5f86dfd44a 129 #define LCD_C_SPI3_16 0x10000000 /*SPI 3 line (MOSI, SCL, CS pins), 16 bits (RS, RW + 8 Data) */
wim 36:9f5f86dfd44a 130 #define LCD_C_SPI3_24 0x20000000 /*SPI 3 line (MOSI, SCL, CS pins), 24 bits (RS, RW + 8 Data) */
wim 36:9f5f86dfd44a 131 #define LCD_C_SPI4 0x40000000 /*SPI 4 line (MOSI, SCL, CS, RS pin), RS pin + 8 Data */
wim 36:9f5f86dfd44a 132 #define LCD_C_I2C 0x80000000 /*I2C (SDA, SCL pin), 8 control bits (Co, RS, RW) + 8 Data */
wim 30:033048611c01 133 // Features encoded in b23..b16
wim 30:033048611c01 134 #define LCD_C_FTR_MSK 0x00FF0000
wim 30:033048611c01 135 #define LCD_C_BST 0x00010000 /*Booster */
wim 32:59c4b8f648d4 136 #define LCD_C_CTR 0x00020000 /*Contrast Control */
wim 32:59c4b8f648d4 137 #define LCD_C_ICN 0x00040000 /*Icons */
wim 32:59c4b8f648d4 138 #define LCD_C_PDN 0x00080000 /*Power Down */
wim 37:ce348c002929 139 // Fonttable encoded in b15..b12
wim 37:ce348c002929 140 #define LCD_C_FNT_MSK 0x0000F000
wim 37:ce348c002929 141 #define LCD_C_FT0 0x00000000 /*Default */
wim 39:e9c2319de9c5 142 #define LCD_C_FT1 0x00001000 /*Font1, C */
wim 39:e9c2319de9c5 143 #define LCD_C_FT2 0x00002000 /*Font2, R */
wim 32:59c4b8f648d4 144
wim 11:9ec02df863a1 145 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
wim 11:9ec02df863a1 146 *
wim 33:900a94bc7585 147 * @brief Currently supports 8x1, 8x2, 12x2, 12x3, 12x4, 16x1, 16x2, 16x3, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels
wim 37:ce348c002929 148 * Interface options include direct mbed pins, I2C portexpander (PCF8474/PCF8574A or MCP23008) or
wim 37:ce348c002929 149 * SPI bus shiftregister (74595) or native I2C or SPI interfaces for some supported devices.
wim 11:9ec02df863a1 150 */
wim 21:9eb628d9e164 151 class TextLCD_Base : public Stream {
wim 37:ce348c002929 152 //class TextLCD_Base {
wim 35:311be6444a39 153
wim 37:ce348c002929 154 //Unfortunately the following #define selection breaks Doxygen !!!
wim 37:ce348c002929 155 //Add it manually when you want to disable the Stream inheritance
wim 35:311be6444a39 156 //#if (LCD_PRINTF == 1)
wim 35:311be6444a39 157 //class TextLCD_Base : public Stream {
wim 35:311be6444a39 158 //#else
wim 37:ce348c002929 159 //class TextLCD_Base {
wim 35:311be6444a39 160 //#endif
wim 35:311be6444a39 161
simon 1:ac48b187213c 162 public:
simon 1:ac48b187213c 163
simon 2:227356c7d12c 164 /** LCD panel format */
wim 33:900a94bc7585 165 // The commented out types exist but have not yet been tested with the library
simon 1:ac48b187213c 166 enum LCDType {
wim 39:e9c2319de9c5 167 // LCD6x1 = (LCD_T_A | LCD_T_C6 | LCD_T_R1), /**< 6x1 LCD panel */
wim 39:e9c2319de9c5 168 // LCD6x2 = (LCD_T_A | LCD_T_C6 | LCD_T_R2), /**< 6x2 LCD panel */
wim 39:e9c2319de9c5 169 LCD8x1 = (LCD_T_A | LCD_T_C8 | LCD_T_R1), /**< 8x1 LCD panel */
wim 39:e9c2319de9c5 170 LCD8x2 = (LCD_T_A | LCD_T_C8 | LCD_T_R2), /**< 8x2 LCD panel */
wim 39:e9c2319de9c5 171 LCD8x2B = (LCD_T_D | LCD_T_C8 | LCD_T_R2), /**< 8x2 LCD panel (actually 16x1) */
wim 39:e9c2319de9c5 172 // LCD10x2D = (LCD_T_D | LCD_T_C10 | LCD_T_R2), /**< 10x2 LCD panel, special mode SSD1803, 4-line but double height */
wim 39:e9c2319de9c5 173 LCD10x4D = (LCD_T_D | LCD_T_C10 | LCD_T_R4), /**< 10x4 LCD panel, special mode SSD1803 */
wim 39:e9c2319de9c5 174 LCD12x1 = (LCD_T_A | LCD_T_C12 | LCD_T_R1), /**< 12x1 LCD panel */
wim 39:e9c2319de9c5 175 LCD12x2 = (LCD_T_A | LCD_T_C12 | LCD_T_R2), /**< 12x2 LCD panel */
wim 39:e9c2319de9c5 176 LCD12x3D = (LCD_T_D | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode PCF21XX, KS0073 */
wim 39:e9c2319de9c5 177 LCD12x3D1 = (LCD_T_D1 | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode PCF21XX, KS0073 */
wim 39:e9c2319de9c5 178 // LCD12x3G = (LCD_T_G | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode ST7036 */
wim 39:e9c2319de9c5 179 LCD12x4 = (LCD_T_A | LCD_T_C12 | LCD_T_R4), /**< 12x4 LCD panel */
wim 39:e9c2319de9c5 180 LCD12x4D = (LCD_T_B | LCD_T_C12 | LCD_T_R4), /**< 12x4 LCD panel, special mode PCF21XX, KS0073 */
wim 39:e9c2319de9c5 181 LCD16x1 = (LCD_T_A | LCD_T_C16 | LCD_T_R1), /**< 16x1 LCD panel */
wim 39:e9c2319de9c5 182 LCD16x1C = (LCD_T_C | LCD_T_C16 | LCD_T_R1), /**< 16x1 LCD panel (actually 8x2) */
wim 30:033048611c01 183 LCD16x2 = (LCD_T_A | LCD_T_C16 | LCD_T_R2), /**< 16x2 LCD panel (default) */
wim 30:033048611c01 184 // LCD16x2B = (LCD_T_B | LCD_T_C16 | LCD_T_R2), /**< 16x2 LCD panel, alternate addressing, wrong.. */
wim 39:e9c2319de9c5 185 LCD16x3D = (LCD_T_D | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode SSD1803 */
wim 39:e9c2319de9c5 186 // LCD16x3D1 = (LCD_T_D1 | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode SSD1803 */
wim 39:e9c2319de9c5 187 LCD16x3F = (LCD_T_F | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel (actually 24x2) */
wim 39:e9c2319de9c5 188 LCD16x3G = (LCD_T_G | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode ST7036 */
wim 39:e9c2319de9c5 189 LCD16x4 = (LCD_T_A | LCD_T_C16 | LCD_T_R4), /**< 16x4 LCD panel */
wim 39:e9c2319de9c5 190 // LCD16x4D = (LCD_T_D | LCD_T_C16 | LCD_T_R4), /**< 16x4 LCD panel, special mode SSD1803 */
wim 34:e5a0dcb43ecc 191 LCD20x1 = (LCD_T_A | LCD_T_C20 | LCD_T_R1), /**< 20x1 LCD panel */
wim 30:033048611c01 192 LCD20x2 = (LCD_T_A | LCD_T_C20 | LCD_T_R2), /**< 20x2 LCD panel */
wim 39:e9c2319de9c5 193 // LCD20x3 = (LCD_T_A | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel */
wim 39:e9c2319de9c5 194 // LCD20x3D = (LCD_T_D | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel, special mode SSD1803 */
wim 39:e9c2319de9c5 195 // LCD20x3D1 = (LCD_T_D1 | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel, special mode SSD1803 */
wim 30:033048611c01 196 LCD20x4 = (LCD_T_A | LCD_T_C20 | LCD_T_R4), /**< 20x4 LCD panel */
wim 39:e9c2319de9c5 197 LCD20x4D = (LCD_T_D | LCD_T_C20 | LCD_T_R4), /**< 20x4 LCD panel, special mode SSD1803 */
wim 39:e9c2319de9c5 198 // LCD20x6 = (LCD_T_E | LCD_T_C20 | LCD_T_R6), /**< 20x6 LCD panel, Two controller version */
wim 39:e9c2319de9c5 199 LCD24x1 = (LCD_T_A | LCD_T_C24 | LCD_T_R1), /**< 24x1 LCD panel */
wim 39:e9c2319de9c5 200 LCD24x2 = (LCD_T_A | LCD_T_C24 | LCD_T_R2), /**< 24x2 LCD panel */
wim 39:e9c2319de9c5 201 // LCD24x3D = (LCD_T_D | LCD_T_C24 | LCD_T_R3), /**< 24x3 LCD panel */
wim 39:e9c2319de9c5 202 // LCD24x3D1 = (LCD_T_D | LCD_T_C24 | LCD_T_R3), /**< 24x3 LCD panel */
wim 39:e9c2319de9c5 203 LCD24x4D = (LCD_T_D | LCD_T_C24 | LCD_T_R4), /**< 24x4 LCD panel, special mode KS0078 */
wim 33:900a94bc7585 204 // LCD32x1 = (LCD_T_A | LCD_T_C32 | LCD_T_R1), /**< 32x1 LCD panel */
wim 39:e9c2319de9c5 205 // LCD32x1C = (LCD_T_C | LCD_T_C32 | LCD_T_R1), /**< 32x1 LCD panel (actually 16x2) */
wim 39:e9c2319de9c5 206 // LCD32x2 = (LCD_T_A | LCD_T_C32 | LCD_T_R2), /**< 32x2 LCD panel */
wim 39:e9c2319de9c5 207 // LCD32x4 = (LCD_T_A | LCD_T_C32 | LCD_T_R4), /**< 32x4 LCD panel */
wim 39:e9c2319de9c5 208 // LCD40x1 = (LCD_T_A | LCD_T_C40 | LCD_T_R1), /**< 40x1 LCD panel */
wim 39:e9c2319de9c5 209 // LCD40x1C = (LCD_T_C | LCD_T_C40 | LCD_T_R1), /**< 40x1 LCD panel (actually 20x2) */
wim 39:e9c2319de9c5 210 LCD40x2 = (LCD_T_A | LCD_T_C40 | LCD_T_R2), /**< 40x2 LCD panel */
wim 39:e9c2319de9c5 211 LCD40x4 = (LCD_T_E | LCD_T_C40 | LCD_T_R4) /**< 40x4 LCD panel, Two controller version */
wim 30:033048611c01 212 };
wim 30:033048611c01 213
wim 30:033048611c01 214
wim 30:033048611c01 215 /** LCD Controller Device */
wim 30:033048611c01 216 enum LCDCtrl {
wim 37:ce348c002929 217 HD44780 = 0 | LCD_C_PAR, /**< HD44780 or full equivalent (default) */
wim 37:ce348c002929 218 AC780 = 1 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_PDN), /**< AC780/KS0066i 4/8 bit, SPI, I2C */
wim 37:ce348c002929 219 AIP31068 = 2 | (LCD_C_SPI3_9 | LCD_C_I2C | LCD_C_BST), /**< AIP31068 I2C, SPI3 */
wim 37:ce348c002929 220 KS0073 = 3 | (LCD_C_PAR | LCD_C_SPI3_24 | LCD_C_PDN), /**< KS0073 4/8 bit, SPI3 */
wim 37:ce348c002929 221 KS0078 = 4 | (LCD_C_PAR | LCD_C_SPI3_24 | LCD_C_PDN), /**< KS0078 24x4 support, 4/8 bit, SPI3 */
wim 37:ce348c002929 222 PCF2103_3V3 = 5 | (LCD_C_PAR | LCD_C_I2C), /**< PCF2103 3V3 no Booster, 4/8 bit, I2C */
wim 37:ce348c002929 223 PCF2113_3V3 = 6 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< PCF2113 3V3 with Booster, 4/8 bit, I2C */
wim 37:ce348c002929 224 PCF2116_3V3 = 7 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST), /**< PCF2116 3V3 with Booster, 4/8 bit, I2C */
wim 39:e9c2319de9c5 225 // PCF2116C_3V3 = | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_FT1), /**< PCF2116C 3V3 with Booster, 4/8 bit, I2C */
wim 39:e9c2319de9c5 226 // PCF2116K_3V3 = | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_FT2), /**< PCF2116K 3V3 with Booster, 4/8 bit, I2C */
wim 39:e9c2319de9c5 227 PCF2116_5V = 8 | (LCD_C_PAR | LCD_C_I2C), /**< PCF2116 5V no Booster, 4/8 bit, I2C */
wim 39:e9c2319de9c5 228 PCF2116C_5V = 9 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_FT1), /**< PCF2116C 3V3 with Booster, 4/8 bit, I2C */
wim 39:e9c2319de9c5 229 PCF2119_3V3 = 10 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< PCF2119 3V3 with Booster, 4/8 bit, I2C */
wim 39:e9c2319de9c5 230 // PCF2119C_3V3 = 11 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_CTR | LCD_C_FT1), /**< PCF2119K 3V3 with Booster, 4/8 bit, I2C */
wim 39:e9c2319de9c5 231 PCF2119R_3V3 = 12 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_CTR | LCD_C_FT2), /**< PCF2119R 3V3 with Booster, 4/8 bit, I2C */
wim 39:e9c2319de9c5 232 // PCF2119_5V = | (LCD_C_PAR | LCD_C_I2C), /**< PCF2119 5V no Booster, 4/8 bit, I2C */
wim 37:ce348c002929 233 PT6314 = 13 | (LCD_C_PAR | LCD_C_SPI3_16 | LCD_C_CTR), /**< PT6314 VFD, 4/8 bit, SPI3 */
wim 37:ce348c002929 234 SSD1803_3V3 = 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 */
wim 37:ce348c002929 235 // SSD1803_5V = 15 | (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 */
wim 37:ce348c002929 236 ST7032_3V3 = 16 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7032 3V3 with Booster, 4/8 bit, SPI4, I2C */
wim 37:ce348c002929 237 ST7032_5V = 17 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_CTR), /**< ST7032 5V no Booster, 4/8 bit, SPI4, I2C */
wim 37:ce348c002929 238 ST7036_3V3 = 18 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7036 3V3 with Booster, 4/8 bit, SPI4, I2C */
wim 37:ce348c002929 239 ST7036_5V = 19 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7036 5V no Booster, 4/8 bit, SPI4, I2C */
wim 37:ce348c002929 240 ST7066_ACM = 20 | (LCD_C_PAR | LCD_C_I2C), /**< ST7066 4/8 bit, I2C on ACM1602 using a PIC */
wim 37:ce348c002929 241 ST7070 = 21 | (LCD_C_PAR | LCD_C_SPI3_8 | LCD_C_SPI4), /**< ST7070 4/8 bit, SPI3 */
wim 37:ce348c002929 242 US2066_3V3 = 22 | (LCD_C_PAR | LCD_C_SPI3_24 | LCD_C_I2C | LCD_C_CTR | LCD_C_PDN), /**< US2066/SSD1311 3V3, 4/8 bit, I2C, SPI3 */
wim 39:e9c2319de9c5 243 WS0010 = 23 | (LCD_C_PAR | LCD_C_SPI3_10 | LCD_C_PDN), /**< WS0010/RS0010 OLED Controller, 4/8 bit, SPI3 */
wim 37:ce348c002929 244 // WS0012 = 24 | (LCD_C_PAR | LCD_C_SPI3_10 | LCD_C_I2C | LCD_C_PDN), /**< WS0012 4/8 bit, SPI, I2C */
wim 39:e9c2319de9c5 245 HD66712 = 25 | (LCD_C_PAR | LCD_C_SPI3_24 | LCD_C_BST | LCD_C_PDN) /**< HD66712 Controller, 4/8 bit, SPI3 */
wim 30:033048611c01 246 };
wim 30:033048611c01 247
wim 30:033048611c01 248
wim 10:dd9b3a696acd 249 /** LCD Cursor control */
wim 10:dd9b3a696acd 250 enum LCDCursor {
wim 17:652ab113bc2e 251 CurOff_BlkOff = 0x00, /**< Cursor Off, Blinking Char Off */
wim 17:652ab113bc2e 252 CurOn_BlkOff = 0x02, /**< Cursor On, Blinking Char Off */
wim 17:652ab113bc2e 253 CurOff_BlkOn = 0x01, /**< Cursor Off, Blinking Char On */
wim 17:652ab113bc2e 254 CurOn_BlkOn = 0x03 /**< Cursor On, Blinking Char On */
wim 17:652ab113bc2e 255 };
wim 17:652ab113bc2e 256
wim 17:652ab113bc2e 257 /** LCD Display control */
wim 17:652ab113bc2e 258 enum LCDMode {
wim 17:652ab113bc2e 259 DispOff = 0x00, /**< Display Off */
wim 17:652ab113bc2e 260 DispOn = 0x04 /**< Display On */
wim 10:dd9b3a696acd 261 };
wim 10:dd9b3a696acd 262
wim 20:e0da005a777f 263 /** LCD Backlight control */
wim 20:e0da005a777f 264 enum LCDBacklight {
wim 20:e0da005a777f 265 LightOff, /**< Backlight Off */
wim 20:e0da005a777f 266 LightOn /**< Backlight On */
wim 20:e0da005a777f 267 };
wim 10:dd9b3a696acd 268
wim 33:900a94bc7585 269 /** LCD Blink control (UDC), supported for some Controllers */
wim 33:900a94bc7585 270 enum LCDBlink {
wim 33:900a94bc7585 271 BlinkOff, /**< Blink Off */
wim 33:900a94bc7585 272 BlinkOn /**< Blink On */
wim 33:900a94bc7585 273 };
wim 33:900a94bc7585 274
wim 33:900a94bc7585 275 /** LCD Orientation control, supported for some Controllers */
wim 33:900a94bc7585 276 enum LCDOrient {
wim 33:900a94bc7585 277 Top, /**< Top view */
wim 33:900a94bc7585 278 Bottom /**< Upside down view */
wim 33:900a94bc7585 279 };
wim 33:900a94bc7585 280
wim 34:e5a0dcb43ecc 281 /** LCD BigFont control, supported for some Controllers */
wim 34:e5a0dcb43ecc 282 enum LCDBigFont {
wim 34:e5a0dcb43ecc 283 None, /**< no lines */
wim 34:e5a0dcb43ecc 284 TopLine, /**< 1+2 line */
wim 34:e5a0dcb43ecc 285 CenterLine, /**< 2+3 line */
wim 34:e5a0dcb43ecc 286 BottomLine, /**< 2+3 line or 3+4 line */
wim 34:e5a0dcb43ecc 287 TopBottomLine /**< 1+2 line and 3+4 line */
wim 34:e5a0dcb43ecc 288 };
wim 33:900a94bc7585 289
wim 34:e5a0dcb43ecc 290
wim 37:ce348c002929 291 /** Convert ASCII character code to the LCD fonttable code
wim 37:ce348c002929 292 *
wim 37:ce348c002929 293 * @param c The character to write to the display
wim 37:ce348c002929 294 * @return The character code for the specific fonttable of the controller
wim 37:ce348c002929 295 */
wim 37:ce348c002929 296 int ASCII_2_LCD (int c);
wim 37:ce348c002929 297
wim 37:ce348c002929 298
wim 34:e5a0dcb43ecc 299 #if(LCD_PRINTF != 1)
wim 34:e5a0dcb43ecc 300 /** Write a character to the LCD
wim 34:e5a0dcb43ecc 301 *
wim 34:e5a0dcb43ecc 302 * @param c The character to write to the display
wim 34:e5a0dcb43ecc 303 */
wim 34:e5a0dcb43ecc 304 int putc(int c);
wim 34:e5a0dcb43ecc 305
wim 34:e5a0dcb43ecc 306 /** Write a raw string to the LCD
wim 34:e5a0dcb43ecc 307 *
wim 34:e5a0dcb43ecc 308 * @param string text, may be followed by variables to emulate formatting the string.
wim 34:e5a0dcb43ecc 309 * However, printf formatting is NOT supported and variables will be ignored!
wim 34:e5a0dcb43ecc 310 */
wim 34:e5a0dcb43ecc 311 int printf(const char* text, ...);
wim 34:e5a0dcb43ecc 312 #else
simon 2:227356c7d12c 313 #if DOXYGEN_ONLY
simon 2:227356c7d12c 314 /** Write a character to the LCD
simon 2:227356c7d12c 315 *
simon 2:227356c7d12c 316 * @param c The character to write to the display
simon 2:227356c7d12c 317 */
simon 2:227356c7d12c 318 int putc(int c);
simon 2:227356c7d12c 319
wim 34:e5a0dcb43ecc 320 /** Write a formatted string to the LCD
simon 2:227356c7d12c 321 *
simon 2:227356c7d12c 322 * @param format A printf-style format string, followed by the
wim 34:e5a0dcb43ecc 323 * variables to use in formatting the string.
simon 2:227356c7d12c 324 */
wim 34:e5a0dcb43ecc 325 int printf(const char* format, ...);
simon 2:227356c7d12c 326 #endif
wim 34:e5a0dcb43ecc 327
wim 34:e5a0dcb43ecc 328 #endif
simon 2:227356c7d12c 329
wim 29:a3663151aa65 330 /** Locate cursor to a screen column and row
simon 2:227356c7d12c 331 *
simon 2:227356c7d12c 332 * @param column The horizontal position from the left, indexed from 0
simon 2:227356c7d12c 333 * @param row The vertical position from the top, indexed from 0
simon 2:227356c7d12c 334 */
simon 1:ac48b187213c 335 void locate(int column, int row);
simon 2:227356c7d12c 336
wim 10:dd9b3a696acd 337 /** Return the memoryaddress of screen column and row location
wim 10:dd9b3a696acd 338 *
wim 10:dd9b3a696acd 339 * @param column The horizontal position from the left, indexed from 0
wim 10:dd9b3a696acd 340 * @param row The vertical position from the top, indexed from 0
wim 36:9f5f86dfd44a 341 * @return The memoryaddress of screen column and row location
wim 10:dd9b3a696acd 342 */
wim 39:e9c2319de9c5 343 int getAddress(int column, int row);
wim 10:dd9b3a696acd 344
wim 10:dd9b3a696acd 345 /** Set the memoryaddress of screen column and row location
wim 10:dd9b3a696acd 346 *
wim 10:dd9b3a696acd 347 * @param column The horizontal position from the left, indexed from 0
wim 10:dd9b3a696acd 348 * @param row The vertical position from the top, indexed from 0
wim 10:dd9b3a696acd 349 */
wim 9:0893d986e717 350 void setAddress(int column, int row);
wim 9:0893d986e717 351
wim 22:35742ec80c24 352 /** Clear the screen and locate to 0,0
wim 22:35742ec80c24 353 */
simon 1:ac48b187213c 354 void cls();
simon 2:227356c7d12c 355
wim 10:dd9b3a696acd 356 /** Return the number of rows
wim 10:dd9b3a696acd 357 *
wim 36:9f5f86dfd44a 358 * @return The number of rows
wim 10:dd9b3a696acd 359 */
simon 1:ac48b187213c 360 int rows();
wim 10:dd9b3a696acd 361
wim 10:dd9b3a696acd 362 /** Return the number of columns
wim 10:dd9b3a696acd 363 *
wim 36:9f5f86dfd44a 364 * @return The number of columns
wim 10:dd9b3a696acd 365 */
wim 10:dd9b3a696acd 366 int columns();
simon 2:227356c7d12c 367
wim 11:9ec02df863a1 368 /** Set the Cursormode
wim 11:9ec02df863a1 369 *
wim 17:652ab113bc2e 370 * @param cursorMode The Cursor mode (CurOff_BlkOff, CurOn_BlkOff, CurOff_BlkOn, CurOn_BlkOn)
wim 11:9ec02df863a1 371 */
wim 17:652ab113bc2e 372 void setCursor(LCDCursor cursorMode);
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 33:900a94bc7585 386 /** Set User Defined Characters (UDC)
wim 11:9ec02df863a1 387 *
wim 34:e5a0dcb43ecc 388 * @param unsigned char c The Index of the UDC (0..7) for HD44780 clones and (0..15) for some more advanced controllers
wim 34:e5a0dcb43ecc 389 * @param char *udc_data The bitpatterns for the UDC (8 bytes of 5 significant bits for bitpattern and 3 bits for blinkmode (advanced types))
wim 11:9ec02df863a1 390 */
wim 11:9ec02df863a1 391 void setUDC(unsigned char c, char *udc_data);
wim 11:9ec02df863a1 392
wim 39:e9c2319de9c5 393 #if(LCD_BLINK == 1)
wim 36:9f5f86dfd44a 394 /** Set UDC Blink and Icon blink
wim 33:900a94bc7585 395 * setUDCBlink method is supported by some compatible devices (eg SSD1803)
wim 33:900a94bc7585 396 *
wim 33:900a94bc7585 397 * @param blinkMode The Blink mode (BlinkOff, BlinkOn)
wim 33:900a94bc7585 398 */
wim 33:900a94bc7585 399 void setUDCBlink(LCDBlink blinkMode);
wim 39:e9c2319de9c5 400 #endif
wim 33:900a94bc7585 401
wim 32:59c4b8f648d4 402 /** Set Contrast
wim 32:59c4b8f648d4 403 * setContrast method is supported by some compatible devices (eg ST7032i) that have onboard LCD voltage generation
wim 32:59c4b8f648d4 404 * Code imported from fork by JH1PJL
wim 32:59c4b8f648d4 405 *
wim 32:59c4b8f648d4 406 * @param unsigned char c contrast data (6 significant bits, valid range 0..63, Value 0 will disable the Vgen)
wim 32:59c4b8f648d4 407 * @return none
wim 32:59c4b8f648d4 408 */
wim 32:59c4b8f648d4 409 void setContrast(unsigned char c = LCD_DEF_CONTRAST);
wim 32:59c4b8f648d4 410
wim 39:e9c2319de9c5 411 #if(LCD_POWER == 1)
wim 32:59c4b8f648d4 412 /** Set Power
wim 32:59c4b8f648d4 413 * setPower method is supported by some compatible devices (eg SSD1803) that have power down modes
wim 32:59c4b8f648d4 414 *
wim 32:59c4b8f648d4 415 * @param bool powerOn Power on/off
wim 32:59c4b8f648d4 416 * @return none
wim 32:59c4b8f648d4 417 */
wim 32:59c4b8f648d4 418 void setPower(bool powerOn = true);
wim 39:e9c2319de9c5 419 #endif
wim 32:59c4b8f648d4 420
wim 39:e9c2319de9c5 421 #if(LCD_ORIENT == 1)
wim 33:900a94bc7585 422 /** Set Orient
wim 33:900a94bc7585 423 * setOrient method is supported by some compatible devices (eg SSD1803, US2066) that have top/bottom view modes
wim 33:900a94bc7585 424 *
wim 33:900a94bc7585 425 * @param LCDOrient orient Orientation
wim 33:900a94bc7585 426 * @return none
wim 33:900a94bc7585 427 */
wim 33:900a94bc7585 428 void setOrient(LCDOrient orient = Top);
wim 39:e9c2319de9c5 429 #endif
wim 33:900a94bc7585 430
wim 39:e9c2319de9c5 431 #if(LCD_BIGFONT == 1)
wim 34:e5a0dcb43ecc 432 /** Set Big Font
wim 34:e5a0dcb43ecc 433 * setBigFont method is supported by some compatible devices (eg SSD1803, US2066)
wim 34:e5a0dcb43ecc 434 *
wim 34:e5a0dcb43ecc 435 * @param lines The selected Big Font lines (None, TopLine, CenterLine, BottomLine, TopBottomLine)
wim 34:e5a0dcb43ecc 436 * Double height characters can be shown on lines 1+2, 2+3, 3+4 or 1+2 and 3+4
wim 34:e5a0dcb43ecc 437 * Valid double height lines depend on the LCDs number of rows.
wim 34:e5a0dcb43ecc 438 */
wim 34:e5a0dcb43ecc 439 void setBigFont(LCDBigFont lines);
wim 39:e9c2319de9c5 440 #endif
wim 32:59c4b8f648d4 441
wim 39:e9c2319de9c5 442 #if(LCD_ICON==1)
wim 36:9f5f86dfd44a 443 /** Set Icons
wim 36:9f5f86dfd44a 444 *
wim 36:9f5f86dfd44a 445 * @param unsigned char idx The Index of the icon pattern (0..15) for KS0073 and similar controllers
wim 36:9f5f86dfd44a 446 * and Index (0..31) for PCF2103 and similar controllers
wim 36:9f5f86dfd44a 447 * @param unsigned char data The bitpattern for the icons (6 lsb for KS0073 bitpattern (5 lsb for KS0078) and 2 msb for blinkmode)
wim 36:9f5f86dfd44a 448 * The bitpattern for the PCF2103 icons is 5 lsb (UDC 0..2) and 5 lsb for blinkmode (UDC 4..6)
wim 36:9f5f86dfd44a 449 */
wim 36:9f5f86dfd44a 450 void setIcon(unsigned char idx, unsigned char data);
wim 36:9f5f86dfd44a 451
wim 36:9f5f86dfd44a 452 /** Clear Icons
wim 36:9f5f86dfd44a 453 *
wim 36:9f5f86dfd44a 454 * @param none
wim 36:9f5f86dfd44a 455 * @return none
wim 36:9f5f86dfd44a 456 */
wim 36:9f5f86dfd44a 457 //@TODO Add support for 40x4 dual controller
wim 36:9f5f86dfd44a 458 void clrIcon();
wim 39:e9c2319de9c5 459 #endif
wim 36:9f5f86dfd44a 460
wim 39:e9c2319de9c5 461 #if(LCD_INVERT == 1)
wim 36:9f5f86dfd44a 462 /** Set Invert
wim 36:9f5f86dfd44a 463 * setInvert method is supported by some compatible devices (eg KS0073) to swap between black and white
wim 36:9f5f86dfd44a 464 *
wim 36:9f5f86dfd44a 465 * @param bool invertOn Invert on/off
wim 36:9f5f86dfd44a 466 * @return none
wim 36:9f5f86dfd44a 467 */
wim 36:9f5f86dfd44a 468 //@TODO Add support for 40x4 dual controller
wim 36:9f5f86dfd44a 469 void setInvert(bool invertOn);
wim 39:e9c2319de9c5 470 #endif
wim 36:9f5f86dfd44a 471
simon 1:ac48b187213c 472 protected:
wim 13:24506ba22480 473
wim 21:9eb628d9e164 474 /** LCD controller select, mainly used for LCD40x4
wim 21:9eb628d9e164 475 */
wim 19:c747b9e2e7b8 476 enum _LCDCtrl_Idx {
wim 15:b70ebfffb258 477 _LCDCtrl_0, /*< Primary */
wim 15:b70ebfffb258 478 _LCDCtrl_1, /*< Secondary */
wim 15:b70ebfffb258 479 };
wim 21:9eb628d9e164 480
wim 37:ce348c002929 481 /** LCD Datalength control to select between 4 or 8 bit data/commands, mainly used for native Serial interface */
wim 36:9f5f86dfd44a 482 enum _LCDDatalength {
wim 36:9f5f86dfd44a 483 _LCD_DL_4 = 0x00, /**< Datalength 4 bit */
wim 36:9f5f86dfd44a 484 _LCD_DL_8 = 0x10 /**< Datalength 8 bit */
wim 36:9f5f86dfd44a 485 };
wim 36:9f5f86dfd44a 486
wim 21:9eb628d9e164 487 /** Create a TextLCD_Base interface
wim 21:9eb628d9e164 488 * @brief Base class, can not be instantiated
wim 21:9eb628d9e164 489 *
wim 21:9eb628d9e164 490 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 21:9eb628d9e164 491 * @param ctrl LCD controller (default = HD44780)
wim 21:9eb628d9e164 492 */
wim 21:9eb628d9e164 493 TextLCD_Base(LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
wim 15:b70ebfffb258 494
simon 1:ac48b187213c 495 // Stream implementation functions
simon 1:ac48b187213c 496 virtual int _putc(int value);
simon 1:ac48b187213c 497 virtual int _getc();
simon 1:ac48b187213c 498
wim 36:9f5f86dfd44a 499 /** Medium level initialisation method for LCD controller
wim 36:9f5f86dfd44a 500 * @param _LCDDatalength dl sets the datalength of data/commands
wim 36:9f5f86dfd44a 501 * @return none
wim 21:9eb628d9e164 502 */
wim 36:9f5f86dfd44a 503 void _init(_LCDDatalength dl = _LCD_DL_4);
wim 29:a3663151aa65 504
wim 29:a3663151aa65 505 /** Low level initialisation method for LCD controller
wim 36:9f5f86dfd44a 506 * Set number of lines, fonttype, no cursor etc
wim 36:9f5f86dfd44a 507 * The controller is accessed in 4-bit parallel mode either directly via mbed pins or through I2C or SPI expander.
wim 36:9f5f86dfd44a 508 * Some controllers also support native I2C or SPI interfaces.
wim 36:9f5f86dfd44a 509 *
wim 36:9f5f86dfd44a 510 * @param _LCDDatalength dl sets the 4 or 8 bit datalength of data/commands. Required for some native serial modes.
wim 36:9f5f86dfd44a 511 * @return none
wim 29:a3663151aa65 512 */
wim 36:9f5f86dfd44a 513 void _initCtrl(_LCDDatalength dl = _LCD_DL_4);
wim 29:a3663151aa65 514
wim 29:a3663151aa65 515 /** Low level character address set method
wim 29:a3663151aa65 516 */
wim 13:24506ba22480 517 int _address(int column, int row);
wim 29:a3663151aa65 518
wim 29:a3663151aa65 519 /** Low level cursor enable or disable method
wim 29:a3663151aa65 520 */
wim 21:9eb628d9e164 521 void _setCursor(LCDCursor show);
wim 29:a3663151aa65 522
wim 29:a3663151aa65 523 /** Low level method to store user defined characters for current controller
wim 34:e5a0dcb43ecc 524 *
wim 34:e5a0dcb43ecc 525 * @param unsigned char c The Index of the UDC (0..7) for HD44780 clones and (0..15) for some more advanced controllers
wim 34:e5a0dcb43ecc 526 * @param char *udc_data The bitpatterns for the UDC (8 bytes of 5 significant bits)
wim 29:a3663151aa65 527 */
wim 17:652ab113bc2e 528 void _setUDC(unsigned char c, char *udc_data);
wim 29:a3663151aa65 529
wim 29:a3663151aa65 530 /** Low level method to restore the cursortype and display mode for current controller
wim 29:a3663151aa65 531 */
wim 21:9eb628d9e164 532 void _setCursorAndDisplayMode(LCDMode displayMode, LCDCursor cursorType);
wim 13:24506ba22480 533
wim 29:a3663151aa65 534 /** Low level nibble write operation to LCD controller (serial or parallel)
wim 21:9eb628d9e164 535 */
wim 17:652ab113bc2e 536 void _writeNibble(int value);
wim 29:a3663151aa65 537
wim 29:a3663151aa65 538 /** Low level command byte write operation to LCD controller.
wim 29:a3663151aa65 539 * Methods resets the RS bit and provides the required timing for the command.
wim 29:a3663151aa65 540 */
wim 15:b70ebfffb258 541 void _writeCommand(int command);
wim 33:900a94bc7585 542
wim 29:a3663151aa65 543 /** Low level data byte write operation to LCD controller (serial or parallel).
wim 29:a3663151aa65 544 * Methods sets the RS bit and provides the required timing for the data.
wim 29:a3663151aa65 545 */
wim 15:b70ebfffb258 546 void _writeData(int data);
wim 15:b70ebfffb258 547
wim 29:a3663151aa65 548 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
wim 29:a3663151aa65 549 * Set the Enable pin.
wim 29:a3663151aa65 550 */
wim 29:a3663151aa65 551 virtual void _setEnable(bool value) = 0;
wim 29:a3663151aa65 552
wim 21:9eb628d9e164 553 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
wim 29:a3663151aa65 554 * Set the RS pin ( 0 = Command, 1 = Data).
wim 29:a3663151aa65 555 */
wim 21:9eb628d9e164 556 virtual void _setRS(bool value) = 0;
wim 29:a3663151aa65 557
wim 29:a3663151aa65 558 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
wim 29:a3663151aa65 559 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 29:a3663151aa65 560 */
wim 21:9eb628d9e164 561 virtual void _setBL(bool value) = 0;
wim 29:a3663151aa65 562
wim 29:a3663151aa65 563 /** Pure Virtual Low level writes to LCD Bus (serial or parallel)
wim 29:a3663151aa65 564 * Set the databus value (4 bit).
wim 29:a3663151aa65 565 */
wim 21:9eb628d9e164 566 virtual void _setData(int value) = 0;
wim 13:24506ba22480 567
wim 29:a3663151aa65 568 /** Low level byte write operation to LCD controller (serial or parallel)
wim 29:a3663151aa65 569 * Depending on the RS pin this byte will be interpreted as data or command
wim 29:a3663151aa65 570 */
wim 29:a3663151aa65 571 virtual void _writeByte(int value);
wim 33:900a94bc7585 572
wim 13:24506ba22480 573 //Display type
wim 37:ce348c002929 574 LCDType _type; // Display type
wim 37:ce348c002929 575 int _nr_cols;
wim 30:033048611c01 576 int _nr_rows;
wim 37:ce348c002929 577 int _addr_mode; // Addressing mode of LCDType, defines relation between display row,col and controller memory address
wim 37:ce348c002929 578
wim 21:9eb628d9e164 579 //Display mode
wim 17:652ab113bc2e 580 LCDMode _currentMode;
wim 17:652ab113bc2e 581
wim 19:c747b9e2e7b8 582 //Controller type
wim 37:ce348c002929 583 LCDCtrl _ctrl; // Controller type
wim 37:ce348c002929 584 int _font; // ASCII character fonttable
wim 37:ce348c002929 585
wim 15:b70ebfffb258 586 //Controller select, mainly used for LCD40x4
wim 19:c747b9e2e7b8 587 _LCDCtrl_Idx _ctrl_idx;
wim 15:b70ebfffb258 588
wim 13:24506ba22480 589 // Cursor
simon 1:ac48b187213c 590 int _column;
simon 1:ac48b187213c 591 int _row;
wim 32:59c4b8f648d4 592 LCDCursor _currentCursor;
wim 32:59c4b8f648d4 593
wim 36:9f5f86dfd44a 594 // Function modes saved to allow switch between Instruction sets after initialisation time
wim 36:9f5f86dfd44a 595 int _function, _function_1, _function_x;
wim 36:9f5f86dfd44a 596
wim 32:59c4b8f648d4 597 // Icon, Booster mode and contrast saved to allow contrast change at later time
wim 32:59c4b8f648d4 598 // Only available for controllers with added features
wim 36:9f5f86dfd44a 599 int _icon_power, _contrast;
simon 1:ac48b187213c 600 };
simon 1:ac48b187213c 601
wim 23:d47f226efb24 602 //--------- End TextLCD_Base -----------
wim 22:35742ec80c24 603
wim 22:35742ec80c24 604
wim 23:d47f226efb24 605 //--------- Start TextLCD Bus -----------
wim 21:9eb628d9e164 606
wim 21:9eb628d9e164 607 /** Create a TextLCD interface for using regular mbed pins
wim 21:9eb628d9e164 608 *
wim 21:9eb628d9e164 609 */
wim 21:9eb628d9e164 610 class TextLCD : public TextLCD_Base {
wim 21:9eb628d9e164 611 public:
wim 21:9eb628d9e164 612 /** Create a TextLCD interface for using regular mbed pins
wim 21:9eb628d9e164 613 *
wim 21:9eb628d9e164 614 * @param rs Instruction/data control line
wim 21:9eb628d9e164 615 * @param e Enable line (clock)
wim 21:9eb628d9e164 616 * @param d4-d7 Data lines for using as a 4-bit interface
wim 21:9eb628d9e164 617 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 21:9eb628d9e164 618 * @param bl Backlight control line (optional, default = NC)
wim 21:9eb628d9e164 619 * @param e2 Enable2 line (clock for second controller, LCD40x4 only)
wim 21:9eb628d9e164 620 * @param ctrl LCD controller (default = HD44780)
wim 21:9eb628d9e164 621 */
wim 21:9eb628d9e164 622 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 623
wim 22:35742ec80c24 624 /** Destruct a TextLCD interface for using regular mbed pins
wim 22:35742ec80c24 625 *
wim 22:35742ec80c24 626 * @param none
wim 22:35742ec80c24 627 * @return none
wim 22:35742ec80c24 628 */
wim 22:35742ec80c24 629 virtual ~TextLCD();
wim 22:35742ec80c24 630
wim 21:9eb628d9e164 631 private:
wim 29:a3663151aa65 632
wim 29:a3663151aa65 633 /** Implementation of pure Virtual Low level writes to LCD Bus (parallel)
wim 29:a3663151aa65 634 * Set the Enable pin.
wim 29:a3663151aa65 635 */
wim 21:9eb628d9e164 636 virtual void _setEnable(bool value);
wim 29:a3663151aa65 637
wim 29:a3663151aa65 638 /** Implementation of pure Virtual Low level writes to LCD Bus (parallel)
wim 32:59c4b8f648d4 639 * Set the RS pin (0 = Command, 1 = Data).
wim 29:a3663151aa65 640 */
wim 21:9eb628d9e164 641 virtual void _setRS(bool value);
wim 29:a3663151aa65 642
wim 29:a3663151aa65 643 /** Implementation of pure Virtual Low level writes to LCD Bus (parallel)
wim 29:a3663151aa65 644 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 29:a3663151aa65 645 */
wim 21:9eb628d9e164 646 virtual void _setBL(bool value);
wim 29:a3663151aa65 647
wim 29:a3663151aa65 648 /** Implementation of pure Virtual Low level writes to LCD Bus (parallel)
wim 29:a3663151aa65 649 * Set the databus value (4 bit).
wim 29:a3663151aa65 650 */
wim 21:9eb628d9e164 651 virtual void _setData(int value);
wim 21:9eb628d9e164 652
wim 22:35742ec80c24 653 /** Regular mbed pins bus
wim 22:35742ec80c24 654 */
wim 22:35742ec80c24 655 DigitalOut _rs, _e;
wim 22:35742ec80c24 656 BusOut _d;
wim 22:35742ec80c24 657
wim 22:35742ec80c24 658 /** Optional Hardware pins for the Backlight and LCD40x4 device
wim 22:35742ec80c24 659 * Default PinName value is NC, must be used as pointer to avoid issues with mbed lib and DigitalOut pins
wim 22:35742ec80c24 660 */
wim 37:ce348c002929 661 DigitalOut *_bl, *_e2;
wim 21:9eb628d9e164 662 };
wim 21:9eb628d9e164 663
wim 23:d47f226efb24 664 //----------- End TextLCD ---------------
wim 21:9eb628d9e164 665
wim 21:9eb628d9e164 666
wim 23:d47f226efb24 667 //--------- Start TextLCD_I2C -----------
wim 34:e5a0dcb43ecc 668 #if(LCD_I2C == 1) /* I2C Expander PCF8574/MCP23008 */
wim 22:35742ec80c24 669
wim 26:bd897a001012 670 /** Create a TextLCD interface using an I2C PCF8574 (or PCF8574A) or MCP23008 portexpander
wim 21:9eb628d9e164 671 *
wim 21:9eb628d9e164 672 */
wim 21:9eb628d9e164 673 class TextLCD_I2C : public TextLCD_Base {
wim 21:9eb628d9e164 674 public:
wim 26:bd897a001012 675 /** Create a TextLCD interface using an I2C PCF8574 (or PCF8574A) or MCP23008 portexpander
wim 21:9eb628d9e164 676 *
wim 21:9eb628d9e164 677 * @param i2c I2C Bus
wim 37:ce348c002929 678 * @param deviceAddress I2C slave address (PCF8574 (or PCF8574A) or MCP23008 portexpander, default = PCF8574_SA0 = 0x40)
wim 21:9eb628d9e164 679 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 21:9eb628d9e164 680 * @param ctrl LCD controller (default = HD44780)
wim 21:9eb628d9e164 681 */
wim 26:bd897a001012 682 TextLCD_I2C(I2C *i2c, char deviceAddress = PCF8574_SA0, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
wim 21:9eb628d9e164 683
wim 21:9eb628d9e164 684 private:
wim 29:a3663151aa65 685
wim 37:ce348c002929 686 /** Place the Enable bit in the databus shadowvalue
wim 37:ce348c002929 687 * Used for mbed I2C portexpander
wim 37:ce348c002929 688 * @param value data to write
wim 37:ce348c002929 689 * @return none
wim 37:ce348c002929 690 */
wim 37:ce348c002929 691 void _setEnableBit(bool value);
wim 37:ce348c002929 692
wim 29:a3663151aa65 693 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
wim 29:a3663151aa65 694 * Set the Enable pin.
wim 29:a3663151aa65 695 */
wim 21:9eb628d9e164 696 virtual void _setEnable(bool value);
wim 29:a3663151aa65 697
wim 29:a3663151aa65 698 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
wim 32:59c4b8f648d4 699 * Set the RS pin (0 = Command, 1 = Data).
wim 29:a3663151aa65 700 */
wim 21:9eb628d9e164 701 virtual void _setRS(bool value);
wim 29:a3663151aa65 702
wim 29:a3663151aa65 703 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
wim 29:a3663151aa65 704 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 29:a3663151aa65 705 */
wim 21:9eb628d9e164 706 virtual void _setBL(bool value);
wim 29:a3663151aa65 707
wim 37:ce348c002929 708 /** Place the 4bit data in the databus shadowvalue
wim 37:ce348c002929 709 * Used for mbed I2C portexpander
wim 37:ce348c002929 710 * @param value data to write
wim 37:ce348c002929 711 * @return none
wim 37:ce348c002929 712 */
wim 37:ce348c002929 713 void _setDataBits(int value);
wim 37:ce348c002929 714
wim 29:a3663151aa65 715 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
wim 29:a3663151aa65 716 * Set the databus value (4 bit).
wim 29:a3663151aa65 717 */
wim 29:a3663151aa65 718 virtual void _setData(int value);
wim 37:ce348c002929 719
wim 37:ce348c002929 720 //New optimized
wim 37:ce348c002929 721 //Test faster _writeByte 0.11s vs 0.27s for a 20x4 fillscreen (PCF8574)
wim 37:ce348c002929 722 //Test faster _writeByte 0.14s vs 0.34s for a 20x4 fillscreen (MCP23008)
wim 37:ce348c002929 723
wim 37:ce348c002929 724 /** Low level writes to LCD serial bus expander
wim 37:ce348c002929 725 */
wim 37:ce348c002929 726 virtual void _writeByte(int value);
wim 37:ce348c002929 727
wim 29:a3663151aa65 728 /** Write data to MCP23008 I2C portexpander
wim 29:a3663151aa65 729 * @param reg register to write
wim 29:a3663151aa65 730 * @param value data to write
wim 29:a3663151aa65 731 * @return none
wim 29:a3663151aa65 732 */
wim 37:ce348c002929 733 void _writeRegister (int reg, int value);
wim 21:9eb628d9e164 734
wim 21:9eb628d9e164 735 //I2C bus
wim 21:9eb628d9e164 736 I2C *_i2c;
wim 21:9eb628d9e164 737 char _slaveAddress;
wim 21:9eb628d9e164 738
wim 37:ce348c002929 739 // Internal bus shadow value for serial bus only
wim 30:033048611c01 740 char _lcd_bus;
wim 21:9eb628d9e164 741 };
wim 34:e5a0dcb43ecc 742 #endif /* I2C Expander PCF8574/MCP23008 */
wim 21:9eb628d9e164 743
wim 23:d47f226efb24 744 //---------- End TextLCD_I2C ------------
wim 22:35742ec80c24 745
wim 22:35742ec80c24 746
wim 23:d47f226efb24 747 //--------- Start TextLCD_SPI -----------
wim 34:e5a0dcb43ecc 748 #if(LCD_SPI == 1) /* SPI Expander SN74595 */
wim 22:35742ec80c24 749
wim 21:9eb628d9e164 750 /** Create a TextLCD interface using an SPI 74595 portexpander
wim 21:9eb628d9e164 751 *
wim 21:9eb628d9e164 752 */
wim 21:9eb628d9e164 753 class TextLCD_SPI : public TextLCD_Base {
wim 21:9eb628d9e164 754 public:
wim 21:9eb628d9e164 755 /** Create a TextLCD interface using an SPI 74595 portexpander
wim 21:9eb628d9e164 756 *
wim 21:9eb628d9e164 757 * @param spi SPI Bus
wim 21:9eb628d9e164 758 * @param cs chip select pin (active low)
wim 21:9eb628d9e164 759 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 21:9eb628d9e164 760 * @param ctrl LCD controller (default = HD44780)
wim 21:9eb628d9e164 761 */
wim 21:9eb628d9e164 762 TextLCD_SPI(SPI *spi, PinName cs, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780);
wim 21:9eb628d9e164 763
wim 21:9eb628d9e164 764 private:
wim 29:a3663151aa65 765
wim 29:a3663151aa65 766 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
wim 29:a3663151aa65 767 * Set the Enable pin.
wim 29:a3663151aa65 768 */
wim 21:9eb628d9e164 769 virtual void _setEnable(bool value);
wim 29:a3663151aa65 770
wim 29:a3663151aa65 771 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
wim 32:59c4b8f648d4 772 * Set the RS pin (0 = Command, 1 = Data).
wim 29:a3663151aa65 773 */
wim 21:9eb628d9e164 774 virtual void _setRS(bool value);
wim 29:a3663151aa65 775
wim 29:a3663151aa65 776 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
wim 29:a3663151aa65 777 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 29:a3663151aa65 778 */
wim 21:9eb628d9e164 779 virtual void _setBL(bool value);
wim 29:a3663151aa65 780
wim 29:a3663151aa65 781 /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander)
wim 29:a3663151aa65 782 * Set the databus value (4 bit).
wim 29:a3663151aa65 783 */
wim 37:ce348c002929 784 virtual void _setData(int value);
wim 21:9eb628d9e164 785
wim 21:9eb628d9e164 786 // SPI bus
wim 21:9eb628d9e164 787 SPI *_spi;
wim 21:9eb628d9e164 788 DigitalOut _cs;
wim 21:9eb628d9e164 789
wim 37:ce348c002929 790 // Internal bus shadow value for serial bus only
wim 21:9eb628d9e164 791 char _lcd_bus;
wim 21:9eb628d9e164 792 };
wim 34:e5a0dcb43ecc 793 #endif /* SPI Expander SN74595 */
wim 23:d47f226efb24 794 //---------- End TextLCD_SPI ------------
wim 21:9eb628d9e164 795
Sissors 24:fb3399713710 796
wim 37:ce348c002929 797 //--------- Start TextLCD_I2C_N -----------
wim 37:ce348c002929 798 #if(LCD_I2C_N == 1) /* Native I2C */
wim 37:ce348c002929 799
wim 37:ce348c002929 800 /** Create a TextLCD interface using a controller with native I2C interface
wim 37:ce348c002929 801 *
wim 37:ce348c002929 802 */
wim 37:ce348c002929 803 class TextLCD_I2C_N : public TextLCD_Base {
wim 37:ce348c002929 804 public:
wim 37:ce348c002929 805 /** Create a TextLCD interface using a controller with native I2C interface
wim 37:ce348c002929 806 *
wim 37:ce348c002929 807 * @param i2c I2C Bus
wim 37:ce348c002929 808 * @param deviceAddress I2C slave address (default = ST7032_SA = 0x7C)
wim 37:ce348c002929 809 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 37:ce348c002929 810 * @param bl Backlight control line (optional, default = NC)
wim 37:ce348c002929 811 * @param ctrl LCD controller (default = ST7032_3V3)
wim 37:ce348c002929 812 */
wim 37:ce348c002929 813 TextLCD_I2C_N(I2C *i2c, char deviceAddress = ST7032_SA, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7032_3V3);
wim 37:ce348c002929 814
wim 37:ce348c002929 815 /** Destruct a TextLCD interface using a controller with native I2C interface
wim 37:ce348c002929 816 */
wim 37:ce348c002929 817 virtual ~TextLCD_I2C_N(void);
wim 37:ce348c002929 818
wim 37:ce348c002929 819 private:
wim 37:ce348c002929 820
wim 37:ce348c002929 821 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 37:ce348c002929 822 * Set the Enable pin.
wim 37:ce348c002929 823 */
wim 37:ce348c002929 824 virtual void _setEnable(bool value);
wim 37:ce348c002929 825
wim 37:ce348c002929 826 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 37:ce348c002929 827 * Set the RS pin ( 0 = Command, 1 = Data).
wim 37:ce348c002929 828 */
wim 37:ce348c002929 829 virtual void _setRS(bool value);
wim 37:ce348c002929 830
wim 37:ce348c002929 831 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 37:ce348c002929 832 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 37:ce348c002929 833 */
wim 37:ce348c002929 834 virtual void _setBL(bool value);
wim 37:ce348c002929 835
wim 37:ce348c002929 836 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 37:ce348c002929 837 * Set the databus value (4 bit).
wim 37:ce348c002929 838 */
wim 37:ce348c002929 839 virtual void _setData(int value);
wim 37:ce348c002929 840
wim 37:ce348c002929 841 /** Low level writes to LCD serial bus only (serial native)
wim 37:ce348c002929 842 */
wim 37:ce348c002929 843 virtual void _writeByte(int value);
wim 37:ce348c002929 844
wim 37:ce348c002929 845 //I2C bus
wim 37:ce348c002929 846 I2C *_i2c;
wim 37:ce348c002929 847 char _slaveAddress;
wim 37:ce348c002929 848
wim 37:ce348c002929 849 // controlbyte to select between data and command. Internal shadow value for serial bus only
wim 37:ce348c002929 850 char _controlbyte;
wim 37:ce348c002929 851
wim 37:ce348c002929 852 //Backlight
wim 37:ce348c002929 853 DigitalOut *_bl;
wim 37:ce348c002929 854
wim 37:ce348c002929 855 };
wim 37:ce348c002929 856 #endif /* Native I2C */
wim 37:ce348c002929 857 //---------- End TextLCD_I2C_N ------------
wim 37:ce348c002929 858
wim 37:ce348c002929 859
wim 26:bd897a001012 860 //--------- Start TextLCD_SPI_N -----------
wim 34:e5a0dcb43ecc 861 #if(LCD_SPI_N == 1) /* Native SPI bus */
Sissors 24:fb3399713710 862
wim 30:033048611c01 863 /** Create a TextLCD interface using a controller with native SPI4 interface
Sissors 24:fb3399713710 864 *
Sissors 24:fb3399713710 865 */
wim 25:6162b31128c9 866 class TextLCD_SPI_N : public TextLCD_Base {
Sissors 24:fb3399713710 867 public:
wim 30:033048611c01 868 /** Create a TextLCD interface using a controller with native SPI4 interface
Sissors 24:fb3399713710 869 *
Sissors 24:fb3399713710 870 * @param spi SPI Bus
Sissors 24:fb3399713710 871 * @param cs chip select pin (active low)
Sissors 24:fb3399713710 872 * @param rs Instruction/data control line
Sissors 24:fb3399713710 873 * @param type Sets the panel size/addressing mode (default = LCD16x2)
Sissors 24:fb3399713710 874 * @param bl Backlight control line (optional, default = NC)
wim 26:bd897a001012 875 * @param ctrl LCD controller (default = ST7032_3V3)
Sissors 24:fb3399713710 876 */
wim 26:bd897a001012 877 TextLCD_SPI_N(SPI *spi, PinName cs, PinName rs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7032_3V3);
wim 37:ce348c002929 878
wim 37:ce348c002929 879 /** Destruct a TextLCD interface using a controller with native SPI4 interface
wim 37:ce348c002929 880 */
wim 25:6162b31128c9 881 virtual ~TextLCD_SPI_N(void);
Sissors 24:fb3399713710 882
Sissors 24:fb3399713710 883 private:
wim 29:a3663151aa65 884
wim 29:a3663151aa65 885 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 29:a3663151aa65 886 * Set the Enable pin.
wim 29:a3663151aa65 887 */
Sissors 24:fb3399713710 888 virtual void _setEnable(bool value);
wim 29:a3663151aa65 889
wim 29:a3663151aa65 890 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 891 * Set the RS pin (0 = Command, 1 = Data).
wim 29:a3663151aa65 892 */
Sissors 24:fb3399713710 893 virtual void _setRS(bool value);
wim 29:a3663151aa65 894
wim 29:a3663151aa65 895 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 29:a3663151aa65 896 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 29:a3663151aa65 897 */
Sissors 24:fb3399713710 898 virtual void _setBL(bool value);
wim 29:a3663151aa65 899
wim 29:a3663151aa65 900 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 29:a3663151aa65 901 * Set the databus value (4 bit).
wim 29:a3663151aa65 902 */
Sissors 24:fb3399713710 903 virtual void _setData(int value);
wim 29:a3663151aa65 904
wim 29:a3663151aa65 905 /** Low level writes to LCD serial bus only (serial native)
wim 29:a3663151aa65 906 */
Sissors 24:fb3399713710 907 virtual void _writeByte(int value);
Sissors 24:fb3399713710 908
Sissors 24:fb3399713710 909 // SPI bus
Sissors 24:fb3399713710 910 SPI *_spi;
Sissors 24:fb3399713710 911 DigitalOut _cs;
Sissors 24:fb3399713710 912 DigitalOut _rs;
wim 30:033048611c01 913
wim 30:033048611c01 914 //Backlight
Sissors 24:fb3399713710 915 DigitalOut *_bl;
Sissors 24:fb3399713710 916 };
wim 34:e5a0dcb43ecc 917 #endif /* Native SPI bus */
wim 25:6162b31128c9 918 //---------- End TextLCD_SPI_N ------------
Sissors 24:fb3399713710 919
wim 26:bd897a001012 920
wim 36:9f5f86dfd44a 921 //-------- Start TextLCD_SPI_N_3_8 --------
wim 36:9f5f86dfd44a 922 #if(LCD_SPI_N_3_8 == 1) /* Native SPI bus */
wim 37:ce348c002929 923 /** Create a TextLCD interface using a controller with native SPI3 8 bits interface
wim 37:ce348c002929 924 * This mode is supported by ST7070.
wim 37:ce348c002929 925 *
wim 37:ce348c002929 926 */
wim 36:9f5f86dfd44a 927 class TextLCD_SPI_N_3_8 : public TextLCD_Base {
wim 36:9f5f86dfd44a 928 public:
wim 36:9f5f86dfd44a 929 /** Create a TextLCD interface using a controller with a native SPI3 8 bits interface
wim 36:9f5f86dfd44a 930 * This mode is supported by ST7070. Note that implementation in TexTLCD is not very efficient due to
wim 36:9f5f86dfd44a 931 * structure of the TextLCD library: each databyte is written separately and requires a separate 'count command' set to 1 byte.
wim 36:9f5f86dfd44a 932 *
wim 36:9f5f86dfd44a 933 * @param spi SPI Bus
wim 36:9f5f86dfd44a 934 * @param cs chip select pin (active low)
wim 36:9f5f86dfd44a 935 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 36:9f5f86dfd44a 936 * @param bl Backlight control line (optional, default = NC)
wim 36:9f5f86dfd44a 937 * @param ctrl LCD controller (default = ST7070)
wim 36:9f5f86dfd44a 938 */
wim 36:9f5f86dfd44a 939 TextLCD_SPI_N_3_8(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7070);
wim 36:9f5f86dfd44a 940
wim 37:ce348c002929 941 /** Destruct a TextLCD interface using a controller with native SPI3_8 interface
wim 37:ce348c002929 942 */
wim 36:9f5f86dfd44a 943 virtual ~TextLCD_SPI_N_3_8(void);
wim 36:9f5f86dfd44a 944
wim 36:9f5f86dfd44a 945 private:
wim 36:9f5f86dfd44a 946
wim 36:9f5f86dfd44a 947 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 36:9f5f86dfd44a 948 * Set the Enable pin.
wim 36:9f5f86dfd44a 949 */
wim 36:9f5f86dfd44a 950 virtual void _setEnable(bool value);
wim 36:9f5f86dfd44a 951
wim 36:9f5f86dfd44a 952 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 36:9f5f86dfd44a 953 * Set the RS pin (0 = Command, 1 = Data).
wim 36:9f5f86dfd44a 954 */
wim 36:9f5f86dfd44a 955 virtual void _setRS(bool value);
wim 36:9f5f86dfd44a 956
wim 36:9f5f86dfd44a 957 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 36:9f5f86dfd44a 958 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 36:9f5f86dfd44a 959 */
wim 36:9f5f86dfd44a 960 virtual void _setBL(bool value);
wim 36:9f5f86dfd44a 961
wim 36:9f5f86dfd44a 962 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 36:9f5f86dfd44a 963 * Set the databus value (4 bit).
wim 36:9f5f86dfd44a 964 */
wim 36:9f5f86dfd44a 965 virtual void _setData(int value);
wim 36:9f5f86dfd44a 966
wim 36:9f5f86dfd44a 967 /** Low level writes to LCD serial bus only (serial native)
wim 36:9f5f86dfd44a 968 */
wim 36:9f5f86dfd44a 969 virtual void _writeByte(int value);
wim 36:9f5f86dfd44a 970
wim 36:9f5f86dfd44a 971 // SPI bus
wim 36:9f5f86dfd44a 972 SPI *_spi;
wim 36:9f5f86dfd44a 973 DigitalOut _cs;
wim 36:9f5f86dfd44a 974
wim 37:ce348c002929 975 // controlbyte to select between data and command. Internal shadow value for serial bus only
wim 36:9f5f86dfd44a 976 char _controlbyte;
wim 36:9f5f86dfd44a 977
wim 36:9f5f86dfd44a 978 //Backlight
wim 36:9f5f86dfd44a 979 DigitalOut *_bl;
wim 36:9f5f86dfd44a 980 };
wim 36:9f5f86dfd44a 981
wim 36:9f5f86dfd44a 982 #endif /* Native SPI bus */
wim 36:9f5f86dfd44a 983 //------- End TextLCD_SPI_N_3_8 -----------
wim 36:9f5f86dfd44a 984
wim 36:9f5f86dfd44a 985
wim 34:e5a0dcb43ecc 986 //------- Start TextLCD_SPI_N_3_9 ---------
wim 34:e5a0dcb43ecc 987 #if(LCD_SPI_N_3_9 == 1) /* Native SPI bus */
wim 30:033048611c01 988 //Code checked out on logic analyser. Not yet tested on hardware..
wim 30:033048611c01 989
wim 30:033048611c01 990 /** Create a TextLCD interface using a controller with native SPI3 9 bits interface
wim 30:033048611c01 991 * Note: current mbed libs only support SPI 9 bit mode for NXP platforms
wim 30:033048611c01 992 *
wim 30:033048611c01 993 */
wim 30:033048611c01 994 class TextLCD_SPI_N_3_9 : public TextLCD_Base {
wim 30:033048611c01 995 public:
wim 30:033048611c01 996 /** Create a TextLCD interface using a controller with native SPI3 9 bits interface
wim 30:033048611c01 997 * Note: current mbed libs only support SPI 9 bit mode for NXP platforms
wim 30:033048611c01 998 *
wim 30:033048611c01 999 * @param spi SPI Bus
wim 30:033048611c01 1000 * @param cs chip select pin (active low)
wim 30:033048611c01 1001 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 30:033048611c01 1002 * @param bl Backlight control line (optional, default = NC)
wim 30:033048611c01 1003 * @param ctrl LCD controller (default = AIP31068)
wim 30:033048611c01 1004 */
wim 30:033048611c01 1005 TextLCD_SPI_N_3_9(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = AIP31068);
wim 37:ce348c002929 1006
wim 37:ce348c002929 1007 /** Destruct a TextLCD interface using a controller with native SPI3_9 interface
wim 37:ce348c002929 1008 */
wim 30:033048611c01 1009 virtual ~TextLCD_SPI_N_3_9(void);
wim 30:033048611c01 1010
wim 30:033048611c01 1011 private:
wim 30:033048611c01 1012
wim 30:033048611c01 1013 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 30:033048611c01 1014 * Set the Enable pin.
wim 30:033048611c01 1015 */
wim 30:033048611c01 1016 virtual void _setEnable(bool value);
wim 30:033048611c01 1017
wim 30:033048611c01 1018 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1019 * Set the RS pin (0 = Command, 1 = Data).
wim 32:59c4b8f648d4 1020 */
wim 32:59c4b8f648d4 1021 virtual void _setRS(bool value);
wim 32:59c4b8f648d4 1022
wim 32:59c4b8f648d4 1023 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1024 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 32:59c4b8f648d4 1025 */
wim 32:59c4b8f648d4 1026 virtual void _setBL(bool value);
wim 32:59c4b8f648d4 1027
wim 32:59c4b8f648d4 1028 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1029 * Set the databus value (4 bit).
wim 32:59c4b8f648d4 1030 */
wim 32:59c4b8f648d4 1031 virtual void _setData(int value);
wim 32:59c4b8f648d4 1032
wim 32:59c4b8f648d4 1033 /** Low level writes to LCD serial bus only (serial native)
wim 32:59c4b8f648d4 1034 */
wim 32:59c4b8f648d4 1035 virtual void _writeByte(int value);
wim 32:59c4b8f648d4 1036
wim 32:59c4b8f648d4 1037 // SPI bus
wim 32:59c4b8f648d4 1038 SPI *_spi;
wim 32:59c4b8f648d4 1039 DigitalOut _cs;
wim 32:59c4b8f648d4 1040
wim 37:ce348c002929 1041 // controlbyte to select between data and command. Internal shadow value for serial bus only
wim 32:59c4b8f648d4 1042 char _controlbyte;
wim 32:59c4b8f648d4 1043
wim 32:59c4b8f648d4 1044 //Backlight
wim 32:59c4b8f648d4 1045 DigitalOut *_bl;
wim 32:59c4b8f648d4 1046 };
wim 34:e5a0dcb43ecc 1047 #endif /* Native SPI bus */
wim 32:59c4b8f648d4 1048 //-------- End TextLCD_SPI_N_3_9 ----------
wim 32:59c4b8f648d4 1049
wim 32:59c4b8f648d4 1050
wim 32:59c4b8f648d4 1051 //------- Start TextLCD_SPI_N_3_10 ---------
wim 34:e5a0dcb43ecc 1052 #if(LCD_SPI_N_3_10 == 1) /* Native SPI bus */
wim 32:59c4b8f648d4 1053
wim 32:59c4b8f648d4 1054 /** Create a TextLCD interface using a controller with native SPI3 10 bits interface
wim 32:59c4b8f648d4 1055 * Note: current mbed libs only support SPI 10 bit mode for NXP platforms
wim 32:59c4b8f648d4 1056 *
wim 32:59c4b8f648d4 1057 */
wim 32:59c4b8f648d4 1058 class TextLCD_SPI_N_3_10 : public TextLCD_Base {
wim 32:59c4b8f648d4 1059 public:
wim 32:59c4b8f648d4 1060 /** Create a TextLCD interface using a controller with native SPI3 10 bits interface
wim 32:59c4b8f648d4 1061 * Note: current mbed libs only support SPI 10 bit mode for NXP platforms
wim 32:59c4b8f648d4 1062 *
wim 32:59c4b8f648d4 1063 * @param spi SPI Bus
wim 32:59c4b8f648d4 1064 * @param cs chip select pin (active low)
wim 32:59c4b8f648d4 1065 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 32:59c4b8f648d4 1066 * @param bl Backlight control line (optional, default = NC)
wim 32:59c4b8f648d4 1067 * @param ctrl LCD controller (default = AIP31068)
wim 32:59c4b8f648d4 1068 */
wim 32:59c4b8f648d4 1069 TextLCD_SPI_N_3_10(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = AIP31068);
wim 37:ce348c002929 1070
wim 37:ce348c002929 1071 /** Destruct a TextLCD interface using a controller with native SPI3_10 interface
wim 37:ce348c002929 1072 */
wim 32:59c4b8f648d4 1073 virtual ~TextLCD_SPI_N_3_10(void);
wim 32:59c4b8f648d4 1074
wim 32:59c4b8f648d4 1075 private:
wim 32:59c4b8f648d4 1076
wim 32:59c4b8f648d4 1077 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1078 * Set the Enable pin.
wim 32:59c4b8f648d4 1079 */
wim 32:59c4b8f648d4 1080 virtual void _setEnable(bool value);
wim 32:59c4b8f648d4 1081
wim 32:59c4b8f648d4 1082 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1083 * Set the RS pin (0 = Command, 1 = Data).
wim 32:59c4b8f648d4 1084 */
wim 32:59c4b8f648d4 1085 virtual void _setRS(bool value);
wim 32:59c4b8f648d4 1086
wim 32:59c4b8f648d4 1087 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1088 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 32:59c4b8f648d4 1089 */
wim 32:59c4b8f648d4 1090 virtual void _setBL(bool value);
wim 32:59c4b8f648d4 1091
wim 32:59c4b8f648d4 1092 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1093 * Set the databus value (4 bit).
wim 32:59c4b8f648d4 1094 */
wim 32:59c4b8f648d4 1095 virtual void _setData(int value);
wim 32:59c4b8f648d4 1096
wim 32:59c4b8f648d4 1097 /** Low level writes to LCD serial bus only (serial native)
wim 32:59c4b8f648d4 1098 */
wim 32:59c4b8f648d4 1099 virtual void _writeByte(int value);
wim 32:59c4b8f648d4 1100
wim 32:59c4b8f648d4 1101 // SPI bus
wim 32:59c4b8f648d4 1102 SPI *_spi;
wim 32:59c4b8f648d4 1103 DigitalOut _cs;
wim 36:9f5f86dfd44a 1104
wim 37:ce348c002929 1105 // controlbyte to select between data and command. Internal shadow value for serial bus only
wim 32:59c4b8f648d4 1106 char _controlbyte;
wim 32:59c4b8f648d4 1107
wim 32:59c4b8f648d4 1108 //Backlight
wim 32:59c4b8f648d4 1109 DigitalOut *_bl;
wim 32:59c4b8f648d4 1110 };
wim 32:59c4b8f648d4 1111
wim 34:e5a0dcb43ecc 1112 #endif /* Native SPI bus */
wim 32:59c4b8f648d4 1113 //-------- End TextLCD_SPI_N_3_10 ----------
wim 32:59c4b8f648d4 1114
wim 32:59c4b8f648d4 1115
wim 32:59c4b8f648d4 1116 //------- Start TextLCD_SPI_N_3_16 ---------
wim 34:e5a0dcb43ecc 1117 #if(LCD_SPI_N_3_16 == 1) /* Native SPI bus */
wim 32:59c4b8f648d4 1118
wim 32:59c4b8f648d4 1119 /** Create a TextLCD interface using a controller with native SPI3 16 bits interface
wim 32:59c4b8f648d4 1120 *
wim 32:59c4b8f648d4 1121 */
wim 32:59c4b8f648d4 1122 class TextLCD_SPI_N_3_16 : public TextLCD_Base {
wim 32:59c4b8f648d4 1123 public:
wim 32:59c4b8f648d4 1124 /** Create a TextLCD interface using a controller with native SPI3 16 bits interface
wim 32:59c4b8f648d4 1125 *
wim 32:59c4b8f648d4 1126 * @param spi SPI Bus
wim 32:59c4b8f648d4 1127 * @param cs chip select pin (active low)
wim 32:59c4b8f648d4 1128 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 32:59c4b8f648d4 1129 * @param bl Backlight control line (optional, default = NC)
wim 32:59c4b8f648d4 1130 * @param ctrl LCD controller (default = PT6314)
wim 32:59c4b8f648d4 1131 */
wim 32:59c4b8f648d4 1132 TextLCD_SPI_N_3_16(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = PT6314);
wim 37:ce348c002929 1133
wim 37:ce348c002929 1134 /** Destruct a TextLCD interface using a controller with native SPI3_16 interface
wim 37:ce348c002929 1135 */
wim 32:59c4b8f648d4 1136 virtual ~TextLCD_SPI_N_3_16(void);
wim 32:59c4b8f648d4 1137
wim 32:59c4b8f648d4 1138 private:
wim 32:59c4b8f648d4 1139
wim 32:59c4b8f648d4 1140 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1141 * Set the Enable pin.
wim 32:59c4b8f648d4 1142 */
wim 32:59c4b8f648d4 1143 virtual void _setEnable(bool value);
wim 32:59c4b8f648d4 1144
wim 32:59c4b8f648d4 1145 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1146 * Set the RS pin (0 = Command, 1 = Data).
wim 30:033048611c01 1147 */
wim 30:033048611c01 1148 virtual void _setRS(bool value);
wim 30:033048611c01 1149
wim 30:033048611c01 1150 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 30:033048611c01 1151 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 30:033048611c01 1152 */
wim 30:033048611c01 1153 virtual void _setBL(bool value);
wim 30:033048611c01 1154
wim 30:033048611c01 1155 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 30:033048611c01 1156 * Set the databus value (4 bit).
wim 30:033048611c01 1157 */
wim 30:033048611c01 1158 virtual void _setData(int value);
wim 30:033048611c01 1159
wim 30:033048611c01 1160 /** Low level writes to LCD serial bus only (serial native)
wim 30:033048611c01 1161 */
wim 30:033048611c01 1162 virtual void _writeByte(int value);
wim 30:033048611c01 1163
wim 30:033048611c01 1164 // SPI bus
wim 30:033048611c01 1165 SPI *_spi;
wim 30:033048611c01 1166 DigitalOut _cs;
wim 30:033048611c01 1167
wim 37:ce348c002929 1168 // controlbyte to select between data and command. Internal shadow value for serial bus only
wim 30:033048611c01 1169 char _controlbyte;
wim 30:033048611c01 1170
wim 30:033048611c01 1171 //Backlight
wim 30:033048611c01 1172 DigitalOut *_bl;
wim 30:033048611c01 1173 };
wim 34:e5a0dcb43ecc 1174 #endif /* Native SPI bus */
wim 32:59c4b8f648d4 1175 //-------- End TextLCD_SPI_N_3_16 ----------
wim 34:e5a0dcb43ecc 1176
wim 30:033048611c01 1177
wim 32:59c4b8f648d4 1178 //------- Start TextLCD_SPI_N_3_24 ---------
wim 34:e5a0dcb43ecc 1179 #if(LCD_SPI_N_3_24 == 1) /* Native SPI bus */
wim 30:033048611c01 1180
wim 32:59c4b8f648d4 1181 /** Create a TextLCD interface using a controller with native SPI3 24 bits interface
wim 32:59c4b8f648d4 1182 * Note: lib uses SPI 8 bit mode
wim 30:033048611c01 1183 *
wim 30:033048611c01 1184 */
wim 32:59c4b8f648d4 1185 class TextLCD_SPI_N_3_24 : public TextLCD_Base {
wim 30:033048611c01 1186 public:
wim 32:59c4b8f648d4 1187 /** Create a TextLCD interface using a controller with native SPI3 24 bits interface
wim 32:59c4b8f648d4 1188 * Note: lib uses SPI 8 bit mode
wim 30:033048611c01 1189 *
wim 30:033048611c01 1190 * @param spi SPI Bus
wim 30:033048611c01 1191 * @param cs chip select pin (active low)
wim 30:033048611c01 1192 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 30:033048611c01 1193 * @param bl Backlight control line (optional, default = NC)
wim 32:59c4b8f648d4 1194 * @param ctrl LCD controller (default = SSD1803)
wim 30:033048611c01 1195 */
wim 32:59c4b8f648d4 1196 TextLCD_SPI_N_3_24(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = SSD1803_3V3);
wim 37:ce348c002929 1197
wim 37:ce348c002929 1198 /** Destruct a TextLCD interface using a controller with native SPI3_24 interface
wim 37:ce348c002929 1199 */
wim 32:59c4b8f648d4 1200 virtual ~TextLCD_SPI_N_3_24(void);
wim 30:033048611c01 1201
wim 30:033048611c01 1202 private:
wim 30:033048611c01 1203
wim 30:033048611c01 1204 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 30:033048611c01 1205 * Set the Enable pin.
wim 30:033048611c01 1206 */
wim 30:033048611c01 1207 virtual void _setEnable(bool value);
wim 30:033048611c01 1208
wim 30:033048611c01 1209 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 32:59c4b8f648d4 1210 * Set the RS pin (0 = Command, 1 = Data).
wim 30:033048611c01 1211 */
wim 30:033048611c01 1212 virtual void _setRS(bool value);
wim 30:033048611c01 1213
wim 30:033048611c01 1214 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 30:033048611c01 1215 * Set the BL pin (0 = Backlight Off, 1 = Backlight On).
wim 30:033048611c01 1216 */
wim 30:033048611c01 1217 virtual void _setBL(bool value);
wim 30:033048611c01 1218
wim 30:033048611c01 1219 /** Implementation of pure Virtual Low level writes to LCD Bus (serial native)
wim 30:033048611c01 1220 * Set the databus value (4 bit).
wim 30:033048611c01 1221 */
wim 30:033048611c01 1222 virtual void _setData(int value);
wim 30:033048611c01 1223
wim 30:033048611c01 1224 /** Low level writes to LCD serial bus only (serial native)
wim 30:033048611c01 1225 */
wim 30:033048611c01 1226 virtual void _writeByte(int value);
wim 30:033048611c01 1227
wim 30:033048611c01 1228 // SPI bus
wim 30:033048611c01 1229 SPI *_spi;
wim 30:033048611c01 1230 DigitalOut _cs;
wim 30:033048611c01 1231
wim 30:033048611c01 1232 // controlbyte to select between data and command. Internal value for serial bus only
wim 30:033048611c01 1233 char _controlbyte;
wim 30:033048611c01 1234
wim 30:033048611c01 1235 //Backlight
wim 30:033048611c01 1236 DigitalOut *_bl;
wim 30:033048611c01 1237 };
wim 34:e5a0dcb43ecc 1238 #endif /* Native SPI bus */
wim 32:59c4b8f648d4 1239 //-------- End TextLCD_SPI_N_3_24 ----------
wim 30:033048611c01 1240
wim 38:cbe275b0b647 1241
simon 1:ac48b187213c 1242 #endif