The time can be set within the GUI

This commit is contained in:
ollo
2018-02-03 16:51:00 +01:00
parent 28b7bbe04a
commit ca47018a32
4 changed files with 34 additions and 9 deletions

View File

@@ -23,6 +23,8 @@ public class ESP8266Time extends TwoArgFunction {
private static long gSimulationStartTime = 0;
private static long gOverwrittenTime = 0;
@Override
public LuaValue call(LuaValue modname, LuaValue env) {
env.checkglobals();
@@ -48,11 +50,16 @@ public class ESP8266Time extends TwoArgFunction {
gSimulationStartTime = System.currentTimeMillis();
}
long time = System.currentTimeMillis();
if (ESP8266Tmr.gTimingFactor > 1) {
time = gSimulationStartTime + ((time - gSimulationStartTime) * ESP8266Tmr.gTimingFactor);
if (gOverwrittenTime == 0) {
/* Time simulation is disabled -> calculate something according to the speedup factor */
long time = System.currentTimeMillis();
if (ESP8266Tmr.gTimingFactor > 1) {
time = gSimulationStartTime + ((time - gSimulationStartTime) * ESP8266Tmr.gTimingFactor);
}
return time;
} else {
return gOverwrittenTime;
}
return time;
}
private class SyncFunction extends ThreeArgFunction {
@@ -87,5 +94,9 @@ public class ESP8266Time extends TwoArgFunction {
}
}
public static void setOverwrittenTime(long timeInMillis) {
gOverwrittenTime = timeInMillis;
}
}