Witam, mam problem z stworzonym przez siebie zegarem w programie bascom ( dzialam na symulatorze )
Wiec program nie chce pokazywać mi minut ani sekund tylko pokazuje stale 255
A godziny zatrzymują się na 4 godzinie.
Chciałem tez dodać switch który po kliknięciu zapisuje i przechodzi np z godzin do minut i z minut do sekund ale każdy jak go dodaje nie działa . Macie może jakieś pomysły gdzie popełniłem błąd? Bardzo prosiłbym o pomoc
Kod :
$sim
$regfile = "m32def.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
Dim Liczh As Byte
Dim Liczm As Byte
Dim Liczs As Byte
Dim Liczba As Byte
Cursor Off
Config Porta = Output
Porta = 255
Funkcja_przel Alias Pina.5
Liczba = 0
Deflcdchar 0,32,32,15,17,17,15,1,14' g
Cls
Locate 1, 6
Lcd "Witam"
Cls
Gosub Disp
Do
Debounce funkcja_przel , 0 , Funkcja , Sub
Liczba = Encoder(pina.7 , Pina.6 , Lewo , Prawo , 0)
Waitus 150
Loop
End
Lewo:
If Liczba = 0 Then
If Liczh > 0 Then Liczh = Liczh - 1
If Liczh < 0 Then Liczh = 24
Gosub Disp
End If
If Liczba = 1 Then
If Liczm > 0 Then Liczm = Liczm - 1
If Liczm < 0 Then Liczm = 59
Gosub Disp
End If
If Liczba = 2 Then
If Liczs > 0 Then Liczs = Liczs - 1
If Liczs < 0 Then Liczs = 59
Gosub Disp
End If
Return
Prawo:
If Liczba = 0 Then
If Liczh < 25 Then Liczh = Liczh + 1
If Liczh = 25 Then Liczh = 0
Gosub Disp
End If
If Liczba = 1 Then
If Liczm < 60 Then Liczm = Liczm - 1
If Liczm = 60 Then Liczm = 0
Gosub Disp
End If
If Liczba = 2 Then
If Liczs < 60 Then Liczs = Liczs - 1
If Liczs = 60 Then Liczs = 0
Gosub Disp
End If
Return
Disp:
Cls
Locate 1, 6
Lcd "Ze"; Chr(0) ;"ar"
Locate 2, 5
Lcd Liczh ; ":" ; Liczm ; ":" ; Liczs
Return
Funkcja:
If Liczba = 0 Then
Locate 2, 5
Cursor Blink
End If
If Liczba = 1 Then
Locate 2, 8
Cursor Blink
End If
If Liczba = 2 Then
Locate 2, 10
Cursor Blink
End If
If Liczba = 3 Then Gosub Zegar
If Liczba = 4 Then Liczba = 0
Return
Zegar:
If Liczh < 25 Then
If Liczm < 60 Then
If Liczs < 60 Then
Liczs = Liczs + 1
Gosub Disp
Wait 1
Else
Liczm = Liczm + 1
Liczs = 0
End If
Else
Liczm = 0
Liczh = Liczh + 1
End If
Else
Liczh = 0
End If
Return
Wiec program nie chce pokazywać mi minut ani sekund tylko pokazuje stale 255
A godziny zatrzymują się na 4 godzinie.
Chciałem tez dodać switch który po kliknięciu zapisuje i przechodzi np z godzin do minut i z minut do sekund ale każdy jak go dodaje nie działa . Macie może jakieś pomysły gdzie popełniłem błąd? Bardzo prosiłbym o pomoc
Kod :
$sim
$regfile = "m32def.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
Dim Liczh As Byte
Dim Liczm As Byte
Dim Liczs As Byte
Dim Liczba As Byte
Cursor Off
Config Porta = Output
Porta = 255
Funkcja_przel Alias Pina.5
Liczba = 0
Deflcdchar 0,32,32,15,17,17,15,1,14' g
Cls
Locate 1, 6
Lcd "Witam"
Cls
Gosub Disp
Do
Debounce funkcja_przel , 0 , Funkcja , Sub
Liczba = Encoder(pina.7 , Pina.6 , Lewo , Prawo , 0)
Waitus 150
Loop
End
Lewo:
If Liczba = 0 Then
If Liczh > 0 Then Liczh = Liczh - 1
If Liczh < 0 Then Liczh = 24
Gosub Disp
End If
If Liczba = 1 Then
If Liczm > 0 Then Liczm = Liczm - 1
If Liczm < 0 Then Liczm = 59
Gosub Disp
End If
If Liczba = 2 Then
If Liczs > 0 Then Liczs = Liczs - 1
If Liczs < 0 Then Liczs = 59
Gosub Disp
End If
Return
Prawo:
If Liczba = 0 Then
If Liczh < 25 Then Liczh = Liczh + 1
If Liczh = 25 Then Liczh = 0
Gosub Disp
End If
If Liczba = 1 Then
If Liczm < 60 Then Liczm = Liczm - 1
If Liczm = 60 Then Liczm = 0
Gosub Disp
End If
If Liczba = 2 Then
If Liczs < 60 Then Liczs = Liczs - 1
If Liczs = 60 Then Liczs = 0
Gosub Disp
End If
Return
Disp:
Cls
Locate 1, 6
Lcd "Ze"; Chr(0) ;"ar"
Locate 2, 5
Lcd Liczh ; ":" ; Liczm ; ":" ; Liczs
Return
Funkcja:
If Liczba = 0 Then
Locate 2, 5
Cursor Blink
End If
If Liczba = 1 Then
Locate 2, 8
Cursor Blink
End If
If Liczba = 2 Then
Locate 2, 10
Cursor Blink
End If
If Liczba = 3 Then Gosub Zegar
If Liczba = 4 Then Liczba = 0
Return
Zegar:
If Liczh < 25 Then
If Liczm < 60 Then
If Liczs < 60 Then
Liczs = Liczs + 1
Gosub Disp
Wait 1
Else
Liczm = Liczm + 1
Liczs = 0
End If
Else
Liczm = 0
Liczh = Liczh + 1
End If
Else
Liczh = 0
End If
Return