I2C

Committer:
docent
Date:
Thu Jul 16 07:15:57 2020 +0000
Revision:
43:eb52abed1a83
Parent:
41:111ca62e8a59
for my students

Who changed what in which revision?

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