mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
bd616cba76
commit
9ed5c45863
|
@ -81,6 +81,7 @@ static void applyAlternatorPinState(PwmConfig *state, int stateIndex) {
|
|||
|
||||
void initAlternatorCtrl(Logging *sharedLogger) {
|
||||
logger = sharedLogger;
|
||||
addConsoleAction("altinfo", showAltInfo);
|
||||
if (boardConfiguration->alternatorControlPin == GPIO_UNASSIGNED)
|
||||
return;
|
||||
|
||||
|
@ -91,7 +92,6 @@ void initAlternatorCtrl(Logging *sharedLogger) {
|
|||
(tfunc_t) AltCtrlThread, NULL);
|
||||
|
||||
addConsoleActionF("set_alt_p", setAltPFactor);
|
||||
addConsoleAction("altinfo", showAltInfo);
|
||||
|
||||
applySettings();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "error_handling.h"
|
||||
#include "io_pins.h"
|
||||
#include "memstreams.h"
|
||||
#include "efilib2.h"
|
||||
|
||||
#if EFI_HD44780_LCD
|
||||
#include "lcd_HD44780.h"
|
||||
|
@ -83,17 +84,17 @@ char *getWarninig(void) {
|
|||
return warningBuffer;
|
||||
}
|
||||
|
||||
uint64_t lastLockTime;
|
||||
uint32_t lastLockTime;
|
||||
uint32_t maxLockTime = 0;
|
||||
|
||||
bool isInsideTriggerHandler = false;
|
||||
|
||||
void onLockHook(void) {
|
||||
lastLockTime = getTimeNowNt();
|
||||
lastLockTime = GET_TIMESTAMP();
|
||||
}
|
||||
|
||||
void onUnlockHook(void) {
|
||||
uint64_t t = getTimeNowNt() - lastLockTime;
|
||||
uint64_t t = GET_TIMESTAMP() - lastLockTime;
|
||||
if (t > maxLockTime) {
|
||||
maxLockTime = t;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
|||
* @see com.rusefi.StartupFrame
|
||||
*/
|
||||
public class Launcher {
|
||||
public static final int CONSOLE_VERSION = 20150513;
|
||||
public static final int CONSOLE_VERSION = 20150514;
|
||||
public static final boolean SHOW_STIMULATOR = false;
|
||||
private static final String TAB_INDEX = "main_tab";
|
||||
protected static final String PORT_KEY = "port";
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.rusefi.ui.storage.Node;
|
|||
import com.rusefi.ui.util.UiUtils;
|
||||
import com.rusefi.ui.widgets.PopupMenuButton;
|
||||
import com.rusefi.ui.widgets.SensorGauge;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
@ -160,19 +161,30 @@ public class GaugesPanel {
|
|||
gauges.removeAll();
|
||||
|
||||
for (int i = 0; i < rows * columns; i++) {
|
||||
String gaugeName = config.getProperty("gauge_" + i, DEFAULT_LAYOUT[i].name());
|
||||
String gaugeName = config.getProperty(getKey(i), DEFAULT_LAYOUT[i].name());
|
||||
Sensor sensor;
|
||||
try {
|
||||
sensor = Sensor.valueOf(Sensor.class, gaugeName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
sensor = DEFAULT_LAYOUT[i];
|
||||
}
|
||||
gauges.add(SensorGauge.createGauge(sensor));
|
||||
final int currentGaugeIndex = i;
|
||||
gauges.add(SensorGauge.createGauge(sensor, new SensorGauge.GaugeChangeListener() {
|
||||
@Override
|
||||
public void onSensorChange(Sensor sensor) {
|
||||
config.setProperty(getKey(currentGaugeIndex), sensor.name());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
saveConfig(rows, columns);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getKey(int i) {
|
||||
return "gauge_" + i;
|
||||
}
|
||||
|
||||
private void saveConfig(int rows, int columns) {
|
||||
config.setProperty(GAUGES_ROWS, rows);
|
||||
config.setProperty(GAUGES_COLUMNS, columns);
|
||||
|
|
|
@ -27,6 +27,7 @@ public class MessagesView {
|
|||
public final JScrollPane messagesScroll = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
public MessagesView() {
|
||||
messages.setEditable(false);
|
||||
StyledDocument d = (StyledDocument) messages.getDocument();
|
||||
bold = d.addStyle("StyleName", null);
|
||||
bold.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
|
||||
|
|
|
@ -7,10 +7,8 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||
|
@ -26,7 +24,7 @@ public class RecentCommands {
|
|||
|
||||
private final JPanel content = new JPanel(new GridLayout(NUMBER_OF_COMMANDS + 1, 1));
|
||||
|
||||
private final LinkedHashMap<Entry, Object> entries = new LinkedHashMap<Entry, Object>() {
|
||||
private static final LinkedHashMap<Entry, Object> entries = new LinkedHashMap<Entry, Object>() {
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<Entry, Object> eldest) {
|
||||
return size() > NUMBER_OF_COMMANDS;
|
||||
|
@ -188,4 +186,15 @@ public class RecentCommands {
|
|||
return command.compareTo(o.command);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRecent(int index) {
|
||||
List<Entry> elements;
|
||||
index = Math.max(0, index);
|
||||
synchronized (entries) {
|
||||
elements = new ArrayList<>(entries.keySet());
|
||||
}
|
||||
if (index >= elements.size())
|
||||
return elements.get(0).command;
|
||||
return elements.get(elements.size() - 1 - index).command;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.ui.widgets;
|
||||
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.ui.RecentCommands;
|
||||
import com.rusefi.ui.storage.Node;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -9,6 +10,8 @@ import javax.swing.event.DocumentListener;
|
|||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* Date: 3/20/13
|
||||
|
@ -26,6 +29,7 @@ public class AnyCommand {
|
|||
|
||||
private JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
private boolean reentrant;
|
||||
private int index;
|
||||
|
||||
public AnyCommand(final Node config, boolean listenToCommands) {
|
||||
this(config, config.getProperty(KEY, ""), listenToCommands);
|
||||
|
@ -36,6 +40,15 @@ public class AnyCommand {
|
|||
content.setBorder(BorderFactory.createLineBorder(Color.PINK));
|
||||
content.add(new JLabel("Command: "));
|
||||
content.add(text);
|
||||
JButton go = new JButton("Go");
|
||||
go.setContentAreaFilled(false);
|
||||
go.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
go();
|
||||
}
|
||||
});
|
||||
content.add(go);
|
||||
|
||||
CommandQueue.getInstance().addListener(new CommandQueue.CommandQueueListener() {
|
||||
@Override
|
||||
|
@ -45,16 +58,23 @@ public class AnyCommand {
|
|||
}
|
||||
});
|
||||
|
||||
text.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
String command = RecentCommands.getRecent(++index);
|
||||
text.setText(command);
|
||||
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
String command = RecentCommands.getRecent(--index);
|
||||
text.setText(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
text.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String cmd = text.getText();
|
||||
if (!isValidInput(text))
|
||||
return;
|
||||
int timeout = CommandQueue.getTimeout(cmd);
|
||||
reentrant = true;
|
||||
CommandQueue.getInstance().write(cmd.toLowerCase(), timeout);
|
||||
reentrant = false;
|
||||
go();
|
||||
}
|
||||
});
|
||||
text.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
@ -87,15 +107,21 @@ public class AnyCommand {
|
|||
// todo: limit the length of text in the text field
|
||||
}
|
||||
|
||||
private void go() {
|
||||
index = 0;
|
||||
String cmd = text.getText();
|
||||
if (!isValidInput(text))
|
||||
return;
|
||||
int timeout = CommandQueue.getTimeout(cmd);
|
||||
reentrant = true;
|
||||
CommandQueue.getInstance().write(cmd.toLowerCase(), timeout);
|
||||
reentrant = false;
|
||||
}
|
||||
|
||||
public JTextField getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean requestFocusInWindow() {
|
||||
// return text.requestFocusInWindow();
|
||||
// }
|
||||
|
||||
private static boolean isValidInput(JTextField text) {
|
||||
boolean isOk = true;
|
||||
for (char c : text.getText().toCharArray()) {
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SensorGauge {
|
|||
return createGauge(sensor, GaugeChangeListener.VOID);
|
||||
}
|
||||
|
||||
private static Component createGauge(Sensor sensor, GaugeChangeListener listener) {
|
||||
public static Component createGauge(Sensor sensor, GaugeChangeListener listener) {
|
||||
JPanel wrapper = new JPanel(new BorderLayout());
|
||||
|
||||
createGaugeBody(sensor, wrapper, listener);
|
||||
|
@ -36,7 +36,7 @@ public class SensorGauge {
|
|||
return wrapper;
|
||||
}
|
||||
|
||||
interface GaugeChangeListener {
|
||||
public interface GaugeChangeListener {
|
||||
GaugeChangeListener VOID = new GaugeChangeListener() {
|
||||
@Override
|
||||
public void onSensorChange(Sensor sensor) {
|
||||
|
|
Loading…
Reference in New Issue