Advertisement
TodWulff

idscan.lua - tool for scanning resource ids on EdgeTX radios

Mar 28th, 2024
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.90 KB | None | 0 0
  1. local start_time
  2. local debug_out = ""
  3. local t_max = 500
  4. local t_index = 0
  5.  
  6. local function init()
  7.   start_time = getTime()/100
  8.   debug_out = "\r\n\r\nInit'g idscan.lua @ " .. start_time .. " seconds after startup \r\n\r\n"
  9.   serialWrite(debug_out)
  10. end
  11.  
  12. -- periodically called function
  13. local function run()
  14.     local temp_info_str = ""
  15.    
  16.     t_index = t_index + 1
  17.  
  18.     if t_index <= t_max then
  19.    
  20.         local ctl_name = getSwitchName(t_index)
  21.         local tbd_val = getValue(t_index)
  22.         local tbd_info = getFieldInfo(t_index)
  23.        
  24.         temp_info_str = "info: " .. tostring(tbd_info)
  25.        
  26.         if tbd_info ~= nil then
  27.             local tbd_info_id = getFieldInfo(t_index).id
  28.             local tbd_info_name = getFieldInfo(t_index).name
  29.             local tbd_info_desc = getFieldInfo(t_index).desc
  30.             local tbd_info_unitid = getFieldInfo(t_index).unit
  31.             temp_info_str = temp_info_str  .. " | " .. "id: "   .. tostring(tbd_info_id) .. " | "
  32.             temp_info_str = temp_info_str .. "name: "   .. tostring(tbd_info_name) .. " | "
  33.             temp_info_str = temp_info_str .. "desc: "   .. tostring(tbd_info_desc) .. " | "
  34.             temp_info_str = temp_info_str .. "unitid: " .. tostring(tbd_info_unitid)
  35.         end
  36.        
  37.        
  38.         if ctl_name ~= nil then
  39.             local sw_val = getSwitchValue(t_index)
  40.             if sw_val ~= nil then
  41.                 serialWrite(tostring(t_index) .. ": sw_" .. ctl_name .. " = " .. tostring(sw_val) .. " (".. temp_info_str .. ")\r\n")
  42.             else
  43.                 serialWrite(tostring(t_index) .. ": sw_" .. ctl_name .. " = nil" .. " (".. temp_info_str .. ")\r\n")
  44.             end
  45.         else
  46.             -- so not a switch - lets see if a val and info can be fetched
  47.             if tbd_val ~= nil then
  48.                 serialWrite(tostring(t_index) .. ": tbd_" .. "????" .. " = " .. tostring(tbd_val) .. " (".. temp_info_str .. ")\r\n")
  49.             else
  50.                 serialWrite(tostring(t_index) .. ": tbd_" .. "????" .. " = nil" .. " (".. temp_info_str .. ")\r\n")
  51.             end    
  52.         end
  53.     else
  54.         serialWrite(".")
  55.     end
  56.    
  57. end
  58.  
  59. return {run=run, init=init}
  60.  
Tags: IDs edgetx idscan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement