The code implement timers to make a clock. The lcd16x2 is used to display the Hour, min and seconds. It also provide alarm capabilities

Committer:
EDISON_NGUNJIRI
Date:
Mon May 16 06:06:11 2022 +0000
Revision:
0:0898e006947b
LCD16X2 in 4bit mode clock

Who changed what in which revision?

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