-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex.js
65 lines (56 loc) · 1.04 KB
/
ex.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var rs = 3;
var en = 5;
var dp = [6, 7, 8, 9];
// initialize
var LCD = require("./index").LCD;
var lcd = new LCD(rs, en, dp);
lcd.begin();
// 1. hello
lcd.print("Hello, world!");
delay(3000);
// 2. two lines
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("The first line.");
lcd.setCursor(0, 1);
lcd.print("The second line.");
delay(3000);
// 3. scroll
for (var i = 0; i < lcd.cols; i++) {
lcd.scrollRight();
delay(300);
}
for (var i = 0; i < lcd.cols; i++) {
lcd.scrollLeft();
delay(300);
}
delay(3000);
// 4. cursor and blink
lcd.clear();
lcd.cursor();
delay(2000);
lcd.cursor(false);
delay(2000);
lcd.blink();
delay(2000);
lcd.blink(false);
delay(3000);
// custom chars
var heart = [
0b00000, 0b01010, 0b11111, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000,
];
var smiley = [
0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b10001, 0b01110, 0b00000,
];
lcd.clear();
lcd.createChar(0, heart);
lcd.createChar(1, smiley);
lcd.write(0);
lcd.write(1);
lcd.write(0);
lcd.write(1);
lcd.write(0);
lcd.write(1);
lcd.write(0);
lcd.write(1);
global.lcd = lcd;