A wiec wczoraj z nudow zrobilem cos kompletnie nieprzydatnego ;]
No moze nie tak bardzo no ale. Jest to multiefekt swietlny.
Steruje 2 liniami portu na ktorych sa 2 tranzystory (BC516).
Program nie jest zbyt piekny ale dopiero ucze sie bascoma:
I teraz mam pytanie czy da sie go jakos sensownie zoptymalizowac?
Niezbyt mi sie podoba zadek if w kazdej petli.
Myslalem nad zrobieniem RS (po rs odbiera co ma robic) ale chyba nie zmiesci mi sie to we flash
Czy ktos dobry moze mi pokazac jak zaimpletowac tutaj rs w taki sposob aby zmiescilo sie w pamieci?
Mam jeszce 1 problem z ty kodem, funkcja Strobe10ms dzila jakby zle.
Tzn diody migaja bardzo szybko (tak dokladnie jak chce) ale blyski sa ciemne tzn. tak jakby trwaly za krotko.
Mam racje ?
Diody wtedy migaja z polowe mniejsza jasnoscia niz normlanie.
Z gory dziekuje
No moze nie tak bardzo no ale. Jest to multiefekt swietlny.
Steruje 2 liniami portu na ktorych sa 2 tranzystory (BC516).
Program nie jest zbyt piekny ale dopiero ucze sie bascoma:
$crystal = 4000000
Config Portd = &B1111111
Portd = &B1111111
Config Portb = &B00000000
Portb = &B11111111
Goto Main
Police:
Do
Toggle Portd.3
Waitms 23
Toggle Portd.3
Waitms 80
Toggle Portd.3
Waitms 23
Toggle Portd.3
Waitms 500
Toggle Portd.4
Waitms 23
Toggle Portd.4
Waitms 80
Toggle Portd.4
Waitms 23
Toggle Portd.4
Waitms 500
If Pinb.0 = 0 Then Goto Main
If Pinb.1 = 0 Then Goto Police
If Pinb.2 = 0 Then Goto Police2
If Pinb.3 = 0 Then Goto Police3
If Pinb.4 = 0 Then Goto Strobe50ms
If Pinb.5 = 0 Then Goto Strobe40ms
If Pinb.6 = 0 Then Goto Strobe10ms
If Pinb.7 = 0 Then Goto Strobeimp
Loop
Police2:
Do
Toggle Portd.3
Waitms 15
Toggle Portd.3
Waitms 180
Toggle Portd.4
Waitms 15
Toggle Portd.4
Waitms 180
If Pinb.0 = 0 Then Goto Main
If Pinb.1 = 0 Then Goto Police
If Pinb.2 = 0 Then Goto Police2
If Pinb.3 = 0 Then Goto Police3
If Pinb.4 = 0 Then Goto Strobe50ms
If Pinb.5 = 0 Then Goto Strobe40ms
If Pinb.6 = 0 Then Goto Strobe10ms
If Pinb.7 = 0 Then Goto Strobeimp
Loop
Police3:
Do
Toggle Portd.3
Toggle Portd.4
Waitms 15
Toggle Portd.3
Toggle Portd.4
Waitms 600
Toggle Portd.3
Toggle Portd.4
Waitms 23
Toggle Portd.3
Toggle Portd.4
Waitms 80
Toggle Portd.3
Toggle Portd.4
Waitms 23
Toggle Portd.3
Toggle Portd.4
Waitms 600
If Pinb.0 = 0 Then Goto Main
If Pinb.1 = 0 Then Goto Police
If Pinb.2 = 0 Then Goto Police2
If Pinb.3 = 0 Then Goto Police3
If Pinb.4 = 0 Then Goto Strobe50ms
If Pinb.5 = 0 Then Goto Strobe40ms
If Pinb.6 = 0 Then Goto Strobe10ms
If Pinb.7 = 0 Then Goto Strobeimp
Loop
Strobe50ms:
Portd.3 = 1
Portd.4 = 1
Do
Toggle Portd.3
Toggle Portd.4
Waitms 50
Toggle Portd.3
Toggle Portd.4
Waitms 50
If Pinb.0 = 0 Then Goto Main
If Pinb.1 = 0 Then Goto Police
If Pinb.2 = 0 Then Goto Police2
If Pinb.3 = 0 Then Goto Police3
If Pinb.4 = 0 Then Goto Strobe50ms
If Pinb.5 = 0 Then Goto Strobe40ms
If Pinb.6 = 0 Then Goto Strobe10ms
If Pinb.7 = 0 Then Goto Strobeimp
Loop
Strobe40ms:
Portd.3 = 1
Portd.4 = 1
Do
Toggle Portd.3
Toggle Portd.4
Waitms 40
Toggle Portd.3
Toggle Portd.4
Waitms 40
If Pinb.0 = 0 Then Goto Main
If Pinb.1 = 0 Then Goto Police
If Pinb.2 = 0 Then Goto Police2
If Pinb.3 = 0 Then Goto Police3
If Pinb.4 = 0 Then Goto Strobe50ms
If Pinb.5 = 0 Then Goto Strobe40ms
If Pinb.6 = 0 Then Goto Strobe10ms
If Pinb.7 = 0 Then Goto Strobeimp
Loop
Strobe10ms:
Portd.3 = 1
Portd.4 = 1
Do
Toggle Portd.3
Toggle Portd.4
Waitms 10
Toggle Portd.3
Toggle Portd.4
Waitms 50
If Pinb.0 = 0 Then Goto Main
If Pinb.1 = 0 Then Goto Police
If Pinb.2 = 0 Then Goto Police2
If Pinb.3 = 0 Then Goto Police3
If Pinb.4 = 0 Then Goto Strobe50ms
If Pinb.5 = 0 Then Goto Strobe40ms
If Pinb.6 = 0 Then Goto Strobe10ms
If Pinb.7 = 0 Then Goto Strobeimp
Loop
Strobeimp:
Portd.3 = 1
Portd.4 = 1
Toggle Portd.3
Toggle Portd.4
Waitms 10
Toggle Portd.3
Toggle Portd.4
If Pinb.1 = 0 Then Goto Police
If Pinb.2 = 0 Then Goto Police2
If Pinb.3 = 0 Then Goto Police3
If Pinb.4 = 0 Then Goto Strobe50ms
If Pinb.5 = 0 Then Goto Strobe40ms
If Pinb.6 = 0 Then Goto Strobe10ms
If Pinb.7 = 0 Then Goto Strobeimp
Goto Main
Main:
Do
If Pinb.1 = 0 Then Goto Police
If Pinb.2 = 0 Then Goto Police2
If Pinb.3 = 0 Then Goto Police3
If Pinb.4 = 0 Then Goto Strobe50ms
If Pinb.5 = 0 Then Goto Strobe40ms
If Pinb.6 = 0 Then Goto Strobe10ms
If Pinb.7 = 0 Then Goto Strobeimp
Loop
End
I teraz mam pytanie czy da sie go jakos sensownie zoptymalizowac?
Niezbyt mi sie podoba zadek if w kazdej petli.
Myslalem nad zrobieniem RS (po rs odbiera co ma robic) ale chyba nie zmiesci mi sie to we flash
Czy ktos dobry moze mi pokazac jak zaimpletowac tutaj rs w taki sposob aby zmiescilo sie w pamieci?
Mam jeszce 1 problem z ty kodem, funkcja Strobe10ms dzila jakby zle.
Tzn diody migaja bardzo szybko (tak dokladnie jak chce) ale blyski sa ciemne tzn. tak jakby trwaly za krotko.
Mam racje ?
Diody wtedy migaja z polowe mniejsza jasnoscia niz normlanie.
Z gory dziekuje
