Updated for more display types. Fixed memoryaddress confusion in address() method. Added new getAddress() method. Added support for UDCs, Backlight control and other features such as control through I2C and SPI port expanders and controllers with native I2C and SPI interfaces. Refactored to fix issue with pins that are default declared as NC.
Dependents: GPSDevice TestTextLCD SD to Flash Data Transfer DrumMachine ... more
Fork of TextLCD by
Example
Hello World! for the TextLCD
#include "mbed.h" #include "TextLCD.h" // Host PC Communication channels Serial pc(USBTX, USBRX); // tx, rx // I2C Communication I2C i2c_lcd(p28,p27); // SDA, SCL // SPI Communication SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK //TextLCD lcd(p15, p16, p17, p18, p19, p20); // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780 //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, 74595 expander, CS pin, LCD Type TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type //TextLCD_SPI_N lcd(&spi_lcd, p8, p9); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3 //TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=ST7032_3V3 int main() { pc.printf("LCD Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows()); for (int row=0; row<lcd.rows(); row++) { int col=0; pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); // lcd.putc('-'); lcd.putc('0' + row); for (col=1; col<lcd.columns()-1; col++) { lcd.putc('*'); } pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); lcd.putc('+'); } // Show cursor as blinking character lcd.setCursor(TextLCD::CurOff_BlkOn); // Set and show user defined characters. A maximum of 8 UDCs are supported by the HD44780. // They are defined by a 5x7 bitpattern. lcd.setUDC(0, (char *) udc_0); // Show |> lcd.putc(0); lcd.setUDC(1, (char *) udc_1); // Show <| lcd.putc(1); }
Handbook page
More info is here
TextLCD.h@24:fb3399713710, 2014-05-10 (annotated)
- Committer:
- Sissors
- Date:
- Sat May 10 13:50:25 2014 +0000
- Revision:
- 24:fb3399713710
- Parent:
- 23:d47f226efb24
- Child:
- 25:6162b31128c9
Added ST7032 support + SPI mode
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 1:ac48b187213c | 1 | /* mbed TextLCD Library, for a 4-bit LCD based on HD44780 |
simon | 6:e4cb7ddee0d3 | 2 | * Copyright (c) 2007-2010, sford, http://mbed.org |
wim | 13:24506ba22480 | 3 | * 2013, v01: WH, Added LCD types, fixed LCD address issues, added Cursor and UDCs |
wim | 15:b70ebfffb258 | 4 | * 2013, v02: WH, Added I2C and SPI bus interfaces |
wim | 15:b70ebfffb258 | 5 | * 2013, v03: WH, Added support for LCD40x4 which uses 2 controllers |
wim | 17:652ab113bc2e | 6 | * 2013, v04: WH, Added support for Display On/Off, improved 4bit bootprocess |
wim | 18:bd65dc10f27f | 7 | * 2013, v05: WH, Added support for 8x2B, added some UDCs |
wim | 19:c747b9e2e7b8 | 8 | * 2013, v06: WH, Added support for devices that use internal DC/DC converters |
wim | 20:e0da005a777f | 9 | * 2013, v07: WH, Added support for backlight and include portdefinitions for LCD2004 Module from DFROBOT |
wim | 21:9eb628d9e164 | 10 | * 2014, v08: WH, Refactored in Base and Derived Classes to deal with mbed lib change regarding 'NC' defined DigitalOut pins |
simon | 1:ac48b187213c | 11 | * |
simon | 1:ac48b187213c | 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
simon | 1:ac48b187213c | 13 | * of this software and associated documentation files (the "Software"), to deal |
simon | 1:ac48b187213c | 14 | * in the Software without restriction, including without limitation the rights |
simon | 1:ac48b187213c | 15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
simon | 1:ac48b187213c | 16 | * copies of the Software, and to permit persons to whom the Software is |
simon | 1:ac48b187213c | 17 | * furnished to do so, subject to the following conditions: |
simon | 2:227356c7d12c | 18 | * |
simon | 1:ac48b187213c | 19 | * The above copyright notice and this permission notice shall be included in |
simon | 1:ac48b187213c | 20 | * all copies or substantial portions of the Software. |
simon | 2:227356c7d12c | 21 | * |
simon | 1:ac48b187213c | 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
simon | 1:ac48b187213c | 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
simon | 1:ac48b187213c | 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
simon | 1:ac48b187213c | 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
simon | 1:ac48b187213c | 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
simon | 1:ac48b187213c | 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
simon | 1:ac48b187213c | 28 | * THE SOFTWARE. |
simon | 1:ac48b187213c | 29 | */ |
simon | 1:ac48b187213c | 30 | |
simon | 1:ac48b187213c | 31 | #ifndef MBED_TEXTLCD_H |
simon | 1:ac48b187213c | 32 | #define MBED_TEXTLCD_H |
simon | 1:ac48b187213c | 33 | |
simon | 1:ac48b187213c | 34 | #include "mbed.h" |
simon | 2:227356c7d12c | 35 | |
wim | 15:b70ebfffb258 | 36 | |
simon | 5:a53b3e2d6f1e | 37 | /** A TextLCD interface for driving 4-bit HD44780-based LCDs |
simon | 2:227356c7d12c | 38 | * |
wim | 16:c276b75e6585 | 39 | * Currently supports 8x1, 8x2, 12x4, 16x1, 16x2, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels |
wim | 22:35742ec80c24 | 40 | * Interface options include direct mbed pins, I2C portexpander (PCF8474, PCF8574A) or SPI bus shiftregister (74595) |
wim | 19:c747b9e2e7b8 | 41 | * Supports some controllers that provide internal DC/DC converters for VLCD or VLED. |
simon | 2:227356c7d12c | 42 | * |
simon | 2:227356c7d12c | 43 | * @code |
simon | 2:227356c7d12c | 44 | * #include "mbed.h" |
simon | 2:227356c7d12c | 45 | * #include "TextLCD.h" |
simon | 5:a53b3e2d6f1e | 46 | * |
wim | 16:c276b75e6585 | 47 | * // I2C Communication |
wim | 16:c276b75e6585 | 48 | * I2C i2c_lcd(p28,p27); // SDA, SCL |
wim | 16:c276b75e6585 | 49 | * |
wim | 16:c276b75e6585 | 50 | * // SPI Communication |
wim | 16:c276b75e6585 | 51 | * SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK |
wim | 16:c276b75e6585 | 52 | * |
wim | 22:35742ec80c24 | 53 | * //TextLCD lcd(p15, p16, p17, p18, p19, p20); // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780 |
wim | 22:35742ec80c24 | 54 | * //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type |
wim | 22:35742ec80c24 | 55 | * TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type |
wim | 21:9eb628d9e164 | 56 | * //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type |
simon | 5:a53b3e2d6f1e | 57 | * |
simon | 2:227356c7d12c | 58 | * int main() { |
wim | 16:c276b75e6585 | 59 | * lcd.printf("Hello World!\n"); |
simon | 2:227356c7d12c | 60 | * } |
simon | 2:227356c7d12c | 61 | * @endcode |
simon | 2:227356c7d12c | 62 | */ |
wim | 8:03116f75b66e | 63 | |
wim | 16:c276b75e6585 | 64 | //Pin Defines for I2C PCF8574 and SPI 74595 Bus interfaces |
wim | 13:24506ba22480 | 65 | //LCD and serial portexpanders should be wired accordingly |
wim | 20:e0da005a777f | 66 | // |
wim | 20:e0da005a777f | 67 | #if (1) |
wim | 20:e0da005a777f | 68 | //Definitions for hardware used by WH |
wim | 13:24506ba22480 | 69 | //Note: LCD RW pin must be connected to GND |
wim | 15:b70ebfffb258 | 70 | // E2 is used for LCD40x4 (second controller) |
wim | 13:24506ba22480 | 71 | // BL may be used for future expansion to control backlight |
wim | 15:b70ebfffb258 | 72 | #define D_LCD_PIN_D4 0 |
wim | 15:b70ebfffb258 | 73 | #define D_LCD_PIN_D5 1 |
wim | 15:b70ebfffb258 | 74 | #define D_LCD_PIN_D6 2 |
wim | 15:b70ebfffb258 | 75 | #define D_LCD_PIN_D7 3 |
wim | 15:b70ebfffb258 | 76 | #define D_LCD_PIN_RS 4 |
wim | 15:b70ebfffb258 | 77 | #define D_LCD_PIN_E 5 |
wim | 15:b70ebfffb258 | 78 | #define D_LCD_PIN_E2 6 |
wim | 15:b70ebfffb258 | 79 | #define D_LCD_PIN_BL 7 |
wim | 13:24506ba22480 | 80 | |
wim | 20:e0da005a777f | 81 | #define D_LCD_PIN_RW D_LCD_PIN_E2 |
wim | 20:e0da005a777f | 82 | |
wim | 20:e0da005a777f | 83 | #else |
wim | 20:e0da005a777f | 84 | |
wim | 20:e0da005a777f | 85 | //Definitions for LCD2004 Module from DFROBOT, See http://arduino-info.wikispaces.com/LCD-Blue-I2C |
wim | 20:e0da005a777f | 86 | //This hardware is different from earlier/different Arduino I2C LCD displays |
wim | 20:e0da005a777f | 87 | //Note: LCD RW pin must be kept LOW |
wim | 20:e0da005a777f | 88 | // E2 is not available on default Arduino hardware and does not support LCD40x4 (second controller) |
wim | 20:e0da005a777f | 89 | // BL is used to control backlight |
wim | 20:e0da005a777f | 90 | #define D_LCD_PIN_RS 0 |
wim | 20:e0da005a777f | 91 | #define D_LCD_PIN_RW 1 |
wim | 20:e0da005a777f | 92 | #define D_LCD_PIN_E 2 |
wim | 20:e0da005a777f | 93 | #define D_LCD_PIN_BL 3 |
wim | 20:e0da005a777f | 94 | #define D_LCD_PIN_D4 4 |
wim | 20:e0da005a777f | 95 | #define D_LCD_PIN_D5 5 |
wim | 20:e0da005a777f | 96 | #define D_LCD_PIN_D6 6 |
wim | 20:e0da005a777f | 97 | #define D_LCD_PIN_D7 7 |
wim | 20:e0da005a777f | 98 | |
wim | 20:e0da005a777f | 99 | #define D_LCD_PIN_E2 D_LCD_PIN_RW |
wim | 20:e0da005a777f | 100 | #endif |
wim | 13:24506ba22480 | 101 | |
wim | 13:24506ba22480 | 102 | //Bitpattern Defines for I2C PCF8574 and SPI 74595 Bus |
wim | 13:24506ba22480 | 103 | // |
wim | 13:24506ba22480 | 104 | #define D_LCD_D4 (1<<D_LCD_PIN_D4) |
wim | 13:24506ba22480 | 105 | #define D_LCD_D5 (1<<D_LCD_PIN_D5) |
wim | 13:24506ba22480 | 106 | #define D_LCD_D6 (1<<D_LCD_PIN_D6) |
wim | 13:24506ba22480 | 107 | #define D_LCD_D7 (1<<D_LCD_PIN_D7) |
wim | 13:24506ba22480 | 108 | #define D_LCD_RS (1<<D_LCD_PIN_RS) |
wim | 13:24506ba22480 | 109 | #define D_LCD_E (1<<D_LCD_PIN_E) |
wim | 13:24506ba22480 | 110 | #define D_LCD_E2 (1<<D_LCD_PIN_E2) |
wim | 13:24506ba22480 | 111 | #define D_LCD_BL (1<<D_LCD_PIN_BL) |
wim | 20:e0da005a777f | 112 | //#define D_LCD_RW (1<<D_LCD_PIN_RW) |
wim | 20:e0da005a777f | 113 | |
wim | 20:e0da005a777f | 114 | |
wim | 20:e0da005a777f | 115 | #define D_LCD_BUS_MSK (D_LCD_D4 | D_LCD_D5 | D_LCD_D6 | D_LCD_D7) |
wim | 20:e0da005a777f | 116 | #define D_LCD_BUS_DEF 0x00 |
wim | 13:24506ba22480 | 117 | |
wim | 13:24506ba22480 | 118 | |
wim | 13:24506ba22480 | 119 | /** Some sample User Defined Chars 5x7 dots */ |
wim | 11:9ec02df863a1 | 120 | const char udc_ae[] = {0x00, 0x00, 0x1B, 0x05, 0x1F, 0x14, 0x1F, 0x00}; //æ |
wim | 11:9ec02df863a1 | 121 | const char udc_0e[] = {0x00, 0x00, 0x0E, 0x13, 0x15, 0x19, 0x0E, 0x00}; //ø |
wim | 11:9ec02df863a1 | 122 | const char udc_ao[] = {0x0E, 0x0A, 0x0E, 0x01, 0x0F, 0x11, 0x0F, 0x00}; //Ã¥ |
wim | 11:9ec02df863a1 | 123 | const char udc_AE[] = {0x0F, 0x14, 0x14, 0x1F, 0x14, 0x14, 0x17, 0x00}; //Æ |
wim | 11:9ec02df863a1 | 124 | const char udc_0E[] = {0x0E, 0x13, 0x15, 0x15, 0x15, 0x19, 0x0E, 0x00}; //Ø |
wim | 18:bd65dc10f27f | 125 | const char udc_Ao[] = {0x0E, 0x0A, 0x0E, 0x11, 0x1F, 0x11, 0x11, 0x00}; //Ã… |
wim | 18:bd65dc10f27f | 126 | const char udc_PO[] = {0x04, 0x0A, 0x0A, 0x1F, 0x1B, 0x1B, 0x1F, 0x00}; //Padlock Open |
wim | 18:bd65dc10f27f | 127 | const char udc_PC[] = {0x1C, 0x10, 0x08, 0x1F, 0x1B, 0x1B, 0x1F, 0x00}; //Padlock Closed |
wim | 11:9ec02df863a1 | 128 | |
wim | 11:9ec02df863a1 | 129 | const char udc_0[] = {0x18, 0x14, 0x12, 0x11, 0x12, 0x14, 0x18, 0x00}; // |> |
wim | 11:9ec02df863a1 | 130 | const char udc_1[] = {0x03, 0x05, 0x09, 0x11, 0x09, 0x05, 0x03, 0x00}; // <| |
wim | 11:9ec02df863a1 | 131 | const char udc_2[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00}; // | |
wim | 11:9ec02df863a1 | 132 | const char udc_3[] = {0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00}; // || |
wim | 11:9ec02df863a1 | 133 | const char udc_4[] = {0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00}; // ||| |
wim | 11:9ec02df863a1 | 134 | const char udc_5[] = {0x00, 0x1f, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00}; // = |
wim | 11:9ec02df863a1 | 135 | const char udc_6[] = {0x15, 0x0a, 0x15, 0x0a, 0x15, 0x0a, 0x15, 0x00}; // checkerboard |
wim | 11:9ec02df863a1 | 136 | const char udc_7[] = {0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x10, 0x00}; // \ |
wim | 11:9ec02df863a1 | 137 | |
wim | 13:24506ba22480 | 138 | const char udc_degr[] = {0x06, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00}; // Degree symbol |
wim | 13:24506ba22480 | 139 | |
wim | 13:24506ba22480 | 140 | const char udc_TM_T[] = {0x1F, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; // Trademark T |
wim | 13:24506ba22480 | 141 | const char udc_TM_M[] = {0x11, 0x1B, 0x15, 0x11, 0x00, 0x00, 0x00, 0x00}; // Trademark M |
wim | 13:24506ba22480 | 142 | |
wim | 13:24506ba22480 | 143 | //const char udc_Bat_Hi[] = {0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Full |
wim | 13:24506ba22480 | 144 | //const char udc_Bat_Ha[] = {0x0E, 0x11, 0x13, 0x17, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Half |
wim | 13:24506ba22480 | 145 | //const char udc_Bat_Lo[] = {0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x00}; // Battery Low |
wim | 13:24506ba22480 | 146 | const char udc_Bat_Hi[] = {0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Full |
wim | 13:24506ba22480 | 147 | const char udc_Bat_Ha[] = {0x0E, 0x11, 0x11, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Half |
wim | 13:24506ba22480 | 148 | const char udc_Bat_Lo[] = {0x0E, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x1F, 0x00}; // Battery Low |
wim | 18:bd65dc10f27f | 149 | const char udc_AC[] = {0x0A, 0x0A, 0x1F, 0x11, 0x0E, 0x04, 0x04, 0x00}; // AC Power |
wim | 13:24506ba22480 | 150 | |
wim | 18:bd65dc10f27f | 151 | //const char udc_smiley[] = {0x00, 0x0A, 0x00, 0x04, 0x11, 0x0E, 0x00, 0x00}; // Smiley |
wim | 18:bd65dc10f27f | 152 | //const char udc_droopy[] = {0x00, 0x0A, 0x00, 0x04, 0x00, 0x0E, 0x11, 0x00}; // Droopey |
wim | 18:bd65dc10f27f | 153 | //const char udc_note[] = {0x01, 0x03, 0x05, 0x09, 0x0B, 0x1B, 0x18, 0x00}; // Note |
wim | 18:bd65dc10f27f | 154 | |
wim | 18:bd65dc10f27f | 155 | //const char udc_bar_1[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00}; // Bar 1 |
wim | 18:bd65dc10f27f | 156 | //const char udc_bar_2[] = {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00}; // Bar 11 |
wim | 18:bd65dc10f27f | 157 | //const char udc_bar_3[] = {0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x00}; // Bar 111 |
wim | 18:bd65dc10f27f | 158 | //const char udc_bar_4[] = {0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x00}; // Bar 1111 |
wim | 18:bd65dc10f27f | 159 | //const char udc_bar_5[] = {0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Bar 11111 |
wim | 13:24506ba22480 | 160 | |
wim | 11:9ec02df863a1 | 161 | |
wim | 11:9ec02df863a1 | 162 | /** A TextLCD interface for driving 4-bit HD44780-based LCDs |
wim | 11:9ec02df863a1 | 163 | * |
wim | 22:35742ec80c24 | 164 | * @brief Currently supports 8x1, 8x2, 12x2, 12x4, 16x1, 16x2, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels |
wim | 22:35742ec80c24 | 165 | * Interface options include direct mbed pins, I2C portexpander (PCF8474, PCF8574A) or SPI bus shiftregister (74595) |
wim | 11:9ec02df863a1 | 166 | * |
wim | 11:9ec02df863a1 | 167 | */ |
wim | 21:9eb628d9e164 | 168 | class TextLCD_Base : public Stream { |
simon | 1:ac48b187213c | 169 | public: |
simon | 1:ac48b187213c | 170 | |
simon | 2:227356c7d12c | 171 | /** LCD panel format */ |
simon | 1:ac48b187213c | 172 | enum LCDType { |
wim | 8:03116f75b66e | 173 | LCD8x1, /**< 8x1 LCD panel */ |
wim | 13:24506ba22480 | 174 | LCD8x2, /**< 8x2 LCD panel */ |
wim | 18:bd65dc10f27f | 175 | LCD8x2B, /**< 8x2 LCD panel (actually 16x1) */ |
wim | 15:b70ebfffb258 | 176 | LCD12x2, /**< 12x2 LCD panel */ |
wim | 15:b70ebfffb258 | 177 | LCD12x4, /**< 12x4 LCD panel */ |
wim | 13:24506ba22480 | 178 | LCD16x1, /**< 16x1 LCD panel (actually 8x2) */ |
wim | 8:03116f75b66e | 179 | LCD16x2, /**< 16x2 LCD panel (default) */ |
wim | 8:03116f75b66e | 180 | LCD16x2B, /**< 16x2 LCD panel alternate addressing */ |
wim | 8:03116f75b66e | 181 | LCD16x4, /**< 16x4 LCD panel */ |
wim | 8:03116f75b66e | 182 | LCD20x2, /**< 20x2 LCD panel */ |
wim | 8:03116f75b66e | 183 | LCD20x4, /**< 20x4 LCD panel */ |
wim | 9:0893d986e717 | 184 | LCD24x2, /**< 24x2 LCD panel */ |
wim | 10:dd9b3a696acd | 185 | LCD24x4, /**< 24x4 LCD panel, special mode KS0078 */ |
wim | 15:b70ebfffb258 | 186 | LCD40x2, /**< 40x2 LCD panel */ |
wim | 15:b70ebfffb258 | 187 | LCD40x4 /**< 40x4 LCD panel, Two controller version */ |
simon | 1:ac48b187213c | 188 | }; |
simon | 1:ac48b187213c | 189 | |
wim | 19:c747b9e2e7b8 | 190 | /** LCD Controller Device */ |
wim | 19:c747b9e2e7b8 | 191 | enum LCDCtrl { |
wim | 19:c747b9e2e7b8 | 192 | HD44780, /**< HD44780 (default) */ |
wim | 19:c747b9e2e7b8 | 193 | WS0010, /**< WS0010 OLED Controller */ |
Sissors | 24:fb3399713710 | 194 | ST7036, /**< ST7036 */ |
Sissors | 24:fb3399713710 | 195 | ST7032 /**< ST7032 */ |
wim | 19:c747b9e2e7b8 | 196 | }; |
wim | 19:c747b9e2e7b8 | 197 | |
wim | 19:c747b9e2e7b8 | 198 | |
wim | 10:dd9b3a696acd | 199 | /** LCD Cursor control */ |
wim | 10:dd9b3a696acd | 200 | enum LCDCursor { |
wim | 17:652ab113bc2e | 201 | CurOff_BlkOff = 0x00, /**< Cursor Off, Blinking Char Off */ |
wim | 17:652ab113bc2e | 202 | CurOn_BlkOff = 0x02, /**< Cursor On, Blinking Char Off */ |
wim | 17:652ab113bc2e | 203 | CurOff_BlkOn = 0x01, /**< Cursor Off, Blinking Char On */ |
wim | 17:652ab113bc2e | 204 | CurOn_BlkOn = 0x03 /**< Cursor On, Blinking Char On */ |
wim | 17:652ab113bc2e | 205 | }; |
wim | 17:652ab113bc2e | 206 | |
wim | 17:652ab113bc2e | 207 | |
wim | 17:652ab113bc2e | 208 | /** LCD Display control */ |
wim | 17:652ab113bc2e | 209 | enum LCDMode { |
wim | 17:652ab113bc2e | 210 | DispOff = 0x00, /**< Display Off */ |
wim | 17:652ab113bc2e | 211 | DispOn = 0x04 /**< Display On */ |
wim | 10:dd9b3a696acd | 212 | }; |
wim | 10:dd9b3a696acd | 213 | |
wim | 20:e0da005a777f | 214 | /** LCD Backlight control */ |
wim | 20:e0da005a777f | 215 | enum LCDBacklight { |
wim | 20:e0da005a777f | 216 | LightOff, /**< Backlight Off */ |
wim | 20:e0da005a777f | 217 | LightOn /**< Backlight On */ |
wim | 20:e0da005a777f | 218 | }; |
wim | 10:dd9b3a696acd | 219 | |
simon | 2:227356c7d12c | 220 | |
simon | 2:227356c7d12c | 221 | #if DOXYGEN_ONLY |
simon | 2:227356c7d12c | 222 | /** Write a character to the LCD |
simon | 2:227356c7d12c | 223 | * |
simon | 2:227356c7d12c | 224 | * @param c The character to write to the display |
simon | 2:227356c7d12c | 225 | */ |
simon | 2:227356c7d12c | 226 | int putc(int c); |
simon | 2:227356c7d12c | 227 | |
simon | 2:227356c7d12c | 228 | /** Write a formated string to the LCD |
simon | 2:227356c7d12c | 229 | * |
simon | 2:227356c7d12c | 230 | * @param format A printf-style format string, followed by the |
simon | 2:227356c7d12c | 231 | * variables to use in formating the string. |
simon | 2:227356c7d12c | 232 | */ |
simon | 2:227356c7d12c | 233 | int printf(const char* format, ...); |
simon | 2:227356c7d12c | 234 | #endif |
simon | 2:227356c7d12c | 235 | |
simon | 2:227356c7d12c | 236 | /** Locate to a screen column and row |
simon | 2:227356c7d12c | 237 | * |
simon | 2:227356c7d12c | 238 | * @param column The horizontal position from the left, indexed from 0 |
simon | 2:227356c7d12c | 239 | * @param row The vertical position from the top, indexed from 0 |
simon | 2:227356c7d12c | 240 | */ |
simon | 1:ac48b187213c | 241 | void locate(int column, int row); |
simon | 2:227356c7d12c | 242 | |
wim | 10:dd9b3a696acd | 243 | |
wim | 10:dd9b3a696acd | 244 | /** Return the memoryaddress of screen column and row location |
wim | 10:dd9b3a696acd | 245 | * |
wim | 10:dd9b3a696acd | 246 | * @param column The horizontal position from the left, indexed from 0 |
wim | 10:dd9b3a696acd | 247 | * @param row The vertical position from the top, indexed from 0 |
wim | 10:dd9b3a696acd | 248 | * @param return The memoryaddress of screen column and row location |
wim | 10:dd9b3a696acd | 249 | */ |
wim | 9:0893d986e717 | 250 | int getAddress(int column, int row); |
wim | 10:dd9b3a696acd | 251 | |
wim | 10:dd9b3a696acd | 252 | |
wim | 10:dd9b3a696acd | 253 | /** Set the memoryaddress of screen column and row location |
wim | 10:dd9b3a696acd | 254 | * |
wim | 10:dd9b3a696acd | 255 | * @param column The horizontal position from the left, indexed from 0 |
wim | 10:dd9b3a696acd | 256 | * @param row The vertical position from the top, indexed from 0 |
wim | 10:dd9b3a696acd | 257 | */ |
wim | 9:0893d986e717 | 258 | void setAddress(int column, int row); |
wim | 9:0893d986e717 | 259 | |
wim | 10:dd9b3a696acd | 260 | |
wim | 22:35742ec80c24 | 261 | /** Clear the screen and locate to 0,0 |
wim | 22:35742ec80c24 | 262 | */ |
simon | 1:ac48b187213c | 263 | void cls(); |
simon | 2:227356c7d12c | 264 | |
wim | 10:dd9b3a696acd | 265 | /** Return the number of rows |
wim | 10:dd9b3a696acd | 266 | * |
wim | 10:dd9b3a696acd | 267 | * @param return The number of rows |
wim | 10:dd9b3a696acd | 268 | */ |
simon | 1:ac48b187213c | 269 | int rows(); |
wim | 10:dd9b3a696acd | 270 | |
wim | 10:dd9b3a696acd | 271 | /** Return the number of columns |
wim | 10:dd9b3a696acd | 272 | * |
wim | 10:dd9b3a696acd | 273 | * @param return The number of columns |
wim | 10:dd9b3a696acd | 274 | */ |
wim | 10:dd9b3a696acd | 275 | int columns(); |
simon | 2:227356c7d12c | 276 | |
wim | 11:9ec02df863a1 | 277 | /** Set the Cursormode |
wim | 11:9ec02df863a1 | 278 | * |
wim | 17:652ab113bc2e | 279 | * @param cursorMode The Cursor mode (CurOff_BlkOff, CurOn_BlkOff, CurOff_BlkOn, CurOn_BlkOn) |
wim | 11:9ec02df863a1 | 280 | */ |
wim | 17:652ab113bc2e | 281 | void setCursor(LCDCursor cursorMode); |
wim | 17:652ab113bc2e | 282 | |
wim | 17:652ab113bc2e | 283 | |
wim | 17:652ab113bc2e | 284 | /** Set the Displaymode |
wim | 17:652ab113bc2e | 285 | * |
wim | 17:652ab113bc2e | 286 | * @param displayMode The Display mode (DispOff, DispOn) |
wim | 17:652ab113bc2e | 287 | */ |
wim | 21:9eb628d9e164 | 288 | void setMode(LCDMode displayMode); |
wim | 11:9ec02df863a1 | 289 | |
wim | 20:e0da005a777f | 290 | /** Set the Backlight mode |
wim | 20:e0da005a777f | 291 | * |
wim | 21:9eb628d9e164 | 292 | * @param backlightMode The Backlight mode (LightOff, LightOn) |
wim | 20:e0da005a777f | 293 | */ |
wim | 21:9eb628d9e164 | 294 | void setBacklight(LCDBacklight backlightMode); |
wim | 20:e0da005a777f | 295 | |
wim | 11:9ec02df863a1 | 296 | |
wim | 11:9ec02df863a1 | 297 | /** Set User Defined Characters |
wim | 11:9ec02df863a1 | 298 | * |
wim | 11:9ec02df863a1 | 299 | * @param unsigned char c The Index of the UDC (0..7) |
wim | 12:6bf9d9957d31 | 300 | * @param char *udc_data The bitpatterns for the UDC (8 bytes of 5 significant bits) |
wim | 11:9ec02df863a1 | 301 | */ |
wim | 11:9ec02df863a1 | 302 | void setUDC(unsigned char c, char *udc_data); |
wim | 11:9ec02df863a1 | 303 | |
wim | 20:e0da005a777f | 304 | |
simon | 1:ac48b187213c | 305 | protected: |
wim | 13:24506ba22480 | 306 | |
wim | 21:9eb628d9e164 | 307 | /** LCD controller select, mainly used for LCD40x4 |
wim | 21:9eb628d9e164 | 308 | */ |
wim | 19:c747b9e2e7b8 | 309 | enum _LCDCtrl_Idx { |
wim | 15:b70ebfffb258 | 310 | _LCDCtrl_0, /*< Primary */ |
wim | 15:b70ebfffb258 | 311 | _LCDCtrl_1, /*< Secondary */ |
wim | 15:b70ebfffb258 | 312 | }; |
wim | 21:9eb628d9e164 | 313 | |
wim | 21:9eb628d9e164 | 314 | /** Create a TextLCD_Base interface |
wim | 21:9eb628d9e164 | 315 | * @brief Base class, can not be instantiated |
wim | 21:9eb628d9e164 | 316 | * |
wim | 21:9eb628d9e164 | 317 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wim | 21:9eb628d9e164 | 318 | * @param ctrl LCD controller (default = HD44780) |
wim | 21:9eb628d9e164 | 319 | */ |
wim | 21:9eb628d9e164 | 320 | TextLCD_Base(LCDType type = LCD16x2, LCDCtrl ctrl = HD44780); |
wim | 21:9eb628d9e164 | 321 | |
wim | 15:b70ebfffb258 | 322 | |
simon | 1:ac48b187213c | 323 | // Stream implementation functions |
simon | 1:ac48b187213c | 324 | virtual int _putc(int value); |
simon | 1:ac48b187213c | 325 | virtual int _getc(); |
simon | 1:ac48b187213c | 326 | |
wim | 21:9eb628d9e164 | 327 | /** Low level methods for LCD controller |
wim | 21:9eb628d9e164 | 328 | */ |
wim | 13:24506ba22480 | 329 | void _init(); |
wim | 15:b70ebfffb258 | 330 | void _initCtrl(); |
wim | 13:24506ba22480 | 331 | int _address(int column, int row); |
wim | 21:9eb628d9e164 | 332 | void _setCursor(LCDCursor show); |
wim | 17:652ab113bc2e | 333 | void _setUDC(unsigned char c, char *udc_data); |
wim | 21:9eb628d9e164 | 334 | void _setCursorAndDisplayMode(LCDMode displayMode, LCDCursor cursorType); |
wim | 13:24506ba22480 | 335 | |
wim | 21:9eb628d9e164 | 336 | /** Low level write operations to LCD controller |
wim | 21:9eb628d9e164 | 337 | */ |
wim | 17:652ab113bc2e | 338 | void _writeNibble(int value); |
Sissors | 24:fb3399713710 | 339 | virtual void _writeByte(int value); |
wim | 15:b70ebfffb258 | 340 | void _writeCommand(int command); |
wim | 15:b70ebfffb258 | 341 | void _writeData(int data); |
wim | 15:b70ebfffb258 | 342 | |
wim | 21:9eb628d9e164 | 343 | /** Pure Virtual Low level writes to LCD Bus (serial or parallel) |
wim | 21:9eb628d9e164 | 344 | */ |
wim | 21:9eb628d9e164 | 345 | virtual void _setEnable(bool value) = 0; |
wim | 21:9eb628d9e164 | 346 | virtual void _setRS(bool value) = 0; |
wim | 21:9eb628d9e164 | 347 | virtual void _setBL(bool value) = 0; |
wim | 21:9eb628d9e164 | 348 | virtual void _setData(int value) = 0; |
wim | 13:24506ba22480 | 349 | |
wim | 13:24506ba22480 | 350 | |
wim | 13:24506ba22480 | 351 | //Display type |
simon | 1:ac48b187213c | 352 | LCDType _type; |
simon | 1:ac48b187213c | 353 | |
wim | 21:9eb628d9e164 | 354 | //Display mode |
wim | 17:652ab113bc2e | 355 | LCDMode _currentMode; |
wim | 17:652ab113bc2e | 356 | |
wim | 19:c747b9e2e7b8 | 357 | //Controller type |
wim | 19:c747b9e2e7b8 | 358 | LCDCtrl _ctrl; |
wim | 19:c747b9e2e7b8 | 359 | |
wim | 15:b70ebfffb258 | 360 | //Controller select, mainly used for LCD40x4 |
wim | 19:c747b9e2e7b8 | 361 | _LCDCtrl_Idx _ctrl_idx; |
wim | 15:b70ebfffb258 | 362 | |
wim | 13:24506ba22480 | 363 | // Cursor |
simon | 1:ac48b187213c | 364 | int _column; |
simon | 1:ac48b187213c | 365 | int _row; |
wim | 15:b70ebfffb258 | 366 | LCDCursor _currentCursor; |
simon | 1:ac48b187213c | 367 | }; |
simon | 1:ac48b187213c | 368 | |
wim | 23:d47f226efb24 | 369 | //--------- End TextLCD_Base ----------- |
wim | 22:35742ec80c24 | 370 | |
wim | 22:35742ec80c24 | 371 | |
wim | 22:35742ec80c24 | 372 | |
wim | 23:d47f226efb24 | 373 | //--------- Start TextLCD Bus ----------- |
wim | 21:9eb628d9e164 | 374 | |
wim | 21:9eb628d9e164 | 375 | /** Create a TextLCD interface for using regular mbed pins |
wim | 21:9eb628d9e164 | 376 | * |
wim | 21:9eb628d9e164 | 377 | */ |
wim | 21:9eb628d9e164 | 378 | class TextLCD : public TextLCD_Base { |
wim | 21:9eb628d9e164 | 379 | public: |
wim | 21:9eb628d9e164 | 380 | /** Create a TextLCD interface for using regular mbed pins |
wim | 21:9eb628d9e164 | 381 | * |
wim | 21:9eb628d9e164 | 382 | * @param rs Instruction/data control line |
wim | 21:9eb628d9e164 | 383 | * @param e Enable line (clock) |
wim | 21:9eb628d9e164 | 384 | * @param d4-d7 Data lines for using as a 4-bit interface |
wim | 21:9eb628d9e164 | 385 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wim | 21:9eb628d9e164 | 386 | * @param bl Backlight control line (optional, default = NC) |
wim | 21:9eb628d9e164 | 387 | * @param e2 Enable2 line (clock for second controller, LCD40x4 only) |
wim | 21:9eb628d9e164 | 388 | * @param ctrl LCD controller (default = HD44780) |
wim | 21:9eb628d9e164 | 389 | */ |
wim | 21:9eb628d9e164 | 390 | 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 | 391 | |
wim | 22:35742ec80c24 | 392 | |
wim | 22:35742ec80c24 | 393 | /** Destruct a TextLCD interface for using regular mbed pins |
wim | 22:35742ec80c24 | 394 | * |
wim | 22:35742ec80c24 | 395 | * @param none |
wim | 22:35742ec80c24 | 396 | * @return none |
wim | 22:35742ec80c24 | 397 | */ |
wim | 22:35742ec80c24 | 398 | virtual ~TextLCD(); |
wim | 22:35742ec80c24 | 399 | |
wim | 21:9eb628d9e164 | 400 | private: |
wim | 21:9eb628d9e164 | 401 | //Low level writes to LCD Bus (serial or parallel) |
wim | 21:9eb628d9e164 | 402 | virtual void _setEnable(bool value); |
wim | 21:9eb628d9e164 | 403 | virtual void _setRS(bool value); |
wim | 21:9eb628d9e164 | 404 | virtual void _setBL(bool value); |
wim | 21:9eb628d9e164 | 405 | virtual void _setData(int value); |
wim | 21:9eb628d9e164 | 406 | |
wim | 22:35742ec80c24 | 407 | /** Regular mbed pins bus |
wim | 22:35742ec80c24 | 408 | */ |
wim | 22:35742ec80c24 | 409 | DigitalOut _rs, _e; |
wim | 22:35742ec80c24 | 410 | BusOut _d; |
wim | 22:35742ec80c24 | 411 | |
wim | 22:35742ec80c24 | 412 | /** Optional Hardware pins for the Backlight and LCD40x4 device |
wim | 22:35742ec80c24 | 413 | * Default PinName value is NC, must be used as pointer to avoid issues with mbed lib and DigitalOut pins |
wim | 22:35742ec80c24 | 414 | */ |
wim | 22:35742ec80c24 | 415 | DigitalOut *_bl, *_e2; |
wim | 21:9eb628d9e164 | 416 | }; |
wim | 21:9eb628d9e164 | 417 | |
wim | 22:35742ec80c24 | 418 | |
wim | 23:d47f226efb24 | 419 | //----------- End TextLCD --------------- |
wim | 21:9eb628d9e164 | 420 | |
wim | 21:9eb628d9e164 | 421 | |
wim | 23:d47f226efb24 | 422 | //--------- Start TextLCD_I2C ----------- |
wim | 22:35742ec80c24 | 423 | |
wim | 22:35742ec80c24 | 424 | |
wim | 22:35742ec80c24 | 425 | /** Create a TextLCD interface using an I2C PC8574 or PCF8574A portexpander |
wim | 21:9eb628d9e164 | 426 | * |
wim | 21:9eb628d9e164 | 427 | */ |
wim | 21:9eb628d9e164 | 428 | class TextLCD_I2C : public TextLCD_Base { |
wim | 21:9eb628d9e164 | 429 | public: |
wim | 22:35742ec80c24 | 430 | /** Create a TextLCD interface using an I2C PC8574 or PCF8574A portexpander |
wim | 21:9eb628d9e164 | 431 | * |
wim | 21:9eb628d9e164 | 432 | * @param i2c I2C Bus |
wim | 22:35742ec80c24 | 433 | * @param deviceAddress I2C slave address (PCF8574 or PCF8574A, default = 0x40) |
wim | 21:9eb628d9e164 | 434 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wim | 21:9eb628d9e164 | 435 | * @param ctrl LCD controller (default = HD44780) |
wim | 21:9eb628d9e164 | 436 | */ |
wim | 22:35742ec80c24 | 437 | TextLCD_I2C(I2C *i2c, char deviceAddress = 0x40, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780); |
wim | 21:9eb628d9e164 | 438 | |
wim | 21:9eb628d9e164 | 439 | private: |
wim | 21:9eb628d9e164 | 440 | //Low level writes to LCD Bus (serial or parallel) |
wim | 21:9eb628d9e164 | 441 | virtual void _setEnable(bool value); |
wim | 21:9eb628d9e164 | 442 | virtual void _setRS(bool value); |
wim | 21:9eb628d9e164 | 443 | virtual void _setBL(bool value); |
wim | 21:9eb628d9e164 | 444 | virtual void _setData(int value); |
wim | 21:9eb628d9e164 | 445 | |
wim | 21:9eb628d9e164 | 446 | //I2C bus |
wim | 21:9eb628d9e164 | 447 | I2C *_i2c; |
wim | 21:9eb628d9e164 | 448 | char _slaveAddress; |
wim | 21:9eb628d9e164 | 449 | |
wim | 21:9eb628d9e164 | 450 | // Internal bus mirror value for serial bus only |
wim | 21:9eb628d9e164 | 451 | char _lcd_bus; |
wim | 21:9eb628d9e164 | 452 | |
wim | 21:9eb628d9e164 | 453 | }; |
wim | 21:9eb628d9e164 | 454 | |
wim | 21:9eb628d9e164 | 455 | |
wim | 23:d47f226efb24 | 456 | //---------- End TextLCD_I2C ------------ |
wim | 22:35742ec80c24 | 457 | |
wim | 22:35742ec80c24 | 458 | |
wim | 22:35742ec80c24 | 459 | |
wim | 23:d47f226efb24 | 460 | //--------- Start TextLCD_SPI ----------- |
wim | 22:35742ec80c24 | 461 | |
wim | 21:9eb628d9e164 | 462 | |
wim | 21:9eb628d9e164 | 463 | /** Create a TextLCD interface using an SPI 74595 portexpander |
wim | 21:9eb628d9e164 | 464 | * |
wim | 21:9eb628d9e164 | 465 | */ |
wim | 21:9eb628d9e164 | 466 | class TextLCD_SPI : public TextLCD_Base { |
wim | 21:9eb628d9e164 | 467 | public: |
wim | 21:9eb628d9e164 | 468 | /** Create a TextLCD interface using an SPI 74595 portexpander |
wim | 21:9eb628d9e164 | 469 | * |
wim | 21:9eb628d9e164 | 470 | * @param spi SPI Bus |
wim | 21:9eb628d9e164 | 471 | * @param cs chip select pin (active low) |
wim | 21:9eb628d9e164 | 472 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wim | 21:9eb628d9e164 | 473 | * @param ctrl LCD controller (default = HD44780) |
wim | 21:9eb628d9e164 | 474 | */ |
wim | 21:9eb628d9e164 | 475 | TextLCD_SPI(SPI *spi, PinName cs, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780); |
wim | 21:9eb628d9e164 | 476 | |
wim | 21:9eb628d9e164 | 477 | |
wim | 21:9eb628d9e164 | 478 | private: |
wim | 21:9eb628d9e164 | 479 | //Low level writes to LCD Bus (serial or parallel) |
wim | 21:9eb628d9e164 | 480 | virtual void _setEnable(bool value); |
wim | 21:9eb628d9e164 | 481 | virtual void _setRS(bool value); |
wim | 21:9eb628d9e164 | 482 | virtual void _setBL(bool value); |
wim | 21:9eb628d9e164 | 483 | virtual void _setData(int value); |
wim | 21:9eb628d9e164 | 484 | virtual void _setCS(bool value); |
wim | 21:9eb628d9e164 | 485 | |
wim | 21:9eb628d9e164 | 486 | //Low level writes to LCD serial bus only |
wim | 21:9eb628d9e164 | 487 | void _writeBus(); |
wim | 21:9eb628d9e164 | 488 | |
wim | 21:9eb628d9e164 | 489 | // SPI bus |
wim | 21:9eb628d9e164 | 490 | SPI *_spi; |
wim | 21:9eb628d9e164 | 491 | DigitalOut _cs; |
wim | 21:9eb628d9e164 | 492 | |
wim | 21:9eb628d9e164 | 493 | // Internal bus mirror value for serial bus only |
wim | 21:9eb628d9e164 | 494 | char _lcd_bus; |
wim | 21:9eb628d9e164 | 495 | |
wim | 21:9eb628d9e164 | 496 | }; |
wim | 21:9eb628d9e164 | 497 | |
wim | 23:d47f226efb24 | 498 | //---------- End TextLCD_SPI ------------ |
wim | 21:9eb628d9e164 | 499 | |
Sissors | 24:fb3399713710 | 500 | |
Sissors | 24:fb3399713710 | 501 | //--------- Start TextLCD_NativeSPI ----------- |
Sissors | 24:fb3399713710 | 502 | |
Sissors | 24:fb3399713710 | 503 | |
Sissors | 24:fb3399713710 | 504 | /** Create a TextLCD interface with direct SPI access to the controller |
Sissors | 24:fb3399713710 | 505 | * |
Sissors | 24:fb3399713710 | 506 | */ |
Sissors | 24:fb3399713710 | 507 | class TextLCD_NativeSPI : public TextLCD_Base { |
Sissors | 24:fb3399713710 | 508 | public: |
Sissors | 24:fb3399713710 | 509 | /** Create a TextLCD interface using an SPI 74595 portexpander |
Sissors | 24:fb3399713710 | 510 | * |
Sissors | 24:fb3399713710 | 511 | * @param spi SPI Bus |
Sissors | 24:fb3399713710 | 512 | * @param cs chip select pin (active low) |
Sissors | 24:fb3399713710 | 513 | * @param rs Instruction/data control line |
Sissors | 24:fb3399713710 | 514 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
Sissors | 24:fb3399713710 | 515 | * @param bl Backlight control line (optional, default = NC) |
Sissors | 24:fb3399713710 | 516 | * @param ctrl LCD controller (default = ST7032) |
Sissors | 24:fb3399713710 | 517 | */ |
Sissors | 24:fb3399713710 | 518 | TextLCD_NativeSPI(SPI *spi, PinName cs, PinName rs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7032); |
Sissors | 24:fb3399713710 | 519 | virtual ~TextLCD_NativeSPI(void); |
Sissors | 24:fb3399713710 | 520 | |
Sissors | 24:fb3399713710 | 521 | private: |
Sissors | 24:fb3399713710 | 522 | virtual void _setEnable(bool value); |
Sissors | 24:fb3399713710 | 523 | virtual void _setRS(bool value); |
Sissors | 24:fb3399713710 | 524 | virtual void _setBL(bool value); |
Sissors | 24:fb3399713710 | 525 | virtual void _setData(int value); |
Sissors | 24:fb3399713710 | 526 | virtual void _writeByte(int value); |
Sissors | 24:fb3399713710 | 527 | |
Sissors | 24:fb3399713710 | 528 | // SPI bus |
Sissors | 24:fb3399713710 | 529 | SPI *_spi; |
Sissors | 24:fb3399713710 | 530 | DigitalOut _cs; |
Sissors | 24:fb3399713710 | 531 | DigitalOut _rs; |
Sissors | 24:fb3399713710 | 532 | DigitalOut *_bl; |
Sissors | 24:fb3399713710 | 533 | |
Sissors | 24:fb3399713710 | 534 | }; |
Sissors | 24:fb3399713710 | 535 | |
Sissors | 24:fb3399713710 | 536 | //---------- End TextLCD_NativeSPI ------------ |
Sissors | 24:fb3399713710 | 537 | |
simon | 1:ac48b187213c | 538 | #endif |