Skip to content

Commit

Permalink
Make target board autoselection configurable via Preferences
Browse files Browse the repository at this point in the history
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
  • Loading branch information
facchinm committed May 30, 2018
1 parent 45c8655 commit f4ed232
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/src/cc/arduino/view/preferences/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private void initComponents() {
verifyUploadBox = new javax.swing.JCheckBox();
externalEditorBox = new javax.swing.JCheckBox();
cacheCompiledCore = new javax.swing.JCheckBox();
autoselectBoard = new javax.swing.JCheckBox();
checkUpdatesBox = new javax.swing.JCheckBox();
updateExtensionBox = new javax.swing.JCheckBox();
saveVerifyUploadBox = new javax.swing.JCheckBox();
Expand Down Expand Up @@ -280,6 +281,9 @@ public void mouseEntered(java.awt.event.MouseEvent evt) {
cacheCompiledCore.setText(tr("Aggressively cache compiled core"));
checkboxesContainer.add(cacheCompiledCore);

autoselectBoard.setText(tr("Automatically use the correct target when selecting a known serial port"));
checkboxesContainer.add(autoselectBoard);

checkUpdatesBox.setText(tr("Check for updates on startup"));
checkboxesContainer.add(checkUpdatesBox);

Expand Down Expand Up @@ -731,6 +735,7 @@ private void autoScaleCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//
private javax.swing.JButton extendedAdditionalUrlFieldWindow;
private javax.swing.JCheckBox externalEditorBox;
private javax.swing.JCheckBox cacheCompiledCore;
private javax.swing.JCheckBox autoselectBoard;
private javax.swing.JTextField fontSizeField;
private javax.swing.JLabel fontSizeLabel;
private javax.swing.JLabel jLabel1;
Expand Down Expand Up @@ -836,6 +841,8 @@ private void savePreferencesData() {

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

PreferencesData.setBoolean("editor.autoselectboard", autoselectBoard.isSelected());

PreferencesData.setBoolean("update.check", checkUpdatesBox.isSelected());

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

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

autoselectBoard.setSelected(PreferencesData.getBoolean("editor.autoselectboard"));

checkUpdatesBox.setSelected(PreferencesData.getBoolean("update.check"));

updateExtensionBox.setSelected(PreferencesData.get("editor.update_extension") == null || PreferencesData.getBoolean("editor.update_extension"));
Expand Down
4 changes: 2 additions & 2 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,8 @@ private void selectSerialPort(String name, String boardId) {
// ignore
}
}
if (boardId != null) {

if (boardId != null && PreferencesData.getBoolean("editor.autoselectboard")) {
TargetBoard targetBoard = BaseNoGui.getPlatform().resolveBoardById(BaseNoGui.packages, boardId);
if (targetBoard != null) {
base.selectTargetBoard(targetBoard);
Expand Down

0 comments on commit f4ed232

Please sign in to comment.