auto-sync
This commit is contained in:
parent
cd736e716e
commit
42b6c85527
|
@ -19,7 +19,7 @@ import javax.swing.*;
|
||||||
* @see WavePanel
|
* @see WavePanel
|
||||||
*/
|
*/
|
||||||
public class Launcher extends FrameHelper {
|
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;
|
public static final boolean SHOW_STIMULATOR = true;
|
||||||
private final String port;
|
private final String port;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class RpmModel {
|
||||||
private int displayedValue;
|
private int displayedValue;
|
||||||
private int value;
|
private int value;
|
||||||
private final List<RpmListener> listeners = new ArrayList<RpmListener>();
|
private final List<RpmListener> listeners = new ArrayList<RpmListener>();
|
||||||
|
private long timeAtLastUpdate;
|
||||||
|
|
||||||
public static RpmModel getInstance() {
|
public static RpmModel getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
|
@ -36,6 +37,7 @@ public class RpmModel {
|
||||||
|
|
||||||
public void setValue(int rpm) {
|
public void setValue(int rpm) {
|
||||||
value = rpm;
|
value = rpm;
|
||||||
|
|
||||||
for (RpmListener listener : listeners)
|
for (RpmListener listener : listeners)
|
||||||
listener.onRpmChange(this);
|
listener.onRpmChange(this);
|
||||||
}
|
}
|
||||||
|
@ -46,8 +48,11 @@ public class RpmModel {
|
||||||
|
|
||||||
public int getSmoothedValue() {
|
public int getSmoothedValue() {
|
||||||
int diff = Math.abs(displayedValue - value);
|
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;
|
displayedValue = value;
|
||||||
|
}
|
||||||
return displayedValue;
|
return displayedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue