Pada hari yang mendung ini saya akan menjelaskan bagaimana cara mengakses LCD grafik / LCD GRAPHIC 128x64 menggunakan kontroller ST7920, sekedar informasi saja bahwa tiap-tiap LCD grafik memiliki kontrollernya masing-masing, jadi tidak bisa asal menggunakan kontroller, harus tau tipe LCD grafik yang digunakan dan kontroller yang digunakan oleh GLCD tersebut. ada bermacam-macam tipe GLCD dan jenis kontroller salah satunya ST7920, yang lainnya KS0108 dll, jika dilihat kedua GLCD tersebut sekilas sama namun pin yang digunakan berbeda berikut tampilan dari GLCD kontroller ST7920, perbedaan mencolok dari tipe GLCD ST7920 dan KS0108 yaitu terdapat pin NC dan PSB pada GLCD ST7920, pada GLCD KS0108 yaitu terdapat pin D/I, CS1 dan CS2.
1. GLCD 128x64 dengan kontroller ST7920
2. Skematik Minimum System
3. Cara Pemasangan MCU ke GLCD
MCU GLCD
PortC.0 - PortC.1 DB.0 - DB.7
PortD.7 RS
PortD.6 RW
PortD.5 E
PortD.4 PSB
PortD,3 RST
GND VSS
+5 V VDD
GND K
+5 V A
Untuk Pemasangan Vout dan Vo seperti gambar berikut
*catatan = Data (DB0-DB7) dihubungkan ke PortC mikrokontroller, untuk itu harus melakukan disable JTAG mikrokontroller pada PortC dengan cara berikut jika menggunakan AVRDUDE, pada LOW FUSE isikan FF dan pada HIGH FUSE isikan C9. seperti gambar berikut.
4. Program BASCOM AVR
$regfile = "m32def.dat"
$crystal = 4000000
$hwstack = 32
$swstack = 20
$framesize = 40
Declare Sub Lcdstart()
Declare Sub Lcdimgcls()
Declare Sub Imgcls()
Declare Sub Lcdcommand(ir As Byte)
Declare Sub Lcdwrite(dr_en As Byte)
Declare Function Lcdget() As Byte
Declare Sub Showstr(zf As String)
Declare Sub Point(x As Byte , Y As Byte)
Declare Sub Lcdline(px1 As Byte , Py1 As Byte , Px2 As Byte , Py2 As Byte )
Declare Sub Lcdcircle(px1 As Byte , Py1 As Byte , Rcircle As Byte)
Outport Alias Portc
Getport Alias Pinc
Rs Alias Portd.7 'H: Data L: Instruction Code
Rw Alias Portd.6 'H: Read L: Write
E Alias Portd.5
Psb Alias Portd.4
Rst Alias Portd.3
Ddrc = &HFF
Ddrd = &HFF
Portc = 0
Portd = 0
Dim Mybyte As Byte
Dim Myword As Word
Dim Lcdstr As String * 32
Dim Lcdx As Byte
Dim Lcdy As Byte
Dim Pstx As Byte , Psty As Byte
Dim Xx1 As Byte , Yy1 As Byte , Xx2 As Byte , Yy2 As Byte
Dim K As Single , Mysingle As Single
Dim Dx As Integer , Dy As Integer
Dim X As Byte , Y As Byte
Dim Xi As Byte , Yi As Byte
Dim Xadrs As Byte , Yadrs As Byte , Xpos As Byte
Dim Byteh As Byte , Bytel As Byte
Const Pi = 3.1416
Dim Strsatuan As String * 1
Dim Strpuluhan As String * 1
Dim Strratusan As String * 1
Dim Strribuan As String * 1
Dim Ribuan As Integer
Dim Ratusan As Integer
Dim Puluhan As Integer
Dim Satuan As Integer
Set Psb
Set Rst
Reset Rw
Reset E
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Dim Dataadc As Integer
Dim Temp As Integer
Start Adc
'========== ( main program ) =========
Call Lcdstart
Mybyte = &B00001100 : Lcdcommand Mybyte 'To Write Character
'&H98 = 9 untuk baris / row , 8 untuk kolom
Mybyte = &H81
Lcdcommand Mybyte
Lcdstr = "LCD GRAPHIC"
Showstr Lcdstr
Mybyte = &H92
Lcdcommand Mybyte
Lcdstr = "ST7920"
Showstr Lcdstr
Mybyte = &H89
Lcdcommand Mybyte
Lcdstr = "BY YANUAR M"
Showstr Lcdstr
Mybyte = &H9A
Lcdcommand Mybyte
Lcdstr = "LANJUT ??"
Showstr Lcdstr
Wait 2
Call Lcdimgcls
'&H98 = 9 untuk baris / row , 8 untuk kolom
Mybyte = &H81
Lcdcommand Mybyte
Lcdstr = "OK KITA"
Showstr Lcdstr
Mybyte = &H92
Lcdcommand Mybyte
Lcdstr = "LANJUTKAN"
Showstr Lcdstr
Mybyte = &H89
Lcdcommand Mybyte
Lcdstr = "DEMO LCD"
Showstr Lcdstr
Mybyte = &H9A
Lcdcommand Mybyte
Lcdstr = "GRAPHIC"
Showstr Lcdstr
Wait 2
Call Lcdimgcls
Mybyte = &B00110110
Lcdcommand Mybyte
Call Imgcls
'atas
'0 ujung kiri atas
'127 ujung kanan atas
'kotak 1
' (50,10)
Psty = 10
For Pstx = 50 To 100 Step 1
Point Pstx , Psty
Next
' (100,10)
Pstx = 100
For Psty = 10 To 20 Step 1
Point Pstx , Psty
Next
'bawah
' (100,20)
Psty = 20
For Pstx = 100 To 50 Step -1
Point Pstx , Psty
Next
' (50,20)
Pstx = 50
For Psty = 20 To 10 Step -1
Point Pstx , Psty
Next
Wait 2
Call Imgcls
'kotak 2
' (50,20)
Psty = 20
For Pstx = 50 To 100 Step 1
Point Pstx , Psty
Next
' (100,20)
Pstx = 100
For Psty = 20 To 40 Step 1
Point Pstx , Psty
Next
'bawah
' (100,40)
Psty = 40
For Pstx = 100 To 50 Step -1
Point Pstx , Psty
Next
' (50,40)
Pstx = 50
For Psty = 40 To 20 Step -1
Point Pstx , Psty
Next
Wait 2
'titik tengah lingkaran (50,40)
Pstx = 50 : Psty = 40 : Mybyte = 15
Lcdcircle Pstx , Psty , Mybyte
Wait 1
Pstx = 100 : Psty = 40 : Mybyte = 15
Lcdcircle Pstx , Psty , Mybyte
Wait 1
' (70,0)
Psty = 0
For Pstx = 70 To 80 Step 1
Point Pstx , Psty
Next
' (80,0)
Pstx = 80
For Psty = 0 To 20 Step 1
Point Pstx , Psty
Next
'bawah
' (70,20)
Pstx = 70
For Psty = 20 To 0 Step -1
Point Pstx , Psty
Next
Wait 2
Call Imgcls
Call Lcdstart
Mybyte = &B00001100 : Lcdcommand Mybyte 'To Write Character
Call Lcdimgcls
Do
Mybyte = &H81
Lcdcommand Mybyte
Lcdstr = "DATA ADC"
Showstr Lcdstr
Dataadc = Getadc(0)
Temp = Dataadc
'mencari angka ribuan
Ribuan = Temp / 1000
'Mencari angka Ratusan
Ratusan = Temp / 100
'Mencari angka Puluhan
Temp = Temp Mod 100
Puluhan = Temp / 10
'Mencari angka Satuan
Satuan = Temp Mod 10
Mybyte = &H81
Lcdcommand Mybyte
Lcdstr = "DATA ADC"
Showstr Lcdstr
Mybyte = &H91
Lcdcommand Mybyte
Lcdstr = Strribuan
Showstr Lcdstr
Lcdstr = Strratusan
Showstr Lcdstr
Lcdstr = Strpuluhan
Showstr Lcdstr
Lcdstr = Strsatuan
Showstr Lcdstr
If Satuan = 0 Then
Strsatuan = "0"
Elseif Satuan = 1 Then
Strsatuan = "1"
Elseif Satuan = 2 Then
Strsatuan = "2"
Elseif Satuan = 3 Then
Strsatuan = "3"
Elseif Satuan = 4 Then
Strsatuan = "4"
Elseif Satuan = 5 Then
Strsatuan = "5"
Elseif Satuan = 6 Then
Strsatuan = "6"
Elseif Satuan = 7 Then
Strsatuan = "7"
Elseif Satuan = 8 Then
Strsatuan = "8"
Elseif Satuan = 9 Then
Strsatuan = "9"
Else
'Strsatuan = "0"
End If
If Puluhan = 0 Then
Strpuluhan = "0"
Elseif Puluhan = 1 Then
Strpuluhan = "1"
Elseif Puluhan = 2 Then
Strpuluhan = "2"
Elseif Puluhan = 3 Then
Strpuluhan = "3"
Elseif Puluhan = 4 Then
Strpuluhan = "4"
Elseif Puluhan = 5 Then
Strpuluhan = "5"
Elseif Puluhan = 6 Then
Strpuluhan = "6"
Elseif Puluhan = 7 Then
Strpuluhan = "7"
Elseif Puluhan = 8 Then
Strpuluhan = "8"
Elseif Puluhan = 9 Then
Strpuluhan = "9"
Else
'Strpuluhan = "0"
End If
If Ratusan = 0 Then
Strratusan = "0"
Elseif Ratusan = 1 Then
Strratusan = "1"
Elseif Ratusan = 2 Then
Strratusan = "2"
Elseif Ratusan = 3 Then
Strratusan = "3"
Elseif Ratusan = 4 Then
Strratusan = "4"
Elseif Ratusan = 5 Then
Strratusan = "5"
Elseif Ratusan = 6 Then
Strratusan = "6"
Elseif Ratusan = 7 Then
Strratusan = "7"
Elseif Ratusan = 8 Then
Strratusan = "8"
Elseif Ratusan = 9 Then
Strratusan = "9"
Else
' Strratusan = "0"
End If
If Ribuan = 0 Then
Strribuan = "0"
Elseif Ribuan = 1 Then
Strribuan = "1"
Elseif Ribuan = 2 Then
Strribuan = "2"
Elseif Ribuan = 3 Then
Strribuan = "3"
Elseif Ribuan = 4 Then
Strribuan = "4"
Elseif Ribuan = 5 Then
Strribuan = "5"
Elseif Ribuan = 6 Then
Strribuan = "6"
Elseif Ribuan = 7 Then
Strribuan = "7"
Elseif Ribuan = 8 Then
Strribuan = "8"
Elseif Ribuan = 9 Then
Strribuan = "9"
Else
'Strribuan = "0"
End If
Waitms 500
Call Lcdimgcls
Loop
'===========( sub program )============
Function Lcdget()as Byte
E = 0
Rs = 1
Rw = 1
E = 1
Ddrc = 0
Outport = 0
nop
Lcdget = Getport
nop
E = 0
Rw = 0
Waitus 80
Ddrc = &HFF
End Function
Sub Lcdstart()
Waitms 50
Mybyte = &H30 : Lcdcommand Mybyte
Mybyte = &B01 : Lcdcommand Mybyte : Waitms 2
Mybyte = &H06 : Lcdcommand Mybyte
Mybyte = &H0C : Lcdcommand Mybyte
End Sub
Sub Lcdcommand(ir As Byte)
E = 0
Rs = 0
E = 1
nop
Outport = Ir
nop
E = 0
Waitus 80
End Sub
Sub Lcdwrite(dr_en As Byte)
E = 0
Rs = 1
E = 1
nop
Outport = Dr_en
nop
E = 0
Waitus 80
End Sub
Sub Showstr(zf As String)
Local T As Byte , I As Byte , Zf1 As String * 1
Zf = Format(zf , "0")
For T = 1 To Len(zf)
Zf1 = Mid(zf , T , 1)
I = Asc(zf1)
Lcdwrite I
Next
End Sub
Sub Lcdimgcls()
Mybyte = &H80
Lcdcommand Mybyte
Lcdstr = " "
Showstr Lcdstr
Mybyte = &H90
Lcdcommand Mybyte
Lcdstr = " "
Showstr Lcdstr
Mybyte = &H88
Lcdcommand Mybyte
Lcdstr = " "
Showstr Lcdstr
Mybyte = &H98
Lcdcommand Mybyte
Lcdstr = " "
Showstr Lcdstr
End Sub
Sub Lcdcircle(px1 As Byte , Py1 As Byte , Rcircle As Byte)
For Myword = 0 To 359 Step 2
Mysingle = Myword
K = Deg2rad(mysingle)
Mysingle = Sin(k)
Mysingle = Mysingle * Rcircle
Xx1 = Mysingle + Px1
Mysingle = Cos(k)
Mysingle = Mysingle * Rcircle
Yy1 = Mysingle + Py1
Point Xx1 , Yy1
Next
End Sub
Sub Point(x As Byte , Y As Byte )
' (0,0)-(127,63)
Xadrs = X \ 16
Xpos = X Mod 16
Yadrs = Y \ 32
Yadrs = Yadrs * 8
Xadrs = Xadrs + Yadrs
Yadrs = Y Mod 32
Xadrs = Xadrs + &H80
Yadrs = Yadrs + &H80
Lcdcommand Yadrs
Lcdcommand Xadrs
Byteh = Lcdget()
Byteh = Lcdget()
Bytel = Lcdget()
If Xpos < 8 Then
Xpos = 7 - Xpos
Xpos = 2 ^ Xpos
Byteh = Byteh Or Xpos
Else
Xpos = 15 - Xpos
Xpos = 2 ^ Xpos
Bytel = Bytel Or Xpos
End If
Lcdcommand Yadrs
Lcdcommand Xadrs
Lcdwrite Byteh
Lcdwrite Bytel
End Sub
Sub Imgcls()
Mybyte = &H00
For Lcdx = &H80 To &B10001111
For Lcdy = &H80 To &B10011111
Lcdcommand Lcdy
Lcdcommand Lcdx
Lcdwrite Mybyte
Lcdwrite Mybyte
Next
Next
End Sub
$crystal = 4000000
$hwstack = 32
$swstack = 20
$framesize = 40
Declare Sub Lcdstart()
Declare Sub Lcdimgcls()
Declare Sub Imgcls()
Declare Sub Lcdcommand(ir As Byte)
Declare Sub Lcdwrite(dr_en As Byte)
Declare Function Lcdget() As Byte
Declare Sub Showstr(zf As String)
Declare Sub Point(x As Byte , Y As Byte)
Declare Sub Lcdline(px1 As Byte , Py1 As Byte , Px2 As Byte , Py2 As Byte )
Declare Sub Lcdcircle(px1 As Byte , Py1 As Byte , Rcircle As Byte)
Outport Alias Portc
Getport Alias Pinc
Rs Alias Portd.7 'H: Data L: Instruction Code
Rw Alias Portd.6 'H: Read L: Write
E Alias Portd.5
Psb Alias Portd.4
Rst Alias Portd.3
Ddrc = &HFF
Ddrd = &HFF
Portc = 0
Portd = 0
Dim Mybyte As Byte
Dim Myword As Word
Dim Lcdstr As String * 32
Dim Lcdx As Byte
Dim Lcdy As Byte
Dim Pstx As Byte , Psty As Byte
Dim Xx1 As Byte , Yy1 As Byte , Xx2 As Byte , Yy2 As Byte
Dim K As Single , Mysingle As Single
Dim Dx As Integer , Dy As Integer
Dim X As Byte , Y As Byte
Dim Xi As Byte , Yi As Byte
Dim Xadrs As Byte , Yadrs As Byte , Xpos As Byte
Dim Byteh As Byte , Bytel As Byte
Const Pi = 3.1416
Dim Strsatuan As String * 1
Dim Strpuluhan As String * 1
Dim Strratusan As String * 1
Dim Strribuan As String * 1
Dim Ribuan As Integer
Dim Ratusan As Integer
Dim Puluhan As Integer
Dim Satuan As Integer
Set Psb
Set Rst
Reset Rw
Reset E
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Dim Dataadc As Integer
Dim Temp As Integer
Start Adc
'========== ( main program ) =========
Call Lcdstart
Mybyte = &B00001100 : Lcdcommand Mybyte 'To Write Character
'&H98 = 9 untuk baris / row , 8 untuk kolom
Mybyte = &H81
Lcdcommand Mybyte
Lcdstr = "LCD GRAPHIC"
Showstr Lcdstr
Mybyte = &H92
Lcdcommand Mybyte
Lcdstr = "ST7920"
Showstr Lcdstr
Mybyte = &H89
Lcdcommand Mybyte
Lcdstr = "BY YANUAR M"
Showstr Lcdstr
Mybyte = &H9A
Lcdcommand Mybyte
Lcdstr = "LANJUT ??"
Showstr Lcdstr
Wait 2
Call Lcdimgcls
'&H98 = 9 untuk baris / row , 8 untuk kolom
Mybyte = &H81
Lcdcommand Mybyte
Lcdstr = "OK KITA"
Showstr Lcdstr
Mybyte = &H92
Lcdcommand Mybyte
Lcdstr = "LANJUTKAN"
Showstr Lcdstr
Mybyte = &H89
Lcdcommand Mybyte
Lcdstr = "DEMO LCD"
Showstr Lcdstr
Mybyte = &H9A
Lcdcommand Mybyte
Lcdstr = "GRAPHIC"
Showstr Lcdstr
Wait 2
Call Lcdimgcls
Mybyte = &B00110110
Lcdcommand Mybyte
Call Imgcls
'atas
'0 ujung kiri atas
'127 ujung kanan atas
'kotak 1
' (50,10)
Psty = 10
For Pstx = 50 To 100 Step 1
Point Pstx , Psty
Next
' (100,10)
Pstx = 100
For Psty = 10 To 20 Step 1
Point Pstx , Psty
Next
'bawah
' (100,20)
Psty = 20
For Pstx = 100 To 50 Step -1
Point Pstx , Psty
Next
' (50,20)
Pstx = 50
For Psty = 20 To 10 Step -1
Point Pstx , Psty
Next
Wait 2
Call Imgcls
'kotak 2
' (50,20)
Psty = 20
For Pstx = 50 To 100 Step 1
Point Pstx , Psty
Next
' (100,20)
Pstx = 100
For Psty = 20 To 40 Step 1
Point Pstx , Psty
Next
'bawah
' (100,40)
Psty = 40
For Pstx = 100 To 50 Step -1
Point Pstx , Psty
Next
' (50,40)
Pstx = 50
For Psty = 40 To 20 Step -1
Point Pstx , Psty
Next
Wait 2
'titik tengah lingkaran (50,40)
Pstx = 50 : Psty = 40 : Mybyte = 15
Lcdcircle Pstx , Psty , Mybyte
Wait 1
Pstx = 100 : Psty = 40 : Mybyte = 15
Lcdcircle Pstx , Psty , Mybyte
Wait 1
' (70,0)
Psty = 0
For Pstx = 70 To 80 Step 1
Point Pstx , Psty
Next
' (80,0)
Pstx = 80
For Psty = 0 To 20 Step 1
Point Pstx , Psty
Next
'bawah
' (70,20)
Pstx = 70
For Psty = 20 To 0 Step -1
Point Pstx , Psty
Next
Wait 2
Call Imgcls
Call Lcdstart
Mybyte = &B00001100 : Lcdcommand Mybyte 'To Write Character
Call Lcdimgcls
Do
Mybyte = &H81
Lcdcommand Mybyte
Lcdstr = "DATA ADC"
Showstr Lcdstr
Dataadc = Getadc(0)
Temp = Dataadc
'mencari angka ribuan
Ribuan = Temp / 1000
'Mencari angka Ratusan
Ratusan = Temp / 100
'Mencari angka Puluhan
Temp = Temp Mod 100
Puluhan = Temp / 10
'Mencari angka Satuan
Satuan = Temp Mod 10
Mybyte = &H81
Lcdcommand Mybyte
Lcdstr = "DATA ADC"
Showstr Lcdstr
Mybyte = &H91
Lcdcommand Mybyte
Lcdstr = Strribuan
Showstr Lcdstr
Lcdstr = Strratusan
Showstr Lcdstr
Lcdstr = Strpuluhan
Showstr Lcdstr
Lcdstr = Strsatuan
Showstr Lcdstr
If Satuan = 0 Then
Strsatuan = "0"
Elseif Satuan = 1 Then
Strsatuan = "1"
Elseif Satuan = 2 Then
Strsatuan = "2"
Elseif Satuan = 3 Then
Strsatuan = "3"
Elseif Satuan = 4 Then
Strsatuan = "4"
Elseif Satuan = 5 Then
Strsatuan = "5"
Elseif Satuan = 6 Then
Strsatuan = "6"
Elseif Satuan = 7 Then
Strsatuan = "7"
Elseif Satuan = 8 Then
Strsatuan = "8"
Elseif Satuan = 9 Then
Strsatuan = "9"
Else
'Strsatuan = "0"
End If
If Puluhan = 0 Then
Strpuluhan = "0"
Elseif Puluhan = 1 Then
Strpuluhan = "1"
Elseif Puluhan = 2 Then
Strpuluhan = "2"
Elseif Puluhan = 3 Then
Strpuluhan = "3"
Elseif Puluhan = 4 Then
Strpuluhan = "4"
Elseif Puluhan = 5 Then
Strpuluhan = "5"
Elseif Puluhan = 6 Then
Strpuluhan = "6"
Elseif Puluhan = 7 Then
Strpuluhan = "7"
Elseif Puluhan = 8 Then
Strpuluhan = "8"
Elseif Puluhan = 9 Then
Strpuluhan = "9"
Else
'Strpuluhan = "0"
End If
If Ratusan = 0 Then
Strratusan = "0"
Elseif Ratusan = 1 Then
Strratusan = "1"
Elseif Ratusan = 2 Then
Strratusan = "2"
Elseif Ratusan = 3 Then
Strratusan = "3"
Elseif Ratusan = 4 Then
Strratusan = "4"
Elseif Ratusan = 5 Then
Strratusan = "5"
Elseif Ratusan = 6 Then
Strratusan = "6"
Elseif Ratusan = 7 Then
Strratusan = "7"
Elseif Ratusan = 8 Then
Strratusan = "8"
Elseif Ratusan = 9 Then
Strratusan = "9"
Else
' Strratusan = "0"
End If
If Ribuan = 0 Then
Strribuan = "0"
Elseif Ribuan = 1 Then
Strribuan = "1"
Elseif Ribuan = 2 Then
Strribuan = "2"
Elseif Ribuan = 3 Then
Strribuan = "3"
Elseif Ribuan = 4 Then
Strribuan = "4"
Elseif Ribuan = 5 Then
Strribuan = "5"
Elseif Ribuan = 6 Then
Strribuan = "6"
Elseif Ribuan = 7 Then
Strribuan = "7"
Elseif Ribuan = 8 Then
Strribuan = "8"
Elseif Ribuan = 9 Then
Strribuan = "9"
Else
'Strribuan = "0"
End If
Waitms 500
Call Lcdimgcls
Loop
'===========( sub program )============
Function Lcdget()as Byte
E = 0
Rs = 1
Rw = 1
E = 1
Ddrc = 0
Outport = 0
nop
Lcdget = Getport
nop
E = 0
Rw = 0
Waitus 80
Ddrc = &HFF
End Function
Sub Lcdstart()
Waitms 50
Mybyte = &H30 : Lcdcommand Mybyte
Mybyte = &B01 : Lcdcommand Mybyte : Waitms 2
Mybyte = &H06 : Lcdcommand Mybyte
Mybyte = &H0C : Lcdcommand Mybyte
End Sub
Sub Lcdcommand(ir As Byte)
E = 0
Rs = 0
E = 1
nop
Outport = Ir
nop
E = 0
Waitus 80
End Sub
Sub Lcdwrite(dr_en As Byte)
E = 0
Rs = 1
E = 1
nop
Outport = Dr_en
nop
E = 0
Waitus 80
End Sub
Sub Showstr(zf As String)
Local T As Byte , I As Byte , Zf1 As String * 1
Zf = Format(zf , "0")
For T = 1 To Len(zf)
Zf1 = Mid(zf , T , 1)
I = Asc(zf1)
Lcdwrite I
Next
End Sub
Sub Lcdimgcls()
Mybyte = &H80
Lcdcommand Mybyte
Lcdstr = " "
Showstr Lcdstr
Mybyte = &H90
Lcdcommand Mybyte
Lcdstr = " "
Showstr Lcdstr
Mybyte = &H88
Lcdcommand Mybyte
Lcdstr = " "
Showstr Lcdstr
Mybyte = &H98
Lcdcommand Mybyte
Lcdstr = " "
Showstr Lcdstr
End Sub
Sub Lcdcircle(px1 As Byte , Py1 As Byte , Rcircle As Byte)
For Myword = 0 To 359 Step 2
Mysingle = Myword
K = Deg2rad(mysingle)
Mysingle = Sin(k)
Mysingle = Mysingle * Rcircle
Xx1 = Mysingle + Px1
Mysingle = Cos(k)
Mysingle = Mysingle * Rcircle
Yy1 = Mysingle + Py1
Point Xx1 , Yy1
Next
End Sub
Sub Point(x As Byte , Y As Byte )
' (0,0)-(127,63)
Xadrs = X \ 16
Xpos = X Mod 16
Yadrs = Y \ 32
Yadrs = Yadrs * 8
Xadrs = Xadrs + Yadrs
Yadrs = Y Mod 32
Xadrs = Xadrs + &H80
Yadrs = Yadrs + &H80
Lcdcommand Yadrs
Lcdcommand Xadrs
Byteh = Lcdget()
Byteh = Lcdget()
Bytel = Lcdget()
If Xpos < 8 Then
Xpos = 7 - Xpos
Xpos = 2 ^ Xpos
Byteh = Byteh Or Xpos
Else
Xpos = 15 - Xpos
Xpos = 2 ^ Xpos
Bytel = Bytel Or Xpos
End If
Lcdcommand Yadrs
Lcdcommand Xadrs
Lcdwrite Byteh
Lcdwrite Bytel
End Sub
Sub Imgcls()
Mybyte = &H00
For Lcdx = &H80 To &B10001111
For Lcdy = &H80 To &B10011111
Lcdcommand Lcdy
Lcdcommand Lcdx
Lcdwrite Mybyte
Lcdwrite Mybyte
Next
Next
End Sub
5. VIDEO HASILNYA
Hi, great blog, helped me a lot, but do you by any chance have more example programs for 128x64 dengan ST7920 Controller BASCOM AVR?
ReplyDeleteThanks.