Hier ein paar Ausschnitte aus einem Code von mir.
Code:
Menü:
Zeit = 0 'anzeige der Zeit verhindern.
Cls
Locate 1 , 9
Lcd "Menõ"
Lowerline
Lcd "--------------------"
Thirdline
Lcd "1. Datum & Zeit"
Fourthline
Lcd "2. Hintergrundbel."
Waitms 300 'alte FB-Taste ignorieren
Do
Gosub Getir
If Command = 0 Then Goto Pc_aus
If Command = 1 Then Goto Menü11
If Command = 2 Then Goto Menü2
Loop
Menü11:
Cls
Locate 1 , 9
Lcd "Menõ"
Lowerline
Lcd "--------------------"
Thirdline
Lcd "1. Zeit stellen "
Fourthline
Lcd "2. Timer stellen "
Do
Gosub Getir
If Command = 0 Then Goto Menü
If Command = 1 Then Gosub Zeit_stellen
If Command = 2 Then
A = 1
Goto Timer_stellen
End If
Loop
Zeit_stellen:
Cls
Lcd " Zeit stellen"
Lowerline
Lcd "Bitte Datum und"
Thirdline
Lcd "Uhrzeit eingeben"
Fourthline
Lcd " --.--.20-- --:--"
Cursor Blink
Do
Locate 4 , 3
Do
Gosub Getir 'Tag stellen
Loop Until Command < 10
Lcd Command
A = Command * 10
Waitms 200
Locate 4 , 4
Do
Gosub Getir
Loop Until Command < 10
Lcd Command
B = Command
Tag = A + B
Loop Until Tag < 32
Do
Waitms 200
Locate 4 , 6
Do
Gosub Getir 'Monat stellen
Loop Until Command < 10
Lcd Command
A = Command * 10
Waitms 200
Locate 4 , 7
Do
Gosub Getir
Loop Until Command < 10
Lcd Command
B = Command
Monat = A + B
Loop Until Monat < 13
Waitms 200
Locate 4 , 11
Do
Gosub Getir 'Jahr stellen
Loop Until Command < 10
Lcd Command
A = Command * 10
Waitms 200
Locate 4 , 12
Do
Gosub Getir
Loop Until Command < 10
Lcd Command
B = Command
Jahr = A + B
Writeeeprom Jahr , 8
Do
Waitms 200
Locate 4 , 15
Do
Gosub Getir 'Stunden stellen
Loop Until Command < 10
Lcd Command
A = Command * 10
Waitms 200
Locate 4 , 16
Do
Gosub Getir
Loop Until Command < 10
Lcd Command
B = Command
Stunden = A + B
Loop Until Stunden < 24
Do
Waitms 200
Locate 4 , 18
Do
Gosub Getir 'Minuten stellen
Loop Until Command < 10
Lcd Command
A = Command * 10
Waitms 200
Locate 4 , 19
Do
Gosub Getir
Loop Until Command < 10
Lcd Command
B = Command
Minuten = A + B
Loop Until Minuten < 60
Sekunden = 0 'nach letzter Eingabe Sekunden wieder auf 0 setzen
Cursor Off
Cursor Noblink
Jahr2 = Str(jahr)
Tag2 = Str(tag)
Monat2 = Str(monat)
Tag2 = Format(tag2 , "00")
Monat2 = Format(monat2 , "00")
Waitms 1000
Return
Getir: 'IR-Code empfangen und auswerten
Getrc5(adress , Command)
If Adress <> Fbcode Then Command = 127 'Command für falsche Adresse setzen damit nicht auf andere FB reagiert wird
If Command > 127 Then Command = Command - 128 'Togglebit einfernen
Return
Modus:
Cls
Lcd " Modus der HGB"
Lowerline
Lcd "--------------------"
Thirdline
Lcd "1. wenn PC an"
Fourthline
Lcd "2. wenn PC aus"
Waitms 200
Do
Gosub Getir
If Command = 0 Then Return
If Command = 1 Then Gosub Modus_an
If Command = 2 Then Gosub Modus_aus
Loop
Modus_an:
Cls
Lcd "1. Lightcontrol" '15 zeichen
Lowerline
Lcd "2. dauerhaft" '12 Zeichen
Thirdline
Lcd "3. dimmer" '9 zeichen
Fourthline
Lcd "4. Schwellwert" '14 Zeichen
Waitms 300
Do
Locate 1 , 17
If Lightcontrol = 1 Then
Lcd " Ja "
Else
Lcd "Nein"
End If
Locate 2 , 17
If Pwmandauer = 1 Then
Lcd "An "
Else
Lcd "Aus"
End If
Locate 3 , 19
If Pwmandimmer = 1 Then
Lcd "*"
Else
Lcd " "
End If
Locate 4 , 19
If Pwmanschwell = 1 Then
Lcd "*"
Else
Lcd " "
End If
Gosub Getir
Select Case Command
Case 0 : Return
Case 1 : Toggle Lightcontrol
Case 2 : Toggle Pwmandauer
Case 3 : Toggle Pwmandimmer
Case 4 : Toggle Pwmanschwell
End Select
Waitms 100
Loop
Modus_aus:
Cls
Lcd "1. dauerhaft"
Lowerline
Lcd "2. dimmer"
Thirdline
Lcd "3. Schwellwert"
Waitms 300
Do
Locate 1 , 17
If Pwmausdauer = 1 Then
Lcd "An "
Else
Lcd "Aus"
End If
Locate 2 , 19
If Pwmausdimmer = 1 Then
Lcd "*"
Else
Lcd " "
End If
Locate 3 , 19
If Pwmausschwell = 1 Then
Lcd "*"
Else
Lcd " "
End If
Gosub Getir
Select Case Command
Case 0 : Return
Case 1 : Toggle Pwmausdauer
Case 2 : Toggle Pwmausdimmer
Case 3 : Toggle Pwmausschwell
End Select
Waitms 100
Loop
Minhell:
Cls
Waitms 200
Lowerline
Lcd "Mit '1' speichern"
Thirdline
Lcd "mit '0' zurück"
Do
Upperline
A = Getadc(0)
B = A / 4
Lcd B
Gosub Getir
If Command = 0 Then Return
If Command = 1 Then
Minhell = B
Writeeeprom Minhell , 2
End If
Loop
Maxhell:
Cls
Waitms 200
Lowerline
Lcd "Mit '1' speichern"
Thirdline
Lcd "mit '0' zurück"
Do
Upperline
A = Getadc(0)
B = A / 4
Lcd B
Gosub Getir
If Command = 0 Then Return
If Command = 1 Then
Maxhell = B
Writeeeprom Maxhell , 4
End If
Loop
Hgb:
Cls
Lcd " HGB"
Lowerline
Lcd "--------------------"
Thirdline
Lcd "1. min. Wert"
Fourthline
Lcd "2. max. Wert"
Waitms 200
Do
Gosub Getir
If Command = 0 Then Return
If Command = 1 Then Gosub Hgbmin
If Command = 2 Then Gosub Hgbmax
Loop
Hgbmin:
Ocr2 = 0
A = 0
Cls
Lowerline
Lcd "7 = - 9 = +"
Thirdline
Lcd "1 = speichern"
Fourthline
Lcd "0 = zurück"
Waitms 200
Do
Gosub Getir
If Command = 0 Then Return
If Command = 1 Then
Pwmmin = A
Writeeeprom Pwmmin , 100
End If
If Command = 7 Then A = A - 5
If Command = 9 Then A = A + 5
If A < 0 Then A = 0
If A > 250 Then A = 250
Ocr2 = A
Upperline
Lcd A ; " "
Loop
Hgbmax:
Ocr2 = 250
A = 250
Cls
Lowerline
Lcd "7 = - 9 = +"
Thirdline
Lcd "1 = speichern"
Fourthline
Lcd "0 = zurück"
Waitms 200
Do
Gosub Getir
If Command = 0 Then Return
If Command = 1 Then
Pwmmax = A
Writeeeprom Pwmmax , 100
End If
If Command = 7 Then A = A - 5
If Command = 9 Then A = A + 5
If A < 0 Then A = 0
If A > 250 Then A = 250
Ocr2 = A
Upperline
Lcd A ; " "
Loop
Savecode:
Zeit = 0 'anzeigen der Zeit (Sekunden) verhindern.
Cls
Lcd "Bitte eine Taste auf"
Lowerline
Lcd "der Fernbedienung"
Thirdline
Lcd "dr" ; Chr(245) ; "cken..."
Do
Getrc5(adress , Command)
If Adress = 255 Then Loop 'wenn nix gedrückt, dann nochmal abfragen
Writeeeprom Adress , 1
Cls
Lcd "Code gespeichert..."
Fbcode = Adress
Waitms 1000
Cls
Return
Timeroffset: 'Vor- und Nachlauf der Uhr kompensieren
Zeit = 0
Cls
Lcd " ACHTUNG!!!"
Lowerline
Lcd "Bedienungsanleitung"
Thirdline
Lcd "beachten!"
Waitms 150
Do
Gosub Getir
Loop Until Command < 127 'erst wenn eine Taste gedrückt wurde weiter machen
If Command <> 5 Then Goto Pc_aus 'nur bei "5" weiter machen
Cls
Lcd "Wert eingeben:"
Lowerline
Lcd "Sollwert: 18661"
Thirdline
Lcd "Istwert: " ; Timervorgabe
Fourthline
Lcd "-----"
Cursor On
Cursor Blink
F = 1 : A = 10000 : C = 0
Waitms 250
Do
Locate 4 , F
Do
Gosub Getir
Loop Until Command < 10
Lcd Command
Waitms 250
B = A * Command
C = C + B
A = A / 10
Incr F
Loop Until F = 6
Cursor Off
Cursor Noblink
Waitms 1000
Timervorgabe = C
Writeeeprom Timervorgabe , 106
Goto ...
PS: (C) by Marco78!!!
Lesezeichen