Hi guys,
been playing with the DC24 emulator to test some Lua code and have come across a bug there. Seems like this is the right place to report it.
The getInputsVal call only returns -1 and 1 for any stick defined. If you get the label from the switchinfo structure and call getInputs you get the correct value. If you look at the switchinfo value field that is also incorrect.
Please find some code below to demonstrate the issue.
Regards
Simon
local InputE
local count
local function loop()
if (not InputE) then return end
-- don;t flood the debug console
count = count + 1
if (count < 25) then return end
count = 0
local val = system.getInputsVal(InputE)
local swInfo = system.getSwitchInfo(InputE)
local val2 = system.getInputs(swInfo.label)
print(string.format("val=%f, gival=%f", val, val2))
end
-------------------------------------------------------------------------------
-- form Code
local function OnChangedES(value)
InputE = value
system.pSave("InputE", value)
end
local function initForm(formID)
form.addRow(2)
form.addLabel({label="control",font=FONT_BOLD})
form.addInputbox(InputE, true, OnChangedES)
end
--------------------------------------------------------------------------------
local function init()
system.registerForm(1, MENU_FINE, "Hysteresis Switch",initForm,nil,printForm)
InputE = system.pLoad("InputE", nil)
count = 0
end
--------------------------------------------------------------------------------
return {init=init, loop=loop, author="Simon Wood", version="1.1", name="pot test"}