1
- # Driver for character-based LCD displays
1
+ # 1. Driver for character-based LCD displays
2
2
3
3
This driver is for displays based on the Hitachi HD44780 driver: these are
4
4
widely available, typically in 16 character x 2 rows format.
5
5
6
- # Files
6
+ # 2. Files
7
7
8
8
* ` alcd.py ` Driver, includes connection details.
9
9
* ` alcdtest.py ` Test/demo script.
10
10
11
- Currently most of the documentation, including wiring details, is in the code.
11
+ # 3. Typical wiring
12
12
13
- # Display Formatting
13
+ The driver uses 4-bit mode to economise on pins and wiring. Pins are arbitrary
14
+ but this configuration was used in testing:
15
+
16
+ | LCD | Board |
17
+ | :----:| :----:|
18
+ | Rs | Y1 |
19
+ | E | Y2 |
20
+ | D7 | Y3 |
21
+ | D6 | Y4 |
22
+ | D5 | Y5 |
23
+ | D4 | Y6 |
24
+
25
+ # 4. LCD Class
26
+
27
+ ## 4.1 Constructor
28
+
29
+ This takes the following positional args:
30
+ * ` pinlist ` A tuple of 6 strings, being the Pyboard pins used for signals
31
+ ` Rs ` , ` E ` , ` D4 ` , ` D5 ` , ` D6 ` , ` D7 ` e.g. ` ('Y1','Y2','Y6','Y5','Y4','Y3') ` .
32
+ * ` cols ` The number of horizontal characters in the display (typically 16).
33
+ * ` rows ` Default 2. Number of rows in the display.
34
+
35
+ ## 4.2 Display updates
36
+
37
+ The class has no public properties or methods. The display is represented as an
38
+ array of strings indexed by row. The row contents is replaced in its entirety.
39
+ This is illustrated by the test program:
40
+
41
+ ``` python
42
+ import uasyncio as asyncio
43
+ import utime as time
44
+ from alcd import LCD , PINLIST
45
+
46
+ lcd = LCD(PINLIST , cols = 16 )
47
+
48
+ async def lcd_task ():
49
+ for secs in range (20 , - 1 , - 1 ):
50
+ lcd[0 ] = ' MicroPython {} ' .format(secs)
51
+ lcd[1 ] = " {:11d } uS" .format(time.ticks_us())
52
+ await asyncio.sleep(1 )
53
+
54
+ loop = asyncio.get_event_loop()
55
+ loop.run_until_complete(lcd_task())
56
+ ```
57
+
58
+ The row contents may be read back by issuing
59
+
60
+ ``` python
61
+ row0 = lcd[0 ]
62
+ ```
63
+
64
+ # 5. Display Formatting
14
65
15
66
The driver represents an LCD display as an array indexed by row. Assigning a
16
67
string to a row causes that row to be updated. To write text to a specific
17
68
column of the display it is recommended to use the Python string ` format `
18
69
method.
19
70
20
- For exampls this function formats a string such that it is left-padded with
71
+ For example this function formats a string such that it is left-padded with
21
72
spaces to a given column and right-padded to the specified width (typically the
22
73
width of the display). This ensures previous contents are overwritten.
23
74
@@ -34,5 +85,5 @@ def print_at(st, col, width=16):
34
85
>>>
35
86
```
36
87
37
- Similar use of the ` format ` method can be used to achieve more complex
88
+ This use of the ` format ` method may be extended to achieve more complex
38
89
tabulated data layouts.
0 commit comments