All functions implement, but not running

This commit is contained in:
Ollo 2021-03-18 21:38:26 +01:00
parent d1a67f1cb4
commit 238618b245
2 changed files with 23 additions and 0 deletions

View File

@ -34,6 +34,7 @@ public class ESP8266Node extends TwoArgFunction {
final LuaTable node = new LuaTable(); final LuaTable node = new LuaTable();
node.set("compile", new CompileFunction()); node.set("compile", new CompileFunction());
node.set("restart", new RestartFunction()); node.set("restart", new RestartFunction());
node.set("heap", new HeapFunction());
env.set("node", node); env.set("node", node);
env.get("package").get("loaded").set("node", node); env.get("package").get("loaded").set("node", node);
return node; return node;
@ -73,6 +74,18 @@ public class ESP8266Node extends TwoArgFunction {
} }
private class HeapFunction extends ZeroArgFunction {
@Override
public LuaValue call() {
System.out.println("[Node] Heap");
return LuaValue.valueOf(Runtime.getRuntime().freeMemory());
}
}
public void setWorkingDirectory(File workingDir) { public void setWorkingDirectory(File workingDir) {
this.workingDir = workingDir; this.workingDir = workingDir;
} }

View File

@ -34,6 +34,7 @@ public class ESP8266Tmr extends TwoArgFunction {
tmr.set("stop", new stop()); tmr.set("stop", new stop());
tmr.set("alarm", new alarm()); tmr.set("alarm", new alarm());
tmr.set("create", new create()); tmr.set("create", new create());
tmr.set("wdclr", new watchDog());
env.set("tmr", tmr); env.set("tmr", tmr);
env.get("package").get("loaded").set("tmr", tmr); env.get("package").get("loaded").set("tmr", tmr);
@ -127,6 +128,15 @@ public class ESP8266Tmr extends TwoArgFunction {
} }
} }
private class watchDog extends ZeroArgFunction {
public LuaValue call() {
System.out.println("[TMR] Watchdog fed");
return LuaValue.valueOf(true);
}
}
private class dynStop extends ZeroArgFunction { private class dynStop extends ZeroArgFunction {
private final int dynIndex; private final int dynIndex;
public dynStop(int index) { public dynStop(int index) {