[Bascom] 4D Systems Visi Genie

Gotowe kody obsługi układów elektronicznych udostępnione przez użytkowników forum.
ODPOWIEDZ
Pikczu
Posty: 389
Rejestracja: 17 sie 2015, 13:46
Lokalizacja: Dublin, Ireland
Kontakt:

[Bascom] 4D Systems Visi Genie

Post autor: Pikczu » 15 maja 2019, 21:44

Witam,
Udostępniam bibliotekę do wyświetlaczy firmy 4D systems.
Przygotowana pod środowisko VISI Geni dla wyświetlaczy generacji 4 procesorem diablo 16 (najbardziej wypasione z oferty).
https://www.4dsystems.com.au/
W skrócie 4d systems to znany i doświadczony producent wyświetlaczy inteligentnych z Australii.
Do tworzenia projektu na wyświetlacz potrzebne nam jest oprogramowanie Workshop 4 IDE za opłatą otrzymamy wersje PRO która pozwala na tworzenie wielowarstwowych elementów graficznych.
Workshop pro 4 składa się z czterech środowisk.
4 srodowiska.PNG
Designer
Designer pozwala na pisanie kodu 4DGL w jego naturalnej formie.
Visi
Visulane środowisko pozwalające na "przeciąganie i upuszczanie" grafiki z pełna kontrola nad generowanym kodem.
Visi Genie
Zaawansowane środowisko które pozwala na bardzo szybkie tworzenie projektu bez pisania grama kodu.
Serial
Środowisko przekształca wyświetlacz w "slave" bardzo bogata lista komend pozwala na pełna kontrole wyświetlacza przez port szeregowy.

Więcej o samym Workoshop 4 na stronie producenta:
https://www.4dsystems.com.au/product/4D_Workshop_4_IDE/

[media]https://www.youtube.com/watch?time_cont ... 1PCTq9H3Dw[/media]

Komunikacja w środowisku Visi Genie składa się z 11 komend i 37 obiektów.
tabela 1.PNG
Więcej o komunikacji mozemy znaleźc w linku:
http://www.4dsystems.com.au/productpage ... _R_2_0.pdf

Biblioteka w wersji 1.0 podzielona jest na sześć sub-rutyn i jedna funkcje.
(plik zawiera jedna nieużywaną subrutynę Push _fifo oraz funkcję pop_fifo do użycia w przyszłości)
Function Xor_this() -oblicza sumę kontrolna XOR
Sub 4d_uart_rx()' -do odczytu danych z UART
Sub 4d_read_obj_sub - do odczytu danych z obiektów.
'Sub Push_fifo -nieużywana.
Function Pop_fifo()-nieużywana.
Sub 4d_write_obj- do zapisu danych w obiektach.
Sub 4d_write_contrast- do zmiany kontrastu wyświetlacza
Sub 4d_write_str_old- wysyłanie stringów dla Bascoma w wersji 2.0.8.1
Sub 4d_write_str -wysyłanie stringów dla Bascoma w wersji for 2.0.8.2 i nowszej.

Wszytkie komentarze w języku angielskim,z racji tego iż biblioteka bedzie dostepna na forum 4D systems i MCS electronics.
W razie potrzeby pytajcie śmiało :)
  1. $nocompile
  2. '4D_system_Visi_Genie Library version 1.0
  3. 'By Pikczu 2019.05.14
  4. 'Pawel.labedz@gmail.com
  5. '-------------------------------------------------------------------------------
  6. ' Name to include: $include "Subs\4D_system_Visi_Genie_V1.0.inc"
  7. '                               ^
  8. '                               ^
  9. 'This is your folder with subs--^
  10. '-------------------------------------------------------------------------------
  11. 'This libry is dedicated for 4D systems LCD displays Visi Genie enviroment.
  12. 'Function Xor_this()
  13. 'Sub 4d_uart_rx()
  14. 'Sub 4d_read_obj_sub(object_id &H0 to &H25 , object index &H0 to &HFF )
  15. 'Sub Push_fifo -not in use
  16. 'Function Pop_fifo()- not in use
  17. 'Sub 4d_write_obj(object_id &H0 to &H25, object index &H0 to &HFF  , object value &h00 to &HFFFF )
  18. 'Sub 4d_write_contrast(contrast value from 1 to 10  )
  19. 'Sub 4d_write_str_old(index hex value , "your text" ) for bascom version before 2.0.8.2
  20. 'Sub 4d_write_str(index hex value , "your text" )  for bascom version 2.0.8.2 and above
  21. '*******************************************************************************
  22. ' To do:
  23. 'Add sub for unicode string
  24. 'Add magic code sub
  25. '*******************************************************************************
  26. '*****************************Used in 4D systems TX subs************************
  27. Dim ACK_NACK_flag As Byte                                   ' ACK byte flag is setup each time we expect the ack to come from the display
  28. ACK_NACK_flag = 0
  29. Dim 4d_wait_count as word                                   'Used inside each 4D sub rutine to count number of loops while waiting for the response from the lcd.
  30. Dim 4d_arr_tx(6)as Byte                                     'main array used to send the data
  31. Dim 4d_helpa As Word At 4d_arr_tx(4) Overlay                'array index 4 and  for object values
  32. Dim 4d_string_tx_arr(39) As Byte                            ' Array for string
  33. Dim 4d_string_tx As String * 34 At 4d_string_tx_arr(1) + 3 Overlay       '+3 add room for string length byte + command byte + string index
  34. '********************for future use ********************************************
  35. 'Const 4d_max_len = 32                                       'maximum 4D string length
  36. 'Const Ack_nack_max = 32                                     'max number of ack or NACK in the que
  37. 'Dim Ack_nack_cnt As Byte                                   'for feature use
  38. 'Dim 4d_frame As Byte                                       'for feature use
  39. 'Const 4d_max_frame = 16                                    'maximum number of message
  40. 'Dim Backup_tx As Byte                                      'for feature use
  41. '*******************************************************************************
  42. '*****************************Used in 4D systems RX subs************************
  43. Dim 4d_arr_rx(6) As Byte                                    'used for received data
  44. 'Dim 4d_var_rx As Word At 4d_arr_rx(4) Overlay               'overlay for rx
  45. 'Dim 4d_var_rx_tmp As Word
  46. 'Dim Obj_index As Byte                                       '4d object index
  47. '*******************************************************************************
  48. '***************************Variables used in XOR CRC **************************
  49. Dim Xor_crc As Byte                                         'xor crc for 4d
  50. Xor_crc = 0
  51. '*******************************************************************************
  52. '*****************************Variables for objects indexes ********************
  53. Dim Dipswitch_idx As Byte                                   '0
  54. Dim Knob_idx As Byte
  55. Dim Rockerswitch_idx As Byte
  56. Dim Rotaryswitch_idx As Byte
  57. Dim Slider_idx As Byte
  58. Dim Trackbar_idx As Byte
  59. Dim Winbutton_idx As Byte
  60. Dim Angularmeter_idx As Byte
  61. Dim Coolgauge_idx As Byte
  62. Dim Customdigits_idx As Byte
  63. Dim Form_idx As Byte                                        'Used To Set The Current Form
  64. Dim Gauge_idx As Byte                                       '
  65. 'Dim Image_idx As Byte                                       ' Displayed As Part Of Form , No Method To Alter
  66. Dim Keyboard_idx As Byte                                    ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  67. Dim Led_idx As Byte
  68. Dim Leddigits_idx As Byte
  69. Dim Meter_idx As Byte
  70. Dim Strings_idx As Byte
  71. Dim Thermometer_idx As Byte
  72. Dim Userled_idx As Byte
  73. Dim Video_idx As Byte
  74. 'Dim Statictext_idx As Byte                                  ' Displayed As Part Of Form , No Method To Alter
  75. Dim S_ound_idx As Byte
  76. Dim T_imer_idx As Byte
  77. Dim Spectrum_idx As Byte
  78. Dim Scope_idx As Byte
  79. Dim Tank_idx As Byte
  80. Dim Userimages_idx As Byte
  81. Dim Pinoutput_idx As Byte
  82. Dim Pininput_idx As Byte
  83. Dim 4dbutton_idx As Byte
  84. Dim Anibutton_idx As Byte
  85. Dim Colorpicker_idx As Byte
  86. Dim Userbutton_idx As Byte
  87. Dim Magicobject_idx As Byte                                 'ONLY Available When Using Genie Pro
  88. Dim Smartgauge_idx As Byte                                  'ONLY Available When Using Genie Pro
  89. Dim Smartslider_idx As Byte                                 'ONLY Available When Using Genie Pro
  90. Dim Smartknob_idx As Byte                                   'Only Available When Using Genie Pro
  91. '*******************************************************************************
  92. '**********************Arrays for objects values *******************************
  93. Dim Dipswitch_val(2) As Byte                                '0
  94. Dim Knob_val(2) As Byte
  95. Dim Rockerswitch_val(2) As Byte
  96. Dim Rotaryswitch_val(2) As Byte
  97. Dim Slider_val(2) As Byte
  98. Dim Trackbar_val(2) As Byte
  99. Dim Winbutton_val(2) As Byte
  100. Dim Angularmeter_val(2) As Byte
  101. Dim Coolgauge_val(2) As Byte
  102. Dim Customdigits_val(2) As Byte
  103. Dim Form_val(2) As Byte                                     'Used To Set The Current Form
  104. Dim Gauge_val(2) As Byte                                    '
  105. 'Dim Image_val(2) As Byte                                    ' Displayed As Part Of Form , No Method To Alter
  106. Dim Keyboard_val(2) As Byte                                 ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  107. Dim Led_val(2) As Byte
  108. Dim Leddigits_val(2) As Byte
  109. Dim Meter_val(2) As Byte
  110. Dim Strings_val(2) As Byte
  111. Dim Thermometer_val(2) As Byte
  112. Dim Userled_val(2) As Byte
  113. Dim Video_val(2) As Byte
  114. 'Dim Statictext_val(2) As Byte                               ' Displayed As Part Of Form , No Method To Alter
  115. Dim S_ound_val(2) As Byte
  116. Dim T_imer_val(2) As Byte
  117. Dim Spectrum_val(2) As Byte
  118. Dim Scope_val(2) As Byte
  119. Dim Tank_val(2) As Byte
  120. Dim Userimages_val(2) As Byte
  121. Dim Pinoutput_val As Byte
  122. Dim Pininput_val As Byte
  123. Dim 4dbutton_val(2) As Byte
  124. Dim Anibutton_val(2) As Byte
  125. Dim Colorpicker_val(2) As Byte
  126. Dim Userbutton_val(2) As Byte
  127. Dim Magicobject_val(2) As Byte                              'ONLY Available When Using Genie Pro
  128. Dim Smartgauge_val(2) As Byte                               'ONLY Available When Using Genie Pro
  129. Dim Smartslider_val(2) As Byte                              'ONLY Available When Using Genie Pro
  130. Dim Smartknob_val(2) As Byte                                'Only Available When Using Genie Pro
  131. '*******************************************************************************
  132. '*********************Constants used in select case for RX **********************
  133. Const A_ck = &H06
  134. Const Nak = &H15
  135. '*******************************************************************************
  136. Const Dipswitch = &H00                                      '0
  137. Const Knob = &H01
  138. Const Rockerswitch = &H02
  139. Const Rotaryswitch = &H03
  140. Const Slider = &H04
  141. Const Trackbar = &H05
  142. Const Winbutton = &H06
  143. Const Angularmeter = &H07
  144. Const Coolgauge = &H08
  145. Const Customdigits = &H09
  146. Const Form = &H0A                                           'Used To Set The Current Form
  147. Const Gauge = &H0B                                          '
  148. Const Image = &H0C                                          ' Displayed As Part Of Form , No Method To Alter
  149. Const Keyboard = &H0D                                       ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  150. Const Led = &H0E
  151. Const Leddigits = &H0F
  152. Const Meter = &H10
  153. Const Strings = &H11
  154. Const Thermometer = &H12
  155. Const Userled = &H13
  156. Const Video = &H14
  157. Const Statictext = &H15                                     ' Displayed As Part Of Form , No Method To Alter
  158. Const S_ound = &H16
  159. Const T_imer = &H17
  160. Const Spectrum = &H18
  161. Const Scope = &H19
  162. Const Tank = &H1A
  163. Const Userimages = &H1B
  164. Const Pinoutput = &H1C
  165. Const Pininput = &H1D
  166. Const 4dbutton = &H1E
  167. Const Anibutton = &H1F
  168. Const Colorpicker = &H20
  169. Const Userbutton = &H21
  170. Const Magicobject = &H22                                    'ONLY Available When Using Genie Pro
  171. Const Smartgauge = &H23                                     'ONLY Available When Using Genie Pro
  172. Const Smartslider = &H24                                    'ONLY Available When Using Genie Pro
  173. Const Smartknob = &H25                                      'Only Available When Using Genie Pro
  174. '*******************************************************************************
  175. Const Read_obj = &H00                                       'TX command to get value
  176. Const Write_obj = &H01                                      'TX command to write object value
  177. Const Write_str = &H02                                      'TX command to send string
  178. Const Write_stru = &H03                                     'TX command to send string unicode
  179. Const Write_contrast = &H04                                 'TX command to set contrast
  180. Const Report_obj = &H05                                     'RX- response to read obj command
  181. Const Report_event = &H07                                   'RX response to event no request needed
  182. Const Write_magic_bytes = &H08                              'TX command for magic bytes PRO licence required
  183. Const Write_magic_dbytes = &H09                             'TX command for magic bytes PRO licence required
  184. Const Report_magic_event_bytes = &H0A                       'RX response to  magic bytes PRO licence required
  185. '*******************************************************************************
  186. '*******************************************************************************
  187. '**************************XOR function to calculate CRC************************
  188. Function Xor_this(ar()as Byte ) As Byte                     '  Function XOR
  189.    Local Xor_ing As Byte                                    'temporary variable for xor value so could be a local
  190.    Xor_ing = Ar(1) Xor Ar(2)                                'xoring
  191.    Xor_ing = Xor_ing Xor Ar(3)
  192.    Xor_ing = Xor_ing Xor Ar(4)
  193.    Xor_ing = Xor_ing Xor Ar(5)
  194.  
  195.    Xor_this = Xor_ing                                       'final result assignment
  196. End Function
  197.  
  198. '*******************************************************************************
  199. '*************************SUB for checking the UART ****************************
  200. Sub 4d_uart_rx()
  201. '*******************************************************************************
  202. 'Call this sub routine from main loop to check for events.
  203. 'Syntax : Call 4d_uart_rx()
  204. 'In adition this sub is called from: 4d_read_obj_sub, 4d_write_obj, 4d_write_contrast and 4d_write_str
  205. 'For more info refer to Visi Genie reference manual page 10 section 3.1.3.6 &7
  206. 'Global variable will be updated.
  207. '*******************************************************************************
  208.    While Ischarwaiting(#4) <> 0
  209.       Inputbin #lcd_4d , 4d_arr_rx(1) , 1
  210.       'print #debug_port , "received= " ; 4d_arr_rx(1)
  211.       Select Case 4d_arr_rx(1)                              'command
  212.          '**********************************************************************
  213.          Case Report_obj:                                   '&H05  report object command
  214.             Inputbin #lcd_4d , 4d_arr_rx(2) , 5             'get next 5 bytes from the buffer
  215.             Xor_crc = Xor_this(4d_arr_rx(1))                ' check the crc
  216.             If 4d_arr_rx(6) = Xor_crc Then                  'if crc ok then check what came
  217.                'CRC ok then we can clear the flag
  218.                ACK_NACK_flag = 0                            'reset ACK flag
  219.                Select Case 4d_arr_rx(2)                     'object ID
  220.                   Case Dipswitch:                           '0
  221.                      Dipswitch_idx = 4d_arr_rx(3)
  222.                      Dipswitch_val(1) = 4d_arr_rx(4)
  223.                      Dipswitch_val(2) = 4d_arr_rx(5)
  224.                      'Print #debug_port , "Dipswitch "
  225.                      Debug "Dipswitch "
  226.                   Case Knob:                                '1
  227.                      Knob_idx = 4d_arr_rx(3)
  228.                      Knob_val(1) = 4d_arr_rx(4)
  229.                      Knob_val(2) = 4d_arr_rx(5)
  230.                      'Print #debug_port , "Knob "
  231.                      Debug "Knob "
  232.                   Case Rockerswitch:                        '2
  233.                      Rockerswitch_idx = 4d_arr_rx(3)
  234.                      Rockerswitch_val(1) = 4d_arr_rx(4)
  235.                      Rockerswitch_val(2) = 4d_arr_rx(5)
  236.                      'Print #debug_port , "Rockerswitch "
  237.                      Debug "Rockerswitch "
  238.                   Case Rotaryswitch:                        '3
  239.                      Rotaryswitch_idx = 4d_arr_rx(3)
  240.                      Rotaryswitch_val(1) = 4d_arr_rx(4)
  241.                      Rotaryswitch_val(2) = 4d_arr_rx(5)
  242.                      'Print #debug_port , "Rotaryswitch "
  243.                      Debug "Rotaryswitch "
  244.                   Case Slider:                              '4
  245.                      Slider_idx = 4d_arr_rx(3)
  246.                      Slider_val(1) = 4d_arr_rx(4)
  247.                      Slider_val(2) = 4d_arr_rx(5)
  248.                      'Print #debug_port , "Slider "
  249.                      Debug "Slider "
  250.                   Case Trackbar:                            '5
  251.                      Trackbar_idx = 4d_arr_rx(3)
  252.                      Trackbar_val(1) = 4d_arr_rx(4)
  253.                      Trackbar_val(2) = 4d_arr_rx(5)
  254.                      'Print #debug_port , "Trackbar "
  255.                      Debug "Trackbar "
  256.                   Case Winbutton:                           '6
  257.                      Winbutton_idx = 4d_arr_rx(3)
  258.                      Winbutton_val(1) = 4d_arr_rx(4)
  259.                      Winbutton_val(2) = 4d_arr_rx(5)
  260.                      'Print #debug_port , "Winbutton "
  261.                      Debug "Winbutton "
  262.                   Case Angularmeter:                        '7
  263.                      Angularmeter_idx = 4d_arr_rx(3)
  264.                      Angularmeter_val(1) = 4d_arr_rx(4)
  265.                      Angularmeter_val(2) = 4d_arr_rx(5)
  266.                      'Print #debug_port , "Angularmeter "
  267.                      Debug "Angularmeter "
  268.                   Case Coolgauge:                           '8
  269.                      Coolgauge_idx = 4d_arr_rx(3)
  270.                      Coolgauge_val(1) = 4d_arr_rx(4)
  271.                      Coolgauge_val(2) = 4d_arr_rx(5)
  272.                      'Print #debug_port , "Coolgauge "
  273.                      Debug "Coolgauge "
  274.                   Case Customdigits:                        '9
  275.                      Customdigits_idx = 4d_arr_rx(3)
  276.                      Customdigits_val(1) = 4d_arr_rx(4)
  277.                      Customdigits_val(2) = 4d_arr_rx(5)
  278.                      'Print #debug_port , "Customdigits "
  279.                      Debug "Customdigits "
  280.                   Case Form:                                '10
  281.                      Form_idx = 4d_arr_rx(3)
  282.                      Form_val(1) = 4d_arr_rx(4)
  283.                      Form_val(2) = 4d_arr_rx(5)
  284.                      'Print #debug_port , "Form "
  285.                      Debug "Form "
  286.                   Case Gauge:                               '11
  287.                      Gauge_idx = 4d_arr_rx(3)
  288.                      Gauge_val(1) = 4d_arr_rx(4)
  289.                      Gauge_val(2) = 4d_arr_rx(5)
  290.                      'Print #debug_port , "Gauge "
  291.                      Debug "Gauge "
  292.                   Case Image:                               '12
  293.                   'Image_idx = 4d_arr_rx(3)
  294.                   'Image_val(1) = 4d_arr_rx(4)
  295.                   'Image_val(2) = 4d_arr_rx(5)
  296.                      'Print #debug_port , "Image "
  297.                      Debug "Image "
  298.                   Case Keyboard:                            '13
  299.                      Keyboard_idx = 4d_arr_rx(3)
  300.                      Keyboard_val(1) = 4d_arr_rx(4)
  301.                      Keyboard_val(2) = 4d_arr_rx(5)
  302.                      'Print #debug_port , "Keyboard "
  303.                      Debug "Keyboard "
  304.                   Case Led:                                 '14
  305.                      Led_idx = 4d_arr_rx(3)
  306.                      Led_val(1) = 4d_arr_rx(4)
  307.                      Led_val(2) = 4d_arr_rx(5)
  308.                      'Print #debug_port , "Led "
  309.                      Debug "Led "
  310.                   Case Leddigits:                           '15
  311.                      Leddigits_idx = 4d_arr_rx(3)
  312.                      Leddigits_val(1) = 4d_arr_rx(4)
  313.                      Leddigits_val(2) = 4d_arr_rx(5)
  314.                      'Print #debug_port , "Leddigits "
  315.                      Debug "Leddigits "
  316.                   Case Meter:                               '16
  317.                      Meter_idx = 4d_arr_rx(3)
  318.                      Meter_val(1) = 4d_arr_rx(4)
  319.                      Meter_val(2) = 4d_arr_rx(5)
  320.                      'Print #debug_port , "Meter "
  321.                      Debug "Meter "
  322.                   Case Strings:                             '17
  323.                      Strings_idx = 4d_arr_rx(3)
  324.                      Strings_val(1) = 4d_arr_rx(4)
  325.                      Strings_val(2) = 4d_arr_rx(5)
  326.                      Print #debug_port , "Strings "
  327.                      Debug "Strings "
  328.                   Case Thermometer:                         '18
  329.                      Thermometer_idx = 4d_arr_rx(3)
  330.                      Thermometer_val(1) = 4d_arr_rx(4)
  331.                      Thermometer_val(2) = 4d_arr_rx(5)
  332.                      'Print #debug_port , "Thermometer "
  333.                      Debug "Thermometer "
  334.                   Case Userled:                             '19
  335.                      Userled_idx = 4d_arr_rx(3)
  336.                      Userled_val(1) = 4d_arr_rx(4)
  337.                      Userled_val(2) = 4d_arr_rx(5)
  338.                      Print #debug_port , "Userled "
  339.                      Debug "Userled "
  340.                   Case Video:                               '20
  341.                      Video_idx = 4d_arr_rx(3)
  342.                      Video_val(1) = 4d_arr_rx(4)
  343.                      Video_val(2) = 4d_arr_rx(5)
  344.                       'Print #debug_port ,  "Video "
  345.                      Debug "Video "
  346.                   Case Statictext:                          '21
  347.                   'Statictext_idx = 4d_arr_rx(3)
  348.                   'Statictext_val(1) = 4d_arr_rx(4)
  349.                   'Statictext_val(2) = 4d_arr_rx(5)
  350.                    'Print #debug_port , "Statictext "
  351.                      Debug "Statictext "
  352.                   Case S_ound:                              '22
  353.                      S_ound_idx = 4d_arr_rx(3)
  354.                      S_ound_val(1) = 4d_arr_rx(4)
  355.                      S_ound_val(2) = 4d_arr_rx(5)
  356.                     'Print #debug_port , "S_ound "
  357.                      Debug "S_ound "
  358.                   Case T_imer:                              '23
  359.                      T_imer_idx = 4d_arr_rx(3)
  360.                      T_imer_val(1) = 4d_arr_rx(4)
  361.                      T_imer_val(2) = 4d_arr_rx(5)
  362.                      'Print #debug_port , "T_imer "
  363.                      Debug "T_imer "
  364.                   Case Spectrum:                            '24
  365.                      Spectrum_idx = 4d_arr_rx(3)
  366.                      Spectrum_val(1) = 4d_arr_rx(4)
  367.                      Spectrum_val(2) = 4d_arr_rx(5)
  368.                      'Print #debug_port , "Spectrum "
  369.                      Debug "Spectrum "
  370.                   Case Scope:                               '25
  371.                      Scope_idx = 4d_arr_rx(3)
  372.                      Scope_val(1) = 4d_arr_rx(4)
  373.                      Scope_val(2) = 4d_arr_rx(5)
  374.                      'Print #debug_port , "Scope "
  375.                      Debug "Scope "
  376.                   Case Tank:                                '26
  377.                      Tank_idx = 4d_arr_rx(3)
  378.                      Tank_val(1) = 4d_arr_rx(4)
  379.                      Tank_val(2) = 4d_arr_rx(5)
  380.                      'Print #debug_port , "Tank "
  381.                      Debug "Tank "
  382.                   Case Userimages:                          '27
  383.                      Userimages_idx = 4d_arr_rx(3)
  384.                      Userimages_val(1) = 4d_arr_rx(4)
  385.                      Userimages_val(2) = 4d_arr_rx(5)
  386.                      'Print #debug_port , "Userimages "
  387.                      Debug "Userimages "
  388.                   Case Pinoutput:                           '28
  389.                      Pinoutput_idx = 4d_arr_rx(3)
  390.                   'Pinoutput_val(1) = 4d_arr_rx(4)
  391.                      Pinoutput_val = 4d_arr_rx(5)
  392.                      'Print #debug_port , "Pinoutput "
  393.                      Debug "Pinoutput "
  394.                   Case Pininput:                            '29
  395.                      Pininput_idx = 4d_arr_rx(3)
  396.                   'Pininput_val(1) = 4d_arr_rx(4)
  397.                      Pininput_val = 4d_arr_rx(5)
  398.                      'Print #debug_port , "Pininput "
  399.                      Debug "Pininput "
  400.                   Case 4dbutton:                            '30
  401.                      4dbutton_idx = 4d_arr_rx(3)
  402.                      4dbutton_val(1) = 4d_arr_rx(4)
  403.                      4dbutton_val(2) = 4d_arr_rx(5)
  404.                      'Print #debug_port , "4dbutton "
  405.                      Debug "4dbutton "
  406.                   Case Anibutton:                           '31
  407.                      Anibutton_idx = 4d_arr_rx(3)
  408.                      Anibutton_val(1) = 4d_arr_rx(4)
  409.                      Anibutton_val(2) = 4d_arr_rx(5)
  410.                      'Print #debug_port , "Anibutton "
  411.                      Debug "Anibutton "
  412.                   Case Colorpicker:                         '32
  413.                      Colorpicker_idx = 4d_arr_rx(3)
  414.                      Colorpicker_val(1) = 4d_arr_rx(4)
  415.                      Colorpicker_val(2) = 4d_arr_rx(5)
  416.                      'Print #debug_port , "Colorpicker "
  417.                      Debug "Colorpicker "
  418.                   Case Userbutton:                          '33
  419.                      Userbutton_idx = 4d_arr_rx(3)
  420.                      Userbutton_val(1) = 4d_arr_rx(4)
  421.                      Userbutton_val(2) = 4d_arr_rx(5)
  422.                      'Print #debug_port , "Userbutton "
  423.                      Debug "Userbutton "
  424.                   Case Magicobject:                         '34
  425.                      Magicobject_idx = 4d_arr_rx(3)
  426.                      Magicobject_val(1) = 4d_arr_rx(4)
  427.                      Magicobject_val(2) = 4d_arr_rx(5)
  428.                      'Print #debug_port , "Magicobject "
  429.                      Debug "Magicobject "
  430.                   Case Smartgauge:                          '35
  431.                      Smartgauge_idx = 4d_arr_rx(3)
  432.                      Smartgauge_val(1) = 4d_arr_rx(4)
  433.                      Smartgauge_val(2) = 4d_arr_rx(5)
  434.                      'Print #debug_port , "Smartgauge "
  435.                      Debug "Smartgauge "
  436.                   Case Smartslider:                         '36
  437.                      Smartslider_idx = 4d_arr_rx(3)
  438.                      Smartslider_val(1) = 4d_arr_rx(4)
  439.                      Smartslider_val(2) = 4d_arr_rx(5)
  440.                      'Print #debug_port , "Smartslider "
  441.                      Debug "Smartslider "
  442.                   Case Smartknob:                           '37
  443.                      Smartknob_idx = 4d_arr_rx(3)
  444.                      Smartknob_val(1) = 4d_arr_rx(4)
  445.                      Smartknob_val(2) = 4d_arr_rx(5)
  446.                      'Print #debug_port , "Smartknob "
  447.                      Debug "Smartknob "
  448.                   Case Else:
  449.                   'This should never happen as CRC being check before select case
  450.                   'But lets keep this here just in case.
  451.                      'Print #debug_port , "Event report wrong ID: " ; 4d_arr_rx(3)
  452.                      Debug "Event report wrong ID: " ; 4d_arr_rx(3)
  453.                      'Clear Serialin4
  454.                      'Print #debug_port , "S_pace: " ; S_pace
  455.                      'Print #debug_port , "frame error"
  456.                End Select
  457.             Else
  458.                Printbin #lcd_4d , &H15                      'send NACK message to the display
  459.                'Print #debug_port , "Read object CRC error !"
  460.                Debug "Read object CRC error !"
  461.             End If
  462.          '**********************************************************************
  463.          Case A_ck:                                         '&H06    ACK command
  464.             ACK_NACK_flag = 0                               'reset ack flag
  465.             'Print #debug_port , "ACK"                       'print ACK message to debug port
  466.             Debug "ACK"                                     'print ACK message to debug port
  467.          '**********************************************************************
  468.          Case Report_event:                                 '&H07
  469.             Inputbin #4 , 4d_arr_rx(2) , 5                  'get next 5 get next 5 bytes from the buffer
  470.             Xor_crc = Xor_this(4d_arr_rx(1))                ' check the crc
  471.             If 4d_arr_rx(6) = Xor_crc Then                  'if crc ok then check what came
  472.  
  473.                Select Case 4d_arr_rx(2)                     'object ID
  474.                   Case Dipswitch:                           '0
  475.                      Dipswitch_idx = 4d_arr_rx(3)
  476.                      Dipswitch_val(1) = 4d_arr_rx(4)
  477.                      Dipswitch_val(2) = 4d_arr_rx(5)
  478.                      'Print #debug_port , "Dipswitch "
  479.                      Debug "Dipswitch "
  480.                   Case Knob:                                '1
  481.                      Knob_idx = 4d_arr_rx(3)
  482.                      Knob_val(1) = 4d_arr_rx(4)
  483.                      Knob_val(2) = 4d_arr_rx(5)
  484.                      'Print #debug_port , "Knob "
  485.                      Debug "Knob "
  486.                   Case Rockerswitch:                        '2
  487.                      Rockerswitch_idx = 4d_arr_rx(3)
  488.                      Rockerswitch_val(1) = 4d_arr_rx(4)
  489.                      Rockerswitch_val(2) = 4d_arr_rx(5)
  490.                      'Print #debug_port , "Rockerswitch "
  491.                      Debug "Rockerswitch "
  492.                   Case Rotaryswitch:                        '3
  493.                      Rotaryswitch_idx = 4d_arr_rx(3)
  494.                      Rotaryswitch_val(1) = 4d_arr_rx(4)
  495.                      Rotaryswitch_val(2) = 4d_arr_rx(5)
  496.                      'Print #debug_port , "Rotaryswitch "
  497.                      Debug "Rotaryswitch "
  498.                   Case Slider:                              '4
  499.                      Slider_idx = 4d_arr_rx(3)
  500.                      Slider_val(1) = 4d_arr_rx(4)
  501.                      Slider_val(2) = 4d_arr_rx(5)
  502.                      'Print #debug_port , "Slider "
  503.                      Debug "Slider "
  504.                   Case Trackbar:                            '5
  505.                      Trackbar_idx = 4d_arr_rx(3)
  506.                      Trackbar_val(1) = 4d_arr_rx(4)
  507.                      Trackbar_val(2) = 4d_arr_rx(5)
  508.                      'Print #debug_port , "Trackbar "
  509.                      Debug "Trackbar "
  510.                   Case Winbutton:                           '6
  511.                      Winbutton_idx = 4d_arr_rx(3)
  512.                      Winbutton_val(1) = 4d_arr_rx(4)
  513.                      Winbutton_val(2) = 4d_arr_rx(5)
  514.                      'Print #debug_port , "Winbutton "
  515.                      Debug "Winbutton "
  516.                   Case Angularmeter:                        '7
  517.                      Angularmeter_idx = 4d_arr_rx(3)
  518.                      Angularmeter_val(1) = 4d_arr_rx(4)
  519.                      Angularmeter_val(2) = 4d_arr_rx(5)
  520.                      'Print #debug_port , "Angularmeter "
  521.                      Debug "Angularmeter "
  522.                   Case Coolgauge:                           '8
  523.                      Coolgauge_idx = 4d_arr_rx(3)
  524.                      Coolgauge_val(1) = 4d_arr_rx(4)
  525.                      Coolgauge_val(2) = 4d_arr_rx(5)
  526.                      'Print #debug_port , "Coolgauge "
  527.                      Debug "Coolgauge "
  528.                   Case Customdigits:                        '9
  529.                      Customdigits_idx = 4d_arr_rx(3)
  530.                      Customdigits_val(1) = 4d_arr_rx(4)
  531.                      Customdigits_val(2) = 4d_arr_rx(5)
  532.                      'Print #debug_port , "Customdigits "
  533.                      Debug "Customdigits "
  534.                   Case Form:                                '10
  535.                      Form_idx = 4d_arr_rx(3)
  536.                      Form_val(1) = 4d_arr_rx(4)
  537.                      Form_val(2) = 4d_arr_rx(5)
  538.                      'Print #debug_port , "Form "
  539.                      Debug "Form "
  540.                   Case Gauge:                               '11
  541.                      Gauge_idx = 4d_arr_rx(3)
  542.                      Gauge_val(1) = 4d_arr_rx(4)
  543.                      Gauge_val(2) = 4d_arr_rx(5)
  544.                      'Print #debug_port , "Gauge "
  545.                      Debug "Gauge "
  546.                   Case Image:                               '12
  547.                   'Image_idx = 4d_arr_rx(3)
  548.                   'Image_val(1) = 4d_arr_rx(4)
  549.                   'Image_val(2) = 4d_arr_rx(5)
  550.                      'Print #debug_port , "Image "
  551.                      Debug "Image "
  552.                   Case Keyboard:                            '13
  553.                      Keyboard_idx = 4d_arr_rx(3)
  554.                      Keyboard_val(1) = 4d_arr_rx(4)
  555.                      Keyboard_val(2) = 4d_arr_rx(5)
  556.                      'Print #debug_port , "Keyboard "
  557.                      Debug "Keyboard "
  558.                   Case Led:                                 '14
  559.                      Led_idx = 4d_arr_rx(3)
  560.                      Led_val(1) = 4d_arr_rx(4)
  561.                      Led_val(2) = 4d_arr_rx(5)
  562.                      'Print #debug_port , "Led "
  563.                      Debug "Led "
  564.                   Case Leddigits:                           '15
  565.                      Leddigits_idx = 4d_arr_rx(3)
  566.                      Leddigits_val(1) = 4d_arr_rx(4)
  567.                      Leddigits_val(2) = 4d_arr_rx(5)
  568.                      'Print #debug_port , "Leddigits "
  569.                      Debug "Leddigits "
  570.                   Case Meter:                               '16
  571.                      Meter_idx = 4d_arr_rx(3)
  572.                      Meter_val(1) = 4d_arr_rx(4)
  573.                      Meter_val(2) = 4d_arr_rx(5)
  574.                      'Print #debug_port , "Meter "
  575.                      Debug "Meter "
  576.                   Case Strings:                             '17
  577.                      Strings_idx = 4d_arr_rx(3)
  578.                      Strings_val(1) = 4d_arr_rx(4)
  579.                      Strings_val(2) = 4d_arr_rx(5)
  580.                      Print #debug_port , "Strings "
  581.                      Debug "Strings "
  582.                   Case Thermometer:                         '18
  583.                      Thermometer_idx = 4d_arr_rx(3)
  584.                      Thermometer_val(1) = 4d_arr_rx(4)
  585.                      Thermometer_val(2) = 4d_arr_rx(5)
  586.                      'Print #debug_port , "Thermometer "
  587.                      Debug "Thermometer "
  588.                   Case Userled:                             '19
  589.                      Userled_idx = 4d_arr_rx(3)
  590.                      Userled_val(1) = 4d_arr_rx(4)
  591.                      Userled_val(2) = 4d_arr_rx(5)
  592.                      Print #debug_port , "Userled "
  593.                      Debug "Userled "
  594.                   Case Video:                               '20
  595.                      Video_idx = 4d_arr_rx(3)
  596.                      Video_val(1) = 4d_arr_rx(4)
  597.                      Video_val(2) = 4d_arr_rx(5)
  598.                       'Print #debug_port ,  "Video "
  599.                      Debug "Video "
  600.                   Case Statictext:                          '21
  601.                   'Statictext_idx = 4d_arr_rx(3)
  602.                   'Statictext_val(1) = 4d_arr_rx(4)
  603.                   'Statictext_val(2) = 4d_arr_rx(5)
  604.                    'Print #debug_port , "Statictext "
  605.                      Debug "Statictext "
  606.                   Case S_ound:                              '22
  607.                      S_ound_idx = 4d_arr_rx(3)
  608.                      S_ound_val(1) = 4d_arr_rx(4)
  609.                      S_ound_val(2) = 4d_arr_rx(5)
  610.                     'Print #debug_port , "S_ound "
  611.                      Debug "S_ound "
  612.                   Case T_imer:                              '23
  613.                      T_imer_idx = 4d_arr_rx(3)
  614.                      T_imer_val(1) = 4d_arr_rx(4)
  615.                      T_imer_val(2) = 4d_arr_rx(5)
  616.                      'Print #debug_port , "T_imer "
  617.                      Debug "T_imer "
  618.                   Case Spectrum:                            '24
  619.                      Spectrum_idx = 4d_arr_rx(3)
  620.                      Spectrum_val(1) = 4d_arr_rx(4)
  621.                      Spectrum_val(2) = 4d_arr_rx(5)
  622.                      'Print #debug_port , "Spectrum "
  623.                      Debug "Spectrum "
  624.                   Case Scope:                               '25
  625.                      Scope_idx = 4d_arr_rx(3)
  626.                      Scope_val(1) = 4d_arr_rx(4)
  627.                      Scope_val(2) = 4d_arr_rx(5)
  628.                      'Print #debug_port , "Scope "
  629.                      Debug "Scope "
  630.                   Case Tank:                                '26
  631.                      Tank_idx = 4d_arr_rx(3)
  632.                      Tank_val(1) = 4d_arr_rx(4)
  633.                      Tank_val(2) = 4d_arr_rx(5)
  634.                      'Print #debug_port , "Tank "
  635.                      Debug "Tank "
  636.                   Case Userimages:                          '27
  637.                      Userimages_idx = 4d_arr_rx(3)
  638.                      Userimages_val(1) = 4d_arr_rx(4)
  639.                      Userimages_val(2) = 4d_arr_rx(5)
  640.                      'Print #debug_port , "Userimages "
  641.                      Debug "Userimages "
  642.                   Case Pinoutput:                           '28
  643.                      Pinoutput_idx = 4d_arr_rx(3)
  644.                   'Pinoutput_val(1) = 4d_arr_rx(4)
  645.                      Pinoutput_val = 4d_arr_rx(5)
  646.                      'Print #debug_port , "Pinoutput "
  647.                      Debug "Pinoutput "
  648.                   Case Pininput:                            '29
  649.                      Pininput_idx = 4d_arr_rx(3)
  650.                   'Pininput_val(1) = 4d_arr_rx(4)
  651.                      Pininput_val = 4d_arr_rx(5)
  652.                      'Print #debug_port , "Pininput "
  653.                      Debug "Pininput "
  654.                   Case 4dbutton:                            '30
  655.                      4dbutton_idx = 4d_arr_rx(3)
  656.                      4dbutton_val(1) = 4d_arr_rx(4)
  657.                      4dbutton_val(2) = 4d_arr_rx(5)
  658.                      'Print #debug_port , "4dbutton "
  659.                      Debug "4dbutton "
  660.                   Case Anibutton:                           '31
  661.                      Anibutton_idx = 4d_arr_rx(3)
  662.                      Anibutton_val(1) = 4d_arr_rx(4)
  663.                      Anibutton_val(2) = 4d_arr_rx(5)
  664.                      'Print #debug_port , "Anibutton "
  665.                      Debug "Anibutton "
  666.                   Case Colorpicker:                         '32
  667.                      Colorpicker_idx = 4d_arr_rx(3)
  668.                      Colorpicker_val(1) = 4d_arr_rx(4)
  669.                      Colorpicker_val(2) = 4d_arr_rx(5)
  670.                      'Print #debug_port , "Colorpicker "
  671.                      Debug "Colorpicker "
  672.                   Case Userbutton:                          '33
  673.                      Userbutton_idx = 4d_arr_rx(3)
  674.                      Userbutton_val(1) = 4d_arr_rx(4)
  675.                      Userbutton_val(2) = 4d_arr_rx(5)
  676.                      'Print #debug_port , "Userbutton "
  677.                      Debug "Userbutton "
  678.                   Case Magicobject:                         '34
  679.                      Magicobject_idx = 4d_arr_rx(3)
  680.                      Magicobject_val(1) = 4d_arr_rx(4)
  681.                      Magicobject_val(2) = 4d_arr_rx(5)
  682.                      'Print #debug_port , "Magicobject "
  683.                      Debug "Magicobject "
  684.                   Case Smartgauge:                          '35
  685.                      Smartgauge_idx = 4d_arr_rx(3)
  686.                      Smartgauge_val(1) = 4d_arr_rx(4)
  687.                      Smartgauge_val(2) = 4d_arr_rx(5)
  688.                      'Print #debug_port , "Smartgauge "
  689.                      Debug "Smartgauge "
  690.                   Case Smartslider:                         '36
  691.                      Smartslider_idx = 4d_arr_rx(3)
  692.                      Smartslider_val(1) = 4d_arr_rx(4)
  693.                      Smartslider_val(2) = 4d_arr_rx(5)
  694.                      'Print #debug_port , "Smartslider "
  695.                      Debug "Smartslider "
  696.                   Case Smartknob:                           '37
  697.                      Smartknob_idx = 4d_arr_rx(3)
  698.                      Smartknob_val(1) = 4d_arr_rx(4)
  699.                      Smartknob_val(2) = 4d_arr_rx(5)
  700.                      'Print #debug_port , "Smartknob "
  701.                      Debug "Smartknob "
  702.                   Case Else:
  703.                      'Print #debug_port , "Event report wrong ID: " ; 4d_arr_rx(3)
  704.                      Debug "Event report wrong ID: " ; 4d_arr_rx(3)
  705.                      Clear Serialin4
  706.                      'Print #debug_port , "S_pace" ; S_pace
  707.                      Debug "S_pace" ; S_pace
  708.                      'Print #debug_port , "frame error"
  709.                      Debug "frame error"
  710.                End Select
  711.             Else
  712.                Printbin #lcd_4d , &H15                      'send NAK to LCD
  713.                'Print #debug_port , "Event CRC error"
  714.                debug "Event CRC error"
  715.             End If
  716.          '**********************************************************************
  717.          Case Nak:
  718.          'Print #debug_port ,
  719.             'Print #debug_port , "NACK"                      '&h15  NAK  command
  720.             debug "NACK"                                    '&h15  NAK  command
  721.             ACK_NACK_flag.1 = 1                             'reset ACK/NACK flag
  722.            'Clear Serialin4
  723.          '**********************************************************************
  724.          Case Else:
  725.             'Print #debug_port , "Error in Code =: " ; 4d_arr_rx(1)
  726.             debug "Error in Code =: " ; 4d_arr_rx(1)
  727.             Clear Serialin4
  728.             'Print #debug_port , "frame error"
  729.             debug "frame error"
  730.       End Select
  731.    Wend
  732. End Sub
  733.  
  734. '*******************************************************************************
  735. '###############################################################################
  736. '*************************SUB for checking the UART ****************************
  737. 'This should be a function not a sub but waiting for the function result is taking way to long.
  738. 'call this sub to get values of the object from the display
  739. Sub 4d_read_obj(byval 4d_object_id As Byte , Byval 4d_object_index As Byte )
  740. '*******************************************************************************
  741. 'Syntax: Call 4d_read_obj_sub(object_id &H0 to &H25, object index &H0 to &HFF  )
  742. 'For more info refer to Visi Genie reference manual page 7 section 3.1.3.1
  743. 'Global variable will be updated.
  744. '*******************************************************************************
  745.    'this should be a function
  746.    4d_arr_tx(1) = Write_obj                                 '&h00 constant
  747.    4d_arr_tx(2) = 4d_object_id                              'object ID as per constants
  748.    4d_arr_tx(3) = 4d_object_index                           'object index
  749.    Xor_crc = 4d_arr_tx(1) Xor 4d_arr_tx(2)                  'calculate the xor check sum
  750.    Xor_crc = Xor_crc Xor 4d_arr_tx(3)
  751.  
  752.    4d_arr_tx(4) = Xor_crc
  753.    Printbin #lcd_4d , 4d_arr_tx(1) ; 4                      'print binary  the final result
  754.    ACK_NACK_flag.0 = 1                                      'any response starting with 05 should clear this flag.
  755.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  756.       Incr 4d_wait_count                                    'just to indicate how long will this take
  757.       Call 4d_uart_rx                                       'check the Uart
  758.       if ACK_NACK_flag.0 = 0 and ACK_NACK_flag.1 = 1 then
  759.          Printbin #lcd_4d , 4d_arr_tx(1) ; 4                'repeat previous transmission
  760.          ACK_NACK_flag.0 = 1                                'any response starting with 05 shoudl clear this flag.
  761.          ACK_NACK_flag.1 = 0
  762.       end if                                                'this flag is clear by NACK command therefore
  763.    Wend
  764.    'Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
  765.    debug "Waiting for the response counter: " ; 4d_wait_count
  766.    4d_wait_count = 0
  767.   'The response from the display should be Report_obj: &h05
  768. End Sub
  769.  
  770. '******************************************************************************
  771. '*******************************************************************************
  772. Dim fifo_head As Byte                                       'index plus data
  773. Dim fifo_tail As Byte                                       'index plus data
  774. fifo_head = 0
  775. fifo_tail = 0
  776.  
  777. Dim Fifo_tmp(6) As Byte
  778. 'Const Fifosize = 16
  779. Dim Fifo_buffer(6 , 16) As Byte                             ' 16 arrays, 6 bytes long
  780. 'Dim Fifo_idx As Byte
  781. 'Dim Copy_val As Byte
  782. 'Copy_val = 1
  783.  
  784. '*******************************************************************************
  785. '*******************************************************************************
  786. '###############################################################################
  787. Sub Push_fifo(ar_pushf() As Byte )
  788. 'Base on ollopa code from MCs forum:
  789. 'https : / / www.mcselec.com / index2.phpPrint option = com_forum&Itemid = 59&page = viewtopic&t = 7941&highlight = fifo
  790. 'Thank you ollopa for sharing the idea !
  791.    Local Copy_val_a As Byte
  792.    Local Oldhead As Byte
  793.    Oldhead = fifo_head                                      '
  794.    Incr fifo_head
  795.    If fifo_head > Fifosize Then fifo_head = 1
  796.  
  797.    If fifo_head = fifo_tail Then
  798.       fifo_head = Oldhead
  799.    Else
  800.       Copy_val_a = Memcopy(ar_pushf(1) , Fifo_buffer(1 , fifo_head ) , 6 , 3)
  801.       Print #debug_port , "push mem position= " ; Hex(varptr(fifo_buffer(1 , fifo_head )))
  802.    End If
  803. End Sub
  804.  
  805. Function Pop_fifo() As Byte
  806. 'Base on ollopa code from MCs forum:
  807. 'https : / / www.mcselec.com / index2.phpPrint option = com_forum&Itemid = 59&page = viewtopic&t = 7941&highlight = fifo
  808. 'Thank you ollopa for sharing the idea !
  809.    Local Copy_val_b As Byte
  810.    Incr Tail
  811.    Copy_val_b = Memcopy(fifo_buffer(1 , fifo_tail ) , Fifo_tmp(1) , 6 , 3)
  812.    Print #debug_port , "pop mem position= " ; Hex(varptr(fifo_buffer(1 , fifo_tail )))
  813.    Pop_fifo(1) = Fifo_tmp(1)
  814. End Function
  815. '*******************************************************************************
  816. '###############################################################################
  817. Sub 4d_write_obj(byval 4d_object_id As Byte , Byval 4d_object_index As Byte , Byval 4d_obj_value As Word )
  818.  
  819. 'Dim 4d_helpa As Word At 4d_arr_tx(4) Overlay  'copy for clarity
  820. '*******************************************************************************
  821. 'Syntax: Call 4d_write_obj(object_id &H0 to &H25, object index &H0 to &HFF  , object value &h00 to &HFFFF )
  822. 'For more info refer to Visi Genie reference manual page 8 section 3.1.3.2
  823. '*******************************************************************************
  824.    Swap 4d_obj_value                                        'little endian to big endian
  825.    4d_helpa = 4d_obj_value                                  'assign to overlaid variable
  826.    4d_arr_tx(1) = Write_obj                                 '&h01 constant
  827.    4d_arr_tx(2) = 4d_object_id                              'object ID as per constants
  828.    4d_arr_tx(3) = 4d_object_index                           'object index
  829.    '4d_arr_tx(4) for clarity as this is overlay so the values are already there in global array
  830.    '4d_arr_tx(5) for clarity as this is overlay so the values are already there in global array
  831.    Xor_crc = 4d_arr_tx(1) Xor 4d_arr_tx(2)                  'calculate the xor check sum
  832.    Xor_crc = Xor_crc Xor 4d_arr_tx(3)
  833.    Xor_crc = Xor_crc Xor 4d_arr_tx(4)
  834.    4d_arr_tx(6) = Xor_crc Xor 4d_arr_tx(5)
  835.    Printbin #lcd_4d , 4d_arr_tx(1) ; 6                      'print binary  the final result
  836.    'Printbin #debug_port , 4d_arr_tx(1) ; 6                  'print binary  the final result to debug port
  837.    ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
  838.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  839.       Incr 4d_wait_count                                    'just to indicate how long will this take
  840.       Call 4d_uart_rx                                       'check the Uart
  841.       if ACK_NACK_flag.1 = 1 then                           'NAK received from the display
  842.          Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' repeat previous transmission
  843.          ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  844.       end if
  845.    Wend
  846.          'Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
  847.    Debug "Waiting for the response counter: " ; 4d_wait_count
  848.    4d_wait_count = 0
  849. End Sub
  850. '*******************************************************************************
  851. '###############################################################################
  852. Sub 4d_write_contrast(byval 4d_contrast_val As Byte)
  853. '*******************************************************************************
  854. 'Syntax: Call 4d_write_contrast(contrast value form 1 to 10  )
  855. 'For more info refer to Visi Genie reference manual page 9 section 3.1.3.5
  856. '*******************************************************************************
  857.    If 4d_contrast_val => 10 Then
  858.       4d_contrast_val = 10
  859.    End If
  860.    Dim 4d_contrast_tx(3) As Byte
  861.    4d_contrast_tx(1) = Write_contrast
  862.    4d_contrast_tx(2) = 4d_contrast_val
  863.    4d_contrast_tx(3) = Write_contrast Xor 4d_contrast_val
  864.    Printbin #lcd_4d , 4d_contrast_tx(1) ; 3
  865.    ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
  866.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  867.       Incr 4d_wait_count                                    'just to indicate how long will this take
  868.       Call 4d_uart_rx                                       'check the Uart
  869.       if ACK_NACK_flag.1 = 1 then                           'NAK received from the display
  870.          Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' repeat previous transmission
  871.          ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  872.       end if
  873.    Wend
  874.   'Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
  875.    Debug "Waiting for the response counter: " ; 4d_wait_count
  876.    4d_wait_count = 0
  877. End Sub
  878.  
  879.  
  880. Sub 4d_write_str_old(byval 4d_str_indx As Byte , Byval 4d_string_tmp As String )
  881. '*******************************************************************************
  882. 'Syntax: Call 4d_write_str_old(index hex value , "your text" )
  883. 'The body of the command is:
  884. 'comand_code+ string_index+ string_length + string + xorcrc
  885. 'For more info refer to Visi Genie reference manual page 8 section 3.1.3.3
  886. '*******************************************************************************
  887.    Local Index_help_a As Byte                               'used to calculate the length of the string
  888.    Dim Tot_command_len As Byte                              'total command length
  889.  
  890.    Tot_command_len = Len(4d_string_tmp) + 4                 'total = string + string length byte + command byte + string index byte used for calculating crc
  891.    Print #debug_port , "total command length =" ; Tot_command_len
  892.    4d_string_tx = 4d_string_tmp                             'copy the string in to variable overlaid at array
  893.    4d_string_tx_arr(1) = Write_str                          '&h02 write string command
  894.    4d_string_tx_arr(2) = 4d_str_indx                        'index of the string
  895.    4d_string_tx_arr(3) = Len(4d_string_tmp)                 'length of the original string
  896.  
  897.    For Index_help_a = 1 To Tot_command_len -1               'we need to xor this and assign at the end
  898.    'the minus (-)1 skip xor of the null termination
  899.       4d_string_tx_arr(tot_command_len) = 4d_string_tx_arr(tot_command_len) Xor 4d_string_tx_arr(index_help_a)
  900.    Next Index_help_a
  901.    Index_help_a = 0
  902.    Select Case Tot_command_len                              ' total command length
  903.       Case 5:
  904.          Printbin #debug_port , 4d_string_tx_arr(1) ; 5     'code +string index+ string length +  1 char + crc
  905.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 5         'code +string index+ string length +  1 char + crc
  906.       Case 6:
  907.          Printbin #debug_port , 4d_string_tx_arr(1) ; 6     'code +string index+ string length +  2 char + crc
  908.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 6         'code +string index+ string length +  2 char + crc
  909.       Case 7:
  910.          Printbin #debug_port , 4d_string_tx_arr(1) ; 7     'code +string index+ string length +  3 char + crc
  911.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 7         'code +string index+ string length +  3 char + crc
  912.       Case 8:
  913.          Printbin #debug_port , 4d_string_tx_arr(1) ; 8     'code +string index+ string length +  4 char + crc
  914.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 8         'code +string index+ string length +  4 char + crc
  915.       Case 9:
  916.          Printbin #debug_port , 4d_string_tx_arr(1) ; 9     'code +string index+ string length +  5 char + crc
  917.          Printbin #lcd_4d , 4d_string_tx_arr(1) , 9         'code +string index+ string length +  5 char + crc
  918.       Case 10:
  919.          Printbin #debug_port , 4d_string_tx_arr(1) ; 10    'code +string index+ string length +  6 char + crc
  920.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 10        'code +string index+ string length +  6 char + crc
  921.       Case 11:
  922.          Printbin #debug_port , 4d_string_tx_arr(1) ; 11    'code +string index+ string length +  7 char + crc
  923.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 11        'code +string index+ string length +  7 char + crc
  924.       Case 12:
  925.          Printbin #debug_port , 4d_string_tx_arr(1) ; 12    'code +string index+ string length +  8 char + crc
  926.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 12        'code +string index+ string length +  8 char + crc
  927.       Case 13:
  928.          Printbin #debug_port , 4d_string_tx_arr(1) ; 13    'code +string index+ string length +  9 char + crc
  929.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 13        'code +string index+ string length +  9 char + crc
  930.       Case 14:
  931.          Printbin #debug_port , 4d_string_tx_arr(1) ; 14    'code +string index+ string length +  10 char + crc
  932.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 14        'code +string index+ string length +  10 char + crc
  933.       Case 15:
  934.          Printbin #debug_port , 4d_string_tx_arr(1) ; 15    'code +string index+ string length +  11 char + crc
  935.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 15        'code +string index+ string length +  11 char + crc
  936.       Case 16:
  937.          Printbin #debug_port , 4d_string_tx_arr(1) ; 16    'code +string index+ string length +  12 char + crc
  938.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 16        'code +string index+ string length +  12 char + crc
  939.       Case 17:
  940.          Printbin #debug_port , 4d_string_tx_arr(1) ; 17    'code +string index+ string length +  13 char + crc
  941.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 17        'code +string index+ string length +  13 char + crc
  942.       Case 18:
  943.          Printbin #debug_port , 4d_string_tx_arr(1) ; 18    'code +string index+ string length +  14 char + crc
  944.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 18        'code +string index+ string length +  14 char + crc
  945.       Case 19:
  946.          Printbin #debug_port , 4d_string_tx_arr(1) ; 19    'code +string index+ string length +  15 char + crc
  947.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 19        'code +string index+ string length +  15 char + crc
  948.       Case 20:
  949.          Printbin #debug_port , 4d_string_tx_arr(1) ; 20    'code +string index+ string length +  16 char + crc
  950.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 20        'code +string index+ string length +  16 char + crc
  951.       Case 21:
  952.          Printbin #debug_port , 4d_string_tx_arr(1) ; 21    'code +string index+ string length +  17 char + crc
  953.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 21        'code +string index+ string length +  17 char + crc
  954.       Case 22:
  955.          Printbin #debug_port , 4d_string_tx_arr(1) ; 22    'code +string index+ string length +  18 char + crc
  956.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 22        'code +string index+ string length +  18 char + crc
  957.       Case 23:
  958.          Printbin #debug_port , 4d_string_tx_arr(1) ; 23    'code +string index+ string length +  19 char + crc
  959.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 23        'code +string index+ string length +  19 char + crc
  960.       Case 24:
  961.          Printbin #debug_port , 4d_string_tx_arr(1) ; 24    'code +string index+ string length +  20 char + crc
  962.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 24        'code +string index+ string length +  20 char + crc
  963.       Case 25:
  964.          Printbin #debug_port , 4d_string_tx_arr(1) ; 25    'code +string index+ string length +  21 char + crc
  965.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 25        'code +string index+ string length +  21 char + crc
  966.       Case 26:
  967.          Printbin #debug_port , 4d_string_tx_arr(1) ; 26    'code +string index+ string length +  22 char + crc
  968.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 26        'code +string index+ string length +  22 char + crc
  969.       Case 27:
  970.          Printbin #debug_port , 4d_string_tx_arr(1) ; 27    'code +string index+ string length +  23 char + crc
  971.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 27        'code +string index+ string length +  23 char + crc
  972.       Case 28:
  973.          Printbin #debug_port , 4d_string_tx_arr(1) ; 28    'code +string index+ string length +  24 char + crc
  974.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 28        'code +string index+ string length +  24 char + crc
  975.       Case 29:
  976.          Printbin #debug_port , 4d_string_tx_arr(1) ; 29    'code +string index+ string length +  25 char + crc
  977.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 29        'code +string index+ string length +  25 char + crc
  978.       Case 30:
  979.          Printbin #debug_port , 4d_string_tx_arr(1) ; 30    'code +string index+ string length +  26 char + crc
  980.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 30        'code +string index+ string length +  26 char + crc
  981.       Case 31:
  982.          Printbin #debug_port , 4d_string_tx_arr(1) ; 31    'code +string index+ string length +  27 char + crc
  983.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 31        'code +string index+ string length +  27 char + crc
  984.       Case 32:
  985.          Printbin #debug_port , 4d_string_tx_arr(1) ; 32    'code +string index+ string length +  28 char + crc
  986.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 32        'code +string index+ string length +  28 char + crc
  987.       Case 33:
  988.          Printbin #debug_port , 4d_string_tx_arr(1) ; 33    'code +string index+ string length +  29 char + crc
  989.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 33        'code +string index+ string length +  29 char + crc
  990.       Case 34:
  991.          Printbin #debug_port , 4d_string_tx_arr(1) ; 34    'code +string index+ string length +  30 char + crc
  992.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 34        'code +string index+ string length +  30 char + crc
  993.       Case 35:
  994.          Printbin #debug_port , 4d_string_tx_arr(1) ; 35    'code +string index+ string length +  31 char + crc
  995.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 35        'code +string index+ string length +  31 char + crc
  996.       Case 36:
  997.          Printbin #debug_port , 4d_string_tx_arr(1) ; 36    'code +string index+ string length +  32 char + crc
  998.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 36        'code +string index+ string length +  32 char + crc
  999.    End Select
  1000.    ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
  1001.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  1002.       Incr 4d_wait_count                                    'just to idicate how long will this take
  1003.       Call 4d_uart_rx                                       'check the Uart
  1004.       if ACK_NACK_flag.1 = 1 then                           'NAK received form the display
  1005.          Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' reapet previous transmision
  1006.          ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  1007.       end if
  1008.    Wend
  1009.   'Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
  1010.    Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
  1011.    4d_wait_count = 0
  1012.  
  1013. End Sub
  1014.  
  1015.  
  1016. Sub 4d_write_str(byval 4d_str_indx As Byte , Byval 4d_string_tmp As String )
  1017. '*******************************************************************************
  1018. 'Syntax: Call 4d_write_str(index hex value , "your text" )
  1019. 'The body of the command is:
  1020. 'comand_code + string_index+ string_length + string + xorcrc
  1021. 'For more info refer to Visi Genie reference manual page 8 section 3.1.3.3
  1022. '*******************************************************************************
  1023.    Local Index_help_a As Byte                               'used to calculate the lengt of the string
  1024.    Dim Tot_command_len As Byte                              'total command length
  1025.    Tot_command_len = Len(4d_string_tmp) + 4                 'total = string + string length byte + command byte + string index byte used for calculating crc
  1026.    Print #debug_port , "total command length =" ; Tot_command_len
  1027.    4d_string_tx = 4d_string_tmp                             'copy the string in to variable overlaid at array
  1028.    4d_string_tx_arr(1) = Write_str                          '&h02 write string command
  1029.    4d_string_tx_arr(2) = 4d_str_indx                        'index of the string
  1030.    4d_string_tx_arr(3) = Len(4d_string_tmp)                 'length of the original string
  1031.    For Index_help_a = 1 To Tot_command_len -1               'we need to xor this and assign at the end
  1032.    'the minus (-)1 skip xor of the null termination
  1033.       4d_string_tx_arr(tot_command_len) = 4d_string_tx_arr(tot_command_len) Xor 4d_string_tx_arr(index_help_a)
  1034.    Next Index_help_a
  1035.    Index_help_a = 0
  1036.    Printbin #debug_port , 4d_string_tx_arr(1) , Tot_command_len       'code +string index+ string length +  1 char + crc
  1037.    Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
  1038.    ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
  1039.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  1040.       Incr 4d_wait_count                                    'just to indicate how long will this take
  1041.       Call 4d_uart_rx                                       'check the Uart
  1042.       if ACK_NACK_flag.1 = 1 then                           'NAK received from the display
  1043.          Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' repeat previous transmission
  1044.          ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  1045.       end if
  1046.    Wend
  1047.   'Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
  1048.    Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
  1049.    4d_wait_count = 0
  1050.  
  1051. End Sub
  1052.  
  1053. '*******************************************************************************
  1054. '###############################################################################
Przykładowy projet na Xmega 128A3u spakowany rarem można pobrać z mojego dropboxa:
https://www.dropbox.com/s/1yr5yd0sx3ae8 ... s.rar?dl=0

Plik biblioteki Include spakowany rarem:
4D_system_Visi_Genie_V1.0.rar
-----------------------------------------Duży edyt ----------------------------------
Scaliłem trzy posty razem bo Bartek usunął limit znaków na post.
Usunąłem kilka ząłaczników niesty limit mnie nie puszcza ale zastapiłem linkami.

Teraz dodatkowo coś o bibliotece.
Biblioteka jest napisana w sposób "poprawny politycznie" czyli według zaleceń producenta.
Po każdej wysłanej komendzie czekamy w pętli na odpowiedz od wyświetlacza zwykle jest to komenda ACK hexowe &H6 lub NACK Hexowe &h15
W Xmega 128A3U czas oczekiwania zwykle to około 6000 obiegów pętli.
Sporo ale cóż taki "design".
W wersji drugiej planuje dodanie kolejnego parametru do sub rutyn, coś w stylu czekaj lub nie.
Decyzja będzie należała do programisty co zrobić w czasie oczekiwania na odwiedź.
Niestety będzie to wymagało dobrej organizacji kodu bo w łatwy sposób będzie można zawiesić wyświetlacz.

W bibliotece umiesciłem komendy Debug w łatwy sposób możemy przetestować co się dzieje z naszym kodem.
Informacja o kazdy ważnejszy kroku bedzie wysyła na com0.
Napisanie biblioteki zajęło dość sporo czasu bo aż:
$projecttime = 1239
$version 0 , 0 , 1636 kompilacji kodu :D

Co jeszcze zostało do zrobienia:
Dopisać wysyłanie stringów w Unicode- zwyczajnie nie używam unicode nie chciało mi się.
Dopisać tzw Report_Magic_events_bytes- funkcja dostępna po zakupie licencji PRO, Pozwala na tworzenie własnych wstawek w kodzie 4D odbiera wskazaną ilość tablic typu bajt.
Dopisać tzw Report_Magic_events_Dbytes- funkcja dostępna po zakupie licencji PRO, Pozwala na tworzenie własnych wstawek w kodzie 4D odbiera wskazaną ilość tablic typu word.
Dopisać tzw Write_Magic_bytes- funkcja dostępna po zakupie licencji PRO, Pozwala na tworzenie własnych wstawek w kodzie 4D wysyła wskazaną ilość tablic typu bajt.
Dopisać tzw Write_Magic_Dbytes- funkcja dostępna po zakupie licencji PRO, Pozwala na tworzenie własnych wstawek w kodzie 4D wysyła wskazaną ilość tablic typu word.

Funkcje te nie są potrzebne to standardowej pracy z wykorzystaniem Visi-Genie.
Dopisze gdy nadejdą długie deszczowe Irlandzkie wieczory :)
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Ostatnio zmieniony 16 maja 2019, 20:02 przez Pikczu, łącznie zmieniany 1 raz.
Pikczu
Posty: 389
Rejestracja: 17 sie 2015, 13:46
Lokalizacja: Dublin, Ireland
Kontakt:

Re: [Bascom] 4D Systems Visi Genie

Post autor: Pikczu » 04 maja 2020, 21:10

Nowa wersja 4D_system_Visi_Genie_V1.1
Zmiany są niewilekie, dodałem komendy debug i poprawiłem błędy w komentarzach.
Dodaje też demo dla Atmega2560 (arduino) posiadanie wyświetlacza jest konieczne do testowania kodu.
Link do dropboxa:
https://www.dropbox.com/s/8c4qkid2zral5 ... 1.rar?dl=0
4D_system_Visi_Genie_V1.1.rar
  1. $nocompile
  2. '4D_system_Visi_Genie Library version 1.1
  3. 'By Pikczu 2019.05.14
  4. 'Pawel.labedz@gmail.com
  5. '*******************************************************************************
  6. 'Change log:
  7. ' Initial version 1.0 date: 2019.05.14
  8. ' Version: 1.1 date: 2020.05.04
  9. 'Minor changes:
  10. 'Corrected debug commands and spelling in the comments.
  11. 'Added extra debug commands to: 4d_write_obj
  12. '*******************************************************************************
  13. '-------------------------------------------------------------------------------
  14. ' Name to include: $include "Subs\4D_system_Visi_Genie_V1.1.inc"
  15. '                               ^
  16. '                               ^
  17. 'This is your folder with subs--^
  18. '-------------------------------------------------------------------------------
  19. 'This library is dedicated for 4D systems LCD displays Visi Genie environment.
  20. 'Function Xor_this()
  21. 'Sub 4d_uart_rx()
  22. 'Sub 4d_read_obj_sub(object_id &H0 to &H25 , object index &H0 to &HFF )
  23. 'Sub Push_fifo -not in use
  24. 'Function Pop_fifo()- not in use
  25. 'Sub 4d_write_obj(object_id &H0 to &H25, object index &H0 to &HFF  , object value &h00 to &HFFFF )
  26. 'Sub 4d_write_contrast(contrast value from 1 to 10  )
  27. 'Sub 4d_write_str_old(index hex value , "your text" ) for Bascom version before 2.0.8.2
  28. 'Sub 4d_write_str(index hex value , "your text" )  for Bascom version 2.0.8.2 and above
  29. '*******************************************************************************
  30. ' To do:
  31. 'Add sub for Unicode string
  32. 'Add magic code sub
  33. '###############################################################################
  34. '*************************Add to main code here*******************************
  35. 'If you are using different port then uart 0 for debug, uncomment all debug 'print #debug_port , xxx in the code.
  36. 'And comment all Bascom Debug commands.
  37. 'Then modify the port number below to match your debug port.
  38. 'Const Debug_port =4                                         'Debug port different then 0
  39. '
  40. 'Const Lcd_4d = 2                                            'Uart port used for 4d SYSTEM LCD
  41. '               ^
  42. '               ^
  43. 'Modify the number to suit your uart port.
  44. '*******************************************************************************
  45. '###############################################################################
  46. '*****************************Used in 4D systems TX subs************************
  47. Dim ACK_NACK_flag As Byte                                   ' ACK byte flag is setup each time we expect the ack to come from the display
  48. ACK_NACK_flag = 0
  49. Dim 4d_wait_count as word                                   'Used inside each 4D sub routine to count number of loops while waiting for the response from the lcd.
  50. Dim 4d_arr_tx(6)as Byte                                     'main array used to send the data
  51. Dim 4d_helpa As Word At 4d_arr_tx(4) Overlay                'array for object values  overlay at main array
  52. Dim 4d_string_tx_arr(39) As Byte                            ' Array for string
  53. Dim 4d_string_tx As String * 34 At 4d_string_tx_arr(1) + 3 Overlay       '+3 add room for string length byte + command byte + string index
  54. '********************for future use ********************************************
  55. 'Const 4d_max_len = 32                                       'maximum 4D string length
  56. 'Const Ack_nack_max = 32                                     'max number of ack or NACK in the que
  57. 'Dim Ack_nack_cnt As Byte                                   'for feature use
  58. 'Dim 4d_frame As Byte                                       'for feature use
  59. 'Const 4d_max_frame = 16                                    'maximum number of messages
  60. 'Dim Backup_tx As Byte                                      'for feature use
  61. '*******************************************************************************
  62. '*****************************Used in 4D systems RX subs************************
  63. Dim 4d_arr_rx(6) As Byte                                    'used for received data
  64. 'Dim 4d_var_rx As Word At 4d_arr_rx(4) Overlay               'overlay for rx
  65. 'Dim 4d_var_rx_tmp As Word
  66. 'Dim Obj_index As Byte                                       '4d object index
  67. '*******************************************************************************
  68. '***************************Variables used in XOR CRC **************************
  69. Dim Xor_crc As Byte                                         'xor crc for 4d
  70. Xor_crc = 0
  71. '*******************************************************************************
  72. '*****************************Variables for objects indexes ********************
  73. Dim Dipswitch_idx As Byte                                   '0
  74. Dim Knob_idx As Byte
  75. Dim Rockerswitch_idx As Byte
  76. Dim Rotaryswitch_idx As Byte
  77. Dim Slider_idx As Byte
  78. Dim Trackbar_idx As Byte
  79. Dim Winbutton_idx As Byte
  80. Dim Angularmeter_idx As Byte
  81. Dim Coolgauge_idx As Byte
  82. Dim Customdigits_idx As Byte
  83. Dim Form_idx As Byte                                        'Used to Set The Current Form
  84. Dim Gauge_idx As Byte                                       '
  85. 'Dim Image_idx As Byte                                       ' Displayed As Part Of Form, No Method To Alter
  86. Dim Keyboard_idx As Byte                                    ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  87. Dim Led_idx As Byte
  88. Dim Leddigits_idx As Byte
  89. Dim Meter_idx As Byte
  90. Dim Strings_idx As Byte
  91. Dim Thermometer_idx As Byte
  92. Dim Userled_idx As Byte
  93. Dim Video_idx As Byte
  94. 'Dim Statictext_idx As Byte                                  ' Displayed As Part Of Form, No Method To Alter
  95. Dim S_ound_idx As Byte
  96. Dim T_imer_idx As Byte
  97. Dim Spectrum_idx As Byte
  98. Dim Scope_idx As Byte
  99. Dim Tank_idx As Byte
  100. Dim Userimages_idx As Byte
  101. Dim Pinoutput_idx As Byte
  102. Dim Pininput_idx As Byte
  103. Dim 4dbutton_idx As Byte
  104. Dim Anibutton_idx As Byte
  105. Dim Colorpicker_idx As Byte
  106. Dim Userbutton_idx As Byte
  107. Dim Magicobject_idx As Byte                                 'ONLY Available When Using Genie Pro
  108. Dim Smartgauge_idx As Byte                                  'ONLY Available When Using Genie Pro
  109. Dim Smartslider_idx As Byte                                 'ONLY Available When Using Genie Pro
  110. Dim Smartknob_idx As Byte                                   'Only Available When Using Genie Pro
  111. '*******************************************************************************
  112. '**********************Arrays for objects values *******************************
  113. Dim Dipswitch_val(2) As Byte                                '0
  114. Dim Knob_val(2) As Byte
  115. Dim Rockerswitch_val(2) As Byte
  116. Dim Rotaryswitch_val(2) As Byte
  117. Dim Slider_val(2) As Byte
  118. Dim Trackbar_val(2) As Byte
  119. Dim Winbutton_val(2) As Byte
  120. Dim Angularmeter_val(2) As Byte
  121. Dim Coolgauge_val(2) As Byte
  122. Dim Customdigits_val(2) As Byte
  123. Dim Form_val(2) As Byte                                     'Used To Set The Current Form
  124. Dim Gauge_val(2) As Byte                                    '
  125. 'Dim Image_val(2) As Byte                                    ' Displayed As Part Of Form , No Method To Alter
  126. Dim Keyboard_val(2) As Byte                                 ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  127. Dim Led_val(2) As Byte
  128. Dim Leddigits_val(2) As Byte
  129. Dim Meter_val(2) As Byte
  130. Dim Strings_val(2) As Byte
  131. Dim Thermometer_val(2) As Byte
  132. Dim Userled_val(2) As Byte
  133. Dim Video_val(2) As Byte
  134. 'Dim Statictext_val(2) As Byte                               ' Displayed As Part Of Form , No Method To Alter
  135. Dim S_ound_val(2) As Byte
  136. Dim T_imer_val(2) As Byte
  137. Dim Spectrum_val(2) As Byte
  138. Dim Scope_val(2) As Byte
  139. Dim Tank_val(2) As Byte
  140. Dim Userimages_val(2) As Byte
  141. Dim Pinoutput_val As Byte
  142. Dim Pininput_val As Byte
  143. Dim 4dbutton_val(2) As Byte
  144. Dim Anibutton_val(2) As Byte
  145. Dim Colorpicker_val(2) As Byte
  146. Dim Userbutton_val(2) As Byte
  147. Dim Magicobject_val(2) As Byte                              'ONLY Available When Using Genie Pro
  148. Dim Smartgauge_val(2) As Byte                               'ONLY Available When Using Genie Pro
  149. Dim Smartslider_val(2) As Byte                              'ONLY Available When Using Genie Pro
  150. Dim Smartknob_val(2) As Byte                                'Only Available When Using Genie Pro
  151. '*******************************************************************************
  152. '*********************Constants used in select case for RX **********************
  153. Const A_ck = &H06
  154. Const Nak = &H15
  155. '*******************************************************************************
  156. Const Dipswitch = &H00                                      '0
  157. Const Knob = &H01
  158. Const Rockerswitch = &H02
  159. Const Rotaryswitch = &H03
  160. Const Slider = &H04
  161. Const Trackbar = &H05
  162. Const Winbutton = &H06
  163. Const Angularmeter = &H07
  164. Const Coolgauge = &H08
  165. Const Customdigits = &H09
  166. Const Form = &H0A                                           'Used To Set The Current Form
  167. Const Gauge = &H0B                                          '
  168. Const Image = &H0C                                          ' Displayed As Part Of Form, No Method To Alter
  169. Const Keyboard = &H0D                                       ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  170. Const Led = &H0E
  171. Const Leddigits = &H0F
  172. Const Meter = &H10
  173. Const Strings = &H11
  174. Const Thermometer = &H12
  175. Const Userled = &H13
  176. Const Video = &H14
  177. Const Statictext = &H15                                     ' Displayed As Part Of Form, No Method To Alter
  178. Const S_ound = &H16
  179. Const T_imer = &H17
  180. Const Spectrum = &H18
  181. Const Scope = &H19
  182. Const Tank = &H1A
  183. Const Userimages = &H1B
  184. Const Pinoutput = &H1C
  185. Const Pininput = &H1D
  186. Const 4dbutton = &H1E
  187. Const Anibutton = &H1F
  188. Const Colorpicker = &H20
  189. Const Userbutton = &H21
  190. Const Magicobject = &H22                                    'ONLY Available When Using Genie Pro
  191. Const Smartgauge = &H23                                     'ONLY Available When Using Genie Pro
  192. Const Smartslider = &H24                                    'ONLY Available When Using Genie Pro
  193. Const Smartknob = &H25                                      'Only Available When Using Genie Pro
  194. '*******************************************************************************
  195. Const Read_obj = &H00                                       'TX command to get value
  196. Const Write_obj = &H01                                      'TX command to write object value
  197. Const Write_str = &H02                                      'TX command to send string
  198. Const Write_stru = &H03                                     'TX command to send string Unicode
  199. Const Write_contrast = &H04                                 'TX command to set contrast
  200. Const Report_obj = &H05                                     'RX- response to read obj command
  201. Const Report_event = &H07                                   'RX response to event no request needed
  202. Const Write_magic_bytes = &H08                              'TX command for magic bytes PRO licence required
  203. Const Write_magic_dbytes = &H09                             'TX command for magic bytes PRO licence required
  204. Const Report_magic_event_bytes = &H0A                       'RX response to magic bytes PRO licence required
  205. '*******************************************************************************
  206. '*******************************************************************************
  207. '**************************XOR function to calculate CRC************************
  208. Function Xor_this(ar()as Byte ) As Byte                     '  Function XOR
  209.    Local Xor_ing As Byte                                    'temporary variable for xor value so could be a local
  210.    Xor_ing = Ar(1) Xor Ar(2)                                'xoring
  211.    Xor_ing = Xor_ing Xor Ar(3)
  212.    Xor_ing = Xor_ing Xor Ar(4)
  213.    Xor_ing = Xor_ing Xor Ar(5)
  214.    Xor_this = Xor_ing                                       'final result assignment
  215. End Function
  216. '*******************************************************************************
  217. '*************************SUB for checking the UART ****************************
  218. Sub 4d_uart_rx()
  219. '*******************************************************************************
  220. 'Call this sub routine from main loop to check for events.
  221. 'Syntax : Call 4d_uart_rx()
  222. 'In addition this sub is called from: 4d_read_obj_sub, 4d_write_obj, 4d_write_contrast and 4d_write_str
  223. 'For more info refer to Visi Genie reference manual page 10 section 3.1.3.6 &7
  224. 'Global variable will be updated.
  225. '*******************************************************************************
  226.    While Ischarwaiting(#lcd_4d) <> 0                        'While characters are waiting in the buffer
  227.       Inputbin #lcd_4d , 4d_arr_rx(1) , 1                   'input them in to the array
  228.       debug "received= " ; 4d_arr_rx(1)
  229.       'print #debug_port , "received= " ; 4d_arr_rx(1)
  230.       Select Case 4d_arr_rx(1)                              'command
  231.          '**********************************************************************
  232.          Case Report_obj:                                   '&H05 report object command
  233.             Inputbin #lcd_4d , 4d_arr_rx(2) , 5             'get next 5 bytes from the buffer
  234.             Xor_crc = Xor_this(4d_arr_rx(1))                ' check the crc
  235.             If 4d_arr_rx(6) = Xor_crc Then                  'if crc ok then check what came
  236.                'CRC ok then we can clear the flag
  237.                ACK_NACK_flag = 0                            'reset ACK flag
  238.                Select Case 4d_arr_rx(2)                     'object ID
  239.                   Case Dipswitch:                           '0
  240.                      Dipswitch_idx = 4d_arr_rx(3)
  241.                      Dipswitch_val(1) = 4d_arr_rx(4)
  242.                      Dipswitch_val(2) = 4d_arr_rx(5)
  243.                      'Print #debug_port , "Dipswitch "
  244.                      Debug "Dipswitch "
  245.                   Case Knob:                                '1
  246.                      Knob_idx = 4d_arr_rx(3)
  247.                      Knob_val(1) = 4d_arr_rx(4)
  248.                      Knob_val(2) = 4d_arr_rx(5)
  249.                      'Print #debug_port , "Knob "
  250.                      Debug "Knob "
  251.                   Case Rockerswitch:                        '2
  252.                      Rockerswitch_idx = 4d_arr_rx(3)
  253.                      Rockerswitch_val(1) = 4d_arr_rx(4)
  254.                      Rockerswitch_val(2) = 4d_arr_rx(5)
  255.                      'Print #debug_port , "Rockerswitch "
  256.                      Debug "Rockerswitch "
  257.                   Case Rotaryswitch:                        '3
  258.                      Rotaryswitch_idx = 4d_arr_rx(3)
  259.                      Rotaryswitch_val(1) = 4d_arr_rx(4)
  260.                      Rotaryswitch_val(2) = 4d_arr_rx(5)
  261.                      'Print #debug_port , "Rotaryswitch "
  262.                      Debug "Rotaryswitch "
  263.                   Case Slider:                              '4
  264.                      Slider_idx = 4d_arr_rx(3)
  265.                      Slider_val(1) = 4d_arr_rx(4)
  266.                      Slider_val(2) = 4d_arr_rx(5)
  267.                      'Print #debug_port , "Slider "
  268.                      Debug "Slider "
  269.                   Case Trackbar:                            '5
  270.                      Trackbar_idx = 4d_arr_rx(3)
  271.                      Trackbar_val(1) = 4d_arr_rx(4)
  272.                      Trackbar_val(2) = 4d_arr_rx(5)
  273.                      'Print #debug_port , "Trackbar "
  274.                      Debug "Trackbar "
  275.                   Case Winbutton:                           '6
  276.                      Winbutton_idx = 4d_arr_rx(3)
  277.                      Winbutton_val(1) = 4d_arr_rx(4)
  278.                      Winbutton_val(2) = 4d_arr_rx(5)
  279.                      'Print #debug_port , "Winbutton "
  280.                      Debug "Winbutton "
  281.                   Case Angularmeter:                        '7
  282.                      Angularmeter_idx = 4d_arr_rx(3)
  283.                      Angularmeter_val(1) = 4d_arr_rx(4)
  284.                      Angularmeter_val(2) = 4d_arr_rx(5)
  285.                      'Print #debug_port , "Angularmeter "
  286.                      Debug "Angularmeter "
  287.                   Case Coolgauge:                           '8
  288.                      Coolgauge_idx = 4d_arr_rx(3)
  289.                      Coolgauge_val(1) = 4d_arr_rx(4)
  290.                      Coolgauge_val(2) = 4d_arr_rx(5)
  291.                      'Print #debug_port , "Coolgauge "
  292.                      Debug "Coolgauge "
  293.                   Case Customdigits:                        '9
  294.                      Customdigits_idx = 4d_arr_rx(3)
  295.                      Customdigits_val(1) = 4d_arr_rx(4)
  296.                      Customdigits_val(2) = 4d_arr_rx(5)
  297.                      'Print #debug_port , "Customdigits "
  298.                      Debug "Customdigits "
  299.                   Case Form:                                '10
  300.                      Form_idx = 4d_arr_rx(3)
  301.                      Form_val(1) = 4d_arr_rx(4)
  302.                      Form_val(2) = 4d_arr_rx(5)
  303.                      'Print #debug_port , "Form "
  304.                      Debug "Form "
  305.                   Case Gauge:                               '11
  306.                      Gauge_idx = 4d_arr_rx(3)
  307.                      Gauge_val(1) = 4d_arr_rx(4)
  308.                      Gauge_val(2) = 4d_arr_rx(5)
  309.                      'Print #debug_port , "Gauge "
  310.                      Debug "Gauge "
  311.                   Case Image:                               '12
  312.                   'Image_idx = 4d_arr_rx(3)
  313.                   'Image_val(1) = 4d_arr_rx(4)
  314.                   'Image_val(2) = 4d_arr_rx(5)
  315.                      'Print #debug_port , "Image "
  316.                      Debug "Image "
  317.                   Case Keyboard:                            '13
  318.                      Keyboard_idx = 4d_arr_rx(3)
  319.                      Keyboard_val(1) = 4d_arr_rx(4)
  320.                      Keyboard_val(2) = 4d_arr_rx(5)
  321.                      'Print #debug_port , "Keyboard "
  322.                      Debug "Keyboard "
  323.                   Case Led:                                 '14
  324.                      Led_idx = 4d_arr_rx(3)
  325.                      Led_val(1) = 4d_arr_rx(4)
  326.                      Led_val(2) = 4d_arr_rx(5)
  327.                      'Print #debug_port , "Led "
  328.                      Debug "Led "
  329.                   Case Leddigits:                           '15
  330.                      Leddigits_idx = 4d_arr_rx(3)
  331.                      Leddigits_val(1) = 4d_arr_rx(4)
  332.                      Leddigits_val(2) = 4d_arr_rx(5)
  333.                      'Print #debug_port , "Leddigits "
  334.                      Debug "Leddigits "
  335.                   Case Meter:                               '16
  336.                      Meter_idx = 4d_arr_rx(3)
  337.                      Meter_val(1) = 4d_arr_rx(4)
  338.                      Meter_val(2) = 4d_arr_rx(5)
  339.                      'Print #debug_port , "Meter "
  340.                      Debug "Meter "
  341.                   Case Strings:                             '17
  342.                      Strings_idx = 4d_arr_rx(3)
  343.                      Strings_val(1) = 4d_arr_rx(4)
  344.                      Strings_val(2) = 4d_arr_rx(5)
  345.                      'Print #debug_port , "Strings "
  346.                      Debug "Strings "
  347.                   Case Thermometer:                         '18
  348.                      Thermometer_idx = 4d_arr_rx(3)
  349.                      Thermometer_val(1) = 4d_arr_rx(4)
  350.                      Thermometer_val(2) = 4d_arr_rx(5)
  351.                      'Print #debug_port , "Thermometer "
  352.                      Debug "Thermometer "
  353.                   Case Userled:                             '19
  354.                      Userled_idx = 4d_arr_rx(3)
  355.                      Userled_val(1) = 4d_arr_rx(4)
  356.                      Userled_val(2) = 4d_arr_rx(5)
  357.                      'Print #debug_port , "Userled "
  358.                      Debug "Userled "
  359.                   Case Video:                               '20
  360.                      Video_idx = 4d_arr_rx(3)
  361.                      Video_val(1) = 4d_arr_rx(4)
  362.                      Video_val(2) = 4d_arr_rx(5)
  363.                       'Print #debug_port ,  "Video "
  364.                      Debug "Video "
  365.                   Case Statictext:                          '21
  366.                   'Statictext_idx = 4d_arr_rx(3)
  367.                   'Statictext_val(1) = 4d_arr_rx(4)
  368.                   'Statictext_val(2) = 4d_arr_rx(5)
  369.                    'Print #debug_port , "Statictext "
  370.                      Debug "Statictext "
  371.                   Case S_ound:                              '22
  372.                      S_ound_idx = 4d_arr_rx(3)
  373.                      S_ound_val(1) = 4d_arr_rx(4)
  374.                      S_ound_val(2) = 4d_arr_rx(5)
  375.                     'Print #debug_port , "S_ound "
  376.                      Debug "S_ound "
  377.                   Case T_imer:                              '23
  378.                      T_imer_idx = 4d_arr_rx(3)
  379.                      T_imer_val(1) = 4d_arr_rx(4)
  380.                      T_imer_val(2) = 4d_arr_rx(5)
  381.                      'Print #debug_port , "T_imer "
  382.                      Debug "T_imer "
  383.                   Case Spectrum:                            '24
  384.                      Spectrum_idx = 4d_arr_rx(3)
  385.                      Spectrum_val(1) = 4d_arr_rx(4)
  386.                      Spectrum_val(2) = 4d_arr_rx(5)
  387.                      'Print #debug_port , "Spectrum "
  388.                      Debug "Spectrum "
  389.                   Case Scope:                               '25
  390.                      Scope_idx = 4d_arr_rx(3)
  391.                      Scope_val(1) = 4d_arr_rx(4)
  392.                      Scope_val(2) = 4d_arr_rx(5)
  393.                      'Print #debug_port , "Scope "
  394.                      Debug "Scope "
  395.                   Case Tank:                                '26
  396.                      Tank_idx = 4d_arr_rx(3)
  397.                      Tank_val(1) = 4d_arr_rx(4)
  398.                      Tank_val(2) = 4d_arr_rx(5)
  399.                      'Print #debug_port , "Tank "
  400.                      Debug "Tank "
  401.                   Case Userimages:                          '27
  402.                      Userimages_idx = 4d_arr_rx(3)
  403.                      Userimages_val(1) = 4d_arr_rx(4)
  404.                      Userimages_val(2) = 4d_arr_rx(5)
  405.                      'Print #debug_port , "Userimages "
  406.                      Debug "Userimages "
  407.                   Case Pinoutput:                           '28
  408.                      Pinoutput_idx = 4d_arr_rx(3)
  409.                   'Pinoutput_val(1) = 4d_arr_rx(4)
  410.                      Pinoutput_val = 4d_arr_rx(5)
  411.                      'Print #debug_port , "Pinoutput "
  412.                      Debug "Pinoutput "
  413.                   Case Pininput:                            '29
  414.                      Pininput_idx = 4d_arr_rx(3)
  415.                   'Pininput_val(1) = 4d_arr_rx(4)
  416.                      Pininput_val = 4d_arr_rx(5)
  417.                      'Print #debug_port , "Pininput "
  418.                      Debug "Pininput "
  419.                   Case 4dbutton:                            '30
  420.                      4dbutton_idx = 4d_arr_rx(3)
  421.                      4dbutton_val(1) = 4d_arr_rx(4)
  422.                      4dbutton_val(2) = 4d_arr_rx(5)
  423.                      'Print #debug_port , "4dbutton "
  424.                      Debug "4dbutton "
  425.                   Case Anibutton:                           '31
  426.                      Anibutton_idx = 4d_arr_rx(3)
  427.                      Anibutton_val(1) = 4d_arr_rx(4)
  428.                      Anibutton_val(2) = 4d_arr_rx(5)
  429.                      'Print #debug_port , "Anibutton "
  430.                      Debug "Anibutton "
  431.                   Case Colorpicker:                         '32
  432.                      Colorpicker_idx = 4d_arr_rx(3)
  433.                      Colorpicker_val(1) = 4d_arr_rx(4)
  434.                      Colorpicker_val(2) = 4d_arr_rx(5)
  435.                      'Print #debug_port , "Colorpicker "
  436.                      Debug "Colorpicker "
  437.                   Case Userbutton:                          '33
  438.                      Userbutton_idx = 4d_arr_rx(3)
  439.                      Userbutton_val(1) = 4d_arr_rx(4)
  440.                      Userbutton_val(2) = 4d_arr_rx(5)
  441.                      'Print #debug_port , "Userbutton "
  442.                      Debug "Userbutton "
  443.                   Case Magicobject:                         '34
  444.                      Magicobject_idx = 4d_arr_rx(3)
  445.                      Magicobject_val(1) = 4d_arr_rx(4)
  446.                      Magicobject_val(2) = 4d_arr_rx(5)
  447.                      'Print #debug_port , "Magicobject "
  448.                      Debug "Magicobject "
  449.                   Case Smartgauge:                          '35
  450.                      Smartgauge_idx = 4d_arr_rx(3)
  451.                      Smartgauge_val(1) = 4d_arr_rx(4)
  452.                      Smartgauge_val(2) = 4d_arr_rx(5)
  453.                      'Print #debug_port , "Smartgauge "
  454.                      Debug "Smartgauge "
  455.                   Case Smartslider:                         '36
  456.                      Smartslider_idx = 4d_arr_rx(3)
  457.                      Smartslider_val(1) = 4d_arr_rx(4)
  458.                      Smartslider_val(2) = 4d_arr_rx(5)
  459.                      'Print #debug_port , "Smartslider "
  460.                      Debug "Smartslider "
  461.                   Case Smartknob:                           '37
  462.                      Smartknob_idx = 4d_arr_rx(3)
  463.                      Smartknob_val(1) = 4d_arr_rx(4)
  464.                      Smartknob_val(2) = 4d_arr_rx(5)
  465.                      'Print #debug_port , "Smartknob "
  466.                      Debug "Smartknob "
  467.                   Case Else:
  468.                   'This should never happen as CRC being check before select case
  469.                   'But lets keep this here just in case.
  470.                      'Print #debug_port , "Event report wrong ID: " ; 4d_arr_rx(3)
  471.                      Debug "Event report wrong ID: " ; 4d_arr_rx(3)
  472.                      'Clear Serialin4
  473.                      'Print #debug_port , "S_pace: " ; S_pace
  474.                      'Print #debug_port , "frame error"
  475.                End Select
  476.             Else
  477.                Printbin #lcd_4d , &H15                      'send NACK message to the display
  478.                'Print #debug_port , "Read object CRC error !"
  479.                Debug "Read object CRC error !"
  480.             End If
  481.          '**********************************************************************
  482.          Case A_ck:                                         '&H06    ACK command
  483.             ACK_NACK_flag = 0                               'reset ack flag
  484.             'Print #debug_port , "ACK"                       'print ACK message to debug port
  485.             Debug "ACK"                                     'print ACK message to debug port
  486.          '**********************************************************************
  487.          Case Report_event:                                 '&H07
  488.             Inputbin #Lcd_4d , 4d_arr_rx(2) , 5             'get next 5 get next 5 bytes from the buffer
  489.             Xor_crc = Xor_this(4d_arr_rx(1))                ' check the crc
  490.             If 4d_arr_rx(6) = Xor_crc Then                  'if crc ok then check what came
  491.                Select Case 4d_arr_rx(2)                     'object ID
  492.                   Case Dipswitch:                           '0
  493.                      Dipswitch_idx = 4d_arr_rx(3)
  494.                      Dipswitch_val(1) = 4d_arr_rx(4)
  495.                      Dipswitch_val(2) = 4d_arr_rx(5)
  496.                      'Print #debug_port , "Dipswitch "
  497.                      Debug "Dipswitch "
  498.                   Case Knob:                                '1
  499.                      Knob_idx = 4d_arr_rx(3)
  500.                      Knob_val(1) = 4d_arr_rx(4)
  501.                      Knob_val(2) = 4d_arr_rx(5)
  502.                      'Print #debug_port , "Knob "
  503.                      Debug "Knob "
  504.                   Case Rockerswitch:                        '2
  505.                      Rockerswitch_idx = 4d_arr_rx(3)
  506.                      Rockerswitch_val(1) = 4d_arr_rx(4)
  507.                      Rockerswitch_val(2) = 4d_arr_rx(5)
  508.                      'Print #debug_port , "Rocker switch "
  509.                      Debug "Rockerswitch "
  510.                   Case Rotaryswitch:                        '3
  511.                      Rotaryswitch_idx = 4d_arr_rx(3)
  512.                      Rotaryswitch_val(1) = 4d_arr_rx(4)
  513.                      Rotaryswitch_val(2) = 4d_arr_rx(5)
  514.                      'Print #debug_port , "Rotary switch "
  515.                      Debug "Rotaryswitch "
  516.                   Case Slider:                              '4
  517.                      Slider_idx = 4d_arr_rx(3)
  518.                      Slider_val(1) = 4d_arr_rx(4)
  519.                      Slider_val(2) = 4d_arr_rx(5)
  520.                      'Print #debug_port , "Slider "
  521.                      Debug "Slider "
  522.                   Case Trackbar:                            '5
  523.                      Trackbar_idx = 4d_arr_rx(3)
  524.                      Trackbar_val(1) = 4d_arr_rx(4)
  525.                      Trackbar_val(2) = 4d_arr_rx(5)
  526.                      'Print #debug_port , "Trackbar "
  527.                      Debug "Trackbar "
  528.                   Case Winbutton:                           '6
  529.                      Winbutton_idx = 4d_arr_rx(3)
  530.                      Winbutton_val(1) = 4d_arr_rx(4)
  531.                      Winbutton_val(2) = 4d_arr_rx(5)
  532.                      'Print #debug_port , "Win button "
  533.                      Debug "Winbutton "
  534.                   Case Angularmeter:                        '7
  535.                      Angularmeter_idx = 4d_arr_rx(3)
  536.                      Angularmeter_val(1) = 4d_arr_rx(4)
  537.                      Angularmeter_val(2) = 4d_arr_rx(5)
  538.                      'Print #debug_port , "Angular meter "
  539.                      Debug "Angularmeter "
  540.                   Case Coolgauge:                           '8
  541.                      Coolgauge_idx = 4d_arr_rx(3)
  542.                      Coolgauge_val(1) = 4d_arr_rx(4)
  543.                      Coolgauge_val(2) = 4d_arr_rx(5)
  544.                      'Print #debug_port , "Coolgauge "
  545.                      Debug "Coolgauge "
  546.                   Case Customdigits:                        '9
  547.                      Customdigits_idx = 4d_arr_rx(3)
  548.                      Customdigits_val(1) = 4d_arr_rx(4)
  549.                      Customdigits_val(2) = 4d_arr_rx(5)
  550.                      'Print #debug_port , "Custom digits "
  551.                      Debug "Customdigits "
  552.                   Case Form:                                '10
  553.                      Form_idx = 4d_arr_rx(3)
  554.                      Form_val(1) = 4d_arr_rx(4)
  555.                      Form_val(2) = 4d_arr_rx(5)
  556.                      'Print #debug_port , "Form "
  557.                      Debug "Form "
  558.                   Case Gauge:                               '11
  559.                      Gauge_idx = 4d_arr_rx(3)
  560.                      Gauge_val(1) = 4d_arr_rx(4)
  561.                      Gauge_val(2) = 4d_arr_rx(5)
  562.                      'Print #debug_port , "Gauge "
  563.                      Debug "Gauge "
  564.                   Case Image:                               '12
  565.                   'Image_idx = 4d_arr_rx(3)
  566.                   'Image_val(1) = 4d_arr_rx(4)
  567.                   'Image_val(2) = 4d_arr_rx(5)
  568.                      'Print #debug_port , "Image "
  569.                      Debug "Image "
  570.                   Case Keyboard:                            '13
  571.                      Keyboard_idx = 4d_arr_rx(3)
  572.                      Keyboard_val(1) = 4d_arr_rx(4)
  573.                      Keyboard_val(2) = 4d_arr_rx(5)
  574.                      'Print #debug_port , "Keyboard "
  575.                      Debug "Keyboard "
  576.                   Case Led:                                 '14
  577.                      Led_idx = 4d_arr_rx(3)
  578.                      Led_val(1) = 4d_arr_rx(4)
  579.                      Led_val(2) = 4d_arr_rx(5)
  580.                      'Print #debug_port , "Led "
  581.                      Debug "Led "
  582.                   Case Leddigits:                           '15
  583.                      Leddigits_idx = 4d_arr_rx(3)
  584.                      Leddigits_val(1) = 4d_arr_rx(4)
  585.                      Leddigits_val(2) = 4d_arr_rx(5)
  586.                      'Print #debug_port , "Led digits "
  587.                      Debug "Led digits "
  588.                   Case Meter:                               '16
  589.                      Meter_idx = 4d_arr_rx(3)
  590.                      Meter_val(1) = 4d_arr_rx(4)
  591.                      Meter_val(2) = 4d_arr_rx(5)
  592.                      'Print #debug_port , "Meter "
  593.                      Debug "Meter "
  594.                   Case Strings:                             '17
  595.                      Strings_idx = 4d_arr_rx(3)
  596.                      Strings_val(1) = 4d_arr_rx(4)
  597.                      Strings_val(2) = 4d_arr_rx(5)
  598.                      'Print #debug_port , "Strings "
  599.                      Debug "Strings "
  600.                   Case Thermometer:                         '18
  601.                      Thermometer_idx = 4d_arr_rx(3)
  602.                      Thermometer_val(1) = 4d_arr_rx(4)
  603.                      Thermometer_val(2) = 4d_arr_rx(5)
  604.                      'Print #debug_port , "Thermometer "
  605.                      Debug "Thermometer "
  606.                   Case Userled:                             '19
  607.                      Userled_idx = 4d_arr_rx(3)
  608.                      Userled_val(1) = 4d_arr_rx(4)
  609.                      Userled_val(2) = 4d_arr_rx(5)
  610.                      'Print #debug_port , "User led "
  611.                      Debug "User led "
  612.                   Case Video:                               '20
  613.                      Video_idx = 4d_arr_rx(3)
  614.                      Video_val(1) = 4d_arr_rx(4)
  615.                      Video_val(2) = 4d_arr_rx(5)
  616.                       'Print #debug_port ,  "Video "
  617.                      Debug "Video "
  618.                   Case Statictext:                          '21
  619.                   'Statictext_idx = 4d_arr_rx(3)
  620.                   'Statictext_val(1) = 4d_arr_rx(4)
  621.                   'Statictext_val(2) = 4d_arr_rx(5)
  622.                    'Print #debug_port , "Statictext "
  623.                      Debug "Statictext "
  624.                   Case S_ound:                              '22
  625.                      S_ound_idx = 4d_arr_rx(3)
  626.                      S_ound_val(1) = 4d_arr_rx(4)
  627.                      S_ound_val(2) = 4d_arr_rx(5)
  628.                     'Print #debug_port , "S_ound "
  629.                      Debug "S_ound "
  630.                   Case T_imer:                              '23
  631.                      T_imer_idx = 4d_arr_rx(3)
  632.                      T_imer_val(1) = 4d_arr_rx(4)
  633.                      T_imer_val(2) = 4d_arr_rx(5)
  634.                      'Print #debug_port , "T_imer "
  635.                      Debug "T_imer "
  636.                   Case Spectrum:                            '24
  637.                      Spectrum_idx = 4d_arr_rx(3)
  638.                      Spectrum_val(1) = 4d_arr_rx(4)
  639.                      Spectrum_val(2) = 4d_arr_rx(5)
  640.                      'Print #debug_port , "Spectrum "
  641.                      Debug "Spectrum "
  642.                   Case Scope:                               '25
  643.                      Scope_idx = 4d_arr_rx(3)
  644.                      Scope_val(1) = 4d_arr_rx(4)
  645.                      Scope_val(2) = 4d_arr_rx(5)
  646.                      'Print #debug_port , "Scope "
  647.                      Debug "Scope "
  648.                   Case Tank:                                '26
  649.                      Tank_idx = 4d_arr_rx(3)
  650.                      Tank_val(1) = 4d_arr_rx(4)
  651.                      Tank_val(2) = 4d_arr_rx(5)
  652.                      'Print #debug_port , "Tank "
  653.                      Debug "Tank "
  654.                   Case Userimages:                          '27
  655.                      Userimages_idx = 4d_arr_rx(3)
  656.                      Userimages_val(1) = 4d_arr_rx(4)
  657.                      Userimages_val(2) = 4d_arr_rx(5)
  658.                      'Print #debug_port , "User images "
  659.                      Debug "User images "
  660.                   Case Pinoutput:                           '28
  661.                      Pinoutput_idx = 4d_arr_rx(3)
  662.                   'Pinoutput_val(1) = 4d_arr_rx(4)
  663.                      Pinoutput_val = 4d_arr_rx(5)
  664.                      'Print #debug_port , "Pinoutput "
  665.                      Debug "Pinoutput "
  666.                   Case Pininput:                            '29
  667.                      Pininput_idx = 4d_arr_rx(3)
  668.                   'Pininput_val(1) = 4d_arr_rx(4)
  669.                      Pininput_val = 4d_arr_rx(5)
  670.                      'Print #debug_port , "Pin input "
  671.                      Debug "Pin input "
  672.                   Case 4dbutton:                            '30
  673.                      4dbutton_idx = 4d_arr_rx(3)
  674.                      4dbutton_val(1) = 4d_arr_rx(4)
  675.                      4dbutton_val(2) = 4d_arr_rx(5)
  676.                      'Print #debug_port , "4dbutton "
  677.                      Debug "4dbutton "
  678.                   Case Anibutton:                           '31
  679.                      Anibutton_idx = 4d_arr_rx(3)
  680.                      Anibutton_val(1) = 4d_arr_rx(4)
  681.                      Anibutton_val(2) = 4d_arr_rx(5)
  682.                      'Print #debug_port , "Ani button "
  683.                      Debug "Anibutton "
  684.                   Case Colorpicker:                         '32
  685.                      Colorpicker_idx = 4d_arr_rx(3)
  686.                      Colorpicker_val(1) = 4d_arr_rx(4)
  687.                      Colorpicker_val(2) = 4d_arr_rx(5)
  688.                      'Print #debug_port , "Color picker "
  689.                      Debug "Color picker "
  690.                   Case Userbutton:                          '33
  691.                      Userbutton_idx = 4d_arr_rx(3)
  692.                      Userbutton_val(1) = 4d_arr_rx(4)
  693.                      Userbutton_val(2) = 4d_arr_rx(5)
  694.                      'Print #debug_port , "User button "
  695.                      Debug "User button "
  696.                   Case Magicobject:                         '34
  697.                      Magicobject_idx = 4d_arr_rx(3)
  698.                      Magicobject_val(1) = 4d_arr_rx(4)
  699.                      Magicobject_val(2) = 4d_arr_rx(5)
  700.                      'Print #debug_port , "Magic object "
  701.                      Debug "Magic object "
  702.                   Case Smartgauge:                          '35
  703.                      Smartgauge_idx = 4d_arr_rx(3)
  704.                      Smartgauge_val(1) = 4d_arr_rx(4)
  705.                      Smartgauge_val(2) = 4d_arr_rx(5)
  706.                      'Print #debug_port , "Smart gauge "
  707.                      Debug "Smart gauge "
  708.                   Case Smartslider:                         '36
  709.                      Smartslider_idx = 4d_arr_rx(3)
  710.                      Smartslider_val(1) = 4d_arr_rx(4)
  711.                      Smartslider_val(2) = 4d_arr_rx(5)
  712.                      'Print #debug_port , "Smart slider "
  713.                      Debug "Smart slider "
  714.                   Case Smartknob:                           '37
  715.                      Smartknob_idx = 4d_arr_rx(3)
  716.                      Smartknob_val(1) = 4d_arr_rx(4)
  717.                      Smartknob_val(2) = 4d_arr_rx(5)
  718.                      'Print #debug_port , "Smart knob "
  719.                      Debug "Smart knob "
  720.                   Case Else:
  721.                      'Print #debug_port , "Event report wrong ID: " ; 4d_arr_rx(3)
  722.                      Debug "Event report wrong ID: " ; 4d_arr_rx(3)
  723.                      'Clear Serialin4 ' uncomment this if you using different port for debugging then 0
  724.                      'Print #debug_port , "S_pace" ; S_pace
  725.                      Debug "S_pace" ; S_pace
  726.                      'Print #debug_port , "frame error"
  727.                      Debug "frame error"
  728.                End Select
  729.             Else
  730.                Printbin #lcd_4d , &H15                      'send NAK to LCD
  731.                'Print #debug_port , "Event CRC error"
  732.                debug "Event CRC error"
  733.             End If
  734.          '**********************************************************************
  735.          Case Nak:
  736.          'Print #debug_port ,
  737.             'Print #debug_port , "NACK"                      '&h15  NAK  command
  738.             debug "NACK"                                    '&h15 NAK command
  739.             ACK_NACK_flag.1 = 1                             'reset ACK/NACK flag
  740.            'Clear Serialin4
  741.          '**********************************************************************
  742.          Case Else:
  743.             'Print #debug_port , "Error in Code =: " ; 4d_arr_rx(1)
  744.             debug "Error in Code =: " ; 4d_arr_rx(1)
  745.             'Clear Serialin4                                 'uncomment this if you using different port for debugging then 0 and change the port number
  746.             'Print #debug_port , "frame error"
  747.             debug "frame error"
  748.       End Select
  749.    Wend
  750. End Sub
  751. '*******************************************************************************
  752. '###############################################################################
  753. '*************************SUB for checking the UART ****************************
  754. 'This should be a function not a sub but waiting for the function result is taking way to long.
  755. 'call this sub to get values of the object from the display
  756. Sub 4d_read_obj(byval 4d_object_id As Byte , Byval 4d_object_index As Byte )
  757. '*******************************************************************************
  758. 'Syntax: Call 4d_read_obj_sub(object_id &H0 to &H25, object index &H0 to &HFF  )
  759. 'For more info refer to Visi Genie reference manual page 7 section 3.1.3.1
  760. 'Global variable will be updated.
  761. '*******************************************************************************
  762.    'this should be a function
  763.    4d_arr_tx(1) = Write_obj                                 '&h00 constant
  764.    4d_arr_tx(2) = 4d_object_id                              'object ID as per constants
  765.    4d_arr_tx(3) = 4d_object_index                           'object index
  766.    Xor_crc = 4d_arr_tx(1) Xor 4d_arr_tx(2)                  'calculate the xor check sum
  767.    Xor_crc = Xor_crc Xor 4d_arr_tx(3)
  768.    4d_arr_tx(4) = Xor_crc
  769.    Printbin #lcd_4d , 4d_arr_tx(1) ; 4                      'print binary  the final result
  770.    ACK_NACK_flag.0 = 1                                      'any response starting with 05 should clear this flag.
  771.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  772.       Incr 4d_wait_count                                    'just to indicate how long will this take
  773.       Call 4d_uart_rx                                       'check the Uart
  774.       if ACK_NACK_flag.0 = 0 and ACK_NACK_flag.1 = 1 then
  775.          Printbin #lcd_4d , 4d_arr_tx(1) ; 4                'repeat previous transmission
  776.          ACK_NACK_flag.0 = 1                                'any response starting with 05 should clear this flag.
  777.          ACK_NACK_flag.1 = 0
  778.       end if                                                'this flag is clear by NACK command therefore
  779.    Wend
  780.    'Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
  781.    debug "Waiting for the response counter: " ; 4d_wait_count
  782.    4d_wait_count = 0
  783.   'The response from the display should be Report_obj: &h05
  784. End Sub
  785. '******************************************************************************
  786. '*******************************************************************************
  787. Dim fifo_head As Byte                                       'index plus data
  788. Dim fifo_tail As Byte                                       'index plus data
  789. fifo_head = 0
  790. fifo_tail = 0
  791. Dim Fifo_tmp(6) As Byte
  792. 'Const Fifosize = 16
  793. Dim Fifo_buffer(6 , 16) As Byte                             ' 16 arrays, 6 bytes long
  794. 'Dim Fifo_idx As Byte
  795. 'Dim Copy_val As Byte
  796. 'Copy_val = 1
  797. '*******************************************************************************
  798. '*******************************************************************************
  799. '###############################################################################
  800. Sub Push_fifo(ar_pushf() As Byte )
  801. 'Base on ollopa code from MCs forum:
  802. 'https : / / www.mcselec.com / index2.phpPrint option = com_forum&Itemid = 59&page = viewtopic&t = 7941&highlight = fifo
  803. 'Thank you ollopa for sharing the idea !
  804.    Local Copy_val_a As Byte
  805.    Local Oldhead As Byte
  806.    Oldhead = fifo_head                                      '
  807.    Incr fifo_head
  808.    If fifo_head > Fifosize Then fifo_head = 1
  809.    If fifo_head = fifo_tail Then
  810.       fifo_head = Oldhead
  811.    Else
  812.       Copy_val_a = Memcopy(ar_pushf(1) , Fifo_buffer(1 , fifo_head ) , 6 , 3)
  813.       Print #debug_port , "push mem position= " ; Hex(varptr(fifo_buffer(1 , fifo_head )))
  814.    End If
  815. End Sub
  816. Function Pop_fifo() As Byte
  817. 'Base on ollopa code from MCs forum:
  818. 'https : / / www.mcselec.com / index2.phpPrint option = com_forum&Itemid = 59&page = viewtopic&t = 7941&highlight = fifo
  819. 'Thank you ollopa for sharing the idea !
  820.    Local Copy_val_b As Byte
  821.    Incr Tail
  822.    Copy_val_b = Memcopy(fifo_buffer(1 , fifo_tail ) , Fifo_tmp(1) , 6 , 3)
  823.    Print #debug_port , "pop mem position= " ; Hex(varptr(fifo_buffer(1 , fifo_tail )))
  824.    Pop_fifo(1) = Fifo_tmp(1)
  825. End Function
  826. '*******************************************************************************
  827. '###############################################################################
  828. Sub 4d_write_obj(byval 4d_object_id As Byte , Byval 4d_object_index As Byte , Byval 4d_obj_value As Word )
  829. 'Dim 4d_helpa As Word At 4d_arr_tx(4) Overlay  'copy for clarity
  830. '*******************************************************************************
  831. 'Syntax: Call 4d_write_obj(object_id &H0 to &H25, object index &H0 to &HFF  , object value &h00 to &HFFFF )
  832. 'For more info refer to Visi Genie reference manual page 8 section 3.1.3.2
  833. '*******************************************************************************
  834.    Swap 4d_obj_value                                        'little endian to big endian
  835.    4d_helpa = 4d_obj_value                                  'assign to overlaid variable
  836.    4d_arr_tx(1) = Write_obj                                 '&h01 constant
  837.    4d_arr_tx(2) = 4d_object_id                              'object ID as per constants
  838.    4d_arr_tx(3) = 4d_object_index                           'object index
  839.    '4d_arr_tx(4) for clarity as this is overlay so the values are already there in global array
  840.    '4d_arr_tx(5) for clarity as this is overlay so the values are already there in global array
  841.    Xor_crc = 4d_arr_tx(1) Xor 4d_arr_tx(2)                  'calculate the xor check sum
  842.    Xor_crc = Xor_crc Xor 4d_arr_tx(3)
  843.    Xor_crc = Xor_crc Xor 4d_arr_tx(4)
  844.    4d_arr_tx(6) = Xor_crc Xor 4d_arr_tx(5)
  845.    Printbin #lcd_4d , 4d_arr_tx(1) ; 6                      'print binary  the final result
  846.    'Printbin #debug_port , 4d_arr_tx(1) ; 6                  'print binary  the final result to debug port
  847.    Debug "Command code: " ; 4d_arr_tx(1)                    'Debug print command code (should be 1)
  848.    Debug "Object ID: " ; 4d_arr_tx(2)                       'Debug print object ID
  849.    Debug "Object index: " ; 4d_arr_tx(3)                    'Debug print object index
  850.    Debug "Object value MSB: " ; 4d_arr_tx(4)                'Debug print object value MSB
  851.    Debug "Object value LSB: " ; 4d_arr_tx(5)                'Debug print object value LSB
  852.    Debug "CRC: " ; 4d_arr_tx(6)                             'CRC
  853.    ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
  854.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  855.       Incr 4d_wait_count                                    'just to indicate how long will this take
  856.       Call 4d_uart_rx                                       'check the Uart
  857.       if ACK_NACK_flag.1 = 1 then                           'NAK received from the display
  858.          Printbin #lcd_4d , 4d_arr_tx(1) ; 6                ' repeat previous transmission
  859.          ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  860.       end if
  861.    Wend
  862.          'Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
  863.    Debug "Waiting for the response counter: " ; 4d_wait_count
  864.    4d_wait_count = 0
  865. End Sub
  866. '*******************************************************************************
  867. '###############################################################################
  868. Sub 4d_write_contrast(byval 4d_contrast_val As Byte)
  869. '*******************************************************************************
  870. 'Syntax: Call 4d_write_contrast(contrast value form 1 to 10  )
  871. 'For more info refer to Visi Genie reference manual page 9 section 3.1.3.5
  872. '*******************************************************************************
  873.    If 4d_contrast_val => 10 Then
  874.       4d_contrast_val = 10
  875.    End If
  876.    Dim 4d_contrast_tx(3) As Byte
  877.    4d_contrast_tx(1) = Write_contrast
  878.    4d_contrast_tx(2) = 4d_contrast_val
  879.    4d_contrast_tx(3) = Write_contrast Xor 4d_contrast_val
  880.    Printbin #lcd_4d , 4d_contrast_tx(1) ; 3
  881.    ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
  882.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  883.       Incr 4d_wait_count                                    'just to indicate how long will this take
  884.       Call 4d_uart_rx
  885.                     'check the Uart
  886.       if ACK_NACK_flag.1 = 1 then                           'NAK received from the display
  887.          Printbin #lcd_4d , 4d_arr_tx(1) ; 3                ' repeat previous transmission
  888.          ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  889.       end if
  890.    Wend
  891.   'Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
  892.    Debug "Waiting for the response counter: " ; 4d_wait_count
  893.    4d_wait_count = 0
  894. End Sub
  895.  
  896. Sub 4d_write_str_old(byval 4d_str_indx As Byte , Byval 4d_string_tmp As String )
  897. '*******************************************************************************
  898. 'Syntax: Call 4d_write_str_old(index hex value , "your text" )
  899. 'The body of the command is:
  900. 'comand_code+ string_index+ string_length + string + xorcrc
  901. 'For more info refer to Visi Genie reference manual page 8 section 3.1.3.3
  902. '*******************************************************************************
  903.    Local Index_help_a As Byte                               'used to calculate the length of the string
  904.    Dim Tot_command_len As Byte                              'total command length
  905.    Tot_command_len = Len(4d_string_tmp) + 4                 'total = string + string length byte + command byte + string index byte used for calculating crc
  906.    Print #debug_port , "total command length =" ; Tot_command_len
  907.    4d_string_tx = 4d_string_tmp                             'copy the string in to variable overlaid at array
  908.    4d_string_tx_arr(1) = Write_str                          '&h02 write string command
  909.    4d_string_tx_arr(2) = 4d_str_indx                        'index of the string
  910.    4d_string_tx_arr(3) = Len(4d_string_tmp)                 'length of the original string
  911.    For Index_help_a = 1 To Tot_command_len -1               'we need to xor this and assign at the end
  912.    'the minus (-)1 skip xor of the null termination
  913.       4d_string_tx_arr(tot_command_len) = 4d_string_tx_arr(tot_command_len) Xor 4d_string_tx_arr(index_help_a)
  914.    Next Index_help_a
  915.    Index_help_a = 0
  916.    Select Case Tot_command_len                              ' total command length
  917.       Case 5:
  918.          Printbin #debug_port , 4d_string_tx_arr(1) ; 5     'code +string index+ string length +  1 char + crc
  919.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 5         'code +string index+ string length +  1 char + crc
  920.       Case 6:
  921.          Printbin #debug_port , 4d_string_tx_arr(1) ; 6     'code +string index+ string length +  2 char + crc
  922.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 6         'code +string index+ string length +  2 char + crc
  923.       Case 7:
  924.          Printbin #debug_port , 4d_string_tx_arr(1) ; 7     'code +string index+ string length +  3 char + crc
  925.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 7         'code +string index+ string length +  3 char + crc
  926.       Case 8:
  927.          Printbin #debug_port , 4d_string_tx_arr(1) ; 8     'code +string index+ string length +  4 char + crc
  928.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 8         'code +string index+ string length +  4 char + crc
  929.       Case 9:
  930.          Printbin #debug_port , 4d_string_tx_arr(1) ; 9     'code +string index+ string length +  5 char + crc
  931.          Printbin #lcd_4d , 4d_string_tx_arr(1) , 9         'code +string index+ string length +  5 char + crc
  932.       Case 10:
  933.          Printbin #debug_port , 4d_string_tx_arr(1) ; 10    'code +string index+ string length +  6 char + crc
  934.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 10        'code +string index+ string length +  6 char + crc
  935.       Case 11:
  936.          Printbin #debug_port , 4d_string_tx_arr(1) ; 11    'code +string index+ string length +  7 char + crc
  937.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 11        'code +string index+ string length +  7 char + crc
  938.       Case 12:
  939.          Printbin #debug_port , 4d_string_tx_arr(1) ; 12    'code +string index+ string length +  8 char + crc
  940.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 12        'code +string index+ string length +  8 char + crc
  941.       Case 13:
  942.          Printbin #debug_port , 4d_string_tx_arr(1) ; 13    'code +string index+ string length +  9 char + crc
  943.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 13        'code +string index+ string length +  9 char + crc
  944.       Case 14:
  945.          Printbin #debug_port , 4d_string_tx_arr(1) ; 14    'code +string index+ string length +  10 char + crc
  946.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 14        'code +string index+ string length +  10 char + crc
  947.       Case 15:
  948.          Printbin #debug_port , 4d_string_tx_arr(1) ; 15    'code +string index+ string length +  11 char + crc
  949.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 15        'code +string index+ string length +  11 char + crc
  950.       Case 16:
  951.          Printbin #debug_port , 4d_string_tx_arr(1) ; 16    'code +string index+ string length +  12 char + crc
  952.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 16        'code +string index+ string length +  12 char + crc
  953.       Case 17:
  954.          Printbin #debug_port , 4d_string_tx_arr(1) ; 17    'code +string index+ string length +  13 char + crc
  955.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 17        'code +string index+ string length +  13 char + crc
  956.       Case 18:
  957.          Printbin #debug_port , 4d_string_tx_arr(1) ; 18    'code +string index+ string length +  14 char + crc
  958.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 18        'code +string index+ string length +  14 char + crc
  959.       Case 19:
  960.          Printbin #debug_port , 4d_string_tx_arr(1) ; 19    'code +string index+ string length +  15 char + crc
  961.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 19        'code +string index+ string length +  15 char + crc
  962.       Case 20:
  963.          Printbin #debug_port , 4d_string_tx_arr(1) ; 20    'code +string index+ string length +  16 char + crc
  964.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 20        'code +string index+ string length +  16 char + crc
  965.       Case 21:
  966.          Printbin #debug_port , 4d_string_tx_arr(1) ; 21    'code +string index+ string length +  17 char + crc
  967.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 21        'code +string index+ string length +  17 char + crc
  968.       Case 22:
  969.          Printbin #debug_port , 4d_string_tx_arr(1) ; 22    'code +string index+ string length +  18 char + crc
  970.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 22        'code +string index+ string length +  18 char + crc
  971.       Case 23:
  972.          Printbin #debug_port , 4d_string_tx_arr(1) ; 23    'code +string index+ string length +  19 char + crc
  973.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 23        'code +string index+ string length +  19 char + crc
  974.       Case 24:
  975.          Printbin #debug_port , 4d_string_tx_arr(1) ; 24    'code +string index+ string length +  20 char + crc
  976.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 24        'code +string index+ string length +  20 char + crc
  977.       Case 25:
  978.          Printbin #debug_port , 4d_string_tx_arr(1) ; 25    'code +string index+ string length +  21 char + crc
  979.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 25        'code +string index+ string length +  21 char + crc
  980.       Case 26:
  981.          Printbin #debug_port , 4d_string_tx_arr(1) ; 26    'code +string index+ string length +  22 char + crc
  982.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 26        'code +string index+ string length +  22 char + crc
  983.       Case 27:
  984.          Printbin #debug_port , 4d_string_tx_arr(1) ; 27    'code +string index+ string length +  23 char + crc
  985.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 27        'code +string index+ string length +  23 char + crc
  986.       Case 28:
  987.          Printbin #debug_port , 4d_string_tx_arr(1) ; 28    'code +string index+ string length +  24 char + crc
  988.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 28        'code +string index+ string length +  24 char + crc
  989.       Case 29:
  990.          Printbin #debug_port , 4d_string_tx_arr(1) ; 29    'code +string index+ string length +  25 char + crc
  991.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 29        'code +string index+ string length +  25 char + crc
  992.       Case 30:
  993.          Printbin #debug_port , 4d_string_tx_arr(1) ; 30    'code +string index+ string length +  26 char + crc
  994.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 30        'code +string index+ string length +  26 char + crc
  995.       Case 31:
  996.          Printbin #debug_port , 4d_string_tx_arr(1) ; 31    'code +string index+ string length +  27 char + crc
  997.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 31        'code +string index+ string length +  27 char + crc
  998.       Case 32:
  999.          Printbin #debug_port , 4d_string_tx_arr(1) ; 32    'code +string index+ string length +  28 char + crc
  1000.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 32        'code +string index+ string length +  28 char + crc
  1001.       Case 33:
  1002.          Printbin #debug_port , 4d_string_tx_arr(1) ; 33    'code +string index+ string length +  29 char + crc
  1003.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 33        'code +string index+ string length +  29 char + crc
  1004.       Case 34:
  1005.          Printbin #debug_port , 4d_string_tx_arr(1) ; 34    'code +string index+ string length +  30 char + crc
  1006.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 34        'code +string index+ string length +  30 char + crc
  1007.       Case 35:
  1008.          Printbin #debug_port , 4d_string_tx_arr(1) ; 35    'code +string index+ string length +  31 char + crc
  1009.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 35        'code +string index+ string length +  31 char + crc
  1010.       Case 36:
  1011.          Printbin #debug_port , 4d_string_tx_arr(1) ; 36    'code +string index+ string length +  32 char + crc
  1012.          Printbin #lcd_4d , 4d_string_tx_arr(1) ; 36        'code +string index+ string length +  32 char + crc
  1013.    End Select
  1014.    ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
  1015.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  1016.       Incr 4d_wait_count                                    'just to idicate how long will this take
  1017.       Call 4d_uart_rx                                       'check the Uart
  1018.       if ACK_NACK_flag.1 = 1 then                           'NAK received form the display
  1019.          'Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' repeat previous transmission
  1020.          'Above line is a bug but I will not fix it as this is for older version of the Bascom
  1021.          'Please upgrade to 2.0.8.2 or higer.
  1022.          ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  1023.       end if
  1024.    Wend
  1025.   'Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
  1026.    Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
  1027.    4d_wait_count = 0
  1028. End Sub
  1029.  
  1030. Sub 4d_write_str(byval 4d_str_indx As Byte , Byval 4d_string_tmp As String )
  1031. '*******************************************************************************
  1032. 'Syntax: Call 4d_write_str(index hex value , "your text" )
  1033. 'The body of the command is:
  1034. 'comand_code + string_index+ string_length + string + xorcrc
  1035. 'For more info refer to Visi Genie reference manual page 8 section 3.1.3.3
  1036. '*******************************************************************************
  1037.    Local Index_help_a As Byte                               'used to calculate the length of the string
  1038.    Dim Tot_command_len As Byte                              'total command length
  1039.    Tot_command_len = Len(4d_string_tmp) + 4                 'total = string + string length byte + command byte + string index byte used for calculating crc
  1040.    'Print #debug_port , "total command length =" ; Tot_command_len
  1041.    Debug "total command length =" ; Tot_command_len
  1042.    4d_string_tx = 4d_string_tmp                             'copy the string in to variable overlaid at array
  1043.    4d_string_tx_arr(1) = Write_str                          '&h02 write string command
  1044.    4d_string_tx_arr(2) = 4d_str_indx                        'index of the string
  1045.    4d_string_tx_arr(3) = Len(4d_string_tmp)                 'length of the original string
  1046.    For Index_help_a = 1 To Tot_command_len -1               'we need to xor this and assign at the end
  1047.    'the minus (-)1 skip xor of the null termination
  1048.       4d_string_tx_arr(tot_command_len) = 4d_string_tx_arr(tot_command_len) Xor 4d_string_tx_arr(index_help_a)
  1049.    Next Index_help_a
  1050.    Index_help_a = 0
  1051.    'Printbin #debug_port , 4d_string_tx_arr(1) , Tot_command_len       'code +string index+ string length +  1 char + crc
  1052.    Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
  1053.    Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
  1054.    ACK_NACK_flag.0 = 1                                      'ACK flag set to busy
  1055.    While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  1056.       Incr 4d_wait_count                                    'just to indicate how long will this take
  1057.       Call 4d_uart_rx                                       'check the Uart
  1058.       if ACK_NACK_flag.1 = 1 then                           'NAK received from the display
  1059.          Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len       'code +string index+ string length +  1 char + crc 'repeat previous transmission
  1060.          ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  1061.       end if
  1062.    Wend
  1063.   'Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
  1064.    Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
  1065.    4d_wait_count = 0
  1066. End Sub
  1067. '*******************************************************************************
  1068. '###############################################################################
Testowy kod dla Atmegha2560 (arduino)
  1. '$sim
  2. Debug ON
  3. $regfile = "m2560def.dat"
  4. $crystal = 16000000
  5. $baud = 19200
  6. $hwstack = 128
  7. $swstack = 96
  8. $framesize = 96
  9.  
  10. $projecttime = 164
  11. Config Submode = New                                        'use full use it if you can it helps a lot
  12. $version 0 , 0 , 12
  13. Dim Firmware As String * 9                                  'string to display the version later in the code
  14. Firmware = "test_0.1"                                       'as above
  15.  
  16. '************************* Uart configuration **********************************
  17. Config Com1 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
  18. Config Com2 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
  19. 'Config Com3 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
  20. 'Config Com4 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
  21.  
  22. Config Serialin1 = Buffered , Size = 64                     'this is buffor for serial in  2  (yes 2)
  23. Config Serialout1 = Buffered , Size = 64                    'this is buffor for serial out  2  (yes 2)
  24. 'Config Serialin2 = Buffered , Size = 64                     'this is buffor for serial in  3
  25. 'Config Serialout2 = Buffered , Size = 64                    'this is buffor for serial in  3
  26. 'Config Serialin3 = Buffered , Size = 64                     'this is buffor for serial in  4
  27. 'Config Serialout3 = Buffered , Size = 64                    'this is buffor for serial in  4
  28. ' As per MCS help file:
  29. '•         SERIALIN or SERIALIN0 : first UART/UART0
  30. '•         SERIALIN1 : second UART/UART1
  31. '•         SERIALIN2 : third UART/UART2
  32. '•         SERIALIN3 : fourth UART/UART3
  33. '•         SERIALIN4 : fifth UART/UART4
  34. '•         SERIALIN5 : sixth UART/UART5
  35. '•         SERIALIN6 : seventh UART/UART6
  36. '•         SERIALIN7 : eight UART / UART7
  37. '*******************************************************************************
  38. '************************* Open the UART ***************************************
  39. Open "com2:" For Binary As #2                               'open if needed  and dont forget to close after END line
  40. 'Open "Com3:" For Binary As #3                              'open if needed  and dont forget to close after END line
  41. 'Open "Com4:" For Binary As #4                              'open if needed  and dont forget to close after END line
  42. '*******************************************************************************
  43.  
  44. $include "Subs\4D_system_Visi_Genie_V1.1.inc"               ' include 4d visigene library
  45. '***************************Uart ***************************************
  46. 'If you are using different port then uart 0 for debug, uncomment all debug 'print #debug_port , xxx in the code.
  47. 'And comment all Bascom Debug commands.
  48. 'Then modify the port number below to match your debug port.
  49. 'Const Debug_port =4                                         'Debug port different then 0
  50. '
  51. Const Lcd_4d = 2                                            'Uart port used for 4d SYSTEM LCD
  52. '              ^
  53. '              ^
  54. 'Modify the number to suit your uart port.
  55.  
  56. '*******************************************************************************
  57. '************************* Variables *******************************************
  58. '*******************************************************************************
  59. Dim R_andom As Byte
  60. Dim S_pace As Byte
  61. Dim Gauge_0 As Word
  62. dim texT_test as string * 10
  63. '*******************************************************************************
  64.  
  65.  
  66. config PORTB.7 = output
  67. portb.7 = 0
  68. '-------------------------------------------------------------------------------
  69. '************************* Main loop *******************************************
  70. Enable Interrupts                                           'Global interrupts enable
  71.  
  72. Call 4d_write_str(&H0 , "hello world" )
  73.  
  74. Do
  75.    R_andom = Rnd(100)                                          'generate some random values for our test
  76.    texT_test = str(R_andom)                                 'covert the var to string
  77.    Call 4d_uart_rx()                                        'add this to  your main loop to receive activity from the display.
  78.    toggle portb.7                                           'blink led on Arduino board
  79.  
  80.    'Call 4d_write_str(&H0 , " !Warrning! " )                 'display the text
  81.   ' wait 1
  82.    'Call 4d_write_str(&H0 , "Corona virus" )                 'display the text
  83.    'wait 1
  84.    'Call 4d_write_str(&H0 , texT_test )                      'display the text
  85.    waitms 500
  86.    Call 4d_write_obj(leddigits , &H00 , R_andom )           'display for test  id 15
  87.  
  88.    Call 4d_write_obj(Gauge , &H00 , R_andom )               'display for test  id 11
  89. loop
  90.  
  91. end
  92.  
  93.  
  94.  
  95. Close #2                                                    'close the uart 2
  96. 'Close #3                                                    'close the uart 3
  97. 'Close #4                                                    'close the uart 4
Pikczu
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Pikczu
Posty: 389
Rejestracja: 17 sie 2015, 13:46
Lokalizacja: Dublin, Ireland
Kontakt:

Re: [Bascom] 4D Systems Visi Genie

Post autor: Pikczu » 15 sie 2020, 23:15

Witam,
4D Systems wypuściło na rynek nowe wyświetlacze serii Pixxi oraz dodało nowe funkcje do wyświetlaczy z procesorem Diablo16.
W systemie pojawiło się 29 nowych funkcji takich jak wskaźniki i bargrafy, przełączniki itp.

Zaktualizowana biblioteka w wersji 1.2 poniżej.
Zmiany są spore, ale nie zajęły dużo czasu raptem dwa wieczory :)
Dodałem warunkową kompilacje #IF #else #endif dla pixxi i diablo16.,
Poprawiłem wszytki komendy związane z debugowaniem, ułatwiając sobie życie poprzez #IF #else
Dodałem 29 nowych funkcji.
Błędy jak najbardziej możliwe :)
  1. $nocompile
  2. '4D_system_Visi_Genie Library version 1.2
  3. 'By Pikczu 2019.05.14
  4. 'Pawel.labedz@gmail.com
  5. '*******************************************************************************
  6. 'Change log:
  7. ' Initial version 1.0 date: 2019.05.14
  8. ' Version: 1.1 date: 2020.05.04
  9. 'Minor changes:
  10. 'Corrected debug commands and spelling in the comments.
  11. 'Added extra debug commands to: 4d_write_obj
  12. 'Version: 1.2 date: 2020.08.15
  13. 'Added new inherent and internal command for Pixxi and Diablo16 displays.
  14. '
  15. '*******************************************************************************
  16. '-------------------------------------------------------------------------------
  17. ' Name to include: $include "Subs\4D_system_Visi_Genie_V1.2.inc"
  18. '                               ^
  19. '                               ^
  20. 'This is your folder with subs--^
  21. '-------------------------------------------------------------------------------
  22. 'This library is dedicated for 4D systems LCD displays Visi Genie environment.
  23. 'Function Xor_this()
  24. 'Sub 4d_uart_rx()
  25. 'Sub 4d_read_obj_sub(object_id &H0 to &H25 , object index &H0 to &HFF )
  26. 'Sub Push_fifo -not in use
  27. 'Function Pop_fifo()- not in use
  28. 'Sub 4d_write_obj(object_id &H0 to &H25, object index &H0 to &HFF  , object value &h00 to &HFFFF )
  29. 'Sub 4d_write_contrast(contrast value from 1 to 10  )
  30. 'Sub 4d_write_str_old(index hex value , "your text" ) for Bascom version before 2.0.8.2
  31. 'Sub 4d_write_str(index hex value , "your text" )  for Bascom version 2.0.8.2 and above
  32. '*******************************************************************************
  33. ' To do:
  34. 'Add sub for Unicode string
  35. 'Add magic code sub
  36. '
  37. '###############################################################################
  38. '*************************Add this to main code ********************************
  39. 'If you are using different port for the drbug than uart
  40. 'modify the port number below to match your debug port and paste in teh main code before $Iclude file
  41. '
  42. 'Const Other_debug_port = 0 ' 0 or 1
  43. '#if Other_debug_port = 0
  44.    'Const Debug_port = 4 '                                     'Debug Port Different Then Serial0
  45. '#endif
  46.  
  47. 'Const Lcd_4d = 2                                            'Uart port used for 4d SYSTEM LCD
  48. '               ^
  49. '               ^
  50. 'Modify the number to suit your uart port.
  51. '
  52. 'Const Use_pixxi_diablo16 = 1  'if you are using new Pxxi or Diablo16 you can use new internal or inherent function.
  53. '
  54. '*******************************************************************************
  55. '###############################################################################
  56. '*****************************Used in 4D systems TX subs************************
  57. Dim Ack_nack_flag As Byte                                   ' ACK byte flag is setup each time we expect the ack to come from the display
  58. Ack_nack_flag = 0                                           'default value =0 all ok
  59. Dim 4d_wait_count As Word                                   'Used inside each 4D sub routine to count number of loops while waiting for the response from the lcd.
  60. Dim 4d_arr_tx(6)as Byte                                     'main array used to send the data
  61. Dim 4d_helpa As Word At 4d_arr_tx(4) Overlay                'array for object values  overlay at main array
  62. Dim 4d_string_tx_arr(39) As Byte                            ' Array for string
  63. Dim 4d_string_tx As String * 34 At 4d_string_tx_arr(1) + 3 Overlay       '+3 add room for string length byte + command byte + string index
  64. '********************for future use ********************************************
  65. 'Const 4d_max_len = 32                                       'maximum 4D string length
  66. 'Const Ack_nack_max = 32                                     'max number of ack or NACK in the que
  67. 'Dim Ack_nack_cnt As Byte                                   'for feature use
  68. 'Dim 4d_frame As Byte                                       'for feature use
  69. 'Const 4d_max_frame = 16                                    'maximum number of messages
  70. 'Dim Backup_tx As Byte                                      'for feature use
  71. '*******************************************************************************
  72. '*****************************Used in 4D systems RX subs************************
  73. Dim 4d_arr_rx(6) As Byte                                    'used for received data
  74. 'Dim 4d_var_rx As Word At 4d_arr_rx(4) Overlay               'overlay for rx
  75. 'Dim 4d_var_rx_tmp As Word
  76. 'Dim Obj_index As Byte                                       '4d object index
  77. '*******************************************************************************
  78. '***************************Variables used in XOR CRC **************************
  79. Dim Xor_crc As Byte                                         'xor crc for 4d
  80. Xor_crc = 0
  81. '*******************************************************************************
  82. '*****************************Variables for objects indexes ********************
  83. Dim Dipswitch_idx As Byte                                   '0
  84. Dim Knob_idx As Byte
  85. Dim Rockerswitch_idx As Byte
  86. Dim Rotaryswitch_idx As Byte
  87. Dim Slider_idx As Byte
  88. Dim Trackbar_idx As Byte
  89. Dim Winbutton_idx As Byte
  90. Dim Angularmeter_idx As Byte
  91. Dim Coolgauge_idx As Byte
  92. Dim Customdigits_idx As Byte
  93. Dim Form_idx As Byte                                        'Used to Set The Current Form
  94. Dim Gauge_idx As Byte                                       '
  95. 'Dim Image_idx As Byte                                       ' Displayed As Part Of Form, No Method To Alter
  96. Dim Keyboard_idx As Byte                                    ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  97. Dim Led_idx As Byte
  98. Dim Leddigits_idx As Byte
  99. Dim Meter_idx As Byte
  100. Dim Strings_idx As Byte
  101. Dim Thermometer_idx As Byte
  102. Dim Userled_idx As Byte
  103. Dim Video_idx As Byte
  104. 'Dim Statictext_idx As Byte                                  ' Displayed As Part Of Form, No Method To Alter
  105. Dim S_ound_idx As Byte
  106. Dim T_imer_idx As Byte
  107. Dim Spectrum_idx As Byte
  108. Dim Scope_idx As Byte
  109. Dim Tank_idx As Byte
  110. Dim Userimages_idx As Byte
  111. Dim Pinoutput_idx As Byte
  112. Dim Pininput_idx As Byte
  113. Dim 4dbutton_idx As Byte
  114. Dim Anibutton_idx As Byte
  115. Dim Colorpicker_idx As Byte
  116. Dim Userbutton_idx As Byte
  117. Dim Magicobject_idx As Byte                                 'ONLY Available When Using Genie Pro
  118. Dim Smartgauge_idx As Byte                                  'ONLY Available When Using Genie Pro
  119. Dim Smartslider_idx As Byte                                 'ONLY Available When Using Genie Pro
  120. Dim Smartknob_idx As Byte                                   'Only Available When Using Genie Pro
  121. '*******************************************************************************
  122. '**************************index variable for New Pixxi or diablo16*************
  123. #if Use_pixxi_diablo16
  124.    Dim Int_leddigitsh_idx As Byte                           'This object is only available for Diablo16 and Pixxi
  125.    Dim Int_angular_meter_idx As Byte                        'This object is only available for Diablo16 and Pixxi
  126.    Dim Int_gauge_idx As Byte                                'This object is only available for Diablo16 and Pixxi
  127.    Dim Inhe_label_idx As Byte                               'This object is only available for Diablo16 and Pixxi (flash-mode)
  128.    Dim Inhe_user_gauge_idx As Byte                          'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  129.    Dim Inhe_media_gauge_idx As Byte                         'This object is only available for Diablo16 and Pixxi (flash-mode)
  130.    Dim Inhe_media_thermometer_idx As Byte                   'This object is only available for Diablo16 and Pixxi (flash-mode)
  131.    Dim Int_led_idx As Byte                                  'This object is only available for Diablo16 and Pixxi
  132.    Dim Inhe_media_led_idx As Byte                           'This object is only available for Diablo16 and Pixxi (flash-mode)
  133.    Dim Int_leddigits_idx As Byte                            'This object is only available for Diablo16 and Pixxi
  134.    Dim Int_needle_idx As Byte                               'This object is only available for Diablo16 and Pixxi
  135.    Dim Int_ruler_gauge_idx As Byte                          'This object is only available for Diablo16 and Pixx
  136.    Dim Int_leddigit_idx As Byte                             'This object is only available for Diablo16 and Pixxi
  137.    Dim Int_buttond_idx As Byte                              'This object is only available for Diablo16 and Pixxi
  138.    Dim Inhe_buttone_idx As Byte                             'This object is only available for Diablo16 and Pixxi (flash-mode)
  139.    Dim Inhe_media_idx As Byte                               'This object is only available for Diablo16 and Pixxi (flash-mode)
  140.    Dim Inhe_toggle_idx As Byte                              'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  141.    Dim Int_dial_idx As Byte                                 'This object is only available for Diablo16 and Pixxi
  142.    Dim Inhe_media_rotary_idx As Byte                        'This object is only available for Diablo16 and Pixxi (flash-mode)
  143.    Dim Inhe_rotary_in_idx As Byte                           'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  144.    Dim Int_switch_idx As Byte                               'This object is only available for Diablo16 and Pixxi
  145.    Dim Inhe_switchb_idx As Byte                             'This object is only available for Diablo16 and Pixxi (flash-mode)
  146.    Dim Int_slidere_idx As Byte                              'This object is only available for Diablo16 and Pixxi
  147.    Dim Inhe_media_slider_idx As Byte                        'This object is only available for Diablo16 and Pixxi (flash-mode)
  148.    Dim Inhe_sliderh_idx As Byte                             'This object is only available for Diablo16 and Pixxi (flash-mode)
  149.    Dim Inhe_sliderg_idx As Byte                             'This object is only available for Diablo16 and Pixxi (flash-mode)
  150.    Dim Inhe_sliderf_idx As Byte                             'This object is only available for Diablo16 and Pixxi (flash-mode)
  151.    Dim Inhe_sliderd_idx As Byte                             'This object is only available for Diablo16 and Pixxi (flash-mode)
  152.    Dim Inhe_sliderc_idx As Byte                             'This object is only available for Diablo16 and Pixxi (flash-mode)
  153.    Dim Inhe_linear_in_idx As Byte                           'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  154. #endif
  155. '*******************************************************************************
  156. '**********************Arrays for objects values *******************************
  157. Dim Dipswitch_val(2) As Byte                                '0
  158. Dim Knob_val(2) As Byte
  159. Dim Rockerswitch_val(2) As Byte
  160. Dim Rotaryswitch_val(2) As Byte
  161. Dim Slider_val(2) As Byte
  162. Dim Trackbar_val(2) As Byte
  163. Dim Winbutton_val(2) As Byte
  164. Dim Angularmeter_val(2) As Byte
  165. Dim Coolgauge_val(2) As Byte
  166. Dim Customdigits_val(2) As Byte
  167. Dim Form_val(2) As Byte                                     'Used To Set The Current Form
  168. Dim Gauge_val(2) As Byte                                    '
  169. 'Dim Image_val(2) As Byte                                    ' Displayed As Part Of Form , No Method To Alter
  170. Dim Keyboard_val(2) As Byte                                 ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  171. Dim Led_val(2) As Byte
  172. Dim Leddigits_val(2) As Byte
  173. Dim Meter_val(2) As Byte
  174. Dim Strings_val(2) As Byte
  175. Dim Thermometer_val(2) As Byte
  176. Dim Userled_val(2) As Byte
  177. Dim Video_val(2) As Byte
  178. 'Dim Statictext_val(2) As Byte                               ' Displayed As Part Of Form , No Method To Alter
  179. Dim S_ound_val(2) As Byte
  180. Dim T_imer_val(2) As Byte
  181. Dim Spectrum_val(2) As Byte
  182. Dim Scope_val(2) As Byte
  183. Dim Tank_val(2) As Byte
  184. Dim Userimages_val(2) As Byte
  185. Dim Pinoutput_val As Byte
  186. Dim Pininput_val As Byte
  187. Dim 4dbutton_val(2) As Byte
  188. Dim Anibutton_val(2) As Byte
  189. Dim Colorpicker_val(2) As Byte
  190. Dim Userbutton_val(2) As Byte
  191. Dim Magicobject_val(2) As Byte                              'ONLY Available When Using Genie Pro
  192. Dim Smartgauge_val(2) As Byte                               'ONLY Available When Using Genie Pro
  193. Dim Smartslider_val(2) As Byte                              'ONLY Available When Using Genie Pro
  194. Dim Smartknob_val(2) As Byte                                'Only Available When Using Genie Pro
  195. '*******************************************************************************
  196. '************************Value arrays for new Pixxi or diablo16*****************
  197. #if Use_pixxi_diablo16
  198.  
  199.    Dim Int_leddigitsh_val(2) As Byte                        'This object is only available for Diablo16 and Pixxi
  200.    Dim Int_angular_meter_val(2) As Byte                     'This object is only available for Diablo16 and Pixxi
  201.    Dim Int_gauge_val(2) As Byte                             'This object is only available for Diablo16 and Pixxi
  202.    Dim Inhe_label_val(2) As Byte                            'This object is only available for Diablo16 and Pixxi (flash-mode)
  203.    Dim Inhe_user_gauge_val(2) As Byte                       'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  204.    Dim Inhe_media_gauge_val(2) As Byte                      'This object is only available for Diablo16 and Pixxi (flash-mode)
  205.    Dim Inhe_media_thermometer_val(2) As Byte                'This object is only available for Diablo16 and Pixxi (flash-mode)
  206.    Dim Int_led_val(2) As Byte                               'This object is only available for Diablo16 and Pixxi
  207.    Dim Inhe_media_led_val(2) As Byte                        'This object is only available for Diablo16 and Pixxi (flash-mode)
  208.    Dim Int_leddigits_val(2) As Byte                         'This object is only available for Diablo16 and Pixxi
  209.    Dim Int_needle_val(2) As Byte                            'This object is only available for Diablo16 and Pixxi
  210.    Dim Int_ruler_gauge_val(2) As Byte                       'This object is only available for Diablo16 and Pixx
  211.    Dim Int_leddigit_val(2) As Byte                          'This object is only available for Diablo16 and Pixxi
  212.    Dim Int_buttond_val(2) As Byte                           'This object is only available for Diablo16 and Pixxi
  213.    Dim Inhe_buttone_val(2) As Byte                          'This object is only available for Diablo16 and Pixxi (flash-mode)
  214.    Dim Inhe_media_button_val(2) As Byte                     'This object is only available for Diablo16 and Pixxi (flash-mode)
  215.    Dim Inhe_toggle_in_val(2) As Byte                        'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  216.    Dim Int_dial_val(2) As Byte                              'This object is only available for Diablo16 and Pixxi
  217.    Dim Inhe_media_rotary_val(2) As Byte                     'This object is only available for Diablo16 and Pixxi (flash-mode)
  218.    Dim Inhe_rotary_in_val(2) As Byte                        'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  219.    Dim Int_switch_val(2) As Byte                            'This object is only available for Diablo16 and Pixxi
  220.    Dim Inhe_switchb_val(2) As Byte                          'This object is only available for Diablo16 and Pixxi (flash-mode)
  221.    Dim Int_slidere_val(2) As Byte                           'This object is only available for Diablo16 and Pixxi
  222.    Dim Inhe_media_slider_val(2) As Byte                     'This object is only available for Diablo16 and Pixxi (flash-mode)
  223.    Dim Inhe_sliderh_val(2) As Byte                          'This object is only available for Diablo16 and Pixxi (flash-mode)
  224.    Dim Inhe_sliderg_val(2) As Byte                          'This object is only available for Diablo16 and Pixxi (flash-mode)
  225.    Dim Inhe_sliderf_val(2) As Byte                          'This object is only available for Diablo16 and Pixxi (flash-mode)
  226.    Dim Inhe_sliderd_val(2) As Byte                          'This object is only available for Diablo16 and Pixxi (flash-mode)
  227.    Dim Inhe_sliderc_val(2) As Byte                          'This object is only available for Diablo16 and Pixxi (flash-mode)
  228.    Dim Inhe_linear_in_val(2) As Byte                        'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  229. #endif
  230. '*******************************************************************************
  231. '*********************Constants used in select case for RX **********************
  232. Const A_ck = &H06
  233. Const Nak = &H15
  234. '*******************************************************************************
  235. Const Dipswitch = &H00                                      '0
  236. Const Knob = &H01
  237. Const Rockerswitch = &H02
  238. Const Rotaryswitch = &H03
  239. Const Slider = &H04
  240. Const Trackbar = &H05
  241. Const Winbutton = &H06
  242. Const Angularmeter = &H07
  243. Const Coolgauge = &H08
  244. Const Customdigits = &H09
  245. Const Form = &H0A                                           'Used To Set The Current Form
  246. Const Gauge = &H0B                                          '
  247. Const Image = &H0C                                          ' Displayed As Part Of Form, No Method To Alter
  248. Const Keyboard = &H0D                                       ' KEYBOARD Inputs Are Always Single Bytes And Are Unsolicited
  249. Const Led = &H0E
  250. Const Leddigits = &H0F
  251. Const Meter = &H10
  252. Const Strings = &H11
  253. Const Thermometer = &H12
  254. Const Userled = &H13
  255. Const Video = &H14
  256. Const Statictext = &H15                                     ' Displayed As Part Of Form, No Method To Alter
  257. Const S_ound = &H16
  258. Const T_imer = &H17
  259. Const Spectrum = &H18
  260. Const Scope = &H19
  261. Const Tank = &H1A
  262. Const Userimages = &H1B
  263. Const Pinoutput = &H1C
  264. Const Pininput = &H1D
  265. Const 4dbutton = &H1E
  266. Const Anibutton = &H1F
  267. Const Colorpicker = &H20
  268. Const Userbutton = &H21
  269. Const Magicobject = &H22                                    'ONLY Available When Using Genie Pro
  270. Const Smartgauge = &H23                                     'ONLY Available When Using Genie Pro
  271. Const Smartslider = &H24                                    'ONLY Available When Using Genie Pro
  272. Const Smartknob = &H25                                      'Only Available When Using Genie Pro
  273. '**********Constants for new Pixxi and Diablo16 ********************************
  274. #if Use_pixxi_diablo16
  275.    Const Int_leddigitsh = &H26                              'This object is only available for Diablo16 and Pixxi
  276.    Const Int_angular_meter = &H27                           'This object is only available for Diablo16 and Pixxi
  277.    Const Int_gauge = &H28                                   'This object is only available for Diablo16 and Pixxi
  278.    Const Inhe_label = &H29                                  'This object is only available for Diablo16 and Pixxi (flash-mode)
  279.    Const Inhe_user_gauge = &H2A                             'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  280.    Const Inhe_media_gauge = &H2B                            'This object is only available for Diablo16 and Pixxi (flash-mode)
  281.    Const Inhe_media_thermometer = &H2C                      'This object is only available for Diablo16 and Pixxi (flash-mode)
  282.    Const Int_led = &H2D                                     'This object is only available for Diablo16 and Pixxi
  283.    Const Inhe_media_led = &H2E                              'This object is only available for Diablo16 and Pixxi (flash-mode)
  284.    Const Int_leddigits = &H2F                               'This object is only available for Diablo16 and Pixxi
  285.    Const Int_needle = &H30                                  'This object is only available for Diablo16 and Pixxi
  286.    Const Int_ruler_gauge = &H31                             'This object is only available for Diablo16 and Pixx
  287.    Const Int_leddigit = &H32                                'This object is only available for Diablo16 and Pixxi
  288.    Const Int_buttond = &H33                                 'This object is only available for Diablo16 and Pixxi
  289.    Const Inhe_buttone = &H34                                'This object is only available for Diablo16 and Pixxi (flash-mode)
  290.    Const Inhe_media_button = &H35                           'This object is only available for Diablo16 and Pixxi (flash-mode)
  291.    Const Inhe_toggle_in = &H36                              'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  292.    Const Int_dial = &H37                                    'This object is only available for Diablo16 and Pixxi
  293.    Const Inhe_media_rotary = &H38                           'This object is only available for Diablo16 and Pixxi (flash-mode)
  294.    Const Inhe_rotary_in = &H39                              'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  295.    Const Int_switch = &H3A                                  'This object is only available for Diablo16 and Pixxi
  296.    Const Inhe_switchb = &H3B                                'This object is only available for Diablo16 and Pixxi (flash-mode)
  297.    Const Int_slidere = &H3C                                 'This object is only available for Diablo16 and Pixxi
  298.    Const Inhe_media_slider = &H3D                           'This object is only available for Diablo16 and Pixxi (flash-mode)
  299.    Const Inhe_sliderh = &H3E                                'This object is only available for Diablo16 and Pixxi (flash-mode)
  300.    Const Inhe_sliderg = &H3F                                'This object is only available for Diablo16 and Pixxi (flash-mode)
  301.    Const Inhe_sliderf = &H40                                'This object is only available for Diablo16 and Pixxi (flash-mode)
  302.    Const Inhe_sliderd = &H41                                'This object is only available for Diablo16 and Pixxi (flash-mode)
  303.    Const Inhe_sliderc = &H42                                'This object is only available for Diablo16 and Pixxi (flash-mode)
  304.    Const Inhe_linear_in = &H43                              'This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  305. #endif
  306. '*******************************************************************************
  307. Const Read_obj = &H00                                       'TX command to get value
  308. Const Write_obj = &H01                                      'TX command to write object value
  309. Const Write_str = &H02                                      'TX command to send string
  310. Const Write_stru = &H03                                     'TX command to send string Unicode
  311. Const Write_contrast = &H04                                 'TX command to set contrast
  312. Const Report_obj = &H05                                     'RX- response to read obj command
  313. Const Report_event = &H07                                   'RX response to event no request needed
  314. Const Write_magic_bytes = &H08                              'TX command for magic bytes PRO licence required
  315. Const Write_magic_dbytes = &H09                             'TX command for magic bytes PRO licence required
  316. Const Report_magic_event_bytes = &H0A                       'RX response to magic bytes PRO licence required
  317. '*******************************************************************************
  318. '*******************************************************************************
  319. '**************************XOR function to calculate CRC************************
  320. Function Xor_this(ar()as Byte ) As Byte                     '  Function XOR
  321.    Local Xor_ing As Byte                                    'temporary variable for xor value so could be a local
  322.    Xor_ing = Ar(1) Xor Ar(2)                                'xoring
  323.    Xor_ing = Xor_ing Xor Ar(3)
  324.    Xor_ing = Xor_ing Xor Ar(4)
  325.    Xor_ing = Xor_ing Xor Ar(5)
  326.    Xor_this = Xor_ing                                       'final result assignment
  327. End Function
  328. '*******************************************************************************
  329. '*************************SUB for checking the UART ****************************
  330. Sub 4d_uart_rx()                                            'main sub used for 4D systems LCD
  331. '*******************************************************************************
  332. 'Call this sub routine from main loop to check for events.
  333. 'Syntax : Call 4d_uart_rx()
  334. 'In addition this sub is called from: 4d_read_obj_sub, 4d_write_obj, 4d_write_contrast and 4d_write_str
  335. 'For more info refer to Visi Genie reference manual page 10 section 3.1.3.6 &7
  336. 'Global variable will be updated.
  337. '*******************************************************************************
  338.    While Ischarwaiting(#lcd_4d) <> 0                        'While characters are waiting in the buffer
  339.       Inputbin #lcd_4d , 4d_arr_rx(1) , 1                   'input them in to the array
  340.       #if Other_debug_port
  341.          Print #debug_port , "received= " ; 4d_arr_rx(1)
  342.       #else
  343.          Debug "received= " ; 4d_arr_rx(1)
  344.       #endif
  345.       Select Case 4d_arr_rx(1)                              'command
  346.          '**********************************************************************
  347.          Case Report_obj:                                   '&H05 report object command
  348.             Inputbin #lcd_4d , 4d_arr_rx(2) , 5             'get next 5 bytes from the buffer
  349.             Xor_crc = Xor_this(4d_arr_rx(1))                ' check the crc
  350.             If 4d_arr_rx(6) = Xor_crc Then                  'if crc ok then check what came
  351.                'CRC ok then we can clear the flag
  352.                Ack_nack_flag = 0                            'reset ACK flag
  353.                Select Case 4d_arr_rx(2)                     'object ID
  354.                   Case Dipswitch:                           '0
  355.                      Dipswitch_idx = 4d_arr_rx(3)
  356.                      Dipswitch_val(1) = 4d_arr_rx(4)
  357.                      Dipswitch_val(2) = 4d_arr_rx(5)
  358.                      #if Other_debug_port                   'If other uart used for the debug
  359.                         Print #debug_port , "Dipswitch"
  360.                      #else
  361.                         Debug "Dipswitch"
  362.                      #endif
  363.                   Case Knob:                                '1
  364.                      Knob_idx = 4d_arr_rx(3)
  365.                      Knob_val(1) = 4d_arr_rx(4)
  366.                      Knob_val(2) = 4d_arr_rx(5)
  367.                      #if Other_debug_port
  368.                         Print #debug_port , "Knob"
  369.                      #else
  370.                         Debug "Knob"
  371.                      #endif
  372.                   Case Rockerswitch:                        '2
  373.                      Rockerswitch_idx = 4d_arr_rx(3)
  374.                      Rockerswitch_val(1) = 4d_arr_rx(4)
  375.                      Rockerswitch_val(2) = 4d_arr_rx(5)
  376.                      #if Other_debug_port
  377.                         Print #debug_port , "Rockerswitch"
  378.                      #else
  379.                         Debug "Rockerswitch"
  380.                      #endif
  381.                   Case Rotaryswitch:                        '3
  382.                      Rotaryswitch_idx = 4d_arr_rx(3)
  383.                      Rotaryswitch_val(1) = 4d_arr_rx(4)
  384.                      Rotaryswitch_val(2) = 4d_arr_rx(5)
  385.                      #if Other_debug_port
  386.                         Print #debug_port , "Rotaryswitch"
  387.                      #else
  388.                         Debug "Rotaryswitch"
  389.                      #endif
  390.                   Case Slider:                              '4
  391.                      Slider_idx = 4d_arr_rx(3)
  392.                      Slider_val(1) = 4d_arr_rx(4)
  393.                      Slider_val(2) = 4d_arr_rx(5)
  394.                      #if Other_debug_port
  395.                         Print #debug_port , "Slider"
  396.                      #else
  397.                         Debug "Slider"
  398.                      #endif
  399.                   Case Trackbar:                            '5
  400.                      Trackbar_idx = 4d_arr_rx(3)
  401.                      Trackbar_val(1) = 4d_arr_rx(4)
  402.                      Trackbar_val(2) = 4d_arr_rx(5)
  403.                      #if Other_debug_port
  404.                         Print #debug_port , "Trackbar"
  405.                      #else
  406.                         Debug "Trackbar"
  407.                      #endif
  408.                   Case Winbutton:                           '6
  409.                      Winbutton_idx = 4d_arr_rx(3)
  410.                      Winbutton_val(1) = 4d_arr_rx(4)
  411.                      Winbutton_val(2) = 4d_arr_rx(5)
  412.                      #if Other_debug_port
  413.                         Print #debug_port , "Winbutton"
  414.                      #else
  415.                         Debug "Winbutton"
  416.                      #endif
  417.                   Case Angularmeter:                        '7
  418.                      Angularmeter_idx = 4d_arr_rx(3)
  419.                      Angularmeter_val(1) = 4d_arr_rx(4)
  420.                      Angularmeter_val(2) = 4d_arr_rx(5)
  421.                      #if Other_debug_port
  422.                         Print #debug_port , "Angularmeter"
  423.                      #else
  424.                         Debug "Angularmeter"
  425.                      #endif
  426.                   Case Coolgauge:                           '8
  427.                      Coolgauge_idx = 4d_arr_rx(3)
  428.                      Coolgauge_val(1) = 4d_arr_rx(4)
  429.                      Coolgauge_val(2) = 4d_arr_rx(5)
  430.                      #if Other_debug_port
  431.                         Print #debug_port , "Coolgauge"
  432.                      #else
  433.                         Debug "Coolgauge"
  434.                      #endif
  435.                   Case Customdigits:                        '9
  436.                      Customdigits_idx = 4d_arr_rx(3)
  437.                      Customdigits_val(1) = 4d_arr_rx(4)
  438.                      Customdigits_val(2) = 4d_arr_rx(5)
  439.                      #if Other_debug_port
  440.                         Print #debug_port , "Customdigits"
  441.                      #else
  442.                         Debug "Customdigits"
  443.                      #endif
  444.                   Case Form:                                '10
  445.                      Form_idx = 4d_arr_rx(3)
  446.                      Form_val(1) = 4d_arr_rx(4)
  447.                      Form_val(2) = 4d_arr_rx(5)
  448.                      #if Other_debug_port
  449.                         Print #debug_port , "Form"
  450.                      #else
  451.                         Debug "Form"
  452.                      #endif
  453.                   Case Gauge:                               '11
  454.                      Gauge_idx = 4d_arr_rx(3)
  455.                      Gauge_val(1) = 4d_arr_rx(4)
  456.                      Gauge_val(2) = 4d_arr_rx(5)
  457.                      #if Other_debug_port
  458.                         Print #debug_port , "Gauge"
  459.                      #else
  460.                         Debug "Gauge"
  461.                      #endif
  462.                   Case Image:                               '12
  463.                   'Image_idx = 4d_arr_rx(3)
  464.                   'Image_val(1) = 4d_arr_rx(4)
  465.                   'Image_val(2) = 4d_arr_rx(5)
  466.                      #if Other_debug_port
  467.                         Print #debug_port , "Image"
  468.                      #else
  469.                         Debug "Image"
  470.                      #endif
  471.                   Case Keyboard:                            '13
  472.                      Keyboard_idx = 4d_arr_rx(3)
  473.                      Keyboard_val(1) = 4d_arr_rx(4)
  474.                      Keyboard_val(2) = 4d_arr_rx(5)
  475.                      #if Other_debug_port
  476.                         Print #debug_port , "Keyboard"
  477.                      #else
  478.                         Debug "Keyboard"
  479.                      #endif
  480.                   Case Led:                                 '14
  481.                      Led_idx = 4d_arr_rx(3)
  482.                      Led_val(1) = 4d_arr_rx(4)
  483.                      Led_val(2) = 4d_arr_rx(5)
  484.                      #if Other_debug_port
  485.                         Print #debug_port , "Led"
  486.                      #else
  487.                         Debug "Led"
  488.                      #endif
  489.                   Case Leddigits:                           '15
  490.                      Leddigits_idx = 4d_arr_rx(3)
  491.                      Leddigits_val(1) = 4d_arr_rx(4)
  492.                      Leddigits_val(2) = 4d_arr_rx(5)
  493.                      #if Other_debug_port
  494.                         Print #debug_port , "Leddigits"
  495.                      #else
  496.                         Debug "Leddigits"
  497.                      #endif
  498.                   Case Meter:                               '16
  499.                      Meter_idx = 4d_arr_rx(3)
  500.                      Meter_val(1) = 4d_arr_rx(4)
  501.                      Meter_val(2) = 4d_arr_rx(5)
  502.                      #if Other_debug_port
  503.                         Print #debug_port , "Meter"
  504.                      #else
  505.                         Debug "Meter"
  506.                      #endif
  507.                   Case Strings:                             '17
  508.                      Strings_idx = 4d_arr_rx(3)
  509.                      Strings_val(1) = 4d_arr_rx(4)
  510.                      Strings_val(2) = 4d_arr_rx(5)
  511.                      #if Other_debug_port
  512.                         Print #debug_port , "Strings"
  513.                      #else
  514.                         Debug "Strings"
  515.                      #endif
  516.                   Case Thermometer:                         '18
  517.                      Thermometer_idx = 4d_arr_rx(3)
  518.                      Thermometer_val(1) = 4d_arr_rx(4)
  519.                      Thermometer_val(2) = 4d_arr_rx(5)
  520.                      #if Other_debug_port
  521.                         Print #debug_port , "Thermometer"
  522.                      #else
  523.                         Debug "Thermometer"
  524.                      #endif
  525.                   Case Userled:                             '19
  526.                      Userled_idx = 4d_arr_rx(3)
  527.                      Userled_val(1) = 4d_arr_rx(4)
  528.                      Userled_val(2) = 4d_arr_rx(5)
  529.                      #if Other_debug_port
  530.                         Print #debug_port , "Userled"
  531.                      #else
  532.                         Debug "Userled"
  533.                      #endif
  534.                   Case Video:                               '20
  535.                      Video_idx = 4d_arr_rx(3)
  536.                      Video_val(1) = 4d_arr_rx(4)
  537.                      Video_val(2) = 4d_arr_rx(5)
  538.                      #if Other_debug_port
  539.                         Print #debug_port , "Video"
  540.                      #else
  541.                         Debug "Video"
  542.                      #endif
  543.                   Case Statictext:                          '21
  544.                   'Statictext_idx = 4d_arr_rx(3)
  545.                   'Statictext_val(1) = 4d_arr_rx(4)
  546.                   'Statictext_val(2) = 4d_arr_rx(5)
  547.                      #if Other_debug_port
  548.                         Print #debug_port , "Statictext"
  549.                      #else
  550.                         Debug "Statictext"
  551.                      #endif
  552.                   Case S_ound:                              '22
  553.                      S_ound_idx = 4d_arr_rx(3)
  554.                      S_ound_val(1) = 4d_arr_rx(4)
  555.                      S_ound_val(2) = 4d_arr_rx(5)
  556.                      #if Other_debug_port
  557.                         Print #debug_port , "S_ound"
  558.                      #else
  559.                         Debug "S_ound"
  560.                      #endif
  561.                   Case T_imer:                               '23
  562.                      T_imer_idx = 4d_arr_rx(3)
  563.                      T_imer_val(1) = 4d_arr_rx(4)
  564.                      T_imer_val(2) = 4d_arr_rx(5)
  565.  
  566.                      #if Other_debug_port
  567.                         Print #debug_port , "T_imer"
  568.                      #else
  569.                         Debug "T_imer"
  570.                      #endif
  571.                   Case Spectrum:                            '24
  572.                      Spectrum_idx = 4d_arr_rx(3)
  573.                      Spectrum_val(1) = 4d_arr_rx(4)
  574.                      Spectrum_val(2) = 4d_arr_rx(5)
  575.                      #if Other_debug_port
  576.                         Print #debug_port , "Spectrum"
  577.                      #else
  578.                         Debug "Spectrum"
  579.                      #endif
  580.                   Case Scope:                               '25
  581.                      Scope_idx = 4d_arr_rx(3)
  582.                      Scope_val(1) = 4d_arr_rx(4)
  583.                      Scope_val(2) = 4d_arr_rx(5)
  584.                      #if Other_debug_port
  585.                         Print #debug_port , "Scope"
  586.                      #else
  587.                         Debug "Scope"
  588.                      #endif
  589.                   Case Tank:                                 '26
  590.                      Tank_idx = 4d_arr_rx(3)
  591.                      Tank_val(1) = 4d_arr_rx(4)
  592.                      Tank_val(2) = 4d_arr_rx(5)
  593.                      #if Other_debug_port
  594.                         Print #debug_port , "Tank"
  595.                      #else
  596.                         Debug "Tank"
  597.                      #endif
  598.                   Case Userimages:                          '27
  599.                      Userimages_idx = 4d_arr_rx(3)
  600.                      Userimages_val(1) = 4d_arr_rx(4)
  601.                      Userimages_val(2) = 4d_arr_rx(5)
  602.                      #if Other_debug_port
  603.                         Print #debug_port , "Userimages"
  604.                      #else
  605.                         Debug "Userimages"
  606.                      #endif
  607.                   Case Pinoutput:                           '28
  608.                      Pinoutput_idx = 4d_arr_rx(3)
  609.                   'Pinoutput_val(1) = 4d_arr_rx(4)
  610.                      Pinoutput_val = 4d_arr_rx(5)
  611.                      #if Other_debug_port
  612.                         Print #debug_port , "Pinoutput"
  613.                      #else
  614.                         Debug "Pinoutput"
  615.                      #endif
  616.                   Case Pininput:                            '29
  617.                      Pininput_idx = 4d_arr_rx(3)
  618.                   'Pininput_val(1) = 4d_arr_rx(4)
  619.                      Pininput_val = 4d_arr_rx(5)
  620.                      #if Other_debug_port
  621.                         Print #debug_port , "Pininput"
  622.                      #else
  623.                         Debug "Pininput"
  624.                      #endif
  625.                   Case 4dbutton:                            '30
  626.                      4dbutton_idx = 4d_arr_rx(3)
  627.                      4dbutton_val(1) = 4d_arr_rx(4)
  628.                      4dbutton_val(2) = 4d_arr_rx(5)
  629.                      #if Other_debug_port
  630.                         Print #debug_port , "4dbutton"
  631.                      #else
  632.                         Debug "4dbutton"
  633.                      #endif
  634.                   Case Anibutton:                           '31
  635.                      Anibutton_idx = 4d_arr_rx(3)
  636.                      Anibutton_val(1) = 4d_arr_rx(4)
  637.                      Anibutton_val(2) = 4d_arr_rx(5)
  638.                      #if Other_debug_port
  639.                         Print #debug_port , "Anibutton"
  640.                      #else
  641.                         Debug "Anibutton"
  642.                      #endif
  643.                   Case Colorpicker:                         '32
  644.                      Colorpicker_idx = 4d_arr_rx(3)
  645.                      Colorpicker_val(1) = 4d_arr_rx(4)
  646.                      Colorpicker_val(2) = 4d_arr_rx(5)
  647.                      #if Other_debug_port
  648.                         Print #debug_port , "Colorpicker"
  649.                      #else
  650.                         Debug "Colorpicker"
  651.                      #endif
  652.                   Case Userbutton:                          '33
  653.                      Userbutton_idx = 4d_arr_rx(3)
  654.                      Userbutton_val(1) = 4d_arr_rx(4)
  655.                      Userbutton_val(2) = 4d_arr_rx(5)
  656.                      #if Other_debug_port
  657.                         Print #debug_port , "Userbutton"
  658.                      #else
  659.                         Debug "Userbutton"
  660.                      #endif
  661.                   Case Magicobject:                         '34
  662.                      Magicobject_idx = 4d_arr_rx(3)
  663.                      Magicobject_val(1) = 4d_arr_rx(4)
  664.                      Magicobject_val(2) = 4d_arr_rx(5)
  665.  
  666.                      #if Other_debug_port
  667.                         Print #debug_port , "Magicobject"
  668.                      #else
  669.                         Debug "Magicobject"
  670.                      #endif
  671.                   Case Smartgauge:                          '35
  672.                      Smartgauge_idx = 4d_arr_rx(3)
  673.                      Smartgauge_val(1) = 4d_arr_rx(4)
  674.                      Smartgauge_val(2) = 4d_arr_rx(5)
  675.                      #if Other_debug_port
  676.                         Print #debug_port , "Smartgauge"
  677.                      #else
  678.                         Debug "Smartgauge"
  679.                      #endif
  680.                   Case Smartslider:                         '36
  681.                      Smartslider_idx = 4d_arr_rx(3)
  682.                      Smartslider_val(1) = 4d_arr_rx(4)
  683.                      Smartslider_val(2) = 4d_arr_rx(5)
  684.  
  685.                      #if Other_debug_port
  686.                         Print #debug_port , "Smartslider"
  687.                      #else
  688.                         Debug "Smartslider"
  689.                      #endif
  690.                   Case Smartknob:                           '37
  691.                      Smartknob_idx = 4d_arr_rx(3)
  692.                      Smartknob_val(1) = 4d_arr_rx(4)
  693.                      Smartknob_val(2) = 4d_arr_rx(5)
  694.                      #if Other_debug_port
  695.                         Print #debug_port , "Smartknob"
  696.                      #else
  697.                         Debug "Smartknob"
  698.                      #endif
  699. '*******************************************************************************
  700. '*********************************New Pixxi or diablo16*************************
  701.                      #if Use_pixxi_diablo16
  702.                         Case Int_leddigitsh:                '38 This object is only available for Diablo16 and Pixxi
  703.                         Int_leddigitsh_idx = 4d_arr_rx(3)
  704.                         Int_leddigitsh_val(1) = 4d_arr_rx(4)
  705.                         Int_leddigitsh_val(2) = 4d_arr_rx(5)
  706.                         #if Other_debug_port
  707.                            Print #debug_port , "Int_leddigitsh"
  708.                         #else
  709.                            Debug "Int_leddigitsh "
  710.                         #endif
  711.                         Case Int_angular_meter:             '39 This object is only available for Diablo16 and Pixxi
  712.                         Int_angular_meter_idx = 4d_arr_rx(3)
  713.                         Int_angular_meter_val(1) = 4d_arr_rx(4)
  714.                         Int_angular_meter_val(2) = 4d_arr_rx(5)
  715.  
  716.                         #if Other_debug_port
  717.                            Print #debug_port , "Int_angular_meter"
  718.                         #else
  719.                            Debug "Int_angular_meter "
  720.                         #endif
  721.  
  722.                         Case Int_gauge:                     '40 This object is only available for Diablo16 and Pixxi
  723.                         Int_gauge_idx = 4d_arr_rx(3)
  724.                         Int_gauge_val(1) = 4d_arr_rx(4)
  725.                         Int_gauge_val(2) = 4d_arr_rx(5)
  726.  
  727.                         #if Other_debug_port
  728.                            Print #debug_port , "Int_gauge"
  729.                         #else
  730.                            Debug "Int_gauge"
  731.                         #endif
  732.                         Case Inhe_label:                    '41 This object is only available for Diablo16 and Pixxi (flash-mode)
  733.                         Inhe_label_idx = 4d_arr_rx(3)
  734.                         Inhe_label_val(1) = 4d_arr_rx(4)
  735.                         Inhe_label_val(2) = 4d_arr_rx(5)
  736.  
  737.                         #if Other_debug_port
  738.                            Print #debug_port , "Inhe_label"
  739.                         #else
  740.                            Debug "Inhe_label"
  741.                         #endif
  742.                         Case Inhe_user_gauge:               '42 This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  743.                         Inhe_user_gauge_idx = 4d_arr_rx(3)
  744.                         Inhe_user_gauge_val(1) = 4d_arr_rx(4)
  745.                         Inhe_user_gauge_val(2) = 4d_arr_rx(5)
  746.                         #if Other_debug_port
  747.                            Print #debug_port , "Inhe_user_gauge"
  748.                         #else
  749.                            Debug "Inhe_user_gauge"
  750.                         #endif
  751.                         Case Inhe_media_gauge:              '43 This object is only available for Diablo16 and Pixxi (flash-mode)
  752.                         Inhe_media_gauge_idx = 4d_arr_rx(3)
  753.                         Inhe_media_gauge_val(1) = 4d_arr_rx(4)
  754.                         Inhe_media_gauge_val(2) = 4d_arr_rx(5)
  755.                         #if Other_debug_port
  756.                            Print #debug_port , "Inhe_media_gauge"
  757.                         #else
  758.                            Debug "Inhe_media_gauge"
  759.                         #endif
  760.                         Case Inhe_media_thermometer:        '44 This object is only available for Diablo16 and Pixxi (flash-mode)
  761.                         Inhe_media_thermometer_idx = 4d_arr_rx(3)
  762.                         Inhe_media_thermometer_val(1) = 4d_arr_rx(4)
  763.                         Inhe_media_thermometer_val(2) = 4d_arr_rx(5)
  764.                         #if Other_debug_port
  765.                            Print #debug_port , "Inhe_media_thermometer"
  766.                         #else
  767.                            Debug "Inhe_media_thermometer "
  768.                         #endif
  769.                         Case Int_led:                       '45 This object is only available for Diablo16 and Pixxi
  770.                         Int_led_idx = 4d_arr_rx(3)
  771.                         Int_led_val(1) = 4d_arr_rx(4)
  772.                         Int_led_val(2) = 4d_arr_rx(5)
  773.                         #if Other_debug_port
  774.                            Print #debug_port , "Int_led"
  775.                         #else
  776.                            Debug "Int_led"
  777.                         #endif
  778.                         Case Inhe_media_led:                '46 This object is only available for Diablo16 and Pixxi (flash-mode)
  779.                         Inhe_media_led_idx = 4d_arr_rx(3)
  780.                         Inhe_media_led_val(1) = 4d_arr_rx(4)
  781.                         Inhe_media_led_val(2) = 4d_arr_rx(5)
  782.                         #if Other_debug_port
  783.                            Print #debug_port , "Inhe_media_led"
  784.                         #else
  785.                            Debug "Inhe_media_led"
  786.                         #endif
  787.                         Case Int_leddigits:                 '47 This object is only available for Diablo16 and Pixxi
  788.                         Int_leddigits_idx = 4d_arr_rx(3)
  789.                         Int_leddigits_val(1) = 4d_arr_rx(4)
  790.                         Int_leddigits_val(2) = 4d_arr_rx(5)
  791.                         #if Other_debug_port
  792.                            Print #debug_port , "Int_leddigits"
  793.                         #else
  794.                            Debug "Int_leddigits"
  795.                         #endif
  796.                         Case Int_needle:                    '48 This object is only available for Diablo16 and Pixxi
  797.                         Int_needle_idx = 4d_arr_rx(3)
  798.                         Int_needle_val(1) = 4d_arr_rx(4)
  799.                         Int_needle_val(2) = 4d_arr_rx(5)
  800.                         #if Other_debug_port
  801.                            Print #debug_port , "Int_needle"
  802.                         #else
  803.                            Debug "Int_needle"
  804.                         #endif
  805.                         Case Int_ruler_gauge:               '49 This object is only available for Diablo16 and Pixx
  806.                         Int_ruler_gauge_idx = 4d_arr_rx(3)
  807.                         Int_ruler_gauge_val(1) = 4d_arr_rx(4)
  808.                         Int_ruler_gauge_val(2) = 4d_arr_rx(5)
  809.                         #if Other_debug_port
  810.                            Print #debug_port , "Int_ruler_gauge"
  811.                         #else
  812.                            Debug "Int_ruler_gauge"
  813.                         #endif
  814.                         Case Int_leddigit:                  '50 This object is only available for Diablo16 and Pixxi
  815.                         Int_leddigit_idx = 4d_arr_rx(3)
  816.                         Int_leddigit_val(1) = 4d_arr_rx(4)
  817.                         Int_leddigit_val(2) = 4d_arr_rx(5)
  818.                         #if Other_debug_port
  819.                            Print #debug_port , "Int_leddigit"
  820.                         #else
  821.                            Debug "Int_leddigit"
  822.                         #endif
  823.                         Case Int_buttond:                   '51 This object is only available for Diablo16 and Pixxi
  824.                         Int_buttond_idx = 4d_arr_rx(3)
  825.                         Int_buttond_val(1) = 4d_arr_rx(4)
  826.                         Int_buttond_val(2) = 4d_arr_rx(5)
  827.                         #if Other_debug_port
  828.                            Print #debug_port , "Int_buttond"
  829.                         #else
  830.                            Debug "Int_buttond"
  831.                         #endif
  832.                         Case Inhe_buttone:                  '52 This object is only available for Diablo16 and Pixxi (flash-mode)
  833.                         Inhe_buttone_idx = 4d_arr_rx(3)
  834.                         Inhe_buttone_val(1) = 4d_arr_rx(4)
  835.                         Inhe_buttone_val(2) = 4d_arr_rx(5)
  836.                         #if Other_debug_port
  837.                            Print #debug_port , "Inhe_buttone"
  838.                         #else
  839.                            Debug "Inhe_buttone"
  840.                         #endif
  841.                         Case Inhe_media_button:             '53 This object is only available for Diablo16 and Pixxi (flash-mode)
  842.                         Inhe_media_idx = 4d_arr_rx(3)
  843.                         Inhe_media_button_val(1) = 4d_arr_rx(4)
  844.                         Inhe_media_button_val(2) = 4d_arr_rx(5)
  845.                         #if Other_debug_port
  846.                            Print #debug_port , "Inhe_media_button"
  847.                         #else
  848.                            Debug "Inhe_media_button"
  849.                         #endif
  850.                         Case Inhe_toggle_in:                '54 This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  851.                         Inhe_toggle_idx = 4d_arr_rx(3)
  852.                         Inhe_toggle_in_val(1) = 4d_arr_rx(4)
  853.                         Inhe_toggle_in_val(2) = 4d_arr_rx(5)
  854.                         #if Other_debug_port
  855.                            Print #debug_port , "Inhe_toggle_in"
  856.                         #else
  857.                            Debug "Inhe_toggle_in"
  858.                         #endif
  859.                         Case Int_dial:                      '55 This object is only available for Diablo16 and Pixxi
  860.                         Int_dial_idx = 4d_arr_rx(3)
  861.                         Int_dial_val(1) = 4d_arr_rx(4)
  862.                         Int_dial_val(2) = 4d_arr_rx(5)
  863.                         #if Other_debug_port
  864.                            Print #debug_port , "Int_dial"
  865.                         #else
  866.                            Debug "Int_dial"
  867.                         #endif
  868.                         Case Inhe_media_rotary:             '56 This object is only available for Diablo16 and Pixxi (flash-mode)
  869.                         Inhe_media_rotary_idx = 4d_arr_rx(3)
  870.                         Inhe_media_rotary_val(1) = 4d_arr_rx(4)
  871.                         Inhe_media_rotary_val(2) = 4d_arr_rx(5)
  872.                         #if Other_debug_port
  873.                            Print #debug_port , "Inhe_media_rotary"
  874.                         #else
  875.                            Debug "Inhe_media_rotary"
  876.                         #endif
  877.                         Case Inhe_rotary_in:                '57 This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  878.                         Inhe_rotary_in_idx = 4d_arr_rx(3)
  879.                         Inhe_rotary_in_val(1) = 4d_arr_rx(4)
  880.                         Inhe_rotary_in_val(2) = 4d_arr_rx(5)
  881.                         #if Other_debug_port
  882.                            Print #debug_port , "Inhe_rotary_in"
  883.                         #else
  884.                            Debug "Inhe_rotary_in"
  885.                         #endif
  886.                         Case Int_switch:                    '58 This object is only available for Diablo16 and Pixxi
  887.                         Int_switch_idx = 4d_arr_rx(3)
  888.                         Int_switch_val(1) = 4d_arr_rx(4)
  889.                         Int_switch_val(2) = 4d_arr_rx(5)
  890.                         #if Other_debug_port
  891.                            Print #debug_port , "Int_switch"
  892.                         #else
  893.                            Debug "Int_switch"
  894.                         #endif
  895.                         Case Inhe_switchb:                  '59 This object is only available for Diablo16 and Pixxi (flash-mode)
  896.                         Inhe_switchb_idx = 4d_arr_rx(3)
  897.                         Inhe_switchb_val(1) = 4d_arr_rx(4)
  898.                         Inhe_switchb_val(2) = 4d_arr_rx(5)
  899.                         #if Other_debug_port
  900.                            Print #debug_port , "Inhe_switchb"
  901.                         #else
  902.                            Debug "Inhe_switchb"
  903.                         #endif
  904.                         Case Int_slidere:                   '60 This object is only available for Diablo16 and Pixxi
  905.                         Int_slidere_idx = 4d_arr_rx(3)
  906.                         Int_slidere_val(1) = 4d_arr_rx(4)
  907.                         Int_slidere_val(2) = 4d_arr_rx(5)
  908.                         #if Other_debug_port
  909.                            Print #debug_port , "Int_slidere"
  910.                         #else
  911.                            Debug "Int_slidere"
  912.                         #endif
  913.                         Case Inhe_media_slider:             '61 This object is only available for Diablo16 and Pixxi (flash-mode)
  914.                         Inhe_media_slider_idx = 4d_arr_rx(3)
  915.                         Inhe_media_slider_val(1) = 4d_arr_rx(4)
  916.                         Inhe_media_slider_val(2) = 4d_arr_rx(5)
  917.                         #if Other_debug_port
  918.                            Print #debug_port , "Inhe_media_slider"
  919.                         #else
  920.                            Debug "Inhe_media_slider"
  921.                         #endif
  922.                         Case Inhe_sliderh:                  '62 This object is only available for Diablo16 and Pixxi (flash-mode)
  923.                         Inhe_sliderh_idx = 4d_arr_rx(3)
  924.                         Inhe_sliderh_val(1) = 4d_arr_rx(4)
  925.                         Inhe_sliderh_val(2) = 4d_arr_rx(5)
  926.                         #if Other_debug_port
  927.                            Print #debug_port , "Inhe_slider_h"
  928.                         #else
  929.                            Debug "Inhe_slider_h"
  930.                         #endif
  931.                         Case Inhe_sliderg:                  '63 This object is only available for Diablo16 and Pixxi (flash-mode)
  932.                         Inhe_sliderg_idx = 4d_arr_rx(3)
  933.                         Inhe_sliderg_val(1) = 4d_arr_rx(4)
  934.                         Inhe_sliderg_val(2) = 4d_arr_rx(5)
  935.                         #if Other_debug_port
  936.                            Print #debug_port , "Inhe_slider_g"
  937.                         #else
  938.                            Debug "Inhe_slider_g"
  939.                         #endif
  940.                         Case Inhe_sliderf:                  '64 This object is only available for Diablo16 and Pixxi (flash-mode)
  941.                         Inhe_sliderf_idx = 4d_arr_rx(3)
  942.                         Inhe_sliderf_val(1) = 4d_arr_rx(4)
  943.                         Inhe_sliderf_val(2) = 4d_arr_rx(5)
  944.                         #if Other_debug_port
  945.                            Print #debug_port , "Inhe_slider_f"
  946.                         #else
  947.                            Debug "Inhe_slider_f"
  948.                         #endif
  949.                         Case Inhe_sliderd:                  '65 This object is only available for Diablo16 and Pixxi (flash-mode)
  950.                         Inhe_sliderd_idx = 4d_arr_rx(3)
  951.                         Inhe_sliderd_val(1) = 4d_arr_rx(4)
  952.                         Inhe_sliderd_val(2) = 4d_arr_rx(5)
  953.                         #if Other_debug_port
  954.                            Print #debug_port , "Inhe_slider_d"
  955.                         #else
  956.                            Debug "Inhe_slider_d"
  957.                         #endif
  958.                         Case Inhe_sliderc:                  '66 This Object Is Only Available For Diablo16 And Pixxi(flash -mode)
  959.                         Inhe_sliderc_idx = 4d_arr_rx(3)
  960.                         Inhe_sliderc_val(1) = 4d_arr_rx(4)
  961.                         Inhe_sliderc_val(2) = 4d_arr_rx(5)
  962.                         #if Other_debug_port
  963.                            Print #debug_port , "Inhe_slider_c"
  964.                         #else
  965.                            Debug "Inhe_slider_c"
  966.                         #endif
  967.                         Case Inhe_linear_in:                '67 This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  968.                         Inhe_linear_in_idx = 4d_arr_rx(3)
  969.                         Inhe_linear_in_val(1) = 4d_arr_rx(4)
  970.                         Inhe_linear_in_val(2) = 4d_arr_rx(5)
  971.                         #if Other_debug_port
  972.                            Print #debug_port , "Inhe_linear_in"
  973.                         #else
  974.                            Debug "Inhe_linear_in"
  975.                         #endif
  976.                      #endif
  977.                   Case Else:
  978.                   'This should never happen as CRC being check before select case
  979.                   'But lets keep this here just in case.
  980.                      #if Other_debug_port
  981.                         Print #debug_port , "Event report wrong ID: " ; 4d_arr_rx(3)
  982.                      #else
  983.                         Debug "Event report wrong ID: " ; 4d_arr_rx(3)
  984.                      #endif
  985.                      'Clear Serialin4
  986.                      #if Other_debug_port
  987.                         Print #debug_port , "S_pace: " ; S_pace
  988.                         Print #debug_port , "frame error"
  989.                      #else
  990.                         Debug "S_pace: " ; S_pace
  991.                         Debug "frame error"
  992.                      #endif
  993.                End Select
  994.             Else
  995.                Printbin #lcd_4d , &H15                      'send NACK message to the display
  996.                #if Other_debug_port
  997.                   Print #debug_port , "Read object CRC error !"
  998.                #else
  999.                   Debug "Read object CRC error !"
  1000.                #endif
  1001.             End If
  1002.          '**********************************************************************
  1003.          Case A_ck:                                         '&H06    ACK command
  1004.             Ack_nack_flag = 0                               'reset ack flag
  1005.             #if Other_debug_port
  1006.                Print #debug_port , "ACK"                    'print ACK message to debug port
  1007.             #else
  1008.                Debug "ACK"                                  'print ACK message to debug port
  1009.             #endif
  1010.          '**********************************************************************
  1011.          Case Report_event:                                 '&H07
  1012.             Inputbin #lcd_4d , 4d_arr_rx(2) , 5             ' get next 5 bytes from the buffer
  1013.             Xor_crc = Xor_this(4d_arr_rx(1))                ' check the crc
  1014.             If 4d_arr_rx(6) = Xor_crc Then                  'if crc ok then check what came
  1015.                Select Case 4d_arr_rx(2)                     'object ID
  1016.                   Case Dipswitch:                           '0
  1017.                      Dipswitch_idx = 4d_arr_rx(3)
  1018.                      Dipswitch_val(1) = 4d_arr_rx(4)
  1019.                      Dipswitch_val(2) = 4d_arr_rx(5)
  1020.                      #if Other_debug_port                   'If other uart used for the debug
  1021.                         Print #debug_port , "Dipswitch"
  1022.                      #else
  1023.                         Debug "Dipswitch"
  1024.                      #endif
  1025.                   Case Knob:                                '1
  1026.                      Knob_idx = 4d_arr_rx(3)
  1027.                      Knob_val(1) = 4d_arr_rx(4)
  1028.                      Knob_val(2) = 4d_arr_rx(5)
  1029.                      #if Other_debug_port
  1030.                         Print #debug_port , "Knob"
  1031.                      #else
  1032.                         Debug "Knob"
  1033.                      #endif
  1034.                   Case Rockerswitch:                        '2
  1035.                      Rockerswitch_idx = 4d_arr_rx(3)
  1036.                      Rockerswitch_val(1) = 4d_arr_rx(4)
  1037.                      Rockerswitch_val(2) = 4d_arr_rx(5)
  1038.                      #if Other_debug_port
  1039.                         Print #debug_port , "Rockerswitch"
  1040.                      #else
  1041.                         Debug "Rockerswitch"
  1042.                      #endif
  1043.                   Case Rotaryswitch:                        '3
  1044.                      Rotaryswitch_idx = 4d_arr_rx(3)
  1045.                      Rotaryswitch_val(1) = 4d_arr_rx(4)
  1046.                      Rotaryswitch_val(2) = 4d_arr_rx(5)
  1047.                      #if Other_debug_port
  1048.                         Print #debug_port , "Rotaryswitch"
  1049.                      #else
  1050.                         Debug "Rotaryswitch"
  1051.                      #endif
  1052.                   Case Slider:                              '4
  1053.                      Slider_idx = 4d_arr_rx(3)
  1054.                      Slider_val(1) = 4d_arr_rx(4)
  1055.                      Slider_val(2) = 4d_arr_rx(5)
  1056.                      #if Other_debug_port
  1057.                         Print #debug_port , "Slider"
  1058.                      #else
  1059.                         Debug "Slider"
  1060.                      #endif
  1061.                   Case Trackbar:                            '5
  1062.                      Trackbar_idx = 4d_arr_rx(3)
  1063.                      Trackbar_val(1) = 4d_arr_rx(4)
  1064.                      Trackbar_val(2) = 4d_arr_rx(5)
  1065.                      #if Other_debug_port
  1066.                         Print #debug_port , "Trackbar"
  1067.                      #else
  1068.                         Debug "Trackbar"
  1069.                      #endif
  1070.                   Case Winbutton:                           '6
  1071.                      Winbutton_idx = 4d_arr_rx(3)
  1072.                      Winbutton_val(1) = 4d_arr_rx(4)
  1073.                      Winbutton_val(2) = 4d_arr_rx(5)
  1074.                      #if Other_debug_port
  1075.                         Print #debug_port , "Winbutton"
  1076.                      #else
  1077.                         Debug "Winbutton"
  1078.                      #endif
  1079.                   Case Angularmeter:                        '7
  1080.                      Angularmeter_idx = 4d_arr_rx(3)
  1081.                      Angularmeter_val(1) = 4d_arr_rx(4)
  1082.                      Angularmeter_val(2) = 4d_arr_rx(5)
  1083.                      #if Other_debug_port
  1084.                         Print #debug_port , "Angularmeter"
  1085.                      #else
  1086.                         Debug "Angularmeter"
  1087.                      #endif
  1088.                   Case Coolgauge:                           '8
  1089.                      Coolgauge_idx = 4d_arr_rx(3)
  1090.                      Coolgauge_val(1) = 4d_arr_rx(4)
  1091.                      Coolgauge_val(2) = 4d_arr_rx(5)
  1092.                      #if Other_debug_port
  1093.                         Print #debug_port , "Coolgauge"
  1094.                      #else
  1095.                         Debug "Coolgauge"
  1096.                      #endif
  1097.                   Case Customdigits:                        '9
  1098.                      Customdigits_idx = 4d_arr_rx(3)
  1099.                      Customdigits_val(1) = 4d_arr_rx(4)
  1100.                      Customdigits_val(2) = 4d_arr_rx(5)
  1101.                      #if Other_debug_port
  1102.                         Print #debug_port , "Customdigits"
  1103.                      #else
  1104.                         Debug "Customdigits"
  1105.                      #endif
  1106.                   Case Form:                                '10
  1107.                      Form_idx = 4d_arr_rx(3)
  1108.                      Form_val(1) = 4d_arr_rx(4)
  1109.                      Form_val(2) = 4d_arr_rx(5)
  1110.                      #if Other_debug_port
  1111.                         Print #debug_port , "Form"
  1112.                      #else
  1113.                         Debug "Form"
  1114.                      #endif
  1115.                   Case Gauge:                                '11
  1116.                      Gauge_idx = 4d_arr_rx(3)
  1117.                      Gauge_val(1) = 4d_arr_rx(4)
  1118.                      Gauge_val(2) = 4d_arr_rx(5)
  1119.                      #if Other_debug_port
  1120.                         Print #debug_port , "Gauge"
  1121.                      #else
  1122.                         Debug "Gauge"
  1123.                      #endif
  1124.                   Case Image:                               '12
  1125.                   'Image_idx = 4d_arr_rx(3)
  1126.                   'Image_val(1) = 4d_arr_rx(4)
  1127.                   'Image_val(2) = 4d_arr_rx(5)
  1128.                      #if Other_debug_port
  1129.                         Print #debug_port , "Image"
  1130.                      #else
  1131.                         Debug "Image"
  1132.                      #endif
  1133.                   Case Keyboard:                            '13
  1134.                      Keyboard_idx = 4d_arr_rx(3)
  1135.                      Keyboard_val(1) = 4d_arr_rx(4)
  1136.                      Keyboard_val(2) = 4d_arr_rx(5)
  1137.                      #if Other_debug_port
  1138.                         Print #debug_port , "Keyboard"
  1139.                      #else
  1140.                         Debug "Keyboard"
  1141.                      #endif
  1142.                   Case Led:                                 '14
  1143.                      Led_idx = 4d_arr_rx(3)
  1144.                      Led_val(1) = 4d_arr_rx(4)
  1145.                      Led_val(2) = 4d_arr_rx(5)
  1146.                      #if Other_debug_port
  1147.                         Print #debug_port , "Led"
  1148.                      #else
  1149.                         Debug "Led"
  1150.                      #endif
  1151.                   Case Leddigits:                           '15
  1152.                      Leddigits_idx = 4d_arr_rx(3)
  1153.                      Leddigits_val(1) = 4d_arr_rx(4)
  1154.                      Leddigits_val(2) = 4d_arr_rx(5)
  1155.                      #if Other_debug_port
  1156.                         Print #debug_port , "Leddigits"
  1157.                      #else
  1158.                         Debug "Leddigits"
  1159.                      #endif
  1160.                   Case Meter:                               '16
  1161.                      Meter_idx = 4d_arr_rx(3)
  1162.                      Meter_val(1) = 4d_arr_rx(4)
  1163.                      Meter_val(2) = 4d_arr_rx(5)
  1164.                      #if Other_debug_port
  1165.                         Print #debug_port , "Meter"
  1166.                      #else
  1167.                         Debug "Meter"
  1168.                      #endif
  1169.                   Case Strings:                             '17
  1170.                      Strings_idx = 4d_arr_rx(3)
  1171.                      Strings_val(1) = 4d_arr_rx(4)
  1172.                      Strings_val(2) = 4d_arr_rx(5)
  1173.                      #if Other_debug_port
  1174.                         Print #debug_port , "Strings"
  1175.                      #else
  1176.                         Debug "Strings"
  1177.                      #endif
  1178.                   Case Thermometer:                         '18
  1179.                      Thermometer_idx = 4d_arr_rx(3)
  1180.                      Thermometer_val(1) = 4d_arr_rx(4)
  1181.                      Thermometer_val(2) = 4d_arr_rx(5)
  1182.                      #if Other_debug_port
  1183.                         Print #debug_port , "Thermometer"
  1184.                      #else
  1185.                         Debug "Thermometer"
  1186.                      #endif
  1187.                   Case Userled:                             '19
  1188.                      Userled_idx = 4d_arr_rx(3)
  1189.                      Userled_val(1) = 4d_arr_rx(4)
  1190.                      Userled_val(2) = 4d_arr_rx(5)
  1191.  
  1192.                      #if Other_debug_port
  1193.                         Print #debug_port , "Userled"
  1194.                      #else
  1195.                         Debug "Userled"
  1196.                      #endif
  1197.                   Case Video:                               '20
  1198.                      Video_idx = 4d_arr_rx(3)
  1199.                      Video_val(1) = 4d_arr_rx(4)
  1200.                      Video_val(2) = 4d_arr_rx(5)
  1201.                      #if Other_debug_port
  1202.                         Print #debug_port , "Video"
  1203.                      #else
  1204.                         Debug "Video"
  1205.                      #endif
  1206.                   Case Statictext:                          '21
  1207.                   'Statictext_idx = 4d_arr_rx(3)
  1208.                   'Statictext_val(1) = 4d_arr_rx(4)
  1209.                   'Statictext_val(2) = 4d_arr_rx(5)
  1210.                      #if Other_debug_port
  1211.                         Print #debug_port , "Statictext"
  1212.                      #else
  1213.                         Debug "Statictext"
  1214.                      #endif
  1215.                   Case S_ound:                              '22
  1216.                      S_ound_idx = 4d_arr_rx(3)
  1217.                      S_ound_val(1) = 4d_arr_rx(4)
  1218.                      S_ound_val(2) = 4d_arr_rx(5)
  1219.                      #if Other_debug_port
  1220.                         Print #debug_port , "S_ound"
  1221.                      #else
  1222.                         Debug "S_ound"
  1223.                      #endif
  1224.                   Case T_imer:                              '23
  1225.                      T_imer_idx = 4d_arr_rx(3)
  1226.                      T_imer_val(1) = 4d_arr_rx(4)
  1227.                      T_imer_val(2) = 4d_arr_rx(5)
  1228.                      #if Other_debug_port
  1229.                         Print #debug_port , "T_imer"
  1230.                      #else
  1231.                         Debug "T_imer"
  1232.                      #endif
  1233.                   Case Spectrum:                            '24
  1234.                      Spectrum_idx = 4d_arr_rx(3)
  1235.                      Spectrum_val(1) = 4d_arr_rx(4)
  1236.                      Spectrum_val(2) = 4d_arr_rx(5)
  1237.                      #if Other_debug_port
  1238.                         Print #debug_port , "Spectrum"
  1239.                      #else
  1240.                         Debug "Spectrum"
  1241.                      #endif
  1242.                   Case Scope:                               '25
  1243.                      Scope_idx = 4d_arr_rx(3)
  1244.                      Scope_val(1) = 4d_arr_rx(4)
  1245.                      Scope_val(2) = 4d_arr_rx(5)
  1246.                      #if Other_debug_port
  1247.                         Print #debug_port , "Scope"
  1248.                      #else
  1249.                         Debug "Scope"
  1250.                      #endif
  1251.                   Case Tank:                                '26
  1252.                      Tank_idx = 4d_arr_rx(3)
  1253.                      Tank_val(1) = 4d_arr_rx(4)
  1254.                      Tank_val(2) = 4d_arr_rx(5)
  1255.                      #if Other_debug_port
  1256.                         Print #debug_port , "Tank"
  1257.                      #else
  1258.                         Debug "Tank"
  1259.                      #endif
  1260.                   Case Userimages:                          '27
  1261.                      Userimages_idx = 4d_arr_rx(3)
  1262.                      Userimages_val(1) = 4d_arr_rx(4)
  1263.                      Userimages_val(2) = 4d_arr_rx(5)
  1264.                      #if Other_debug_port
  1265.                         Print #debug_port , "Userimages"
  1266.                      #else
  1267.                         Debug "Userimages"
  1268.                      #endif
  1269.                   Case Pinoutput:                           '28
  1270.                      Pinoutput_idx = 4d_arr_rx(3)
  1271.                   'Pinoutput_val(1) = 4d_arr_rx(4)
  1272.                      Pinoutput_val = 4d_arr_rx(5)
  1273.                      #if Other_debug_port
  1274.                         Print #debug_port , "Pinoutput"
  1275.                      #else
  1276.                         Debug "Pinoutput"
  1277.                      #endif
  1278.                   Case Pininput:                            '29
  1279.                      Pininput_idx = 4d_arr_rx(3)
  1280.                   'Pininput_val(1) = 4d_arr_rx(4)
  1281.                      Pininput_val = 4d_arr_rx(5)
  1282.                      #if Other_debug_port
  1283.                         Print #debug_port , "Pininput"
  1284.                      #else
  1285.                         Debug "Pininput"
  1286.                      #endif
  1287.                   Case 4dbutton:                            '30
  1288.                      4dbutton_idx = 4d_arr_rx(3)
  1289.                      4dbutton_val(1) = 4d_arr_rx(4)
  1290.                      4dbutton_val(2) = 4d_arr_rx(5)
  1291.                      #if Other_debug_port
  1292.                         Print #debug_port , "4dbutton"
  1293.                      #else
  1294.                         Debug "4dbutton"
  1295.                      #endif
  1296.                   Case Anibutton:                           '31
  1297.                      Anibutton_idx = 4d_arr_rx(3)
  1298.                      Anibutton_val(1) = 4d_arr_rx(4)
  1299.                      Anibutton_val(2) = 4d_arr_rx(5)
  1300.                      #if Other_debug_port
  1301.                         Print #debug_port , "Anibutton"
  1302.                      #else
  1303.                         Debug "Anibutton"
  1304.                      #endif
  1305.                   Case Colorpicker:                         '32
  1306.                      Colorpicker_idx = 4d_arr_rx(3)
  1307.                      Colorpicker_val(1) = 4d_arr_rx(4)
  1308.                      Colorpicker_val(2) = 4d_arr_rx(5)
  1309.                      #if Other_debug_port
  1310.                         Print #debug_port , "Colorpicker"
  1311.                      #else
  1312.                         Debug "Colorpicker"
  1313.                      #endif
  1314.                   Case Userbutton:                          '33
  1315.                      Userbutton_idx = 4d_arr_rx(3)
  1316.                      Userbutton_val(1) = 4d_arr_rx(4)
  1317.                      Userbutton_val(2) = 4d_arr_rx(5)
  1318.                      #if Other_debug_port
  1319.                         Print #debug_port , "Userbutton"
  1320.                      #else
  1321.                         Debug "Userbutton"
  1322.                      #endif
  1323.                   Case Magicobject:                         '34
  1324.                      Magicobject_idx = 4d_arr_rx(3)
  1325.                      Magicobject_val(1) = 4d_arr_rx(4)
  1326.                      Magicobject_val(2) = 4d_arr_rx(5)
  1327.                      #if Other_debug_port
  1328.                         Print #debug_port , "Magicobject"
  1329.                      #else
  1330.                         Debug "Magicobject"
  1331.                      #endif
  1332.                   Case Smartgauge:                          '35
  1333.                      Smartgauge_idx = 4d_arr_rx(3)
  1334.                      Smartgauge_val(1) = 4d_arr_rx(4)
  1335.                      Smartgauge_val(2) = 4d_arr_rx(5)
  1336.                      #if Other_debug_port
  1337.                         Print #debug_port , "Smartgauge"
  1338.                      #else
  1339.                         Debug "Smartgauge"
  1340.                      #endif
  1341.                   Case Smartslider:                         '36
  1342.                      Smartslider_idx = 4d_arr_rx(3)
  1343.                      Smartslider_val(1) = 4d_arr_rx(4)
  1344.                      Smartslider_val(2) = 4d_arr_rx(5)
  1345.                      #if Other_debug_port
  1346.                         Print #debug_port , "Smartslider"
  1347.                      #else
  1348.                         Debug "Smartslider"
  1349.                      #endif
  1350.                   Case Smartknob:                           '37
  1351.                      Smartknob_idx = 4d_arr_rx(3)
  1352.                      Smartknob_val(1) = 4d_arr_rx(4)
  1353.                      Smartknob_val(2) = 4d_arr_rx(5)
  1354.                      #if Other_debug_port
  1355.                         Print #debug_port , "Smartknob"
  1356.                      #else
  1357.                         Debug "Smartknob"
  1358.                      #endif
  1359. '*******************************************************************************
  1360. '*********************************New Pixxi or diablo16*************************
  1361.                      #if Use_pixxi_diablo16
  1362.                         Case Int_leddigitsh:                '38 This object is only available for Diablo16 and Pixxi
  1363.                         Int_leddigitsh_idx = 4d_arr_rx(3)
  1364.                         Int_leddigitsh_val(1) = 4d_arr_rx(4)
  1365.                         Int_leddigitsh_val(2) = 4d_arr_rx(5)
  1366.                         #if Other_debug_port
  1367.                            Print #debug_port , "Int_leddigitsh"
  1368.                         #else
  1369.                            Debug "Int_leddigitsh "
  1370.                         #endif
  1371.                         Case Int_angular_meter:             '39 This object is only available for Diablo16 and Pixxi
  1372.                         Int_angular_meter_idx = 4d_arr_rx(3)
  1373.                         Int_angular_meter_val(1) = 4d_arr_rx(4)
  1374.                         Int_angular_meter_val(2) = 4d_arr_rx(5)
  1375.  
  1376.                         #if Other_debug_port
  1377.                            Print #debug_port , "Int_angular_meter"
  1378.                         #else
  1379.                            Debug "Int_angular_meter "
  1380.                         #endif
  1381.                         Case Int_gauge:                      '40 This object is only available for Diablo16 and Pixxi
  1382.                         Int_gauge_idx = 4d_arr_rx(3)
  1383.                         Int_gauge_val(1) = 4d_arr_rx(4)
  1384.                         Int_gauge_val(2) = 4d_arr_rx(5)
  1385.                         #if Other_debug_port
  1386.                            Print #debug_port , "Int_gauge"
  1387.                         #else
  1388.                            Debug "Int_gauge"
  1389.                         #endif
  1390.                         Case Inhe_label:                    '41 This object is only available for Diablo16 and Pixxi (flash-mode)
  1391.                         Inhe_label_idx = 4d_arr_rx(3)
  1392.                         Inhe_label_val(1) = 4d_arr_rx(4)
  1393.                         Inhe_label_val(2) = 4d_arr_rx(5)
  1394.                         #if Other_debug_port
  1395.                            Print #debug_port , "Inhe_label"
  1396.                         #else
  1397.                            Debug "Inhe_label"
  1398.                         #endif
  1399.                         Case Inhe_user_gauge:               '42 This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  1400.                         Inhe_user_gauge_idx = 4d_arr_rx(3)
  1401.                         Inhe_user_gauge_val(1) = 4d_arr_rx(4)
  1402.                         Inhe_user_gauge_val(2) = 4d_arr_rx(5)
  1403.                         #if Other_debug_port
  1404.                            Print #debug_port , "Inhe_user_gauge"
  1405.                         #else
  1406.                            Debug "Inhe_user_gauge"
  1407.                         #endif
  1408.                         Case Inhe_media_gauge:              '43 This object is only available for Diablo16 and Pixxi (flash-mode)
  1409.                         Inhe_media_gauge_idx = 4d_arr_rx(3)
  1410.                         Inhe_media_gauge_val(1) = 4d_arr_rx(4)
  1411.                         Inhe_media_gauge_val(2) = 4d_arr_rx(5)
  1412.                         #if Other_debug_port
  1413.                            Print #debug_port , "Inhe_media_gauge"
  1414.                         #else
  1415.                            Debug "Inhe_media_gauge"
  1416.                         #endif
  1417.                         Case Inhe_media_thermometer:        '44 This object is only available for Diablo16 and Pixxi (flash-mode)
  1418.                         Inhe_media_thermometer_idx = 4d_arr_rx(3)
  1419.                         Inhe_media_thermometer_val(1) = 4d_arr_rx(4)
  1420.                         Inhe_media_thermometer_val(2) = 4d_arr_rx(5)
  1421.                         #if Other_debug_port
  1422.                            Print #debug_port , "Inhe_media_thermometer"
  1423.                         #else
  1424.                            Debug "Inhe_media_thermometer "
  1425.                         #endif
  1426.                         Case Int_led:                       '45 This object is only available for Diablo16 and Pixxi
  1427.                         Int_led_idx = 4d_arr_rx(3)
  1428.                         Int_led_val(1) = 4d_arr_rx(4)
  1429.                         Int_led_val(2) = 4d_arr_rx(5)
  1430.                         #if Other_debug_port
  1431.                            Print #debug_port , "Int_led"
  1432.                         #else
  1433.                            Debug "Int_led"
  1434.                         #endif
  1435.                         Case Inhe_media_led:                '46 This object is only available for Diablo16 and Pixxi (flash-mode)
  1436.                         Inhe_media_led_idx = 4d_arr_rx(3)
  1437.                         Inhe_media_led_val(1) = 4d_arr_rx(4)
  1438.                         Inhe_media_led_val(2) = 4d_arr_rx(5)
  1439.                         #if Other_debug_port
  1440.                            Print #debug_port , "Inhe_media_led"
  1441.                         #else
  1442.                            Debug "Inhe_media_led"
  1443.                         #endif
  1444.                         Case Int_leddigits:                 '47 This object is only available for Diablo16 and Pixxi
  1445.                         Int_leddigits_idx = 4d_arr_rx(3)
  1446.                         Int_leddigits_val(1) = 4d_arr_rx(4)
  1447.                         Int_leddigits_val(2) = 4d_arr_rx(5)
  1448.                         #if Other_debug_port
  1449.                            Print #debug_port , "Int_leddigits"
  1450.                         #else
  1451.                            Debug "Int_leddigits"
  1452.                         #endif
  1453.                         Case Int_needle:                    '48 This object is only available for Diablo16 and Pixxi
  1454.                         Int_needle_idx = 4d_arr_rx(3)
  1455.                         Int_needle_val(1) = 4d_arr_rx(4)
  1456.                         Int_needle_val(2) = 4d_arr_rx(5)
  1457.                         #if Other_debug_port
  1458.                            Print #debug_port , "Int_needle"
  1459.                         #else
  1460.                            Debug "Int_needle"
  1461.                         #endif
  1462.                         Case Int_ruler_gauge:               '49 This object is only available for Diablo16 and Pixx
  1463.                         Int_ruler_gauge_idx = 4d_arr_rx(3)
  1464.                         Int_ruler_gauge_val(1) = 4d_arr_rx(4)
  1465.                         Int_ruler_gauge_val(2) = 4d_arr_rx(5)
  1466.                         #if Other_debug_port
  1467.                            Print #debug_port , "Int_ruler_gauge"
  1468.                         #else
  1469.                            Debug "Int_ruler_gauge"
  1470.                         #endif
  1471.                         Case Int_leddigit:                  '50 This object is only available for Diablo16 and Pixxi
  1472.                         Int_leddigit_idx = 4d_arr_rx(3)
  1473.                         Int_leddigit_val(1) = 4d_arr_rx(4)
  1474.                         Int_leddigit_val(2) = 4d_arr_rx(5)
  1475.                         #if Other_debug_port
  1476.                            Print #debug_port , "Int_leddigit"
  1477.                         #else
  1478.                            Debug "Int_leddigit"
  1479.                         #endif
  1480.                         Case Int_buttond:                   '51 This object is only available for Diablo16 and Pixxi
  1481.                         Int_buttond_idx = 4d_arr_rx(3)
  1482.                         Int_buttond_val(1) = 4d_arr_rx(4)
  1483.                         Int_buttond_val(2) = 4d_arr_rx(5)
  1484.                         #if Other_debug_port
  1485.                            Print #debug_port , "Int_buttond"
  1486.                         #else
  1487.                            Debug "Int_buttond"
  1488.                         #endif
  1489.                         Case Inhe_buttone:                  '52 This object is only available for Diablo16 and Pixxi (flash-mode)
  1490.                         Inhe_buttone_idx = 4d_arr_rx(3)
  1491.                         Inhe_buttone_val(1) = 4d_arr_rx(4)
  1492.                         Inhe_buttone_val(2) = 4d_arr_rx(5)
  1493.                         #if Other_debug_port
  1494.                            Print #debug_port , "Inhe_buttone"
  1495.                         #else
  1496.                            Debug "Inhe_buttone"
  1497.                         #endif
  1498.                         Case Inhe_media_button:             '53 This object is only available for Diablo16 and Pixxi (flash-mode)
  1499.                         Inhe_media_idx = 4d_arr_rx(3)
  1500.                         Inhe_media_button_val(1) = 4d_arr_rx(4)
  1501.                         Inhe_media_button_val(2) = 4d_arr_rx(5)
  1502.                         #if Other_debug_port
  1503.                            Print #debug_port , "Inhe_media_button"
  1504.                         #else
  1505.                            Debug "Inhe_media_button"
  1506.                         #endif
  1507.                         Case Inhe_toggle_in:                '54 This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  1508.                         Inhe_toggle_idx = 4d_arr_rx(3)
  1509.                         Inhe_toggle_in_val(1) = 4d_arr_rx(4)
  1510.                         Inhe_toggle_in_val(2) = 4d_arr_rx(5)
  1511.                         #if Other_debug_port
  1512.                            Print #debug_port , "Inhe_toggle_in"
  1513.                         #else
  1514.                            Debug "Inhe_toggle_in"
  1515.                         #endif
  1516.                         Case Int_dial:                      '55 This object is only available for Diablo16 and Pixxi
  1517.                         Int_dial_idx = 4d_arr_rx(3)
  1518.                         Int_dial_val(1) = 4d_arr_rx(4)
  1519.                         Int_dial_val(2) = 4d_arr_rx(5)
  1520.                         #if Other_debug_port
  1521.                            Print #debug_port , "Int_dial"
  1522.                         #else
  1523.                            Debug "Int_dial"
  1524.                         #endif
  1525.                         Case Inhe_media_rotary:             '56 This object is only available for Diablo16 and Pixxi (flash-mode)
  1526.                         Inhe_media_rotary_idx = 4d_arr_rx(3)
  1527.                         Inhe_media_rotary_val(1) = 4d_arr_rx(4)
  1528.                         Inhe_media_rotary_val(2) = 4d_arr_rx(5)
  1529.                         #if Other_debug_port
  1530.                            Print #debug_port , "Inhe_media_rotary"
  1531.                         #else
  1532.                            Debug "Inhe_media_rotary"
  1533.                         #endif
  1534.                         Case Inhe_rotary_in:                '57 This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  1535.                         Inhe_rotary_in_idx = 4d_arr_rx(3)
  1536.                         Inhe_rotary_in_val(1) = 4d_arr_rx(4)
  1537.                         Inhe_rotary_in_val(2) = 4d_arr_rx(5)
  1538.                         #if Other_debug_port
  1539.                            Print #debug_port , "Inhe_rotary_in"
  1540.                         #else
  1541.                            Debug "Inhe_rotary_in"
  1542.                         #endif
  1543.                         Case Int_switch:                    '58 This object is only available for Diablo16 and Pixxi
  1544.                         Int_switch_idx = 4d_arr_rx(3)
  1545.                         Int_switch_val(1) = 4d_arr_rx(4)
  1546.                         Int_switch_val(2) = 4d_arr_rx(5)
  1547.                         #if Other_debug_port
  1548.                            Print #debug_port , "Int_switch"
  1549.                         #else
  1550.                            Debug "Int_switch"
  1551.                         #endif
  1552.                         Case Inhe_switchb:                  '59 This object is only available for Diablo16 and Pixxi (flash-mode)
  1553.                         Inhe_switchb_idx = 4d_arr_rx(3)
  1554.                         Inhe_switchb_val(1) = 4d_arr_rx(4)
  1555.                         Inhe_switchb_val(2) = 4d_arr_rx(5)
  1556.                         #if Other_debug_port
  1557.                            Print #debug_port , "Inhe_switchb"
  1558.                         #else
  1559.                            Debug "Inhe_switchb"
  1560.                         #endif
  1561.                         Case Int_slidere:                    '60 This object is only available for Diablo16 and Pixxi
  1562.                         Int_slidere_idx = 4d_arr_rx(3)
  1563.                         Int_slidere_val(1) = 4d_arr_rx(4)
  1564.                         Int_slidere_val(2) = 4d_arr_rx(5)
  1565.                         #if Other_debug_port
  1566.                            Print #debug_port , "Int_slidere"
  1567.                         #else
  1568.                            Debug "Int_slidere"
  1569.                         #endif
  1570.                         Case Inhe_media_slider:             '61 This object is only available for Diablo16 and Pixxi (flash-mode)
  1571.                         Inhe_media_slider_idx = 4d_arr_rx(3)
  1572.                         Inhe_media_slider_val(1) = 4d_arr_rx(4)
  1573.                         Inhe_media_slider_val(2) = 4d_arr_rx(5)
  1574.                         #if Other_debug_port
  1575.                            Print #debug_port , "Inhe_media_slider"
  1576.                         #else
  1577.                            Debug "Inhe_media_slider"
  1578.                         #endif
  1579.                         Case Inhe_sliderh:                  '62 This object is only available for Diablo16 and Pixxi (flash-mode)
  1580.                         Inhe_sliderh_idx = 4d_arr_rx(3)
  1581.                         Inhe_sliderh_val(1) = 4d_arr_rx(4)
  1582.                         Inhe_sliderh_val(2) = 4d_arr_rx(5)
  1583.                         #if Other_debug_port
  1584.                            Print #debug_port , "Inhe_slider_h"
  1585.                         #else
  1586.                            Debug "Inhe_slider_h"
  1587.                         #endif
  1588.                         Case Inhe_sliderg:                  '63 This object is only available for Diablo16 and Pixxi (flash-mode)
  1589.                         Inhe_sliderg_idx = 4d_arr_rx(3)
  1590.                         Inhe_sliderg_val(1) = 4d_arr_rx(4)
  1591.                         Inhe_sliderg_val(2) = 4d_arr_rx(5)
  1592.                         #if Other_debug_port
  1593.                            Print #debug_port , "Inhe_slider_g"
  1594.                         #else
  1595.                            Debug "Inhe_slider_g"
  1596.                         #endif
  1597.                         Case Inhe_sliderf:                  '64 This object is only available for Diablo16 and Pixxi (flash-mode)
  1598.                         Inhe_sliderf_idx = 4d_arr_rx(3)
  1599.                         Inhe_sliderf_val(1) = 4d_arr_rx(4)
  1600.                         Inhe_sliderf_val(2) = 4d_arr_rx(5)
  1601.                         #if Other_debug_port
  1602.                            Print #debug_port , "Inhe_slider_f"
  1603.                         #else
  1604.                            Debug "Inhe_slider_f"
  1605.                         #endif
  1606.                         Case Inhe_sliderd:                  '65 This object is only available for Diablo16 and Pixxi (flash-mode)
  1607.                         Inhe_sliderd_idx = 4d_arr_rx(3)
  1608.                         Inhe_sliderd_val(1) = 4d_arr_rx(4)
  1609.                         Inhe_sliderd_val(2) = 4d_arr_rx(5)
  1610.                         #if Other_debug_port
  1611.                            Print #debug_port , "Inhe_slider_d"
  1612.                         #else
  1613.                            Debug "Inhe_slider_d"
  1614.                         #endif
  1615.                         Case Inhe_sliderc:                  '66 This Object Is Only Available For Diablo16 And Pixxi(flash -mode)
  1616.                         Inhe_sliderc_idx = 4d_arr_rx(3)
  1617.                         Inhe_sliderc_val(1) = 4d_arr_rx(4)
  1618.                         Inhe_sliderc_val(2) = 4d_arr_rx(5)
  1619.                         #if Other_debug_port
  1620.                            Print #debug_port , "Inhe_slider_c"
  1621.                         #else
  1622.                            Debug "Inhe_slider_c"
  1623.                         #endif
  1624.                         Case Inhe_linear_in:                '67 This object is only available with Workshop4 PRO for Diablo16 and Pixxi (flash-mode)
  1625.                         Inhe_linear_in_idx = 4d_arr_rx(3)
  1626.                         Inhe_linear_in_val(1) = 4d_arr_rx(4)
  1627.                         Inhe_linear_in_val(2) = 4d_arr_rx(5)
  1628.                         #if Other_debug_port
  1629.                            Print #debug_port , "Inhe_linear_in"
  1630.                         #else
  1631.                            Debug "Inhe_linear_in"
  1632.                         #endif
  1633.                      #endif
  1634.                   Case Else:
  1635.                     'This should never happen as CRC being check before select case
  1636.                   'But lets keep this here just in case.
  1637.                      #if Other_debug_port
  1638.                         Print #debug_port , "Event report wrong ID: " ; 4d_arr_rx(3)
  1639.                      #else
  1640.                         Debug "Event report wrong ID: " ; 4d_arr_rx(3)
  1641.                      #endif
  1642.                      'Clear Serialin4
  1643.  
  1644.                      #if Other_debug_port
  1645.                         Print #debug_port , "S_pace: " ; S_pace
  1646.                         Print #debug_port , "frame error"
  1647.                      #else
  1648.                         Debug "S_pace: " ; S_pace
  1649.                         Debug "frame error"
  1650.                      #endif
  1651.                End Select
  1652.             Else
  1653.                Printbin #lcd_4d , &H15                     'send NACK message to the display
  1654.                #if Other_debug_port
  1655.                   Print #debug_port , "Read object CRC error !"
  1656.                #else
  1657.                   Debug "Read object CRC error !"
  1658.                #endif
  1659.             End If
  1660.          '**********************************************************************
  1661.          Case Nak:
  1662.             #if Other_debug_port
  1663.                Print #debug_port , "NACK"                         '&h15  NAK  command
  1664.             #else
  1665.                Debug "NACK"                                    '&h15 NAK command
  1666.             #endif
  1667.             Ack_nack_flag.1 = 1                             'set ACK/NACK flag
  1668.            'Clear Serialin4
  1669.          '**********************************************************************
  1670.          Case Else:
  1671.             #if Other_debug_port
  1672.                Print #debug_port , "Error in Code =: " ; 4d_arr_rx(1)
  1673.             #else
  1674.                Debug "Error in Code =: " ; 4d_arr_rx(1)
  1675.             #endif
  1676.             'Clear Serialin4                                 'uncomment this if you using different port for debugging then 0 and change the port number
  1677.             #if Other_debug_port
  1678.                Print #debug_port , "frame error"
  1679.             #else
  1680.                Debug "frame error"
  1681.             #endif
  1682.       End Select
  1683.    Wend
  1684. End Sub
  1685. '*******************************************************************************
  1686. '###############################################################################
  1687. '*************************SUB for checking the UART ****************************
  1688. 'This should be a function not a sub but waiting for the function result is taking way to long.
  1689. 'call this sub to get values of the object from the display
  1690. Sub 4d_read_obj(byval 4d_object_id As Byte , Byval 4d_object_index As Byte )
  1691. '*******************************************************************************
  1692. 'Syntax: Call 4d_read_obj_sub(object_id &H0 to &H25, object index &H0 to &HFF  )
  1693. 'For more info refer to Visi Genie reference manual page 7 section 3.1.3.1
  1694. 'Global variable will be updated.
  1695. '*******************************************************************************
  1696.    'this should be a function
  1697.    4d_arr_tx(1) = Write_obj                                 '&h00 constant
  1698.    4d_arr_tx(2) = 4d_object_id                              'object ID as per constants
  1699.    4d_arr_tx(3) = 4d_object_index                           'object index
  1700.    Xor_crc = 4d_arr_tx(1) Xor 4d_arr_tx(2)                  'calculate the xor check sum
  1701.    Xor_crc = Xor_crc Xor 4d_arr_tx(3)
  1702.    4d_arr_tx(4) = Xor_crc
  1703.    Printbin #lcd_4d , 4d_arr_tx(1) ; 4                      'print binary  the final result
  1704.    Ack_nack_flag.0 = 1                                      'any response starting with 05 should clear this flag.
  1705.    While Ack_nack_flag <> 0                                 'while waiting for response from the display
  1706.       Incr 4d_wait_count                                    'just to indicate how long will this take
  1707.       Call 4d_uart_rx                                       'check the Uart
  1708.       If Ack_nack_flag.0 = 0 And Ack_nack_flag.1 = 1 Then
  1709.          Printbin #lcd_4d , 4d_arr_tx(1) ; 4                'repeat previous transmission
  1710.          Ack_nack_flag.0 = 1                                'any response starting with 05 should clear this flag.
  1711.          Ack_nack_flag.1 = 0
  1712.       End If                                                'this flag is clear by NACK command therefore
  1713.    Wend
  1714.    #if Other_debug_port
  1715.       Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
  1716.    #else
  1717.       Debug "Waiting for the response counter: " ; 4d_wait_count
  1718.    #endif
  1719.    4d_wait_count = 0
  1720.   'The response from the display should be Report_obj: &h05
  1721. End Sub
  1722. '******************************************************************************
  1723. '*******************************************************************************
  1724. Dim Fifo_head As Byte                                       'index plus data
  1725. Dim Fifo_tail As Byte                                       'index plus data
  1726. Fifo_head = 0
  1727. Fifo_tail = 0
  1728. Dim Fifo_tmp(6) As Byte
  1729. 'Const Fifosize = 16
  1730. Dim Fifo_buffer(6 , 16) As Byte                             ' 16 arrays, 6 bytes long
  1731. 'Dim Fifo_idx As Byte
  1732. 'Dim Copy_val As Byte
  1733. 'Copy_val = 1
  1734. '*******************************************************************************
  1735. '*******************************************************************************
  1736. '###############################################################################
  1737. Sub Push_fifo(ar_pushf() As Byte )
  1738. 'Base on ollopa code from MCs forum:
  1739. 'https : / / www.mcselec.com / index2.phpPrint option = com_forum&Itemid = 59&page = viewtopic&t = 7941&highlight = fifo
  1740. 'Thank you MR Ollopa for sharing the idea !
  1741.    Local Copy_val_a As Byte
  1742.    Local Oldhead As Byte
  1743.    Oldhead = Fifo_head                                      '
  1744.    Incr Fifo_head
  1745.    If Fifo_head > Fifosize Then Fifo_head = 1
  1746.    If Fifo_head = Fifo_tail Then
  1747.       Fifo_head = Oldhead
  1748.    Else
  1749.       Copy_val_a = Memcopy(ar_pushf(1) , Fifo_buffer(1 , Fifo_head ) , 6 , 3)
  1750.       Print #debug_port , "push mem position= " ; Hex(varptr(fifo_buffer(1 , Fifo_head )))
  1751.    End If
  1752. End Sub
  1753. Function Pop_fifo() As Byte
  1754. 'Base on MR Ollopa code from MCs forum:
  1755. 'https : / / www.mcselec.com / index2.phpPrint option = com_forum&Itemid = 59&page = viewtopic&t = 7941&highlight = fifo
  1756. 'Thank you ollopa for sharing the idea !
  1757.    Local Copy_val_b As Byte
  1758.    Incr Tail
  1759.    Copy_val_b = Memcopy(fifo_buffer(1 , Fifo_tail ) , Fifo_tmp(1) , 6 , 3)
  1760.    #if Other_debug_port
  1761.       Print #debug_port , "pop mem position= " ; Hex(varptr(fifo_buffer(1 , Fifo_tail )))
  1762.    #else
  1763.       Debug "pop mem position= " ; Hex(varptr(fifo_buffer(1 , Fifo_tail )))
  1764.    #endif
  1765.    Pop_fifo(1) = Fifo_tmp(1)
  1766. End Function
  1767. '*******************************************************************************
  1768. '###############################################################################
  1769. Sub 4d_write_obj(byval 4d_object_id As Byte , Byval 4d_object_index As Byte , Byval 4d_obj_value As Word )
  1770. 'Dim 4d_helpa As Word At 4d_arr_tx(4) Overlay  'copy for clarity
  1771. '*******************************************************************************
  1772. 'Syntax: Call 4d_write_obj(object_id &H0 to &H25, object index &H0 to &HFF  , object value &h00 to &HFFFF )
  1773. 'For more info refer to Visi Genie reference manual page 8 section 3.1.3.2
  1774. '*******************************************************************************
  1775.    Swap 4d_obj_value                                        'little endian to big endian
  1776.    4d_helpa = 4d_obj_value                                  'assign to overlaid variable
  1777.    4d_arr_tx(1) = Write_obj                                 '&h01 constant
  1778.    4d_arr_tx(2) = 4d_object_id                              'object ID as per constants
  1779.    4d_arr_tx(3) = 4d_object_index                           'object index
  1780.    '4d_arr_tx(4) for clarity as this is overlay so the values are already there in global array
  1781.    '4d_arr_tx(5) for clarity as this is overlay so the values are already there in global array
  1782.    Xor_crc = 4d_arr_tx(1) Xor 4d_arr_tx(2)                  'calculate the xor check sum
  1783.    Xor_crc = Xor_crc Xor 4d_arr_tx(3)
  1784.    Xor_crc = Xor_crc Xor 4d_arr_tx(4)
  1785.    4d_arr_tx(6) = Xor_crc Xor 4d_arr_tx(5)
  1786.    Printbin #lcd_4d , 4d_arr_tx(1) ; 6                      'print binary  the final result
  1787.  
  1788.    #if Other_debug_port
  1789.       'Printbin #debug_port , 4d_arr_tx(1) ; 6                  'print binary  the final result to debug port
  1790.       Printbin #debug_port , "Command code: " ; 4d_arr_tx(1)   'Debug print command code (should be 1)
  1791.       Printbin #debug_port , "Object ID: " ; 4d_arr_tx(2)      'Debug print object ID
  1792.       Printbin #debug_port , "Object index: " ; 4d_arr_tx(3)   'Debug print object index
  1793.       Printbin #debug_port , "Object value MSB: " ; 4d_arr_tx(4)       'Debug print object value MSB
  1794.       Printbin #debug_port , "Object value LSB: " ; 4d_arr_tx(5)       'Debug print object value LSB
  1795.       Printbin #debug_port , "CRC: " ; 4d_arr_tx(6)            'CRC
  1796.    #else
  1797.       Debug "Command code: " ; 4d_arr_tx(1)                    'Debug print command code (should be 1)
  1798.       Debug "Object ID: " ; 4d_arr_tx(2)                    'Debug print object ID
  1799.       Debug "Object index: " ; 4d_arr_tx(3)                    'Debug print object index
  1800.       Debug "Object value MSB: " ; 4d_arr_tx(4)                'Debug print object value MSB
  1801.       Debug "Object value LSB: " ; 4d_arr_tx(5)                'Debug print object value LSB
  1802.       Debug "CRC: " ; 4d_arr_tx(6)                             'CRC
  1803.    #endif
  1804.  
  1805.    Ack_nack_flag.0 = 1                                      'ACK flag set to busy
  1806. 'Two diffent ack_nack bit are used
  1807. ' after command is sent to the display the bit.0 is set.
  1808.    While Ack_nack_flag <> 0                                 'while waiting for response from the display
  1809.       Incr 4d_wait_count                                    'just to indicate how long will this take
  1810.       Call 4d_uart_rx                                       'check the Uart
  1811.       '
  1812.       If Ack_nack_flag.1 = 1 Then                           'NAK received from the display
  1813. 'if NACK is received the bit.0 is still set to 1
  1814. 'in addition the bit.1 is set.
  1815.          Printbin #lcd_4d , 4d_arr_tx(1) ; 6                     ' repeat previous transmission
  1816.          Ack_nack_flag.1 = 0                                     'Clear NACK flag and check again for ACK or NACK
  1817. 'the main ack bit.0 is still set
  1818. 'the command is sent again
  1819. 'ack.nac bit.1 is set to 0 temporary to check for correct ack command.
  1820. 'the correct ack command will clear all bits and sub will be finished.
  1821. 'time out will be added here later.
  1822.       End If
  1823.    Wend
  1824.    #if Other_debug_port
  1825.       Print #debug_port , "Waiting in the loop for the response counter: " ; 4d_wait_count
  1826.    #else
  1827.       Debug "Waiting in the loop for the response counter: " ; 4d_wait_count
  1828.    #endif
  1829.    4d_wait_count = 0
  1830. End Sub
  1831. '*******************************************************************************
  1832. '###############################################################################
  1833. Sub 4d_write_contrast(byval 4d_contrast_val As Byte)
  1834. '*******************************************************************************
  1835. 'Syntax: Call 4d_write_contrast(contrast value form 1 to 10  )
  1836. 'For more info refer to Visi Genie reference manual page 9 section 3.1.3.5
  1837. '*******************************************************************************
  1838.    If 4d_contrast_val => 10 Then
  1839.       4d_contrast_val = 10
  1840.    End If
  1841.    Dim 4d_contrast_tx(3) As Byte
  1842.    4d_contrast_tx(1) = Write_contrast
  1843.    4d_contrast_tx(2) = 4d_contrast_val
  1844.    4d_contrast_tx(3) = Write_contrast Xor 4d_contrast_val
  1845.    Printbin #lcd_4d , 4d_contrast_tx(1) ; 3
  1846.    Ack_nack_flag.0 = 1                                      'ACK flag set to busy
  1847.    While Ack_nack_flag <> 0                                 'while waiting for response from the display
  1848.       Incr 4d_wait_count                                    'just to indicate how long will this take
  1849.       Call 4d_uart_rx
  1850.                     'check the Uart
  1851.       If Ack_nack_flag.1 = 1 Then                           'NAK received from the display
  1852.          Printbin #lcd_4d , 4d_arr_tx(1) ; 3                ' repeat previous transmission
  1853.          Ack_nack_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  1854.       End If
  1855.    Wend
  1856.    #if Other_debug_port
  1857.       Print #debug_port , "Waiting for the response counter: " ; 4d_wait_count
  1858.    #else
  1859.       Debug "Waiting for the response counter: " ; 4d_wait_count
  1860.    #endif
  1861.    4d_wait_count = 0
  1862. End Sub
  1863.  
  1864. 'Sub 4d_write_str_old(byval 4d_str_indx As Byte , Byval 4d_string_tmp As String )
  1865. ''*******************************************************************************
  1866. ''Syntax: Call 4d_write_str_old(index hex value , "your text" )
  1867. ''The body of the command is:
  1868. ''comand_code+ string_index+ string_length + string + xorcrc
  1869. ''For more info refer to Visi Genie reference manual page 8 section 3.1.3.3
  1870. ''*******************************************************************************
  1871.   ' Local Index_help_a As Byte                               'used to calculate the length of the string
  1872.    'Dim Tot_command_len As Byte                              'total command length
  1873.    'Tot_command_len = Len(4d_string_tmp) + 4                 'total = string + string length byte + command byte + string index byte used for calculating crc
  1874.    'Print #debug_port , "total command length =" ; Tot_command_len
  1875.    '4d_string_tx = 4d_string_tmp                             'copy the string in to variable overlaid at array
  1876.    '4d_string_tx_arr(1) = Write_str                          '&h02 write string command
  1877.    '4d_string_tx_arr(2) = 4d_str_indx                        'index of the string
  1878.    '4d_string_tx_arr(3) = Len(4d_string_tmp)                 'length of the original string
  1879.    'For Index_help_a = 1 To Tot_command_len -1               'we need to xor this and assign at the end
  1880.   ' 'the minus (-)1 skip xor of the null termination
  1881.       '4d_string_tx_arr(tot_command_len) = 4d_string_tx_arr(tot_command_len) Xor 4d_string_tx_arr(index_help_a)
  1882.    'Next Index_help_a
  1883.    'Index_help_a = 0
  1884.   ' Select Case Tot_command_len                              ' total command length
  1885.       'Case 5:
  1886.          'Printbin #debug_port , 4d_string_tx_arr(1) ; 5     'code +string index+ string length +  1 char + crc
  1887.          'Printbin #lcd_4d , 4d_string_tx_arr(1) ; 5         'code +string index+ string length +  1 char + crc
  1888.       'Case 6:
  1889.          'Printbin #debug_port , 4d_string_tx_arr(1) ; 6     'code +string index+ string length +  2 char + crc
  1890. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 6         'code +string index+ string length +  2 char + crc
  1891. '      Case 7:
  1892. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 7     'code +string index+ string length +  3 char + crc
  1893. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 7         'code +string index+ string length +  3 char + crc
  1894. '      Case 8:
  1895. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 8     'code +string index+ string length +  4 char + crc
  1896. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 8         'code +string index+ string length +  4 char + crc
  1897. '      Case 9:
  1898. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 9     'code +string index+ string length +  5 char + crc
  1899. '         Printbin #lcd_4d , 4d_string_tx_arr(1) , 9         'code +string index+ string length +  5 char + crc
  1900. '      Case 10:
  1901. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 10    'code +string index+ string length +  6 char + crc
  1902. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 10        'code +string index+ string length +  6 char + crc
  1903. '      Case 11:
  1904. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 11    'code +string index+ string length +  7 char + crc
  1905. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 11        'code +string index+ string length +  7 char + crc
  1906. '      Case 12:
  1907. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 12    'code +string index+ string length +  8 char + crc
  1908. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 12        'code +string index+ string length +  8 char + crc
  1909. '      Case 13:
  1910. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 13    'code +string index+ string length +  9 char + crc
  1911. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 13        'code +string index+ string length +  9 char + crc
  1912. '      Case 14:
  1913. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 14    'code +string index+ string length +  10 char + crc
  1914. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 14        'code +string index+ string length +  10 char + crc
  1915. '      Case 15:
  1916.  '        Printbin #debug_port , 4d_string_tx_arr(1) ; 15    'code +string index+ string length +  11 char + crc
  1917. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 15        'code +string index+ string length +  11 char + crc
  1918. '      Case 16:
  1919. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 16    'code +string index+ string length +  12 char + crc
  1920. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 16        'code +string index+ string length +  12 char + crc
  1921. '      Case 17:
  1922. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 17    'code +string index+ string length +  13 char + crc
  1923. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 17        'code +string index+ string length +  13 char + crc
  1924. '      Case 18:
  1925. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 18    'code +string index+ string length +  14 char + crc
  1926. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 18        'code +string index+ string length +  14 char + crc
  1927. '      Case 19:
  1928. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 19    'code +string index+ string length +  15 char + crc
  1929. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 19        'code +string index+ string length +  15 char + crc
  1930. '      Case 20:
  1931. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 20    'code +string index+ string length +  16 char + crc
  1932. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 20        'code +string index+ string length +  16 char + crc
  1933. '      Case 21:
  1934. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 21    'code +string index+ string length +  17 char + crc
  1935. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 21        'code +string index+ string length +  17 char + crc
  1936. '      Case 22:
  1937. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 22    'code +string index+ string length +  18 char + crc
  1938. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 22        'code +string index+ string length +  18 char + crc
  1939. '      Case 23:
  1940. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 23    'code +string index+ string length +  19 char + crc
  1941. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 23        'code +string index+ string length +  19 char + crc
  1942. '      Case 24:
  1943. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 24    'code +string index+ string length +  20 char + crc
  1944. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 24        'code +string index+ string length +  20 char + crc
  1945. '      Case 25:
  1946. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 25    'code +string index+ string length +  21 char + crc
  1947. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 25        'code +string index+ string length +  21 char + crc
  1948. '      Case 26:
  1949. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 26    'code +string index+ string length +  22 char + crc
  1950. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 26        'code +string index+ string length +  22 char + crc
  1951. '      Case 27:
  1952. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 27    'code +string index+ string length +  23 char + crc
  1953. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 27        'code +string index+ string length +  23 char + crc
  1954. '      Case 28:
  1955. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 28    'code +string index+ string length +  24 char + crc
  1956. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 28        'code +string index+ string length +  24 char + crc
  1957. '      Case 29:
  1958. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 29    'code +string index+ string length +  25 char + crc
  1959. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 29        'code +string index+ string length +  25 char + crc
  1960. '      Case 30:
  1961. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 30    'code +string index+ string length +  26 char + crc
  1962. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 30        'code +string index+ string length +  26 char + crc
  1963. '      Case 31:
  1964. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 31    'code +string index+ string length +  27 char + crc
  1965. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 31        'code +string index+ string length +  27 char + crc
  1966. '      Case 32:
  1967. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 32    'code +string index+ string length +  28 char + crc
  1968. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 32        'code +string index+ string length +  28 char + crc
  1969. '      Case 33:
  1970. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 33    'code +string index+ string length +  29 char + crc
  1971. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 33        'code +string index+ string length +  29 char + crc
  1972. '      Case 34:
  1973. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 34    'code +string index+ string length +  30 char + crc
  1974. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 34        'code +string index+ string length +  30 char + crc
  1975. '      Case 35:
  1976. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 35    'code +string index+ string length +  31 char + crc
  1977. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 35        'code +string index+ string length +  31 char + crc
  1978. '      Case 36:
  1979. '         Printbin #debug_port , 4d_string_tx_arr(1) ; 36    'code +string index+ string length +  32 char + crc
  1980. '         Printbin #lcd_4d , 4d_string_tx_arr(1) ; 36        'code +string index+ string length +  32 char + crc
  1981. '   End Select
  1982. '   Ack_nack_flag.0 = 1                                      'ACK flag set to busy
  1983. '   While ACK_NACK_flag <> 0                                 'while waiting for response from the display
  1984. '      Incr 4d_wait_count                                    'just to idicate how long will this take
  1985. '      Call 4d_uart_rx                                       'check the Uart
  1986. '      if ACK_NACK_flag.1 = 1 then                           'NAK received form the display
  1987. '         'Printbin #lcd_4d , 4d_arr_tx(1) ; 4                ' repeat previous transmission
  1988. '         'Above line is a bug but I will not fix it as this is for older version of the Bascom
  1989. '         'Please upgrade to 2.0.8.2 or higer.
  1990. '         ACK_NACK_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  1991. '      end if
  1992. '   Wend
  1993. '  'Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
  1994. '   Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
  1995. '   4d_wait_count = 0
  1996. 'End Sub
  1997.  
  1998. Sub 4d_write_str(byval 4d_str_indx As Byte , Byval 4d_string_tmp As String )
  1999. '*******************************************************************************
  2000. 'Syntax: Call 4d_write_str(index hex value , "your text" )
  2001. 'The body of the command is:
  2002. 'comand_code + string_index+ string_length + string + xorcrc
  2003. 'For more info refer to Visi Genie reference manual page 8 section 3.1.3.3
  2004. '*******************************************************************************
  2005.    Local Index_help_a As Byte                               'used to calculate the length of the string
  2006.    Dim Tot_command_len As Byte                              'total command length
  2007.    Tot_command_len = Len(4d_string_tmp) + 4                 'total = string + string length byte + command byte + string index byte used for calculating crc
  2008.    #if Other_debug_port
  2009.    Print #debug_port , "total command length =" ; Tot_command_len
  2010.    #else
  2011.    Debug "total command length =" ; Tot_command_len
  2012.    #endif
  2013.    4d_string_tx = 4d_string_tmp                             'copy the string in to variable overlaid at array
  2014.    4d_string_tx_arr(1) = Write_str                          '&h02 write string command
  2015.    4d_string_tx_arr(2) = 4d_str_indx                        'index of the string
  2016.    4d_string_tx_arr(3) = Len(4d_string_tmp)                 'length of the original string
  2017.    For Index_help_a = 1 To Tot_command_len -1               'we need to xor this and assign at the end
  2018.    'the minus (-)1 skips xor of the null termination
  2019.       4d_string_tx_arr(tot_command_len) = 4d_string_tx_arr(tot_command_len) Xor 4d_string_tx_arr(index_help_a)
  2020.    Next Index_help_a
  2021.    Index_help_a = 0
  2022.    #if Other_debug_port
  2023.    Printbin #debug_port , 4d_string_tx_arr(1) , Tot_command_len       'code +string index+ string length +  1 char + crc
  2024.    #else
  2025.    Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
  2026.    #endif
  2027.  
  2028.    Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len 'code +string index+ string length +  1 char + crc
  2029.    Ack_nack_flag.0 = 1                                      'ACK flag set to busy
  2030.    While Ack_nack_flag <> 0                                 'while waiting for response from the display
  2031.       Incr 4d_wait_count                                    'just to indicate how long will this take
  2032.       Call 4d_uart_rx                                       'check the Uart
  2033.       If Ack_nack_flag.1 = 1 Then                           'NAK received from the display
  2034.          Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len       'code +string index+ string length +  1 char + crc 'repeat previous transmission
  2035.          Ack_nack_flag.1 = 0                                'Clear NACK flag and check again for ACK or NACK
  2036.       End If
  2037.    Wend
  2038.    #if Other_debug_port
  2039.   Printbin #lcd_4d , 4d_string_tx_arr(1) , Tot_command_len  'code +string index+ string length +  1 char + crc
  2040.    #else
  2041.    Debug 4d_string_tx_arr(1) , Tot_command_len              'code +string index+ string length +  1 char + crc
  2042.    #endif
  2043.    4d_wait_count = 0
  2044. End Sub
  2045. '*******************************************************************************
  2046. '###############################################################################
4D_system_Visi_Genie_V1.2.rar
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
ODPOWIEDZ