21
Mach4 General Discussion / Is there a trick to updating registers? what am I doing wrong
« on: March 06, 2023, 11:33:00 AM »
For some reason, I can't get any registers to update (in any of my coding...?)
Here is the problem du jour:
I trigger this function via a SW toggle switch. The code is running so it is reading the register correctly the first time (I get the "Joystick Jogging Enabled (Toggle)" logging message) but it is not able to read back the register to toggle off.
Is there something strange about 1 and 0, true and false? Perhaps I am doing my booleans wrong?
Here is the problem du jour:
I trigger this function via a SW toggle switch. The code is running so it is reading the register correctly the first time (I get the "Joystick Jogging Enabled (Toggle)" logging message) but it is not able to read back the register to toggle off.
Is there something strange about 1 and 0, true and false? Perhaps I am doing my booleans wrong?
Code: [Select]
function JJogEnToggleBrSp()
local inst = mc.mcGetInstance()
local JogEnH=mc.mcRegGetHandle(inst,"iRegs0/JJog/Enable");
local JogEn=mc.mcRegGetValue(inst,JogEnH);
if (JogEn == 0) then
mc.mcRegSetValue(JogEnH, 1);
mc.mcCntlSetLastError(inst, "Joystick Jogging Enabled (Toggle)") -- BS Debug
end
if (JogEn == 1) then
mc.mcRegSetValue(JogEnH, 0);
mc.mcCntlSetLastError(inst, "Joystick Jogging Disabled (Toggle)") -- BS Debug
end
end