Author | Richard Zengerink, Copyright (c) 2008, all rights reserved |
Adapted-by | |
Compiler | =2.4 |
Simple interface for DOG-M (st7036) alphanumeric LCD screens. Screens can range from 1x8 (1 lines, 8 chars), 2x16 and 3x16. Uses 4 bit wide datapath + 2 handshake lines (total 6 PIC pins). Expects: - 2 pins for handshake: 'lcd_rs' and 'lcd_en' - 1 port nibble for data: 'lcd_dataport' * 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 3 lines const byte LCD_CHARS = 16 -- 8, 16 chars per line and variables (aliases): var byte lcd_dataport is portA_low -- 4 data pins var bit lcd_en is pin_A4 -- trigger var bit lcd_rs is pin_A5 -- cmd/data select 2. Include this library. and somewhere before actually using the lcd: 3. Set the chosen LCD dataport and handshake pins to output: portA_low_direction = all_output pin_A4_direction = output pin_A5_direction = output 4. Call lcd_init() to initialize the lcd controller. Above is an example for a 2x16 LCD: Bits 0..3 of portA are used for data, pins 4 and 5 of portA are used for handshake. Any other available nibble and handshake pins could be used (provided these are configurable for output).
const lcd_normal_delay = 3
delay's necessary for initialisation and some commands
const lcd_long_delay = 120
delay in 10 usec units = 1,2mS
lcd_init()
Initialize display in 1 and 2 or 3 line, display on, no cursor shown an cursor moves to the right.
_lcd_write_data(byte in value)
sends data byte in value to LCD
__lcd_write(byte in value)
Send byte to the LCD as 2 nibbles (most significant nibble first) and automatically set the cursor one position right.
_lcd_write_command(byte in value)
sends command byte in value to LCD