Skip to content

Commit 0e4dcc6

Browse files
committed
Merge pull request arduino#3444 from calvinatintel/master
LiquidCrystal Library changes for Galileo and Edison compatibility
2 parents 431f319 + b0278f4 commit 0e4dcc6

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

libraries/LiquidCrystal/src/LiquidCrystal.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t en
6767
_data_pins[6] = d6;
6868
_data_pins[7] = d7;
6969

70-
pinMode(_rs_pin, OUTPUT);
71-
// we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#
72-
if (_rw_pin != 255) {
73-
pinMode(_rw_pin, OUTPUT);
74-
}
75-
pinMode(_enable_pin, OUTPUT);
76-
7770
if (fourbitmode)
7871
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
7972
else
@@ -95,6 +88,19 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
9588
_displayfunction |= LCD_5x10DOTS;
9689
}
9790

91+
pinMode(_rs_pin, OUTPUT);
92+
// we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#
93+
if (_rw_pin != 255) {
94+
pinMode(_rw_pin, OUTPUT);
95+
}
96+
pinMode(_enable_pin, OUTPUT);
97+
98+
// Do these once, instead of every time a character is drawn for speed reasons.
99+
for (int i=0; i<((_displayfunction & LCD_8BITMODE) ? 8 : 4); ++i)
100+
{
101+
pinMode(_data_pins[i], OUTPUT);
102+
}
103+
98104
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
99105
// according to datasheet, we need at least 40ms after power rises above 2.7V
100106
// before sending commands. Arduino can turn on way before 4.5V so we'll wait 50
@@ -158,12 +164,6 @@ void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
158164

159165
}
160166

161-
/*
162-
in some 16x4 LCD when line 3 and 4 are not placed correctly you may try:
163-
setRowOffsets(0x00, 0x40, 0x14, 0x54)
164-
or
165-
setRowOffsets(0x00, 0x40, 0x10, 0x50)
166-
*/
167167
void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3)
168168
{
169169
_row_offsets[0] = row0;
@@ -311,7 +311,6 @@ void LiquidCrystal::pulseEnable(void) {
311311

312312
void LiquidCrystal::write4bits(uint8_t value) {
313313
for (int i = 0; i < 4; i++) {
314-
pinMode(_data_pins[i], OUTPUT);
315314
digitalWrite(_data_pins[i], (value >> i) & 0x01);
316315
}
317316

@@ -320,7 +319,6 @@ void LiquidCrystal::write4bits(uint8_t value) {
320319

321320
void LiquidCrystal::write8bits(uint8_t value) {
322321
for (int i = 0; i < 8; i++) {
323-
pinMode(_data_pins[i], OUTPUT);
324322
digitalWrite(_data_pins[i], (value >> i) & 0x01);
325323
}
326324

0 commit comments

Comments
 (0)