software about measure for robotic

Dependents:   A18_RobotmeasureV1

Fork of TextLCD by Wim Huiskamp

It's error WTF !!!

Committer:
wim
Date:
Fri Oct 10 15:47:56 2014 +0000
Revision:
35:311be6444a39
Parent:
34:e5a0dcb43ecc
Child:
36:9f5f86dfd44a
Added AC780 support, added I2C expander module types, fixed setBacklight() for inverted logic I2C expander modules. Fixed bug in LCD_SPI_N define.

Who changed what in which revision?

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