Skip to content

Commit 765b1b5

Browse files
committed
Make target board autoselection configurable via Preferences
The setting is off by default. Per-sketch board autoselection could work better because: * Most 3rd party boards ship with generic USB to serial converters, making autoselection useless * The port menu is not easily reachable as it is in Create
1 parent 4ecc037 commit 765b1b5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/src/cc/arduino/view/preferences/Preferences.java

+9
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ private void initComponents() {
133133
verifyUploadBox = new javax.swing.JCheckBox();
134134
externalEditorBox = new javax.swing.JCheckBox();
135135
cacheCompiledCore = new javax.swing.JCheckBox();
136+
autoselectBoard = new javax.swing.JCheckBox();
136137
checkUpdatesBox = new javax.swing.JCheckBox();
137138
updateExtensionBox = new javax.swing.JCheckBox();
138139
saveVerifyUploadBox = new javax.swing.JCheckBox();
@@ -280,6 +281,9 @@ public void mouseEntered(java.awt.event.MouseEvent evt) {
280281
cacheCompiledCore.setText(tr("Aggressively cache compiled core"));
281282
checkboxesContainer.add(cacheCompiledCore);
282283

284+
autoselectBoard.setText(tr("Automatically use the correct target when selecting a known serial port"));
285+
checkboxesContainer.add(autoselectBoard);
286+
283287
checkUpdatesBox.setText(tr("Check for updates on startup"));
284288
checkboxesContainer.add(checkUpdatesBox);
285289

@@ -731,6 +735,7 @@ private void autoScaleCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//
731735
private javax.swing.JButton extendedAdditionalUrlFieldWindow;
732736
private javax.swing.JCheckBox externalEditorBox;
733737
private javax.swing.JCheckBox cacheCompiledCore;
738+
private javax.swing.JCheckBox autoselectBoard;
734739
private javax.swing.JTextField fontSizeField;
735740
private javax.swing.JLabel fontSizeLabel;
736741
private javax.swing.JLabel jLabel1;
@@ -836,6 +841,8 @@ private void savePreferencesData() {
836841

837842
PreferencesData.setBoolean("compiler.cache_core", cacheCompiledCore.isSelected());
838843

844+
PreferencesData.setBoolean("editor.autoselectboard", autoselectBoard.isSelected());
845+
839846
PreferencesData.setBoolean("update.check", checkUpdatesBox.isSelected());
840847

841848
PreferencesData.setBoolean("editor.update_extension", updateExtensionBox.isSelected());
@@ -908,6 +915,8 @@ private void showPrerefencesData() {
908915

909916
cacheCompiledCore.setSelected(PreferencesData.get("compiler.cache_core") == null || PreferencesData.getBoolean("compiler.cache_core"));
910917

918+
autoselectBoard.setSelected(PreferencesData.getBoolean("editor.autoselectboard"));
919+
911920
checkUpdatesBox.setSelected(PreferencesData.getBoolean("update.check"));
912921

913922
updateExtensionBox.setSelected(PreferencesData.get("editor.update_extension") == null || PreferencesData.getBoolean("editor.update_extension"));

app/src/processing/app/Editor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,8 @@ private void selectSerialPort(String name, String boardId) {
11001100
// ignore
11011101
}
11021102
}
1103-
1104-
if (boardId != null) {
1103+
1104+
if (boardId != null && PreferencesData.getBoolean("editor.autoselectboard")) {
11051105
TargetBoard targetBoard = BaseNoGui.getPlatform().resolveBoardById(BaseNoGui.packages, boardId);
11061106
if (targetBoard != null) {
11071107
base.selectTargetBoard(targetBoard);

0 commit comments

Comments
 (0)