This is a generic HD44780 driver for node. It knows the "language" of the display, but you have to provide the functions that communicates with the hardware. Both 8 and 4 bit interfaces are supported.
Both read and write operations are requied. It reads the BUSY flag and address-counter from the display.
You have to provide the functions that communicates with the hardware.
-
async pin_enable(state)
This function should set the ENABLE line to high if sate is true, and to low if it is false.
-
async port_raw_write(rs, data)
This function should
- set the hardware to OUTPUT D0-D7 (D4-D7 in 4-bit-mode)
- set the R/W pin to WRITE (LOW)
- set the RS pin to HIGH or LOW according to rs variable
- output data to data-pins. (in 4-bit-mode data is in D4-D7)
-
async port_raw_read(rs)
This function should
- set the hardware to INPUT D0-D7 (D4-D7 in 4-bit-mode)
- set the R/W pin to READ (HIGH)
- set the RS pin to HIGH or LOW according to rs variable
- read data from data-pins. (in 4-bit-mode data is in D4-D7)
Write text to display memory from current position.
A sprintf-like behaviour is supported:
%(flags)(width)(.precision)(specifier)
flags
- "-" Left-justify
- "+" Always add sign
- "0" Left-pads a number with 0 instead of spaces.
width
Minimum number of characters to be printed.
precision
-
For b, d, o, x and X this specifies the minimum number of digits to be written. Will be zero-padded if shorter.
-
For f this is the number of digits to be printed after the decimal point.
-
For s this is the maximum number of characters to be printed.
specifier
- % Prints a % character
- d Print number as decimal
- f Print number as float
- o Print number as octal
- s Print string
- x Print number as hex (lower case)
- X Print number as HEX (upper case)
Supported control-characters
Character | Description | |
---|---|---|
0x07 | BEL | Calls the bell function. By default it doses not do anything, but you can override it. |
0x08 | DEL | Moves cursor back one step and replaces the character there with a space. |
0x0A | NEW LINE | Moves cursor to the next line. If it is at the bottom line, it moves to the first line. |
0x0C | FROM FEED | Clears the display. |
0x0D | CARRIAGE RETURN | Moves the cursor to the start of the current line. |
0x0E | SHIFT OUT | Shifts out the normal characters and allow you to use the custom chacters. The custom characters are mapped from 0x30 - 0x37 (digits 0 - 7). Example: "\0x0E0" |
0x0F | SHIFT IN | Shift in the normal characters. |
Almost the same as write, but sets the position before writing.