sd

Fork of TextLCD by Wim Huiskamp

Committer:
wim
Date:
Fri Nov 06 18:59:27 2015 +0000
Revision:
41:111ca62e8a59
Parent:
40:d3496c3ea301
Added setFont() support (for SSD1803, US2066, ST7070) and support for UTF-8 code (Cyrillic language), added SPLC792A controller.

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