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