本帖最后由 lilith 于 2012-7-19 11:17 编辑
fanfanrenfan 发表于 2012-7-18 10:14 ![](static/image/common/back.gif)
顶楼主,不但东西做的好,而且很耐心的解答各种问题!
同样关注12864的表头程序,呵呵! ...
那个东西等这个基本做好开始测试后再去完善它,然后丢上来吧
另外应对某些人的“使用编译器提供的 LCD 显示驱动”的质疑,用 BASIC 写了一个 KS0108 兼容的 19264 屏驱动 对于用 BASIC 的人来说这个够蛋疼了,其实编译器提供的东西拿来用没什么不好
$Device= m16
$Stack = 32
$Clock = 8
Dim i As Byte
Dim j As Byte
Dim Ft1 As Flash Byte
Dim Charat As String *33
Declare Function WriteKS(Code As Byte, Channel As Byte) As Byte
Declare Function SetKS(Code As Byte, Channel As Byte) As Byte
Declare Function InitKS() As Byte
Declare Function ResetKS() As Byte
Declare Function ClsKS(GRAM As Byte) As Byte
Declare Function DrawPix(x As Byte, y As Byte) As Byte
Declare Function DrawPage(x As Byte, Page As Byte, Code As Byte) As Byte
Declare Function DrawChr(x As Byte, Page As Byte) As Byte
DDRA = &b11111111
DDRC = &b11111111
InitKS()
ClsKS(0)
WaitUs 10
Charat = "0123456789:;<=>?@ABCDEFGHIJKLMNO"
DrawChr(1,0)
Charat = "PQRSTUVWXYZ[/]^-,abcdefghijklmno"
DrawChr(1,1)
Charat = "pqrstuvwxyz{|}\~!'#$%&()*+-."
DrawChr(1,2)
Wait 1
i = 0
Do
Charat = " "
DrawChr(1,4)
Charat = Str(i)
DrawChr(1,4)
i=i+1
WaitMs 250
Loop
Function SetKS(Code As Byte, Channel As Byte) As Byte
PORTC = Code
Select Case Channel
Case 1 : PORTA.3 = 0 : PORTA.4 = 0
Case 2 : PORTA.3 = 1 : PORTA.4 = 0
Case 3 : PORTA.3 = 0 : PORTA.4 = 1
End Select
PORTA.1 = 0
PORTA.2 = 0
PORTA.0 = 1 : WaitUs 1 : PORTA.0 = 0 : WaitUs 1
Return 0
End Function
Function WriteKS(Code As Byte, Channel As Byte) As Byte
PORTC = Code
Select Case Channel
Case 1 : PORTA.3 = 0 : PORTA.4 = 0
Case 2 : PORTA.3 = 1 : PORTA.4 = 0
Case 3 : PORTA.3 = 0 : PORTA.4 = 1
End Select
PORTA.1 = 0
PORTA.2 = 1
PORTA.0 = 1 : WaitUs 1 : PORTA.0 = 0 : WaitUs 1
Return 0
End Function
Function InitKS() As Byte
Local iC As Byte
ResetKS()
For iC = 1 To 3
SetKS(&hc0, iC)
SetKS(&h3f, iC)
Next iC
Return 0
End Function
Function ResetKS() As Byte
PORTA.5 = 0
WaitMs 200
PORTA.5 = 1
End Function
Function ClsKS(GRAM As Byte) As Byte
Local iP As Byte
Local iQ As Byte
Local iC As Byte
For iC = 1 To 3
For iP = 0 To 7
For iQ = 0 To 63
SetKS(&hB8 + iP, iC)' : WaitUs 1
SetKS(&h40 + iQ, iC)' : WaitUs 1
WriteKS(GRAM, iC)' : WaitUs 1
Next iQ
Next iP
Next iC
Return 0
End Function
Function DrawPix(x As Byte, y As Byte) As Byte
Local xAdd As Byte
Local xChip As Byte
Local yAdd As Byte
Local yCode As Byte
Local yPage As Byte
Local iStep As Byte
yCode = 1
xChip = ((x-1)/64)+1
xAdd = x mod 64
If xAdd = 0 Then
xAdd = 63
Else
xAdd = xAdd - 1
End If
yPage = (y-1)/8
yAdd = y mod 8
If yAdd = 0 Then yAdd = 8
For iStep = 1 To yAdd - 1
yCode = yCode * 2
Next iStep
If yAdd = 1 Then yCode = 1
SetKS(&hB8 + yPage, xChip)
SetKS(&h40 + xAdd, xChip)
WriteKS(yCode, xChip)
End Function
Function DrawPage(x As Byte, Page As Byte, Code As Byte) As Byte
Local xAdd As Byte
Local xChip As Byte
xChip = ((x-1)/64)+1
xAdd = x mod 64
If xAdd = 0 Then
xAdd = 63
Else
xAdd = xAdd - 1
End If
SetKS(&hB8 + Page, xChip)
SetKS(&h40 + xAdd, xChip)
WriteKS(Code, xChip)
Return 0
End Function
Function DrawChr(x As Byte, Page As Byte) As Byte
Local is As Byte
Local iLs As Byte
Local iFn As Byte
Local iChn As Byte
Local bChr As Byte
Local xAdd As Byte
xAdd = 0
iLs = Len(Charat)
For is = 1 To iLs
bChr = Asc(Mid(Charat,is,1)) - 32
For iFn = 0 To 4
iChn = Ft1(bChr * 5 + iFn)
DrawPage(x+xAdd,Page,iChn)
xAdd = xAdd + 1
Next iFn
xAdd = xAdd + 1
Next is
Return 0
End Function
' 字符码表:
Ft1 = &h00,&h00,&h00,&h00,&h00,&h00,
&h00,&h5F,&h00,&h00,&h00,&h03,
&h00,&h03,&h00,&h14,&h7F,&h14,
&h7F,&h14,&h44,&h4A,&hFF,&h52,
&h22,&h23,&h13,&h08,&h64,&h62,
&h36,&h49,&h55,&h22,&h50,&h00,
&h00,&h05,&h03,&h00,&h00,&h1C,
&h22,&h41,&h00,&h00,&h00,&h41,
&h22,&h1C,&h14,&h08,&h3E,&h08,
&h14,&h08,&h08,&h3E,&h08,&h08,
&h00,&hA0,&h60,&h00,&h00,&h08,
&h08,&h08,&h08,&h08,&h00,&h60,
&h60,&h00,&h00,&h20,&h10,&h08,
&h04,&h02,&h3E,&h51,&h49,&h45,
&h3E,&h00,&h42,&h7F,&h40,&h00,
&h42,&h61,&h51,&h49,&h46,&h21,
&h41,&h45,&h4B,&h31,&h18,&h14,
&h12,&h7F,&h10,&h27,&h45,&h45,
&h45,&h39,&h3C,&h4A,&h49,&h49,
&h30,&h01,&h71,&h09,&h05,&h03,
&h36,&h49,&h49,&h49,&h36,&h06,
&h49,&h49,&h29,&h1E,&h00,&h36,
&h36,&h00,&h00,&h00,&hA6,&h66,
&h00,&h00,&h08,&h14,&h22,&h41,
&h00,&h14,&h14,&h14,&h14,&h14,
&h41,&h22,&h14,&h08,&h00,&h02,
&h01,&h51,&h09,&h06,&h42,&h63,
&h52,&h4B,&h46,&h7E,&h11,&h11,
&h11,&h7E,&h7F,&h49,&h49,&h49,
&h36,&h3E,&h41,&h41,&h41,&h22,
&h7F,&h41,&h41,&h22,&h1C,&h7F,
&h49,&h49,&h49,&h41,&h7F,&h09,
&h09,&h09,&h01,&h3E,&h41,&h49,
&h49,&h7A,&h7F,&h08,&h08,&h08,
&h7F,&h00,&h41,&h7F,&h41,&h00,
&h20,&h40,&h41,&h3F,&h01,&h7F,
&h08,&h14,&h22,&h41,&h7F,&h40,
&h40,&h40,&h40,&h7F,&h02,&h0C,
&h02,&h7F,&h7F,&h04,&h08,&h10,
&h7F,&h3E,&h41,&h41,&h41,&h3E,
&h7F,&h09,&h09,&h09,&h06,&h3E,
&h41,&h51,&h21,&h5E,&h7F,&h09,
&h19,&h29,&h46,&h26,&h49,&h49,
&h49,&h32,&h01,&h01,&h7F,&h01,
&h01,&h3F,&h40,&h40,&h40,&h3F,
&h1F,&h20,&h40,&h20,&h1F,&h3F,
&h40,&h38,&h40,&h3F,&h63,&h14,
&h08,&h14,&h63,&h07,&h08,&h70,
&h08,&h07,&h61,&h51,&h49,&h45,
&h43,&h48,&h56,&h54,&h56,&h24,
&h02,&h04,&h08,&h10,&h20,&h3C,
&h42,&h42,&h43,&h24,&h3C,&h43,
&h42,&h43,&h24,&h80,&h80,&h80,
&h80,&h80,&h44,&h65,&h56,&h4D,
&h44,&h30,&h54,&h54,&h54,&h78,
&h7F,&h44,&h44,&h44,&h38,&h38,
&h44,&h44,&h44,&h44,&h38,&h44,
&h44,&h44,&h7F,&h38,&h54,&h54,
&h54,&h18,&h04,&h04,&h7E,&h05,
&h05,&h18,&hA4,&hA4,&hA4,&h7C,
&h7F,&h08,&h04,&h04,&h78,&h00,
&h44,&h7D,&h40,&h00,&h40,&h80,
&h84,&h7D,&h00,&h7F,&h10,&h28,
&h44,&h00,&h00,&h41,&h7F,&h40,
&h00,&h7C,&h04,&h7C,&h04,&h78,
&h7C,&h08,&h04,&h04,&h78,&h38,
&h44,&h44,&h44,&h38,&hFC,&h24,
&h24,&h24,&h18,&h18,&h24,&h24,
&h24,&hFC,&h7C,&h08,&h04,&h04,
&h00,&h48,&h54,&h54,&h54,&h24,
&h04,&h04,&h3F,&h44,&h44,&h3C,
&h40,&h40,&h20,&h7C,&h1C,&h20,
&h40,&h20,&h1C,&h3C,&h40,&h30,
&h40,&h3C,&h44,&h28,&h10,&h28,
&h44,&h1C,&hA0,&hA0,&hA0,&h7C,
&h44,&h64,&h54,&h4C,&h44,&h48,
&h55,&h56,&h55,&h24,&h00,&h00,
&h77,&h00,&h00,&h38,&h44,&h46,
&h45,&h44,&h38,&h45,&h46,&h45,
&h44,&h00,&h00,&h07,&h05,&h07 |