auto-sync

This commit is contained in:
rusEfi 2014-10-02 18:03:02 -05:00
parent d7fe7959a3
commit 92d299b795
2 changed files with 7 additions and 2 deletions

View File

@ -19,7 +19,7 @@ import javax.swing.*;
* @see WavePanel
*/
public class Launcher extends FrameHelper {
public static final int CONSOLE_VERSION = 20140929;
public static final int CONSOLE_VERSION = 20141002;
public static final boolean SHOW_STIMULATOR = true;
private final String port;

View File

@ -20,6 +20,7 @@ public class RpmModel {
private int displayedValue;
private int value;
private final List<RpmListener> listeners = new ArrayList<RpmListener>();
private long timeAtLastUpdate;
public static RpmModel getInstance() {
return INSTANCE;
@ -36,6 +37,7 @@ public class RpmModel {
public void setValue(int rpm) {
value = rpm;
for (RpmListener listener : listeners)
listener.onRpmChange(this);
}
@ -46,8 +48,11 @@ public class RpmModel {
public int getSmoothedValue() {
int diff = Math.abs(displayedValue - value);
if (diff > value * SMOOTHING_RATIO)
boolean isOlderThenOneSecond = System.currentTimeMillis() - timeAtLastUpdate > 1000;
if (diff > value * SMOOTHING_RATIO || isOlderThenOneSecond) {
timeAtLastUpdate = System.currentTimeMillis();
displayedValue = value;
}
return displayedValue;
}