$regfile = "m2560def.dat" '8K SRAM | 4K EEPROM
$crystal = 16000000
$hwstack = 256
$swstack = 128
$framesize = 256
$baud = 115200
$baud1 = 9600
Debug On
Config Submode = New
Const Max_usb_in_command_len = 50
Const Max_nex_command_len = 50
'*****************************************************************
'* CONFIG BUFFERED USART FOR DEBUG via USB *
'*****************************************************************
Config Com1 = 115200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Echo Off
Config Serialin0 = Buffered , Size = Max_usb_in_command_len 'RX from Terminal
Dim Char As Byte , Cmd_timeout1 As Byte , Got_str1 As Byte
Dim Command1 As String * Max_usb_in_command_len
'Config Serialout0 = Buffered , Size = Max_usb_out_command_len 'TX to the Terminal
Open "COM1:" For Binary As #1
Const Usb = 1
'*****************************************************************
'* CONFIG BUFFERED USART FOR NEXTION *
'*****************************************************************
Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Serialin1 = Buffered , Size = Max_nex_command_len 'RX
Dim Cmd_timeout As Byte , Got_str As Byte
'unnecessary
Dim Command As String * Max_nex_command_len
'Config Serialout1 = Buffered , Size = Max_nex_command_len 'TX
Open "COM2:" For Binary As #2
Const Nex = 2
'*****************************************************************
'* TIMER2 FOR TIME BASE *
'*****************************************************************
Config Timer2 = Timer , Prescale = 1024 , Compare_a = Disconnect , Compare_b = Disconnect , Clear_timer = 1
Compare2a = 155 '10ms @16MHz/1024
'****************************************************************
Config portf.0 = Input : Pinf.0 = 1
Config portf.1 = Input : Pinf.1 = 1
Config portf.2 = Input : Pinf.2 = 1
Config Portb.7 = Output : Portb.7 = 0
'****************************************************************
Z_error alias Pinf.0
X_error alias Pinf.1
Man_auto alias pinf.2
Led_test alias portb.7
'****************************************************************
Dim nex_ekran as Byte
Dim dp as Byte
Dim spindle_h as bit
Dim posZmm_new as word
Dim posZmm_old as word
Dim posZmm_eeprom as word
Dim posZmm_h as single
Dim posZmm as word
Dim posXmm_new as word
Dim posXmm_old as word
Dim posXmm_eeprom as word
Dim posXmm_h as single
Dim posXmm as word
Dim Z_step_new as word
Dim Z_step_old as word
Dim Z_step_eeprom as word
Dim Z_step as word
Dim X_step_new as word
Dim X_step_old as word
Dim X_step_eeprom as word
Dim X_step as word
Dim Z_screw_new as byte
Dim Z_screw_old as byte
Dim Z_screw_eeprom as byte
Dim Z_screw as byte
Dim X_screw_new as byte
Dim X_screw_old as byte
Dim X_screw_eeprom as byte
Dim X_screw as byte
Dim Enc_spind_new as word
Dim Enc_spind_old as word
Dim Enc_spind_eeprom as word
Dim Enc_spind as word
Dim Enc_Z_new as word
Dim Enc_Z_old as word
Dim Enc_Z_eeprom as word
Dim Enc_Z as word
Dim Enc_X_new as word
Dim Enc_X_old as word
Dim Enc_X_eeprom as word
Dim Enc_X as word
Dim New_id as Byte
Dim New_Touch as Byte
Dim New_page as long
Dim Old_page as long
Dim Help_print_nex as byte
H_print_nex_Z alias help_print_nex.0
H_print_nex_X alias help_print_nex.1
H_print_nex_M_A alias help_print_nex.2
Dim Help_print_eep_nex as byte
H_print_Zmm_eep alias help_print_eep_nex.0
H_print_Xmm_eep alias help_print_eep_nex.1
H_print_Z_steps_eep alias help_print_eep_nex.2
H_print_X_steps_eep alias help_print_eep_nex.3
H_print_Z_screw_eep alias help_print_eep_nex.4
H_print_X_screw_eep alias help_print_eep_nex.5
H_print_Enc_spind_eep alias help_print_eep_nex.6
H_print_Enc_Z_eep alias help_print_eep_nex.7
H_print_Enc_X_eep alias help_print_eep_nex.8
'****************************************************************
'BARTek multipurpose
Dim Helpb As Byte , Helpstr As String * 30 , N As Byte , Tempb As Byte , Helpl As Long
Enable Interrupts 'buffered USART
Print #usb , "Program restarted"
'NEXTION RETURN DATA LENGTH
Const Invalid_instruction = &H00 '4
Const Instruction_okay = &H01 '4
Const Invalid_component_id = &H02 '4
Const Invalid_page_id = &H03 '4
Const Invalid_picture_id = &H04 '4
Const Invalid_font_id = &H05 '4
Const Invalid_file_operation = &H06 '4
Const Invalid_crc = &H09 '4
Const Invalid_baud_rate = &H11 '4
Const Invalid_vaweform_id = &H12 '4
Const Invalid_variable_name = &H1A '4
Const Invalid_variable_operation = &H1B '4
Const Assignement_failed = &H1C '4
Const Eeprom_operation_failed = &H1D '4
Const Invalid_parameters_quantity = &H1E '4
Const Io_operation_failed = &H1F '4
Const Escape_char_invalid = &H20 '4
Const Variable_name_to_long = &H23 '4
'return codes valid in all cases
'00 00 00 FF FF FF =>Nextion starup '6
Const Serial_buff_overflow = &H24 '4
Const Touch_event = &H65 '7
' 65 00 01 01 FF FF FF
' | | | |
' | | | event 01=press, 00=release
' | | component ID
' | page number
' touch event
Const Curr_page_num = &H66 '5 second byte is page num
Const Touch_awake_coordinate = &H67 '9
Const Touch_sleep_coordinate = &H68
'first two bytes is X
'next two bytes is Y
'last byte is event 01=press, 00=release
'eg. 67 00 7A 00 1E 01 FF FF FF
Const String_data = &H70 'varied len eg.70 xx xx xx xx xx xx FF FF FF
Const Numeric_data = &H71 '8 eg.71 xx xx xx xx FF FF FF <-4bytes 32bit value, little endian
Const Auto_sleep = &H86 '4
Const Auto_awake = &H87 '4
Const Nextion_ready = &H88 '4
Const Micro_sd_upgrade = &H89 '4
Const Transp_data_finished = &HFD '4
Const Transp_data_ready = &HFE '4
Macro Nexend 'to end a tx sequence--------------------------
Printbin #nex , &HFF ; &HFF ; &HFF
End Macro
Macro Nexq ' to send quote before or after a sentence---------
Printbin &H22
End Macro
Sub Set_return_level()
'how much return will be sent over serial
'LEVEL (2 is default)
'0=no return command will be sent
'1=only confirm succes commands
'2=only if command failed
'3=all return command from &H00 to &H23 will be sent
Print #nex , "bkcmd=1";
Nexend
End Sub
Dim Nex_buff(30) As Byte , Nex_idx As Byte , End_cnt As Byte , Min_len As Byte
Dim New_long As Long At Nex_buff(2) Overlay
Dim New_string As String * 29 At Nex_buff(2) Overlay
'for touch event
Dim Touch_page As Byte At Nex_buff(2) Overlay
Dim Touch_id As Byte At Nex_buff(3) Overlay
Dim Touch_state As Byte At Nex_buff(4) Overlay '1=press , 0=release
'for coordinates
Dim New_x As Word At Nex_buff(2) Overlay
Dim New_y As Word At Nex_buff(4) Overlay
Call Set_return_level
'****************************************************************
Help_print_eep_nex = 0
Help_print_nex = 0
Readeeprom posZmm_eeprom , 10
Readeeprom posXmm_eeprom , 30
Readeeprom Z_step_eeprom , 50
Readeeprom X_step_eeprom , 70
Readeeprom Z_screw_eeprom , 90
Readeeprom X_screw_eeprom , 110
Readeeprom Enc_spind_eeprom , 130
Readeeprom Enc_Z_eeprom , 150
Readeeprom Enc_X_eeprom , 170
'****************************************************************
posZmm_old = posZmm_eeprom
posXmm_old = posXmm_eeprom
Z_step_old = Z_step_eeprom
X_step_old = X_step_eeprom
Z_screw_old = Z_screw_eeprom
X_screw_old = X_screw_eeprom
Enc_spind_old = Enc_spind_eeprom
Enc_Z_old = Enc_Z_eeprom
Enc_X_old = Enc_X_eeprom
spindle_h = 0
'****************************************************************
Do
'--[ USART0 COM1 USB ]------------------------
If 0 < Ischarwaiting(#usb) Then
Char = Inkey(#usb)
Cmd_timeout1 = 10 '
Select Case Char
Case 10 : Got_str1 = 1
Case 13
Case Else
Command1 = Command1 + Chr(char)
End Select
If Len(command1) > 49 Then Got_str1 = 1
If Got_str1 = 0 Then Cmd_timeout1 = 50 '50x10ms
'end if Ischarwaiting
End If
'--[ PARSE COM1 USB ]-------------------------
If Got_str1 = 1 Then
If 0 < Instr(command1 , "AT+RST") Then
Print #usb , "Reseting in progress..."
Config Watchdog = 16
Start Watchdog
Do : Loop
Elseif 0 < Instr(command1 , "AT+ON") Then
Print #nex , "sendxy=1";
Nexend
Elseif 0 < Instr(command1 , "AT+OFF") Then
Print #nex , "sendxy=0";
Nexend
End If
Got_str1 = 0
Command1 = ""
Cmd_timeout1 = 0
End If
'--[ USART1 COM2 nex ]---------------------
If 0 < Ischarwaiting(#nex) Then
Incr Nex_idx
Nex_buff(nex_idx) = Waitkey(#nex)
Cmd_timeout = 10 'unnecessary
If Nex_idx = 1 Then 'check what type of msg we receiving
Select Case Nex_buff(1)
Case 0
'it can be 4bytes Invalid_instruction
'or 6 bytes Nextion_startup (may be after reset)
Min_len = 1
Case Touch_event
Min_len = 4
Case Touch_awake_coordinate '9 bytes
Min_len = 6
Case Touch_sleep_coordinate '9 bytes
Min_len = 6
Case String_data 'it will be string with variable len
Min_len = 2
Case Numeric_data 'there can be FF`s so we must wait for 8 bytes
Min_len = 5
Case Else
Min_len = 1 'rest of return`s have one byte followed three FF`s
End Select
Else
'msg continue
If Nex_buff(nex_idx) = &HFF Then
If Nex_idx > Min_len Then
If End_cnt < 2 Then
Incr End_cnt
Else 'we received third FF
' '-----------------------------[ DEBUG ]----------
'' Debug #usb , "Debug=> ";
'' For N = 1 To Nex_idx
'' Debug #usb , Hex(nex_buff(n)) ; " ";
'' Next
'' Debug #usb , ""
' '------------------------------------------------
'parse
Select Case Nex_buff(1)
Case Invalid_instruction
If Nex_idx = 4 Then
Debug #usb , "Invalid instruction!"
Elseif Nex_idx = 6 Then
Debug #usb , "Nextion rebooted OK"
End If
Case Instruction_okay
Debug #usb , "Command accepted"
Case Invalid_variable_name
Debug #usb , "Variable or component NAME not recognized!"
Case Touch_event
If Touch_state = 0 Then
Debug #usb , "Relased object " ; Touch_id ; " on page " ; Touch_page
Else
Debug #usb , "Pressed object " ; Touch_id ; " on page " ; Touch_page
End If
New_id = Touch_id 'ID obiektu
New_Touch = Touch_page 'strona
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if Touch_id = 5 and Touch_page = 0 then
print #nex , "get dp";
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
end if
if Touch_id = 2 and Touch_page = 1 then
print #nex , "get dp";
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
end if
if Touch_id = 3 and Touch_page = 1 then
print #nex , "get dp";
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
end if
if Touch_id = 2 and Touch_page = 2 then
print #nex , "get dp";
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
end if
if Touch_id = 5 and Touch_page = 1 then
print #nex , "get dp";
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
end if
if Touch_id = 7 and Touch_page = 4 then
print #nex , "get dp";
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
end if
'****************************************************************
' spindle pic
'****************************************************************
if Touch_id = 11 and Touch_page = 2 and spindle_h = 0 then
if spindle_h = 0 then
print #nex , "pic 380,20,5" ;
printbin #nex , &hFF
printbin #nex , &hff
printbin #nex , &hff
toggle spindle_h
Debug #usb , "Spindle " ; spindle_h
end if
elseif Touch_id = 11 and Touch_page = 2 and spindle_h = 1 then
if spindle_h = 1 then
print #nex , "pic 380,20,4" ;
printbin #nex , &hFF
printbin #nex , &hff
printbin #nex , &hff
toggle spindle_h
Debug #usb , "Spindle " ; spindle_h
end if
end if
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Case Touch_awake_coordinate To Touch_sleep_coordinate
Swap New_x 'big endian order received
Swap New_y
Debug #usb , "Coordinates are: X=" ; New_x ; " Y=" ; New_y
Case String_data
Helpb = Nex_idx - 2
Nex_buff(helpb) = 0 'add string terminator
''Debug #usb , "New string=> " ; New_string
'****************************************************************
'You can parse commands/data here
Case Numeric_data
Debug #usb , "New value=> " ; New_long
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if New_Touch = 0 and New_id = 5 and New_long = 1 then
New_page = New_long
end if
if New_Touch = 1 and New_id = 2 and New_long = 0 then
New_page = New_long
end if
if New_Touch = 1 and New_id = 3 and New_long = 2 then
New_page = New_long
end if
if New_Touch = 2 and New_id = 2 and New_long = 1 then
New_page = New_long
end if
if New_Touch = 1 and New_id = 5 and New_long = 4 then
New_page = New_long
end if
if New_Touch = 4 and New_id = 7 and New_long = 1 then
New_page = New_long
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' NEW FEED Z AXIS
if New_Touch = 2 and New_id = 5 and New_page = 2 then
posZmm_new = New_long
if posZmm_old <> posZmm_new then
posZmm_old = posZmm_new
posZmm_h = posZmm_old / 100
Debug #usb , "nowy posow osi Z " ; posZmm_h
posZmm_eeprom = posZmm_old
Writeeeprom posZmm_eeprom , 10
Debug #usb , "Zapisana do EEprom " ; posZmm_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' NEW FEED X AXIS
if New_Touch = 2 and New_id = 8 and New_page = 2 then
posXmm_new = New_long
if posXmm_old <> posXmm_new then
posXmm_old = posXmm_new
posXmm_h = posXmm_old / 100
Debug #usb , "nowy posow osi X " ; posXmm_h
posXmm_eeprom = posXmm_old
Writeeeprom posXmm_eeprom , 30
Debug #usb , "Zapisana do EEprom " ; posXmm_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' NEW STEPS Z AXIS
if New_Touch = 4 and New_id = 2 and New_page = 4 then
Z_step_new = New_long
if Z_step_old <> Z_step_new then
Z_step_old = Z_step_new
Debug #usb , "stepper Z " ; Z_step_old
Z_step_eeprom = Z_step_old
Writeeeprom Z_step_eeprom , 50
Debug #usb , "Zapisana do EEprom " ; Z_step_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' NEW STEPS X AXIS
if New_Touch = 4 and New_id = 3 and New_page = 4 then
X_step_new = New_long
if X_step_old <> X_step_new then
X_step_old = X_step_new
Debug #usb , "stepper X " ; X_step_old
X_step_eeprom = X_step_old
Writeeeprom X_step_eeprom , 70
Debug #usb , "Zapisana do EEprom " ; X_step_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' THREAD PITCH Z AXIS
if New_Touch = 4 and New_id = 8 and New_page = 4 then
Z_screw_new = New_long
if Z_screw_old <> Z_screw_new then
Z_screw_old = Z_screw_new
Debug #usb , "new pitch Z " ; Z_screw_old
Z_screw_eeprom = Z_screw_old
Writeeeprom Z_screw_eeprom , 90
Debug #usb , "Zapisana do EEprom " ; Z_screw_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' THREAD PITCH X AXIS
if New_Touch = 4 and New_id = 9 and New_page = 4 then
X_screw_new = New_long
if X_screw_old <> X_screw_new then
X_screw_old = X_screw_new
Debug #usb , "new pitch X " ; X_screw_old
X_screw_eeprom = X_screw_old
Writeeeprom X_screw_eeprom , 110
Debug #usb , "Zapisana do EEprom " ; X_screw_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' SPINDLE ENCODER PULSE
if New_Touch = 4 and New_id = 4 and New_page = 4 then
Enc_spind_new = New_long
if Enc_spind_old <> Enc_spind_new then
Enc_spind_old = Enc_spind_new
Debug #usb , "Encoder Spindle " ; Enc_spind_old
Enc_spind_eeprom = Enc_spind_old
Writeeeprom Enc_spind_eeprom , 130
Debug #usb , "Zapisana do EEprom " ; Enc_spind_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Z AXIS ENCODER PULSE
if New_Touch = 4 and New_id = 5 and New_page = 4 then
Enc_Z_new = New_long
if Enc_Z_old <> Enc_Z_new then
Enc_Z_old = Enc_Z_new
Debug #usb , "Encoder Z " ; Enc_Z_old
Enc_Z_eeprom = Enc_Z_old
Writeeeprom Enc_Z_eeprom , 150
Debug #usb , "Zapisana do EEprom " ; Enc_Z_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' X AXIS ENCODER PULSE
if New_Touch = 4 and New_id = 6 and New_page = 4 then
Enc_X_new = New_long
if Enc_X_old <> Enc_X_new then
Enc_X_old = Enc_X_new
Debug #usb , "Encoder X " ; Enc_X_old
Enc_X_eeprom = Enc_X_old
Writeeeprom Enc_X_eeprom , 170
Debug #usb , "Zapisana do EEprom " ; Enc_X_eeprom
end if
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' loading initial settings
if New_page = 2 then
posZmm = posZmm_old
posXmm = posXmm_old
print #nex , "posZmm.val=" ; posZmm ;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
print #nex , "posXmm.val=" ; posXmm;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
end if
'8888888888888888888888888888888888888888888888888888888888
if New_page = 4 then
Z_step = Z_step_old
X_step = X_step_old
Z_screw = Z_screw_old
X_screw = X_screw_old
Enc_spind = Enc_spind_old
Enc_Z = Enc_Z_old
Enc_X = Enc_X_old
print #nex , "Z_step.val=" ; Z_step ;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
print #nex , "X_step.val=" ; X_step;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
print #nex , "Z_screw.val=" ; Z_screw ;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
print #nex , "X_screw.val=" ; X_screw;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
print #nex , "Enc_spind.val=" ; Enc_spind;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
print #nex , "Enc_Z.val=" ; Enc_Z;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
print #nex , "Enc_X.val=" ; Enc_X;
printbin #nex , &hff
printbin #nex , &hff
printbin #nex , &hff
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'If you expect numeric data from Nextion then it will be here
End Select
Nex_idx = 0
End_cnt = 0
End If
End If
End If
End If
'****************************************************************
'****************************************************************
End If
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'działa By Pikczu
'****************************************************************
'ERROR Z AXIS
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
if new_page = 2 and Z_error = 0 then
if H_print_nex_Z = 0 then
toggle h_print_nex_Z
print #nex , "pic 500,340,10" ;
printbin #nex , &hFF
printbin #nex , &hff
printbin #nex , &hff
end if
end if
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
if new_page = 2 and Z_error = 1 then
if H_print_nex_Z = 1 then
toggle h_print_nex_Z
print #nex , "pic 500,340,9" ;
printbin #nex , &hFF
printbin #nex , &hff
printbin #nex , &hff
end if
end if
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
'ERROR X AXIS
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
if new_page = 2 and X_error = 0 then
if H_print_nex_X = 0 then
toggle h_print_nex_X
print #nex , "pic 650,340,10" ;
printbin #nex , &hFF
printbin #nex , &hff
printbin #nex , &hff
end if
end if
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
if new_page = 2 and X_error = 1 then
if H_print_nex_X = 1 then
toggle h_print_nex_X
print #nex , "pic 650,340,9" ;
printbin #nex , &hFF
printbin #nex , &hff
printbin #nex , &hff
end if
end if
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
'changing the operating mode from manual to automatic
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
if new_page = 2 and Man_auto = 0 then
if H_print_nex_M_A = 0 then
toggle H_print_nex_M_A
print #nex , "pic 20,330,8" ;
printbin #nex , &hFF
printbin #nex , &hff
printbin #nex , &hff
end if
end if
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
if new_page = 2 and Man_auto = 1 then
if H_print_nex_M_A = 1 then
toggle H_print_nex_M_A
print #nex , "pic 20,330,6" ;
printbin #nex , &hFF
printbin #nex , &hff
printbin #nex , &hff
end if
end if
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
'if old_page=0 and
if Z_error = 0 or X_error = 0 then
Led_test = 1
else
Led_test = 0
end if
'****************************************************************
'--[ TIMER2 10ms ]----------------------------
If Tifr2.ocf2a = 1 Then
Tifr2.ocf2a = 1
If Cmd_timeout1 > 0 Then
Decr Cmd_timeout1
If Cmd_timeout1 = 0 Then
Command1 = ""
End If
End If
If Cmd_timeout > 0 Then
Decr Cmd_timeout
If Cmd_timeout = 0 Then
Nex_idx = 0
End_cnt = 0
End If
End If
'10ms
End If
Loop
End