DarkBeast
08.12.2007, 16:33
so ich habe mir hier aus dem forum ein codeschnippsel für das display von pollin mit der bezeichnung "HLM8070" besorgt und etwas umgestrickt. Funktioniert auch wunderbar doch jetzt würde ich das *bas programm dazu gerne als lib verwenden um dann z.B. dieses programm bei bedarf in andere programme einbauen zu können ähnlich wie die anderen displays per LCD-anweisung wie die in bascom schon enthalten ist kann mir irgendwer erklären wie das geht ????
bin allerdings weder in c noch in asm eine leuchte auch meine Bascom kentnisse bewegen sich eher auf anfänger niveau
hier erstmal der code den ich verwende damit auch andere die das teil haben es mit einfachen mitteln einsetzen können
$regfile = "m32def.dat"
$crystal = 16000000
Declare Sub Lcd_m50530_init() 'declare the SUB program
Declare Sub Lcd_m50530_chr(ch As Byte)
Declare Sub Lcd_m50530_command(command As Byte)
Declare Sub Lcd_m50530_gotoxy(lcd_x As Byte , Lcd_y As Byte)
Declare Sub Lcd_m50530_clear()
Declare Sub Lcd_m50530_enable
Declare Sub Lcd_m50530_print()
Lcd_m50530 Alias Portc
Config Lcd_m50530 = Output
_oc1 Alias 4
_oc2 Alias 5
_ex Alias 6
Dim T As Byte ' Zählschleife
Dim Lcd_temp As Byte ' Temp im Unterprogramm
Dim Lcd_parameter As Byte ' wird an LCD gesendet
Dim _x As Byte ' Cursor x Position
Dim _y As Byte ' Cursor y Position
Dim Text As String * 16 ' String zur textübergabe
Dim Xstring As String * 16
Dim Xchar As Byte
Dim I As Byte
'-------------------------
' Begin Hauptprogramm
'-------------------------
_x = 5 : _y = 2
Call Lcd_m50530_init
Do
For I = 1 To 100
Text = Str(i)
Call Lcd_m50530_gotoxy(_x , _y)
Call Lcd_m50530_print()
Waitms 200
If I = 100 Then Call Lcd_m50530_clear
Next
Loop
'-------------------------
' End Hauptprogramm
'-------------------------
'----------------------------------------
Sub Lcd_m50530_init
'----------------------------------------
Lcd_parameter = $d8 'set function mode (SF) 0b11011000
Call Lcd_m50530_command(lcd_parameter) '4bit-Modus einstellen 11 -4/8bit-FONT-2xDUTY-2xRAM
Lcd_parameter = $50 'set entry mode (SE) 0b01010000
Call Lcd_m50530_command(lcd_parameter) 'Cursor selbst setzen
Lcd_parameter = $33 'set display mode (SD) 0b00110011
Call Lcd_m50530_command(lcd_parameter) 'Display ein, Cursor nicht anzeigen
Lcd_parameter = $01 ' 0b00000001 Display löschen
Call Lcd_m50530_command(lcd_parameter)
Waitms 2
End Sub
'----------------------------------------
Sub Lcd_m50530_chr(ch As Byte)
'----------------------------------------
Lcd_temp = Ch
Shift Lcd_temp , Right , 4
Set Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Lcd_temp = Ch And $0f
Set Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Waitus 20
End Sub
'---------------------------------------
Sub Lcd_m50530_command(command As Byte)
'---------------------------------------
Lcd_temp = Command
Shift Lcd_temp , Right , 4
Reset Lcd_temp._oc1
Reset Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Lcd_temp = Command And $0f
Reset Lcd_temp._oc1
Reset Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Waitus 20
End Sub
'-----------------------------------------------------
Sub Lcd_m50530_gotoxy(lcd_x As Byte , Lcd_y As Byte)
'-----------------------------------------------------
Select Case Lcd_y
Case 1 : Lcd_parameter = $00
Case 2 : Lcd_parameter = $40
Case 3 : Lcd_parameter = $80
Case 4 : Lcd_parameter = $c0
Case Else : Lcd_parameter = $00
End Select
Lcd_parameter = Lcd_parameter + Lcd_x
Decr Lcd_parameter
Lcd_temp = Lcd_parameter
Shift Lcd_temp , Right , 4
Set Lcd_temp._oc1
Set Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Lcd_temp = Lcd_parameter And $0f
Set Lcd_temp._oc1
Set Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Waitus 20
End Sub
'----------------------------------------
Sub Lcd_m50530_clear
'----------------------------------------
Lcd_parameter = $01 ' 0b00000001 Display löschen
Call Lcd_m50530_command(lcd_parameter)
Waitms 2
End Sub
'----------------------------------------
Sub Lcd_m50530_enable
'----------------------------------------
Set Lcd_m50530._ex
Waitus 1
Reset Lcd_m50530._ex
End Sub
'----------------------------------------
Sub Lcd_m50530_print()
'----------------------------------------
For T = 1 To Len(text)
Xstring = Mid(text , T , 1)
Xchar = Asc(xstring)
Call Lcd_m50530_chr(xchar)
Next
End Sub
bin allerdings weder in c noch in asm eine leuchte auch meine Bascom kentnisse bewegen sich eher auf anfänger niveau
hier erstmal der code den ich verwende damit auch andere die das teil haben es mit einfachen mitteln einsetzen können
$regfile = "m32def.dat"
$crystal = 16000000
Declare Sub Lcd_m50530_init() 'declare the SUB program
Declare Sub Lcd_m50530_chr(ch As Byte)
Declare Sub Lcd_m50530_command(command As Byte)
Declare Sub Lcd_m50530_gotoxy(lcd_x As Byte , Lcd_y As Byte)
Declare Sub Lcd_m50530_clear()
Declare Sub Lcd_m50530_enable
Declare Sub Lcd_m50530_print()
Lcd_m50530 Alias Portc
Config Lcd_m50530 = Output
_oc1 Alias 4
_oc2 Alias 5
_ex Alias 6
Dim T As Byte ' Zählschleife
Dim Lcd_temp As Byte ' Temp im Unterprogramm
Dim Lcd_parameter As Byte ' wird an LCD gesendet
Dim _x As Byte ' Cursor x Position
Dim _y As Byte ' Cursor y Position
Dim Text As String * 16 ' String zur textübergabe
Dim Xstring As String * 16
Dim Xchar As Byte
Dim I As Byte
'-------------------------
' Begin Hauptprogramm
'-------------------------
_x = 5 : _y = 2
Call Lcd_m50530_init
Do
For I = 1 To 100
Text = Str(i)
Call Lcd_m50530_gotoxy(_x , _y)
Call Lcd_m50530_print()
Waitms 200
If I = 100 Then Call Lcd_m50530_clear
Next
Loop
'-------------------------
' End Hauptprogramm
'-------------------------
'----------------------------------------
Sub Lcd_m50530_init
'----------------------------------------
Lcd_parameter = $d8 'set function mode (SF) 0b11011000
Call Lcd_m50530_command(lcd_parameter) '4bit-Modus einstellen 11 -4/8bit-FONT-2xDUTY-2xRAM
Lcd_parameter = $50 'set entry mode (SE) 0b01010000
Call Lcd_m50530_command(lcd_parameter) 'Cursor selbst setzen
Lcd_parameter = $33 'set display mode (SD) 0b00110011
Call Lcd_m50530_command(lcd_parameter) 'Display ein, Cursor nicht anzeigen
Lcd_parameter = $01 ' 0b00000001 Display löschen
Call Lcd_m50530_command(lcd_parameter)
Waitms 2
End Sub
'----------------------------------------
Sub Lcd_m50530_chr(ch As Byte)
'----------------------------------------
Lcd_temp = Ch
Shift Lcd_temp , Right , 4
Set Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Lcd_temp = Ch And $0f
Set Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Waitus 20
End Sub
'---------------------------------------
Sub Lcd_m50530_command(command As Byte)
'---------------------------------------
Lcd_temp = Command
Shift Lcd_temp , Right , 4
Reset Lcd_temp._oc1
Reset Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Lcd_temp = Command And $0f
Reset Lcd_temp._oc1
Reset Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Waitus 20
End Sub
'-----------------------------------------------------
Sub Lcd_m50530_gotoxy(lcd_x As Byte , Lcd_y As Byte)
'-----------------------------------------------------
Select Case Lcd_y
Case 1 : Lcd_parameter = $00
Case 2 : Lcd_parameter = $40
Case 3 : Lcd_parameter = $80
Case 4 : Lcd_parameter = $c0
Case Else : Lcd_parameter = $00
End Select
Lcd_parameter = Lcd_parameter + Lcd_x
Decr Lcd_parameter
Lcd_temp = Lcd_parameter
Shift Lcd_temp , Right , 4
Set Lcd_temp._oc1
Set Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Lcd_temp = Lcd_parameter And $0f
Set Lcd_temp._oc1
Set Lcd_temp._oc2
Lcd_m50530 = Lcd_temp
Call Lcd_m50530_enable
Waitus 20
End Sub
'----------------------------------------
Sub Lcd_m50530_clear
'----------------------------------------
Lcd_parameter = $01 ' 0b00000001 Display löschen
Call Lcd_m50530_command(lcd_parameter)
Waitms 2
End Sub
'----------------------------------------
Sub Lcd_m50530_enable
'----------------------------------------
Set Lcd_m50530._ex
Waitus 1
Reset Lcd_m50530._ex
End Sub
'----------------------------------------
Sub Lcd_m50530_print()
'----------------------------------------
For T = 1 To Len(text)
Xstring = Mid(text , T , 1)
Xchar = Asc(xstring)
Call Lcd_m50530_chr(xchar)
Next
End Sub