Skip to content

Commit

Permalink
#1426 just select a board if none has been found
Browse files Browse the repository at this point in the history
This also makes that the first time you create a project a board is
selected
  • Loading branch information
jantje committed Dec 24, 2021
1 parent cdfd191 commit 1a21864
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,19 @@ public static List<BoardDescription> makeBoardDescriptors(File boardFile) {

public BoardDescription() {
File boardsFile = new File(myStorageNode.get(KEY_LAST_USED_BOARDS_FILE, EMPTY));
myBoardTxtFile = new BoardTxtFile(boardsFile);
myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, EMPTY);
myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, EMPTY);
myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, EMPTY);
myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, EMPTY));
if (!boardsFile.exists()) {
List<ArduinoPlatformVersion> platforms = BoardsManager.getInstalledPlatforms();
//If you crash on the next line no platform have been installed
ArduinoPlatformVersion platform = platforms.get(0);
myBoardTxtFile = new BoardTxtFile(platform.getBoardsFile());
myBoardID = myBoardTxtFile.getAllBoardIDs().get(0);
} else {
myBoardTxtFile = new BoardTxtFile(boardsFile);
myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, EMPTY);
myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, EMPTY);
myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, EMPTY);
myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, EMPTY));
}
}

public BoardDescription(BoardDescription srcObject) {
Expand Down

0 comments on commit 1a21864

Please sign in to comment.