mirror of https://github.com/rusefi/rusefi-1.git
trying to reduce confusion in UI
This commit is contained in:
parent
8b07e0c643
commit
615b9e5933
|
@ -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 = 20211123;
|
public static final int CONSOLE_VERSION = 20211124;
|
||||||
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() {
|
||||||
|
|
|
@ -11,29 +11,30 @@ import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
|
|
||||||
public class ProgramSelector {
|
public class ProgramSelector {
|
||||||
|
|
||||||
private static final String AUTO_DFU = "Auto DFU";
|
private static final String AUTO_DFU = "Auto Update";
|
||||||
private static final String MANUAL_DFU = "Manual DFU";
|
private static final String MANUAL_DFU = "Manual DFU Update";
|
||||||
private static final String DFU_SWITCH = "Switch to DFU";
|
private static final String DFU_SWITCH = "Switch to DFU Mode";
|
||||||
private static final String DFU_ERASE = "Full Erase";
|
private static final String DFU_ERASE = "Full Chip Erase";
|
||||||
private static final String ST_LINK = "ST-LINK";
|
private static final String ST_LINK = "ST-LINK Update";
|
||||||
public static final boolean IS_WIN = System.getProperty("os.name").toLowerCase().contains("win");
|
public static final boolean IS_WIN = System.getProperty("os.name").toLowerCase().contains("win");
|
||||||
|
|
||||||
private static final String HELP = "https://github.com/rusefi/rusefi/wiki/HOWTO-Update-Firmware";
|
private static final String HELP = "https://github.com/rusefi/rusefi/wiki/HOWTO-Update-Firmware";
|
||||||
|
|
||||||
private final JPanel controls = new JPanel(new FlowLayout());
|
private final JPanel controls = new JPanel(new FlowLayout());
|
||||||
private final JComboBox mode = new JComboBox();
|
private final JComboBox<String> mode = new JComboBox<>();
|
||||||
|
|
||||||
public ProgramSelector(JComboBox<String> comboPorts) {
|
public ProgramSelector(JComboBox<String> comboPorts) {
|
||||||
/**
|
/*
|
||||||
* todo: add FULL AUTO mode which would fire up DFU and ST-LINK in parallel hoping that one of those would work?
|
* todo: add FULL AUTO mode which would fire up DFU and ST-LINK in parallel hoping that one of those would work?
|
||||||
*/
|
*/
|
||||||
mode.addItem(AUTO_DFU);
|
|
||||||
if (IS_WIN) {
|
if (IS_WIN) {
|
||||||
|
mode.addItem(AUTO_DFU);
|
||||||
mode.addItem(MANUAL_DFU);
|
mode.addItem(MANUAL_DFU);
|
||||||
mode.addItem(DFU_ERASE);
|
mode.addItem(DFU_ERASE);
|
||||||
mode.addItem(ST_LINK);
|
mode.addItem(ST_LINK);
|
||||||
|
@ -57,23 +58,29 @@ public class ProgramSelector {
|
||||||
|
|
||||||
getConfig().getRoot().setProperty(getClass().getSimpleName(), selectedMode);
|
getConfig().getRoot().setProperty(getClass().getSimpleName(), selectedMode);
|
||||||
|
|
||||||
|
Objects.requireNonNull(selectedMode);
|
||||||
if (selectedMode.equals(AUTO_DFU)) {
|
switch (selectedMode) {
|
||||||
DfuFlasher.doAutoDfu(comboPorts.getSelectedItem(), comboPorts);
|
case AUTO_DFU:
|
||||||
} else if (selectedMode.equals(MANUAL_DFU)) {
|
DfuFlasher.doAutoDfu(comboPorts.getSelectedItem(), comboPorts);
|
||||||
DfuFlasher.runDfuProgramming();
|
break;
|
||||||
} else if (selectedMode.equals(ST_LINK)) {
|
case MANUAL_DFU:
|
||||||
// todo: add ST-LINK no-assert mode? or not?
|
DfuFlasher.runDfuProgramming();
|
||||||
FirmwareFlasher.doUpdateFirmware(FirmwareFlasher.IMAGE_FILE, updateFirmware);
|
break;
|
||||||
} else if (selectedMode.equals(DFU_SWITCH)) {
|
case ST_LINK:
|
||||||
StatusWindow wnd = DfuFlasher.createStatusWindow();
|
// todo: add ST-LINK no-assert mode? or not?
|
||||||
Object selected = comboPorts.getSelectedItem();
|
FirmwareFlasher.doUpdateFirmware(FirmwareFlasher.IMAGE_FILE, updateFirmware);
|
||||||
String port = selected == null ? PortDetector.AUTO : selected.toString();
|
break;
|
||||||
DfuFlasher.rebootToDfu(comboPorts, port, wnd);
|
case DFU_SWITCH:
|
||||||
} else if (selectedMode.equals(DFU_ERASE)) {
|
StatusWindow wnd = DfuFlasher.createStatusWindow();
|
||||||
DfuFlasher.runDfuErase();
|
Object selected = comboPorts.getSelectedItem();
|
||||||
} else {
|
String port = selected == null ? PortDetector.AUTO : selected.toString();
|
||||||
throw new IllegalArgumentException("How did you " + selectedMode);
|
DfuFlasher.rebootToDfu(comboPorts, port, wnd);
|
||||||
|
break;
|
||||||
|
case DFU_ERASE:
|
||||||
|
DfuFlasher.runDfuErase();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("How did you " + selectedMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue