proyecto LCD

Committer:
fcalzadas
Date:
Wed Nov 13 21:28:23 2019 +0000
Revision:
9:2db641efba7e
Parent:
8:308d188a2d3a
proyecto de LCD

Who changed what in which revision?

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