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