my first Lua
This commit is contained in:
parent
4e47e7bdb9
commit
f47320fd70
|
@ -26,6 +26,8 @@ Release template (copy/paste this for new release):
|
||||||
All notable user-facing or behavior-altering changes will be documented in this file.
|
All notable user-facing or behavior-altering changes will be documented in this file.
|
||||||
|
|
||||||
## Month 202x Release - "Release Name"
|
## Month 202x Release - "Release Name"
|
||||||
|
### Added
|
||||||
|
- rusEFI console Lua tab loads scripts from ECU on start
|
||||||
|
|
||||||
## August 2021 Release - "Lottery Day"
|
## August 2021 Release - "Lottery Day"
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ static int lua_stopEngine(lua_State*) {
|
||||||
|
|
||||||
void configureRusefiLuaHooks(lua_State* l) {
|
void configureRusefiLuaHooks(lua_State* l) {
|
||||||
lua_register(l, "print", lua_efi_print);
|
lua_register(l, "print", lua_efi_print);
|
||||||
lua_register(l, "readpin", lua_readpin);
|
lua_register(l, "readPin", lua_readpin);
|
||||||
lua_register(l, "getAnalog", lua_getAnalog);
|
lua_register(l, "getAnalog", lua_getAnalog);
|
||||||
lua_register(l, "getSensor", lua_getSensor);
|
lua_register(l, "getSensor", lua_getSensor);
|
||||||
lua_register(l, "getSensorRaw", lua_getSensorRaw);
|
lua_register(l, "getSensorRaw", lua_getSensorRaw);
|
||||||
|
|
|
@ -449,6 +449,10 @@ static void configureInputs(void) {
|
||||||
|
|
||||||
addChannel("AUXF#1", engineConfiguration->auxFastSensor1_adcChannel, ADC_FAST);
|
addChannel("AUXF#1", engineConfiguration->auxFastSensor1_adcChannel, ADC_FAST);
|
||||||
|
|
||||||
|
for (int i = 0;i < LUA_ANALOG_INPUT_COUNT;i++) {
|
||||||
|
addChannel("LUA", engineConfiguration->luaAnalogInputs[i], ADC_FAST);
|
||||||
|
}
|
||||||
|
|
||||||
setAdcChannelOverrides();
|
setAdcChannelOverrides();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.net.URL;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class rusEFIVersion {
|
public class rusEFIVersion {
|
||||||
public static final int CONSOLE_VERSION = 20210806;
|
public static final int CONSOLE_VERSION = 20210831;
|
||||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
|
|
||||||
public static long classBuildTimeMillis() {
|
public static long classBuildTimeMillis() {
|
||||||
|
|
|
@ -14,11 +14,14 @@ import java.awt.event.ActionListener;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import static com.rusefi.ui.util.UiUtils.trueLayout;
|
||||||
|
|
||||||
public class LuaScriptPanel {
|
public class LuaScriptPanel {
|
||||||
private final UIContext context;
|
private final UIContext context;
|
||||||
private final JPanel mainPanel = new JPanel(new BorderLayout());
|
private final JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
private final AnyCommand command;
|
private final AnyCommand command;
|
||||||
private final JTextArea scriptText = new JTextArea();
|
private final JTextArea scriptText = new JTextArea();
|
||||||
|
private boolean isFirstRender = true;
|
||||||
|
|
||||||
public LuaScriptPanel(UIContext context, Node config) {
|
public LuaScriptPanel(UIContext context, Node config) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -31,7 +34,7 @@ public class LuaScriptPanel {
|
||||||
JButton writeButton = new JButton("Write to ECU");
|
JButton writeButton = new JButton("Write to ECU");
|
||||||
JButton resetButton = new JButton("Reset/Reload Lua");
|
JButton resetButton = new JButton("Reset/Reload Lua");
|
||||||
|
|
||||||
readButton.addActionListener(e -> read());
|
readButton.addActionListener(e -> readFromECU());
|
||||||
writeButton.addActionListener(e -> write());
|
writeButton.addActionListener(e -> write());
|
||||||
resetButton.addActionListener(e -> resetLua());
|
resetButton.addActionListener(e -> resetLua());
|
||||||
|
|
||||||
|
@ -43,7 +46,7 @@ public class LuaScriptPanel {
|
||||||
// Center panel - script editor and log
|
// Center panel - script editor and log
|
||||||
JPanel scriptPanel = new JPanel(new BorderLayout());
|
JPanel scriptPanel = new JPanel(new BorderLayout());
|
||||||
scriptText.setTabSize(2);
|
scriptText.setTabSize(2);
|
||||||
scriptPanel.add(this.scriptText, BorderLayout.CENTER);
|
scriptPanel.add(scriptText, BorderLayout.CENTER);
|
||||||
|
|
||||||
//centerPanel.add(, BorderLayout.WEST);
|
//centerPanel.add(, BorderLayout.WEST);
|
||||||
JPanel messagesPanel = new JPanel(new BorderLayout());
|
JPanel messagesPanel = new JPanel(new BorderLayout());
|
||||||
|
@ -51,10 +54,27 @@ public class LuaScriptPanel {
|
||||||
messagesPanel.add(BorderLayout.NORTH, mp.getButtonPanel());
|
messagesPanel.add(BorderLayout.NORTH, mp.getButtonPanel());
|
||||||
messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll());
|
messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll());
|
||||||
|
|
||||||
JSplitPane centerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scriptPanel, messagesPanel);
|
JSplitPane centerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scriptPanel, messagesPanel) {
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
super.paint(g);
|
||||||
|
if (isFirstRender) {
|
||||||
|
readFromECU();
|
||||||
|
isFirstRender = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this.mainPanel.add(upperPanel, BorderLayout.NORTH);
|
mainPanel.add(upperPanel, BorderLayout.NORTH);
|
||||||
this.mainPanel.add(centerPanel, BorderLayout.CENTER);
|
mainPanel.add(centerPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
trueLayout(mainPanel);
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
centerPanel.setDividerLocation(centerPanel.getSize().width / 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getPanel() {
|
public JPanel getPanel() {
|
||||||
|
@ -68,11 +88,11 @@ public class LuaScriptPanel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void read() {
|
void readFromECU() {
|
||||||
BinaryProtocol bp = this.context.getLinkManager().getCurrentStreamState();
|
BinaryProtocol bp = context.getLinkManager().getCurrentStreamState();
|
||||||
|
|
||||||
if (bp == null) {
|
if (bp == null) {
|
||||||
// TODO: Handle missing ECU
|
scriptText.setText("No ECU located");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue