diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 9bc5a5986..5754a8264 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1113,7 +1113,10 @@ public class Base { String selBoard = Preferences.get("board"); menu.removeAll(); + boolean first = true; + ButtonGroup group = new ButtonGroup(); + // Cycle through all packages for (TargetPackage targetPackage : packages.values()) { String packageName = targetPackage.getName(); @@ -1123,8 +1126,16 @@ public class Base { String platformName = targetPlatform.getName(); Map boards = targetPlatform.getBoards(); - // For every platform cycle throug all boards - for (String board : boards.keySet()) { + // Add a title for each group of boards + if (!first) + menu.add(new JSeparator()); + first = false; + JMenuItem separator = new JMenuItem(targetPlatform.getPreferences().get("name")); + separator.setEnabled(false); + menu.add(separator); + + // For every platform cycle through all boards + for (String board : targetPlatform.getOrderedBoards()) { // Setup a menu item for the current board String boardName = boards.get(board).get("name"); diff --git a/app/src/processing/app/debug/TargetPlatform.java b/app/src/processing/app/debug/TargetPlatform.java index 65b9f459d..ca5d4aac6 100644 --- a/app/src/processing/app/debug/TargetPlatform.java +++ b/app/src/processing/app/debug/TargetPlatform.java @@ -24,15 +24,19 @@ package processing.app.debug; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import processing.app.helpers.PreferencesMap; +import processing.core.PApplet; public class TargetPlatform { private String name; private File folder; private Map boards; + private List boardsOrder; private Map programmers; private PreferencesMap preferences; @@ -50,6 +54,7 @@ public class TargetPlatform { PreferencesMap boardPreferences = new PreferencesMap(); boardPreferences.load(boardsFile); boards = boardPreferences.createFirstLevelMap(); + boardsOrder = readBoardsOrder(boardsFile); } } catch (Exception e) { System.err.println("Error loading boards from boards.txt: " + e); @@ -76,6 +81,32 @@ public class TargetPlatform { } } + /** + * Loads the ordered list of boards as they appears on the boards.txt file + * + * @param boardsFile + * @return + */ + private List readBoardsOrder(File boardsFile) { + String[] strings = PApplet.loadStrings(boardsFile); + + List res = new ArrayList(); + String latestBoard = "-"; + for (String s : strings) { + int dot = s.indexOf('.'); + if (dot == -1) + continue; + String board = s.substring(0, dot); + if (board.equals(latestBoard)) + continue; + if (!boards.containsKey(board)) + continue; + latestBoard = board; + res.add(board); + } + return res; + } + public String getName() { return name; } @@ -87,6 +118,10 @@ public class TargetPlatform { public Map getBoards() { return boards; } + + public List getOrderedBoards() { + return boardsOrder; + } public Map getProgrammers() { return programmers; diff --git a/hardware/arduino/avr/platform.txt b/hardware/arduino/avr/platform.txt index 557b2d3af..d439ddd5c 100644 --- a/hardware/arduino/avr/platform.txt +++ b/hardware/arduino/avr/platform.txt @@ -2,7 +2,7 @@ # AVR compile variables # --------------------- -name=Arduino +name=Arduino AVR Boards # Default "compiler.path" is correct, change only if you want to overidde the initial value #compiler.path={ide.path}/tools/avr/bin/.. compiler.c.cmd=avr-gcc diff --git a/hardware/arduino/sam/platform.txt b/hardware/arduino/sam/platform.txt index ce0e310b1..1b5993719 100644 --- a/hardware/arduino/sam/platform.txt +++ b/hardware/arduino/sam/platform.txt @@ -2,7 +2,7 @@ # SAM3 compile variables # --------------------- -name=Atmel SAM3 +name=Arduino ARM (32-bits) Boards compiler.path={runtime.ide.path}/hardware/tools/g++_arm_none_eabi/bin/ #compiler.path=C:/arm-none-eabi-gcc-4_6/bin/ compiler.c.cmd=arm-none-eabi-gcc