' DCF77 - Testprogramm
' GLCD T6963C Controller
' 240 x 64 Pixel !
$regfile = "m16def.dat"
$crystal = 4433619
$hwstack = 128
$swstack = 128
$framesize = 128
'First we define that we use a graphic LCD
' Only 240*64 supported yet
Config Graphlcd = 240 * 128 , Dataport = Portc , Controlport = Portd , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6
'The dataport is the portname that is connected to the data lines of the LCD
'The controlport is the portname which pins are used to control the lcd
'CE, CD etc. are the pin number of the CONTROLPORT.
'For example CE =2 because it is connected to PORTD.2
'mode 8 gives 240 / 8 = 30 columns
'mode=6 gives 240 / 6 = 40 columns
' Bestimme die Ein und Ausgänge
Ddra = &B0000_0000 '1 ist Ausgang 0 ist Eingang
Porta = &B1111_1111 'auf Hi oder Low setzen
Ddrb = &B1_1101 '1 ist Ausgang 0 ist Eingang
Portb = &B0_0010 'auf Hi oder Low setzen
' Uhreinstellungen
Config Dcf77 = Pina.0 , Timer = 1 , Timer1sec = 1 , Debug = 1 , Update = 0 , Check = 1 , Inverted = 1 , Gosub = Sectic
Config Date = Dmy , Separator = .
Enable Interrupts
Time$ = "00:30:00"
Date$ = "01.01.07"
Dim Puls As Bit , Sync As Bit , Sec_z As Byte
'---------------------------------------------------
' 1-Wire Temperaturmessung mit DS1820
Config 1wire = Pina.2
Config Single = Scientific , Digits = 1
Dim Ist_temp As Single ' Ist-Temperatur
Dim Temp As Word '
Dim Temp1 As Integer '
Dim Scratch(9) As Byte '
Dim I1w As Byte '
' Displayangaben
Cls
Cursor Off
Wait 1
Gosub Grafik
Line(119 , 3) -(119 , 60) , 0 'Linie mitte löschen
' #############################################################################
' Arbeitsschleife
Do
Gosub Anzeige
Portb.0 = Puls
If Sec_z > 10 Then
Gosub Get_1wire
Sec_z = 0
End If
' ----------------------------------------
If _sec > 1 Then Reset Dcf_status.7
If _sec < 2 Then
If Dcf_status.7 = 1 Then
Sync = 1
Else
Sync = 0
End If
Else
End If
If Sync = 1 Then
Portb.0 = Puls
Locate 5 , 11 : Lcd "erfolgt"
If Puls = 1 Then
Line(119 , 3) -(119 , 60) , 255 'Linie mitte
Else
Line(119 , 3) -(119 , 60) , 0 'Linie mitte löschen
End If
Else
Portb.0 = 1
Locate 5 , 11 : Lcd " fehlt "
Line(119 , 3) -(119 , 60) , 0 'Linie mitte löschen
End If
Loop
End
' ------------------------------------------------------------------------------
Sectic:
Toggle Puls
Incr Sec_z
Return
' ------------------------------------------------------------------------------
Grafik:
'Koordinaten X1 + Y1 zu X2 + Y2
Line(0 , 0) -(239 , 0) , 255 'Linie außen oben
Line(3 , 3) -(236 , 3) , 255 'Linie innen oben
Line(3 , 60) -(236 , 60) , 255 'Linie innen unten
Line(0 , 63) -(239 , 63) , 255 'Linie außen unten
Line(0 , 0) -(0 , 63) , 255 'Linie außen links
Line(3 , 3) -(3 , 60) , 255 'Linie innen links
Line(239 , 1) -(239 , 62) , 255 'Linie außen rechts
Line(236 , 3) -(236 , 60) , 255 'Linie innen rechts
Line(118 , 3) -(118 , 60) , 255 'Linie mitte links
Line(120 , 3) -(120 , 60) , 255 'Linie mitte rechts
Locate 2 , 2 : Lcd "--Reale Uhrzeit--"
Locate 3 , 2 : Lcd "Uhrzeit:"
Locate 4 , 2 : Lcd "Datum :"
Locate 5 , 2 : Lcd "Sync. :"
Locate 7 , 2 : Lcd "In-Temp:"
Locate 2 , 22 : Lcd "---DCF-77 Zeit---"
Locate 3 , 22 : Lcd "DCF_sec:"
Locate 4 , 22 : Lcd "DCF_day:"
Locate 6 , 28 : Lcd "Cassio"
Locate 7 , 24 : Lcd "AVR-Praxis.de"
Return
' ------------------------------------------------------------------------------
Anzeige:
Locate 3 , 11 : Lcd Time$
Locate 4 , 11 : Lcd Date$
Locate 7 , 11 : Lcd Ist_temp ; "Cel."
Locate 3 , 31 : Lcd Time(dcf_sec)
Locate 4 , 31 : Lcd Date(dcf_day)
Return
' ------------------------------------------------------------------------------
Get_1wire:
1wreset
1wwrite &HCC
1wwrite &H44
Do
Temp = 1wread() ' Ende der Temperaturmessung abwarten
Loop Until Temp = &HFF
1wreset
1wwrite &HCC
1wwrite &HBE
For I1w = 1 To 9
Scratch(i1w) = 1wread()
Next
Temp = Scratch(2)
Shift Temp , Left , 8
Temp = Temp + Scratch(1)
Temp1 = Temp
Temp1 = Temp1 / 2
Ist_temp = Scratch(8) - Scratch(7)
Ist_temp = Ist_temp / Scratch(8)
Ist_temp = Ist_temp + Temp1
Ist_temp = Ist_temp - 0.25
Return