Start simulation of _diet-files
This commit is contained in:
parent
bba21e562b
commit
acda0ded1c
2
init.lua
2
init.lua
@ -11,7 +11,7 @@ bootledtimer:register(75, tmr.ALARM_AUTO, function (timer)
|
|||||||
spaceLeds = math.max(MAXLEDS - (counter1*2), 0)
|
spaceLeds = math.max(MAXLEDS - (counter1*2), 0)
|
||||||
ws2812.write(string.char(16,0,0):rep(counter1) .. string.char(0,0,0):rep(spaceLeds) .. string.char(0,0,8):rep(counter1))
|
ws2812.write(string.char(16,0,0):rep(counter1) .. string.char(0,0,0):rep(spaceLeds) .. string.char(0,0,8):rep(counter1))
|
||||||
if ((counter1*2) > 114) then
|
if ((counter1*2) > 114) then
|
||||||
timer:unregister()
|
bootledtimer:unregister()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
bootledtimer:start()
|
bootledtimer:start()
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package de.c3ma.ollo.mockup;
|
package de.c3ma.ollo.mockup;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
import org.luaj.vm2.LuaValue;
|
import org.luaj.vm2.LuaValue;
|
||||||
@ -21,6 +22,8 @@ public class ESP8266File extends TwoArgFunction {
|
|||||||
|
|
||||||
private File openedFile = null;
|
private File openedFile = null;
|
||||||
|
|
||||||
|
private String SHRINKED_FILE_POSTFIX = "_diet";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue modname, LuaValue env) {
|
public LuaValue call(LuaValue modname, LuaValue env) {
|
||||||
env.checkglobals();
|
env.checkglobals();
|
||||||
@ -59,9 +62,25 @@ public class ESP8266File extends TwoArgFunction {
|
|||||||
|
|
||||||
final String codeFileName = fileName.checkjstring();
|
final String codeFileName = fileName.checkjstring();
|
||||||
final File f = new File( workingDir.getAbsolutePath() + File.separator + codeFileName);
|
final File f = new File( workingDir.getAbsolutePath() + File.separator + codeFileName);
|
||||||
//System.out.println("[FILE] Loading " + codeFileName);
|
// Check if the file exists as it
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
ESP8266File.this.openedFile = f;
|
ESP8266File.this.openedFile = f;
|
||||||
|
} else {
|
||||||
|
if (codeFileName.contains(SHRINKED_FILE_POSTFIX)) {
|
||||||
|
File fShrinked = new File( workingDir.getAbsolutePath() + File.separator + codeFileName.replace(SHRINKED_FILE_POSTFIX, ""));
|
||||||
|
File fShrinkedLC = new File(fShrinked.getAbsolutePath().replace(".lua", ".lc"));
|
||||||
|
if (!fShrinkedLC.exists()) {
|
||||||
|
try {
|
||||||
|
System.out.println("[FILE] Generate " + codeFileName);
|
||||||
|
Files.copy(fShrinked.toPath(), f.toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("[FILE] Generate " + codeFileName + " failed: " + e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("[FILE] Already found " + fShrinkedLC.getName());
|
||||||
|
return LuaValue.valueOf(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return LuaValue.valueOf((f.exists()));
|
return LuaValue.valueOf((f.exists()));
|
||||||
|
Loading…
Reference in New Issue
Block a user