Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- btn1="SET,0,INPUT0,STEP,1,2,10."
- btn2="SET,0,INPUT0,STEP,3,3,10."
- btn3="SET,0,INPUT0,STEP,4,5,10."
- btn4="SET,0,INPUT0,STEP,6,6,10."
- btn5="SET,0,INPUT0,STEP,7,7,10."
- btn6="SET,0,INPUT0,STEP,8,8,10."
- btn7="SET,0,OUTPUT0,STEP,6,6,20."
- btn8="SET,0,OUTPUT0,STEP,7,7,20."
- btn9="SET,0,INPUT0,STEP,1,2,-10."
- btn10="SET,0,INPUT0,STEP,3,3,-10."
- btn11="SET,0,INPUT0,STEP,4,5,-10."
- btn12="SET,0,INPUT0,STEP,6,6,-10."
- btn13="SET,0,INPUT0,STEP,7,7,-10."
- btn14="SET,0,INPUT0,STEP,8,8,-10."
- btn15="SET,0,OUTPUT0,STEP,6,6,-20."
- btn16="SET,0,OUTPUT0,STEP,7,7,-20."
- btn17="SET,0,INPUT0,MUTE,1,2,1."
- btn18="SET,0,INPUT0,MUTE,3,3,1."
- btn19="SET,0,INPUT0,MUTE,4,5,1."
- btn20="SET,0,INPUT0,MUTE,6,6,1."
- btn21="SET,0,INPUT0,MUTE,7,7,1."
- btn22="SET,0,INPUT0,MUTE,8,8,1."
- btn23="SET,0,OUTPUT0,MUTE,6,6,1."
- btn24="SET,0,OUTPUT0,MUTE,7,7,1."
- btn25="SET,0,INPUT0,MUTE,1,8,1."
- btn25_="SET,0,OUTPUT0,MUTE,1,8,1."
- btn17_1="SET,0,INPUT0,MUTE,1,2,0."
- btn18_1="SET,0,INPUT0,MUTE,3,3,0."
- btn19_1="SET,0,INPUT0,MUTE,4,5,0."
- btn20_1="SET,0,INPUT0,MUTE,6,6,0."
- btn21_1="SET,0,INPUT0,MUTE,7,7,0."
- btn22_1="SET,0,INPUT0,MUTE,8,8,0."
- btn23_1="SET,0,OUTPUT0,MUTE,6,6,0."
- btn24_1="SET,0,OUTPUT0,MUTE,7,7,0."
- btn25_1="SET,0,INPUT0,MUTE,1,8,0."
- btn25_2="SET,0,OUTPUT0,MUTE,1,8,0."
- btn26="SET,0,PRESET,ID,0,0,1."
- request_in ="GET,0,INPUT0,MUTE,1,8,0."
- request_out ="GET,0,OUTPUT0,MUTE,1,8,0."
- --[[function net_send(msg)
- local tmp = {}
- for i = 1, #msg do
- tmp[i-1] = msg[i]
- end
- client_send_data(tmp)
- end--]]
- inmut = {0, 0, 0, 0, 0, 0, 0, 0}
- outmut = {0, 0, 0, 0, 0, 0, 0, 0}
- local wificom = 0
- local mode = 1
- local server_port = '5557'
- local server_ip = '10.0.255.186'
- local dhcp = 0
- local ipaddr = '10.0.255.123'
- local netmask = '255.255.255.0'
- local gateway = '10.0.255.1'
- local dns = '10.0.255.1'
- function on_init()
- start_timer(1, 1000, 1, 0)
- set_network_cfg(dhcp, ipaddr, netmask, gateway, dns)
- --set_network_service_cfg(wificom, mode, server_port, server_ip)
- save_network_cfg()
- sockfd=udp_create(12345)
- end
- function on_timer(timer_id)
- if timer_id ==1 then
- byte_cmd(request_in)
- byte_cmd(request_out)
- rcudp(sockfd)
- if inmut[1] == 1 and inmut[2] == 1 then set_value(0,17,1) end
- if inmut[1] == 0 and inmut[2] == 0 then set_value(0,17,0) end
- if inmut[3] == 1 then set_value(0,18,1) end
- if inmut[3] == 0 then set_value(0,18,0) end
- if inmut[4] == 1 and inmut[5] == 1 then set_value(0,19,1) end
- if inmut[4] == 0 and inmut[5] == 0 then set_value(0,19,0) end
- if inmut[6] == 1 then set_value(0,20,1) end
- if inmut[6] == 0 then set_value(0,20,0) end
- if inmut[7] == 1 then set_value(0,21,1) end
- if inmut[7] == 0 then set_value(0,21,0) end
- if inmut[8] == 1 then set_value(0,22,1) end
- if inmut[8] == 0 then set_value(0,22,0) end
- if outmut[6] == 1 then set_value(0,23,1) end
- if outmut[7] == 0 then set_value(0,23,0) end
- if outmut[6] == 1 then set_value(0,24,1) end
- if outmut[7] == 0 then set_value(0,24,0) end
- end
- end
- function on_control_notify(screen,control,value)
- if screen == 0 then
- if control >0 and control <=16 and value==1 then
- byte_cmd(_G["btn".. tostring(control)])
- end
- if control >16 and control < 25 and value==1 then
- byte_cmd(_G["btn".. tostring(control)])
- end
- if control >16 and control < 25 and value==0 then
- byte_cmd(_G["btn".. tostring(control).. '_1'])
- end
- if control ==26 and value==1 then
- byte_cmd(btn26)
- end
- if control ==25 and value==1 then
- byte_cmd(btn25)
- byte_cmd(btn25_)
- end
- if control ==25 and value==0 then
- byte_cmd(btn25_1)
- byte_cmd(btn25_2)
- end
- end
- end
- function byte_cmd (cmd)
- local cmd_loc = {}
- for i = 1, cmd:len() do
- cmd_loc[i-1] = cmd:byte(i)
- end
- udp_sendto(sockfd, server_ip, server_port, cmd_loc)
- end
- function rcudp(sockfd)
- local ret,ip,port,packet = udp_recvfrom(sockfd)
- local packet_str = ""
- for _, ch in ipairs(packet) do
- packet_str = packet_str .. string.char(ch)
- end
- local _,_,i,j,v = packet_str:find("INPUT0,MUTE,(%d+),(%d+),(%d+)")
- local _,_,s,t,r = packet_str:find("OUTPUT0,MUTE,(%d+),(%d+),(%d+)")
- if i == j and i ~= nil then
- inmut[tonumber(i)] = tonumber(v)
- end
- if s == t and s ~= nil then
- outmut[tonumber(s)] = tonumber(r)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment