Skip to content

Commit 06c09fe

Browse files
committed
Change code format of the example files.
1 parent 9b34782 commit 06c09fe

File tree

3 files changed

+78
-68
lines changed

3 files changed

+78
-68
lines changed

examples/CustomChars/CustomChars.ino

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,65 @@
11
#include <Wire.h>
22
#include <LiquidCrystal_I2C.h>
33

4-
uint8_t bell[8] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
5-
uint8_t note[8] = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
6-
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
7-
uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
8-
uint8_t duck[8] = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
9-
uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
10-
uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
11-
uint8_t retarrow[8] = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
12-
13-
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
4+
uint8_t bell[8] = {0x4, 0xe, 0xe, 0xe, 0x1f, 0x0, 0x4};
5+
uint8_t note[8] = {0x2, 0x3, 0x2, 0xe, 0x1e, 0xc, 0x0};
6+
uint8_t clock[8] = {0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0};
7+
uint8_t heart[8] = {0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0};
8+
uint8_t duck[8] = {0x0, 0xc, 0x1d, 0xf, 0xf, 0x6, 0x0};
9+
uint8_t check[8] = {0x0, 0x1 ,0x3, 0x16, 0x1c, 0x8, 0x0};
10+
uint8_t cross[8] = {0x0, 0x1b, 0xe, 0x4, 0xe, 0x1b, 0x0};
11+
uint8_t retarrow[8] = { 0x1, 0x1, 0x5, 0x9, 0x1f, 0x8, 0x4};
12+
13+
// Set the LCD address to 0x27 for a 16 chars and 2 line display
14+
LiquidCrystal_I2C lcd(0x27, 16, 2);
1415

1516
void setup()
1617
{
17-
lcd.init(); // initialize the lcd
18-
lcd.backlight();
19-
20-
lcd.createChar(0, bell);
21-
lcd.createChar(1, note);
22-
lcd.createChar(2, clock);
23-
lcd.createChar(3, heart);
24-
lcd.createChar(4, duck);
25-
lcd.createChar(5, check);
26-
lcd.createChar(6, cross);
27-
lcd.createChar(7, retarrow);
28-
lcd.home();
29-
30-
lcd.print("Hello world...");
31-
lcd.setCursor(0, 1);
32-
lcd.print(" i ");
33-
lcd.print(3, BYTE);
34-
lcd.print(" arduinos!");
35-
delay(5000);
36-
displayKeyCodes();
37-
18+
lcd.init();
19+
lcd.backlight();
20+
21+
lcd.createChar(0, bell);
22+
lcd.createChar(1, note);
23+
lcd.createChar(2, clock);
24+
lcd.createChar(3, heart);
25+
lcd.createChar(4, duck);
26+
lcd.createChar(5, check);
27+
lcd.createChar(6, cross);
28+
lcd.createChar(7, retarrow);
29+
lcd.home();
30+
31+
lcd.print("Hello world...");
32+
lcd.setCursor(0, 1);
33+
lcd.print(" i ");
34+
lcd.print(3, BYTE);
35+
lcd.print(" arduinos!");
36+
delay(5000);
37+
displayKeyCodes();
3838
}
3939

4040
// display all keycodes
4141
void displayKeyCodes(void) {
42-
uint8_t i = 0;
43-
while (1) {
44-
lcd.clear();
45-
lcd.print("Codes 0x"); lcd.print(i, HEX);
46-
lcd.print("-0x"); lcd.print(i+16, HEX);
47-
lcd.setCursor(0, 1);
48-
for (int j=0; j<16; j++) {
49-
lcd.print(i+j, BYTE);
50-
}
51-
i+=16;
52-
53-
delay(4000);
54-
}
42+
uint8_t i = 0;
43+
44+
while (1) {
45+
lcd.clear();
46+
lcd.print("Codes 0x");
47+
lcd.print(i, HEX);
48+
lcd.print("-0x");
49+
lcd.print(i + 16, HEX);
50+
lcd.setCursor(0, 1);
51+
52+
for (int j = 0; j < 16; j++) {
53+
lcd.print(i + j, BYTE);
54+
}
55+
i += 16;
56+
57+
delay(4000);
58+
}
5559
}
5660

5761
void loop()
5862
{
59-
63+
// Do nothing here...
6064
}
6165

examples/HelloWorld/HelloWorld.ino

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
#include <Wire.h>
22
#include <LiquidCrystal_I2C.h>
33

4-
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
4+
// Set the LCD address to 0x27 for a 16 chars and 2 line display
5+
LiquidCrystal_I2C lcd(0x27, 16, 2);
56

67
void setup()
78
{
8-
lcd.init(); // initialize the lcd
9-
10-
// Print a message to the LCD.
11-
lcd.backlight();
12-
lcd.print("Hello, world!");
9+
// initialize the LCD
10+
lcd.init();
11+
12+
// Turn on the blacklight and print a message.
13+
lcd.backlight();
14+
lcd.print("Hello, world!");
1315
}
1416

1517
void loop()
1618
{
19+
// Do nothing here...
1720
}
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
/*
1+
/**
22
* Displays text sent over the serial port (e.g. from the Serial Monitor) on
33
* an attached LCD.
44
*/
55
#include <Wire.h>
66
#include <LiquidCrystal_I2C.h>
77

8-
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
8+
// Set the LCD address to 0x27 for a 16 chars and 2 line display
9+
LiquidCrystal_I2C lcd(0x27, 16, 2);
910

1011
void setup()
1112
{
12-
lcd.init(); // initialize the lcd
13-
lcd.backlight();
14-
Serial.begin(9600);
13+
lcd.init();
14+
lcd.backlight();
15+
16+
// Initialize the serial port at a speed of 9600 baud
17+
Serial.begin(9600);
1518
}
1619

1720
void loop()
1821
{
19-
// when characters arrive over the serial port...
20-
if (Serial.available()) {
21-
// wait a bit for the entire message to arrive
22-
delay(100);
23-
// clear the screen
24-
lcd.clear();
25-
// read all the available characters
26-
while (Serial.available() > 0) {
27-
// display each character to the LCD
28-
lcd.write(Serial.read());
29-
}
30-
}
22+
// If characters arrived over the serial port...
23+
if (Serial.available()) {
24+
// Wait a bit for the entire message to arrive
25+
delay(100);
26+
// Clear the screen
27+
lcd.clear();
28+
29+
// Write all characters received with the serial port to the LCD.
30+
while (Serial.available() > 0) {
31+
lcd.write(Serial.read());
32+
}
33+
}
3134
}

0 commit comments

Comments
 (0)