Strona 1 z 1

Pilot IR NEC

: 12 sty 2018, 11:19
autor: marekszy
Witam, tak bawię się pilotem z aliexpress na kodzie zaczerpniętym ze strony kaktusa i o ile odczytywanie działa prawidłowo to mam problem ze sterowaniem portami.
W tym układzie jak nacisnę przycisk pilota to "set led_0" powoduje załączenie diody na stałe ,a "toggle" działa bardzo losowo.
Możesz zerknąć aby to zadziałało na zasadzie naciskam przycisk to led świeci, puszczam to gaśnie oraz jedno naciśnięcie zaświeci a kolejne wygasi.
  1. [/'Tester pilotów NEC - dziala
  2. 'LCD: RS-PB.3 , ENA-PB.2 , D4-PB.6 , D5-PB.5 , D6-PB.7 , D7-PB.4
  3. 'WYJŚCIA: LED_G-PD.6 , LED_R-PD.4 , LED_B-PD.3 , LED_Y-PD.5 , LED_G-PD.1 , LED_R-PD.0
  4. 'ODBIORNIK IR-PD.2 (INT0)
  5. 'ODBIORNIK IR NEC-PD.3 (INT1)
  6. 'CKDIW 8 - wylaczone
  7. 'PORTA.0/PORTA.1 - kwarc  ,PORTA.2 - reset
  8. 'Adres:0 , 1 – com: 162 , 2 – com: 98 , 3 – com: 226 , 4 – com: 34 , 5 – com: 2 , 6 – com: 194
  9. '7 – com: 224 , 8 – com: 168 , 9 – com: 144 , 0 – com: 152 , * - com: 104 , # - com: 176
  10. 'Góra  - com: 24 , Dół – com: 74 , Lewo – com: 16 , Prawo – com: 90 , OK – com: 56
  11.  
  12. '1 - com:34 ,
  13.  
  14. $regfile = "attiny2313.dat"
  15. $crystal = 8000000
  16. $hwstack = 36
  17. $swstack = 36
  18. $framesize = 40
  19.  
  20. Config Porta = &B11111100 : Porta = &B11111111
  21. Config Portb = &B11111100 : Portb = &B11111111
  22. Config Portd = &B11110011 : Portd = &B00001100
  23.  
  24. Config Lcdpin = Pin , Db4 = PortB.6 , Db5 = Portb.5 , Db6 = Portb.7 , Db7 = Portb.4 , E = Portb.2 , Rs = Portb.3
  25. Config Lcd = 16 * 2
  26. Cursor Off
  27. Cls
  28.  
  29. Config Timer0 = Timer , Prescale = 256                      '8000000/256=31250 Hz
  30. Config Int1 = Falling                                       'Interruption on Falling
  31. Stop Timer0
  32. Enable Timer0
  33. Enable Int1
  34. Enable Interrupts
  35. On Timer0 Tikers                                            'work on timer
  36. On Int1 Infrared
  37.  
  38. Locate 1 , 1
  39. Lcd "NEC DEC."
  40. Locate 2 , 1
  41. Lcd "Marekszy"
  42. 'Wait 1
  43.  
  44. led_0 alias portd.0
  45. led_1 alias portd.1
  46. led_4 alias portd.4
  47. led_5 alias portd.5
  48. led_6 alias portd.6
  49.  
  50.                                             'work on interruption
  51. Dim Got As Bit
  52. Dim Tik As Word                                             'counter of teaks of timer
  53. Dim Byt As Byte                                             'counter accepted bit
  54. Dim Repeat_flag As Bit                                      'flag of repetition
  55. Dim Start_flag As Bit                                       'flag of start condition
  56. Dim Address_1 As Byte                                       'direct byte of address
  57. Dim Command_1 As Byte                                       'direct byte of command
  58. Dim Address_0 As Byte                                       'indirect byte of address
  59. Dim Command_0 As Byte                                       'indirect byte of command
  60. Dim Summa As Word
  61. Dim Address_nec As Byte , Command_nec As Byte
  62. Cursor Off                                                  'Switch Off cursor
  63. '################################################################################################################
  64.  
  65. Do                                                          'Main cycle
  66. If Got = 1 Then
  67.    Cls
  68.    Locate 1 , 1
  69.    Lcd "Adr:" ; Address_nec
  70.    Locate 2 , 1
  71.    Lcd "Com:" ; Command_nec                                     'Lcd ADDRESS and COMMAND
  72.    Reset Got
  73. End If
  74. 'Waitms 10                                                       'Delay 10 en
  75.  
  76. If Address_nec <> 255 Then                                      'jeśli Wpisać "If Address=0 Then"
  77.                                                                 'to zawęzimy tylko do telewizorów
  78.  
  79.  Select Case Command_nec
  80.  
  81.    Case 162:                                                    'przycisk pilota - 1
  82.       set Led_0
  83.    Case 98:                                                     'przycisk pilota - 2
  84.       toggle Led_1
  85.    case 226:                                                    'przycisk pilota - 3
  86.       set led_5
  87.    case 34:                                                     'przycisk pilota - 4
  88.       set led_4
  89.    case 2:                                                      'przycisk pilota - 5
  90.       set led_6
  91.    case 176:                                                    'przycisk pilota - #
  92.       reset led_0
  93.       reset led_1
  94.       reset led_4
  95.       reset led_5
  96.       reset led_6
  97.   End Select
  98.  
  99. End If
  100.  
  101.  
  102. Loop
  103. End                                                     'End of main cycle
  104.  
  105. '################################################################################################################
  106.  
  107.  Tikers:                                                    'work on timer
  108.    Timer0 = 253                                               '31250/(256-253)=10416,66 Hz (96 een)
  109.    Incr Tik
  110.    If Tik >= 1200 Then                                        'if 1200 teaks, have thrown all in source condition
  111.      Tik = 0
  112.      Repeat_flag = 0
  113.      Start_flag = 0
  114.      Address_1 = 255
  115.      Command_1 = 255
  116.      Address_0 = 0
  117.      Command_0 = 0
  118.      Address_nec = 255
  119.      Command_nec = 255
  120.      Stop Timer0
  121.    End If
  122.  Return
  123. '################################################################################################################
  124.  
  125.  Infrared:                                                  'work on interruption
  126.  Start Timer0
  127.  
  128.  If Tik >= 139 And Tik < 150 Then                           'if has happenned from 139 before 150 teaks - "START"
  129.   Address_nec = 1
  130.   Repeat_flag = 0
  131.   Start_flag = 1
  132.   Address_1 = 255
  133.   Command_1 = 255
  134.   Address_0 = 0
  135.   Command_0 = 0
  136.  End If
  137.  
  138.  If Tik >= 116 And Tik < 139 Then                           'if has happenned from 116 before 138 teaks - "REPETITION"
  139.   Address_nec = 0
  140.   Repeat_flag = 1
  141.   Start_flag = 0
  142.  End If
  143.  
  144.  If Tik >= 22 And Tik < 116 And Start_flag = 1 Then         'if has happenned from 22 before 115 teaks - have taken "1"
  145.    Incr Byt
  146.  
  147.    If Byt < 9 Then
  148.       Shift Address_1 , Left
  149.       Address_1 = Address_1 + 1
  150.    End If
  151.  
  152.    If Byt >= 9 And Byt < 17 Then
  153.       Shift Address_0 , Left
  154.       Address_0 = Address_0 + 1
  155.    End If
  156.  
  157.    If Byt >= 17 And Byt < 25 Then
  158.       Shift Command_1 , Left
  159.       Command_1 = Command_1 + 1
  160.    End If
  161.  
  162.    If Byt >= 25 Then
  163.       Shift Command_0 , Left
  164.       Command_0 = Command_0 + 1
  165.    End If
  166.  End If
  167.  
  168.  If Tik >= 10 And Tik < 22 And Start_flag = 1 Then          'if has happenned from 10 before 21 teaks - have taken "0"
  169.     Incr Byt
  170.     If Byt < 9 Then
  171.       Shift Address_1 , Left
  172.     End If
  173.  
  174.     If Byt >= 9 And Byt < 17 Then
  175.        Shift Address_0 , Left
  176.     End If
  177.  
  178.     If Byt >= 17 And Byt < 25 Then
  179.        Shift Command_1 , Left
  180.     End If
  181.  
  182.     If Byt >= 25 Then
  183.        Shift Command_0 , Left
  184.     End If
  185.  End If
  186.  
  187.  Tik = 0
  188.  
  189.  If Byt = 32 Then
  190.    Address_nec = Address_1
  191.    Command_nec = Command_1
  192.    Set Got
  193.    Address_1 = 255
  194.    Command_1 = 255
  195.    Byt = 0
  196.    Repeat_flag = 0
  197.    Start_flag = 0
  198.    Stop Timer0
  199.  End If
  200.  
  201.  ReturnCodebox]

Re: Pilot IR NEC

: 12 sty 2018, 15:15
autor: niveasoft
Wolisz żebym Ci napisał jak to zrobić i samemu pogłówkować czy chcesz gotowca? :D

Wykorzystałbym jakiś odcinek czasowy i kiedy:
Ma działać tak długo jak wcisnięty przycisk to -> ustaw Timeout_działania na 2xdługość czasowego przesyłania komendy
->dalej jak tylko Timeout > 0 to odliczaj w dół. Jak Timeout = 0 to wyłacz wyjście.
Czyli ktoś nadaje, timepout jest odliczany zawsze, ale zawsze jest odbudowywany bo odebrano znów kod i tak długo trzyma wyjście aż puścisz.

Sprawa włącz wyłącz -> odebrano kod ->(jeśli Lock_timeout = 0 Then) ustawiam Lock_timeout czyli czas na puszczenie przycisku. Dopóki odbieram tę sama komendę to Lock_timeout jest odświeżany.
->użytkownik puścił przycisk - minęło 2xczas odebrania komendy->zatrzask (Lock_timeout) zdjęty) i można przełaczyć stan

Re: Pilot IR NEC

: 12 sty 2018, 18:12
autor: marekszy
No dzięki za wytłumaczenie, ale trochę mi zajmie kombinowanie, wolę spojrzeć na gotowca wtedy jakoś łatwiej to zrozumiec.

Re: Pilot IR NEC

: 14 sty 2018, 15:01
autor: niveasoft
Proszę. Nietestowane. Musiałem zrezygnować z użycia Bitów na rzecz Bajtów.
To przeświadczenie że obsługa Bitów zajmuje mniej wzięło się chyba z tego że kiedyś procki miały mało SRAM.
Niestety żeby użyć Bit to trzeba skomplikowanego kodu który sprawdza poszczególne Bity w bajcie.
Miałem 100% użycia Flash i 10Bytes to long.
Po tym jak użyłem Byte zamiast Bit spadło do 98% ;)
  1. 'Tester pilotów NEC - dziala
  2. 'LCD: RS-PB.3 , ENA-PB.2 , D4-PB.6 , D5-PB.5 , D6-PB.7 , D7-PB.4
  3. 'WYJŚCIA: LED_G-PD.6 , LED_R-PD.4 , LED_B-PD.3 , LED_Y-PD.5 , LED_G-PD.1 , LED_R-PD.0
  4. 'ODBIORNIK IR-PD.2 (INT0)
  5. 'ODBIORNIK IR NEC-PD.3 (INT1)
  6. 'CKDIW 8 - wylaczone
  7. 'PORTA.0/PORTA.1 - kwarc  ,PORTA.2 - reset
  8. 'Adres:0 , 1 – com: 162 , 2 – com: 98 , 3 – com: 226 , 4 – com: 34 , 5 – com: 2 , 6 – com: 194
  9. '7 – com: 224 , 8 – com: 168 , 9 – com: 144 , 0 – com: 152 , * - com: 104 , # - com: 176
  10. 'Góra  - com: 24 , Dół – com: 74 , Lewo – com: 16 , Prawo – com: 90 , OK – com: 56
  11.  
  12. '1 - com:34 ,
  13.  
  14. $regfile = "attiny2313.dat"
  15. $crystal = 8000000
  16. $hwstack = 36
  17. $swstack = 36
  18. $framesize = 40
  19.  
  20. Config Porta = &B11111100 : Porta = &B11111111
  21. Config Portb = &B11111100 : Portb = &B11111111
  22. Config Portd = &B11110011 : Portd = &B00001100
  23.  
  24. Config Lcdpin = Pin , Db4 = PortB.6 , Db5 = Portb.5 , Db6 = Portb.7 , Db7 = Portb.4 , E = Portb.2 , Rs = Portb.3
  25. Config Lcd = 16x2
  26. Cursor Off
  27. Cls
  28.  
  29. Config Timer1 = Timer , Prescale = 1024 , Clear_timer = 1
  30.  Compare1a = 77                                             '10ms @8MHz/1024
  31.  
  32.  
  33. Config Timer0 = Timer , Prescale = 256                      '8000000/256=31250 Hz
  34. Config Int1 = Falling                                       'Interruption on Falling
  35. Stop Timer0
  36. Enable Timer0
  37. Enable Int1
  38. Enable Interrupts
  39. On Timer0 Tikers                                            'work on timer
  40. On Int1 Infrared
  41.  
  42. Locate 1 , 1
  43. Lcd "NEC DEC."
  44. Locate 2 , 1
  45. Lcd "Marekszy"
  46.  
  47. led_0 alias portd.0
  48. Led_1 Alias Portd.1
  49. led_4 alias portd.4
  50. led_5 alias portd.5
  51. led_6 alias portd.6
  52.  
  53.                                             'work on interruption
  54. Dim Got As Byte
  55. Dim Tik As Word                                             'counter of teaks of timer
  56. Dim Byt As Byte                                             'counter accepted bit
  57. Dim Repeat_flag As Byte                                     'flag of repetition
  58. Dim Start_flag As Byte                                      'flag of start condition
  59. Dim Address_1 As Byte                                       'direct byte of address
  60. Dim Command_1 As Byte                                       'direct byte of command
  61. Dim Address_0 As Byte                                       'indirect byte of address
  62. Dim Command_0 As Byte                                       'indirect byte of command
  63. Dim Summa As Word
  64. Dim Address_nec As Byte , Command_nec As Byte
  65.  
  66. '################################################################################################################
  67. Dim Lock_timeout As Byte , Time_to_off_led5 As Byte
  68.  
  69.  
  70. Do                                                          'Main cycle
  71.  If Got = 1 Then
  72.    Cls
  73.    Locate 1 , 1
  74.    Lcd "Adr:" ; Address_nec
  75.    Locate 2 , 1
  76.    Lcd "Com:" ; Command_nec                                     'Lcd ADDRESS and COMMAND
  77.    Reset Got
  78.  End If
  79.  
  80.  If Tifr.ocf1a = 1 Then
  81.   Tifr.ocf1a = 1
  82.  
  83.    If Lock_timeout > 0 Then Decr Lock_timeout
  84.    If Time_to_off_led5 > 0 Then Decr Time_to_off_led5
  85.  
  86.  End If
  87.  
  88.  
  89. If Address_nec <> 255 Then                                      'jeśli Wpisać "If Address=0 Then"
  90.                                                                 'to zawęzimy tylko do telewizorów
  91.  
  92.  Select Case Command_nec
  93.  
  94.    Case 162:                                                    'przycisk pilota - 1
  95.       set Led_0
  96.    Case 98:                                                     'przycisk pilota - 2
  97.  
  98.       If Lock_timeout = 0 Then Toggle Led_1                 'tylko jeśli wcześniej zwolniono przycisk
  99.       Lock_timeout = 50                                     '50x10ms=500ms
  100.       'lock przedłużany zawsze jak odebrano tą komendę
  101.  
  102.    Case 226:                                                'przycisk pilota - 3
  103.  
  104.       Time_to_off_led5 = 10                                 '100ms
  105.        'ustawiamy czas a nie pin
  106.        'wartośc odnawiana tak długo jak wciśnięty przycisk
  107.  
  108.    case 34:                                                     'przycisk pilota - 4
  109.       set led_4
  110.    case 2:                                                      'przycisk pilota - 5
  111.       set led_6
  112.    case 176:                                                    'przycisk pilota - #
  113.       Reset Led_0
  114.       Reset Led_1
  115.       Reset Led_4
  116.       Reset Led_5
  117.       reset led_6
  118.   End Select
  119.  
  120. End If
  121.  
  122.  If Time_to_off_led5 > 0 Then Set Led_5 Else Reset Led_5
  123.   'dopóki wartośc jest odnawiana przyciskiem to Led5 świeci
  124.  
  125. Loop
  126. End                                                     'End of main cycle
  127.  
  128. '################################################################################################################
  129.  
  130.  Tikers:                                                    'work on timer
  131.    Timer0 = 253                                               '31250/(256-253)=10416,66 Hz (96 een)
  132.    Incr Tik
  133.    If Tik >= 1200 Then                                        'if 1200 teaks, have thrown all in source condition
  134.      Tik = 0
  135.      Repeat_flag = 0
  136.      Start_flag = 0
  137.      Address_1 = 255
  138.      Command_1 = 255
  139.      Address_0 = 0
  140.      Command_0 = 0
  141.      Address_nec = 255
  142.      Command_nec = 255
  143.      Stop Timer0
  144.    End If
  145.  Return
  146. '################################################################################################################
  147.  
  148.  Infrared:                                                  'work on interruption
  149.  Start Timer0
  150.  
  151.  If Tik >= 139 And Tik < 150 Then                           'if has happenned from 139 before 150 teaks - "START"
  152.   Address_nec = 1
  153.   Repeat_flag = 0
  154.   Start_flag = 1
  155.   Address_1 = 255
  156.   Command_1 = 255
  157.   Address_0 = 0
  158.   Command_0 = 0
  159.  End If
  160.  
  161.  If Tik >= 116 And Tik < 139 Then                           'if has happenned from 116 before 138 teaks - "REPETITION"
  162.   Address_nec = 0
  163.   Repeat_flag = 1
  164.   Start_flag = 0
  165.  End If
  166.  
  167.  If Tik >= 22 And Tik < 116 And Start_flag = 1 Then         'if has happenned from 22 before 115 teaks - have taken "1"
  168.    Incr Byt
  169.  
  170.    If Byt < 9 Then
  171.       Shift Address_1 , Left
  172.       Address_1 = Address_1 + 1
  173.    End If
  174.  
  175.    If Byt >= 9 And Byt < 17 Then
  176.       Shift Address_0 , Left
  177.       Address_0 = Address_0 + 1
  178.    End If
  179.  
  180.    If Byt >= 17 And Byt < 25 Then
  181.       Shift Command_1 , Left
  182.       Command_1 = Command_1 + 1
  183.    End If
  184.  
  185.    If Byt >= 25 Then
  186.       Shift Command_0 , Left
  187.       Command_0 = Command_0 + 1
  188.    End If
  189.  End If
  190.  
  191.  If Tik >= 10 And Tik < 22 And Start_flag = 1 Then          'if has happenned from 10 before 21 teaks - have taken "0"
  192.     Incr Byt
  193.     If Byt < 9 Then
  194.       Shift Address_1 , Left
  195.     End If
  196.  
  197.     If Byt >= 9 And Byt < 17 Then
  198.        Shift Address_0 , Left
  199.     End If
  200.  
  201.     If Byt >= 17 And Byt < 25 Then
  202.        Shift Command_1 , Left
  203.     End If
  204.  
  205.     If Byt >= 25 Then
  206.        Shift Command_0 , Left
  207.     End If
  208.  End If
  209.  
  210.  Tik = 0
  211.  
  212.  If Byt = 32 Then
  213.    Address_nec = Address_1
  214.    Command_nec = Command_1
  215.    Got = 1
  216.    Address_1 = 255
  217.    Command_1 = 255
  218.    Byt = 0
  219.    Repeat_flag = 0
  220.    Start_flag = 0
  221.    Stop Timer0
  222.  End If
  223.  
  224.  Return

Re: Pilot IR NEC

: 14 sty 2018, 17:47
autor: marekszy
Bartek, mistrzu, obsługa przycisków działa tak jak chciałem, teraz można dobrać sobie to co komu pasuje.
Nie mam jeszcze na niego pomysłu, ale mając taki zarys działania można go adoptować wszędzie.
Dzięki
Po wywaleniu obsługi lcd zajmuje już tylko 66%

Re: Pilot IR NEC

: 14 sty 2018, 20:23
autor: Pikczu
Bartek możesz zredukować tylko to jednego bajtu i podzielić na poszczególne bity.
dim flaga as byte
flaga.0
flaga.1
flaga.2
I tak dalej tak dalej , wtedy załatwiasz 8 flag jednym bajtem, zawsze tez można z Aliasować.

Pozdrawiam
Pikczu

Re: Pilot IR NEC

: 10 lut 2018, 18:21
autor: Henryk
Witam :D
Poczytałem , pobawiłem się , Dzięki fajnie hula :)
Skorzystałem , to i dzielę się z tym co namieszałem .
Mała przeróbka pod Atmaga 8 , pilot z tandetnego odbiornika DVBT ( jak na fotce ) , do wykorzystania pozostał portc - jeśli zrezygnujemy z LCD i część portd .
Klawisze 1 - 8 sterują pinami portub , resztę pozostawiam twórczemu myśleniu ;)
  1. $regfile = "m8def.dat"
  2. $crystal = 8000000
  3. $hwstack = 36
  4. $swstack = 36
  5. $framesize = 40
  6. ' Pind.3 - podpinamy do wyjścia IR
  7. Config Portb = &B11111111 : Portb = &B11111111
  8. 'Config Portd = &B11110011 : Portd = &B11111111
  9. Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
  10. Cursor Off
  11. Cls
  12.  
  13. Config Timer1 = Timer , Prescale = 1024 , Clear_timer = 1
  14.  Compare1a = 77                                             '10ms @8MHz/1024
  15.  
  16.  
  17. Config Timer0 = Timer , Prescale = 256                      '8000000/256=31250 Hz
  18. Config Int1 = Falling                                       'Interruption on Falling
  19. Stop Timer0
  20. Enable Timer0
  21. Enable Int1
  22. Enable Interrupts
  23. On Timer0 Tikers                                            'work on timer
  24. On Int1 Infrared
  25.  
  26. Locate 1 , 1
  27. Lcd "NEC DEC."
  28. Locate 2 , 1
  29. Lcd "Marekszy"
  30.  
  31. Led_0 Alias Portb.0
  32. Led_1 Alias Portb.1
  33. Led_2 Alias Portb.2
  34. Led_3 Alias Portb.3
  35. Led_4 Alias Portb.4
  36. Led_5 Alias Portb.5
  37. Led_6 Alias Portb.6
  38. Led_7 Alias Portb.7
  39.                                             'work on interruption
  40. Dim Got As Byte
  41. Dim Tik As Word                                             'counter of teaks of timer
  42. Dim Byt As Byte                                             'counter accepted bit
  43. Dim Repeat_flag As Byte                                     'flag of repetition
  44. Dim Start_flag As Byte                                      'flag of start condition
  45. Dim Address_1 As Byte                                       'direct byte of address
  46. Dim Command_1 As Byte                                       'direct byte of command
  47. Dim Address_0 As Byte                                       'indirect byte of address
  48. Dim Command_0 As Byte                                       'indirect byte of command
  49. Dim Summa As Word
  50. Dim Address_nec As Byte , Command_nec As Byte
  51.  
  52. '################################################################################################################
  53.  
  54. Do                                                          'Main cycle
  55.  If Got = 1 Then
  56.    Cls
  57.    Locate 1 , 1
  58.    Lcd "Adr:" ; Address_nec
  59.    Locate 2 , 1
  60.    Lcd "Com:" ; Command_nec                                     'Lcd ADDRESS and COMMAND
  61.    Reset Got
  62.  End If
  63.  
  64.  If Address_nec <> 1 Then       'jeśli Wpisać "If Address=0 Then" to zawęzimy tylko do telewizorów
  65.  
  66.  Select Case Command_nec
  67.  
  68.    Case 32:         'przycisk pilota - 1
  69.       Toggle Led_0
  70.       Waitms 100
  71.    Case 160:        'przycisk pilota - 2
  72.       Toggle Led_1
  73.       Waitms 100
  74.    Case 96:         'przycisk pilota - 3
  75.       Toggle Led_2
  76.       Waitms 100
  77.    Case 224:        'przycisk pilota - 4
  78.       Toggle Led_3
  79.       Waitms 100
  80.    Case 16:          'przycisk pilota - 5
  81.       Toggle Led_4
  82.       Waitms 100
  83.    Case 144:        'przycisk pilota - 6
  84.       Toggle Led_5
  85.       Waitms 100
  86.    Case 80:         'przycisk pilota - 7
  87.       Toggle Led_6
  88.       Waitms 100
  89.    Case 216:        'przycisk pilota - 8
  90.       Toggle Led_7
  91.       Waitms 100
  92.    Case 72:
  93.       Set Led_0
  94.       Set Led_1
  95.       Set Led_2
  96.       Set Led_3
  97.       Set Led_4
  98.       Set Led_5
  99.       Set Led_6
  100.       Set Led_7
  101.   End Select
  102.  
  103. End If
  104.  
  105.  Loop
  106. End                                                     'End of main cycle
  107.  
  108. '################################################################################################################
  109.  
  110.  Tikers:                                                    'work on timer
  111.    Timer0 = 253                                               '31250/(256-253)=10416,66 Hz (96 een)
  112.    Incr Tik
  113.    If Tik >= 1200 Then                                        'if 1200 teaks, have thrown all in source condition
  114.      Tik = 0
  115.      Repeat_flag = 0
  116.      Start_flag = 0
  117.      Address_1 = 255
  118.      Command_1 = 255
  119.      Address_0 = 0
  120.      Command_0 = 0
  121.      Address_nec = 255
  122.      Command_nec = 255
  123.      Stop Timer0
  124.    End If
  125.  Return
  126. '################################################################################################################
  127.  
  128.  Infrared:                                                  'work on interruption
  129.  Start Timer0
  130.  
  131.  If Tik >= 139 And Tik < 150 Then                           'if has happenned from 139 before 150 teaks - "START"
  132.   Address_nec = 1
  133.   Repeat_flag = 0
  134.   Start_flag = 1
  135.   Address_1 = 255
  136.   Command_1 = 255
  137.   Address_0 = 0
  138.   Command_0 = 0
  139.  End If
  140.  
  141.  If Tik >= 116 And Tik < 139 Then                           'if has happenned from 116 before 138 teaks - "REPETITION"
  142.   Address_nec = 0
  143.   Repeat_flag = 1
  144.   Start_flag = 0
  145.  End If
  146.  
  147.  If Tik >= 22 And Tik < 116 And Start_flag = 1 Then         'if has happenned from 22 before 115 teaks - have taken "1"
  148.    Incr Byt
  149.  
  150.    If Byt < 9 Then
  151.       Shift Address_1 , Left
  152.       Address_1 = Address_1 + 1
  153.    End If
  154.  
  155.    If Byt >= 9 And Byt < 17 Then
  156.       Shift Address_0 , Left
  157.       Address_0 = Address_0 + 1
  158.    End If
  159.  
  160.    If Byt >= 17 And Byt < 25 Then
  161.       Shift Command_1 , Left
  162.       Command_1 = Command_1 + 1
  163.    End If
  164.  
  165.    If Byt >= 25 Then
  166.       Shift Command_0 , Left
  167.       Command_0 = Command_0 + 1
  168.    End If
  169.  End If
  170.  
  171.  If Tik >= 10 And Tik < 22 And Start_flag = 1 Then          'if has happenned from 10 before 21 teaks - have taken "0"
  172.     Incr Byt
  173.     If Byt < 9 Then
  174.       Shift Address_1 , Left
  175.     End If
  176.  
  177.     If Byt >= 9 And Byt < 17 Then
  178.        Shift Address_0 , Left
  179.     End If
  180.  
  181.     If Byt >= 17 And Byt < 25 Then
  182.        Shift Command_1 , Left
  183.     End If
  184.  
  185.     If Byt >= 25 Then
  186.        Shift Command_0 , Left
  187.     End If
  188.  End If
  189.  
  190.  Tik = 0
  191.  
  192.  If Byt = 32 Then
  193.    Address_nec = Address_1
  194.    Command_nec = Command_1
  195.    Got = 1
  196.    Address_1 = 255
  197.    Command_1 = 255
  198.    Byt = 0
  199.    Repeat_flag = 0
  200.    Start_flag = 0
  201.    Stop Timer0
  202.  End If
  203.  
  204.  Return
pilot_media.JPG