function frameMainOnUpdateUI() mcState, rc = mc.mcCntlGetState(inst) if (co ~= nil) and (mcState == 0) then local state = coroutine.status(co) if state == "suspended" then --Would also need to be idle coroutine.resume(co) end if state == "dead" then --Would also need to be idle co = nil end end function m_bpButtonTopLeftOnButtonClick() co = coroutine.create (co_wait) end --This is just to test the coroutine yield and resume function co_wait() coroutine.yield() mc.mcCntlSetLastError (inst, "After Yield 0") mc.mcCntlGcodeExecute(inst, "G91\nG31 X10 F8\nG90\nG10 L2 P1 X5.0\nG0 G54 X-2.5\nG31 X0 F30") coroutine.yield() mc.mcCntlSetLastError (inst, "After Yield 1") mc.mcCntlGcodeExecute(inst, "G31 X4 F30") coroutine.yield() mc.mcCntlSetLastError (inst, "After Yield 2") mc.mcCntlGcodeExecute(inst, "G31 X0 F30") coroutine.yield() mc.mcCntlSetLastError (inst, "After Yield 3") mc.mcCntlGcodeExecute(inst, "G31 X2 F30") coroutine.yield() mc.mcCntlSetLastError (inst, "After Yield 4") mc.mcCntlGcodeExecute(inst, "G31 X0 F30") end