mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Add Base.selectSerialPort
This method takes care of setting the serial.port preference to the given value, as well as deriving the serial.port.file preference. This should prevent duplicate code in the future. Note that a second copy of this code lives in SerialUploader, but that doesn't write to the global Preferences but a local prefs map. Since the global Preferences are currently static, there is no way to share code between these two copies.
This commit is contained in:
parent
7548591d51
commit
c0ab536b7b
@ -1600,6 +1600,13 @@ public class Base {
|
||||
rebuildExamplesMenu(Editor.examplesMenu);
|
||||
}
|
||||
|
||||
public static void selectSerialPort(String port) {
|
||||
Preferences.set("serial.port", port);
|
||||
if (port.startsWith("/dev/"))
|
||||
Preferences.set("serial.port.file", port.substring(5));
|
||||
else
|
||||
Preferences.set("serial.port.file", port);
|
||||
}
|
||||
|
||||
public void rebuildProgrammerMenu(JMenu menu) {
|
||||
menu.removeAll();
|
||||
|
@ -965,11 +965,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
if (selection != null) selection.setState(true);
|
||||
//System.out.println(item.getLabel());
|
||||
Preferences.set("serial.port", name);
|
||||
if (name.startsWith("/dev/"))
|
||||
Preferences.set("serial.port.file", name.substring(5));
|
||||
else
|
||||
Preferences.set("serial.port.file", name);
|
||||
Base.selectSerialPort(name);
|
||||
if (serialMonitor != null) {
|
||||
try {
|
||||
serialMonitor.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user