Code:
' Für die Displayansteuerung gilt:
' ------------------------------------------------------------------------------------------------------------
' Software-Grundlagen wurden von Peter Küsters, www.display3000.com ermittelt
' Weitere Displays, Platinen, Spezialstecker und fertige Module: www.display3000.com
' ------------------------------------------------------------------------------------------------------------
'
' ************************ WICHTIG !!!!! *******************************
' * Einstellungen in Bascom unter Options, Compiler, Chip *
' * HWSTACK-64 *
' * SWSTACK-128 *
' * FRAMESIZE-16 *
' ************************************************************************
'
$regfile = "m128def.dat" 'ATMega 8, anpassen bei anderen
$crystal = 8000000 '8 MHz Takt, bei höherem Takt muss evtl. die Ausgabegeschwindigkeit der Daten an das
'Display gedrosselt werden. Also erst mit 8 MHz testen um zu sehen, dass alles klappt,
$include "Config_MMC.BAS"
$include "CONFIG_AVR-DOS.BAS"
Dim Temp1 As Byte , Temp2 As Byte , Temp3 As Byte , Temp4 As Byte
Dim Drehung As Byte
Dim Fontbreite As Byte , Fonthoehe As Byte , Xpixel As Byte , Ypixel As Byte
Dim R As Integer , X1 As Byte , X2 As Byte , Y1 As Byte , Y2 As Byte , E As Byte , F As Integer , G As Long , Zeichen As String * 1
Dim A As Byte , B As Byte , C As Integer , D As Integer , T1 As Byte , T2 As Byte
Dim Befehl As Byte , Ausgabe As Byte
Dim Pix As Byte , Gapx As Double , Gapy As Double , S As Byte
Dim X As Byte , Y As Byte , H As Integer , M As Integer , Pixel As Integer , Schleife As Integer , Hx As Integer , Hy As Integer , Xinc As Integer , Yinc As Integer
Dim Temp As Byte
Dim Lcd_command As Byte , Lcd_data As Byte , Lcd_string As String * 22 , Fontsize As Byte , Lcd_fcolor As Byte , Lcd_bcolor As Byte
Dim Lx1 As Byte , Ly1 As Byte , Lx2 As Byte , Ly2 As Byte , Color As Byte , Zeichenarray(6) As Byte
'---------------------------------------------------------------------------------------------------------------------------------------------------
'Übernahme der aktuellen Portbelegung in Variablen bzw. Konstanten. Durch Änderung der folgenden Zeilen kann dass Programm auf jede andere Anschlussbelegung geändert werden,
'wenn man das Display in einer anderen Konfiguration (z.B. einem eigenen Board) nutzt.
Lcd_port Alias Portb 'Port B wird also hier im Programm mittels "LCD_Port" angesprochen.
Ddrb = &B01100110 'Port B: alles display lines: output (1)
Const Rs = 6 'also Port b.6
Const Cs = 5 'also Port b.5
Const Sdata = 2 'also Port b.2
Const Sclk = 1 'also Port b.1
'---------------------------------------------------------------------------------------------------------------------------------------------------
Const Kommando = 0 'Durch eine "0" wird dem Display mitgeteilt, dass nun ein Kommando folgt
Const Parameter = 1 'Durch eine "1" wird dem Display mitgeteilt, dass nun ein Parameter folgt
Const Blau = &B00000011 'Vordefinierte Konstanten für die Farbwerte machen das Programmiererleben leichter:
Const Gelb = &B11111100
Const Rot = &B11100000
Const Gruen = &B00011100
Const Schwarz = &B00000000
Const Weiss = &B11111111
Const Hellgruen = &B00111110
Const Dunkelgruen = &B00010100
Const Dunkelrot = &B10100000
Const Dunkelblau = &B00000010
Const Hellblau = &B00011111
Const Orange = &B11111000
'----------------------------------------------------------------------------------------------------------------------------------------------------
'####----AD-Wandler----#####'
Config Adc = Single , Prescaler = Auto , Reference = Internal
Start Adc
Config Portf.0 = Input 'Portf.0-3 =Input
Config Portf.1 = Input
Config Portf.2 = Input
'####----MMC-Karte----#####'
Config Serialin = Buffered , Size = 20
Config Clock = Soft
Enable Interrupts
Config Date = Dmy , Separator = .
Dim Btemp1 As Byte
Dim Text As String * 10 , Placeholder As String * 5
Placeholder = ";"
'####----Variablen----#####'
'Dim Sensor1(3)as String * 16
Dim Voutxw As Word
Dim Voutx As Single
Dim Voutxstr As String * 16
Dim Voutyw As Word
Dim Vouty As Single
Dim Voutystr As String * 16
Dim Voutzw As Word
Dim Voutz As Single
Dim Voutzstr As String * 16
'####----Switches----#####'
Dim Marker As Bit
Config Pind.4 = Input 'Marker
Portd.4 = 1
Config Pind.5 = Input 'RUN
Portd.5 = 1
Config Pind.6 = Input 'Halt
Portd.6 = 1
Dim Referenzspannung As Word
Referenzspannung = 3.85
'---------------------------------------------------------------------------------------------------------------------------------------------------
'Hauptprogramm
'---------------------------------------------------------------------------------------------------------------------------------------------------
Gosub Lcd_init
Gosub Lcd_cls
'---------------------------SD Anfang---------------------------------------------
If Gbdriveerror <> 0 Then
Lcd_string = "Drive error" : Lx1 = 5 : Ly1 = 50 : Fontsize = 1 : Lcd_fcolor = Rot : Lcd_bcolor = Weiss
Gosub Lcd_print
End If
' scratch byte
Btemp1 = Initfilesystem(1)
If Btemp1 > 0 Then
Lcd_string = "File System Error" : Lx1 = 4 : Ly1 = 51 : Fontsize = 1 : Lcd_fcolor = Rot : Lcd_bcolor = Weiss
Gosub Lcd_print
Lcd_string = Str(btemp1) : Lx1 = 5 : Ly1 = 52 : Fontsize = 1 : Lcd_fcolor = Rot : Lcd_bcolor = Weiss
Gosub Lcd_print
Else
'Else des Hauptprogramms
Lcd_string = "Card setup OK " : Lx1 = 5 : Ly1 = 51 : Fontsize = 1 : Lcd_fcolor = Gruen : Lcd_bcolor = Weiss
Gosub Lcd_print
Wait 5
Gosub Lcd_cls
Anfang:
Lcd_string = "Run" : Lx1 = 2 : Ly1 = 56 : Fontsize = 1 : Lcd_fcolor = Schwarz : Lcd_bcolor = Weiss
Gosub Lcd_print
Lcd_string = "Stop" : Lx1 = 18 : Ly1 = 56 : Fontsize = 1 : Lcd_fcolor = Schwarz : Lcd_bcolor = Weiss
Gosub Lcd_print
If Pind.5 = 0 Then
Lcd_string = "Voutx " : Lx1 = 2 : Ly1 = 50 : Fontsize = 1 : Lcd_fcolor = Dunkelgruen : Lcd_bcolor = Weiss
Gosub Lcd_print
Lcd_string = "Vouty " : Lx1 = 2 : Ly1 = 51 : Fontsize = 1 : Lcd_fcolor = Dunkelgruen : Lcd_bcolor = Weiss
Gosub Lcd_print
Lcd_string = "Voutz " : Lx1 = 2 : Ly1 = 52 : Fontsize = 1 : Lcd_fcolor = Dunkelgruen : Lcd_bcolor = Weiss
Gosub Lcd_print
Open "DATA.txt" For Append As #10
While Pind.6 <> 0
Marker = 0
Voutxw = Getadc(0)
'Waitms 10
Voutyw = Getadc(1)
'Waitms 10
Voutzw = Getadc(2)
'Waitms 10
Voutx = Voutxw / 1024
Vouty = Voutyw / 1024
Voutz = Voutzw / 1024
Voutx = Voutx * Referenzspannung
Vouty = Vouty * Referenzspannung
Voutz = Voutz * Referenzspannung
Voutxstr = Fusing(voutx , "#.####")
Voutystr = Fusing(vouty , "#.####")
Voutzstr = Fusing(voutz , "#.####")
Lcd_string = Voutxstr : Lx1 = 8 : Ly1 = 50 : Fontsize = 1 : Lcd_fcolor = Rot : Lcd_bcolor = Weiss
Gosub Lcd_print
Lcd_string = Voutystr : Lx1 = 8 : Ly1 = 51 : Fontsize = 1 : Lcd_fcolor = Blau : Lcd_bcolor = Weiss
Gosub Lcd_print
Lcd_string = Voutzstr : Lx1 = 8 : Ly1 = 52 : Fontsize = 1 : Lcd_fcolor = Dunkelgruen : Lcd_bcolor = Weiss
Gosub Lcd_print
'Sensor1(1) = Voutxstr
'Sensor1(2) = Voutystr
'Sensor1(3) = Voutzstr
'####----Marker----#####'
If Pind.4 = 0 Then
Marker = 1
End If
Print #10 , Voutxstr 'Sensor1(1), Sensor1(2), Sensor1(3)
Wend
Close #10
Gosub Lcd_cls
Goto Anfang
Else
Goto Anfang
End If
End If '
End
'---------------------------------------------------------------------------------------------------------------------------------------------------
' Steuer- und Ausgaberoutinen für das Display
'---------------------------------------------------------------------------------------------------------------------------------------------------
Lesezeichen