6
6
// When the display powers up, it is configured as follows:
7
7
//
8
8
// 1. Display clear
9
- // 2. Function set:
10
- // DL = 1; 8-bit interface data
11
- // N = 0; 1-line display
12
- // F = 0; 5x8 dot character font
13
- // 3. Display on/off control:
14
- // D = 0; Display off
15
- // C = 0; Cursor off
16
- // B = 0; Blinking off
17
- // 4. Entry mode set:
9
+ // 2. Function set:
10
+ // DL = 1; 8-bit interface data
11
+ // N = 0; 1-line display
12
+ // F = 0; 5x8 dot character font
13
+ // 3. Display on/off control:
14
+ // D = 0; Display off
15
+ // C = 0; Cursor off
16
+ // B = 0; Blinking off
17
+ // 4. Entry mode set:
18
18
// I/D = 1; Increment by 1
19
- // S = 0; No shift
19
+ // S = 0; No shift
20
20
//
21
21
// Note, however, that resetting the Arduino doesn't reset the LCD, so we
22
22
// can't assume that its in that state when a sketch starts (and the
@@ -47,7 +47,7 @@ void LiquidCrystal_I2C::begin() {
47
47
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
48
48
// according to datasheet, we need at least 40ms after power rises above 2.7V
49
49
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
50
- delay (50 );
50
+ delay (50 );
51
51
52
52
// Now we pull both RS and R/W low to begin commands
53
53
expanderWrite (_backlightval); // reset expanderand turn backlight off (Bit 8 =1)
@@ -66,28 +66,28 @@ void LiquidCrystal_I2C::begin() {
66
66
delayMicroseconds (4500 ); // wait min 4.1ms
67
67
68
68
// third go!
69
- write4bits (0x03 << 4 );
69
+ write4bits (0x03 << 4 );
70
70
delayMicroseconds (150 );
71
71
72
72
// finally, set to 4-bit interface
73
- write4bits (0x02 << 4 );
73
+ write4bits (0x02 << 4 );
74
74
75
75
// set # lines, font size, etc.
76
- command (LCD_FUNCTIONSET | _displayfunction);
77
-
76
+ command (LCD_FUNCTIONSET | _displayfunction);
77
+
78
78
// turn the display on with no cursor or blinking default
79
79
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
80
80
display ();
81
-
81
+
82
82
// clear it off
83
83
clear ();
84
-
84
+
85
85
// Initialize to default text direction (for roman languages)
86
86
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
87
-
87
+
88
88
// set the entry mode
89
89
command (LCD_ENTRYMODESET | _displaymode);
90
-
90
+
91
91
home ();
92
92
}
93
93
@@ -212,24 +212,24 @@ void LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) {
212
212
uint8_t highnib=value&0xf0 ;
213
213
uint8_t lownib=(value<<4 )&0xf0 ;
214
214
write4bits ((highnib)|mode);
215
- write4bits ((lownib)|mode);
215
+ write4bits ((lownib)|mode);
216
216
}
217
217
218
218
void LiquidCrystal_I2C::write4bits (uint8_t value) {
219
219
expanderWrite (value);
220
220
pulseEnable (value);
221
221
}
222
222
223
- void LiquidCrystal_I2C::expanderWrite (uint8_t _data){
223
+ void LiquidCrystal_I2C::expanderWrite (uint8_t _data){
224
224
Wire.beginTransmission (_addr);
225
225
Wire.write ((int )(_data) | _backlightval);
226
- Wire.endTransmission ();
226
+ Wire.endTransmission ();
227
227
}
228
228
229
229
void LiquidCrystal_I2C::pulseEnable (uint8_t _data){
230
230
expanderWrite (_data | En); // En high
231
231
delayMicroseconds (1 ); // enable pulse must be >450ns
232
-
232
+
233
233
expanderWrite (_data & ~En); // En low
234
234
delayMicroseconds (50 ); // commands need > 37us to settle
235
235
}
@@ -248,6 +248,6 @@ void LiquidCrystal_I2C::setBacklight(uint8_t new_val){
248
248
249
249
void LiquidCrystal_I2C::printstr (const char c[]){
250
250
// This function is not identical to the function used for "real" I2C displays
251
- // it's here so the user sketch doesn't have to be changed
251
+ // it's here so the user sketch doesn't have to be changed
252
252
print (c);
253
253
}
0 commit comments