Code:
$regfile = "m16DEF.DAT"
$crystal = 16000000
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 8 'default use 10 for the SW stack
$framesize = 40
Config Porta = Input
Config Portb = Output
Config Portc = Input
Config Portd = Output
Dim Taster As Byte
Dim Offset As Word 'kann auch byte sein, wenn du nicht mehr als 50 Zeichen brauchst
Dim Zeichen As Word
Dim Spalte As Byte
Dim Werte As Byte
Dim Display_off As Byte , Max_display_off As Byte ,
Dim Blink_an As Word , Blink_count As Word , Max_blink_an As Word 'damit auch höhere Zahlen als 255 gehen
Config Dcf77 = Pind.7 , Check = 2 , Timer = 1 , Timer1sec = 1 , Debug = 1 , Sectic = 1
Config Timer0 = Timer , Prescale = 1024 'timer läuft alle 16.000.000/256/256=250.stel Sekunde über, also etwa alle 4ms
On Timer0 Timer0_isr
Enable Timer0
Enable Interrupts
Spalte = 0
Portc = &B00000000
'---------------------------------
'LCD einstellung
'---------------------------------
Config Lcdpin = Pinc , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
Config Lcd = 20 * 4
Initlcd
Cursor Off
Do
Taster = Pina
Select Case Taster
Case 1 : Offset = 1
Case 2 : Offset = 2
Case 4 : Offset = 3
Case 8 : Offset = 4
Case 16 : Offset = 5
Case 32 : Offset = 6
Case 64 : Offset = 7
Case 128 : Offset = 8
End Select
If Taster=0 And Offset > 0 Then
Offset=0
Locate 1 , 1
Lcd "Kein Taster"
End If
'If Offset = 0 Then
'Locate 1 , 1
'Lcd "Kein Taster"
'End If
If Offset = 1 Then
Locate 1 , 1
Lcd "Taster 1 "
End If
If Offset = 2 Then
Locate 1 , 1
Lcd "Taster 2 "
End If
If Offset = 3 Then
Locate 1 , 1
Lcd "Taster 3 "
End If
'If Pinc.7 = 1 Then Max_display_off = 4
'If Pinc.7 = 0 Then Max_display_off = 0
'If Pinc.6 = 1 Then
'Max_blink_an = 800
'Blink_an = 400 'hier das Verhältnis (400/800), heisst nach der Hälfte der Zeit geht es an, kleiner Wert heisst länger an
'Else
'Max_blink_an = 0
'Blink_an = 0
'End If
Loop
Timer0_isr:
Offset = Offset * 5 'immer 5 Werte pro Zeichen
If Spalte = 5 Then
Spalte = 0
End If
Offset = Offset + Spalte
Werte = Lookup(offset , Zeichen_data)
Incr Display_off
Incr Blink_count
If Blink_count > Max_blink_an Then Blink_count = 0
Portd = 0 'zum Verhindern von Geisterbildern
If Display_off > Max_display_off Then 'damit bleibt das Zeichen immer für eine bestimmte Zeit aus
Display_off = 0
If Blink_count >= Blink_an Then
Portb = Werte 'lädt die Werte
Portd.spalte = 1 'Gibt die Spalte frei
Incr Spalte
End If
End If
Return
Zeichen_data:
Data &B11000001 , &B10101110 , &B10110110 , &B10111010 , &B11000001 '0
Data &B11111111 , &B10111101 , &B10000000 , &B10111111 , &B11111111 '1
Data &B10111101 , &B10011110 , &B10101110 , &B10110110 , &B10111001 '2
Data &B11011110 , &B10111110 , &B10110110 , &B10110010 , &B11001100 '3
Data &B11100111 , &B11101011 , &B11101101 , &B10000000 , &B11101111 '4
Data &B11010000 , &B10110110 , &B10110110 , &B10110110 , &B11000110 '5
Data &B10000000 , &B11110110 , &B11100110 , &B11010110 , &B10111001 'R
Data &B11111011 , &B11111101 , &B10000000 , &B11111101 , &B11111011 'Pfeil 0ben
Data &B11101111 , &B11011111 , &B10000000 , &B11011111 , &B11101111 'Pfeil unten
Data &B11111111 , &B10000000 , &B10000000 , &B10000000 , &B10000000 'A
Data &B10000000 , &B11111111 , &B10000000 , &B10000000 , &B10000000 'B
Data &B10000000 , &B10000000 , &B11111111 , &B10000000 , &B10000000 'C
Data &B10000000 , &B10000000 , &B10000000 , &B11111111 , &B10000000 'D
Data &B10000000 , &B10000000 , &B10000000 , &B10000000 , &B10000000 'E
Ja ich brauch ein niedrigen Prescaler um das flackern auf der 5x7 Matrix zu verhindern.
Lesezeichen