This produces exactly the same pattern on line 2, 3 and 4.
It means that you can use print chr(8)...chr(15) in stead of chr(0)...chr(7). It is because the bit 3 (of 0, 1, 2, 3) in CGRAM address is a "don't care" bit.
[code:1:4249666d69] $regfile = "m162def.dat" ' specify the used micro
$crystal = 8000000 ' used crystal frequency
$baud = 9600 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 32 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
$sim
' ==============================================================================
' LCD
Config Lcd = 20 * 4
'Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.4 , Rs = Portc.5
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Wr = Portc.1 , Rs = Portc.0
Deflcdchar 0 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ' replace [x] with number (0-7)
Deflcdchar 1 , 24 , 24 , 24 , 24 , 24 , 24 , 24 , 24 ' replace [x] with number (0-7)
Deflcdchar 2 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 ' replace [x] with number (0-7)
Deflcdchar 3 , 30 , 30 , 30 , 30 , 30 , 30 , 30 , 30 ' replace [x] with number (0-7)
Deflcdchar 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ' replace [x] with number (0-7)
Deflcdchar 5 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ' replace [x] with number (0-7)
Deflcdchar 6 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 ' replace [x] with number (0-7)
Deflcdchar 7 , 15 , 15 , 15 , 15 , 15 , 15 , 15 , 15 ' replace [x] with number (0-7)
Cls
' ==============================================================================
' Mainprogramm:
Dim Dummy As String * 10
Dim Dummy2 As String * 1
Wait 1
Do
Cls
Locate 1 , 1
Lcd "-12345678-"
Locate 2 , 1
Lcd "-" ; Chr(4) ; Chr(5) ; Chr(6) ; Chr(7) ; Chr(3) ; Chr(2) ; Chr(1) ; Chr(0) ; "-";
Locate 3 , 1
Lcd "-" ; Chr(12) ; Chr(13) ; Chr(14) ; Chr(15) ; Chr(11) ; Chr(10) ; Chr(1) ; Chr(8) ; "-";
Locate 4 , 1
Dummy = Chr(4) + Chr(5) + Chr(6) + Chr(7) + Chr(3) + Chr(2) + Chr(1) + Chr(8)
Lcd "-" ; Dummy ; "-";
Input "Repeat ? " , Dummy2
Loop
End
[/code:1:4249666d69]
↧