Fix cursor handling in segmented DDRAM of HD44780
HD44780 has only 80 bytes of DDRAM, which consists of two 40 bytes
long segments. The segment starting at address 0x00 contains the
data for the first line of the display, while the segment starting
at address 0x40 contains the data for the second line of the
display. This means that there are invalid ranges in the 7-bit
address space of the DDRAM (0x00+40 .. 0x3f and 0x40+40 .. 0x7f).
The cursor (address counter) of the HD44780 automatically "jumps
over" these regions whenever auto-incremented/decremented. This
commit implements this behaviour.
Moreover, this commit also fixes the 4-lines mode. When in a
4-lines setup, the first 20 bytes of the first and the second
memory segments control what is displayed in the first two lines,
as usual. However, the second 20 bytes of the memory segments
contain the data for the third and fourth lines of the display.
This means that the starting addresses of lines 3 & 4 are 0x00+20
and 0x40+20.
2 files changed: