aula 25

Dependents:   Aula25 Onda_lcd

Committer:
ligeiro13
Date:
Mon May 20 22:06:39 2019 +0000
Revision:
0:7b0da2d7a4e4
aps 4

Who changed what in which revision?

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