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