vmh
Dependencies: mbed
TextLCD/TextLCD.h@1:b4814760d8ee, 2017-12-11 (annotated)
- Committer:
- firstspk
- Date:
- Mon Dec 11 20:25:27 2017 +0000
- Revision:
- 1:b4814760d8ee
- Parent:
- 0:4562b55bbb43
test;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wonner163 | 0:4562b55bbb43 | 1 | /* mbed TextLCD Library, for a 4-bit LCD based on HD44780 |
wonner163 | 0:4562b55bbb43 | 2 | * Copyright (c) 2007-2010, sford, http://mbed.org |
wonner163 | 0:4562b55bbb43 | 3 | * 2013, v01: WH, Added LCD types, fixed LCD address issues, added Cursor and UDCs |
wonner163 | 0:4562b55bbb43 | 4 | * 2013, v02: WH, Added I2C and SPI bus interfaces |
wonner163 | 0:4562b55bbb43 | 5 | * 2013, v03: WH, Added support for LCD40x4 which uses 2 controllers |
wonner163 | 0:4562b55bbb43 | 6 | * 2013, v04: WH, Added support for Display On/Off, improved 4bit bootprocess |
wonner163 | 0:4562b55bbb43 | 7 | * 2013, v05: WH, Added support for 8x2B, added some UDCs |
wonner163 | 0:4562b55bbb43 | 8 | * 2013, v06: WH, Added support for devices that use internal DC/DC converters |
wonner163 | 0:4562b55bbb43 | 9 | * 2013, v07: WH, Added support for backlight and include portdefinitions for LCD2004 Module from DFROBOT |
wonner163 | 0:4562b55bbb43 | 10 | * 2014, v08: WH, Refactored in Base and Derived Classes to deal with mbed lib change regarding 'NC' defined DigitalOut pins |
wonner163 | 0:4562b55bbb43 | 11 | * 2014, v09: WH/EO, Added Class for Native SPI controllers such as ST7032 |
wonner163 | 0:4562b55bbb43 | 12 | * 2014, v10: WH, Added Class for Native I2C controllers such as ST7032i, Added support for MCP23008 I2C portexpander, Added support for Adafruit module |
wonner163 | 0:4562b55bbb43 | 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 |
wonner163 | 0:4562b55bbb43 | 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) |
wonner163 | 0:4562b55bbb43 | 15 | * 2014, v13: WH, Added support for controllers US2066/SSD1311 (OLED), added setUDCBlink method for supported devices (eg SSD1803), fixed issue in setPower() |
wonner163 | 0:4562b55bbb43 | 16 | *@Todo Add AC780S/KS0066i |
wonner163 | 0:4562b55bbb43 | 17 | * |
wonner163 | 0:4562b55bbb43 | 18 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wonner163 | 0:4562b55bbb43 | 19 | * of this software and associated documentation files (the "Software"), to deal |
wonner163 | 0:4562b55bbb43 | 20 | * in the Software without restriction, including without limitation the rights |
wonner163 | 0:4562b55bbb43 | 21 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wonner163 | 0:4562b55bbb43 | 22 | * copies of the Software, and to permit persons to whom the Software is |
wonner163 | 0:4562b55bbb43 | 23 | * furnished to do so, subject to the following conditions: |
wonner163 | 0:4562b55bbb43 | 24 | * |
wonner163 | 0:4562b55bbb43 | 25 | * The above copyright notice and this permission notice shall be included in |
wonner163 | 0:4562b55bbb43 | 26 | * all copies or substantial portions of the Software. |
wonner163 | 0:4562b55bbb43 | 27 | * |
wonner163 | 0:4562b55bbb43 | 28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wonner163 | 0:4562b55bbb43 | 29 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wonner163 | 0:4562b55bbb43 | 30 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wonner163 | 0:4562b55bbb43 | 31 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wonner163 | 0:4562b55bbb43 | 32 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wonner163 | 0:4562b55bbb43 | 33 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wonner163 | 0:4562b55bbb43 | 34 | * THE SOFTWARE. |
wonner163 | 0:4562b55bbb43 | 35 | */ |
wonner163 | 0:4562b55bbb43 | 36 | |
wonner163 | 0:4562b55bbb43 | 37 | #ifndef MBED_TEXTLCD_H |
wonner163 | 0:4562b55bbb43 | 38 | #define MBED_TEXTLCD_H |
wonner163 | 0:4562b55bbb43 | 39 | |
wonner163 | 0:4562b55bbb43 | 40 | #include "mbed.h" |
wonner163 | 0:4562b55bbb43 | 41 | |
wonner163 | 0:4562b55bbb43 | 42 | /** A TextLCD interface for driving 4-bit HD44780-based LCDs |
wonner163 | 0:4562b55bbb43 | 43 | * |
wonner163 | 0:4562b55bbb43 | 44 | * Currently supports 8x1, 8x2, 12x3, 12x4, 16x1, 16x2, 16x3, 16x4, 20x2, 20x4, 24x1, 24x2, 24x4, 40x2 and 40x4 panels |
wonner163 | 0:4562b55bbb43 | 45 | * Interface options include direct mbed pins, I2C portexpander (PCF8474/PCF8574A or MCP23008) or SPI bus shiftregister (74595). |
wonner163 | 0:4562b55bbb43 | 46 | * Supports some controllers with native I2C or SP interface. Supports some controllers that provide internal DC/DC converters for VLCD or VLED. |
wonner163 | 0:4562b55bbb43 | 47 | * |
wonner163 | 0:4562b55bbb43 | 48 | * @code |
wonner163 | 0:4562b55bbb43 | 49 | * #include "mbed.h" |
wonner163 | 0:4562b55bbb43 | 50 | * #include "TextLCD.h" |
wonner163 | 0:4562b55bbb43 | 51 | * |
wonner163 | 0:4562b55bbb43 | 52 | * // I2C Communication |
wonner163 | 0:4562b55bbb43 | 53 | * I2C i2c_lcd(p28,p27); // SDA, SCL |
wonner163 | 0:4562b55bbb43 | 54 | * |
wonner163 | 0:4562b55bbb43 | 55 | * // SPI Communication |
wonner163 | 0:4562b55bbb43 | 56 | * SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK |
wonner163 | 0:4562b55bbb43 | 57 | * |
wonner163 | 0:4562b55bbb43 | 58 | * //TextLCD lcd(p15, p16, p17, p18, p19, p20); // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780 |
wonner163 | 0:4562b55bbb43 | 59 | * //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, 74595 expander, CS pin, LCD Type |
wonner163 | 0:4562b55bbb43 | 60 | * TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type |
wonner163 | 0:4562b55bbb43 | 61 | * //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type |
wonner163 | 0:4562b55bbb43 | 62 | * //TextLCD_SPI_N lcd(&spi_lcd, p8, p9); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3 |
wonner163 | 0:4562b55bbb43 | 63 | * //TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=ST7032_3V3 |
wonner163 | 0:4562b55bbb43 | 64 | * |
wonner163 | 0:4562b55bbb43 | 65 | * int main() { |
wonner163 | 0:4562b55bbb43 | 66 | * lcd.printf("Hello World!\n"); |
wonner163 | 0:4562b55bbb43 | 67 | * } |
wonner163 | 0:4562b55bbb43 | 68 | * @endcode |
wonner163 | 0:4562b55bbb43 | 69 | */ |
wonner163 | 0:4562b55bbb43 | 70 | |
wonner163 | 0:4562b55bbb43 | 71 | |
wonner163 | 0:4562b55bbb43 | 72 | //Pin Defines for I2C PCF8574/PCF8574A or MCP23008 and SPI 74595 bus expander interfaces |
wonner163 | 0:4562b55bbb43 | 73 | //LCD and serial portexpanders should be wired accordingly |
wonner163 | 0:4562b55bbb43 | 74 | // |
wonner163 | 0:4562b55bbb43 | 75 | //Select Hardware module (one option only) |
wonner163 | 0:4562b55bbb43 | 76 | #define DEFAULT 0 |
wonner163 | 0:4562b55bbb43 | 77 | #define ADAFRUIT 0 |
wonner163 | 0:4562b55bbb43 | 78 | #define DFROBOT 1 |
wonner163 | 0:4562b55bbb43 | 79 | |
wonner163 | 0:4562b55bbb43 | 80 | #if (DEFAULT==1) |
wonner163 | 0:4562b55bbb43 | 81 | //Definitions for default (WH) mapping between serial port expander pins and LCD controller |
wonner163 | 0:4562b55bbb43 | 82 | //This hardware supports the I2C bus expander (PCF8574/PCF8574A or MCP23008) and SPI bus expander (74595) interfaces |
wonner163 | 0:4562b55bbb43 | 83 | //See https://mbed.org/cookbook/Text-LCD-Enhanced |
wonner163 | 0:4562b55bbb43 | 84 | // |
wonner163 | 0:4562b55bbb43 | 85 | //Note: LCD RW pin must be connected to GND |
wonner163 | 0:4562b55bbb43 | 86 | // E2 is used for LCD40x4 (second controller) |
wonner163 | 0:4562b55bbb43 | 87 | // BL may be used to control backlight |
wonner163 | 0:4562b55bbb43 | 88 | #define D_LCD_PIN_D4 0 |
wonner163 | 0:4562b55bbb43 | 89 | #define D_LCD_PIN_D5 1 |
wonner163 | 0:4562b55bbb43 | 90 | #define D_LCD_PIN_D6 2 |
wonner163 | 0:4562b55bbb43 | 91 | #define D_LCD_PIN_D7 3 |
wonner163 | 0:4562b55bbb43 | 92 | #define D_LCD_PIN_RS 4 |
wonner163 | 0:4562b55bbb43 | 93 | #define D_LCD_PIN_E 5 |
wonner163 | 0:4562b55bbb43 | 94 | #define D_LCD_PIN_E2 6 |
wonner163 | 0:4562b55bbb43 | 95 | #define D_LCD_PIN_BL 7 |
wonner163 | 0:4562b55bbb43 | 96 | |
wonner163 | 0:4562b55bbb43 | 97 | #define D_LCD_PIN_RW D_LCD_PIN_E2 |
wonner163 | 0:4562b55bbb43 | 98 | |
wonner163 | 0:4562b55bbb43 | 99 | //Select I2C Portexpander type (one option only) |
wonner163 | 0:4562b55bbb43 | 100 | #define PCF8574 1 |
wonner163 | 0:4562b55bbb43 | 101 | #define MCP23008 0 |
wonner163 | 0:4562b55bbb43 | 102 | #endif |
wonner163 | 0:4562b55bbb43 | 103 | |
wonner163 | 0:4562b55bbb43 | 104 | #if (ADAFRUIT==1) |
wonner163 | 0:4562b55bbb43 | 105 | //Definitions for Adafruit i2cspilcdbackpack mapping between serial port expander pins and LCD controller |
wonner163 | 0:4562b55bbb43 | 106 | //This hardware supports both an I2C expander (MCP23008) and an SPI expander (74595) selectable by a jumper. |
wonner163 | 0:4562b55bbb43 | 107 | //See http://www.ladyada.net/products/i2cspilcdbackpack |
wonner163 | 0:4562b55bbb43 | 108 | // |
wonner163 | 0:4562b55bbb43 | 109 | //Note: LCD RW pin must be kept LOW |
wonner163 | 0:4562b55bbb43 | 110 | // E2 is not available on this hardware and so it does not support LCD40x4 (second controller) |
wonner163 | 0:4562b55bbb43 | 111 | // BL is used to control backlight |
wonner163 | 0:4562b55bbb43 | 112 | #define D_LCD_PIN_0 0 |
wonner163 | 0:4562b55bbb43 | 113 | #define D_LCD_PIN_RS 1 |
wonner163 | 0:4562b55bbb43 | 114 | #define D_LCD_PIN_E 2 |
wonner163 | 0:4562b55bbb43 | 115 | #define D_LCD_PIN_D4 3 |
wonner163 | 0:4562b55bbb43 | 116 | #define D_LCD_PIN_D5 4 |
wonner163 | 0:4562b55bbb43 | 117 | #define D_LCD_PIN_D6 5 |
wonner163 | 0:4562b55bbb43 | 118 | #define D_LCD_PIN_D7 6 |
wonner163 | 0:4562b55bbb43 | 119 | #define D_LCD_PIN_BL 7 |
wonner163 | 0:4562b55bbb43 | 120 | |
wonner163 | 0:4562b55bbb43 | 121 | #define D_LCD_PIN_E2 D_LCD_PIN_0 |
wonner163 | 0:4562b55bbb43 | 122 | |
wonner163 | 0:4562b55bbb43 | 123 | //Force I2C portexpander type |
wonner163 | 0:4562b55bbb43 | 124 | #define PCF8574 0 |
wonner163 | 0:4562b55bbb43 | 125 | #define MCP23008 1 |
wonner163 | 0:4562b55bbb43 | 126 | #endif |
wonner163 | 0:4562b55bbb43 | 127 | |
wonner163 | 0:4562b55bbb43 | 128 | #if (DFROBOT==1) |
wonner163 | 0:4562b55bbb43 | 129 | //Definitions for DFROBOT LCD2004 Module mapping between serial port expander pins and LCD controller |
wonner163 | 0:4562b55bbb43 | 130 | //This hardware uses PCF8574 and is different from earlier/different Arduino I2C LCD displays |
wonner163 | 0:4562b55bbb43 | 131 | //See http://arduino-info.wikispaces.com/LCD-Blue-I2C |
wonner163 | 0:4562b55bbb43 | 132 | // |
wonner163 | 0:4562b55bbb43 | 133 | //Note: LCD RW pin must be kept LOW |
wonner163 | 0:4562b55bbb43 | 134 | // E2 is not available on default Arduino hardware and so it does not support LCD40x4 (second controller) |
wonner163 | 0:4562b55bbb43 | 135 | // BL is used to control backlight, reverse logic: Low turns on Backlight. This is handled in setBacklight() |
wonner163 | 0:4562b55bbb43 | 136 | #define D_LCD_PIN_RS 0 |
wonner163 | 0:4562b55bbb43 | 137 | #define D_LCD_PIN_RW 1 |
wonner163 | 0:4562b55bbb43 | 138 | #define D_LCD_PIN_E 2 |
wonner163 | 0:4562b55bbb43 | 139 | #define D_LCD_PIN_BL 3 |
wonner163 | 0:4562b55bbb43 | 140 | #define D_LCD_PIN_D4 4 |
wonner163 | 0:4562b55bbb43 | 141 | #define D_LCD_PIN_D5 5 |
wonner163 | 0:4562b55bbb43 | 142 | #define D_LCD_PIN_D6 6 |
wonner163 | 0:4562b55bbb43 | 143 | #define D_LCD_PIN_D7 7 |
wonner163 | 0:4562b55bbb43 | 144 | |
wonner163 | 0:4562b55bbb43 | 145 | #define D_LCD_PIN_E2 D_LCD_PIN_RW |
wonner163 | 0:4562b55bbb43 | 146 | |
wonner163 | 0:4562b55bbb43 | 147 | //Force I2C portexpander type |
wonner163 | 0:4562b55bbb43 | 148 | #define PCF8574 1 |
wonner163 | 0:4562b55bbb43 | 149 | #define MCP23008 0 |
wonner163 | 0:4562b55bbb43 | 150 | #endif |
wonner163 | 0:4562b55bbb43 | 151 | |
wonner163 | 0:4562b55bbb43 | 152 | //Bitpattern Defines for I2C PCF8574/PCF8574A, MCP23008 and SPI 74595 Bus expanders |
wonner163 | 0:4562b55bbb43 | 153 | // |
wonner163 | 0:4562b55bbb43 | 154 | #define D_LCD_D4 (1<<D_LCD_PIN_D4) |
wonner163 | 0:4562b55bbb43 | 155 | #define D_LCD_D5 (1<<D_LCD_PIN_D5) |
wonner163 | 0:4562b55bbb43 | 156 | #define D_LCD_D6 (1<<D_LCD_PIN_D6) |
wonner163 | 0:4562b55bbb43 | 157 | #define D_LCD_D7 (1<<D_LCD_PIN_D7) |
wonner163 | 0:4562b55bbb43 | 158 | #define D_LCD_RS (1<<D_LCD_PIN_RS) |
wonner163 | 0:4562b55bbb43 | 159 | #define D_LCD_E (1<<D_LCD_PIN_E) |
wonner163 | 0:4562b55bbb43 | 160 | #define D_LCD_E2 (1<<D_LCD_PIN_E2) |
wonner163 | 0:4562b55bbb43 | 161 | #define D_LCD_BL (1<<D_LCD_PIN_BL) |
wonner163 | 0:4562b55bbb43 | 162 | //#define D_LCD_RW (1<<D_LCD_PIN_RW) |
wonner163 | 0:4562b55bbb43 | 163 | |
wonner163 | 0:4562b55bbb43 | 164 | #define D_LCD_BUS_MSK (D_LCD_D4 | D_LCD_D5 | D_LCD_D6 | D_LCD_D7) |
wonner163 | 0:4562b55bbb43 | 165 | #define D_LCD_BUS_DEF 0x00 |
wonner163 | 0:4562b55bbb43 | 166 | |
wonner163 | 0:4562b55bbb43 | 167 | /* PCF8574/PCF8574A I2C portexpander slave address */ |
wonner163 | 0:4562b55bbb43 | 168 | #define PCF8574_SA0 0x40 |
wonner163 | 0:4562b55bbb43 | 169 | #define PCF8574_SA1 0x42 |
wonner163 | 0:4562b55bbb43 | 170 | #define PCF8574_SA2 0x44 |
wonner163 | 0:4562b55bbb43 | 171 | #define PCF8574_SA3 0x46 |
wonner163 | 0:4562b55bbb43 | 172 | #define PCF8574_SA4 0x48 |
wonner163 | 0:4562b55bbb43 | 173 | #define PCF8574_SA5 0x4A |
wonner163 | 0:4562b55bbb43 | 174 | #define PCF8574_SA6 0x4C |
wonner163 | 0:4562b55bbb43 | 175 | #define PCF8574_SA7 0x4E |
wonner163 | 0:4562b55bbb43 | 176 | |
wonner163 | 0:4562b55bbb43 | 177 | #define PCF8574A_SA0 0x70 |
wonner163 | 0:4562b55bbb43 | 178 | #define PCF8574A_SA1 0x72 |
wonner163 | 0:4562b55bbb43 | 179 | #define PCF8574A_SA2 0x74 |
wonner163 | 0:4562b55bbb43 | 180 | #define PCF8574A_SA3 0x76 |
wonner163 | 0:4562b55bbb43 | 181 | #define PCF8574A_SA4 0x78 |
wonner163 | 0:4562b55bbb43 | 182 | #define PCF8574A_SA5 0x7A |
wonner163 | 0:4562b55bbb43 | 183 | #define PCF8574A_SA6 0x7C |
wonner163 | 0:4562b55bbb43 | 184 | #define PCF8574A_SA7 0x7E |
wonner163 | 0:4562b55bbb43 | 185 | |
wonner163 | 0:4562b55bbb43 | 186 | /* MCP23008 I2C portexpander slave address */ |
wonner163 | 0:4562b55bbb43 | 187 | #define MCP23008_SA0 0x40 |
wonner163 | 0:4562b55bbb43 | 188 | #define MCP23008_SA1 0x42 |
wonner163 | 0:4562b55bbb43 | 189 | #define MCP23008_SA2 0x44 |
wonner163 | 0:4562b55bbb43 | 190 | #define MCP23008_SA3 0x46 |
wonner163 | 0:4562b55bbb43 | 191 | #define MCP23008_SA4 0x48 |
wonner163 | 0:4562b55bbb43 | 192 | #define MCP23008_SA5 0x4A |
wonner163 | 0:4562b55bbb43 | 193 | #define MCP23008_SA6 0x4C |
wonner163 | 0:4562b55bbb43 | 194 | #define MCP23008_SA7 0x4E |
wonner163 | 0:4562b55bbb43 | 195 | |
wonner163 | 0:4562b55bbb43 | 196 | /* MCP23008 I2C portexpander internal registers */ |
wonner163 | 0:4562b55bbb43 | 197 | #define IODIR 0x00 |
wonner163 | 0:4562b55bbb43 | 198 | #define IPOL 0x01 |
wonner163 | 0:4562b55bbb43 | 199 | #define GPINTEN 0x02 |
wonner163 | 0:4562b55bbb43 | 200 | #define DEFVAL 0x03 |
wonner163 | 0:4562b55bbb43 | 201 | #define INTCON 0x04 |
wonner163 | 0:4562b55bbb43 | 202 | #define IOCON 0x05 |
wonner163 | 0:4562b55bbb43 | 203 | #define GPPU 0x06 |
wonner163 | 0:4562b55bbb43 | 204 | #define INTF 0x07 |
wonner163 | 0:4562b55bbb43 | 205 | #define INTCAP 0x08 |
wonner163 | 0:4562b55bbb43 | 206 | #define GPIO 0x09 |
wonner163 | 0:4562b55bbb43 | 207 | #define OLAT 0x0A |
wonner163 | 0:4562b55bbb43 | 208 | |
wonner163 | 0:4562b55bbb43 | 209 | |
wonner163 | 0:4562b55bbb43 | 210 | /* ST7032i I2C slave address */ |
wonner163 | 0:4562b55bbb43 | 211 | #define ST7032_SA 0x7C |
wonner163 | 0:4562b55bbb43 | 212 | |
wonner163 | 0:4562b55bbb43 | 213 | /* ST7036i I2C slave address */ |
wonner163 | 0:4562b55bbb43 | 214 | #define ST7036_SA0 0x78 |
wonner163 | 0:4562b55bbb43 | 215 | #define ST7036_SA1 0x7A |
wonner163 | 0:4562b55bbb43 | 216 | #define ST7036_SA2 0x7C |
wonner163 | 0:4562b55bbb43 | 217 | #define ST7036_SA3 0x7E |
wonner163 | 0:4562b55bbb43 | 218 | |
wonner163 | 0:4562b55bbb43 | 219 | /* PCF21XX I2C slave address */ |
wonner163 | 0:4562b55bbb43 | 220 | #define PCF21XX_SA0 0x74 |
wonner163 | 0:4562b55bbb43 | 221 | #define PCF21XX_SA1 0x76 |
wonner163 | 0:4562b55bbb43 | 222 | |
wonner163 | 0:4562b55bbb43 | 223 | /* AIP31068 I2C slave address */ |
wonner163 | 0:4562b55bbb43 | 224 | #define AIP31068_SA 0x7C |
wonner163 | 0:4562b55bbb43 | 225 | |
wonner163 | 0:4562b55bbb43 | 226 | /* SSD1803 I2C slave address */ |
wonner163 | 0:4562b55bbb43 | 227 | #define SSD1803_SA0 0x78 |
wonner163 | 0:4562b55bbb43 | 228 | #define SSD1803_SA1 0x7A |
wonner163 | 0:4562b55bbb43 | 229 | |
wonner163 | 0:4562b55bbb43 | 230 | /* US2066/SSD1311 I2C slave address */ |
wonner163 | 0:4562b55bbb43 | 231 | #define US2066_SA0 0x78 |
wonner163 | 0:4562b55bbb43 | 232 | #define US2066_SA1 0x7A |
wonner163 | 0:4562b55bbb43 | 233 | |
wonner163 | 0:4562b55bbb43 | 234 | /* AC780 I2C slave address */ |
wonner163 | 0:4562b55bbb43 | 235 | #define AC780_SA0 0x78 |
wonner163 | 0:4562b55bbb43 | 236 | #define AC780_SA1 0x7A |
wonner163 | 0:4562b55bbb43 | 237 | #define AC780_SA2 0x7C |
wonner163 | 0:4562b55bbb43 | 238 | #define AC780_SA3 0x7E |
wonner163 | 0:4562b55bbb43 | 239 | |
wonner163 | 0:4562b55bbb43 | 240 | //Some native I2C controllers dont support ACK. Set define to '0' to allow code to proceed even without ACK |
wonner163 | 0:4562b55bbb43 | 241 | //#define LCD_I2C_ACK 0 |
wonner163 | 0:4562b55bbb43 | 242 | #define LCD_I2C_ACK 1 |
wonner163 | 0:4562b55bbb43 | 243 | |
wonner163 | 0:4562b55bbb43 | 244 | /* LCD Type information on Rows, Columns and Variant. This information is encoded in |
wonner163 | 0:4562b55bbb43 | 245 | * an int and used for the LCDType enumerators in order to simplify code maintenance */ |
wonner163 | 0:4562b55bbb43 | 246 | // Columns encoded in b7..b0 |
wonner163 | 0:4562b55bbb43 | 247 | #define LCD_T_COL_MSK 0x000000FF |
wonner163 | 0:4562b55bbb43 | 248 | #define LCD_T_C6 0x00000006 |
wonner163 | 0:4562b55bbb43 | 249 | #define LCD_T_C8 0x00000008 |
wonner163 | 0:4562b55bbb43 | 250 | #define LCD_T_C10 0x0000000A |
wonner163 | 0:4562b55bbb43 | 251 | #define LCD_T_C12 0x0000000C |
wonner163 | 0:4562b55bbb43 | 252 | #define LCD_T_C16 0x00000010 |
wonner163 | 0:4562b55bbb43 | 253 | #define LCD_T_C20 0x00000014 |
wonner163 | 0:4562b55bbb43 | 254 | #define LCD_T_C24 0x00000018 |
wonner163 | 0:4562b55bbb43 | 255 | #define LCD_T_C32 0x00000020 |
wonner163 | 0:4562b55bbb43 | 256 | #define LCD_T_C40 0x00000028 |
wonner163 | 0:4562b55bbb43 | 257 | |
wonner163 | 0:4562b55bbb43 | 258 | // Rows encoded in b15..b8 |
wonner163 | 0:4562b55bbb43 | 259 | #define LCD_T_ROW_MSK 0x0000FF00 |
wonner163 | 0:4562b55bbb43 | 260 | #define LCD_T_R1 0x00000100 |
wonner163 | 0:4562b55bbb43 | 261 | #define LCD_T_R2 0x00000200 |
wonner163 | 0:4562b55bbb43 | 262 | #define LCD_T_R3 0x00000300 |
wonner163 | 0:4562b55bbb43 | 263 | #define LCD_T_R4 0x00000400 |
wonner163 | 0:4562b55bbb43 | 264 | |
wonner163 | 0:4562b55bbb43 | 265 | // Addressing mode encoded in b19..b16 |
wonner163 | 0:4562b55bbb43 | 266 | #define LCD_T_ADR_MSK 0x000F0000 |
wonner163 | 0:4562b55bbb43 | 267 | #define LCD_T_A 0x00000000 /*Mode A Default 1, 2 or 4 line display */ |
wonner163 | 0:4562b55bbb43 | 268 | #define LCD_T_B 0x00010000 /*Mode B, Alternate 8x2 (actually 16x1 display) */ |
wonner163 | 0:4562b55bbb43 | 269 | #define LCD_T_C 0x00020000 /*Mode C, Alternate 16x1 (actually 8x2 display) */ |
wonner163 | 0:4562b55bbb43 | 270 | #define LCD_T_D 0x00030000 /*Mode D, Alternate 3 or 4 line display (12x4, 20x4, 24x4) */ |
wonner163 | 0:4562b55bbb43 | 271 | #define LCD_T_D1 0x00040000 /*Mode D1, Alternate 3 out of 4 line display (12x3, 20x3, 24x3) */ |
wonner163 | 0:4562b55bbb43 | 272 | #define LCD_T_E 0x00050000 /*Mode E, 40x4 display (actually two 40x2) */ |
wonner163 | 0:4562b55bbb43 | 273 | #define LCD_T_F 0x00060000 /*Mode F, 16x3 display (actually 24x2) */ |
wonner163 | 0:4562b55bbb43 | 274 | #define LCD_T_G 0x00070000 /*Mode G, 16x3 display */ |
wonner163 | 0:4562b55bbb43 | 275 | |
wonner163 | 0:4562b55bbb43 | 276 | /* LCD Ctrl information on interface support and features. This information is encoded in |
wonner163 | 0:4562b55bbb43 | 277 | * an int and used for the LCDCtrl enumerators in order to simplify code maintenance */ |
wonner163 | 0:4562b55bbb43 | 278 | // Interface encoded in b31..b24 |
wonner163 | 0:4562b55bbb43 | 279 | #define LCD_C_BUS_MSK 0xFF000000 |
wonner163 | 0:4562b55bbb43 | 280 | #define LCD_C_PAR 0x01000000 /*Parallel 4 or 8 bit data, E pin, RS pin, RW=GND */ |
wonner163 | 0:4562b55bbb43 | 281 | #define LCD_C_SPI3_9 0x02000000 /*SPI 3 line (MOSI, SCL, CS pins), 9 bits (RS + 8 Data) */ |
wonner163 | 0:4562b55bbb43 | 282 | #define LCD_C_SPI3_10 0x04000000 /*SPI 3 line (MOSI, SCL, CS pins), 10 bits (RS, RW + 8 Data) */ |
wonner163 | 0:4562b55bbb43 | 283 | #define LCD_C_SPI3_16 0x08000000 /*SPI 3 line (MOSI, SCL, CS pins), 16 bits (RS, RW + 8 Data) */ |
wonner163 | 0:4562b55bbb43 | 284 | #define LCD_C_SPI3_24 0x10000000 /*SPI 3 line (MOSI, SCL, CS pins), 24 bits (RS, RW + 8 Data) */ |
wonner163 | 0:4562b55bbb43 | 285 | #define LCD_C_SPI4 0x20000000 /*SPI 4 line (MOSI, SCL, CS, RS pin), RS pin + 8 Data */ |
wonner163 | 0:4562b55bbb43 | 286 | #define LCD_C_I2C 0x40000000 /*I2C (SDA, SCL pin), 8 control bits (Co, RS, RW) + 8 Data */ |
wonner163 | 0:4562b55bbb43 | 287 | // Features encoded in b23..b16 |
wonner163 | 0:4562b55bbb43 | 288 | #define LCD_C_FTR_MSK 0x00FF0000 |
wonner163 | 0:4562b55bbb43 | 289 | #define LCD_C_BST 0x00010000 /*Booster */ |
wonner163 | 0:4562b55bbb43 | 290 | #define LCD_C_CTR 0x00020000 /*Contrast Control */ |
wonner163 | 0:4562b55bbb43 | 291 | #define LCD_C_ICN 0x00040000 /*Icons */ |
wonner163 | 0:4562b55bbb43 | 292 | #define LCD_C_PDN 0x00080000 /*Power Down */ |
wonner163 | 0:4562b55bbb43 | 293 | |
wonner163 | 0:4562b55bbb43 | 294 | |
wonner163 | 0:4562b55bbb43 | 295 | // Contrast setting, 6 significant bits (only supported for controllers with extended features) |
wonner163 | 0:4562b55bbb43 | 296 | // Voltage Multiplier setting, 2 or 3 significant bits (only supported for controllers with extended features) |
wonner163 | 0:4562b55bbb43 | 297 | #define LCD_DEF_CONTRAST 0x20 |
wonner163 | 0:4562b55bbb43 | 298 | |
wonner163 | 0:4562b55bbb43 | 299 | //ST7032 EastRising ERC1602FS-4 display |
wonner163 | 0:4562b55bbb43 | 300 | //Contrast setting 6 significant bits |
wonner163 | 0:4562b55bbb43 | 301 | //Voltage Multiplier setting 3 significant bits |
wonner163 | 0:4562b55bbb43 | 302 | #define LCD_ST7032_CONTRAST 0x18 |
wonner163 | 0:4562b55bbb43 | 303 | #define LCD_ST7032_RAB 0x04 |
wonner163 | 0:4562b55bbb43 | 304 | |
wonner163 | 0:4562b55bbb43 | 305 | //ST7036 EA DOGM1603 display |
wonner163 | 0:4562b55bbb43 | 306 | //Contrast setting 6 significant bits |
wonner163 | 0:4562b55bbb43 | 307 | //Voltage Multiplier setting 3 significant bits |
wonner163 | 0:4562b55bbb43 | 308 | #define LCD_ST7036_CONTRAST 0x28 |
wonner163 | 0:4562b55bbb43 | 309 | #define LCD_ST7036_RAB 0x04 |
wonner163 | 0:4562b55bbb43 | 310 | |
wonner163 | 0:4562b55bbb43 | 311 | //SSD1803 EA DOGM204 display |
wonner163 | 0:4562b55bbb43 | 312 | //Contrast setting 6 significant bits |
wonner163 | 0:4562b55bbb43 | 313 | //Voltage Multiplier setting 3 significant bits |
wonner163 | 0:4562b55bbb43 | 314 | #define LCD_SSD1_CONTRAST 0x28 |
wonner163 | 0:4562b55bbb43 | 315 | #define LCD_SSD1_RAB 0x06 |
wonner163 | 0:4562b55bbb43 | 316 | |
wonner163 | 0:4562b55bbb43 | 317 | //US2066/SSD1311 EastRising ER-OLEDM2002-4 display |
wonner163 | 0:4562b55bbb43 | 318 | //Contrast setting 8 significant bits, use 6 for compatibility |
wonner163 | 0:4562b55bbb43 | 319 | #define LCD_US20_CONTRAST 0x3F |
wonner163 | 0:4562b55bbb43 | 320 | //#define LCD_US20_CONTRAST 0x1F |
wonner163 | 0:4562b55bbb43 | 321 | |
wonner163 | 0:4562b55bbb43 | 322 | //PCF2113, PCF2119 display |
wonner163 | 0:4562b55bbb43 | 323 | //Contrast setting 6 significant bits |
wonner163 | 0:4562b55bbb43 | 324 | //Voltage Multiplier setting 2 significant bits |
wonner163 | 0:4562b55bbb43 | 325 | #define LCD_PCF2_CONTRAST 0x20 |
wonner163 | 0:4562b55bbb43 | 326 | #define LCD_PCF2_S12 0x02 |
wonner163 | 0:4562b55bbb43 | 327 | |
wonner163 | 0:4562b55bbb43 | 328 | //PT6314 VFD display |
wonner163 | 0:4562b55bbb43 | 329 | //Contrast setting 2 significant bits |
wonner163 | 0:4562b55bbb43 | 330 | #define LCD_PT63_CONTRAST 0x00 |
wonner163 | 0:4562b55bbb43 | 331 | |
wonner163 | 0:4562b55bbb43 | 332 | /** Some sample User Defined Chars 5x7 dots */ |
wonner163 | 0:4562b55bbb43 | 333 | //extern const char udc_ae[]; //æ |
wonner163 | 0:4562b55bbb43 | 334 | //extern const char udc_0e[]; //ø |
wonner163 | 0:4562b55bbb43 | 335 | //extern const char udc_ao[]; //å |
wonner163 | 0:4562b55bbb43 | 336 | //extern const char udc_AE[]; //Æ |
wonner163 | 0:4562b55bbb43 | 337 | //extern const char udc_0E[]; //Ø |
wonner163 | 0:4562b55bbb43 | 338 | //extern const char udc_Ao[]; //Å |
wonner163 | 0:4562b55bbb43 | 339 | //extern const char udc_PO[]; //Padlock Open |
wonner163 | 0:4562b55bbb43 | 340 | //extern const char udc_PC[]; //Padlock Closed |
wonner163 | 0:4562b55bbb43 | 341 | |
wonner163 | 0:4562b55bbb43 | 342 | //extern const char udc_alpha[]; //alpha |
wonner163 | 0:4562b55bbb43 | 343 | //extern const char udc_ohm[]; //ohm |
wonner163 | 0:4562b55bbb43 | 344 | //extern const char udc_sigma[]; //sigma |
wonner163 | 0:4562b55bbb43 | 345 | //extern const char udc_pi[]; //pi |
wonner163 | 0:4562b55bbb43 | 346 | //extern const char udc_root[]; //root |
wonner163 | 0:4562b55bbb43 | 347 | |
wonner163 | 0:4562b55bbb43 | 348 | |
wonner163 | 0:4562b55bbb43 | 349 | extern const char udc_0[]; // |> |
wonner163 | 0:4562b55bbb43 | 350 | extern const char udc_1[]; // <| |
wonner163 | 0:4562b55bbb43 | 351 | extern const char udc_2[]; // | |
wonner163 | 0:4562b55bbb43 | 352 | extern const char udc_3[]; // || |
wonner163 | 0:4562b55bbb43 | 353 | extern const char udc_4[]; // ||| |
wonner163 | 0:4562b55bbb43 | 354 | extern const char udc_5[]; // = |
wonner163 | 0:4562b55bbb43 | 355 | extern const char udc_6[]; // checkerboard |
wonner163 | 0:4562b55bbb43 | 356 | extern const char udc_7[]; // \ |
wonner163 | 0:4562b55bbb43 | 357 | |
wonner163 | 0:4562b55bbb43 | 358 | extern const char udc_degr[]; // Degree symbol |
wonner163 | 0:4562b55bbb43 | 359 | |
wonner163 | 0:4562b55bbb43 | 360 | extern const char udc_TM_T[]; // Trademark T |
wonner163 | 0:4562b55bbb43 | 361 | extern const char udc_TM_M[]; // Trademark M |
wonner163 | 0:4562b55bbb43 | 362 | |
wonner163 | 0:4562b55bbb43 | 363 | //extern const char udc_Bat_Hi[]; // Battery Full |
wonner163 | 0:4562b55bbb43 | 364 | //extern const char udc_Bat_Ha[]; // Battery Half |
wonner163 | 0:4562b55bbb43 | 365 | //extern const char udc_Bat_Lo[]; // Battery Low |
wonner163 | 0:4562b55bbb43 | 366 | extern const char udc_Bat_Hi[]; // Battery Full |
wonner163 | 0:4562b55bbb43 | 367 | extern const char udc_Bat_Ha[]; // Battery Half |
wonner163 | 0:4562b55bbb43 | 368 | extern const char udc_Bat_Lo[]; // Battery Low |
wonner163 | 0:4562b55bbb43 | 369 | extern const char udc_AC[]; // AC Power |
wonner163 | 0:4562b55bbb43 | 370 | |
wonner163 | 0:4562b55bbb43 | 371 | //extern const char udc_smiley[]; // Smiley |
wonner163 | 0:4562b55bbb43 | 372 | //extern const char udc_droopy[]; // Droopey |
wonner163 | 0:4562b55bbb43 | 373 | //extern const char udc_note[]; // Note |
wonner163 | 0:4562b55bbb43 | 374 | |
wonner163 | 0:4562b55bbb43 | 375 | //extern const char udc_bar_1[]; // Bar 1 |
wonner163 | 0:4562b55bbb43 | 376 | //extern const char udc_bar_2[]; // Bar 11 |
wonner163 | 0:4562b55bbb43 | 377 | //extern const char udc_bar_3[]; // Bar 111 |
wonner163 | 0:4562b55bbb43 | 378 | //extern const char udc_bar_4[]; // Bar 1111 |
wonner163 | 0:4562b55bbb43 | 379 | //extern const char udc_bar_5[]; // Bar 11111 |
wonner163 | 0:4562b55bbb43 | 380 | |
wonner163 | 0:4562b55bbb43 | 381 | //extern const char udc_ch_1[]; // Hor bars 4 |
wonner163 | 0:4562b55bbb43 | 382 | //extern const char udc_ch_2[]; // Hor bars 4 (inverted) |
wonner163 | 0:4562b55bbb43 | 383 | //extern const char udc_ch_3[]; // Ver bars 3 |
wonner163 | 0:4562b55bbb43 | 384 | //extern const char udc_ch_4[]; // Ver bars 3 (inverted) |
wonner163 | 0:4562b55bbb43 | 385 | //extern const char udc_ch_yr[]; // Year (kana) |
wonner163 | 0:4562b55bbb43 | 386 | //extern const char udc_ch_mo[]; // Month (kana) |
wonner163 | 0:4562b55bbb43 | 387 | //extern const char udc_ch_dy[]; // Day (kana) |
wonner163 | 0:4562b55bbb43 | 388 | //extern const char udc_ch_mi[]; // minute (kana) |
wonner163 | 0:4562b55bbb43 | 389 | extern const char udc_None[]; |
wonner163 | 0:4562b55bbb43 | 390 | extern const char udc_All[]; |
wonner163 | 0:4562b55bbb43 | 391 | |
wonner163 | 0:4562b55bbb43 | 392 | /** A TextLCD interface for driving 4-bit HD44780-based LCDs |
wonner163 | 0:4562b55bbb43 | 393 | * |
wonner163 | 0:4562b55bbb43 | 394 | * @brief Currently supports 8x1, 8x2, 12x2, 12x3, 12x4, 16x1, 16x2, 16x3, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels |
wonner163 | 0:4562b55bbb43 | 395 | * Interface options include direct mbed pins, I2C portexpander (PCF8474/PCF8574A or MCP23008) or SPI bus shiftregister (74595) and some native I2C or SPI devices |
wonner163 | 0:4562b55bbb43 | 396 | * |
wonner163 | 0:4562b55bbb43 | 397 | */ |
wonner163 | 0:4562b55bbb43 | 398 | class TextLCD_Base : public Stream { |
wonner163 | 0:4562b55bbb43 | 399 | public: |
wonner163 | 0:4562b55bbb43 | 400 | |
wonner163 | 0:4562b55bbb43 | 401 | /** LCD panel format */ |
wonner163 | 0:4562b55bbb43 | 402 | // The commented out types exist but have not yet been tested with the library |
wonner163 | 0:4562b55bbb43 | 403 | enum LCDType { |
wonner163 | 0:4562b55bbb43 | 404 | // LCD6x1 = (LCD_T_A | LCD_T_C6 | LCD_T_R1), /**< 6x1 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 405 | // LCD6x2 = (LCD_T_A | LCD_T_C6 | LCD_T_R2), /**< 6x2 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 406 | LCD8x1 = (LCD_T_A | LCD_T_C8 | LCD_T_R1), /**< 8x1 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 407 | LCD8x2 = (LCD_T_A | LCD_T_C8 | LCD_T_R2), /**< 8x2 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 408 | LCD8x2B = (LCD_T_D | LCD_T_C8 | LCD_T_R2), /**< 8x2 LCD panel (actually 16x1) */ |
wonner163 | 0:4562b55bbb43 | 409 | // LCD12x1 = (LCD_T_A | LCD_T_C12 | LCD_T_R1), /**< 12x1 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 410 | LCD12x2 = (LCD_T_A | LCD_T_C12 | LCD_T_R2), /**< 12x2 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 411 | LCD12x3D = (LCD_T_D | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode PCF21XX */ |
wonner163 | 0:4562b55bbb43 | 412 | LCD12x3D1 = (LCD_T_D1 | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode PCF21XX */ |
wonner163 | 0:4562b55bbb43 | 413 | // LCD12x3G = (LCD_T_G | LCD_T_C12 | LCD_T_R3), /**< 12x3 LCD panel, special mode ST7036 */ |
wonner163 | 0:4562b55bbb43 | 414 | LCD12x4 = (LCD_T_A | LCD_T_C12 | LCD_T_R4), /**< 12x4 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 415 | LCD12x4D = (LCD_T_B | LCD_T_C12 | LCD_T_R4), /**< 12x4 LCD panel, special mode PCF21XX */ |
wonner163 | 0:4562b55bbb43 | 416 | LCD16x1 = (LCD_T_A | LCD_T_C16 | LCD_T_R1), /**< 16x1 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 417 | LCD16x1C = (LCD_T_C | LCD_T_C16 | LCD_T_R1), /**< 16x1 LCD panel (actually 8x2) */ |
wonner163 | 0:4562b55bbb43 | 418 | LCD16x2 = (LCD_T_A | LCD_T_C16 | LCD_T_R2), /**< 16x2 LCD panel (default) */ |
wonner163 | 0:4562b55bbb43 | 419 | // LCD16x2B = (LCD_T_B | LCD_T_C16 | LCD_T_R2), /**< 16x2 LCD panel, alternate addressing, wrong.. */ |
wonner163 | 0:4562b55bbb43 | 420 | LCD16x3D = (LCD_T_D | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode SSD1803 */ |
wonner163 | 0:4562b55bbb43 | 421 | // LCD16x3D1 = (LCD_T_D1 | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode SSD1803 */ |
wonner163 | 0:4562b55bbb43 | 422 | LCD16x3F = (LCD_T_F | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel (actually 24x2) */ |
wonner163 | 0:4562b55bbb43 | 423 | LCD16x3G = (LCD_T_G | LCD_T_C16 | LCD_T_R3), /**< 16x3 LCD panel, special mode ST7036 */ |
wonner163 | 0:4562b55bbb43 | 424 | LCD16x4 = (LCD_T_A | LCD_T_C16 | LCD_T_R4), /**< 16x4 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 425 | // LCD16x4D = (LCD_T_D | LCD_T_C16 | LCD_T_R4), /**< 16x4 LCD panel, special mode SSD1803 */ |
wonner163 | 0:4562b55bbb43 | 426 | // LCD20x1 = (LCD_T_A | LCD_T_C20 | LCD_T_R1), /**< 20x1 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 427 | LCD20x2 = (LCD_T_A | LCD_T_C20 | LCD_T_R2), /**< 20x2 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 428 | // LCD20x3 = (LCD_T_A | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 429 | // LCD20x3D = (LCD_T_D | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel, special mode SSD1803 */ |
wonner163 | 0:4562b55bbb43 | 430 | // LCD20x3D1 = (LCD_T_D1 | LCD_T_C20 | LCD_T_R3), /**< 20x3 LCD panel, special mode SSD1803 */ |
wonner163 | 0:4562b55bbb43 | 431 | LCD20x4 = (LCD_T_A | LCD_T_C20 | LCD_T_R4), /**< 20x4 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 432 | LCD20x4D = (LCD_T_D | LCD_T_C20 | LCD_T_R4), /**< 20x4 LCD panel, special mode SSD1803 */ |
wonner163 | 0:4562b55bbb43 | 433 | LCD24x1 = (LCD_T_A | LCD_T_C24 | LCD_T_R1), /**< 24x1 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 434 | LCD24x2 = (LCD_T_A | LCD_T_C24 | LCD_T_R2), /**< 24x2 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 435 | // LCD24x3D = (LCD_T_D | LCD_T_C24 | LCD_T_R3), /**< 24x3 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 436 | // LCD24x3D1 = (LCD_T_D | LCD_T_C24 | LCD_T_R3), /**< 24x3 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 437 | LCD24x4D = (LCD_T_D | LCD_T_C24 | LCD_T_R4), /**< 24x4 LCD panel, special mode KS0078 */ |
wonner163 | 0:4562b55bbb43 | 438 | // LCD32x1 = (LCD_T_A | LCD_T_C32 | LCD_T_R1), /**< 32x1 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 439 | // LCD32x1C = (LCD_T_C | LCD_T_C32 | LCD_T_R1), /**< 32x1 LCD panel (actually 16x2) */ |
wonner163 | 0:4562b55bbb43 | 440 | // LCD32x2 = (LCD_T_A | LCD_T_C32 | LCD_T_R2), /**< 32x2 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 441 | // LCD32x4 = (LCD_T_A | LCD_T_C32 | LCD_T_R4), /**< 32x4 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 442 | // LCD40x1 = (LCD_T_A | LCD_T_C40 | LCD_T_R1), /**< 40x1 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 443 | // LCD40x1C = (LCD_T_C | LCD_T_C40 | LCD_T_R1), /**< 40x1 LCD panel (actually 20x2) */ |
wonner163 | 0:4562b55bbb43 | 444 | LCD40x2 = (LCD_T_A | LCD_T_C40 | LCD_T_R2), /**< 40x2 LCD panel */ |
wonner163 | 0:4562b55bbb43 | 445 | LCD40x4 = (LCD_T_E | LCD_T_C40 | LCD_T_R4) /**< 40x4 LCD panel, Two controller version */ |
wonner163 | 0:4562b55bbb43 | 446 | }; |
wonner163 | 0:4562b55bbb43 | 447 | |
wonner163 | 0:4562b55bbb43 | 448 | |
wonner163 | 0:4562b55bbb43 | 449 | /** LCD Controller Device */ |
wonner163 | 0:4562b55bbb43 | 450 | enum LCDCtrl { |
wonner163 | 0:4562b55bbb43 | 451 | HD44780 = 0 | LCD_C_PAR, /**< HD44780 or full equivalent (default) */ |
wonner163 | 0:4562b55bbb43 | 452 | WS0010 = 1 | (LCD_C_PAR | LCD_C_SPI3_10 | LCD_C_BST), /**< WS0010 OLED Controller, 4/8 bit, SPI3 */ |
wonner163 | 0:4562b55bbb43 | 453 | ST7036_3V3 = 2 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7036 3V3 with Booster, 4/8 bit, SPI4, I2C */ |
wonner163 | 0:4562b55bbb43 | 454 | ST7036_5V = 3 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7036 5V no Booster, 4/8 bit, SPI4, I2C */ |
wonner163 | 0:4562b55bbb43 | 455 | ST7032_3V3 = 4 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< ST7032 3V3 with Booster, 4/8 bit, SPI4, I2C */ |
wonner163 | 0:4562b55bbb43 | 456 | ST7032_5V = 5 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_CTR), /**< ST7032 5V no Booster, 4/8 bit, SPI4, I2C */ |
wonner163 | 0:4562b55bbb43 | 457 | KS0078 = 6 | (LCD_C_PAR | LCD_C_SPI3_24), /**< KS0078 24x4 support, 4/8 bit, SPI3 */ |
wonner163 | 0:4562b55bbb43 | 458 | PCF2113_3V3 = 7 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< PCF2113 3V3 with Booster, 4/8 bit, I2C */ |
wonner163 | 0:4562b55bbb43 | 459 | PCF2116_3V3 = 8 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST), /**< PCF2116 3V3 with Booster, 4/8 bit, I2C */ |
wonner163 | 0:4562b55bbb43 | 460 | PCF2116_5V = 9 | (LCD_C_PAR | LCD_C_I2C), /**< PCF2116 5V no Booster, 4/8 bit, I2C */ |
wonner163 | 0:4562b55bbb43 | 461 | PCF2119_3V3 = 10 | (LCD_C_PAR | LCD_C_I2C | LCD_C_BST | LCD_C_CTR), /**< PCF2119 3V3 with Booster, 4/8 bit, I2C */ |
wonner163 | 0:4562b55bbb43 | 462 | // PCF2119_5V = 11 | (LCD_C_PAR | LCD_C_I2C), /**< PCF2119 5V no Booster, 4/8 bit, I2C */ |
wonner163 | 0:4562b55bbb43 | 463 | AIP31068 = 12 | (LCD_C_SPI3_9 | LCD_C_I2C | LCD_C_BST), /**< AIP31068 I2C, SPI3 */ |
wonner163 | 0:4562b55bbb43 | 464 | SSD1803_3V3 = 13 | (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 */ |
wonner163 | 0:4562b55bbb43 | 465 | // SSD1803_5V = 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 */ |
wonner163 | 0:4562b55bbb43 | 466 | US2066_3V3 = 15 | (LCD_C_PAR | LCD_C_SPI3_24 | LCD_C_I2C | LCD_C_CTR | LCD_C_PDN), /**< US2066/SSD1311 3V3, 4/8 bit, I2C, SPI3 */ |
wonner163 | 0:4562b55bbb43 | 467 | // PT6314 = 16 | (LCD_C_PAR | LCD_C_SPI3_16 | LCD_C_CTR | LCD_C_PDN), /**< PT6314 VFD, 4/8 bit, SPI3 */ |
wonner163 | 0:4562b55bbb43 | 468 | // AC780 = 17 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_PDN), /**< AC780 4/8 bit, SPI, I2C */ |
wonner163 | 0:4562b55bbb43 | 469 | // KS0066 = 18 | (LCD_C_PAR | LCD_C_SPI4 | LCD_C_I2C | LCD_C_PDN) /**< KS0066i == AC780 4/8 bit, SPI, I2C */ |
wonner163 | 0:4562b55bbb43 | 470 | }; |
wonner163 | 0:4562b55bbb43 | 471 | |
wonner163 | 0:4562b55bbb43 | 472 | |
wonner163 | 0:4562b55bbb43 | 473 | /** LCD Cursor control */ |
wonner163 | 0:4562b55bbb43 | 474 | enum LCDCursor { |
wonner163 | 0:4562b55bbb43 | 475 | CurOff_BlkOff = 0x00, /**< Cursor Off, Blinking Char Off */ |
wonner163 | 0:4562b55bbb43 | 476 | CurOn_BlkOff = 0x02, /**< Cursor On, Blinking Char Off */ |
wonner163 | 0:4562b55bbb43 | 477 | CurOff_BlkOn = 0x01, /**< Cursor Off, Blinking Char On */ |
wonner163 | 0:4562b55bbb43 | 478 | CurOn_BlkOn = 0x03 /**< Cursor On, Blinking Char On */ |
wonner163 | 0:4562b55bbb43 | 479 | }; |
wonner163 | 0:4562b55bbb43 | 480 | |
wonner163 | 0:4562b55bbb43 | 481 | /** LCD Display control */ |
wonner163 | 0:4562b55bbb43 | 482 | enum LCDMode { |
wonner163 | 0:4562b55bbb43 | 483 | DispOff = 0x00, /**< Display Off */ |
wonner163 | 0:4562b55bbb43 | 484 | DispOn = 0x04 /**< Display On */ |
wonner163 | 0:4562b55bbb43 | 485 | }; |
wonner163 | 0:4562b55bbb43 | 486 | |
wonner163 | 0:4562b55bbb43 | 487 | /** LCD Backlight control */ |
wonner163 | 0:4562b55bbb43 | 488 | enum LCDBacklight { |
wonner163 | 0:4562b55bbb43 | 489 | LightOff, /**< Backlight Off */ |
wonner163 | 0:4562b55bbb43 | 490 | LightOn /**< Backlight On */ |
wonner163 | 0:4562b55bbb43 | 491 | }; |
wonner163 | 0:4562b55bbb43 | 492 | |
wonner163 | 0:4562b55bbb43 | 493 | /** LCD Blink control (UDC), supported for some Controllers */ |
wonner163 | 0:4562b55bbb43 | 494 | enum LCDBlink { |
wonner163 | 0:4562b55bbb43 | 495 | BlinkOff, /**< Blink Off */ |
wonner163 | 0:4562b55bbb43 | 496 | BlinkOn /**< Blink On */ |
wonner163 | 0:4562b55bbb43 | 497 | }; |
wonner163 | 0:4562b55bbb43 | 498 | |
wonner163 | 0:4562b55bbb43 | 499 | /** LCD Orientation control, supported for some Controllers */ |
wonner163 | 0:4562b55bbb43 | 500 | enum LCDOrient { |
wonner163 | 0:4562b55bbb43 | 501 | Top, /**< Top view */ |
wonner163 | 0:4562b55bbb43 | 502 | Bottom /**< Upside down view */ |
wonner163 | 0:4562b55bbb43 | 503 | }; |
wonner163 | 0:4562b55bbb43 | 504 | |
wonner163 | 0:4562b55bbb43 | 505 | |
wonner163 | 0:4562b55bbb43 | 506 | #if DOXYGEN_ONLY |
wonner163 | 0:4562b55bbb43 | 507 | /** Write a character to the LCD |
wonner163 | 0:4562b55bbb43 | 508 | * |
wonner163 | 0:4562b55bbb43 | 509 | * @param c The character to write to the display |
wonner163 | 0:4562b55bbb43 | 510 | */ |
wonner163 | 0:4562b55bbb43 | 511 | int putc(int c); |
wonner163 | 0:4562b55bbb43 | 512 | |
wonner163 | 0:4562b55bbb43 | 513 | /** Write a formated string to the LCD |
wonner163 | 0:4562b55bbb43 | 514 | * |
wonner163 | 0:4562b55bbb43 | 515 | * @param format A printf-style format string, followed by the |
wonner163 | 0:4562b55bbb43 | 516 | * variables to use in formating the string. |
wonner163 | 0:4562b55bbb43 | 517 | */ |
wonner163 | 0:4562b55bbb43 | 518 | int printf(const char* format, ...); |
wonner163 | 0:4562b55bbb43 | 519 | #endif |
wonner163 | 0:4562b55bbb43 | 520 | |
wonner163 | 0:4562b55bbb43 | 521 | /** Locate cursor to a screen column and row |
wonner163 | 0:4562b55bbb43 | 522 | * |
wonner163 | 0:4562b55bbb43 | 523 | * @param column The horizontal position from the left, indexed from 0 |
wonner163 | 0:4562b55bbb43 | 524 | * @param row The vertical position from the top, indexed from 0 |
wonner163 | 0:4562b55bbb43 | 525 | */ |
wonner163 | 0:4562b55bbb43 | 526 | void locate(int column, int row); |
wonner163 | 0:4562b55bbb43 | 527 | |
wonner163 | 0:4562b55bbb43 | 528 | /** Return the memoryaddress of screen column and row location |
wonner163 | 0:4562b55bbb43 | 529 | * |
wonner163 | 0:4562b55bbb43 | 530 | * @param column The horizontal position from the left, indexed from 0 |
wonner163 | 0:4562b55bbb43 | 531 | * @param row The vertical position from the top, indexed from 0 |
wonner163 | 0:4562b55bbb43 | 532 | * @param return The memoryaddress of screen column and row location |
wonner163 | 0:4562b55bbb43 | 533 | */ |
wonner163 | 0:4562b55bbb43 | 534 | int getAddress(int column, int row); |
wonner163 | 0:4562b55bbb43 | 535 | |
wonner163 | 0:4562b55bbb43 | 536 | /** Set the memoryaddress of screen column and row location |
wonner163 | 0:4562b55bbb43 | 537 | * |
wonner163 | 0:4562b55bbb43 | 538 | * @param column The horizontal position from the left, indexed from 0 |
wonner163 | 0:4562b55bbb43 | 539 | * @param row The vertical position from the top, indexed from 0 |
wonner163 | 0:4562b55bbb43 | 540 | */ |
wonner163 | 0:4562b55bbb43 | 541 | void setAddress(int column, int row); |
wonner163 | 0:4562b55bbb43 | 542 | |
wonner163 | 0:4562b55bbb43 | 543 | /** Clear the screen and locate to 0,0 |
wonner163 | 0:4562b55bbb43 | 544 | */ |
wonner163 | 0:4562b55bbb43 | 545 | void cls(); |
wonner163 | 0:4562b55bbb43 | 546 | |
wonner163 | 0:4562b55bbb43 | 547 | /** Return the number of rows |
wonner163 | 0:4562b55bbb43 | 548 | * |
wonner163 | 0:4562b55bbb43 | 549 | * @param return The number of rows |
wonner163 | 0:4562b55bbb43 | 550 | */ |
wonner163 | 0:4562b55bbb43 | 551 | int rows(); |
wonner163 | 0:4562b55bbb43 | 552 | |
wonner163 | 0:4562b55bbb43 | 553 | /** Return the number of columns |
wonner163 | 0:4562b55bbb43 | 554 | * |
wonner163 | 0:4562b55bbb43 | 555 | * @param return The number of columns |
wonner163 | 0:4562b55bbb43 | 556 | */ |
wonner163 | 0:4562b55bbb43 | 557 | int columns(); |
wonner163 | 0:4562b55bbb43 | 558 | |
wonner163 | 0:4562b55bbb43 | 559 | /** Set the Cursormode |
wonner163 | 0:4562b55bbb43 | 560 | * |
wonner163 | 0:4562b55bbb43 | 561 | * @param cursorMode The Cursor mode (CurOff_BlkOff, CurOn_BlkOff, CurOff_BlkOn, CurOn_BlkOn) |
wonner163 | 0:4562b55bbb43 | 562 | */ |
wonner163 | 0:4562b55bbb43 | 563 | void setCursor(LCDCursor cursorMode); |
wonner163 | 0:4562b55bbb43 | 564 | |
wonner163 | 0:4562b55bbb43 | 565 | /** Set the Displaymode |
wonner163 | 0:4562b55bbb43 | 566 | * |
wonner163 | 0:4562b55bbb43 | 567 | * @param displayMode The Display mode (DispOff, DispOn) |
wonner163 | 0:4562b55bbb43 | 568 | */ |
wonner163 | 0:4562b55bbb43 | 569 | void setMode(LCDMode displayMode); |
wonner163 | 0:4562b55bbb43 | 570 | |
wonner163 | 0:4562b55bbb43 | 571 | /** Set the Backlight mode |
wonner163 | 0:4562b55bbb43 | 572 | * |
wonner163 | 0:4562b55bbb43 | 573 | * @param backlightMode The Backlight mode (LightOff, LightOn) |
wonner163 | 0:4562b55bbb43 | 574 | */ |
wonner163 | 0:4562b55bbb43 | 575 | void setBacklight(LCDBacklight backlightMode); |
wonner163 | 0:4562b55bbb43 | 576 | |
wonner163 | 0:4562b55bbb43 | 577 | /** Set User Defined Characters (UDC) |
wonner163 | 0:4562b55bbb43 | 578 | * |
wonner163 | 0:4562b55bbb43 | 579 | * @param unsigned char c The Index of the UDC (0..7) |
wonner163 | 0:4562b55bbb43 | 580 | * @param char *udc_data The bitpatterns for the UDC (8 bytes of 5 significant bits) |
wonner163 | 0:4562b55bbb43 | 581 | */ |
wonner163 | 0:4562b55bbb43 | 582 | void setUDC(unsigned char c, char *udc_data); |
wonner163 | 0:4562b55bbb43 | 583 | |
wonner163 | 0:4562b55bbb43 | 584 | /** Set UDC Blink |
wonner163 | 0:4562b55bbb43 | 585 | * setUDCBlink method is supported by some compatible devices (eg SSD1803) |
wonner163 | 0:4562b55bbb43 | 586 | * |
wonner163 | 0:4562b55bbb43 | 587 | * @param blinkMode The Blink mode (BlinkOff, BlinkOn) |
wonner163 | 0:4562b55bbb43 | 588 | */ |
wonner163 | 0:4562b55bbb43 | 589 | void setUDCBlink(LCDBlink blinkMode); |
wonner163 | 0:4562b55bbb43 | 590 | |
wonner163 | 0:4562b55bbb43 | 591 | /** Set Contrast |
wonner163 | 0:4562b55bbb43 | 592 | * setContrast method is supported by some compatible devices (eg ST7032i) that have onboard LCD voltage generation |
wonner163 | 0:4562b55bbb43 | 593 | * Code imported from fork by JH1PJL |
wonner163 | 0:4562b55bbb43 | 594 | * |
wonner163 | 0:4562b55bbb43 | 595 | * @param unsigned char c contrast data (6 significant bits, valid range 0..63, Value 0 will disable the Vgen) |
wonner163 | 0:4562b55bbb43 | 596 | * @return none |
wonner163 | 0:4562b55bbb43 | 597 | */ |
wonner163 | 0:4562b55bbb43 | 598 | void setContrast(unsigned char c = LCD_DEF_CONTRAST); |
wonner163 | 0:4562b55bbb43 | 599 | |
wonner163 | 0:4562b55bbb43 | 600 | /** Set Power |
wonner163 | 0:4562b55bbb43 | 601 | * setPower method is supported by some compatible devices (eg SSD1803) that have power down modes |
wonner163 | 0:4562b55bbb43 | 602 | * |
wonner163 | 0:4562b55bbb43 | 603 | * @param bool powerOn Power on/off |
wonner163 | 0:4562b55bbb43 | 604 | * @return none |
wonner163 | 0:4562b55bbb43 | 605 | */ |
wonner163 | 0:4562b55bbb43 | 606 | void setPower(bool powerOn = true); |
wonner163 | 0:4562b55bbb43 | 607 | |
wonner163 | 0:4562b55bbb43 | 608 | /** Set Orient |
wonner163 | 0:4562b55bbb43 | 609 | * setOrient method is supported by some compatible devices (eg SSD1803, US2066) that have top/bottom view modes |
wonner163 | 0:4562b55bbb43 | 610 | * |
wonner163 | 0:4562b55bbb43 | 611 | * @param LCDOrient orient Orientation |
wonner163 | 0:4562b55bbb43 | 612 | * @return none |
wonner163 | 0:4562b55bbb43 | 613 | */ |
wonner163 | 0:4562b55bbb43 | 614 | void setOrient(LCDOrient orient = Top); |
wonner163 | 0:4562b55bbb43 | 615 | |
wonner163 | 0:4562b55bbb43 | 616 | |
wonner163 | 0:4562b55bbb43 | 617 | //test |
wonner163 | 0:4562b55bbb43 | 618 | // void _initCtrl(); |
wonner163 | 0:4562b55bbb43 | 619 | |
wonner163 | 0:4562b55bbb43 | 620 | protected: |
wonner163 | 0:4562b55bbb43 | 621 | |
wonner163 | 0:4562b55bbb43 | 622 | /** LCD controller select, mainly used for LCD40x4 |
wonner163 | 0:4562b55bbb43 | 623 | */ |
wonner163 | 0:4562b55bbb43 | 624 | enum _LCDCtrl_Idx { |
wonner163 | 0:4562b55bbb43 | 625 | _LCDCtrl_0, /*< Primary */ |
wonner163 | 0:4562b55bbb43 | 626 | _LCDCtrl_1, /*< Secondary */ |
wonner163 | 0:4562b55bbb43 | 627 | }; |
wonner163 | 0:4562b55bbb43 | 628 | |
wonner163 | 0:4562b55bbb43 | 629 | /** Create a TextLCD_Base interface |
wonner163 | 0:4562b55bbb43 | 630 | * @brief Base class, can not be instantiated |
wonner163 | 0:4562b55bbb43 | 631 | * |
wonner163 | 0:4562b55bbb43 | 632 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 633 | * @param ctrl LCD controller (default = HD44780) |
wonner163 | 0:4562b55bbb43 | 634 | */ |
wonner163 | 0:4562b55bbb43 | 635 | TextLCD_Base(LCDType type = LCD16x2, LCDCtrl ctrl = HD44780); |
wonner163 | 0:4562b55bbb43 | 636 | |
wonner163 | 0:4562b55bbb43 | 637 | // Stream implementation functions |
wonner163 | 0:4562b55bbb43 | 638 | virtual int _putc(int value); |
wonner163 | 0:4562b55bbb43 | 639 | virtual int _getc(); |
wonner163 | 0:4562b55bbb43 | 640 | |
wonner163 | 0:4562b55bbb43 | 641 | /** Low level method for LCD controller |
wonner163 | 0:4562b55bbb43 | 642 | */ |
wonner163 | 0:4562b55bbb43 | 643 | void _init(); |
wonner163 | 0:4562b55bbb43 | 644 | |
wonner163 | 0:4562b55bbb43 | 645 | /** Low level initialisation method for LCD controller |
wonner163 | 0:4562b55bbb43 | 646 | */ |
wonner163 | 0:4562b55bbb43 | 647 | void _initCtrl(); |
wonner163 | 0:4562b55bbb43 | 648 | |
wonner163 | 0:4562b55bbb43 | 649 | /** Low level character address set method |
wonner163 | 0:4562b55bbb43 | 650 | */ |
wonner163 | 0:4562b55bbb43 | 651 | int _address(int column, int row); |
wonner163 | 0:4562b55bbb43 | 652 | |
wonner163 | 0:4562b55bbb43 | 653 | /** Low level cursor enable or disable method |
wonner163 | 0:4562b55bbb43 | 654 | */ |
wonner163 | 0:4562b55bbb43 | 655 | void _setCursor(LCDCursor show); |
wonner163 | 0:4562b55bbb43 | 656 | |
wonner163 | 0:4562b55bbb43 | 657 | /** Low level method to store user defined characters for current controller |
wonner163 | 0:4562b55bbb43 | 658 | */ |
wonner163 | 0:4562b55bbb43 | 659 | void _setUDC(unsigned char c, char *udc_data); |
wonner163 | 0:4562b55bbb43 | 660 | |
wonner163 | 0:4562b55bbb43 | 661 | /** Low level method to restore the cursortype and display mode for current controller |
wonner163 | 0:4562b55bbb43 | 662 | */ |
wonner163 | 0:4562b55bbb43 | 663 | void _setCursorAndDisplayMode(LCDMode displayMode, LCDCursor cursorType); |
wonner163 | 0:4562b55bbb43 | 664 | |
wonner163 | 0:4562b55bbb43 | 665 | /** Low level nibble write operation to LCD controller (serial or parallel) |
wonner163 | 0:4562b55bbb43 | 666 | */ |
wonner163 | 0:4562b55bbb43 | 667 | void _writeNibble(int value); |
wonner163 | 0:4562b55bbb43 | 668 | |
wonner163 | 0:4562b55bbb43 | 669 | /** Low level command byte write operation to LCD controller. |
wonner163 | 0:4562b55bbb43 | 670 | * Methods resets the RS bit and provides the required timing for the command. |
wonner163 | 0:4562b55bbb43 | 671 | */ |
wonner163 | 0:4562b55bbb43 | 672 | void _writeCommand(int command); |
wonner163 | 0:4562b55bbb43 | 673 | |
wonner163 | 0:4562b55bbb43 | 674 | /** Low level data byte write operation to LCD controller (serial or parallel). |
wonner163 | 0:4562b55bbb43 | 675 | * Methods sets the RS bit and provides the required timing for the data. |
wonner163 | 0:4562b55bbb43 | 676 | */ |
wonner163 | 0:4562b55bbb43 | 677 | void _writeData(int data); |
wonner163 | 0:4562b55bbb43 | 678 | |
wonner163 | 0:4562b55bbb43 | 679 | /** Pure Virtual Low level writes to LCD Bus (serial or parallel) |
wonner163 | 0:4562b55bbb43 | 680 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 681 | */ |
wonner163 | 0:4562b55bbb43 | 682 | virtual void _setEnable(bool value) = 0; |
wonner163 | 0:4562b55bbb43 | 683 | |
wonner163 | 0:4562b55bbb43 | 684 | /** Pure Virtual Low level writes to LCD Bus (serial or parallel) |
wonner163 | 0:4562b55bbb43 | 685 | * Set the RS pin ( 0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 686 | */ |
wonner163 | 0:4562b55bbb43 | 687 | virtual void _setRS(bool value) = 0; |
wonner163 | 0:4562b55bbb43 | 688 | |
wonner163 | 0:4562b55bbb43 | 689 | /** Pure Virtual Low level writes to LCD Bus (serial or parallel) |
wonner163 | 0:4562b55bbb43 | 690 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 691 | */ |
wonner163 | 0:4562b55bbb43 | 692 | virtual void _setBL(bool value) = 0; |
wonner163 | 0:4562b55bbb43 | 693 | |
wonner163 | 0:4562b55bbb43 | 694 | /** Pure Virtual Low level writes to LCD Bus (serial or parallel) |
wonner163 | 0:4562b55bbb43 | 695 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 696 | */ |
wonner163 | 0:4562b55bbb43 | 697 | virtual void _setData(int value) = 0; |
wonner163 | 0:4562b55bbb43 | 698 | |
wonner163 | 0:4562b55bbb43 | 699 | /** Low level byte write operation to LCD controller (serial or parallel) |
wonner163 | 0:4562b55bbb43 | 700 | * Depending on the RS pin this byte will be interpreted as data or command |
wonner163 | 0:4562b55bbb43 | 701 | */ |
wonner163 | 0:4562b55bbb43 | 702 | virtual void _writeByte(int value); |
wonner163 | 0:4562b55bbb43 | 703 | |
wonner163 | 0:4562b55bbb43 | 704 | //Display type |
wonner163 | 0:4562b55bbb43 | 705 | LCDType _type; |
wonner163 | 0:4562b55bbb43 | 706 | int _nr_cols; |
wonner163 | 0:4562b55bbb43 | 707 | int _nr_rows; |
wonner163 | 0:4562b55bbb43 | 708 | int _addr_mode; |
wonner163 | 0:4562b55bbb43 | 709 | |
wonner163 | 0:4562b55bbb43 | 710 | //Display mode |
wonner163 | 0:4562b55bbb43 | 711 | LCDMode _currentMode; |
wonner163 | 0:4562b55bbb43 | 712 | |
wonner163 | 0:4562b55bbb43 | 713 | //Controller type |
wonner163 | 0:4562b55bbb43 | 714 | LCDCtrl _ctrl; |
wonner163 | 0:4562b55bbb43 | 715 | |
wonner163 | 0:4562b55bbb43 | 716 | //Controller select, mainly used for LCD40x4 |
wonner163 | 0:4562b55bbb43 | 717 | _LCDCtrl_Idx _ctrl_idx; |
wonner163 | 0:4562b55bbb43 | 718 | |
wonner163 | 0:4562b55bbb43 | 719 | // Cursor |
wonner163 | 0:4562b55bbb43 | 720 | int _column; |
wonner163 | 0:4562b55bbb43 | 721 | int _row; |
wonner163 | 0:4562b55bbb43 | 722 | LCDCursor _currentCursor; |
wonner163 | 0:4562b55bbb43 | 723 | |
wonner163 | 0:4562b55bbb43 | 724 | // Function mode saved to allow switch between Instruction sets after initialisation time |
wonner163 | 0:4562b55bbb43 | 725 | // Icon, Booster mode and contrast saved to allow contrast change at later time |
wonner163 | 0:4562b55bbb43 | 726 | // Only available for controllers with added features |
wonner163 | 0:4562b55bbb43 | 727 | int _function, _function_1, _function_x; |
wonner163 | 0:4562b55bbb43 | 728 | int _icon_power; |
wonner163 | 0:4562b55bbb43 | 729 | int _contrast; |
wonner163 | 0:4562b55bbb43 | 730 | |
wonner163 | 0:4562b55bbb43 | 731 | }; |
wonner163 | 0:4562b55bbb43 | 732 | |
wonner163 | 0:4562b55bbb43 | 733 | //--------- End TextLCD_Base ----------- |
wonner163 | 0:4562b55bbb43 | 734 | |
wonner163 | 0:4562b55bbb43 | 735 | |
wonner163 | 0:4562b55bbb43 | 736 | |
wonner163 | 0:4562b55bbb43 | 737 | //--------- Start TextLCD Bus ----------- |
wonner163 | 0:4562b55bbb43 | 738 | |
wonner163 | 0:4562b55bbb43 | 739 | /** Create a TextLCD interface for using regular mbed pins |
wonner163 | 0:4562b55bbb43 | 740 | * |
wonner163 | 0:4562b55bbb43 | 741 | */ |
wonner163 | 0:4562b55bbb43 | 742 | class TextLCD : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 743 | public: |
wonner163 | 0:4562b55bbb43 | 744 | /** Create a TextLCD interface for using regular mbed pins |
wonner163 | 0:4562b55bbb43 | 745 | * |
wonner163 | 0:4562b55bbb43 | 746 | * @param rs Instruction/data control line |
wonner163 | 0:4562b55bbb43 | 747 | * @param e Enable line (clock) |
wonner163 | 0:4562b55bbb43 | 748 | * @param d4-d7 Data lines for using as a 4-bit interface |
wonner163 | 0:4562b55bbb43 | 749 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 750 | * @param bl Backlight control line (optional, default = NC) |
wonner163 | 0:4562b55bbb43 | 751 | * @param e2 Enable2 line (clock for second controller, LCD40x4 only) |
wonner163 | 0:4562b55bbb43 | 752 | * @param ctrl LCD controller (default = HD44780) |
wonner163 | 0:4562b55bbb43 | 753 | */ |
wonner163 | 0:4562b55bbb43 | 754 | 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); |
wonner163 | 0:4562b55bbb43 | 755 | |
wonner163 | 0:4562b55bbb43 | 756 | /** Destruct a TextLCD interface for using regular mbed pins |
wonner163 | 0:4562b55bbb43 | 757 | * |
wonner163 | 0:4562b55bbb43 | 758 | * @param none |
wonner163 | 0:4562b55bbb43 | 759 | * @return none |
wonner163 | 0:4562b55bbb43 | 760 | */ |
wonner163 | 0:4562b55bbb43 | 761 | virtual ~TextLCD(); |
wonner163 | 0:4562b55bbb43 | 762 | |
wonner163 | 0:4562b55bbb43 | 763 | private: |
wonner163 | 0:4562b55bbb43 | 764 | |
wonner163 | 0:4562b55bbb43 | 765 | /** Implementation of pure Virtual Low level writes to LCD Bus (parallel) |
wonner163 | 0:4562b55bbb43 | 766 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 767 | */ |
wonner163 | 0:4562b55bbb43 | 768 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 769 | |
wonner163 | 0:4562b55bbb43 | 770 | /** Implementation of pure Virtual Low level writes to LCD Bus (parallel) |
wonner163 | 0:4562b55bbb43 | 771 | * Set the RS pin (0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 772 | */ |
wonner163 | 0:4562b55bbb43 | 773 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 774 | |
wonner163 | 0:4562b55bbb43 | 775 | /** Implementation of pure Virtual Low level writes to LCD Bus (parallel) |
wonner163 | 0:4562b55bbb43 | 776 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 777 | */ |
wonner163 | 0:4562b55bbb43 | 778 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 779 | |
wonner163 | 0:4562b55bbb43 | 780 | /** Implementation of pure Virtual Low level writes to LCD Bus (parallel) |
wonner163 | 0:4562b55bbb43 | 781 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 782 | */ |
wonner163 | 0:4562b55bbb43 | 783 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 784 | |
wonner163 | 0:4562b55bbb43 | 785 | |
wonner163 | 0:4562b55bbb43 | 786 | /** Regular mbed pins bus |
wonner163 | 0:4562b55bbb43 | 787 | */ |
wonner163 | 0:4562b55bbb43 | 788 | DigitalOut _rs, _e; |
wonner163 | 0:4562b55bbb43 | 789 | BusOut _d; |
wonner163 | 0:4562b55bbb43 | 790 | |
wonner163 | 0:4562b55bbb43 | 791 | /** Optional Hardware pins for the Backlight and LCD40x4 device |
wonner163 | 0:4562b55bbb43 | 792 | * Default PinName value is NC, must be used as pointer to avoid issues with mbed lib and DigitalOut pins |
wonner163 | 0:4562b55bbb43 | 793 | */ |
wonner163 | 0:4562b55bbb43 | 794 | DigitalOut *_bl, *_e2; |
wonner163 | 0:4562b55bbb43 | 795 | }; |
wonner163 | 0:4562b55bbb43 | 796 | |
wonner163 | 0:4562b55bbb43 | 797 | |
wonner163 | 0:4562b55bbb43 | 798 | //----------- End TextLCD --------------- |
wonner163 | 0:4562b55bbb43 | 799 | |
wonner163 | 0:4562b55bbb43 | 800 | |
wonner163 | 0:4562b55bbb43 | 801 | //--------- Start TextLCD_I2C ----------- |
wonner163 | 0:4562b55bbb43 | 802 | |
wonner163 | 0:4562b55bbb43 | 803 | |
wonner163 | 0:4562b55bbb43 | 804 | /** Create a TextLCD interface using an I2C PCF8574 (or PCF8574A) or MCP23008 portexpander |
wonner163 | 0:4562b55bbb43 | 805 | * |
wonner163 | 0:4562b55bbb43 | 806 | */ |
wonner163 | 0:4562b55bbb43 | 807 | class TextLCD_I2C : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 808 | public: |
wonner163 | 0:4562b55bbb43 | 809 | /** Create a TextLCD interface using an I2C PCF8574 (or PCF8574A) or MCP23008 portexpander |
wonner163 | 0:4562b55bbb43 | 810 | * |
wonner163 | 0:4562b55bbb43 | 811 | * @param i2c I2C Bus |
wonner163 | 0:4562b55bbb43 | 812 | * @param deviceAddress I2C slave address (PCF8574 or PCF8574A, default = PCF8574_SA0 = 0x40) |
wonner163 | 0:4562b55bbb43 | 813 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 814 | * @param ctrl LCD controller (default = HD44780) |
wonner163 | 0:4562b55bbb43 | 815 | */ |
wonner163 | 0:4562b55bbb43 | 816 | TextLCD_I2C(I2C *i2c, char deviceAddress = PCF8574_SA0, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780); |
wonner163 | 0:4562b55bbb43 | 817 | |
wonner163 | 0:4562b55bbb43 | 818 | private: |
wonner163 | 0:4562b55bbb43 | 819 | |
wonner163 | 0:4562b55bbb43 | 820 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 821 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 822 | */ |
wonner163 | 0:4562b55bbb43 | 823 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 824 | |
wonner163 | 0:4562b55bbb43 | 825 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 826 | * Set the RS pin (0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 827 | */ |
wonner163 | 0:4562b55bbb43 | 828 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 829 | |
wonner163 | 0:4562b55bbb43 | 830 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 831 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 832 | */ |
wonner163 | 0:4562b55bbb43 | 833 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 834 | |
wonner163 | 0:4562b55bbb43 | 835 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 836 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 837 | */ |
wonner163 | 0:4562b55bbb43 | 838 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 839 | |
wonner163 | 0:4562b55bbb43 | 840 | /** Write data to MCP23008 I2C portexpander |
wonner163 | 0:4562b55bbb43 | 841 | * @param reg register to write |
wonner163 | 0:4562b55bbb43 | 842 | * @param value data to write |
wonner163 | 0:4562b55bbb43 | 843 | * @return none |
wonner163 | 0:4562b55bbb43 | 844 | * |
wonner163 | 0:4562b55bbb43 | 845 | */ |
wonner163 | 0:4562b55bbb43 | 846 | void _write_register (int reg, int value); |
wonner163 | 0:4562b55bbb43 | 847 | |
wonner163 | 0:4562b55bbb43 | 848 | //I2C bus |
wonner163 | 0:4562b55bbb43 | 849 | I2C *_i2c; |
wonner163 | 0:4562b55bbb43 | 850 | char _slaveAddress; |
wonner163 | 0:4562b55bbb43 | 851 | |
wonner163 | 0:4562b55bbb43 | 852 | // Internal bus mirror value for serial bus only |
wonner163 | 0:4562b55bbb43 | 853 | char _lcd_bus; |
wonner163 | 0:4562b55bbb43 | 854 | }; |
wonner163 | 0:4562b55bbb43 | 855 | |
wonner163 | 0:4562b55bbb43 | 856 | //---------- End TextLCD_I2C ------------ |
wonner163 | 0:4562b55bbb43 | 857 | |
wonner163 | 0:4562b55bbb43 | 858 | |
wonner163 | 0:4562b55bbb43 | 859 | //--------- Start TextLCD_SPI ----------- |
wonner163 | 0:4562b55bbb43 | 860 | |
wonner163 | 0:4562b55bbb43 | 861 | /** Create a TextLCD interface using an SPI 74595 portexpander |
wonner163 | 0:4562b55bbb43 | 862 | * |
wonner163 | 0:4562b55bbb43 | 863 | */ |
wonner163 | 0:4562b55bbb43 | 864 | class TextLCD_SPI : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 865 | public: |
wonner163 | 0:4562b55bbb43 | 866 | /** Create a TextLCD interface using an SPI 74595 portexpander |
wonner163 | 0:4562b55bbb43 | 867 | * |
wonner163 | 0:4562b55bbb43 | 868 | * @param spi SPI Bus |
wonner163 | 0:4562b55bbb43 | 869 | * @param cs chip select pin (active low) |
wonner163 | 0:4562b55bbb43 | 870 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 871 | * @param ctrl LCD controller (default = HD44780) |
wonner163 | 0:4562b55bbb43 | 872 | */ |
wonner163 | 0:4562b55bbb43 | 873 | TextLCD_SPI(SPI *spi, PinName cs, LCDType type = LCD16x2, LCDCtrl ctrl = HD44780); |
wonner163 | 0:4562b55bbb43 | 874 | |
wonner163 | 0:4562b55bbb43 | 875 | private: |
wonner163 | 0:4562b55bbb43 | 876 | |
wonner163 | 0:4562b55bbb43 | 877 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 878 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 879 | */ |
wonner163 | 0:4562b55bbb43 | 880 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 881 | |
wonner163 | 0:4562b55bbb43 | 882 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 883 | * Set the RS pin (0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 884 | */ |
wonner163 | 0:4562b55bbb43 | 885 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 886 | |
wonner163 | 0:4562b55bbb43 | 887 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 888 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 889 | */ |
wonner163 | 0:4562b55bbb43 | 890 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 891 | |
wonner163 | 0:4562b55bbb43 | 892 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 893 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 894 | */ |
wonner163 | 0:4562b55bbb43 | 895 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 896 | |
wonner163 | 0:4562b55bbb43 | 897 | /** Implementation of Low level writes to LCD Bus (serial expander) |
wonner163 | 0:4562b55bbb43 | 898 | * Set the CS pin (0 = select, 1 = deselect). |
wonner163 | 0:4562b55bbb43 | 899 | */ |
wonner163 | 0:4562b55bbb43 | 900 | virtual void _setCS(bool value); |
wonner163 | 0:4562b55bbb43 | 901 | |
wonner163 | 0:4562b55bbb43 | 902 | ///** Low level writes to LCD serial bus only (serial expander) |
wonner163 | 0:4562b55bbb43 | 903 | // */ |
wonner163 | 0:4562b55bbb43 | 904 | // void _writeBus(); |
wonner163 | 0:4562b55bbb43 | 905 | |
wonner163 | 0:4562b55bbb43 | 906 | // SPI bus |
wonner163 | 0:4562b55bbb43 | 907 | SPI *_spi; |
wonner163 | 0:4562b55bbb43 | 908 | DigitalOut _cs; |
wonner163 | 0:4562b55bbb43 | 909 | |
wonner163 | 0:4562b55bbb43 | 910 | // Internal bus mirror value for serial bus only |
wonner163 | 0:4562b55bbb43 | 911 | char _lcd_bus; |
wonner163 | 0:4562b55bbb43 | 912 | }; |
wonner163 | 0:4562b55bbb43 | 913 | |
wonner163 | 0:4562b55bbb43 | 914 | //---------- End TextLCD_SPI ------------ |
wonner163 | 0:4562b55bbb43 | 915 | |
wonner163 | 0:4562b55bbb43 | 916 | |
wonner163 | 0:4562b55bbb43 | 917 | //--------- Start TextLCD_SPI_N ----------- |
wonner163 | 0:4562b55bbb43 | 918 | |
wonner163 | 0:4562b55bbb43 | 919 | /** Create a TextLCD interface using a controller with native SPI4 interface |
wonner163 | 0:4562b55bbb43 | 920 | * |
wonner163 | 0:4562b55bbb43 | 921 | */ |
wonner163 | 0:4562b55bbb43 | 922 | class TextLCD_SPI_N : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 923 | public: |
wonner163 | 0:4562b55bbb43 | 924 | /** Create a TextLCD interface using a controller with native SPI4 interface |
wonner163 | 0:4562b55bbb43 | 925 | * |
wonner163 | 0:4562b55bbb43 | 926 | * @param spi SPI Bus |
wonner163 | 0:4562b55bbb43 | 927 | * @param cs chip select pin (active low) |
wonner163 | 0:4562b55bbb43 | 928 | * @param rs Instruction/data control line |
wonner163 | 0:4562b55bbb43 | 929 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 930 | * @param bl Backlight control line (optional, default = NC) |
wonner163 | 0:4562b55bbb43 | 931 | * @param ctrl LCD controller (default = ST7032_3V3) |
wonner163 | 0:4562b55bbb43 | 932 | */ |
wonner163 | 0:4562b55bbb43 | 933 | TextLCD_SPI_N(SPI *spi, PinName cs, PinName rs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7032_3V3); |
wonner163 | 0:4562b55bbb43 | 934 | virtual ~TextLCD_SPI_N(void); |
wonner163 | 0:4562b55bbb43 | 935 | |
wonner163 | 0:4562b55bbb43 | 936 | private: |
wonner163 | 0:4562b55bbb43 | 937 | |
wonner163 | 0:4562b55bbb43 | 938 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 939 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 940 | */ |
wonner163 | 0:4562b55bbb43 | 941 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 942 | |
wonner163 | 0:4562b55bbb43 | 943 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 944 | * Set the RS pin (0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 945 | */ |
wonner163 | 0:4562b55bbb43 | 946 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 947 | |
wonner163 | 0:4562b55bbb43 | 948 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 949 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 950 | */ |
wonner163 | 0:4562b55bbb43 | 951 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 952 | |
wonner163 | 0:4562b55bbb43 | 953 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 954 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 955 | */ |
wonner163 | 0:4562b55bbb43 | 956 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 957 | |
wonner163 | 0:4562b55bbb43 | 958 | /** Low level writes to LCD serial bus only (serial native) |
wonner163 | 0:4562b55bbb43 | 959 | */ |
wonner163 | 0:4562b55bbb43 | 960 | virtual void _writeByte(int value); |
wonner163 | 0:4562b55bbb43 | 961 | |
wonner163 | 0:4562b55bbb43 | 962 | // SPI bus |
wonner163 | 0:4562b55bbb43 | 963 | SPI *_spi; |
wonner163 | 0:4562b55bbb43 | 964 | DigitalOut _cs; |
wonner163 | 0:4562b55bbb43 | 965 | DigitalOut _rs; |
wonner163 | 0:4562b55bbb43 | 966 | |
wonner163 | 0:4562b55bbb43 | 967 | //Backlight |
wonner163 | 0:4562b55bbb43 | 968 | DigitalOut *_bl; |
wonner163 | 0:4562b55bbb43 | 969 | }; |
wonner163 | 0:4562b55bbb43 | 970 | |
wonner163 | 0:4562b55bbb43 | 971 | //---------- End TextLCD_SPI_N ------------ |
wonner163 | 0:4562b55bbb43 | 972 | |
wonner163 | 0:4562b55bbb43 | 973 | |
wonner163 | 0:4562b55bbb43 | 974 | #if(1) |
wonner163 | 0:4562b55bbb43 | 975 | //Code checked out on logic analyser. Not yet tested on hardware.. |
wonner163 | 0:4562b55bbb43 | 976 | |
wonner163 | 0:4562b55bbb43 | 977 | //------- Start TextLCD_SPI_N_3_9 --------- |
wonner163 | 0:4562b55bbb43 | 978 | |
wonner163 | 0:4562b55bbb43 | 979 | /** Create a TextLCD interface using a controller with native SPI3 9 bits interface |
wonner163 | 0:4562b55bbb43 | 980 | * Note: current mbed libs only support SPI 9 bit mode for NXP platforms |
wonner163 | 0:4562b55bbb43 | 981 | * |
wonner163 | 0:4562b55bbb43 | 982 | */ |
wonner163 | 0:4562b55bbb43 | 983 | class TextLCD_SPI_N_3_9 : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 984 | public: |
wonner163 | 0:4562b55bbb43 | 985 | /** Create a TextLCD interface using a controller with native SPI3 9 bits interface |
wonner163 | 0:4562b55bbb43 | 986 | * Note: current mbed libs only support SPI 9 bit mode for NXP platforms |
wonner163 | 0:4562b55bbb43 | 987 | * |
wonner163 | 0:4562b55bbb43 | 988 | * @param spi SPI Bus |
wonner163 | 0:4562b55bbb43 | 989 | * @param cs chip select pin (active low) |
wonner163 | 0:4562b55bbb43 | 990 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 991 | * @param bl Backlight control line (optional, default = NC) |
wonner163 | 0:4562b55bbb43 | 992 | * @param ctrl LCD controller (default = AIP31068) |
wonner163 | 0:4562b55bbb43 | 993 | */ |
wonner163 | 0:4562b55bbb43 | 994 | TextLCD_SPI_N_3_9(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = AIP31068); |
wonner163 | 0:4562b55bbb43 | 995 | virtual ~TextLCD_SPI_N_3_9(void); |
wonner163 | 0:4562b55bbb43 | 996 | |
wonner163 | 0:4562b55bbb43 | 997 | private: |
wonner163 | 0:4562b55bbb43 | 998 | |
wonner163 | 0:4562b55bbb43 | 999 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1000 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 1001 | */ |
wonner163 | 0:4562b55bbb43 | 1002 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 1003 | |
wonner163 | 0:4562b55bbb43 | 1004 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1005 | * Set the RS pin (0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 1006 | */ |
wonner163 | 0:4562b55bbb43 | 1007 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 1008 | |
wonner163 | 0:4562b55bbb43 | 1009 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1010 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 1011 | */ |
wonner163 | 0:4562b55bbb43 | 1012 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 1013 | |
wonner163 | 0:4562b55bbb43 | 1014 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1015 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 1016 | */ |
wonner163 | 0:4562b55bbb43 | 1017 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 1018 | |
wonner163 | 0:4562b55bbb43 | 1019 | /** Low level writes to LCD serial bus only (serial native) |
wonner163 | 0:4562b55bbb43 | 1020 | */ |
wonner163 | 0:4562b55bbb43 | 1021 | virtual void _writeByte(int value); |
wonner163 | 0:4562b55bbb43 | 1022 | |
wonner163 | 0:4562b55bbb43 | 1023 | // SPI bus |
wonner163 | 0:4562b55bbb43 | 1024 | SPI *_spi; |
wonner163 | 0:4562b55bbb43 | 1025 | DigitalOut _cs; |
wonner163 | 0:4562b55bbb43 | 1026 | |
wonner163 | 0:4562b55bbb43 | 1027 | |
wonner163 | 0:4562b55bbb43 | 1028 | // controlbyte to select between data and command. Internal value for serial bus only |
wonner163 | 0:4562b55bbb43 | 1029 | char _controlbyte; |
wonner163 | 0:4562b55bbb43 | 1030 | |
wonner163 | 0:4562b55bbb43 | 1031 | //Backlight |
wonner163 | 0:4562b55bbb43 | 1032 | DigitalOut *_bl; |
wonner163 | 0:4562b55bbb43 | 1033 | }; |
wonner163 | 0:4562b55bbb43 | 1034 | |
wonner163 | 0:4562b55bbb43 | 1035 | //-------- End TextLCD_SPI_N_3_9 ---------- |
wonner163 | 0:4562b55bbb43 | 1036 | #endif |
wonner163 | 0:4562b55bbb43 | 1037 | |
wonner163 | 0:4562b55bbb43 | 1038 | |
wonner163 | 0:4562b55bbb43 | 1039 | #if(1) |
wonner163 | 0:4562b55bbb43 | 1040 | //------- Start TextLCD_SPI_N_3_10 --------- |
wonner163 | 0:4562b55bbb43 | 1041 | |
wonner163 | 0:4562b55bbb43 | 1042 | /** Create a TextLCD interface using a controller with native SPI3 10 bits interface |
wonner163 | 0:4562b55bbb43 | 1043 | * Note: current mbed libs only support SPI 10 bit mode for NXP platforms |
wonner163 | 0:4562b55bbb43 | 1044 | * |
wonner163 | 0:4562b55bbb43 | 1045 | */ |
wonner163 | 0:4562b55bbb43 | 1046 | class TextLCD_SPI_N_3_10 : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 1047 | public: |
wonner163 | 0:4562b55bbb43 | 1048 | /** Create a TextLCD interface using a controller with native SPI3 10 bits interface |
wonner163 | 0:4562b55bbb43 | 1049 | * Note: current mbed libs only support SPI 10 bit mode for NXP platforms |
wonner163 | 0:4562b55bbb43 | 1050 | * |
wonner163 | 0:4562b55bbb43 | 1051 | * @param spi SPI Bus |
wonner163 | 0:4562b55bbb43 | 1052 | * @param cs chip select pin (active low) |
wonner163 | 0:4562b55bbb43 | 1053 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 1054 | * @param bl Backlight control line (optional, default = NC) |
wonner163 | 0:4562b55bbb43 | 1055 | * @param ctrl LCD controller (default = AIP31068) |
wonner163 | 0:4562b55bbb43 | 1056 | */ |
wonner163 | 0:4562b55bbb43 | 1057 | TextLCD_SPI_N_3_10(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = AIP31068); |
wonner163 | 0:4562b55bbb43 | 1058 | virtual ~TextLCD_SPI_N_3_10(void); |
wonner163 | 0:4562b55bbb43 | 1059 | |
wonner163 | 0:4562b55bbb43 | 1060 | private: |
wonner163 | 0:4562b55bbb43 | 1061 | |
wonner163 | 0:4562b55bbb43 | 1062 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1063 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 1064 | */ |
wonner163 | 0:4562b55bbb43 | 1065 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 1066 | |
wonner163 | 0:4562b55bbb43 | 1067 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1068 | * Set the RS pin (0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 1069 | */ |
wonner163 | 0:4562b55bbb43 | 1070 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 1071 | |
wonner163 | 0:4562b55bbb43 | 1072 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1073 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 1074 | */ |
wonner163 | 0:4562b55bbb43 | 1075 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 1076 | |
wonner163 | 0:4562b55bbb43 | 1077 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1078 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 1079 | */ |
wonner163 | 0:4562b55bbb43 | 1080 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 1081 | |
wonner163 | 0:4562b55bbb43 | 1082 | /** Low level writes to LCD serial bus only (serial native) |
wonner163 | 0:4562b55bbb43 | 1083 | */ |
wonner163 | 0:4562b55bbb43 | 1084 | virtual void _writeByte(int value); |
wonner163 | 0:4562b55bbb43 | 1085 | |
wonner163 | 0:4562b55bbb43 | 1086 | // SPI bus |
wonner163 | 0:4562b55bbb43 | 1087 | SPI *_spi; |
wonner163 | 0:4562b55bbb43 | 1088 | DigitalOut _cs; |
wonner163 | 0:4562b55bbb43 | 1089 | |
wonner163 | 0:4562b55bbb43 | 1090 | |
wonner163 | 0:4562b55bbb43 | 1091 | // controlbyte to select between data and command. Internal value for serial bus only |
wonner163 | 0:4562b55bbb43 | 1092 | char _controlbyte; |
wonner163 | 0:4562b55bbb43 | 1093 | |
wonner163 | 0:4562b55bbb43 | 1094 | //Backlight |
wonner163 | 0:4562b55bbb43 | 1095 | DigitalOut *_bl; |
wonner163 | 0:4562b55bbb43 | 1096 | }; |
wonner163 | 0:4562b55bbb43 | 1097 | |
wonner163 | 0:4562b55bbb43 | 1098 | //-------- End TextLCD_SPI_N_3_10 ---------- |
wonner163 | 0:4562b55bbb43 | 1099 | #endif |
wonner163 | 0:4562b55bbb43 | 1100 | |
wonner163 | 0:4562b55bbb43 | 1101 | #if(0) |
wonner163 | 0:4562b55bbb43 | 1102 | //Code not yet checked out on logic analyser. Not yet tested on hardware.. |
wonner163 | 0:4562b55bbb43 | 1103 | |
wonner163 | 0:4562b55bbb43 | 1104 | //------- Start TextLCD_SPI_N_3_16 --------- |
wonner163 | 0:4562b55bbb43 | 1105 | |
wonner163 | 0:4562b55bbb43 | 1106 | /** Create a TextLCD interface using a controller with native SPI3 16 bits interface |
wonner163 | 0:4562b55bbb43 | 1107 | * |
wonner163 | 0:4562b55bbb43 | 1108 | */ |
wonner163 | 0:4562b55bbb43 | 1109 | class TextLCD_SPI_N_3_16 : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 1110 | public: |
wonner163 | 0:4562b55bbb43 | 1111 | /** Create a TextLCD interface using a controller with native SPI3 16 bits interface |
wonner163 | 0:4562b55bbb43 | 1112 | * |
wonner163 | 0:4562b55bbb43 | 1113 | * @param spi SPI Bus |
wonner163 | 0:4562b55bbb43 | 1114 | * @param cs chip select pin (active low) |
wonner163 | 0:4562b55bbb43 | 1115 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 1116 | * @param bl Backlight control line (optional, default = NC) |
wonner163 | 0:4562b55bbb43 | 1117 | * @param ctrl LCD controller (default = PT6314) |
wonner163 | 0:4562b55bbb43 | 1118 | */ |
wonner163 | 0:4562b55bbb43 | 1119 | TextLCD_SPI_N_3_16(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = PT6314); |
wonner163 | 0:4562b55bbb43 | 1120 | virtual ~TextLCD_SPI_N_3_16(void); |
wonner163 | 0:4562b55bbb43 | 1121 | |
wonner163 | 0:4562b55bbb43 | 1122 | private: |
wonner163 | 0:4562b55bbb43 | 1123 | |
wonner163 | 0:4562b55bbb43 | 1124 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1125 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 1126 | */ |
wonner163 | 0:4562b55bbb43 | 1127 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 1128 | |
wonner163 | 0:4562b55bbb43 | 1129 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1130 | * Set the RS pin (0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 1131 | */ |
wonner163 | 0:4562b55bbb43 | 1132 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 1133 | |
wonner163 | 0:4562b55bbb43 | 1134 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1135 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 1136 | */ |
wonner163 | 0:4562b55bbb43 | 1137 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 1138 | |
wonner163 | 0:4562b55bbb43 | 1139 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1140 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 1141 | */ |
wonner163 | 0:4562b55bbb43 | 1142 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 1143 | |
wonner163 | 0:4562b55bbb43 | 1144 | /** Low level writes to LCD serial bus only (serial native) |
wonner163 | 0:4562b55bbb43 | 1145 | */ |
wonner163 | 0:4562b55bbb43 | 1146 | virtual void _writeByte(int value); |
wonner163 | 0:4562b55bbb43 | 1147 | |
wonner163 | 0:4562b55bbb43 | 1148 | // SPI bus |
wonner163 | 0:4562b55bbb43 | 1149 | SPI *_spi; |
wonner163 | 0:4562b55bbb43 | 1150 | DigitalOut _cs; |
wonner163 | 0:4562b55bbb43 | 1151 | |
wonner163 | 0:4562b55bbb43 | 1152 | // controlbyte to select between data and command. Internal value for serial bus only |
wonner163 | 0:4562b55bbb43 | 1153 | char _controlbyte; |
wonner163 | 0:4562b55bbb43 | 1154 | |
wonner163 | 0:4562b55bbb43 | 1155 | //Backlight |
wonner163 | 0:4562b55bbb43 | 1156 | DigitalOut *_bl; |
wonner163 | 0:4562b55bbb43 | 1157 | }; |
wonner163 | 0:4562b55bbb43 | 1158 | |
wonner163 | 0:4562b55bbb43 | 1159 | //-------- End TextLCD_SPI_N_3_16 ---------- |
wonner163 | 0:4562b55bbb43 | 1160 | #endif |
wonner163 | 0:4562b55bbb43 | 1161 | |
wonner163 | 0:4562b55bbb43 | 1162 | #if(1) |
wonner163 | 0:4562b55bbb43 | 1163 | //------- Start TextLCD_SPI_N_3_24 --------- |
wonner163 | 0:4562b55bbb43 | 1164 | |
wonner163 | 0:4562b55bbb43 | 1165 | /** Create a TextLCD interface using a controller with native SPI3 24 bits interface |
wonner163 | 0:4562b55bbb43 | 1166 | * Note: lib uses SPI 8 bit mode |
wonner163 | 0:4562b55bbb43 | 1167 | * |
wonner163 | 0:4562b55bbb43 | 1168 | */ |
wonner163 | 0:4562b55bbb43 | 1169 | class TextLCD_SPI_N_3_24 : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 1170 | public: |
wonner163 | 0:4562b55bbb43 | 1171 | /** Create a TextLCD interface using a controller with native SPI3 24 bits interface |
wonner163 | 0:4562b55bbb43 | 1172 | * Note: lib uses SPI 8 bit mode |
wonner163 | 0:4562b55bbb43 | 1173 | * |
wonner163 | 0:4562b55bbb43 | 1174 | * @param spi SPI Bus |
wonner163 | 0:4562b55bbb43 | 1175 | * @param cs chip select pin (active low) |
wonner163 | 0:4562b55bbb43 | 1176 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 1177 | * @param bl Backlight control line (optional, default = NC) |
wonner163 | 0:4562b55bbb43 | 1178 | * @param ctrl LCD controller (default = SSD1803) |
wonner163 | 0:4562b55bbb43 | 1179 | */ |
wonner163 | 0:4562b55bbb43 | 1180 | TextLCD_SPI_N_3_24(SPI *spi, PinName cs, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = SSD1803_3V3); |
wonner163 | 0:4562b55bbb43 | 1181 | virtual ~TextLCD_SPI_N_3_24(void); |
wonner163 | 0:4562b55bbb43 | 1182 | |
wonner163 | 0:4562b55bbb43 | 1183 | private: |
wonner163 | 0:4562b55bbb43 | 1184 | |
wonner163 | 0:4562b55bbb43 | 1185 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1186 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 1187 | */ |
wonner163 | 0:4562b55bbb43 | 1188 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 1189 | |
wonner163 | 0:4562b55bbb43 | 1190 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1191 | * Set the RS pin (0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 1192 | */ |
wonner163 | 0:4562b55bbb43 | 1193 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 1194 | |
wonner163 | 0:4562b55bbb43 | 1195 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1196 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 1197 | */ |
wonner163 | 0:4562b55bbb43 | 1198 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 1199 | |
wonner163 | 0:4562b55bbb43 | 1200 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1201 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 1202 | */ |
wonner163 | 0:4562b55bbb43 | 1203 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 1204 | |
wonner163 | 0:4562b55bbb43 | 1205 | /** Low level writes to LCD serial bus only (serial native) |
wonner163 | 0:4562b55bbb43 | 1206 | */ |
wonner163 | 0:4562b55bbb43 | 1207 | virtual void _writeByte(int value); |
wonner163 | 0:4562b55bbb43 | 1208 | |
wonner163 | 0:4562b55bbb43 | 1209 | // SPI bus |
wonner163 | 0:4562b55bbb43 | 1210 | SPI *_spi; |
wonner163 | 0:4562b55bbb43 | 1211 | DigitalOut _cs; |
wonner163 | 0:4562b55bbb43 | 1212 | |
wonner163 | 0:4562b55bbb43 | 1213 | // controlbyte to select between data and command. Internal value for serial bus only |
wonner163 | 0:4562b55bbb43 | 1214 | char _controlbyte; |
wonner163 | 0:4562b55bbb43 | 1215 | |
wonner163 | 0:4562b55bbb43 | 1216 | //Backlight |
wonner163 | 0:4562b55bbb43 | 1217 | DigitalOut *_bl; |
wonner163 | 0:4562b55bbb43 | 1218 | }; |
wonner163 | 0:4562b55bbb43 | 1219 | |
wonner163 | 0:4562b55bbb43 | 1220 | //-------- End TextLCD_SPI_N_3_24 ---------- |
wonner163 | 0:4562b55bbb43 | 1221 | #endif |
wonner163 | 0:4562b55bbb43 | 1222 | |
wonner163 | 0:4562b55bbb43 | 1223 | |
wonner163 | 0:4562b55bbb43 | 1224 | //--------- Start TextLCD_I2C_N ----------- |
wonner163 | 0:4562b55bbb43 | 1225 | |
wonner163 | 0:4562b55bbb43 | 1226 | /** Create a TextLCD interface using a controller with native I2C interface |
wonner163 | 0:4562b55bbb43 | 1227 | * |
wonner163 | 0:4562b55bbb43 | 1228 | */ |
wonner163 | 0:4562b55bbb43 | 1229 | class TextLCD_I2C_N : public TextLCD_Base { |
wonner163 | 0:4562b55bbb43 | 1230 | public: |
wonner163 | 0:4562b55bbb43 | 1231 | /** Create a TextLCD interface using a controller with native I2C interface |
wonner163 | 0:4562b55bbb43 | 1232 | * |
wonner163 | 0:4562b55bbb43 | 1233 | * @param i2c I2C Bus |
wonner163 | 0:4562b55bbb43 | 1234 | * @param deviceAddress I2C slave address (default = ST7032_SA = 0x7C) |
wonner163 | 0:4562b55bbb43 | 1235 | * @param type Sets the panel size/addressing mode (default = LCD16x2) |
wonner163 | 0:4562b55bbb43 | 1236 | * @param bl Backlight control line (optional, default = NC) |
wonner163 | 0:4562b55bbb43 | 1237 | * @param ctrl LCD controller (default = ST7032_3V3) |
wonner163 | 0:4562b55bbb43 | 1238 | */ |
wonner163 | 0:4562b55bbb43 | 1239 | TextLCD_I2C_N(I2C *i2c, char deviceAddress = ST7032_SA, LCDType type = LCD16x2, PinName bl = NC, LCDCtrl ctrl = ST7032_3V3); |
wonner163 | 0:4562b55bbb43 | 1240 | virtual ~TextLCD_I2C_N(void); |
wonner163 | 0:4562b55bbb43 | 1241 | |
wonner163 | 0:4562b55bbb43 | 1242 | private: |
wonner163 | 0:4562b55bbb43 | 1243 | |
wonner163 | 0:4562b55bbb43 | 1244 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1245 | * Set the Enable pin. |
wonner163 | 0:4562b55bbb43 | 1246 | */ |
wonner163 | 0:4562b55bbb43 | 1247 | virtual void _setEnable(bool value); |
wonner163 | 0:4562b55bbb43 | 1248 | |
wonner163 | 0:4562b55bbb43 | 1249 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1250 | * Set the RS pin ( 0 = Command, 1 = Data). |
wonner163 | 0:4562b55bbb43 | 1251 | */ |
wonner163 | 0:4562b55bbb43 | 1252 | virtual void _setRS(bool value); |
wonner163 | 0:4562b55bbb43 | 1253 | |
wonner163 | 0:4562b55bbb43 | 1254 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1255 | * Set the BL pin (0 = Backlight Off, 1 = Backlight On). |
wonner163 | 0:4562b55bbb43 | 1256 | */ |
wonner163 | 0:4562b55bbb43 | 1257 | virtual void _setBL(bool value); |
wonner163 | 0:4562b55bbb43 | 1258 | |
wonner163 | 0:4562b55bbb43 | 1259 | /** Implementation of pure Virtual Low level writes to LCD Bus (serial native) |
wonner163 | 0:4562b55bbb43 | 1260 | * Set the databus value (4 bit). |
wonner163 | 0:4562b55bbb43 | 1261 | */ |
wonner163 | 0:4562b55bbb43 | 1262 | virtual void _setData(int value); |
wonner163 | 0:4562b55bbb43 | 1263 | |
wonner163 | 0:4562b55bbb43 | 1264 | /** Low level writes to LCD serial bus only (serial native) |
wonner163 | 0:4562b55bbb43 | 1265 | */ |
wonner163 | 0:4562b55bbb43 | 1266 | virtual void _writeByte(int value); |
wonner163 | 0:4562b55bbb43 | 1267 | |
wonner163 | 0:4562b55bbb43 | 1268 | //I2C bus |
wonner163 | 0:4562b55bbb43 | 1269 | I2C *_i2c; |
wonner163 | 0:4562b55bbb43 | 1270 | char _slaveAddress; |
wonner163 | 0:4562b55bbb43 | 1271 | |
wonner163 | 0:4562b55bbb43 | 1272 | // controlbyte to select between data and command. Internal value for serial bus only |
wonner163 | 0:4562b55bbb43 | 1273 | char _controlbyte; |
wonner163 | 0:4562b55bbb43 | 1274 | |
wonner163 | 0:4562b55bbb43 | 1275 | //Backlight |
wonner163 | 0:4562b55bbb43 | 1276 | DigitalOut *_bl; |
wonner163 | 0:4562b55bbb43 | 1277 | |
wonner163 | 0:4562b55bbb43 | 1278 | }; |
wonner163 | 0:4562b55bbb43 | 1279 | |
wonner163 | 0:4562b55bbb43 | 1280 | //---------- End TextLCD_I2C_N ------------ |
wonner163 | 0:4562b55bbb43 | 1281 | |
wonner163 | 0:4562b55bbb43 | 1282 | |
wonner163 | 0:4562b55bbb43 | 1283 | #endif |