41 |
pfowler |
1 |
Wire.begin
|
|
|
2 |
_displayfunction = LCD_4BITMODE | LCD_2LINE | LCD_5x8DOTS;
|
|
|
3 |
0x08 = 0x00 | 0x08 | 0x00
|
|
|
4 |
|
|
|
5 |
_backlightval = LCD_BACKLIGHT
|
|
|
6 |
expanderWrite(LCD_BACKLIGHT)
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
write4bits(0x30) //4500
|
|
|
11 |
: [0x27 0x30] [0x27 0x34] [0x27 0x30]
|
42 |
pfowler |
12 |
// : [0x27 0x38] [0x27 0x3c] [0x27 0x38] //With back light
|
|
|
13 |
|
|
|
14 |
: [0x27 0x30] [0x27 0x34] [0x27 0x30]
|
41 |
pfowler |
15 |
write4bits(0x30) //4500
|
|
|
16 |
: [0x27 0x30] [0x27 0x34] [0x27 0x30]
|
|
|
17 |
write4bits(0x30) //4500
|
|
|
18 |
: [0x27 0x30] [0x27 0x34] [0x27 0x30]
|
|
|
19 |
|
|
|
20 |
write4bits(0x20)
|
|
|
21 |
: [0x27 0x20] [0x27 0x24] [0x27 0x20]
|
|
|
22 |
|
|
|
23 |
command(LCD_FUNCTIONSET | _displayfunction) // 0x28
|
|
|
24 |
: [0x27 0x20] [0x27 0x24] [0x27 0x20]
|
|
|
25 |
: [0x27 0x80] [0x27 0x84] [0x27 0x80]
|
|
|
26 |
|
|
|
27 |
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF
|
|
|
28 |
0x04 = 0x04 | 0x00 | 0x00
|
|
|
29 |
|
|
|
30 |
command(LCD_DISPLAYCONTROL | _displaycontrol) // 0x0c
|
|
|
31 |
: [0x27 0x00] [0x27 0x04] [0x27 0x00]
|
|
|
32 |
: [0x27 0xc0] [0x27 0xc4] [0x27 0xc0]
|
|
|
33 |
|
|
|
34 |
command(LCD_CLEARDISPLAY) //2000 0x01
|
|
|
35 |
: [0x27 0x00] [0x27 0x04] [0x27 0x00]
|
|
|
36 |
: [0x27 0x10] [0x27 0x14] [0x27 0x10]
|
|
|
37 |
|
|
|
38 |
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT
|
|
|
39 |
0x03 = 0x02 | 0x01
|
|
|
40 |
command(LCD_ENTRYMODESET | _displaymode)
|
|
|
41 |
: [0x27 0x00] [0x27 0x04] [0x27 0x00]
|
|
|
42 |
: [0x27 0x30] [0x27 0x34] [0x27 0x30]
|
|
|
43 |
|
|
|
44 |
command(LCD_RETURNHOME) //2000 0x02
|
|
|
45 |
: [0x27 0x00] [0x27 0x04] [0x27 0x00]
|
|
|
46 |
: [0x27 0x20] [0x27 0x24] [0x27 0x20]
|
|
|
47 |
|
|
|
48 |
send(A) 0x30, mode 0x01
|
|
|
49 |
: [0x27 0x31] [0x27 0x35] [0x27 0x31]
|
|
|
50 |
: [0x27 0x01] [0x27 0x05] [0x27 0x01]
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
******
|
|
|
55 |
|
|
|
56 |
command = send($1, 0)
|
|
|
57 |
|
|
|
58 |
expanderWrite = (Wire.beginTrans(addr), Wire.write((int)data | LCD_BACKLIGHT), Wite.endTrans)
|
|
|
59 |
|
|
|
60 |
write4bits = (expanderWrite($1), pulse())
|
|
|
61 |
|
|
|
62 |
send = (write4bits(highNib), write4bits(lowNib)
|
|
|
63 |
|
|
|
64 |
pulse = (exanderWrite($1 | En), enpanderWrite($1 | ~1)
|