Author | Richard Zengerink, Copyright © 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 8 bit wide datapath + 2 handshake lines (total 10 PIC pins). Expects: - 2 pins for handshake: 'lcd_rs' and 'lcd_en' - 1 port 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 -- 8 data pins var bit lcd_en is pin_b0 -- trigger var bit lcd_rs is pin_b1 -- 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_direction = all_output pin_b0_direction = output pin_b0_direction = output 4. Call lcd_init() to initialize the lcd controller. Above is an example for a 2x16 LCD: portA are is used for data, pins 0 and 1 of portB are used for handshake. Any other available port and handshake pins could be used (provided these are configurable for output). . Available functions for application programs: . _lcd_write() sends byte from value to register of the lcd and shift cursor position 1 right . _lcd_write_data( ) write data to lcd using _lcd_write( ) lcd_rs high . _lcd_write_command( ) write command to lcd using _lcd_write( ) lcd_rs low . lcd_init() initialize the LCD controller
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(byte in value)
Send byte to the LCD and automatically set the cursor one position right.
_lcd_write_data(byte in value)
sends data byte in value to LCD for slow commands an extra delay should be added --
_lcd_write_command(byte in value)
sends command byte in value to LCD for slow commands an extra delay should be added