From 07e4ac2c438f0bc98c1a0f1f737459fb9f61aeeb Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 17 Mar 2021 21:47:48 +0100 Subject: [PATCH 1/2] Defined lua function with the correct amount of arguments --- .../src/de/c3ma/ollo/mockup/ESP8266Tmr.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/simulation/src/de/c3ma/ollo/mockup/ESP8266Tmr.java b/simulation/src/de/c3ma/ollo/mockup/ESP8266Tmr.java index a57e750..3c39469 100644 --- a/simulation/src/de/c3ma/ollo/mockup/ESP8266Tmr.java +++ b/simulation/src/de/c3ma/ollo/mockup/ESP8266Tmr.java @@ -111,19 +111,19 @@ public class ESP8266Tmr extends TwoArgFunction { } } - private class dynStart extends VarArgFunction { + private class dynStart extends ZeroArgFunction { private final int dynIndex; public dynStart(int index) { this.dynIndex = index; } - public Varargs invoke(Varargs varargs) { - if (varargs.narg()== 0) { - if (dynamicThreads[dynIndex] != null) { - dynamicThreads[dynIndex].start(); - System.out.println("[TMR] DynTimer" + dynIndex + " started"); - } + public LuaValue call() { + if (dynamicThreads[dynIndex] != null) { + dynamicThreads[dynIndex].start(); + System.out.println("[TMR] DynTimer" + dynIndex + " started"); + return LuaValue.valueOf(true); + } else { + return LuaValue.valueOf(false); } - return LuaValue.valueOf(true); } } @@ -133,12 +133,14 @@ public class ESP8266Tmr extends TwoArgFunction { this.dynIndex = index; } public LuaValue call() { + boolean status = false; if (dynamicThreads[dynIndex] != null) { dynamicThreads[dynIndex].stopThread(); dynamicThreads[dynIndex] = null; System.out.println("[TMR] DynTimer" + dynIndex + " stopped"); + status = true; } - return LuaValue.valueOf(true); + return LuaValue.valueOf(status); } } From 5f8aa3c221b60615270330f3998e8acea87b9434 Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 17 Mar 2021 21:52:44 +0100 Subject: [PATCH 2/2] adapted code to be executable in the simulation --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index c1a5eac..e8cdc94 100644 --- a/init.lua +++ b/init.lua @@ -33,7 +33,7 @@ end initTimer = tmr.create() initTimer:register(5000, tmr.ALARM_SINGLE, function (t) bootledtimer:unregister() - t:unregister() + initTimer:unregister() initTimer=nil bootledtimer=nil local modlist = { "timecore" , "displayword" }