LCD

Committer:
EDISON_NGUNJIRI
Date:
Sat Dec 11 06:23:29 2021 +0000
Revision:
0:39afc9064b51
code for LCD16X2 and DHT22

Who changed what in which revision?

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