'*******************************************************************************
'引脚定义
Bla Alias Portd.7 : Ddrd.7 = 1
Scl Alias Portd.6 : Ddrd.6 = 1
Sda Alias Portd.5 : Ddrd.5 = 1
Res Alias Portd.4 : Ddrd.4 = 1
Sda_io Alias Ddrd.5
Sda_i Alias Pind.5
Led Alias Portc.0 : Ddrc.0 = 1 : Led = 1
'******************************************************************************* Dim I AsByte , J AsByte , K AsByte Dim X AsByte , Y AsByte Dim Mybyte AsByte , Myword AsWord , Mylong AsLong
'############################################################################### Sub Lcd_cls(byval Cls_byte AsByte)
Lcd_cmd &H20
Lcd_cmd &H44 ' // Set Y address=00 page
Lcd_cmd &H80 ' // Set X address=00 colum For J = 0 To 95
Lcd_dat Cls_byte Next
Lcd_cmd &H20
Lcd_cmd &H45 ' // Set Y address=00 page
Lcd_cmd &H80 ' // Set X address=00 colum For K = 0 To 95
Lcd_dat Cls_byte Next EndSub
'------------------------------------------------------------------------------- Sub Lcd_dis_byte(byval Dx AsByte , Byval Dy AsByte , Byval Dat AsByte) If Dx < 45 Then
Dx = &HB3 + Dx Else
Dx = &HDF - Dx EndIf
Dy = Dy + &H44
Lcd_cmd &H20
Lcd_cmd Dy
Lcd_cmd Dx
Lcd_dat Dat EndSub
'------------------------------------------------------------------------------- Sub Lcd_dis_char(byval Dx AsByte , Byval Dy AsByte , Byval Hex_char AsString * 1) Local Dat_hex AsString * 8 Local Dat_chr AsString * 1
Mybyte = Hexval(hex_char)
Myword = Mybyte * 6 For J = 0 To 5 '6X8点阵
Mybyte = Lookup(myword , Digit_lattice)
Lcd_dis_byte Dx , Dy , Mybyte
Dx = Dx + 1
Myword = Myword + 1 Next EndSub
'------------------------------------------------------------------------------- Sub Lcd_dis_str(byval Dx AsByte , Byval Dy AsByte , Byval Dis_str AsString * 16) Local Chr_str AsString * 1 Local Len_str AsByte Local Sx AsByte Local Index AsByte
Len_str = Len(dis_str)
For Index = 1 To Len_str
Chr_str = Mid(dis_str , Index , 1)
Mybyte = Hexval(chr_str)
Myword = Mybyte * 24
Sx = Dx For J = 1 To 12 '12X16点阵
Mybyte = Lookup(myword , Font12x16)
Lcd_dis_byte Sx , 0 , Mybyte
Sx = Sx + 1
Myword = Myword + 1 Next
Sx = Dx For J = 1 To 12 '12X16点阵
Mybyte = Lookup(myword , Font12x16)
Lcd_dis_byte Sx , 1 , Mybyte
Sx = Sx + 1
Myword = Myword + 1 Next
Dx = Dx + 12 Next EndSub
'------------------------------------------------------------------------------- Sub Lcd_init()
Res = 0 Waitms 10
Res = 1 Waitms 10