Skip to content

Lua created inputs with GVAR Expo cannot be exported and imported #6356

@forbesmyester

Description

@forbesmyester

Is there an existing issue for this problem?

  • I have searched the existing issues

What part of EdgeTX is the focus of this bug?

Transmitter firmware

Current Behavior

I have the following basic implementation showing what I believe to be an error.

local toolName = "TNS|DBG|TNE"

function dump_table(o, escSpec, indent)
  if type(o) == 'table' then
     local s = '{ '
     for k,v in pairs(o) do
        if type(k) ~= 'number' then k = '"'..k..'"' end
        local vout = ""
        if type(o) == 'table' then
            vout = dump_table(v, escSpec)
        end
        s = s .. '['..k..'] = ' .. vout .. ','
     end
     return s .. '} '
  else
     return tostring(o)
  end
end

local function run(event)
    tab = model.getInput(0,0)
    print(dump_table(tab))

    local tab2 = {}
    tab2["switch"] = 0
    tab2["scale"] = 0
    tab2["source"] = 75
    tab2["weight"] = 1258
    tab2["side"] = 3
    tab2["trimSource"] = 3
    tab2["curveValue"] = -789
    tab2["inputName"] = "Xi"
    tab2["name"] = "Xn"
    tab2["flightModes"] = 0
    tab2["offset"] = 0
    tab2["curveType"] = 1
    tab2["curveValue"] = -789

    model.insertInput(2,0,tab2)
    return 1
end

local function init()
    lcd.clear()
end

return {init = init, run = run}

The first input has a Curve with Expo Gvar 6.

Image

The following table is printed from line 2 of the run() function

{ ["curveType"] = 1,["switch"] = 0,["scale"] = 0,["source"] = 75,["weight"] = 1258,["side"] = 3,["trimSource"] = 3,["curveValue"] = -789,["inputName"] = St,["name"] = ,["flightModes"] = 0,["offset"] = 0,}

I see that the curveType is 1 and the curveValue is -789.

I also saw that the curveType seems reasonable (0 == Diff, 1 == Expo, 2 == Func, 3 == Custom). curveValue is something special.

However these values, when loaded as per the second to last line in the run function, the result not in an Expo of Gvar 6, but in an Expo of 235, which does not seem correct.

Image

Observed on both radio TX16S and companion (MT12)

Potentially I may be happy to fix, I did some Lua API work on EdgeTX, but will likely need support.

Expected Behavior

A write of data that was read would restore it as it was

Steps To Reproduce

Run the above script and look at output

Version

2.11.1

Transmitter

RadioMaster TX16S / TX16SMK2

Operating System (OS)

Linux

OS Version

Ubuntu 24.4

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something isn't workingtriageBug report awaiting review / sorting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions