# lcd_hd44780_4

LCD library for HD44780 compatible LCDs, with 4 bits wide datatransfer

Author | Rob Hamerling, Copyright © 2008..2009, all rights reserved.
Adapted-by | Eur van Andel, Joep Suijs (refactoring),Richard Zengerink (lcd_init)
Compiler | 2.4p

Description

       Nibble interface for HD44780 compatible alphanumeric LCD screens.
       Uses 4 bits wide datapath + 2 handshake lines (total 6 PIC pins).
       Expects: 2 pins for handshake: 'lcd_rs' and 'lcd_en'
                and
                     1 port nibble for data: 'lcd_dataport'
                  or
                     4 individual pins for data: 'lcd_d4' .. 'lcd_d7'
    .
       Note:  a 'port nibble' (the lower or higher 4 bits of a port)
              gives faster and more compact code than 4 individual pins.
    .
       Directions for use of this library in application programs
       (in this sequence):
       1. Declare the following constants:
             const byte LCD_ROWS     = 2               -- 1, 2 or 4 lines
             const byte LCD_CHARS    = 16              -- 8, 16 or 20 chars per line
          and aliases for handshake lines:
             alias   lcd_rs          is  pin_A5        -- cmd/data select
             alias   lcd_en          is  pin_A4        -- trigger
          and aliases for 4 data lines:
                alias lcd_dataport  is  portA_low      -- 4 databits
             or
                alias  lcd_d4       is  pin_A3         -- lcd databit d4
                alias  lcd_d5       is  pin_A1         -- lcd databit d5
                alias  lcd_d6       is  pin_C0         -- lcd databit d6
                alias  lcd_d7       is  pin_C2         -- lcd databit d7
    .
       2. Set the chosen LCD dataport and handshake pins to output:
             pin_A4_direction       = output
             pin_A5_direction       = output
          and the data port nibble to output:
                portA_low_direction = all_output
             or the 4 individual datapins to output:
                pin_A3_direction    = output
                pin_A1_direction    = output
                pin_C0_direction    = output
                pin_C2_direction    = output
    .
       3. Include this library.
    .
       4. Call lcd_init() to initialize the lcd controller.
    .
       Above is an example for a 2x16 LCD.
    .
       See hd_44780_common for the LCD API.

Dependencies

- delay
- lcd_hd44780_common

## Summary

### Global variables/contants

### Procedures

- `lcd_init()`

Private

- `__lcd_write_nibble(byte in value)`
- `_lcd_write_data(byte in value)`
- `__lcd_write(byte in value)`
- `_lcd_write_command(byte in value)`

### Functions

## API details

### Global variables/contants

### Procedures

- `lcd_init()`

      Initialize LCD controller to 4-bits mode and default operational settings

Private

- `__lcd_write_nibble(byte in value)`

      Sends low nibble in  to LCD
      Can be used for both commands and data (nibbles).

- `_lcd_write_data(byte in value)`

      Sends data byte in  to LCD

- `__lcd_write(byte in value)`

      Sends byte in  to LCD
      Wait cycle only required after lower nibble (not between nibbles).

- `_lcd_write_command(byte in value)`

      Sends command byte in  to LCD
      For slow commands an extra delay should be added.

### Functions

## Related samples

Here are the list of samples which use this library:

16f648a | 16f648a_lcd_hd44780_custom.jal
16f648a | 16f648a_lcd_hd44780_4_4.jal
16f648a | 16f648a_lcd_hd44780_4_1.jal
16f648a | 16f648a_lcd_hd44780_4bit.jal
16f648a | 16f648a_ds18b20_single.jal
16f648a | 16f648a_backlight.jal
16f676 | 16f676_lcd_hd44780_4_4.jal
16f676 | 16f676_lcd_hd44780_4_1.jal
16f690 | 16f690_lcd_hd44780_4_4.jal
16f690 | 16f690_lcd_hd44780_4_1.jal
16f726 | 16f726_lcd_hd44780_4_4.jal
16f726 | 16f726_lcd_hd44780_4_1.jal
16f727 | 16f727_lcd_hd44780_4_1.jal
16f727 | 16f727_lcd_hd44780_4_4.jal
16f819 | 16f819_lcd_hd44780_4_4.jal
16f819 | 16f819_lcd_hd44780_4_1.jal
16f876a | 16f876a_keyboard_lcd.jal
16f876a | 16f876a_co2_t6603.jal
16f876a | 16f876a_lcd_hd44780_4_1.jal
16f876a | 16f876a_rtc_timeset.jal
16f876a | 16f876a_rtc_lcd.jal
16f876a | 16f876a_humidity_sht.jal
16f876a | 16f876a_tc77.jal
16f876a | 16f876a_lcd_hd44780_4_4.jal
16f877 | 16f877_backlight.jal
16f877 | 16f877_lcd_hd44780_4bit.jal
16f877 | 16f877_ds18b20_single.jal
16f877 | 16f877_lcd_hd44780_custom.jal
16f877a | 16f877a_co2_t6603.jal
16f877a | 16f877a_lcd_format.jal
16f877a | 16f877a_keyboard_lcd.jal
16f877a | 16f877a_rtc_lcd.jal
16f877a | 16f877a_ds1307_sw.jal
16f877a | 16f877a_lcd_hd44780_4bit.jal
16f877a | 16f877a_ds18b20_single.jal
16f877a | 16f877a_ds1307_hw.jal
16f877a | 16f877a_lcd_hd44780_4_1.jal
16f877a | 16f877a_rtc_timeset.jal
16f877a | 16f877a_backlight.jal
16f877a | 16f877a_lcd_hd44780_4_4.jal
16f877a | 16f877a_lcd_hd44780_custom.jal
16f88 | 16f88_lcd_hd44780_4bit.jal
16f88 | 16f88_lcd_hd44780_4_4.jal
16f88 | 16f88_lcd_hd44780_4_1.jal
16f88 | 16f88_ds18b20_single.jal
16f88 | 16f88_lcd_hd44780_custom.jal
16f88 | 16f88_lcd_hd44780_4_4_custom.jal
16f88 | 16f88_backlight.jal
16f886 | 16f886_rtc_lcd_4mhz.jal
16f886 | 16f886_pwm_adc_freq.jal
16f886 | 16f886_rtc_lcd_20mhz.jal
16f886 | 16f886_rtc_lcd_125khz.jal
16f886 | 16f886_pwm_adc_res.jal
16f887 | 16f887_lcd_hd44780_4_1.jal
16f887 | 16f887_lcd_hd44780_4_4.jal
18f1230 | 18f1230_lcd_hd44780_4_1.jal
18f14k50 | 18f14k50_pll.jal
18f2320 | 18f2320_lcd_hd44780_4_1.jal
18f2320 | 18f2320_lcd_hd44780_4_4.jal
18f2450 | 18f2450_lcd_hd44780_custom.jal
18f2450 | 18f2450_ds18b20_single.jal
18f2450 | 18f2450_lcd_hd44780_4bit.jal
18f25j10 | 18f25j10_test_mlx90615.jal
18f26j11 | 18f26j11_rtcc_hw_kbd_lcd.jal
18f452 | 18f452_lcd_hd44780_4bit.jal
18f452 | 18f452_ds18b20_single.jal
18f452 | 18f452_lcd_hd44780_custom.jal
18f452 | 18f452_backlight.jal
18f4550 | 18f4550_lcd_hd44780_4bit.jal
18f4550 | 18f4550_lcd_hd44780_custom.jal
18f4550 | 18f4550_ds18b20_single.jal
18f4685 | 18f4685_lcd_hd44780_4_1.jal
18f4685 | 18f4685_lcd_hd44780_4_4.jal
18f6310 | 18f6310_lcd_hd44780_4_1.jal
18f6310 | 18f6310_lcd_hd44780_4_4.jal