demoss

PANNEL

May 4th, 2022 (edited)
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.51 KB | None | 0 0
  1. btn1="SET,0,INPUT0,STEP,1,2,10."
  2. btn2="SET,0,INPUT0,STEP,3,3,10."
  3. btn3="SET,0,INPUT0,STEP,4,5,10."
  4. btn4="SET,0,INPUT0,STEP,6,6,10."
  5. btn5="SET,0,INPUT0,STEP,7,7,10."
  6. btn6="SET,0,INPUT0,STEP,8,8,10."
  7. btn7="SET,0,OUTPUT0,STEP,6,6,20."
  8. btn8="SET,0,OUTPUT0,STEP,7,7,20."
  9. btn9="SET,0,INPUT0,STEP,1,2,-10."
  10. btn10="SET,0,INPUT0,STEP,3,3,-10."
  11. btn11="SET,0,INPUT0,STEP,4,5,-10."
  12. btn12="SET,0,INPUT0,STEP,6,6,-10."
  13. btn13="SET,0,INPUT0,STEP,7,7,-10."
  14. btn14="SET,0,INPUT0,STEP,8,8,-10."
  15. btn15="SET,0,OUTPUT0,STEP,6,6,-20."
  16. btn16="SET,0,OUTPUT0,STEP,7,7,-20."
  17. btn17="SET,0,INPUT0,MUTE,1,2,1."
  18. btn18="SET,0,INPUT0,MUTE,3,3,1."
  19. btn19="SET,0,INPUT0,MUTE,4,5,1."
  20. btn20="SET,0,INPUT0,MUTE,6,6,1."
  21. btn21="SET,0,INPUT0,MUTE,7,7,1."
  22. btn22="SET,0,INPUT0,MUTE,8,8,1."
  23. btn23="SET,0,OUTPUT0,MUTE,6,6,1."
  24. btn24="SET,0,OUTPUT0,MUTE,7,7,1."
  25. btn25="SET,0,INPUT0,MUTE,1,8,1."
  26. btn25_="SET,0,OUTPUT0,MUTE,1,8,1."
  27.  
  28. btn17_1="SET,0,INPUT0,MUTE,1,2,0."
  29. btn18_1="SET,0,INPUT0,MUTE,3,3,0."
  30. btn19_1="SET,0,INPUT0,MUTE,4,5,0."
  31. btn20_1="SET,0,INPUT0,MUTE,6,6,0."
  32. btn21_1="SET,0,INPUT0,MUTE,7,7,0."
  33. btn22_1="SET,0,INPUT0,MUTE,8,8,0."
  34. btn23_1="SET,0,OUTPUT0,MUTE,6,6,0."
  35. btn24_1="SET,0,OUTPUT0,MUTE,7,7,0."
  36. btn25_1="SET,0,INPUT0,MUTE,1,8,0."
  37. btn25_2="SET,0,OUTPUT0,MUTE,1,8,0."
  38. btn26="SET,0,PRESET,ID,0,0,1."
  39.  
  40. request_in ="GET,0,INPUT0,MUTE,1,8,0."
  41. request_out ="GET,0,OUTPUT0,MUTE,1,8,0."
  42.  
  43. _G.l1mut = 0
  44. _G.l2mut = 0
  45.  
  46. function net_send(msg)
  47.   local tmp = {}
  48.   for i = 1, #msg do
  49.     tmp[i-1] = msg[i]
  50.   end
  51.   client_send_data(tmp)
  52. end
  53. local wificom = 0
  54.             local mode = 1
  55.             local server_port = '5557'
  56.             local server_ip = '10.0.255.186'       
  57.             local dhcp    = 0
  58.             local ipaddr  = '10.0.255.123'
  59.             local netmask = '255.255.255.0'
  60.             local gateway = '10.0.255.1'
  61.             local dns     = '10.0.255.1'   
  62. function on_init() 
  63. start_timer(1, 1000, 1, 0)
  64.             set_network_cfg(dhcp, ipaddr, netmask, gateway, dns)
  65.             --set_network_service_cfg(wificom, mode, server_port, server_ip)
  66.             save_network_cfg() 
  67.         sockfd=udp_create(12345)
  68. end
  69.  
  70. function on_timer(timer_id)
  71. if timer_id ==1 then
  72. byte_cmd(request_in)
  73. rcvudp(sockfd)
  74. byte_cmd(request_out)
  75. rcvudp(sockfd)
  76. if _G.l1mut ==1 and _G.l2mut ==1 then
  77. set_value(0,17,1)
  78. end
  79. if _G.l1mut ==0 and _G.l2mut ==0 then
  80. set_value(0,17,0)
  81. end
  82. end
  83. end
  84.  
  85. function on_control_notify(screen,control,value)
  86. if screen == 0 then
  87. if control >0 and control <=16 and value==1 then
  88. byte_cmd(_G["btn".. tostring(control)])
  89. end
  90. if control >16 and control < 25 and value==1 then
  91. byte_cmd(_G["btn".. tostring(control)])
  92. end
  93. if control >16 and control < 25 and value==0 then
  94. byte_cmd(_G["btn".. tostring(control).. '_1'])
  95. end
  96. if control ==26 and value==1 then
  97. byte_cmd(btn26)
  98. end
  99. if control ==25 and value==1 then
  100. byte_cmd(btn25)
  101. byte_cmd(btn25_)
  102. end
  103. if control ==25 and value==0 then
  104. byte_cmd(btn25_1)
  105. byte_cmd(btn25_2)
  106. end
  107. end
  108. end
  109.  
  110. function byte_cmd (cmd)
  111. local cmd_loc = {}
  112. for i = 1, cmd:len() do
  113.   cmd_loc[i-1] = cmd:byte(i)
  114. end
  115. udp_sendto(sockfd, server_ip, server_port, cmd_loc)
  116. end
  117.  
  118. function rcvudp(sockfd)
  119.   local ret,ip,port,packet = udp_recvfrom(sockfd)
  120.   local packet_str = ""  
  121.   for _, ch in ipairs(packet) do
  122.     packet_str = packet_str .. string.char(ch)  
  123.   end
  124.   print(packet_str)
  125. if packet_str:find("ET0,INPUT0,MUTE,1,1,1") then _G.l1mut =1 end
  126. if packet_str:find("ET0,INPUT0,MUTE,2,2,1") then _G.l2mut =1 end
  127. if packet_str:find("ET0,INPUT0,MUTE,1,1,0") then _G.l1mut =0 end
  128. if packet_str:find("ET0,INPUT0,MUTE,2,2,0") then _G.l2mut =0 end
  129. print(_G.l1mut)
  130. print(_G.l2mut)
  131. end
Add Comment
Please, Sign In to add comment