Simulation speedup factor added
This commit is contained in:
parent
f51613255b
commit
4522e40d52
@ -11,3 +11,4 @@ color4=string.char(green, red, blue)
|
|||||||
colorBg=string.char(0,0,0) -- black is the default background color
|
colorBg=string.char(0,0,0) -- black is the default background color
|
||||||
sntpserverhostname="ptbtime1.ptb.de"
|
sntpserverhostname="ptbtime1.ptb.de"
|
||||||
timezoneoffset=1
|
timezoneoffset=1
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class WS2812Simulation implements LuaSimulation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(final String[] args) {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -100,9 +100,18 @@ public class WS2812Simulation implements LuaSimulation {
|
|||||||
System.out.println("Integrate " + additionalFile.getName() + " into simulation");
|
System.out.println("Integrate " + additionalFile.getName() + " into simulation");
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Script " + args[2] + " cannot be found");
|
System.err.println("Script " + args[2] + " cannot be found");
|
||||||
|
printUsage();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.length >= 4) {
|
||||||
|
try {
|
||||||
|
ESP8266Tmr.gTimingFactor = Integer.parseInt(args[3]);
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
System.err.println("Timing factor not parsable: " + nfe.getMessage());
|
||||||
|
printUsage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
simu.callScript(f.getName());
|
simu.callScript(f.getName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -128,7 +137,7 @@ public class WS2812Simulation implements LuaSimulation {
|
|||||||
private static void printUsage() {
|
private static void printUsage() {
|
||||||
System.out.println("Usage:");
|
System.out.println("Usage:");
|
||||||
System.out.println("one argument required: file to execute.");
|
System.out.println("one argument required: file to execute.");
|
||||||
System.out.println(".e.g: init.lua");
|
System.out.println(".e.g: init.lua (ws2812 layout configuration) (additional LUA script) (timing speedup factor)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,6 +22,8 @@ public class ESP8266Tmr extends TwoArgFunction {
|
|||||||
|
|
||||||
private static LuaThreadTmr[] allThreads = new LuaThreadTmr[MAXTHREADS];
|
private static LuaThreadTmr[] allThreads = new LuaThreadTmr[MAXTHREADS];
|
||||||
|
|
||||||
|
public static int gTimingFactor = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue modname, LuaValue env) {
|
public LuaValue call(LuaValue modname, LuaValue env) {
|
||||||
env.checkglobals();
|
env.checkglobals();
|
||||||
@ -77,7 +79,8 @@ public class ESP8266Tmr extends TwoArgFunction {
|
|||||||
System.err.println("[TMR] Timer" + timerNumer + " stopped");
|
System.err.println("[TMR] Timer" + timerNumer + " stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
allThreads[timerNumer] = new LuaThreadTmr(timerNumer, code, (endlessloop == 1), delay);
|
/* The cycletime is at least 1 ms */
|
||||||
|
allThreads[timerNumer] = new LuaThreadTmr(timerNumer, code, (endlessloop == 1), Math.max(delay / gTimingFactor, 1));
|
||||||
allThreads[timerNumer].start();
|
allThreads[timerNumer].start();
|
||||||
}
|
}
|
||||||
return LuaValue.valueOf(true);
|
return LuaValue.valueOf(true);
|
||||||
|
@ -52,9 +52,9 @@ public class ESP8266Ws2812 extends TwoArgFunction {
|
|||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
if (arg.isstring()) {
|
if (arg.isstring()) {
|
||||||
LuaString jstring = arg.checkstring();
|
LuaString jstring = arg.checkstring();
|
||||||
int length = jstring.rawlen();
|
final int length = jstring.rawlen();
|
||||||
if ((length % 3) == 0) {
|
if ((length % 3) == 0) {
|
||||||
byte[] array = jstring.m_bytes;
|
final byte[] array = jstring.m_bytes;
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
Loading…
Reference in New Issue
Block a user