Author | Rob Hamerling, Copyright (c) 2008..2008, all rights reserved. |
Adapted-by | Eur van Andel |
Compiler | >=2.4g |
Simple interface for HD44780 compatible alphanumeric LCD screens. Screens can range from 2x8 (2 lines, 8 chars) to 4x20. Uses 4 bit wide datapath + 2 handshake lines (total 6 PIC pins). No support for shift and characterset manipulations. Expects: - 2 pins for handshake: 'lcd_rs' and 'lcd_en' - 1 port nibble for data: 'lcd_dataport'
lcd_setcursor(byte in row, byte in col)
lcd'put(byte in c)
lcd_clearscreen()
lcd_init()
lcd_writechar(byte in c)
lcd_setcursor(byte in row, byte in col)
About cursor positions: the LCDs are internally 2x40 char devices. The first line starts at offset 0, the second line at offset 64 (0x40). With 4 line devices the third and fourth line are addressed as extensions of the first and second line by adding an offset. For a 4x20 line device the offset is 20, for a 4x16 line display the offset is 16 or 20. Declare the constant LCD_CHARS as appropriate for your screen (you may have to specify 20 even if your display has only 16 chars!). Note: Some 1x16 LCDs are implemented as 2x8 line LCDs, which means that the second half of the line has to be handled as a second line. Set cursor position Specify row and column in base-0 notation (first line is 0).
lcd'put(byte in c)
Pseudo variable 'lcd' as alternative for lcd_writechar()
lcd_clearscreen()
Clear screen (and set the cursor to the upper left corner: row 0, column 0)
lcd_init()
Initialize LCD * for 4-bit data mode * 2-line (/ 4-line) mode * shift right, invisible cursor
lcd_writechar(byte in c)
Send byte to the LCD as 2 nibbles (most significant nibble first) and automatically set the cursor one position right. There is no check on line overflow.
_lcd_writenibble(byte in data)
Write nibble (lower order 4 bits of byte) to LCD. Nibble is sent to dataport. lcd_rs is not touched: function can be used for commands and data. When wait is required after write then caller should wait (in 4-bit mode only required after second nibble).
sample | 16f876a_t6603.jal |
sample | 16f877a_co2_t6603.jal |
sample | 16f877a_hello_world_lcd.jal |
sample | 16f877a_lcd_format.jal |
sample | 16f876a_sht.jal |
sample | 18f6310_lcd_hd44780_4.jal |
sample | 16f876a_rtc_lcd.jal |
sample | 16f690_hello_world_lcd.jal |
sample | 16f876a_tc77.jal |
sample | 16f876a_keyboard_lcd.jal |
sample | 16f877a_keyboard_lcd.jal |
sample | 16f88_hello_world_lcd.jal |
sample | 16f877a_rtc_lcd.jal |
sample | 16f819_hello_world_lcd.jal |