Wim Huiskamp / TextLCD

Committer:
wim
Date:
Sat Mar 02 16:51:01 2013 +0000
Revision:
17:652ab113bc2e
Parent:
16:c276b75e6585
Child:
18:bd65dc10f27f
Added support for Display On/Off. Improved 4bit bootprocess.

Who changed what in which revision?

UserRevisionLine numberNew 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
simon 1:ac48b187213c 7 *
simon 1:ac48b187213c 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
simon 1:ac48b187213c 9 * of this software and associated documentation files (the "Software"), to deal
simon 1:ac48b187213c 10 * in the Software without restriction, including without limitation the rights
simon 1:ac48b187213c 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
simon 1:ac48b187213c 12 * copies of the Software, and to permit persons to whom the Software is
simon 1:ac48b187213c 13 * furnished to do so, subject to the following conditions:
simon 2:227356c7d12c 14 *
simon 1:ac48b187213c 15 * The above copyright notice and this permission notice shall be included in
simon 1:ac48b187213c 16 * all copies or substantial portions of the Software.
simon 2:227356c7d12c 17 *
simon 1:ac48b187213c 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
simon 1:ac48b187213c 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
simon 1:ac48b187213c 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
simon 1:ac48b187213c 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
simon 1:ac48b187213c 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 1:ac48b187213c 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
simon 1:ac48b187213c 24 * THE SOFTWARE.
simon 1:ac48b187213c 25 */
simon 1:ac48b187213c 26
simon 1:ac48b187213c 27 #ifndef MBED_TEXTLCD_H
simon 1:ac48b187213c 28 #define MBED_TEXTLCD_H
simon 1:ac48b187213c 29
simon 1:ac48b187213c 30 #include "mbed.h"
simon 2:227356c7d12c 31
wim 15:b70ebfffb258 32
simon 5:a53b3e2d6f1e 33 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
simon 2:227356c7d12c 34 *
wim 16:c276b75e6585 35 * Currently supports 8x1, 8x2, 12x4, 16x1, 16x2, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels
wim 16:c276b75e6585 36 * Interface options include direct mbed pins, I2C portexpander (PCF8474) or SPI bus shiftregister (74595)
simon 2:227356c7d12c 37 *
simon 2:227356c7d12c 38 * @code
simon 2:227356c7d12c 39 * #include "mbed.h"
simon 2:227356c7d12c 40 * #include "TextLCD.h"
simon 5:a53b3e2d6f1e 41 *
wim 16:c276b75e6585 42 * // I2C Communication
wim 16:c276b75e6585 43 * I2C i2c_lcd(p28,p27); // SDA, SCL
wim 16:c276b75e6585 44 *
wim 16:c276b75e6585 45 * // SPI Communication
wim 16:c276b75e6585 46 * SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK
wim 16:c276b75e6585 47 *
wim 16:c276b75e6585 48 * TextLCD lcd(p15, p16, p17, p18, p19, p20); // RS, E, D4-D7, LCDType=LCD16x2
wim 16:c276b75e6585 49 * //TextLCD lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type
wim 16:c276b75e6585 50 * //TextLCD lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type
simon 5:a53b3e2d6f1e 51 *
simon 2:227356c7d12c 52 * int main() {
wim 16:c276b75e6585 53 * lcd.printf("Hello World!\n");
simon 2:227356c7d12c 54 * }
simon 2:227356c7d12c 55 * @endcode
simon 2:227356c7d12c 56 */
wim 8:03116f75b66e 57
wim 13:24506ba22480 58
wim 16:c276b75e6585 59 //Pin Defines for I2C PCF8574 and SPI 74595 Bus interfaces
wim 13:24506ba22480 60 //LCD and serial portexpanders should be wired accordingly
wim 13:24506ba22480 61 //Note: LCD RW pin must be connected to GND
wim 15:b70ebfffb258 62 // E2 is used for LCD40x4 (second controller)
wim 13:24506ba22480 63 // BL may be used for future expansion to control backlight
wim 13:24506ba22480 64 //
wim 15:b70ebfffb258 65 #define D_LCD_PIN_D4 0
wim 15:b70ebfffb258 66 #define D_LCD_PIN_D5 1
wim 15:b70ebfffb258 67 #define D_LCD_PIN_D6 2
wim 15:b70ebfffb258 68 #define D_LCD_PIN_D7 3
wim 15:b70ebfffb258 69 #define D_LCD_PIN_RS 4
wim 15:b70ebfffb258 70 #define D_LCD_PIN_E 5
wim 15:b70ebfffb258 71 #define D_LCD_PIN_E2 6
wim 15:b70ebfffb258 72 #define D_LCD_PIN_BL 7
wim 13:24506ba22480 73
wim 13:24506ba22480 74 #define D_LCD_BUS_MSK 0x0F
wim 15:b70ebfffb258 75 #define D_LCD_BUS_DEF 0x00
wim 13:24506ba22480 76
wim 13:24506ba22480 77 //Bitpattern Defines for I2C PCF8574 and SPI 74595 Bus
wim 13:24506ba22480 78 //
wim 13:24506ba22480 79 #define D_LCD_D4 (1<<D_LCD_PIN_D4)
wim 13:24506ba22480 80 #define D_LCD_D5 (1<<D_LCD_PIN_D5)
wim 13:24506ba22480 81 #define D_LCD_D6 (1<<D_LCD_PIN_D6)
wim 13:24506ba22480 82 #define D_LCD_D7 (1<<D_LCD_PIN_D7)
wim 13:24506ba22480 83 #define D_LCD_RS (1<<D_LCD_PIN_RS)
wim 13:24506ba22480 84 #define D_LCD_E (1<<D_LCD_PIN_E)
wim 13:24506ba22480 85 #define D_LCD_E2 (1<<D_LCD_PIN_E2)
wim 13:24506ba22480 86 #define D_LCD_BL (1<<D_LCD_PIN_BL)
wim 13:24506ba22480 87
wim 13:24506ba22480 88
wim 13:24506ba22480 89 /** Some sample User Defined Chars 5x7 dots */
wim 11:9ec02df863a1 90 const char udc_ae[] = {0x00, 0x00, 0x1B, 0x05, 0x1F, 0x14, 0x1F, 0x00}; //æ
wim 11:9ec02df863a1 91 const char udc_0e[] = {0x00, 0x00, 0x0E, 0x13, 0x15, 0x19, 0x0E, 0x00}; //ø
wim 11:9ec02df863a1 92 const char udc_ao[] = {0x0E, 0x0A, 0x0E, 0x01, 0x0F, 0x11, 0x0F, 0x00}; //å
wim 11:9ec02df863a1 93 const char udc_AE[] = {0x0F, 0x14, 0x14, 0x1F, 0x14, 0x14, 0x17, 0x00}; //Æ
wim 11:9ec02df863a1 94 const char udc_0E[] = {0x0E, 0x13, 0x15, 0x15, 0x15, 0x19, 0x0E, 0x00}; //Ø
wim 11:9ec02df863a1 95 const char udc_AA[] = {0x0E, 0x0A, 0x0E, 0x11, 0x1F, 0x11, 0x11, 0x00}; //Å
wim 11:9ec02df863a1 96
wim 11:9ec02df863a1 97 const char udc_0[] = {0x18, 0x14, 0x12, 0x11, 0x12, 0x14, 0x18, 0x00}; // |>
wim 11:9ec02df863a1 98 const char udc_1[] = {0x03, 0x05, 0x09, 0x11, 0x09, 0x05, 0x03, 0x00}; // <|
wim 11:9ec02df863a1 99 const char udc_2[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00}; // |
wim 11:9ec02df863a1 100 const char udc_3[] = {0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00}; // ||
wim 11:9ec02df863a1 101 const char udc_4[] = {0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00}; // |||
wim 11:9ec02df863a1 102 const char udc_5[] = {0x00, 0x1f, 0x00, 0x1f, 0x00, 0x1f, 0x00, 0x00}; // =
wim 11:9ec02df863a1 103 const char udc_6[] = {0x15, 0x0a, 0x15, 0x0a, 0x15, 0x0a, 0x15, 0x00}; // checkerboard
wim 11:9ec02df863a1 104 const char udc_7[] = {0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x10, 0x00}; // \
wim 11:9ec02df863a1 105
wim 13:24506ba22480 106 const char udc_degr[] = {0x06, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00}; // Degree symbol
wim 13:24506ba22480 107
wim 13:24506ba22480 108 const char udc_TM_T[] = {0x1F, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; // Trademark T
wim 13:24506ba22480 109 const char udc_TM_M[] = {0x11, 0x1B, 0x15, 0x11, 0x00, 0x00, 0x00, 0x00}; // Trademark M
wim 13:24506ba22480 110
wim 13:24506ba22480 111 //const char udc_Bat_Hi[] = {0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Full
wim 13:24506ba22480 112 //const char udc_Bat_Ha[] = {0x0E, 0x11, 0x13, 0x17, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Half
wim 13:24506ba22480 113 //const char udc_Bat_Lo[] = {0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x00}; // Battery Low
wim 13:24506ba22480 114 const char udc_Bat_Hi[] = {0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Full
wim 13:24506ba22480 115 const char udc_Bat_Ha[] = {0x0E, 0x11, 0x11, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Battery Half
wim 13:24506ba22480 116 const char udc_Bat_Lo[] = {0x0E, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x1F, 0x00}; // Battery Low
wim 13:24506ba22480 117
wim 13:24506ba22480 118 const char udc_bar_1[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00}; // Bar 1
wim 13:24506ba22480 119 const char udc_bar_2[] = {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00}; // Bar 11
wim 13:24506ba22480 120 const char udc_bar_3[] = {0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x00}; // Bar 111
wim 13:24506ba22480 121 const char udc_bar_4[] = {0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x00}; // Bar 1111
wim 13:24506ba22480 122 const char udc_bar_5[] = {0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}; // Bar 11111
wim 13:24506ba22480 123
wim 11:9ec02df863a1 124
wim 11:9ec02df863a1 125 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
wim 11:9ec02df863a1 126 *
wim 16:c276b75e6585 127 * Currently supports 8x1, 8x2, 12x2, 12x4, 16x1, 16x2, 16x4, 20x2, 20x4, 24x2, 24x4, 40x2 and 40x4 panels
wim 11:9ec02df863a1 128 *
wim 11:9ec02df863a1 129 */
simon 1:ac48b187213c 130 class TextLCD : public Stream {
simon 1:ac48b187213c 131 public:
simon 1:ac48b187213c 132
simon 2:227356c7d12c 133 /** LCD panel format */
simon 1:ac48b187213c 134 enum LCDType {
wim 8:03116f75b66e 135 LCD8x1, /**< 8x1 LCD panel */
wim 13:24506ba22480 136 LCD8x2, /**< 8x2 LCD panel */
wim 15:b70ebfffb258 137 LCD12x2, /**< 12x2 LCD panel */
wim 15:b70ebfffb258 138 LCD12x4, /**< 12x4 LCD panel */
wim 13:24506ba22480 139 LCD16x1, /**< 16x1 LCD panel (actually 8x2) */
wim 8:03116f75b66e 140 LCD16x2, /**< 16x2 LCD panel (default) */
wim 8:03116f75b66e 141 LCD16x2B, /**< 16x2 LCD panel alternate addressing */
wim 8:03116f75b66e 142 LCD16x4, /**< 16x4 LCD panel */
wim 8:03116f75b66e 143 LCD20x2, /**< 20x2 LCD panel */
wim 8:03116f75b66e 144 LCD20x4, /**< 20x4 LCD panel */
wim 9:0893d986e717 145 LCD24x2, /**< 24x2 LCD panel */
wim 10:dd9b3a696acd 146 LCD24x4, /**< 24x4 LCD panel, special mode KS0078 */
wim 15:b70ebfffb258 147 LCD40x2, /**< 40x2 LCD panel */
wim 15:b70ebfffb258 148 LCD40x4 /**< 40x4 LCD panel, Two controller version */
simon 1:ac48b187213c 149 };
simon 1:ac48b187213c 150
wim 10:dd9b3a696acd 151 /** LCD Cursor control */
wim 10:dd9b3a696acd 152 enum LCDCursor {
wim 17:652ab113bc2e 153 CurOff_BlkOff = 0x00, /**< Cursor Off, Blinking Char Off */
wim 17:652ab113bc2e 154 CurOn_BlkOff = 0x02, /**< Cursor On, Blinking Char Off */
wim 17:652ab113bc2e 155 CurOff_BlkOn = 0x01, /**< Cursor Off, Blinking Char On */
wim 17:652ab113bc2e 156 CurOn_BlkOn = 0x03 /**< Cursor On, Blinking Char On */
wim 17:652ab113bc2e 157 };
wim 17:652ab113bc2e 158
wim 17:652ab113bc2e 159
wim 17:652ab113bc2e 160 /** LCD Display control */
wim 17:652ab113bc2e 161 enum LCDMode {
wim 17:652ab113bc2e 162 DispOff = 0x00, /**< Display Off */
wim 17:652ab113bc2e 163 DispOn = 0x04 /**< Display On */
wim 10:dd9b3a696acd 164 };
wim 10:dd9b3a696acd 165
wim 10:dd9b3a696acd 166
wim 15:b70ebfffb258 167 /** Create a TextLCD interface for using regular mbed pins
simon 2:227356c7d12c 168 *
simon 2:227356c7d12c 169 * @param rs Instruction/data control line
simon 2:227356c7d12c 170 * @param e Enable line (clock)
simon 7:44f34c09bd37 171 * @param d4-d7 Data lines for using as a 4-bit interface
simon 2:227356c7d12c 172 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 15:b70ebfffb258 173 * @param e2 Enable2 line (clock for second controller, LCD40x4 only)
simon 2:227356c7d12c 174 */
wim 15:b70ebfffb258 175 TextLCD(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type = LCD16x2, PinName e2 = NC);
wim 13:24506ba22480 176
wim 13:24506ba22480 177 /** Create a TextLCD interface using an I2C PC8574 portexpander
wim 13:24506ba22480 178 *
wim 13:24506ba22480 179 * @param i2c I2C Bus
wim 13:24506ba22480 180 * @param deviceAddress I2C slave address (PCF8574)
wim 13:24506ba22480 181 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 13:24506ba22480 182 */
wim 13:24506ba22480 183 TextLCD(I2C *i2c, char deviceAddress, LCDType type = LCD16x2);
wim 13:24506ba22480 184
wim 13:24506ba22480 185
wim 13:24506ba22480 186 /** Create a TextLCD interface using an SPI 74595 portexpander
wim 13:24506ba22480 187 *
wim 13:24506ba22480 188 * @param spi SPI Bus
wim 13:24506ba22480 189 * @param cs chip select pin (active low)
wim 13:24506ba22480 190 * @param type Sets the panel size/addressing mode (default = LCD16x2)
wim 13:24506ba22480 191 */
wim 14:0c32b66b14b8 192 TextLCD(SPI *spi, PinName cs, LCDType type = LCD16x2);
wim 13:24506ba22480 193
simon 2:227356c7d12c 194
simon 2:227356c7d12c 195 #if DOXYGEN_ONLY
simon 2:227356c7d12c 196 /** Write a character to the LCD
simon 2:227356c7d12c 197 *
simon 2:227356c7d12c 198 * @param c The character to write to the display
simon 2:227356c7d12c 199 */
simon 2:227356c7d12c 200 int putc(int c);
simon 2:227356c7d12c 201
simon 2:227356c7d12c 202 /** Write a formated string to the LCD
simon 2:227356c7d12c 203 *
simon 2:227356c7d12c 204 * @param format A printf-style format string, followed by the
simon 2:227356c7d12c 205 * variables to use in formating the string.
simon 2:227356c7d12c 206 */
simon 2:227356c7d12c 207 int printf(const char* format, ...);
simon 2:227356c7d12c 208 #endif
simon 2:227356c7d12c 209
simon 2:227356c7d12c 210 /** Locate to a screen column and row
simon 2:227356c7d12c 211 *
simon 2:227356c7d12c 212 * @param column The horizontal position from the left, indexed from 0
simon 2:227356c7d12c 213 * @param row The vertical position from the top, indexed from 0
simon 2:227356c7d12c 214 */
simon 1:ac48b187213c 215 void locate(int column, int row);
simon 2:227356c7d12c 216
wim 10:dd9b3a696acd 217
wim 10:dd9b3a696acd 218 /** Return the memoryaddress of screen column and row location
wim 10:dd9b3a696acd 219 *
wim 10:dd9b3a696acd 220 * @param column The horizontal position from the left, indexed from 0
wim 10:dd9b3a696acd 221 * @param row The vertical position from the top, indexed from 0
wim 10:dd9b3a696acd 222 * @param return The memoryaddress of screen column and row location
wim 10:dd9b3a696acd 223 */
wim 9:0893d986e717 224 int getAddress(int column, int row);
wim 10:dd9b3a696acd 225
wim 10:dd9b3a696acd 226
wim 10:dd9b3a696acd 227 /** Set the memoryaddress of screen column and row location
wim 10:dd9b3a696acd 228 *
wim 10:dd9b3a696acd 229 * @param column The horizontal position from the left, indexed from 0
wim 10:dd9b3a696acd 230 * @param row The vertical position from the top, indexed from 0
wim 10:dd9b3a696acd 231 */
wim 9:0893d986e717 232 void setAddress(int column, int row);
wim 9:0893d986e717 233
wim 10:dd9b3a696acd 234
simon 2:227356c7d12c 235 /** Clear the screen and locate to 0,0 */
simon 1:ac48b187213c 236 void cls();
simon 2:227356c7d12c 237
wim 10:dd9b3a696acd 238 /** Return the number of rows
wim 10:dd9b3a696acd 239 *
wim 10:dd9b3a696acd 240 * @param return The number of rows
wim 10:dd9b3a696acd 241 */
simon 1:ac48b187213c 242 int rows();
wim 10:dd9b3a696acd 243
wim 10:dd9b3a696acd 244 /** Return the number of columns
wim 10:dd9b3a696acd 245 *
wim 10:dd9b3a696acd 246 * @param return The number of columns
wim 10:dd9b3a696acd 247 */
wim 10:dd9b3a696acd 248 int columns();
simon 2:227356c7d12c 249
wim 11:9ec02df863a1 250 /** Set the Cursormode
wim 11:9ec02df863a1 251 *
wim 17:652ab113bc2e 252 * @param cursorMode The Cursor mode (CurOff_BlkOff, CurOn_BlkOff, CurOff_BlkOn, CurOn_BlkOn)
wim 11:9ec02df863a1 253 */
wim 17:652ab113bc2e 254 void setCursor(LCDCursor cursorMode);
wim 17:652ab113bc2e 255
wim 17:652ab113bc2e 256
wim 17:652ab113bc2e 257 /** Set the Displaymode
wim 17:652ab113bc2e 258 *
wim 17:652ab113bc2e 259 * @param displayMode The Display mode (DispOff, DispOn)
wim 17:652ab113bc2e 260 */
wim 17:652ab113bc2e 261 void setMode(TextLCD::LCDMode displayMode);
wim 11:9ec02df863a1 262
wim 11:9ec02df863a1 263
wim 11:9ec02df863a1 264 /** Set User Defined Characters
wim 11:9ec02df863a1 265 *
wim 11:9ec02df863a1 266 * @param unsigned char c The Index of the UDC (0..7)
wim 12:6bf9d9957d31 267 * @param char *udc_data The bitpatterns for the UDC (8 bytes of 5 significant bits)
wim 11:9ec02df863a1 268 */
wim 11:9ec02df863a1 269 void setUDC(unsigned char c, char *udc_data);
wim 11:9ec02df863a1 270
simon 1:ac48b187213c 271 protected:
wim 14:0c32b66b14b8 272 /* LCD Bus control */
wim 13:24506ba22480 273 enum _LCDBus {
wim 14:0c32b66b14b8 274 _PinBus, /*< Regular mbed pins */
wim 14:0c32b66b14b8 275 _I2CBus, /*< I2C PCF8574 Portexpander */
wim 15:b70ebfffb258 276 _SPIBus /*< SPI 74595 Shiftregister */
wim 13:24506ba22480 277 };
wim 13:24506ba22480 278
wim 15:b70ebfffb258 279 /* LCD controller select, mainly used for LCD40x4 */
wim 15:b70ebfffb258 280 enum _LCDCtrl {
wim 15:b70ebfffb258 281 _LCDCtrl_0, /*< Primary */
wim 15:b70ebfffb258 282 _LCDCtrl_1, /*< Secondary */
wim 15:b70ebfffb258 283 };
wim 15:b70ebfffb258 284
simon 1:ac48b187213c 285 // Stream implementation functions
simon 1:ac48b187213c 286 virtual int _putc(int value);
simon 1:ac48b187213c 287 virtual int _getc();
simon 1:ac48b187213c 288
wim 15:b70ebfffb258 289 //Low level methods for LCD controller
wim 13:24506ba22480 290 void _init();
wim 15:b70ebfffb258 291 void _initCtrl();
wim 13:24506ba22480 292 int _address(int column, int row);
wim 15:b70ebfffb258 293 void _setCursor(TextLCD::LCDCursor show);
wim 17:652ab113bc2e 294 void _setUDC(unsigned char c, char *udc_data);
wim 17:652ab113bc2e 295 void _setCursorAndDisplayMode(TextLCD::LCDMode displayMode, TextLCD::LCDCursor cursorType);
wim 13:24506ba22480 296
wim 15:b70ebfffb258 297 //Low level write operations to LCD controller
wim 17:652ab113bc2e 298 void _writeNibble(int value);
wim 15:b70ebfffb258 299 void _writeByte(int value);
wim 15:b70ebfffb258 300 void _writeCommand(int command);
wim 15:b70ebfffb258 301 void _writeData(int data);
wim 15:b70ebfffb258 302
wim 13:24506ba22480 303 //Low level writes to LCD Bus (serial or parallel)
wim 13:24506ba22480 304 void _setEnable(bool value);
wim 13:24506ba22480 305 void _setRS(bool value);
wim 13:24506ba22480 306 void _setData(int value);
wim 14:0c32b66b14b8 307 void _setCS(bool value);
wim 14:0c32b66b14b8 308
wim 13:24506ba22480 309 //Low level writes to LCD serial bus only
wim 13:24506ba22480 310 void _writeBus();
wim 13:24506ba22480 311
wim 13:24506ba22480 312
wim 13:24506ba22480 313 // Regular mbed pins bus
wim 15:b70ebfffb258 314 DigitalOut _rs, _e, _e2;
simon 1:ac48b187213c 315 BusOut _d;
wim 13:24506ba22480 316
wim 13:24506ba22480 317 // I2C bus
wim 13:24506ba22480 318 I2C *_i2c;
wim 13:24506ba22480 319 unsigned char _slaveAddress;
wim 13:24506ba22480 320
wim 13:24506ba22480 321 // SPI bus
wim 14:0c32b66b14b8 322 SPI *_spi;
wim 14:0c32b66b14b8 323 DigitalOut _cs;
wim 13:24506ba22480 324
wim 13:24506ba22480 325 //Bus Interface type
wim 13:24506ba22480 326 _LCDBus _busType;
wim 13:24506ba22480 327
wim 15:b70ebfffb258 328 // Internal bus mirror value for serial bus only
wim 13:24506ba22480 329 char _lcd_bus;
wim 13:24506ba22480 330
wim 13:24506ba22480 331 //Display type
simon 1:ac48b187213c 332 LCDType _type;
simon 1:ac48b187213c 333
wim 17:652ab113bc2e 334 //Display type
wim 17:652ab113bc2e 335 LCDMode _currentMode;
wim 17:652ab113bc2e 336
wim 15:b70ebfffb258 337 //Controller select, mainly used for LCD40x4
wim 15:b70ebfffb258 338 _LCDCtrl _ctrl;
wim 15:b70ebfffb258 339
wim 13:24506ba22480 340 // Cursor
simon 1:ac48b187213c 341 int _column;
simon 1:ac48b187213c 342 int _row;
wim 15:b70ebfffb258 343 LCDCursor _currentCursor;
simon 1:ac48b187213c 344 };
simon 1:ac48b187213c 345
simon 1:ac48b187213c 346 #endif