| 90 | } |
| 91 | |
| 92 | void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { |
| 93 | if (lines > 1) { |
| 94 | _displayfunction |= LCD_2LINE; |
| 95 | } |
| 96 | _numlines = lines; |
| 97 | |
| 98 | setRowOffsets(0x00, 0x40, 0x00 + cols, 0x40 + cols); |
| 99 | |
| 100 | // for some 1 line displays you can select a 10 pixel high font |
| 101 | if ((dotsize != LCD_5x8DOTS) && (lines == 1)) { |
| 102 | _displayfunction |= LCD_5x10DOTS; |
| 103 | } |
| 104 | |
| 105 | pinMode(_rs_pin, OUTPUT); |
| 106 | // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# |
| 107 | if (_rw_pin != 255) { |
| 108 | pinMode(_rw_pin, OUTPUT); |
| 109 | } |
| 110 | pinMode(_enable_pin, OUTPUT); |
| 111 | |
| 112 | // Do these once, instead of every time a character is drawn for speed reasons. |
| 113 | for (int i=0; i<((_displayfunction & LCD_8BITMODE) ? 8 : 4); ++i) |
| 114 | { |
| 115 | pinMode(_data_pins[i], OUTPUT); |
| 116 | } |
| 117 | |
| 118 | // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! |
| 119 | // according to datasheet, we need at least 40ms after power rises above 2.7V |
| 120 | // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 |
| 121 | delayMicroseconds(50000); |
| 122 | // Now we pull both RS and R/W low to begin commands |
| 123 | digitalWrite(_rs_pin, LOW); |
| 124 | digitalWrite(_enable_pin, LOW); |
| 125 | if (_rw_pin != 255) { |
| 126 | digitalWrite(_rw_pin, LOW); |
| 127 | } |
| 128 | |
| 129 | //put the LCD into 4 bit or 8 bit mode |
| 130 | if (! (_displayfunction & LCD_8BITMODE)) { |
| 131 | // this is according to the hitachi HD44780 datasheet |
| 132 | // figure 24, pg 46 |
| 133 | |
| 134 | // we start in 8bit mode, try to set 4 bit mode |
| 135 | write4bits(0x03); |
| 136 | delayMicroseconds(4500); // wait min 4.1ms |
| 137 | |
| 138 | // second try |
| 139 | write4bits(0x03); |
| 140 | delayMicroseconds(4500); // wait min 4.1ms |
| 141 | |
| 142 | // third go! |
| 143 | write4bits(0x03); |
| 144 | delayMicroseconds(150); |
| 145 | |
| 146 | // finally, set to 4-bit interface |
| 147 | write4bits(0x02); |
| 148 | } else { |
| 149 | // this is according to the hitachi HD44780 datasheet |
nothing calls this directly
no outgoing calls
no test coverage detected