Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1

THEMA:

Bug in DC24 emulator 06 Apr 2017 12:22 #1

  • simonwood
  • simonwoods Avatar Autor
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Beiträge: 3
  • Dank erhalten: 0
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"}

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Bug in DC24 emulator 06 Apr 2017 12:35 #2

  • IG-Modellbau
  • IG-Modellbaus Avatar
  • Offline
  • Moderator
  • Moderator
  • Beiträge: 3204
  • Dank erhalten: 2275
Hello Simon,
have you set the Stick to proportional?
If I do so, I get values form -1 to +1 as real numbers.
So your code works perfectly all right.


Ingmar
Anhänge:
Folgende Benutzer bedankten sich: simonwood

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Bug in DC24 emulator 06 Apr 2017 12:54 #3

  • simonwood
  • simonwoods Avatar Autor
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Beiträge: 3
  • Dank erhalten: 0
Hi Ingmar,

thanks for the fast response. Where do I set the stick proportional ? I get the correct values from getInputs, but incorrect from getInputsVal - so I'm guessing this is not a global setting ?

S.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Bug in DC24 emulator 06 Apr 2017 12:56 #4

  • simonwood
  • simonwoods Avatar Autor
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Beiträge: 3
  • Dank erhalten: 0
Ignore that - just found it !

My mistake - thanks for helping.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Seite:
  • 1
Ladezeit der Seite: 0.239 Sekunden
Powered by Kunena Forum