ssss

Committer:
irsanjul
Date:
Tue Aug 18 14:57:10 2020 +0000
Revision:
0:d51588bf1724
ssss

Who changed what in which revision?

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