'-----------------------------------------------------------------------------------------
'name : lcd.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: LCD, CLS, LOWERLINE, SHIFTLCD, SHIFTCURSOR, HOME
' CURSOR, DISPLAY
'micro : Mega8515
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
$regfile = "m128def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
'--------------------------------------------------------------
' (c) 1995-2005 MCS Electronics
'--------------------------------------------------------------
' file: LCD.BAS
' demo: LCD, CLS, LOWERLINE, SHIFTLCD, SHIFTCURSOR, HOME
' CURSOR, DISPLAY
'--------------------------------------------------------------
'note : tested in bus mode with 4-bit on the STK200
'LCD - STK200
'-------------------
'D4 D4
'D5 D5
'D6 D6
'D7 D7
'WR WR
'E E
'RS RS
'+5V +5V
'GND GND
'V0 V0
' D0-D3 are not connected since 4 bit bus mode is used!
'Config Lcdpin = Pin , Db4 = Portb.1 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.4 , E = Portb.5 , Rs = Portb.6
Rem with the config lcdpin statement you can override the compiler settings
$lcd = &HC000
$lcdrs = &H8000
Config Lcdbus = 8
Dim A As Byte
Config Lcd = 20 * 4 'configure lcd screen
'other options are 16 * 2 , 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a
'When you dont include this option 16 * 2 is assumed
'16 * 1a is intended for 16 character displays with split addresses over 2 lines
'$LCD = address will turn LCD into 8-bit databus mode
' use this with uP with external RAM and/or ROM
' because it aint need the port pins !
Cls 'clear the LCD display
Lcd "Hello world." 'display this at the top line
Wait 1
Lowerline 'select the lower line
Wait 1
Lcd "Shift this." 'display this at the lower line
Wait 1
For A = 1 To 10
Shiftlcd Right 'shift the text to the right
Wait 1 'wait a moment
Next
For A = 1 To 10
Shiftlcd Left 'shift the text to the left
Wait 1 'wait a moment
Next
Locate 2 , 1 'set cursor position
Lcd "*" 'display this
Wait 1 'wait a moment
Shiftcursor Right 'shift the cursor
Lcd "@" 'display this
Wait 1 'wait a moment
Home Upper 'select line 1 and return home
Lcd "Replaced." 'replace the text
Wait 1 'wait a moment
Cursor Off Noblink 'hide cursor
Wait 1 'wait a moment
Cursor On Blink 'show cursor
Wait 1 'wait a moment
Display Off 'turn display off
Wait 1 'wait a moment
Display On 'turn display on
'-----------------NEW support for 4-line LCD------
Thirdline
Lcd "Line 3"
Fourthline
Lcd "Line 4"
Home Third 'goto home on line three
Home Fourth
Home F 'first letteer also works
Locate 4 , 1 : Lcd "Line 4"
Wait 1