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