auto-sync

This commit is contained in:
rusEfi 2015-09-01 23:02:49 -04:00
parent 516438115a
commit d021a93aed
5 changed files with 58 additions and 32 deletions

View File

@ -118,6 +118,28 @@ static void setIdleValvePosition(int positionPercent) {
doSetIdleValvePosition(positionPercent); doSetIdleValvePosition(positionPercent);
} }
static int idlePositionBeforeBlip;
static efitimeus_t timeToStopBlip = 0;
/**
* I use this questionable feature to tune acceleration enrichment
*/
static void blipIdle(int idlePosition, int durationMs) {
if (timeToStopBlip != 0) {
return; // already in idle blip
}
idlePositionBeforeBlip = boardConfiguration->idlePosition;
setIdleValvePosition(idlePosition);
timeToStopBlip = getTimeNowUs() + 1000 * durationMs;
}
static void undoIdleBlipIfNeeded() {
if (timeToStopBlip != 0 && getTimeNowUs() > timeToStopBlip) {
timeToStopBlip = 0;
setIdleValvePosition(idlePositionBeforeBlip);
}
}
static msg_t ivThread(int param) { static msg_t ivThread(int param) {
(void) param; (void) param;
chRegSetThreadName("IdleValve"); chRegSetThreadName("IdleValve");
@ -136,6 +158,8 @@ static msg_t ivThread(int param) {
getHwPin(boardConfiguration->clutchUpPin)); getHwPin(boardConfiguration->clutchUpPin));
} }
undoIdleBlipIfNeeded();
if (engineConfiguration->idleMode != IM_AUTO) { if (engineConfiguration->idleMode != IM_AUTO) {
// let's re-apply CLT correction // let's re-apply CLT correction
doSetIdleValvePosition(boardConfiguration->idlePosition); doSetIdleValvePosition(boardConfiguration->idlePosition);
@ -208,6 +232,8 @@ void startIdleThread(Logging*sharedLogger, Engine *engine) {
addConsoleActionI("set_idle_position", setIdleValvePosition); addConsoleActionI("set_idle_position", setIdleValvePosition);
addConsoleActionI("set_idle_enabled", (VoidInt) setIdleControlEnabled); addConsoleActionI("set_idle_enabled", (VoidInt) setIdleControlEnabled);
addConsoleActionII("blipidle", blipIdle);
} }
#endif #endif

View File

@ -291,5 +291,5 @@ int getRusEfiVersion(void) {
return 123; // this is here to make the compiler happy about the unused array return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0) if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array return 3211; // this is here to make the compiler happy about the unused array
return 20150830; return 20150901;
} }

View File

@ -32,7 +32,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see com.rusefi.StartupFrame * @see com.rusefi.StartupFrame
*/ */
public class Launcher { public class Launcher {
public static final int CONSOLE_VERSION = 20150831; public static final int CONSOLE_VERSION = 20150901;
public static final boolean SHOW_STIMULATOR = false; public static final boolean SHOW_STIMULATOR = false;
private static final String TAB_INDEX = "main_tab"; private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port"; protected static final String PORT_KEY = "port";
@ -40,8 +40,6 @@ public class Launcher {
private final JTabbedPane tabbedPane = new JTabbedPane(); private final JTabbedPane tabbedPane = new JTabbedPane();
private static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A"); private static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
public static int defaultFontSize;
private static Frame staticFrame; private static Frame staticFrame;
private final TableEditorPane tableEditor = new TableEditorPane(); private final TableEditorPane tableEditor = new TableEditorPane();
private final SettingsTab settingsTab = new SettingsTab(); private final SettingsTab settingsTab = new SettingsTab();

View File

@ -48,7 +48,7 @@ public class SensorLiveGraph extends JPanel {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) { if (SwingUtilities.isRightMouseButton(e)) {
showPopupMenu(e); showPopupMenu(e);
} else if (e.getClickCount() == 2) { // } else if (e.getClickCount() == 2) {
// handleDoubleClick(e, gauge, sensor); // handleDoubleClick(e, gauge, sensor);
} }
} }
@ -192,25 +192,16 @@ public class SensorLiveGraph extends JPanel {
return; // it's hopeless return; // it's hopeless
g.setColor(Color.black); g.setColor(Color.black);
double minValue; VisibleRange range = getRange();
double maxValue;
if (autoScale) {
VisibleRange getVisibleRange = new VisibleRange().invoke();
minValue = getVisibleRange.getMinValue();
maxValue = getVisibleRange.getMaxValue();
} else {
minValue = sensor.getMinValue();
maxValue = sensor.getMaxValue();
}
paintGraph(g, d, minValue, maxValue); paintGraph(g, d, range.minValue, range.maxValue);
g.setColor(Color.red); g.setColor(Color.red);
int minY = d.height; int minY = d.height;
int maxY = g.getFont().getSize(); int maxY = g.getFont().getSize();
g.drawString(String.format("%.2f", minValue), 5, minY); g.drawString(String.format("%.2f", range.minValue), 5, minY);
g.drawString(String.format("%.2f", (minValue + maxValue) / 2), 5, (minY + maxY) / 2); g.drawString(String.format("%.2f", (range.minValue + range.maxValue) / 2), 5, (minY + maxY) / 2);
g.drawString(String.format("%.2f", maxValue), 5, maxY); g.drawString(String.format("%.2f", range.maxValue), 5, maxY);
g.setColor(Color.blue); g.setColor(Color.blue);
String sensorName = sensor.getName() + " "; String sensorName = sensor.getName() + " ";
@ -224,6 +215,16 @@ public class SensorLiveGraph extends JPanel {
paintLastValue(g, d); paintLastValue(g, d);
} }
private VisibleRange getRange() {
VisibleRange range;
if (autoScale) {
range = VisibleRange.findRange(values);
} else {
range = new VisibleRange(sensor.getMinValue(), sensor.getMaxValue());
}
return range;
}
private void paintLastValue(Graphics g, Dimension d) { private void paintLastValue(Graphics g, Dimension d) {
Double last = values.getLast(); Double last = values.getLast();
if (!Double.isNaN(last)) { if (!Double.isNaN(last)) {
@ -253,21 +254,18 @@ public class SensorLiveGraph extends JPanel {
} }
} }
private class VisibleRange { private static class VisibleRange {
private double minValue; private final double minValue;
private double maxValue; private final double maxValue;
public double getMinValue() { public VisibleRange(double minValue, double maxValue) {
return minValue; this.minValue = minValue;
this.maxValue = maxValue;
} }
public double getMaxValue() { public static VisibleRange findRange(LinkedList<Double> values) {
return maxValue; double minValue = Double.MAX_VALUE;
} double maxValue = -Double.MAX_VALUE;
public VisibleRange invoke() {
minValue = Double.MAX_VALUE;
maxValue = -Double.MAX_VALUE;
for (double value : values) { for (double value : values) {
minValue = Math.min(minValue, value); minValue = Math.min(minValue, value);
maxValue = Math.max(maxValue, value); maxValue = Math.max(maxValue, value);
@ -282,7 +280,7 @@ public class SensorLiveGraph extends JPanel {
minValue -= 0.05 * diff; minValue -= 0.05 * diff;
maxValue += 0.05 * diff; maxValue += 0.05 * diff;
} }
return this; return new VisibleRange(minValue, maxValue);
} }
} }
} }

View File

@ -98,4 +98,8 @@ public class Node {
"prefix='" + prefix + '\'' + "prefix='" + prefix + '\'' +
'}'; '}';
} }
public void setProperty(String key, double value) {
setProperty(key, Double.toString(value));
}
} }