() {
+
+ @Override
+ public boolean add(File file) {
+ if (size() >= RECENT_SKETCHES_MAX_SIZE) {
+ return false;
+ }
+ return super.add(file);
+ }
+ };
+
+ for (String path : PreferencesData.getCollection("recent.sketches")) {
+ File file = new File(path);
+ if (file.exists()) {
+ recentSketches.add(file);
+ }
+ }
+
+ recentSketchesMenuItems.clear();
+ for (final File recentSketch : recentSketches) {
+ JMenuItem recentSketchMenuItem = new JMenuItem(recentSketch.getParentFile().getName());
+ recentSketchMenuItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent actionEvent) {
+ try {
+ handleOpen(recentSketch);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ recentSketchesMenuItems.add(recentSketchMenuItem);
+ }
+ }
+
/**
* Close a sketch as specified by its editor window.
@@ -993,35 +984,6 @@ public class Base {
editor.internalCloseRunner();
if (editors.size() == 1) {
- // For 0158, when closing the last window /and/ it was already an
- // untitled sketch, just give up and let the user quit.
-// if (Preferences.getBoolean("sketchbook.closing_last_window_quits") ||
-// (editor.untitled && !editor.getSketch().isModified())) {
- if (OSUtils.isMacOS()) {
- Object[] options = {"OK", "Cancel"};
- String prompt =
- _(" " +
- " " +
- "Are you sure you want to Quit?" +
- "Closing the last open sketch will quit Arduino.");
-
- int result = JOptionPane.showOptionDialog(editor,
- prompt,
- _("Quit"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null,
- options,
- options[0]);
- if (result == JOptionPane.NO_OPTION ||
- result == JOptionPane.CLOSED_OPTION) {
- return false;
- }
- }
-
// This will store the sketch count as zero
editors.remove(editor);
try {
@@ -1030,6 +992,7 @@ public class Base {
//ignore
}
storeSketches();
+ rebuildRecentSketchesMenuItems();
// Save out the current prefs state
PreferencesData.save();
@@ -1098,14 +1061,8 @@ public class Base {
* @return false if canceled along the way
*/
protected boolean handleQuitEach() {
- int index = 0;
for (Editor editor : editors) {
- if (editor.checkModified()) {
- // Update to the new/final sketch path for this fella
- storeSketchPath(editor, index);
- index++;
-
- } else {
+ if (!editor.checkModified()) {
return false;
}
}
@@ -1155,7 +1112,7 @@ public class Base {
// Add a list of all sketches and subfolders
try {
- boolean sketches = addSketches(menu, getSketchbookFolder(), true);
+ boolean sketches = addSketches(menu, BaseNoGui.getSketchbookFolder(), true);
if (sketches) menu.addSeparator();
} catch (IOException e) {
e.printStackTrace();
@@ -1176,7 +1133,7 @@ public class Base {
//new Exception().printStackTrace();
try {
menu.removeAll();
- addSketches(menu, getSketchbookFolder(), false);
+ addSketches(menu, BaseNoGui.getSketchbookFolder(), false);
//addSketches(menu, getSketchbookFolder());
} catch (IOException e) {
e.printStackTrace();
@@ -1195,6 +1152,13 @@ public class Base {
return new LibraryList(libs);
}
+ private List getSortedLibraries() {
+ List installedLibraries = new LinkedList(BaseNoGui.librariesIndexer.getInstalledLibraries());
+ Collections.sort(installedLibraries, new LibraryByTypeComparator());
+ Collections.sort(installedLibraries, new LibraryOfSameTypeComparator());
+ return installedLibraries;
+ }
+
public void rebuildImportMenu(JMenu importMenu) {
if (importMenu == null)
return;
@@ -1222,36 +1186,38 @@ public class Base {
importMenu.addSeparator();
// Split between user supplied libraries and IDE libraries
- TargetPlatform targetPlatform = getTargetPlatform();
+ TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
if (targetPlatform != null) {
- LibraryList ideLibs = getIDELibs();
- LibraryList userLibs = getUserLibs();
- try {
- // Find the current target. Get the platform, and then select the
- // correct name and core path.
- String platformNameLabel;
- platformNameLabel = StringUtils.capitalize(targetPlatform.getContainerPackage().getId()) + "/" + StringUtils.capitalize(targetPlatform.getId());
- platformNameLabel = I18n.format(_("{0} libraries"), platformNameLabel);
- JMenuItem platformItem = new JMenuItem(_(platformNameLabel));
- platformItem.setEnabled(false);
- importMenu.add(platformItem);
-
- if (ideLibs.size() > 0) {
- addLibraries(importMenu, ideLibs);
- }
-
- if (userLibs.size() > 0) {
- if (ideLibs.size() > 0) {
+ List libs = getSortedLibraries();
+ String lastLibType = null;
+ for (ContributedLibrary lib : libs) {
+ if (lastLibType == null || !lastLibType.equals(lib.getTypes().get(0))) {
+ if (lastLibType != null) {
importMenu.addSeparator();
}
- JMenuItem contributedLibraryItem = new JMenuItem(_("Contributed libraries"));
- contributedLibraryItem.setEnabled(false);
- importMenu.add(contributedLibraryItem);
- addLibraries(importMenu, userLibs);
+ lastLibType = lib.getTypes().get(0);
+ JMenuItem platformItem = new JMenuItem(I18n.format(_("{0} libraries"), lastLibType));
+ platformItem.setEnabled(false);
+ importMenu.add(platformItem);
}
- } catch (IOException e) {
- e.printStackTrace();
+
+ AbstractAction action = new AbstractAction(lib.getName()) {
+ public void actionPerformed(ActionEvent event) {
+ UserLibrary l = (UserLibrary) getValue("library");
+ try {
+ activeEditor.getSketch().importLibrary(l);
+ } catch (IOException e) {
+ showWarning(_("Error"), I18n.format("Unable to list header files in {0}", l.getSrcFolder()), e);
+ }
+ }
+ };
+ action.putValue("library", lib);
+
+ // Add new element at the bottom
+ JMenuItem item = new JMenuItem(action);
+ item.putClientProperty("library", lib);
+ importMenu.add(item);
}
}
}
@@ -1288,13 +1254,14 @@ public class Base {
BaseNoGui.onBoardOrPortChange();
// Update editors status bar
- for (Editor editor : editors)
+ for (Editor editor : editors) {
editor.onBoardOrPortChange();
+ }
}
private void openManageLibrariesDialog() {
@SuppressWarnings("serial")
- LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor) {
+ LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, BaseNoGui.getPlatform()) {
@Override
protected void onIndexesUpdated() throws Exception {
BaseNoGui.initPackages();
@@ -1317,7 +1284,7 @@ public class Base {
private void openInstallBoardDialog(final String filterText) throws Exception {
// Create dialog for contribution manager
@SuppressWarnings("serial")
- ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor) {
+ ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor, BaseNoGui.getPlatform()) {
@Override
protected void onIndexesUpdated() throws Exception {
BaseNoGui.initPackages();
@@ -1447,7 +1414,7 @@ public class Base {
@SuppressWarnings("serial")
Action action = new AbstractAction(board.getName()) {
public void actionPerformed(ActionEvent actionevent) {
- selectBoard((TargetBoard) getValue("b"));
+ BaseNoGui.selectBoard((TargetBoard) getValue("b"));
filterVisibilityOfSubsequentBoardMenus(boardsCustomMenus, (TargetBoard) getValue("b"), 1);
onBoardOrPortChange();
@@ -1570,15 +1537,6 @@ public class Base {
throw new IllegalStateException("Menu has no enabled items");
}
-
- private void selectBoard(TargetBoard targetBoard) {
- BaseNoGui.selectBoard(targetBoard);
- }
-
- public static void selectSerialPort(String port) {
- BaseNoGui.selectSerialPort(port);
- }
-
public void rebuildProgrammerMenu(JMenu menu) {
menu.removeAll();
ButtonGroup group = new ButtonGroup();
@@ -1767,14 +1725,6 @@ public class Base {
return list;
}
- protected void loadHardware(File folder) {
- BaseNoGui.loadHardware(folder);
- }
-
-
- // .................................................................
-
-
/**
* Show the About box.
*/
@@ -1816,217 +1766,22 @@ public class Base {
if (activeEditor != null) {
dialog.setLocationRelativeTo(activeEditor);
}
- dialog.pack();
- dialog.setMinimumSize(dialog.getSize());
dialog.setVisible(true);
}
-
- // ...................................................................
-
-
- /**
- * Get list of platform constants.
- */
-// static public int[] getPlatforms() {
-// return platforms;
-// }
-
-
-// static public int getPlatform() {
-// String osname = System.getProperty("os.name");
-//
-// if (osname.indexOf("Mac") != -1) {
-// return PConstants.MACOSX;
-//
-// } else if (osname.indexOf("Windows") != -1) {
-// return PConstants.WINDOWS;
-//
-// } else if (osname.equals("Linux")) { // true for the ibm vm
-// return PConstants.LINUX;
-//
-// } else {
-// return PConstants.OTHER;
-// }
-// }
- static public Platform getPlatform() {
- return BaseNoGui.getPlatform();
- }
-
-
- static public String getPlatformName() {
- String osname = System.getProperty("os.name");
-
- if (osname.indexOf("Mac") != -1) {
- return "macosx";
-
- } else if (osname.indexOf("Windows") != -1) {
- return "windows";
-
- } else if (osname.equals("Linux")) { // true for the ibm vm
- return "linux";
-
- } else {
- return "other";
- }
- }
-
-
- // .................................................................
-
-
- static public File getSettingsFolder() {
- return BaseNoGui.getSettingsFolder();
- }
-
-
- /**
- * Convenience method to get a File object for the specified filename inside
- * the settings folder.
- * For now, only used by Preferences to get the preferences.txt file.
- *
- * @param filename A file inside the settings folder.
- * @return filename wrapped as a File object inside the settings folder
- */
- static public File getSettingsFile(String filename) {
- return BaseNoGui.getSettingsFile(filename);
- }
-
-
- static public File getBuildFolder() {
- return BaseNoGui.getBuildFolder();
- }
-
-
- /**
- * Get the path to the platform's temporary folder, by creating
- * a temporary temporary file and getting its parent folder.
- *
- * Modified for revision 0094 to actually make the folder randomized
- * to avoid conflicts in multi-user environments. (Bug 177)
- */
- static public File createTempFolder(String name) {
- return BaseNoGui.createTempFolder(name);
- }
-
-
// XXX: Remove this method and make librariesIndexer non-static
static public LibraryList getLibraries() {
return BaseNoGui.librariesIndexer.getInstalledLibraries();
}
-
- static public String getExamplesPath() {
- return BaseNoGui.getExamplesPath();
- }
-
-
- static public List getLibrariesPath() {
- return BaseNoGui.getLibrariesPath();
- }
-
-
- static public File getToolsFolder() {
- return BaseNoGui.getToolsFolder();
- }
-
-
- static public String getToolsPath() {
- return BaseNoGui.getToolsPath();
- }
-
-
- static public File getHardwareFolder() {
- return BaseNoGui.getHardwareFolder();
- }
-
- //Get the core libraries
- static public File getCoreLibraries(String path) {
- return getContentFile(path);
- }
-
- static public String getHardwarePath() {
- return BaseNoGui.getHardwarePath();
- }
-
-
- static public String getAvrBasePath() {
- return BaseNoGui.getAvrBasePath();
- }
-
- /**
- * Returns a specific TargetPackage
- *
- * @param packageName
- * @return
- */
- static public TargetPackage getTargetPackage(String packageName) {
- return BaseNoGui.getTargetPackage(packageName);
- }
-
- /**
- * Returns the currently selected TargetPlatform.
- *
- * @return
- */
- static public TargetPlatform getTargetPlatform() {
- return BaseNoGui.getTargetPlatform();
- }
-
- /**
- * Returns a specific TargetPlatform searching Package/Platform
- *
- * @param packageName
- * @param platformName
- * @return
- */
- static public TargetPlatform getTargetPlatform(String packageName,
- String platformName) {
- return BaseNoGui.getTargetPlatform(packageName, platformName);
- }
-
- static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
- return BaseNoGui.getCurrentTargetPlatformFromPackage(pack);
- }
-
- static public PreferencesMap getBoardPreferences() {
- return BaseNoGui.getBoardPreferences();
- }
-
public List getBoardsCustomMenus() {
return boardsCustomMenus;
}
- static public File getPortableFolder() {
- return BaseNoGui.getPortableFolder();
- }
-
-
- static public String getPortableSketchbookFolder() {
- return BaseNoGui.getPortableSketchbookFolder();
- }
-
-
- static public File getSketchbookFolder() {
- return BaseNoGui.getSketchbookFolder();
- }
-
-
- static public File getSketchbookLibrariesFolder() {
- return BaseNoGui.getSketchbookLibrariesFolder();
- }
-
-
static public String getSketchbookLibrariesPath() {
- return getSketchbookLibrariesFolder().getAbsolutePath();
+ return BaseNoGui.getSketchbookLibrariesFolder().getAbsolutePath();
}
-
- static public File getSketchbookHardwareFolder() {
- return BaseNoGui.getSketchbookHardwareFolder();
- }
-
-
public File getDefaultSketchbookFolderOrPromptForIt() {
File sketchbookFolder = BaseNoGui.getDefaultSketchbookFolder();
@@ -2084,7 +1839,7 @@ public class Base {
*/
static public void openURL(String url) {
try {
- getPlatform().openURL(url);
+ BaseNoGui.getPlatform().openURL(url);
} catch (Exception e) {
showWarning(_("Problem Opening URL"),
@@ -2510,9 +2265,7 @@ public class Base {
}
return buffer;
} finally {
- if (input != null) {
- input.close();
- }
+ IOUtils.closeQuietly(input);
}
}
@@ -2560,12 +2313,8 @@ public class Base {
}
to.flush();
} finally {
- if (from != null) {
- from.close(); // ??
- }
- if (to != null) {
- to.close(); // ??
- }
+ IOUtils.closeQuietly(from);
+ IOUtils.closeQuietly(to);
}
targetFile.setLastModified(sourceFile.lastModified());
@@ -2597,12 +2346,15 @@ public class Base {
File targetDir) throws IOException {
targetDir.mkdirs();
String files[] = sourceDir.list();
- for (int i = 0; i < files.length; i++) {
+ if (files == null) {
+ throw new IOException("Unable to list files from " + sourceDir);
+ }
+ for (String file : files) {
// Ignore dot files (.DS_Store), dot folders (.svn) while copying
- if (files[i].charAt(0) == '.') continue;
+ if (file.charAt(0) == '.') continue;
//if (files[i].equals(".") || files[i].equals("..")) continue;
- File source = new File(sourceDir, files[i]);
- File target = new File(targetDir, files[i]);
+ File source = new File(sourceDir, file);
+ File target = new File(targetDir, file);
if (source.isDirectory()) {
//target.mkdirs();
copyDir(source, target);
@@ -2736,8 +2488,17 @@ public class Base {
}
}
- // is there a valid library?
File libFolder = sourceFile;
+ if (FileUtils.isSubDirectory(new File(PreferencesData.get("sketchbook.path")), libFolder)) {
+ activeEditor.statusError(_("A subfolder of your sketchbook is not a valid library"));
+ return;
+ }
+
+ if (FileUtils.isSubDirectory(libFolder, new File(PreferencesData.get("sketchbook.path")))) {
+ activeEditor.statusError(_("You can't import a folder that contains your sketchbook"));
+ return;
+ }
+
String libName = libFolder.getName();
if (!BaseNoGui.isSanitaryName(libName)) {
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
@@ -2748,8 +2509,19 @@ public class Base {
return;
}
+ String[] headers;
+ if (new File(libFolder, "library.properties").exists()) {
+ headers = BaseNoGui.headerListFromIncludePath(UserLibrary.create(libFolder).getSrcFolder());
+ } else {
+ headers = BaseNoGui.headerListFromIncludePath(libFolder);
+ }
+ if (headers.length == 0) {
+ activeEditor.statusError(_("Specified folder/zip file does not contain a valid library"));
+ return;
+ }
+
// copy folder
- File destinationFolder = new File(getSketchbookLibrariesFolder(), sourceFile.getName());
+ File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder(), sourceFile.getName());
if (!destinationFolder.mkdir()) {
activeEditor.statusError(I18n.format(_("A library named {0} already exists"), sourceFile.getName()));
return;
@@ -2761,6 +2533,8 @@ public class Base {
return;
}
activeEditor.statusNotice(_("Library added to your libraries. Check \"Include library\" menu"));
+ } catch (IOException e) {
+ // FIXME error when importing. ignoring :(
} finally {
// delete zip created temp folder, if exists
FileUtils.recursiveDelete(tmpFolder);
@@ -2790,4 +2564,8 @@ public class Base {
public PdeKeywords getPdeKeywords() {
return pdeKeywords;
}
+
+ public List getRecentSketchesMenuItems() {
+ return recentSketchesMenuItems;
+ }
}
diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java
index 9ca878055..e9e987c2f 100644
--- a/app/src/processing/app/Editor.java
+++ b/app/src/processing/app/Editor.java
@@ -25,6 +25,8 @@ package processing.app;
import cc.arduino.packages.MonitorFactory;
import cc.arduino.view.StubMenuListener;
+import cc.arduino.view.findreplace.FindReplace;
+import com.google.common.base.Predicate;
import com.jcraft.jsch.JSchException;
import jssc.SerialPortException;
import processing.app.debug.*;
@@ -68,20 +70,41 @@ import cc.arduino.packages.uploaders.SerialUploader;
@SuppressWarnings("serial")
public class Editor extends JFrame implements RunnerListener {
- private final static List BOARD_PROTOCOLS_ORDER = Arrays.asList(new String[]{"serial", "network"});
- private final static List BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(new String[]{_("Serial ports"), _("Network ports")});
+ public static final int MAX_TIME_AWAITING_FOR_RESUMING_SERIAL_MONITOR = 5000;
- Base base;
+ private final Platform platform;
+ private JMenu recentSketchesMenu;
+
+ private static class ShouldSaveIfModified implements Predicate {
+
+ @Override
+ public boolean apply(Sketch sketch) {
+ return PreferencesData.getBoolean("editor.save_on_verify") && sketch.isModified() && !sketch.isReadOnly();
+ }
+ }
+
+ private static class ShouldSaveReadOnly implements Predicate {
+
+ @Override
+ public boolean apply(Sketch sketch) {
+ return sketch.isReadOnly();
+ }
+ }
+
+ private final static List BOARD_PROTOCOLS_ORDER = Arrays.asList("serial", "network");
+ private final static List BOARD_PROTOCOLS_ORDER_TRANSLATIONS = Arrays.asList(_("Serial ports"), _("Network ports"));
+
+ final Base base;
// otherwise, if the window is resized with the message label
// set to blank, it's preferredSize() will be fukered
- static protected final String EMPTY =
+ private static final String EMPTY =
" " +
" " +
" ";
/** Command on Mac OS X, Ctrl on Windows and Linux */
- static final int SHORTCUT_KEY_MASK =
+ private static final int SHORTCUT_KEY_MASK =
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
/** Command-W on Mac OS X, Ctrl-W on Windows and Linux */
static final KeyStroke WINDOW_CLOSE_KEYSTROKE =
@@ -95,16 +118,15 @@ public class Editor extends JFrame implements RunnerListener {
*/
boolean untitled;
- PageFormat pageFormat;
- PrinterJob printerJob;
+ private PageFormat pageFormat;
// file, sketch, and tools menus for re-inserting items
- JMenu fileMenu;
- JMenu toolsMenu;
+ private JMenu fileMenu;
+ private JMenu toolsMenu;
- int numTools = 0;
+ private int numTools = 0;
- EditorToolbar toolbar;
+ private final EditorToolbar toolbar;
// these menus are shared so that they needn't be rebuilt for all windows
// each time a sketch is created, renamed, or moved.
static JMenu toolbarMenu;
@@ -112,60 +134,55 @@ public class Editor extends JFrame implements RunnerListener {
static JMenu examplesMenu;
static JMenu importMenu;
- static JMenu serialMenu;
+ private static JMenu serialMenu;
static AbstractMonitor serialMonitor;
- EditorHeader header;
+ final EditorHeader header;
EditorStatus status;
EditorConsole console;
- JSplitPane splitPane;
- JPanel consolePanel;
-
- JLabel lineNumberComponent;
+ private JSplitPane splitPane;
// currently opened program
Sketch sketch;
- EditorLineStatus lineStatus;
+ private EditorLineStatus lineStatus;
//JEditorPane editorPane;
- SketchTextArea textarea;
- RTextScrollPane scrollPane;
+ private SketchTextArea textarea;
+ private RTextScrollPane scrollPane;
- // runtime information and window placement
- Point sketchWindowLocation;
//Runner runtime;
- JMenuItem exportAppItem;
- JMenuItem saveMenuItem;
- JMenuItem saveAsMenuItem;
+ private JMenuItem saveMenuItem;
+ private JMenuItem saveAsMenuItem;
- boolean running;
//boolean presenting;
- boolean uploading;
+ private boolean uploading;
// undo fellers
- JMenuItem undoItem, redoItem;
+ private JMenuItem undoItem;
+ private JMenuItem redoItem;
protected UndoAction undoAction;
protected RedoAction redoAction;
- FindReplace find;
+ private FindReplace find;
Runnable runHandler;
Runnable presentHandler;
- Runnable runAndSaveHandler;
- Runnable presentAndSaveHandler;
- Runnable stopHandler;
+ private Runnable runAndSaveHandler;
+ private Runnable presentAndSaveHandler;
+ private Runnable stopHandler;
Runnable exportHandler;
- Runnable exportAppHandler;
+ private Runnable exportAppHandler;
- public Editor(Base ibase, File file, int[] location) throws Exception {
+ public Editor(Base ibase, File file, int[] location, Platform platform) throws Exception {
super("Arduino");
this.base = ibase;
+ this.platform = platform;
Base.setIcon(this);
@@ -239,7 +256,7 @@ public class Editor extends JFrame implements RunnerListener {
textarea.setName("editor");
// assemble console panel, consisting of status area and the console itself
- consolePanel = new JPanel();
+ JPanel consolePanel = new JPanel();
consolePanel.setLayout(new BorderLayout());
status = new EditorStatus(this);
@@ -338,7 +355,7 @@ public class Editor extends JFrame implements RunnerListener {
* window. Dragging files into the editor window is the same as using
* "Sketch → Add File" for each file.
*/
- class FileDropHandler extends TransferHandler {
+ private class FileDropHandler extends TransferHandler {
public boolean canImport(JComponent dest, DataFlavor[] flavors) {
return true;
}
@@ -364,14 +381,14 @@ public class Editor extends JFrame implements RunnerListener {
// this method of moving files.
String data = (String)transferable.getTransferData(uriListFlavor);
String[] pieces = PApplet.splitTokens(data, "\r\n");
- for (int i = 0; i < pieces.length; i++) {
- if (pieces[i].startsWith("#")) continue;
+ for (String piece : pieces) {
+ if (piece.startsWith("#")) continue;
String path = null;
- if (pieces[i].startsWith("file:///")) {
- path = pieces[i].substring(7);
- } else if (pieces[i].startsWith("file:/")) {
- path = pieces[i].substring(5);
+ if (piece.startsWith("file:///")) {
+ path = piece.substring(7);
+ } else if (piece.startsWith("file:/")) {
+ path = piece.substring(5);
}
if (sketch.addFile(new File(path))) {
successful++;
@@ -398,7 +415,7 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected void setPlacement(int[] location) {
+ private void setPlacement(int[] location) {
setBounds(location[0], location[1], location[2], location[3]);
if (location[4] != 0) {
splitPane.setDividerLocation(location[4]);
@@ -457,14 +474,13 @@ public class Editor extends JFrame implements RunnerListener {
if (external) {
// disable line highlight and turn off the caret when disabling
- Color color = Theme.getColor("editor.external.bgcolor");
- textarea.setBackground(color);
+ textarea.setBackground(Theme.getColor("editor.external.bgcolor"));
textarea.setHighlightCurrentLine(false);
textarea.setEditable(false);
} else {
- boolean highlight = PreferencesData.getBoolean("editor.linehighlight");
- textarea.setHighlightCurrentLine(highlight);
+ textarea.setBackground(Theme.getColor("editor.bgcolor"));
+ textarea.setHighlightCurrentLine(PreferencesData.getBoolean("editor.linehighlight"));
textarea.setEditable(true);
}
@@ -489,7 +505,7 @@ public class Editor extends JFrame implements RunnerListener {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
- protected void buildMenuBar() throws Exception {
+ private void buildMenuBar() {
JMenuBar menubar = new JMenuBar();
final JMenu fileMenu = buildFileMenu();
fileMenu.addMenuListener(new StubMenuListener() {
@@ -497,10 +513,10 @@ public class Editor extends JFrame implements RunnerListener {
public void menuSelected(MenuEvent e) {
List components = Arrays.asList(fileMenu.getComponents());
if (!components.contains(sketchbookMenu)) {
- fileMenu.insert(sketchbookMenu, 2);
+ fileMenu.insert(sketchbookMenu, 3);
}
if (!components.contains(sketchbookMenu)) {
- fileMenu.insert(examplesMenu, 3);
+ fileMenu.insert(examplesMenu, 4);
}
fileMenu.revalidate();
validate();
@@ -511,6 +527,7 @@ public class Editor extends JFrame implements RunnerListener {
menubar.add(buildEditMenu());
final JMenu sketchMenu = new JMenu(_("Sketch"));
+ sketchMenu.setMnemonic(KeyEvent.VK_S);
sketchMenu.addMenuListener(new StubMenuListener() {
@Override
@@ -549,9 +566,10 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected JMenu buildFileMenu() {
+ private JMenu buildFileMenu() {
JMenuItem item;
fileMenu = new JMenu(_("File"));
+ fileMenu.setMnemonic(KeyEvent.VK_F);
item = newJMenuItem(_("New"), 'N');
item.addActionListener(new ActionListener() {
@@ -577,6 +595,16 @@ public class Editor extends JFrame implements RunnerListener {
});
fileMenu.add(item);
+ base.rebuildRecentSketchesMenuItems();
+ recentSketchesMenu = new JMenu(_("Open Recent"));
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ rebuildRecentSketchesMenu();
+ }
+ });
+ fileMenu.add(recentSketchesMenu);
+
if (sketchbookMenu == null) {
sketchbookMenu = new JMenu(_("Sketchbook"));
MenuScroller.setScrollerFor(sketchbookMenu);
@@ -658,8 +686,14 @@ public class Editor extends JFrame implements RunnerListener {
return fileMenu;
}
+ public void rebuildRecentSketchesMenu() {
+ recentSketchesMenu.removeAll();
+ for (JMenuItem recentSketchMenuItem : base.getRecentSketchesMenuItems()) {
+ recentSketchesMenu.add(recentSketchMenuItem);
+ }
+ }
- protected void buildSketchMenu(JMenu sketchMenu) {
+ private void buildSketchMenu(JMenu sketchMenu) {
sketchMenu.removeAll();
JMenuItem item = newJMenuItem(_("Verify / Compile"), 'R');
@@ -690,7 +724,7 @@ public class Editor extends JFrame implements RunnerListener {
item = newJMenuItemAlt(_("Export compiled Binary"), 'S');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- handleRun(false, Editor.this.presentAndSaveHandler, Editor.this.runAndSaveHandler);
+ handleRun(false, new ShouldSaveReadOnly(), Editor.this.presentAndSaveHandler, Editor.this.runAndSaveHandler);
}
});
sketchMenu.add(item);
@@ -731,8 +765,9 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected JMenu buildToolsMenu() throws Exception {
+ private JMenu buildToolsMenu() {
toolsMenu = new JMenu(_("Tools"));
+ toolsMenu.setMnemonic(KeyEvent.VK_T);
addInternalTools(toolsMenu);
@@ -744,8 +779,8 @@ public class Editor extends JFrame implements RunnerListener {
});
toolsMenu.add(item);
- addTools(toolsMenu, Base.getToolsFolder());
- File sketchbookTools = new File(Base.getSketchbookFolder(), "tools");
+ addTools(toolsMenu, BaseNoGui.getToolsFolder());
+ File sketchbookTools = new File(BaseNoGui.getSketchbookFolder(), "tools");
addTools(toolsMenu, sketchbookTools);
toolsMenu.addSeparator();
@@ -801,7 +836,7 @@ public class Editor extends JFrame implements RunnerListener {
if (sel == null) {
if (!name.equals(basename)) menu.setText(basename);
} else {
- if (sel.length() > 17) sel = sel.substring(0, 16) + "...";
+ if (sel.length() > 50) sel = sel.substring(0, 50) + "...";
String newname = basename + ": \"" + sel + "\"";
if (!name.equals(newname)) menu.setText(newname);
}
@@ -814,7 +849,7 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected void addTools(JMenu menu, File sourceFolder) {
+ private void addTools(JMenu menu, File sourceFolder) {
if (sourceFolder == null)
return;
@@ -835,8 +870,8 @@ public class Editor extends JFrame implements RunnerListener {
return;
}
- for (int i = 0; i < folders.length; i++) {
- File toolDirectory = new File(folders[i], "tool");
+ for (File folder : folders) {
+ File toolDirectory = new File(folder, "tool");
try {
// add dir to classpath for .classes
@@ -846,7 +881,7 @@ public class Editor extends JFrame implements RunnerListener {
File[] archives = toolDirectory.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return (name.toLowerCase().endsWith(".jar") ||
- name.toLowerCase().endsWith(".zip"));
+ name.toLowerCase().endsWith(".zip"));
}
});
@@ -857,8 +892,8 @@ public class Editor extends JFrame implements RunnerListener {
URLClassLoader loader = new URLClassLoader(urlList);
String className = null;
- for (int j = 0; j < archives.length; j++) {
- className = findClassInZipFile(folders[i].getName(), archives[j]);
+ for (File archive : archives) {
+ className = findClassInZipFile(folder.getName(), archive);
if (className != null) break;
}
@@ -914,12 +949,12 @@ public class Editor extends JFrame implements RunnerListener {
menu.addSeparator();
Collections.sort(toolList);
for (String title : toolList) {
- menu.add((JMenuItem) toolItems.get(title));
+ menu.add(toolItems.get(title));
}
}
- protected String findClassInZipFile(String base, File file) {
+ private String findClassInZipFile(String base, File file) {
// Class file to search for
String classFileName = "/" + base + ".class";
@@ -946,18 +981,21 @@ public class Editor extends JFrame implements RunnerListener {
//System.err.println("Ignoring " + filename + " (" + e.getMessage() + ")");
e.printStackTrace();
} finally {
- if (zipFile != null)
+ if (zipFile != null) {
try {
zipFile.close();
} catch (IOException e) {
+ // noop
}
+ }
}
return null;
}
- protected SketchTextArea createTextArea() throws IOException {
+ private SketchTextArea createTextArea() throws IOException {
final SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
+ textArea.setFocusTraversalKeysEnabled(false);
textArea.requestFocusInWindow();
textArea.setMarkOccurrences(PreferencesData.getBoolean("editor.advanced"));
textArea.setMarginLineEnabled(false);
@@ -970,7 +1008,7 @@ public class Editor extends JFrame implements RunnerListener {
@Override
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
try {
- base.getPlatform().openURL(hyperlinkEvent.getURL().toExternalForm());
+ platform.openURL(sketch.getFolder(), hyperlinkEvent.getURL().toExternalForm());
} catch (Exception e) {
Base.showWarning(e.getMessage(), e.getMessage(), e);
}
@@ -994,7 +1032,7 @@ public class Editor extends JFrame implements RunnerListener {
return textArea;
}
- protected JMenuItem createToolMenuItem(String className) {
+ private JMenuItem createToolMenuItem(String className) {
try {
Class> toolClass = Class.forName(className);
final Tool tool = (Tool) toolClass.newInstance();
@@ -1017,10 +1055,13 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected JMenu addInternalTools(JMenu menu) {
+ private void addInternalTools(JMenu menu) {
JMenuItem item;
item = createToolMenuItem("cc.arduino.packages.formatter.AStyle");
+ if (item == null) {
+ throw new NullPointerException("Tool cc.arduino.packages.formatter.AStyle unavailable");
+ }
item.setName("menuToolsAutoFormat");
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
item.setAccelerator(KeyStroke.getKeyStroke('T', modifiers));
@@ -1030,17 +1071,6 @@ public class Editor extends JFrame implements RunnerListener {
//menu.add(createToolMenuItem("processing.app.tools.ColorSelector"));
menu.add(createToolMenuItem("processing.app.tools.Archiver"));
menu.add(createToolMenuItem("processing.app.tools.FixEncoding"));
-
-// // These are temporary entries while Android mode is being worked out.
-// // The mode will not be in the tools menu, and won't involve a cmd-key
-// if (!Base.RELEASE) {
-// item = createToolMenuItem("processing.app.tools.android.AndroidTool");
-// item.setAccelerator(KeyStroke.getKeyStroke('D', modifiers));
-// menu.add(item);
-// menu.add(createToolMenuItem("processing.app.tools.android.Reset"));
-// }
-
- return menu;
}
@@ -1059,7 +1089,7 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected void selectSerialPort(String name) {
+ private void selectSerialPort(String name) {
if(serialMenu == null) {
System.out.println(_("serialMenu is null"));
return;
@@ -1075,16 +1105,12 @@ public class Editor extends JFrame implements RunnerListener {
continue;
}
JCheckBoxMenuItem checkBoxMenuItem = ((JCheckBoxMenuItem) menuItem);
- if (checkBoxMenuItem == null) {
- System.out.println(_("name is null"));
- continue;
- }
checkBoxMenuItem.setState(false);
if (name.equals(checkBoxMenuItem.getText())) selection = checkBoxMenuItem;
}
if (selection != null) selection.setState(true);
//System.out.println(item.getLabel());
- Base.selectSerialPort(name);
+ BaseNoGui.selectSerialPort(name);
if (serialMonitor != null) {
try {
serialMonitor.close();
@@ -1094,20 +1120,20 @@ public class Editor extends JFrame implements RunnerListener {
}
}
- onBoardOrPortChange();
+ base.onBoardOrPortChange();
//System.out.println("set to " + get("serial.port"));
}
- protected void populatePortMenu() {
+ private void populatePortMenu() {
serialMenu.removeAll();
String selectedPort = PreferencesData.get("serial.port");
List ports = Base.getDiscoveryManager().discovery();
- ports = Base.getPlatform().filterPorts(ports, PreferencesData.getBoolean("serial.ports.showall"));
+ ports = platform.filterPorts(ports, PreferencesData.getBoolean("serial.ports.showall"));
Collections.sort(ports, new Comparator() {
@Override
@@ -1146,10 +1172,11 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected JMenu buildHelpMenu() {
+ private JMenu buildHelpMenu() {
// To deal with a Mac OS X 10.5 bug, add an extra space after the name
// so that the OS doesn't try to insert its slow help menu.
JMenu menu = new JMenu(_("Help"));
+ menu.setMnemonic(KeyEvent.VK_H);
JMenuItem item;
/*
@@ -1236,7 +1263,7 @@ public class Editor extends JFrame implements RunnerListener {
item = new JMenuItem(_("Troubleshooting"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- Base.showReference("reference/Galileo_help_files", "Guide_Troubleshooting_Galileo");;
+ Base.showReference("reference/Galileo_help_files", "Guide_Troubleshooting_Galileo");
}
});
menu.add(item);
@@ -1257,7 +1284,7 @@ public class Editor extends JFrame implements RunnerListener {
item = new JMenuItem(_("Troubleshooting"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- Base.showReference("reference/Edison_help_files", "Guide_Troubleshooting_Edison");;
+ Base.showReference("reference/Edison_help_files", "Guide_Troubleshooting_Edison");
}
});
menu.add(item);
@@ -1286,7 +1313,7 @@ public class Editor extends JFrame implements RunnerListener {
item = new JMenuItem(_("Visit Arduino.cc"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- Base.openURL(_("http://arduino.cc/"));
+ Base.openURL(_("http://www.arduino.cc/"));
}
});
menu.add(item);
@@ -1307,10 +1334,10 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected JMenu buildEditMenu() {
+ private JMenu buildEditMenu() {
JMenu menu = new JMenu(_("Edit"));
menu.setName("menuEdit");
- JMenuItem item;
+ menu.setMnemonic(KeyEvent.VK_E);
undoItem = newJMenuItem(_("Undo"), 'Z');
undoItem.setName("menuEditUndo");
@@ -1330,24 +1357,24 @@ public class Editor extends JFrame implements RunnerListener {
// TODO "cut" and "copy" should really only be enabled
// if some text is currently selected
- item = newJMenuItem(_("Cut"), 'X');
- item.addActionListener(new ActionListener() {
+ JMenuItem cutItem = newJMenuItem(_("Cut"), 'X');
+ cutItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleCut();
}
});
- menu.add(item);
+ menu.add(cutItem);
- item = newJMenuItem(_("Copy"), 'C');
- item.addActionListener(new ActionListener() {
+ JMenuItem copyItem = newJMenuItem(_("Copy"), 'C');
+ copyItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.copy();
}
});
- menu.add(item);
+ menu.add(copyItem);
- item = newJMenuItemShift(_("Copy for Forum"), 'C');
- item.addActionListener(new ActionListener() {
+ JMenuItem copyForumItem = newJMenuItemShift(_("Copy for Forum"), 'C');
+ copyForumItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
@@ -1356,10 +1383,10 @@ public class Editor extends JFrame implements RunnerListener {
// });
}
});
- menu.add(item);
+ menu.add(copyForumItem);
- item = newJMenuItemAlt(_("Copy as HTML"), 'C');
- item.addActionListener(new ActionListener() {
+ JMenuItem copyHTMLItem = newJMenuItemAlt(_("Copy as HTML"), 'C');
+ copyHTMLItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
@@ -1368,59 +1395,61 @@ public class Editor extends JFrame implements RunnerListener {
// });
}
});
- menu.add(item);
+ menu.add(copyHTMLItem);
- item = newJMenuItem(_("Paste"), 'V');
- item.addActionListener(new ActionListener() {
+ JMenuItem pasteItem = newJMenuItem(_("Paste"), 'V');
+ pasteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.paste();
sketch.setModified(true);
}
});
- menu.add(item);
+ menu.add(pasteItem);
- item = newJMenuItem(_("Select All"), 'A');
- item.addActionListener(new ActionListener() {
+ JMenuItem selectAllItem = newJMenuItem(_("Select All"), 'A');
+ selectAllItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textarea.selectAll();
}
});
- menu.add(item);
+ menu.add(selectAllItem);
menu.addSeparator();
- item = newJMenuItem(_("Comment/Uncomment"), '/');
- item.addActionListener(new ActionListener() {
+ JMenuItem commentItem = newJMenuItem(_("Comment/Uncomment"), '/');
+ commentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleCommentUncomment();
}
});
- menu.add(item);
+ menu.add(commentItem);
- item = newJMenuItem(_("Increase Indent"), ']');
- item.addActionListener(new ActionListener() {
+ JMenuItem increaseIndentItem = new JMenuItem(_("Increase Indent"));
+ increaseIndentItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
+ increaseIndentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleIndentOutdent(true);
}
});
- menu.add(item);
+ menu.add(increaseIndentItem);
- item = newJMenuItem(_("Decrease Indent"), '[');
- item.setName("menuDecreaseIndent");
- item.addActionListener(new ActionListener() {
+ JMenuItem decreseIndentItem = new JMenuItem(_("Decrease Indent"));
+ decreseIndentItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
+ decreseIndentItem.setName("menuDecreaseIndent");
+ decreseIndentItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handleIndentOutdent(false);
}
});
- menu.add(item);
+ menu.add(decreseIndentItem);
menu.addSeparator();
- item = newJMenuItem(_("Find..."), 'F');
- item.addActionListener(new ActionListener() {
+ JMenuItem findItem = newJMenuItem(_("Find..."), 'F');
+ findItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find == null) {
- find = new FindReplace(Editor.this);
+ find = new FindReplace(Editor.this, Base.FIND_DIALOG_STATE);
}
if (!OSUtils.isMacOS()) {
find.setFindText(getSelectedText());
@@ -1429,40 +1458,39 @@ public class Editor extends JFrame implements RunnerListener {
find.setVisible(true);
}
});
- menu.add(item);
+ menu.add(findItem);
- item = newJMenuItem(_("Find Next"), 'G');
- item.addActionListener(new ActionListener() {
+ JMenuItem findNextItem = newJMenuItem(_("Find Next"), 'G');
+ findNextItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find != null) {
find.findNext();
}
}
});
- menu.add(item);
+ menu.add(findNextItem);
- item = newJMenuItemShift(_("Find Previous"), 'G');
- item.addActionListener(new ActionListener() {
+ JMenuItem findPreviousItem = newJMenuItemShift(_("Find Previous"), 'G');
+ findPreviousItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find != null) {
find.findPrevious();
}
}
});
- menu.add(item);
+ menu.add(findPreviousItem);
if (OSUtils.isMacOS()) {
- item = newJMenuItem(_("Use Selection For Find"), 'E');
- item.addActionListener(new ActionListener() {
+ JMenuItem useSelectionForFindItem = newJMenuItem(_("Use Selection For Find"), 'E');
+ useSelectionForFindItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (find == null) {
- find = new FindReplace(Editor.this);
+ find = new FindReplace(Editor.this, Base.FIND_DIALOG_STATE);
}
find.setFindText(getSelectedText());
- find.findNext();
}
});
- menu.add(item);
+ menu.add(useSelectionForFindItem);
}
return menu;
@@ -1496,7 +1524,7 @@ public class Editor extends JFrame implements RunnerListener {
* Same as newJMenuItem(), but adds the ALT (on Linux and Windows)
* or OPTION (on Mac OS X) key as a modifier.
*/
- static public JMenuItem newJMenuItemAlt(String title, int what) {
+ private static JMenuItem newJMenuItemAlt(String title, int what) {
JMenuItem menuItem = new JMenuItem(title);
menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_ALT_KEY_MASK));
return menuItem;
@@ -1583,24 +1611,7 @@ public class Editor extends JFrame implements RunnerListener {
// abstract from the editor in this fashion.
- public void setHandlers(Runnable runHandler,
- Runnable presentHandler,
- Runnable runAndSaveHandler,
- Runnable presentAndSaveHandler,
- Runnable stopHandler,
- Runnable exportHandler,
- Runnable exportAppHandler) {
- this.runHandler = runHandler;
- this.presentHandler = presentHandler;
- this.runAndSaveHandler = runAndSaveHandler;
- this.presentAndSaveHandler = presentAndSaveHandler;
- this.stopHandler = stopHandler;
- this.exportHandler = exportHandler;
- this.exportAppHandler = exportAppHandler;
- }
-
-
- public void resetHandlers() {
+ private void resetHandlers() {
runHandler = new BuildHandler();
presentHandler = new BuildHandler(true);
runAndSaveHandler = new BuildHandler(false, true);
@@ -1642,18 +1653,6 @@ public class Editor extends JFrame implements RunnerListener {
}
- /**
- * Get a range of text from the current buffer.
- */
- public String getText(int start, int stop) {
- try {
- return textarea.getText(start, stop - start);
- } catch (BadLocationException e) {
- return null;
- }
- }
-
-
/**
* Replace the entire contents of the front-most tab.
*/
@@ -1695,25 +1694,6 @@ public class Editor extends JFrame implements RunnerListener {
}
- /**
- * Get the position (character offset) of the caret. With text selected,
- * this will be the last character actually selected, no matter the direction
- * of the selection. That is, if the user clicks and drags to select lines
- * 7 up to 4, then the caret position will be somewhere on line four.
- */
- public int getCaretOffset() {
- return textarea.getCaretPosition();
- }
-
-
- /**
- * True if some text is currently selected.
- */
- public boolean isSelectionActive() {
- return textarea.isSelectionActive();
- }
-
-
/**
* Get the beginning point of the current selection.
*/
@@ -1733,7 +1713,7 @@ public class Editor extends JFrame implements RunnerListener {
/**
* Get text for a specified line.
*/
- public String getLineText(int line) {
+ private String getLineText(int line) {
try {
return textarea.getText(textarea.getLineStartOffset(line), textarea.getLineEndOffset(line));
} catch (BadLocationException e) {
@@ -1742,38 +1722,6 @@ public class Editor extends JFrame implements RunnerListener {
}
- /**
- * Get character offset for the start of a given line of text.
- */
- public int getLineStartOffset(int line) {
- try {
- return textarea.getLineStartOffset(line);
- } catch (BadLocationException e) {
- return -1;
- }
- }
-
-
- /**
- * Get character offset for end of a given line of text.
- */
- public int getLineStopOffset(int line) {
- try {
- return textarea.getLineEndOffset(line);
- } catch (BadLocationException e) {
- return -1;
- }
- }
-
-
- /**
- * Get the number of lines in the currently displayed buffer.
- */
- public int getLineCount() {
- return textarea.getLineCount();
- }
-
-
public int getScrollPosition() {
return scrollPane.getVerticalScrollBar().getValue();
}
@@ -1841,64 +1789,21 @@ public class Editor extends JFrame implements RunnerListener {
/**
* Implements Edit → Cut.
*/
- public void handleCut() {
+ private void handleCut() {
textarea.cut();
}
- /**
- * Implements Edit → Copy.
- */
- public void handleCopy() {
- textarea.copy();
- }
-
-
- protected void handleDiscourseCopy() {
+ private void handleDiscourseCopy() {
new DiscourseFormat(Editor.this, false).show();
}
- protected void handleHTMLCopy() {
+ private void handleHTMLCopy() {
new DiscourseFormat(Editor.this, true).show();
}
- /**
- * Implements Edit → Paste.
- */
- public void handlePaste() {
- textarea.paste();
- }
-
-
- /**
- * Implements Edit → Select All.
- */
- public void handleSelectAll() {
- textarea.selectAll();
- }
-
- /**
- * Begins an "atomic" edit. This method is called when TextArea
- * KNOWS that some edits should be compound automatically, such as the playing back of a macro.
- *
- * @see #endInternalAtomicEdit()
- */
- public void beginInternalAtomicEdit(){
- textarea.getUndoManager().beginInternalAtomicEdit();
- }
-
- /**
- * Ends an "atomic" edit.
- *
- * @see #beginInternalAtomicEdit()
- */
- public void endInternalAtomicEdit(){
- textarea.getUndoManager().endInternalAtomicEdit();
- }
-
-
void handleCommentUncomment() {
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaToggleCommentAction);
@@ -1907,7 +1812,7 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected void handleIndentOutdent(boolean indent) {
+ private void handleIndentOutdent(boolean indent) {
if (indent) {
int caretPosition = textarea.getCaretPosition();
@@ -1936,13 +1841,8 @@ public class Editor extends JFrame implements RunnerListener {
action.actionPerformed(null);
}
}
-
- /** Checks the preferences you are in external editing mode */
- public static boolean isExternalMode(){
- return PreferencesData.getBoolean("editor.external");
- }
- protected String getCurrentKeyword() {
+ private String getCurrentKeyword() {
String text = "";
if (textarea.getSelectedText() != null)
text = textarea.getSelectedText().trim();
@@ -1983,7 +1883,7 @@ public class Editor extends JFrame implements RunnerListener {
return text;
}
- protected void handleFindReference() {
+ private void handleFindReference() {
String text = getCurrentKeyword();
String referenceFile = base.getPdeKeywords().getReference(text);
@@ -2005,13 +1905,14 @@ public class Editor extends JFrame implements RunnerListener {
* @param nonVerboseHandler
*/
public void handleRun(final boolean verbose, Runnable verboseHandler, Runnable nonVerboseHandler) {
+ handleRun(verbose, new ShouldSaveIfModified(), verboseHandler, nonVerboseHandler);
+ }
+
+ private void handleRun(final boolean verbose, Predicate shouldSavePredicate, Runnable verboseHandler, Runnable nonVerboseHandler) {
internalCloseRunner();
- if (PreferencesData.getBoolean("editor.save_on_verify")) {
- if (sketch.isModified() && !sketch.isReadOnly()) {
- handleSave(true);
- }
+ if (shouldSavePredicate.apply(sketch)) {
+ handleSave(true);
}
- running = true;
toolbar.activate(EditorToolbar.RUN);
status.progress(_("Compiling sketch..."));
@@ -2067,35 +1968,18 @@ public class Editor extends JFrame implements RunnerListener {
}
}
- class DefaultStopHandler implements Runnable {
+ private class DefaultStopHandler implements Runnable {
public void run() {
// TODO
// DAM: we should try to kill the compilation or upload process here.
}
}
- /**
- * Set the location of the sketch run window. Used by Runner to update the
- * Editor about window drag events while the sketch is running.
- */
- public void setSketchLocation(Point p) {
- sketchWindowLocation = p;
- }
-
-
- /**
- * Get the last location of the sketch's run window. Used by Runner to make
- * the window show up in the same location as when it was last closed.
- */
- public Point getSketchLocation() {
- return sketchWindowLocation;
- }
-
/**
* Implements Sketch → Stop, or pressing Stop on the toolbar.
*/
- public void handleStop() { // called by menu or buttons
+ private void handleStop() { // called by menu or buttons
// toolbar.activate(EditorToolbar.STOP);
internalCloseRunner();
@@ -2108,23 +1992,10 @@ public class Editor extends JFrame implements RunnerListener {
}
- /**
- * Deactivate the Run button. This is called by Runner to notify that the
- * sketch has stopped running, usually in response to an error (or maybe
- * the sketch completing and exiting?) Tools should not call this function.
- * To initiate a "stop" action, call handleStop() instead.
- */
- public void internalRunnerClosed() {
- running = false;
- toolbar.deactivate(EditorToolbar.RUN);
- }
-
-
/**
* Handle internal shutdown of the runner.
*/
public void internalCloseRunner() {
- running = false;
if (stopHandler != null)
try {
@@ -2198,7 +2069,7 @@ public class Editor extends JFrame implements RunnerListener {
// on macosx, setting the destructive property places this option
// away from the others at the lefthand side
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
- new Integer(2));
+ 2);
JDialog dialog = pane.createDialog(this, null);
dialog.setVisible(true);
@@ -2206,12 +2077,8 @@ public class Editor extends JFrame implements RunnerListener {
Object result = pane.getValue();
if (result == options[0]) { // save (and close/quit)
return handleSave(true);
-
- } else if (result == options[2]) { // don't save (still close/quit)
- return true;
-
- } else { // cancel?
- return false;
+ } else {
+ return result == options[2];
}
}
}
@@ -2326,11 +2193,6 @@ public class Editor extends JFrame implements RunnerListener {
// Disable untitled setting from previous document, if any
untitled = false;
- // Store information on who's open and running
- // (in case there's a crash or something that can't be recovered)
- base.storeSketches();
- PreferencesData.save();
-
// opening was successful
return true;
@@ -2374,16 +2236,24 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected boolean handleSave2() {
+ private boolean handleSave2() {
toolbar.activate(EditorToolbar.SAVE);
statusNotice(_("Saving..."));
boolean saved = false;
try {
+ boolean wasReadOnly = sketch.isReadOnly();
+ String previousMainFilePath = sketch.getMainFilePath();
saved = sketch.save();
- if (saved)
+ if (saved) {
statusNotice(_("Done Saving."));
- else
+ if (wasReadOnly) {
+ base.removeRecentSketchPath(previousMainFilePath);
+ }
+ base.storeRecentSketches(sketch);
+ base.rebuildRecentSketchesMenuItems();
+ } else {
statusEmpty();
+ }
// rebuild sketch menu in case a save-as was forced
// Disabling this for 0125, instead rebuild the menu inside
// the Save As method of the Sketch object, since that's the
@@ -2417,6 +2287,8 @@ public class Editor extends JFrame implements RunnerListener {
statusNotice(_("Saving..."));
try {
if (sketch.saveAs()) {
+ base.storeRecentSketches(sketch);
+ base.rebuildRecentSketchesMenuItems();
statusNotice(_("Done Saving."));
// Disabling this for 0125, instead rebuild the menu inside
// the Save As method of the Sketch object, since that's the
@@ -2439,11 +2311,11 @@ public class Editor extends JFrame implements RunnerListener {
}
- public boolean serialPrompt() {
+ private boolean serialPrompt() {
int count = serialMenu.getItemCount();
Object[] names = new Object[count];
for (int i = 0; i < count; i++) {
- names[i] = ((JCheckBoxMenuItem)serialMenu.getItem(i)).getText();
+ names[i] = serialMenu.getItem(i).getText();
}
String result = (String)
@@ -2498,9 +2370,9 @@ public class Editor extends JFrame implements RunnerListener {
public void run() {
try {
+ textarea.removeAllLineHighlights();
if (serialMonitor != null) {
- serialMonitor.close();
- serialMonitor.setVisible(false);
+ serialMonitor.suspend();
}
uploading = true;
@@ -2508,11 +2380,8 @@ public class Editor extends JFrame implements RunnerListener {
boolean success = sketch.exportApplet(false);
if (success) {
statusNotice(_("Done uploading."));
- } else {
- // error message will already be visible
}
} catch (SerialNotFoundException e) {
- populatePortMenu();
if (serialMenu.getItemCount() == 0) statusError(e);
else if (serialPrompt()) run();
else statusNotice(_("Upload canceled."));
@@ -2527,11 +2396,43 @@ public class Editor extends JFrame implements RunnerListener {
statusError(e);
} catch (Exception e) {
e.printStackTrace();
+ } finally {
+ populatePortMenu();
}
status.unprogress();
uploading = false;
//toolbar.clear();
toolbar.deactivate(EditorToolbar.EXPORT);
+
+ resumeOrCloseSerialMonitor();
+ base.onBoardOrPortChange();
+ }
+ }
+
+ private void resumeOrCloseSerialMonitor() {
+ // Return the serial monitor window to its initial state
+ if (serialMonitor != null) {
+ BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
+ long sleptFor = 0;
+ while (boardPort == null && sleptFor < MAX_TIME_AWAITING_FOR_RESUMING_SERIAL_MONITOR) {
+ try {
+ Thread.sleep(100);
+ sleptFor += 100;
+ boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
+ } catch (InterruptedException e) {
+ // noop
+ }
+ }
+ try {
+ if (boardPort == null) {
+ serialMonitor.close();
+ handleSerial();
+ } else {
+ serialMonitor.resume(boardPort);
+ }
+ } catch (Exception e) {
+ statusError(e);
+ }
}
}
@@ -2541,8 +2442,7 @@ public class Editor extends JFrame implements RunnerListener {
try {
if (serialMonitor != null) {
- serialMonitor.close();
- serialMonitor.setVisible(false);
+ serialMonitor.suspend();
}
uploading = true;
@@ -2550,11 +2450,8 @@ public class Editor extends JFrame implements RunnerListener {
boolean success = sketch.exportApplet(true);
if (success) {
statusNotice(_("Done uploading."));
- } else {
- // error message will already be visible
}
} catch (SerialNotFoundException e) {
- populatePortMenu();
if (serialMenu.getItemCount() == 0) statusError(e);
else if (serialPrompt()) run();
else statusNotice(_("Upload canceled."));
@@ -2569,58 +2466,38 @@ public class Editor extends JFrame implements RunnerListener {
statusError(e);
} catch (Exception e) {
e.printStackTrace();
+ } finally {
+ populatePortMenu();
}
status.unprogress();
uploading = false;
//toolbar.clear();
toolbar.deactivate(EditorToolbar.EXPORT);
+
+ resumeOrCloseSerialMonitor();
+ base.onBoardOrPortChange();
}
}
- /**
- * Checks to see if the sketch has been modified, and if so,
- * asks the user to save the sketch or cancel the export.
- * This prevents issues where an incomplete version of the sketch
- * would be exported, and is a fix for
- * Bug 157
- */
- protected boolean handleExportCheckModified() {
- if (!sketch.isModified()) return true;
-
- Object[] options = { _("OK"), _("Cancel") };
- int result = JOptionPane.showOptionDialog(this,
- _("Save changes before export?"),
- _("Save"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null,
- options,
- options[0]);
-
- if (result == JOptionPane.OK_OPTION) {
- handleSave(true);
-
- } else {
- // why it's not CANCEL_OPTION is beyond me (at least on the mac)
- // but f-- it.. let's get this shite done..
- //} else if (result == JOptionPane.CANCEL_OPTION) {
- statusNotice(_("Export canceled, changes must first be saved."));
- //toolbar.clear();
- return false;
- }
- return true;
- }
-
public void handleSerial() {
- if (uploading) return;
-
if (serialMonitor != null) {
- try {
- serialMonitor.close();
- serialMonitor.setVisible(false);
- } catch (Exception e) {
- // noop
+ // The serial monitor already exists
+
+ if (serialMonitor.isClosed()) {
+ // If it's closed, clear the refrence to the existing
+ // monitor and create a new one
+ serialMonitor = null;
+ }
+ else {
+ // If it's not closed, give it the focus
+ try {
+ serialMonitor.toFront();
+ serialMonitor.requestFocus();
+ return;
+ } catch (Exception e) {
+ // noop
+ }
}
}
@@ -2634,6 +2511,16 @@ public class Editor extends JFrame implements RunnerListener {
serialMonitor = new MonitorFactory().newMonitor(port);
serialMonitor.setIconImage(getIconImage());
+ // If currently uploading, disable the monitor (it will be later
+ // enabled when done uploading)
+ if (uploading) {
+ try {
+ serialMonitor.suspend();
+ } catch (Exception e) {
+ statusError(e);
+ }
+ }
+
boolean success = false;
do {
if (serialMonitor.requiresAuthorization() && !PreferencesData.has(serialMonitor.getAuthorizationKey())) {
@@ -2663,6 +2550,11 @@ public class Editor extends JFrame implements RunnerListener {
errorMessage += " (" + ((SerialPortException) e.getCause()).getExceptionType() + ")";
}
statusError(errorMessage);
+ try {
+ serialMonitor.close();
+ } catch (Exception e1) {
+ // noop
+ }
} catch (Exception e) {
statusError(e);
} finally {
@@ -2676,7 +2568,7 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected void handleBurnBootloader() {
+ private void handleBurnBootloader() {
console.clear();
statusNotice(_("Burning bootloader to I/O Board (this may take a minute)..."));
SwingUtilities.invokeLater(new Runnable() {
@@ -2707,28 +2599,22 @@ public class Editor extends JFrame implements RunnerListener {
/**
* Handler for File → Page Setup.
*/
- public void handlePageSetup() {
- //printerJob = null;
- if (printerJob == null) {
- printerJob = PrinterJob.getPrinterJob();
- }
+ private void handlePageSetup() {
+ PrinterJob printerJob = PrinterJob.getPrinterJob();
if (pageFormat == null) {
pageFormat = printerJob.defaultPage();
}
pageFormat = printerJob.pageDialog(pageFormat);
- //System.out.println("page format is " + pageFormat);
}
/**
* Handler for File → Print.
*/
- public void handlePrint() {
+ private void handlePrint() {
statusNotice(_("Printing..."));
//printerJob = null;
- if (printerJob == null) {
- printerJob = PrinterJob.getPrinterJob();
- }
+ PrinterJob printerJob = PrinterJob.getPrinterJob();
if (pageFormat != null) {
//System.out.println("setting page format " + pageFormat);
printerJob.setPrintable(textarea, pageFormat);
@@ -2838,7 +2724,7 @@ public class Editor extends JFrame implements RunnerListener {
/**
* Clear the status area.
*/
- public void statusEmpty() {
+ private void statusEmpty() {
statusNotice(EMPTY);
}
@@ -2846,7 +2732,7 @@ public class Editor extends JFrame implements RunnerListener {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
protected void onBoardOrPortChange() {
- Map boardPreferences = Base.getBoardPreferences();
+ Map boardPreferences = BaseNoGui.getBoardPreferences();
if (boardPreferences != null)
lineStatus.setBoardName(boardPreferences.get("name"));
else
@@ -2856,13 +2742,16 @@ public class Editor extends JFrame implements RunnerListener {
}
- protected void configurePopupMenu(final SketchTextArea textarea){
+ private void configurePopupMenu(final SketchTextArea textarea){
JPopupMenu menu = textarea.getPopupMenu();
menu.addSeparator();
JMenuItem item = createToolMenuItem("cc.arduino.packages.formatter.AStyle");
+ if (item == null) {
+ throw new NullPointerException("Tool cc.arduino.packages.formatter.AStyle unavailable");
+ }
item.setName("menuToolsAutoFormat");
menu.add(item);
diff --git a/app/src/processing/app/EditorConsoleStream.java b/app/src/processing/app/EditorConsoleStream.java
index 6ad0a336a..fbcc27215 100644
--- a/app/src/processing/app/EditorConsoleStream.java
+++ b/app/src/processing/app/EditorConsoleStream.java
@@ -1,6 +1,7 @@
package processing.app;
import cc.arduino.files.DeleteFilesOnShutdown;
+import org.apache.commons.compress.utils.IOUtils;
import static processing.app.I18n._;
@@ -34,7 +35,7 @@ class EditorConsoleStream extends OutputStream {
// sister IDEs) might collide with the file causing permissions problems.
// The files and folders are not deleted on exit because they may be
// needed for debugging or bug reporting.
- tempFolder = Base.createTempFolder("console");
+ tempFolder = BaseNoGui.createTempFolder("console");
DeleteFilesOnShutdown.add(tempFolder);
try {
String outFileName = PreferencesData.get("console.output.file");
@@ -82,17 +83,13 @@ class EditorConsoleStream extends OutputStream {
System.setErr(systemErr);
// close the PrintStream
- consoleOut.close();
- consoleErr.close();
+ IOUtils.closeQuietly(consoleOut);
+ IOUtils.closeQuietly(consoleErr);
// also have to close the original FileOutputStream
// otherwise it won't be shut down completely
- try {
- stdoutFile.close();
- stderrFile.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ IOUtils.closeQuietly(stdoutFile);
+ IOUtils.closeQuietly(stderrFile);
outFile.delete();
errFile.delete();
@@ -149,4 +146,4 @@ class EditorConsoleStream extends OutputStream {
currentConsole = console;
}
-}
\ No newline at end of file
+}
diff --git a/app/src/processing/app/EditorLineStatus.java b/app/src/processing/app/EditorLineStatus.java
index 2696d7d41..253f3919d 100644
--- a/app/src/processing/app/EditorLineStatus.java
+++ b/app/src/processing/app/EditorLineStatus.java
@@ -91,7 +91,7 @@ public class EditorLineStatus extends JComponent {
public void paintComponent(Graphics g) {
if (name == "" && serialport == "") {
- PreferencesMap boardPreferences = Base.getBoardPreferences();
+ PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
if (boardPreferences != null)
setBoardName(boardPreferences.get("name"));
else
diff --git a/app/src/processing/app/EditorListener.java b/app/src/processing/app/EditorListener.java
index 19e90b1c3..cbd082cfc 100644
--- a/app/src/processing/app/EditorListener.java
+++ b/app/src/processing/app/EditorListener.java
@@ -1,7 +1,7 @@
package processing.app;
import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@@ -17,12 +17,9 @@ public class EditorListener implements KeyListener {
}
/** ctrl-alt on windows and linux, cmd-alt on mac os x */
- static final int CTRL_ALT = ActionEvent.ALT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
-
- static final int CTRL_SHIFT = ActionEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
-
- static final int CTRL = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
-
+ private static final int CTRL = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
+ private static final int CTRL_ALT = InputEvent.ALT_MASK | CTRL;
+ private static final int CTRL_SHIFT = InputEvent.SHIFT_MASK | CTRL;
public void keyTyped(KeyEvent event) {
char c = event.getKeyChar();
@@ -37,7 +34,7 @@ public class EditorListener implements KeyListener {
@Override
public void keyPressed(KeyEvent event) {
-
+
SketchTextArea textarea = editor.getTextArea();
if (!textarea.isEditable()) return;
@@ -53,8 +50,7 @@ public class EditorListener implements KeyListener {
// Navigation..
// FIXME: not working on LINUX !!!
- if (((event.getModifiers() & CTRL_SHIFT) == CTRL_SHIFT)) {
- if(code == KeyEvent.VK_TAB)
+ if ((event.getModifiers() & CTRL_SHIFT) == CTRL_SHIFT && code == KeyEvent.VK_TAB) {
sketch.handlePrevCode();
}
@@ -80,4 +76,4 @@ public class EditorListener implements KeyListener {
}
-}
\ No newline at end of file
+}
diff --git a/app/src/processing/app/EditorStatus.java b/app/src/processing/app/EditorStatus.java
index 82abf3aa2..ce84c8c82 100644
--- a/app/src/processing/app/EditorStatus.java
+++ b/app/src/processing/app/EditorStatus.java
@@ -465,7 +465,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void actionPerformed(ActionEvent e) {
String message = "";
message += _("Arduino: ") + BaseNoGui.VERSION_NAME_LONG + " (" + System.getProperty("os.name") + "), ";
- message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n\n";
+ message += _("Board: ") + "\"" + BaseNoGui.getBoardPreferences().get("name") + "\"\n\n";
message += editor.console.consoleTextPane.getText().trim();
if ((PreferencesData.getBoolean("build.verbose")) == false) {
message += "\n\n";
diff --git a/app/src/processing/app/EditorToolbar.java b/app/src/processing/app/EditorToolbar.java
index 67edcdb79..d007ed724 100644
--- a/app/src/processing/app/EditorToolbar.java
+++ b/app/src/processing/app/EditorToolbar.java
@@ -43,7 +43,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
/** Titles for each button when the shift key is pressed. */
static final String titleShift[] = {
- _("Verify"), _("Upload Using Programmer"), _("New"), _("Open in Another Window"), _("Save"), _("Serial Monitor")
+ _("Verify"), _("Upload Using Programmer"), _("New"), _("Open in Another Window"), _("Save As..."), _("Serial Monitor")
};
static final int BUTTON_COUNT = title.length;
@@ -342,7 +342,11 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
break;
case SAVE:
- editor.handleSave(false);
+ if (e.isShiftDown()) {
+ editor.handleSaveAs();
+ } else {
+ editor.handleSave(false);
+ }
break;
case EXPORT:
diff --git a/app/src/processing/app/FindReplace.java b/app/src/processing/app/FindReplace.java
deleted file mode 100644
index 1c3b380d9..000000000
--- a/app/src/processing/app/FindReplace.java
+++ /dev/null
@@ -1,462 +0,0 @@
-/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
- Part of the Processing project - http://processing.org
-
- Copyright (c) 2004-08 Ben Fry and Casey Reas
- Copyright (c) 2001-04 Massachusetts Institute of Technology
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-package processing.app;
-import static processing.app.I18n._;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-import javax.swing.border.Border;
-
-import processing.app.helpers.OSUtils;
-
-
-/**
- * Find & Replace window for the Processing editor.
- *
- * One major annoyance in this is that the window is re-created each time
- * that "Find" is called. This is because Mac OS X has a strange focus
- * issue with windows that are re-shown with setVisible() or show().
- * requestFocusInWindow() properly sets the focus to the find field,
- * however, just a short moment later, the focus is set to null. Even
- * trying to catch this scenario and request it again doesn't seem to work.
- * Most likely this is some annoyance buried deep in one of Apple's docs,
- * or in the doc for the focus stuff (I tend to think the former because
- * Windows doesn't seem to be quite so beligerent). Filed as
- * Bug 244
- * should anyone have clues about how to fix.
- */
-@SuppressWarnings("serial")
-public class FindReplace extends JFrame implements ActionListener {
-
- private Editor editor;
-
- private JTextField findField;
- private JTextField replaceField;
- private static String findString;
- private static String replaceString;
-
- private JButton replaceButton;
- private JButton replaceAllButton;
- private JButton replaceFindButton;
- private JButton previousButton;
- private JButton findButton;
-
- private JCheckBox ignoreCaseBox;
- private static boolean ignoreCase = true;
-
- private JCheckBox wrapAroundBox;
- private static boolean wrapAround = true;
-
- private JCheckBox searchAllFilesBox;
- private static boolean searchAllFiles = false;
-
- public FindReplace(Editor editor) {
- super(_("Find"));
- this.editor = editor;
-
- JPanel contentPanel = new JPanel();
- Border padding = BorderFactory.createEmptyBorder(10, 10, 10, 10);
- contentPanel.setBorder(padding);
- setContentPane(contentPanel);
-
- JLabel findLabel = new JLabel(_("Find:"));
- findField = new JTextField(20);
- JLabel replaceLabel = new JLabel(_("Replace with:"));
- replaceField = new JTextField(20);
-
- // Fill the findString with selected text if no previous value
- if (editor.getSelectedText() != null
- && editor.getSelectedText().length() > 0)
- findString = editor.getSelectedText();
-
- if (findString != null)
- findField.setText(findString);
- if (replaceString != null)
- replaceField.setText(replaceString);
-
- ignoreCaseBox = new JCheckBox(_("Ignore Case"));
- ignoreCaseBox.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- ignoreCase = ignoreCaseBox.isSelected();
- }
- });
- ignoreCaseBox.setSelected(ignoreCase);
-
- wrapAroundBox = new JCheckBox(_("Wrap Around"));
- wrapAroundBox.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- wrapAround = wrapAroundBox.isSelected();
- }
- });
- wrapAroundBox.setSelected(wrapAround);
-
- searchAllFilesBox = new JCheckBox(_("Search all Sketch Tabs"));
- searchAllFilesBox.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- searchAllFiles = searchAllFilesBox.isSelected();
- }
- });
- searchAllFilesBox.setSelected(searchAllFiles);
-
- JPanel checkboxPanel = new JPanel();
- checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.PAGE_AXIS));
- checkboxPanel.add(ignoreCaseBox);
- checkboxPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- checkboxPanel.add(wrapAroundBox);
- checkboxPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- checkboxPanel.add(searchAllFilesBox);
-
- replaceAllButton = new JButton(_("Replace All"));
- replaceAllButton.addActionListener(this);
- replaceButton = new JButton(_("Replace"));
- replaceButton.addActionListener(this);
- replaceFindButton = new JButton(_("Replace & Find"));
- replaceFindButton.addActionListener(this);
- previousButton = new JButton(_("Previous"));
- previousButton.addActionListener(this);
- findButton = new JButton(_("Find"));
- findButton.addActionListener(this);
-
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
-
- // ordering of buttons is different on mac versus pc
- if (OSUtils.isMacOS()) {
- buttonPanel.add(replaceAllButton);
- buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- buttonPanel.add(replaceButton);
- buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- buttonPanel.add(replaceFindButton);
- buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- buttonPanel.add(previousButton);
- buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- buttonPanel.add(findButton);
-
- } else {
- buttonPanel.add(findButton);
- buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- buttonPanel.add(previousButton); // is this the right position for
- // non-Mac?
- buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- buttonPanel.add(replaceFindButton);
- buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- buttonPanel.add(replaceButton);
- buttonPanel.add(Box.createRigidArea(new Dimension(8, 0)));
- buttonPanel.add(replaceAllButton);
- }
-
- // to fix ugliness.. normally macosx java 1.3 puts an
- // ugly white border around this object, so turn it off.
- if (OSUtils.isMacOS()) {
- buttonPanel.setBorder(null);
- }
-
- // Put all components onto the dialog window
- GridBagLayout searchLayout = new GridBagLayout();
- GridBagConstraints gbc = new GridBagConstraints();
- Container pane = getContentPane();
- pane.setLayout(searchLayout);
-
- gbc.insets = new Insets(4, 4, 4, 4);
- gbc.gridx = 0;
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.anchor = GridBagConstraints.LINE_END;
- pane.add(findLabel, gbc);
- gbc.gridx = 1;
- gbc.weightx = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.anchor = GridBagConstraints.LINE_START;
- pane.add(findField, gbc);
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.weightx = 0.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.anchor = GridBagConstraints.LINE_END;
- pane.add(replaceLabel, gbc);
- gbc.gridx = 1;
- gbc.weightx = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.anchor = GridBagConstraints.LINE_START;
- pane.add(replaceField, gbc);
- gbc.gridx = 1;
- gbc.gridy = 2;
- gbc.weighty = 0.0;
- gbc.fill = GridBagConstraints.NONE;
- pane.add(checkboxPanel, gbc);
- gbc.anchor = GridBagConstraints.CENTER;
- gbc.gridwidth = 2;
- gbc.gridx = 0;
- gbc.gridy = 3;
- gbc.insets = new Insets(12, 4, 4, 4);
- pane.add(buttonPanel, gbc);
-
- pack();
- setResizable(false);
- // centers the dialog on thew screen
- setLocationRelativeTo(null);
-
- // make the find button the blinky default
- getRootPane().setDefaultButton(findButton);
-
- setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- handleClose();
- }
- });
- Base.registerWindowCloseKeys(getRootPane(), new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- // hide();
- handleClose();
- }
- });
- Base.setIcon(this);
-
- // hack to to get first field to focus properly on osx
- addWindowListener(new WindowAdapter() {
- public void windowActivated(WindowEvent e) {
- // System.out.println("activating");
- /* boolean ok = */findField.requestFocusInWindow();
- // System.out.println("got " + ok);
- findField.selectAll();
- }
- });
- }
-
- public void handleClose() {
- // System.out.println("handling close now");
- findString = findField.getText();
- replaceString = replaceField.getText();
-
- // this object should eventually become dereferenced
- setVisible(false);
- }
-
- /*
- public void show() {
- findField.requestFocusInWindow();
- super.show();
- //findField.selectAll();
- //findField.requestFocus();
- }
- */
-
-
- public void actionPerformed(ActionEvent e) {
- Object source = e.getSource();
-
- if (source == findButton) {
- findNext();
-
- } else if (source == previousButton) {
- findPrevious();
-
- } else if (source == replaceFindButton) {
- replaceAndFindNext();
-
- } else if (source == replaceButton) {
- replace();
-
- } else if (source == replaceAllButton) {
- replaceAll();
- }
- }
-
- // look for the next instance of the find string to be found
- // once found, select it (and go to that line)
-
- private boolean find(boolean wrap, boolean backwards, boolean searchTabs,
- int originTab) {
- // System.out.println("Find: " + originTab);
- boolean wrapNeeded = false;
- String search = findField.getText();
- // System.out.println("finding for " + search + " " + findString);
- // this will catch "find next" being called when no search yet
- if (search.length() == 0)
- return false;
-
- String text = editor.getText();
-
- if (ignoreCase) {
- search = search.toLowerCase();
- text = text.toLowerCase();
- }
-
- int nextIndex;
- if (!backwards) {
- // int selectionStart = editor.textarea.getSelectionStart();
- int selectionEnd = editor.getSelectionStop();
-
- nextIndex = text.indexOf(search, selectionEnd);
- if (wrap && nextIndex == -1) {
- // if wrapping, a second chance is ok, start from beginning
- wrapNeeded = true;
- }
- } else {
- // int selectionStart = editor.textarea.getSelectionStart();
- int selectionStart = editor.getSelectionStart() - 1;
-
- if (selectionStart >= 0) {
- nextIndex = text.lastIndexOf(search, selectionStart);
- } else {
- nextIndex = -1;
- }
- if (wrap && nextIndex == -1) {
- // if wrapping, a second chance is ok, start from the end
- wrapNeeded = true;
- }
- }
-
- if (nextIndex == -1) {
- // Nothing found on this tab: Search other tabs if required
- if (searchTabs) {
- // editor.
- Sketch sketch = editor.getSketch();
- if (sketch.getCodeCount() > 1) {
- int realCurrentTab = sketch.getCodeIndex(sketch.getCurrentCode());
-
- if (originTab != realCurrentTab) {
- if (originTab < 0)
- originTab = realCurrentTab;
-
- if (!wrap)
- if ((!backwards && realCurrentTab + 1 >= sketch.getCodeCount())
- || (backwards && realCurrentTab - 1 < 0))
- return false; // Can't continue without wrap
-
- if (backwards) {
- sketch.handlePrevCode();
- this.setVisible(true);
- int l = editor.getText().length() - 1;
- editor.setSelection(l, l);
- } else {
- sketch.handleNextCode();
- this.setVisible(true);
- editor.setSelection(0, 0);
- }
-
- return find(wrap, backwards, searchTabs, originTab);
- }
- }
- }
-
- if (wrapNeeded)
- nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search,
- 0);
- }
-
- if (nextIndex != -1) {
- editor.setSelection(nextIndex, nextIndex + search.length());
- return true;
- }
-
- return false;
- }
-
- /**
- * Replace the current selection with whatever's in the replacement text
- * field.
- */
- public void replace() {
- if (findField.getText().length() == 0)
- return;
-
- int newpos = editor.getSelectionStart() - findField.getText().length();
- if (newpos < 0)
- newpos = 0;
- editor.setSelection(newpos, newpos);
-
- boolean foundAtLeastOne = false;
-
- if (find(false, false, searchAllFiles, -1)) {
- foundAtLeastOne = true;
- editor.setSelectedText(replaceField.getText());
- editor.getSketch().setModified(true); // TODO is this necessary?
- }
-
- if (!foundAtLeastOne) {
- Toolkit.getDefaultToolkit().beep();
- }
-
- }
-
- /**
- * Replace the current selection with whatever's in the replacement text
- * field, and then find the next match
- */
- public void replaceAndFindNext() {
- replace();
- findNext();
- }
-
- /**
- * Replace everything that matches by doing find and replace alternately until
- * nothing more found.
- */
- public void replaceAll() {
- if (findField.getText().length() == 0)
- return;
- // move to the beginning
- editor.setSelection(0, 0);
-
- boolean foundAtLeastOne = false;
- while (true) {
- if (find(false, false, searchAllFiles, -1)) {
- foundAtLeastOne = true;
- editor.setSelectedText(replaceField.getText());
- editor.getSketch().setModified(true); // TODO is this necessary?
- } else {
- break;
- }
- }
- if (!foundAtLeastOne) {
- Toolkit.getDefaultToolkit().beep();
- }
- }
-
- public void setFindText(String text) {
- if (text == null) {
- return;
- }
- findField.setText(text);
- findString = text;
- }
-
- public void findNext() {
- if (!find(wrapAround, false, searchAllFiles, -1)) {
- Toolkit.getDefaultToolkit().beep();
- }
- }
-
- public void findPrevious() {
- if (!find(wrapAround, true, searchAllFiles, -1)) {
- Toolkit.getDefaultToolkit().beep();
- }
- }
-
-}
diff --git a/app/src/processing/app/NetworkMonitor.java b/app/src/processing/app/NetworkMonitor.java
index 850481ef7..716c9f0fc 100644
--- a/app/src/processing/app/NetworkMonitor.java
+++ b/app/src/processing/app/NetworkMonitor.java
@@ -26,18 +26,13 @@ public class NetworkMonitor extends AbstractMonitor implements MessageConsumer {
private static final int MAX_CONNECTION_ATTEMPTS = 5;
- private final BoardPort port;
- private final String ipAddress;
-
private MessageSiphon inputConsumer;
private Session session;
private Channel channel;
private int connectionAttempts;
public NetworkMonitor(BoardPort port) {
- super(port.getLabel());
- this.port = port;
- this.ipAddress = port.getAddress();
+ super(port);
onSendCommand(new ActionListener() {
public void actionPerformed(ActionEvent event) {
@@ -61,16 +56,17 @@ public class NetworkMonitor extends AbstractMonitor implements MessageConsumer {
@Override
public String getAuthorizationKey() {
- return "runtime.pwd." + ipAddress;
+ return "runtime.pwd." + getBoardPort().getAddress();
}
@Override
public void open() throws Exception {
+ super.open();
this.connectionAttempts = 0;
JSch jSch = new JSch();
SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup());
- session = sshClientSetupChain.setup(port, jSch);
+ session = sshClientSetupChain.setup(getBoardPort(), jSch);
session.setUserInfo(new NoInteractionUserInfo(PreferencesData.get(getAuthorizationKey())));
session.connect(30000);
@@ -156,6 +152,8 @@ public class NetworkMonitor extends AbstractMonitor implements MessageConsumer {
@Override
public void close() throws Exception {
+ super.close();
+
if (channel != null) {
inputConsumer.stop();
channel.disconnect();
diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java
index 6f76d6e4f..8dc00c137 100644
--- a/app/src/processing/app/Preferences.java
+++ b/app/src/processing/app/Preferences.java
@@ -84,13 +84,6 @@ public class Preferences {
static final int GUI_SMALL = 6;
- static protected void init(File file) {
- PreferencesData.init(file);
-
- // other things that have to be set explicitly for the defaults
- PreferencesHelper.putColor(PreferencesData.prefs, "run.window.bgcolor", SystemColor.control);
- }
-
@Deprecated
protected static void save() {
PreferencesData.save();
diff --git a/app/src/processing/app/SerialMonitor.java b/app/src/processing/app/SerialMonitor.java
index 9f48f82cb..9e4184855 100644
--- a/app/src/processing/app/SerialMonitor.java
+++ b/app/src/processing/app/SerialMonitor.java
@@ -30,14 +30,11 @@ import static processing.app.I18n._;
@SuppressWarnings("serial")
public class SerialMonitor extends AbstractMonitor {
- private final String port;
private Serial serial;
private int serialRate;
public SerialMonitor(BoardPort port) {
- super(port.getLabel());
-
- this.port = port.getAddress();
+ super(port);
serialRate = PreferencesData.getInteger("serial.debug_rate");
serialRates.setSelectedItem(serialRate + " " + _("baud"));
@@ -89,9 +86,11 @@ public class SerialMonitor extends AbstractMonitor {
}
public void open() throws Exception {
+ super.open();
+
if (serial != null) return;
- serial = new Serial(port, serialRate) {
+ serial = new Serial(getBoardPort().getAddress(), serialRate) {
@Override
protected void message(char buff[], int n) {
addToUpdateBuffer(buff, n);
@@ -100,6 +99,7 @@ public class SerialMonitor extends AbstractMonitor {
}
public void close() throws Exception {
+ super.close();
if (serial != null) {
int[] location = getPlacement();
String locationStr = PApplet.join(PApplet.str(location), ",");
diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java
index 74ca35733..9cae9d25e 100644
--- a/app/src/processing/app/Sketch.java
+++ b/app/src/processing/app/Sketch.java
@@ -49,7 +49,7 @@ import java.util.List;
public class Sketch {
static private File tempBuildFolder;
- private Editor editor;
+ private final Editor editor;
/** true if any of the files have been modified. */
private boolean modified;
@@ -57,11 +57,8 @@ public class Sketch {
private SketchCodeDocument current;
private int currentIndex;
- private SketchData data;
+ private final SketchData data;
- /** Class name for the PApplet, as determined by the preprocessor. */
- private String appletClassName;
-
/**
* path is location of the main .pde file, because this is also
* simplest to use when opening the file from the finder/explorer.
@@ -86,7 +83,7 @@ public class Sketch {
"the application to complete the repair.", null);
}
*/
- tempBuildFolder = Base.getBuildFolder();
+ tempBuildFolder = BaseNoGui.getBuildFolder();
//Base.addBuildFolderToClassPath();
load();
@@ -108,6 +105,10 @@ public class Sketch {
* in which case the load happens each time "run" is hit.
*/
protected void load() throws IOException {
+ load(false);
+ }
+
+ protected void load(boolean forceUpdate) throws IOException {
data.load();
for (SketchCode code : data.getCodes()) {
@@ -117,12 +118,12 @@ public class Sketch {
// set the main file to be the current tab
if (editor != null) {
- setCurrentCode(0);
+ setCurrentCode(currentIndex, forceUpdate);
}
}
- boolean renamingCode;
+ private boolean renamingCode;
/**
* Handler for the New Code menu option.
@@ -444,7 +445,7 @@ public class Sketch {
Object[] options = { _("OK"), _("Cancel") };
String prompt = (currentIndex == 0) ?
_("Are you sure you want to delete this sketch?") :
- I18n.format(_("Are you sure you want to delete \"{0}\"?"), current.getCode().getPrettyName());
+ I18n.format(_("Are you sure you want to delete \"{0}\"?"), current.getCode().getFileNameWithExtensionIfNotIno());
int result = JOptionPane.showOptionDialog(editor,
prompt,
_("Delete"),
@@ -519,7 +520,7 @@ public class Sketch {
}
- protected void calcModified() {
+ private void calcModified() {
modified = false;
for (SketchCode code : data.getCodes()) {
if (code.isModified()) {
@@ -611,7 +612,7 @@ public class Sketch {
}
- protected boolean renameCodeToInoExtension(File pdeFile) {
+ private boolean renameCodeToInoExtension(File pdeFile) {
for (SketchCode c : data.getCodes()) {
if (!c.getFile().equals(pdeFile))
continue;
@@ -636,14 +637,11 @@ public class Sketch {
* because they can cause trouble.
*/
protected boolean saveAs() throws IOException {
- String newParentDir = null;
- String newName = null;
-
// get new name for folder
FileDialog fd = new FileDialog(editor, _("Save sketch folder as..."), FileDialog.SAVE);
if (isReadOnly() || isUntitled()) {
// default to the sketchbook folder
- fd.setDirectory(Base.getSketchbookFolder().getAbsolutePath());
+ fd.setDirectory(BaseNoGui.getSketchbookFolder().getAbsolutePath());
} else {
// default to the parent folder of where this was
// on macs a .getParentFile() method is required
@@ -654,8 +652,8 @@ public class Sketch {
fd.setFile(oldName);
fd.setVisible(true);
- newParentDir = fd.getDirectory();
- newName = fd.getFile();
+ String newParentDir = fd.getDirectory();
+ String newName = fd.getFile();
// user canceled selection
if (newName == null) return false;
@@ -836,7 +834,7 @@ public class Sketch {
destFile = new File(data.getCodeFolder(), filename);
} else {
- for (String extension : data.getExtensions()) {
+ for (String extension : SketchData.EXTENSIONS) {
String lower = filename.toLowerCase();
if (lower.endsWith("." + extension)) {
destFile = new File(data.getFolder(), filename);
@@ -956,10 +954,10 @@ public class Sketch {
// could also scan the text in the file to see if each import
// statement is already in there, but if the user has the import
// commented out, then this will be a problem.
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < list.length; i++) {
+ StringBuilder buffer = new StringBuilder();
+ for (String aList : list) {
buffer.append("#include <");
- buffer.append(list[i]);
+ buffer.append(aList);
buffer.append(">\n");
}
buffer.append('\n');
@@ -979,8 +977,12 @@ public class Sketch {
*
*/
public void setCurrentCode(int which) {
+ setCurrentCode(which, false);
+ }
+
+ public void setCurrentCode(int which, boolean forceUpdate) {
// if current is null, then this is the first setCurrent(0)
- if ((currentIndex == which) && (current != null)) {
+ if (!forceUpdate && (currentIndex == which) && (current != null)) {
return;
}
@@ -1065,69 +1067,14 @@ public class Sketch {
//handleOpen(sketch);
//history.lastRecorded = historySaved;
- // set current to null so that the tab gets updated
- // http://dev.processing.org/bugs/show_bug.cgi?id=515
- current = null;
// nuke previous files and settings, just get things loaded
- load();
+ load(true);
}
// // handle preprocessing the main file's code
// return build(tempBuildFolder.getAbsolutePath());
}
-
-
- /**
- * Map an error from a set of processed .java files back to its location
- * in the actual sketch.
- * @param message The error message.
- * @param filename The .java file where the exception was found.
- * @param line Line number of the .java file for the exception (1-indexed)
- * @return A RunnerException to be sent to the editor, or null if it wasn't
- * possible to place the exception to the sketch code.
- */
-// public RunnerException placeExceptionAlt(String message,
-// String filename, int line) {
-// String appletJavaFile = appletClassName + ".java";
-// SketchCode errorCode = null;
-// if (filename.equals(appletJavaFile)) {
-// for (SketchCode code : getCode()) {
-// if (code.isExtension("ino")) {
-// if (line >= code.getPreprocOffset()) {
-// errorCode = code;
-// }
-// }
-// }
-// } else {
-// for (SketchCode code : getCode()) {
-// if (code.isExtension("java")) {
-// if (filename.equals(code.getFileName())) {
-// errorCode = code;
-// }
-// }
-// }
-// }
-// int codeIndex = getCodeIndex(errorCode);
-//
-// if (codeIndex != -1) {
-// //System.out.println("got line num " + lineNumber);
-// // in case this was a tab that got embedded into the main .java
-// line -= getCode(codeIndex).getPreprocOffset();
-//
-// // lineNumber is 1-indexed, but editor wants zero-indexed
-// line--;
-//
-// // getMessage() will be what's shown in the editor
-// RunnerException exception =
-// new RunnerException(message, codeIndex, line, -1);
-// exception.hideStackTrace();
-// return exception;
-// }
-// return null;
-// }
-
-
/**
* Run the build inside the temporary build folder.
* @return null if compilation failed, main class name if not
@@ -1235,29 +1182,6 @@ public class Sketch {
return success;
}
-
- public boolean exportApplicationPrompt() throws IOException, RunnerException {
- return false;
- }
-
-
- /**
- * Export to application via GUI.
- */
- protected boolean exportApplication() throws IOException, RunnerException {
- return false;
- }
-
-
- /**
- * Export to application without GUI.
- */
- public boolean exportApplication(String destPath,
- int exportPlatform) throws IOException, RunnerException {
- return false;
- }
-
-
/**
* Make sure the sketch hasn't been moved or deleted by some
* nefarious user. If they did, try to re-create it and save.
@@ -1297,11 +1221,11 @@ public class Sketch {
*/
public boolean isReadOnly() {
String apath = data.getFolder().getAbsolutePath();
- for (File folder : Base.getLibrariesPath()) {
+ for (File folder : BaseNoGui.getLibrariesPath()) {
if (apath.startsWith(folder.getAbsolutePath()))
return true;
}
- if (apath.startsWith(Base.getExamplesPath()) ||
+ if (apath.startsWith(BaseNoGui.getExamplesPath()) ||
apath.startsWith(Base.getSketchbookLibrariesPath())) {
return true;
}
@@ -1345,7 +1269,7 @@ public class Sketch {
* extensions.
*/
public boolean validExtension(String what) {
- return data.getExtensions().contains(what);
+ return SketchData.EXTENSIONS.contains(what);
}
@@ -1356,7 +1280,7 @@ public class Sketch {
return data.getDefaultExtension();
}
- static private List hiddenExtensions = Arrays.asList("ino", "pde");
+ static private final List hiddenExtensions = Arrays.asList("ino", "pde");
public List getHiddenExtensions() {
return hiddenExtensions;
@@ -1452,11 +1376,6 @@ public class Sketch {
}
- public String getAppletClassName2() {
- return appletClassName;
- }
-
-
// .................................................................
diff --git a/app/src/processing/app/UpdateCheck.java b/app/src/processing/app/UpdateCheck.java
index b3b48dfef..b13e7040f 100644
--- a/app/src/processing/app/UpdateCheck.java
+++ b/app/src/processing/app/UpdateCheck.java
@@ -22,6 +22,7 @@
package processing.app;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.legacy.PApplet;
import javax.swing.*;
@@ -133,9 +134,7 @@ public class UpdateCheck implements Runnable {
reader = new BufferedReader(new InputStreamReader(url.openStream()));
return Integer.parseInt(reader.readLine());
} finally {
- if (reader != null) {
- reader.close();
- }
+ IOUtils.closeQuietly(reader);
}
}
}
diff --git a/app/src/processing/app/helpers/GUIUserNotifier.java b/app/src/processing/app/helpers/GUIUserNotifier.java
index de20b7e3f..0e82cc32a 100644
--- a/app/src/processing/app/helpers/GUIUserNotifier.java
+++ b/app/src/processing/app/helpers/GUIUserNotifier.java
@@ -1,5 +1,7 @@
package processing.app.helpers;
+import processing.app.Base;
+
import static processing.app.I18n._;
import java.awt.Frame;
@@ -8,6 +10,12 @@ import javax.swing.JOptionPane;
public class GUIUserNotifier extends UserNotifier {
+ private final Base base;
+
+ public GUIUserNotifier(Base base) {
+ this.base = base;
+ }
+
/**
* Show an error message that's actually fatal to the program.
* This is an error that can't be recovered. Use showWarning()
@@ -16,7 +24,7 @@ public class GUIUserNotifier extends UserNotifier {
public void showError(String title, String message, Throwable e, int exit_code) {
if (title == null) title = _("Error");
- JOptionPane.showMessageDialog(new Frame(), message, title,
+ JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
JOptionPane.ERROR_MESSAGE);
if (e != null) e.printStackTrace();
@@ -30,7 +38,7 @@ public class GUIUserNotifier extends UserNotifier {
public void showMessage(String title, String message) {
if (title == null) title = _("Message");
- JOptionPane.showMessageDialog(new Frame(), message, title,
+ JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
JOptionPane.INFORMATION_MESSAGE);
}
@@ -40,7 +48,7 @@ public class GUIUserNotifier extends UserNotifier {
public void showWarning(String title, String message, Exception e) {
if (title == null) title = _("Warning");
- JOptionPane.showMessageDialog(new Frame(), message, title,
+ JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
JOptionPane.WARNING_MESSAGE);
if (e != null) e.printStackTrace();
diff --git a/app/src/processing/app/macosx/ThinkDifferent.java b/app/src/processing/app/macosx/ThinkDifferent.java
index 1f243a8d4..a7fd15570 100644
--- a/app/src/processing/app/macosx/ThinkDifferent.java
+++ b/app/src/processing/app/macosx/ThinkDifferent.java
@@ -83,7 +83,7 @@ public class ThinkDifferent {
@Override
public void handleQuitRequestWith(AppEvent.QuitEvent quitEvent, QuitResponse quitResponse) {
if (waitForBase()) {
- if (Base.INSTANCE.handleClose(Base.INSTANCE.getActiveEditor())) {
+ if (Base.INSTANCE.handleQuit()) {
quitResponse.performQuit();
} else {
quitResponse.cancelQuit();
@@ -107,10 +107,10 @@ public class ThinkDifferent {
private static void sleep(int millis) {
try {
- Thread.sleep(100);
+ Thread.sleep(millis);
} catch (InterruptedException e) {
//ignore
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/processing/app/syntax/MyConfigurableCaret.java b/app/src/processing/app/syntax/MyConfigurableCaret.java
new file mode 100644
index 000000000..87cc5c546
--- /dev/null
+++ b/app/src/processing/app/syntax/MyConfigurableCaret.java
@@ -0,0 +1,23 @@
+package processing.app.syntax;
+
+import org.fife.ui.rtextarea.ConfigurableCaret;
+import processing.app.helpers.OSUtils;
+
+import javax.swing.*;
+import java.awt.event.MouseEvent;
+
+public class MyConfigurableCaret extends ConfigurableCaret {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.isConsumed()) {
+ return;
+ }
+
+ if (!OSUtils.isLinux() && SwingUtilities.isMiddleMouseButton(e)) {
+ return;
+ }
+
+ super.mouseClicked(e);
+ }
+}
diff --git a/app/src/processing/app/syntax/PdeKeywords.java b/app/src/processing/app/syntax/PdeKeywords.java
index 3b5a575ce..8740b0675 100644
--- a/app/src/processing/app/syntax/PdeKeywords.java
+++ b/app/src/processing/app/syntax/PdeKeywords.java
@@ -25,6 +25,7 @@
package processing.app.syntax;
import cc.arduino.contributions.libraries.ContributedLibrary;
+import org.apache.commons.compress.utils.IOUtils;
import org.fife.ui.rsyntaxtextarea.TokenMap;
import org.fife.ui.rsyntaxtextarea.TokenTypes;
import processing.app.Base;
@@ -126,9 +127,7 @@ public class PdeKeywords {
fillMissingTokenType();
} finally {
- if (reader != null) {
- reader.close();
- }
+ IOUtils.closeQuietly(reader);
}
}
diff --git a/app/src/processing/app/syntax/SketchTextArea.java b/app/src/processing/app/syntax/SketchTextArea.java
index 580fe99f7..d1245f840 100644
--- a/app/src/processing/app/syntax/SketchTextArea.java
+++ b/app/src/processing/app/syntax/SketchTextArea.java
@@ -30,6 +30,7 @@
package processing.app.syntax;
+import org.apache.commons.compress.utils.IOUtils;
import org.fife.ui.rsyntaxtextarea.*;
import org.fife.ui.rsyntaxtextarea.Theme;
import org.fife.ui.rsyntaxtextarea.Token;
@@ -85,7 +86,7 @@ public class SketchTextArea extends RSyntaxTextArea {
installFeatures();
}
- protected void installFeatures() throws IOException {
+ private void installFeatures() throws IOException {
setTheme(PreferencesData.get("editor.syntax_theme", "default"));
setLinkGenerator(new DocLinkGenerator(pdeKeywords));
@@ -95,16 +96,14 @@ public class SketchTextArea extends RSyntaxTextArea {
setSyntaxEditingStyle(SYNTAX_STYLE_CPLUSPLUS);
}
- public void setTheme(String name) throws IOException {
+ private void setTheme(String name) throws IOException {
FileInputStream defaultXmlInputStream = null;
try {
defaultXmlInputStream = new FileInputStream(new File(BaseNoGui.getContentFile("lib"), "theme/syntax/" + name + ".xml"));
Theme theme = Theme.load(defaultXmlInputStream);
theme.apply(this);
} finally {
- if (defaultXmlInputStream != null) {
- defaultXmlInputStream.close();
- }
+ IOUtils.closeQuietly(defaultXmlInputStream);
}
setForeground(processing.app.Theme.getColor("editor.fgcolor"));
@@ -127,6 +126,7 @@ public class SketchTextArea extends RSyntaxTextArea {
setSyntaxTheme(TokenTypes.COMMENT_EOL, "comment1");
setSyntaxTheme(TokenTypes.COMMENT_KEYWORD, "comment1");
setSyntaxTheme(TokenTypes.COMMENT_MARKUP, "comment1");
+ setSyntaxTheme(TokenTypes.LITERAL_BOOLEAN, "literal_boolean");
setSyntaxTheme(TokenTypes.LITERAL_CHAR, "literal_char");
setSyntaxTheme(TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, "literal_string_double_quote");
}
@@ -143,7 +143,7 @@ public class SketchTextArea extends RSyntaxTextArea {
// Removing the default focus traversal keys
// This is because the DefaultKeyboardFocusManager handles the keypress and consumes the event
- protected void fixControlTab() {
+ private void fixControlTab() {
removeCTRLTabFromFocusTraversal();
removeCTRLSHIFTTabFromFocusTraversal();
@@ -151,23 +151,18 @@ public class SketchTextArea extends RSyntaxTextArea {
private void removeCTRLSHIFTTabFromFocusTraversal() {
KeyStroke ctrlShiftTab = KeyStroke.getKeyStroke("ctrl shift TAB");
- Set backwardKeys = new HashSet(this.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
+ Set backwardKeys = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
backwardKeys.remove(ctrlShiftTab);
}
private void removeCTRLTabFromFocusTraversal() {
KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl TAB");
- Set forwardKeys = new HashSet(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
+ Set forwardKeys = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
forwardKeys.remove(ctrlTab);
this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys);
}
- @Override
- public void select(int selectionStart, int selectionEnd) {
- super.select(selectionStart, selectionEnd);
- }
-
public boolean isSelectionActive() {
return this.getSelectedText() != null;
}
@@ -221,17 +216,6 @@ public class SketchTextArea extends RSyntaxTextArea {
}
- @Override
- protected JPopupMenu createPopupMenu() {
- JPopupMenu menu = super.createPopupMenu();
- return menu;
- }
-
- @Override
- protected void configurePopupMenu(JPopupMenu popupMenu) {
- super.configurePopupMenu(popupMenu);
- }
-
@Override
protected RTAMouseListener createMouseListener() {
return new SketchTextAreaMouseListener(this);
@@ -242,7 +226,7 @@ public class SketchTextArea extends RSyntaxTextArea {
int offset = getLineStartOffset(line);
int end = getLineEndOffset(line);
getDocument().getText(offset, end - offset, segment);
- } catch (BadLocationException e) {
+ } catch (BadLocationException ignored) {
}
}
@@ -271,16 +255,16 @@ public class SketchTextArea extends RSyntaxTextArea {
@Override
public LinkGeneratorResult isLinkAtOffset(RSyntaxTextArea textArea, final int offs) {
+ Token token = textArea.modelToToken(offs);
+ if (token == null) {
+ return null;
+ }
- final Token token = textArea.modelToToken(offs);
+ String reference = pdeKeywords.getReference(token.getLexeme());
- final String reference = pdeKeywords.getReference(token.getLexeme());
+ if (reference != null || (token.getType() == TokenTypes.DATA_TYPE || token.getType() == TokenTypes.VARIABLE || token.getType() == TokenTypes.FUNCTION)) {
- // LOG.fine("reference: " + reference + ", match: " + (token.getType() == TokenTypes.DATA_TYPE || token.getType() == TokenTypes.VARIABLE || token.getType() == TokenTypes.FUNCTION));
-
- if (token != null && (reference != null || (token.getType() == TokenTypes.DATA_TYPE || token.getType() == TokenTypes.VARIABLE || token.getType() == TokenTypes.FUNCTION))) {
-
- LinkGeneratorResult generatorResult = new LinkGeneratorResult() {
+ return new LinkGeneratorResult() {
@Override
public int getSourceOffset() {
@@ -297,8 +281,6 @@ public class SketchTextArea extends RSyntaxTextArea {
return null;
}
};
-
- return generatorResult;
}
return null;
@@ -316,7 +298,7 @@ public class SketchTextArea extends RSyntaxTextArea {
private boolean isScanningForLinks;
private int hoveredOverLinkOffset = -1;
- protected SketchTextAreaMouseListener(RTextArea textArea) {
+ SketchTextAreaMouseListener(RTextArea textArea) {
super(textArea);
insets = new Insets(0, 0, 0, 0);
}
@@ -458,7 +440,7 @@ public class SketchTextArea extends RSyntaxTextArea {
if (isScanningForLinks) {
Cursor c = getCursor();
isScanningForLinks = false;
- if (c != null && c.getType() == Cursor.HAND_CURSOR) {
+ if (c.getType() == Cursor.HAND_CURSOR) {
setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
repaint(); // TODO: Repaint just the affected line.
}
diff --git a/app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java b/app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java
index 5d806f4c9..8c6299f2b 100644
--- a/app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java
+++ b/app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java
@@ -1,6 +1,7 @@
package processing.app.syntax;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaDefaultInputMap;
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit;
import org.fife.ui.rtextarea.RTextArea;
import org.fife.ui.rtextarea.RTextAreaEditorKit;
import processing.app.PreferencesData;
@@ -15,6 +16,7 @@ public class SketchTextAreaDefaultInputMap extends RSyntaxTextAreaDefaultInputMa
public SketchTextAreaDefaultInputMap() {
int defaultModifier = getDefaultModifier();
int alt = InputEvent.ALT_MASK;
+ int shift = InputEvent.SHIFT_MASK;
boolean isOSX = RTextArea.isOSX();
int moveByWordMod = isOSX ? alt : defaultModifier;
@@ -37,7 +39,24 @@ public class SketchTextAreaDefaultInputMap extends RSyntaxTextAreaDefaultInputMa
put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, defaultModifier), DefaultEditorKit.beginAction);
put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, defaultModifier), DefaultEditorKit.endAction);
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, defaultModifier | shift), DefaultEditorKit.selectionBeginLineAction);
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, defaultModifier | shift), DefaultEditorKit.selectionEndLineAction);
+
remove(KeyStroke.getKeyStroke(KeyEvent.VK_J, defaultModifier));
+
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, defaultModifier), DefaultEditorKit.insertTabAction);
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, defaultModifier), RSyntaxTextAreaEditorKit.rstaDecreaseIndentAction);
+
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, defaultModifier | shift), DefaultEditorKit.selectionBeginAction);
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, defaultModifier | shift), DefaultEditorKit.selectionEndAction);
}
+
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, defaultModifier), RSyntaxTextAreaEditorKit.rstaToggleCommentAction);
+
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0), DefaultEditorKit.backwardAction);
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0), DefaultEditorKit.forwardAction);
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, 0), DefaultEditorKit.downAction);
+ put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, 0), DefaultEditorKit.upAction);
+
}
}
diff --git a/app/src/processing/app/syntax/SketchTextAreaUI.java b/app/src/processing/app/syntax/SketchTextAreaUI.java
index 7ae86a102..0f23e3145 100644
--- a/app/src/processing/app/syntax/SketchTextAreaUI.java
+++ b/app/src/processing/app/syntax/SketchTextAreaUI.java
@@ -3,6 +3,7 @@ package processing.app.syntax;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaUI;
import javax.swing.*;
+import javax.swing.text.Caret;
import javax.swing.text.EditorKit;
import javax.swing.text.JTextComponent;
@@ -18,4 +19,11 @@ public class SketchTextAreaUI extends RSyntaxTextAreaUI {
public EditorKit getEditorKit(JTextComponent tc) {
return defaultKit;
}
+
+ @Override
+ protected Caret createCaret() {
+ Caret caret = new MyConfigurableCaret();
+ caret.setBlinkRate(500);
+ return caret;
+ }
}
diff --git a/app/src/processing/app/syntax/SketchTokenMaker.java b/app/src/processing/app/syntax/SketchTokenMaker.java
index 92f105bc5..14a1d936f 100644
--- a/app/src/processing/app/syntax/SketchTokenMaker.java
+++ b/app/src/processing/app/syntax/SketchTokenMaker.java
@@ -32,8 +32,6 @@ package processing.app.syntax;
import org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker;
-import java.util.Arrays;
-
/**
* Controls the syntax highlighting of {@link SketchTextArea} based on the {@link PdeKeywords}
*
@@ -51,6 +49,11 @@ public class SketchTokenMaker extends CPlusPlusTokenMaker {
@Override
public void addToken(char[] array, int start, int end, int tokenType, int startOffset, boolean hyperlink) {
+ if (start > end) {
+ super.addToken(array, start, end, tokenType, startOffset, hyperlink);
+ return;
+ }
+
// This assumes all of your extra tokens would normally be scanned as IDENTIFIER.
int newType = pdeKeywords.getTokenType(array, start, end);
if (newType > -1) {
diff --git a/app/src/processing/app/tools/Archiver.java b/app/src/processing/app/tools/Archiver.java
index c0f533023..664d4dff6 100644
--- a/app/src/processing/app/tools/Archiver.java
+++ b/app/src/processing/app/tools/Archiver.java
@@ -23,6 +23,7 @@
package processing.app.tools;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.Base;
import processing.app.Editor;
import processing.app.Sketch;
@@ -124,22 +125,21 @@ public class Archiver implements Tool {
if (filename != null) {
newbie = new File(directory, filename);
+ ZipOutputStream zos = null;
try {
//System.out.println(newbie);
- FileOutputStream zipOutputFile = new FileOutputStream(newbie);
- ZipOutputStream zos = new ZipOutputStream(zipOutputFile);
+ zos = new ZipOutputStream(new FileOutputStream(newbie));
// recursively fill the zip file
buildZip(location, name, zos);
// close up the jar file
zos.flush();
- zos.close();
-
editor.statusNotice("Created archive " + newbie.getName() + ".");
-
} catch (IOException e) {
e.printStackTrace();
+ } finally {
+ IOUtils.closeQuietly(zos);
}
} else {
editor.statusNotice(_("Archive sketch canceled."));
@@ -150,6 +150,9 @@ public class Archiver implements Tool {
public void buildZip(File dir, String sofar,
ZipOutputStream zos) throws IOException {
String files[] = dir.list();
+ if (files == null) {
+ throw new IOException("Unable to list files from " + dir);
+ }
for (int i = 0; i < files.length; i++) {
if (files[i].equals(".") ||
files[i].equals("..")) continue;
diff --git a/app/src/processing/app/tools/AutoFormat.java b/app/src/processing/app/tools/AutoFormat.java
deleted file mode 100644
index f855400b1..000000000
--- a/app/src/processing/app/tools/AutoFormat.java
+++ /dev/null
@@ -1,950 +0,0 @@
-/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
- Part of the Processing project - http://processing.org
-
- Original Copyright (c) 1997, 1998 Van Di-Han HO. All Rights Reserved.
- Updates Copyright (c) 2001 Jason Pell.
- Further updates Copyright (c) 2003 Martin Gomez, Ateneo de Manila University
- Bug fixes Copyright (c) 2005-09 Ben Fry and Casey Reas
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, version 2.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-package processing.app.tools;
-
-import processing.app.*;
-import processing.app.legacy.PApplet;
-import static processing.app.I18n._;
-
-import java.io.*;
-
-
-/**
- * Handler for dealing with auto format.
- * Contributed by Martin Gomez, additional bug fixes by Ben Fry.
- *
- * After some further digging, this code in fact appears to be a modified
- * version of Jason Pell's GPLed "Java Beautifier" class found here:
- * http://www.geocities.com/jasonpell/programs.html
- * Which is itself based on code from Van Di-Han Ho:
- * http://www.geocities.com/~starkville/vancbj_idx.html
- * [Ben Fry, August 2009]
- */
-public class AutoFormat implements Tool {
- Editor editor;
-
- static final int BLOCK_MAXLEN = 1024;
-
- StringBuffer strOut;
- int indentValue;
- String indentChar;
- int EOF;
- CharArrayReader reader;
- int readCount, indexBlock, lineLength, lineNumber;
- char chars[];
- String strBlock;
- int s_level[];
- int c_level;
- int sp_flg[][];
- int s_ind[][];
- int s_if_lev[];
- int s_if_flg[];
- int if_lev, if_flg, level;
- int ind[];
- int e_flg, paren;
- static int p_flg[];
- char l_char, p_char;
- int a_flg, q_flg, ct;
- int s_tabs[][];
- String w_if_, w_else, w_for, w_ds, w_case, w_cpp_comment, w_jdoc;
- int jdoc, j;
- char string[];
- char cc;
- int s_flg;
- int peek;
- char peekc;
- int tabs;
- char last_char;
- char c;
-
- String line_feed;
-
-
- public void init(Editor editor) {
- this.editor = editor;
- }
-
-
- public String getMenuTitle() {
- return _("Auto Format");
- }
-
- public void comment() throws IOException {
- int save_s_flg;
- save_s_flg = s_flg;
-
- int done = 0;
- c = string[j++] = getchr(); // extra char
- while (done == 0) {
- c = string[j++] = getchr();
- while ((c != '/') && (j < string.length) && EOF == 0) {
- if(c == '\n' || c == '\r') {
- lineNumber++;
- putcoms();
- s_flg = 1;
- }
- c = string[j++] = getchr();
- }
- //String tmpstr = new String(string);
- if (j>1 && string[j-2] == '*') {
- done = 1;
- jdoc = 0;
- } else if (EOF != 0) {
- done = 1;
- }
- }
-
- putcoms();
- s_flg = save_s_flg;
- jdoc = 0;
- return;
- }
-
-
- public char get_string() throws IOException {
- char ch;
- ch = '*';
- while (true) {
- switch (ch) {
- default:
- ch = string[j++] = getchr();
- if (ch == '\\') {
- string[j++] = getchr();
- break;
- }
- if (ch == '\'' || ch == '"') {
- cc = string[j++] = getchr();
- while (cc != ch && EOF == 0) {
- if (cc == '\\') string[j++] = getchr();
- cc = string[j++] = getchr();
- }
- break;
- }
- if (ch == '\n' || ch == '\r') {
- indent_puts();
- a_flg = 1;
- break;
- } else {
- return(ch);
- }
- }
- }
- }
-
-
- public void indent_puts() {
- string[j] = '\0';
- if (j > 0) {
- if (s_flg != 0) {
- if((tabs > 0) && (string[0] != '{') && (a_flg == 1)) {
- tabs++;
- }
- p_tabs();
- s_flg = 0;
- if ((tabs > 0) && (string[0] != '{') && (a_flg == 1)) {
- tabs--;
- }
- a_flg = 0;
- }
- String j_string = new String(string);
- strOut.append(j_string.substring(0,j));
- for (int i=0; i 0)
- {
- if(s_flg != 0)
- {
- p_tabs();
- s_flg = 0;
- }
- string[j] = '\0';
- i = 0;
- while (string[i] == ' ' && EOF == 0) i++;
- if (lookup_com(w_jdoc) == 1) jdoc = 1;
- String strBuffer = new String(string,0,j);
- if (string[i] == '/' && string[i+1]=='*')
- {
- if ((last_char != ';') && (sav_s_flg==1) )
- {
- //fprintf(outfil, strBuffer.substring(i,j));
- fprintf(strBuffer.substring(i,j));
- }
- else
- {
- //fprintf(outfil, strBuffer);
- fprintf(strBuffer);
- }
- }
- else
- {
- if (string[i]=='*' || jdoc == 0)
- //fprintf (outfil, " "+strBuffer.substring(i,j));
- fprintf (" "+strBuffer.substring(i,j));
- else
- //fprintf (outfil, " * "+strBuffer.substring(i,j));
- fprintf (" * "+strBuffer.substring(i,j));
- }
- j = 0;
- string[0] = '\0';
- }
- }
-
-
- public void cpp_comment() throws IOException
- {
- c = getchr();
- while(c != '\n' && c != '\r' && EOF == 0)
- {
- string[j++] = c;
- c = getchr();
- }
- lineNumber++;
- indent_puts();
- s_flg = 1;
- }
-
-
- /* expand indentValue into tabs and spaces */
- public void p_tabs()
- {
- int i,k;
-
- if (tabs<0) tabs = 0;
- if (tabs==0) return;
- i = tabs * indentValue; // calc number of spaces
- //j = i/8; /* calc number of tab chars */
-
- for (k=0; k < i; k++) {
- strOut.append(indentChar);
- }
- }
-
-
- public char getchr() throws IOException
- {
- if((peek < 0) && (last_char != ' ') && (last_char != '\t'))
- {
- if((last_char != '\n') && (last_char != '\r'))
- p_char = last_char;
- }
- if(peek > 0) /* char was read previously */
- {
- last_char = peekc;
- peek = -1;
- }
- else /* read next char in string */
- {
- indexBlock++;
- if (indexBlock >= lineLength)
- {
- for (int ib=0; ib= 'a' && r <= 'z') return(0);
- if(r >= 'A' && r <= 'Z') return(0);
- if(r >= '0' && r <= '9') return(0);
- if(r == '_' || r == '&') return(0);
- return (1);
- }
-
- public int lookup_com (String keyword)
- {
- //char r;
- int l,kk; //,k,i;
- String j_string = new String(string);
-
- if (j<1) return (0);
- kk=0;
- while(string[kk] == ' ' && EOF == 0) kk++;
- l=0;
- l = j_string.indexOf(keyword);
- if (l<0 || l!=kk)
- {
- return 0;
- }
- return (1);
- }
-
-
- public void run() {
- StringBuffer onechar;
-
- // Adding an additional newline as a hack around other errors
- String originalText = editor.getText() + "\n";
- strOut = new StringBuffer();
- indentValue = PreferencesData.getInteger("editor.tabs.size");
- indentChar = new String(" ");
-
- lineNumber = 0;
- c_level = if_lev = level = e_flg = paren = 0;
- a_flg = q_flg = j = tabs = 0;
- if_flg = peek = -1;
- peekc = '`';
- s_flg = 1;
- jdoc = 0;
-
- s_level = new int[10];
- sp_flg = new int[20][10];
- s_ind = new int[20][10];
- s_if_lev = new int[10];
- s_if_flg = new int[10];
- ind = new int[10];
- p_flg = new int[10];
- s_tabs = new int[20][10];
-
- w_else = new String ("else");
- w_if_ = new String ("if");
- w_for = new String ("for");
- w_ds = new String ("default");
- w_case = new String ("case");
- w_cpp_comment = new String ("//");
- w_jdoc = new String ("/**");
- line_feed = new String ("\n");
-
- // read as long as there is something to read
- EOF = 0; // = 1 set in getchr when EOF
-
- chars = new char[BLOCK_MAXLEN];
- string = new char[BLOCK_MAXLEN];
- try { // the whole process
- // open for input
- reader = new CharArrayReader(originalText.toCharArray());
-
- // add buffering to that InputStream
-// bin = new BufferedInputStream(in);
-
- for (int ib = 0; ib < BLOCK_MAXLEN; ib++) chars[ib] = '\0';
-
- lineLength = readCount = 0;
- // read up a block - remember how many bytes read
- readCount = reader.read(chars);
- strBlock = new String(chars);
-
- lineLength = readCount;
- lineNumber = 1;
- indexBlock = -1;
- j = 0;
- while (EOF == 0)
- {
- c = getchr();
- switch(c)
- {
- default:
- string[j++] = c;
- if(c != ',')
- {
- l_char = c;
- }
- break;
-
- case ' ':
- case '\t':
- if(lookup(w_else) == 1)
- {
- gotelse();
- if(s_flg == 0 || j > 0)string[j++] = c;
- indent_puts();
- s_flg = 0;
- break;
- }
- if(s_flg == 0 || j > 0)string[j++] = c;
- break;
-
- case '\r': // for MS Windows 95
- case '\n':
- lineNumber++;
- if (EOF==1)
- {
- break;
- }
- //String j_string = new String(string);
-
- e_flg = lookup(w_else);
- if(e_flg == 1) gotelse();
- if (lookup_com(w_cpp_comment) == 1)
- {
- if (string[j] == '\n')
- {
- string[j] = '\0';
- j--;
- }
- }
-
- indent_puts();
- //fprintf(outfil, line_feed);
- fprintf(line_feed);
- s_flg = 1;
- if(e_flg == 1)
- {
- p_flg[level]++;
- tabs++;
- }
- else
- if(p_char == l_char)
- {
- a_flg = 1;
- }
- break;
-
- case '{':
- if(lookup(w_else) == 1)gotelse();
- if (s_if_lev.length == c_level) {
- s_if_lev = PApplet.expand(s_if_lev);
- s_if_flg = PApplet.expand(s_if_flg);
- }
- s_if_lev[c_level] = if_lev;
- s_if_flg[c_level] = if_flg;
- if_lev = if_flg = 0;
- c_level++;
- if(s_flg == 1 && p_flg[level] != 0)
- {
- p_flg[level]--;
- tabs--;
- }
- string[j++] = c;
- indent_puts();
- getnl() ;
- indent_puts();
- //fprintf(outfil,"\n");
- fprintf("\n");
- tabs++;
- s_flg = 1;
- if(p_flg[level] > 0)
- {
- ind[level] = 1;
- level++;
- s_level[level] = c_level;
- }
- break;
-
- case '}':
- c_level--;
- if (c_level < 0)
- {
- EOF = 1;
- //System.out.println("eof b");
- string[j++] = c;
- indent_puts();
- break;
- }
- if ((if_lev = s_if_lev[c_level]-1) < 0)
- if_lev = 0;
- if_flg = s_if_flg[c_level];
- indent_puts();
- tabs--;
- p_tabs();
- peekc = getchr();
- if( peekc == ';')
- {
- onechar = new StringBuffer();
- onechar.append(c); // the }
- onechar.append(';');
- //fprintf(outfil, onechar.toString());
- fprintf(onechar.toString());
- peek = -1;
- peekc = '`';
- }
- else
- {
- onechar = new StringBuffer();
- onechar.append(c);
- //fprintf(outfil, onechar.toString());
- fprintf(onechar.toString());
- peek = 1;
- }
- getnl();
- indent_puts();
- //fprintf(outfil,"\n");
- fprintf("\n");
- s_flg = 1;
- if(c_level < s_level[level])
- if(level > 0) level--;
- if(ind[level] != 0)
- {
- tabs -= p_flg[level];
- p_flg[level] = 0;
- ind[level] = 0;
- }
- break;
-
- case '"':
- case '\'':
- string[j++] = c;
- cc = getchr();
- while(cc != c && EOF == 0)
- {
- // max. length of line should be 256
- string[j++] = cc;
-
- if(cc == '\\')
- {
- cc = string[j++] = getchr();
- }
- if(cc == '\n')
- {
- lineNumber++;
- indent_puts();
- s_flg = 1;
- }
- cc = getchr();
-
- }
- string[j++] = cc;
- if(getnl() == 1)
- {
- l_char = cc;
- peek = 1;
- peekc = '\n';
- }
- break;
-
- case ';':
- string[j++] = c;
- indent_puts();
- if(p_flg[level] > 0 && ind[level] == 0)
- {
- tabs -= p_flg[level];
- p_flg[level] = 0;
- }
- getnl();
- indent_puts();
- //fprintf(outfil,"\n");
- fprintf("\n");
- s_flg = 1;
- if(if_lev > 0)
- if(if_flg == 1)
- {
- if_lev--;
- if_flg = 0;
- }
- else if_lev = 0;
- break;
-
- case '\\':
- string[j++] = c;
- string[j++] = getchr();
- break;
-
- case '?':
- q_flg = 1;
- string[j++] = c;
- break;
-
- case ':':
- string[j++] = c;
- peekc = getchr();
- if(peekc == ':')
- {
- indent_puts();
- //fprintf (outfil,":");
- fprintf(":");
- peek = -1;
- peekc = '`';
- break;
- }
- else
- {
- //int double_colon = 0;
- peek = 1;
- }
-
- if(q_flg == 1)
- {
- q_flg = 0;
- break;
- }
- if(lookup(w_ds) == 0 && lookup(w_case) == 0)
- {
- s_flg = 0;
- indent_puts();
- }
- else
- {
- tabs--;
- indent_puts();
- tabs++;
- }
- peekc = getchr();
- if(peekc == ';')
- {
- fprintf(";");
- peek = -1;
- peekc = '`';
- }
- else
- {
- peek = 1;
- }
- getnl();
- indent_puts();
- fprintf("\n");
- s_flg = 1;
- break;
-
- case '/':
- string[j++] = c;
- peekc = getchr();
-
- if(peekc == '/')
- {
- string[j++] = peekc;
- peekc = '`';
- peek = -1;
- cpp_comment();
- //fprintf(outfil,"\n");
- fprintf("\n");
- break;
- }
- else
- {
- peek = 1;
- }
-
- if(peekc != '*') {
- break;
- }
- else
- {
- if (j > 0) string[j--] = '\0';
- if (j > 0) indent_puts();
- string[j++] = '/';
- string[j++] = '*';
- peek = -1;
- peekc = '`';
- comment();
- break;
- }
-
- case '#':
- string[j++] = c;
- cc = getchr();
- while(cc != '\n' && EOF == 0)
- {
- string[j++] = cc;
- cc = getchr();
- }
- string[j++] = cc;
- s_flg = 0;
- indent_puts();
- s_flg = 1;
- break;
-
- case ')':
- paren--;
- if (paren < 0)
- {
- EOF = 1;
- //System.out.println("eof c");
- }
- string[j++] = c;
- indent_puts();
- if(getnl() == 1)
- {
- peekc = '\n';
- peek = 1;
- if(paren != 0)
- {
- a_flg = 1;
- }
- else if(tabs > 0)
- {
- p_flg[level]++;
- tabs++;
- ind[level] = 0;
- }
- }
- break;
-
- case '(':
- string[j++] = c;
- paren++;
- if ((lookup(w_for) == 1))
- {
- c = get_string();
- while(c != ';' && EOF == 0) c = get_string();
- ct=0;
- int for_done = 0;
- while (for_done == 0 && EOF == 0)
- {
- c = get_string();
- while(c != ')' && EOF == 0)
- {
- if(c == '(') ct++;
- c = get_string();
- }
- if(ct != 0)
- {
- ct--;
- }
- else for_done = 1;
- } // endwhile for_done
- paren--;
- if (paren < 0)
- {
- EOF = 1;
- //System.out.println("eof d");
- }
- indent_puts();
- if(getnl() == 1)
- {
- peekc = '\n';
- peek = 1;
- p_flg[level]++;
- tabs++;
- ind[level] = 0;
- }
- break;
- }
-
- if(lookup(w_if_) == 1)
- {
- indent_puts();
- s_tabs[c_level][if_lev] = tabs;
- sp_flg[c_level][if_lev] = p_flg[level];
- s_ind[c_level][if_lev] = ind[level];
- if_lev++;
- if_flg = 1;
- }
- } // end switch
-
- //System.out.println("string len is " + string.length);
- //if (EOF == 1) System.out.println(string);
- //String j_string = new String(string);
-
- } // end while not EOF
-
- /*
- int bad;
- while ((bad = bin.read()) != -1) {
- System.out.print((char) bad);
- }
- */
- /*
- char bad;
- //while ((bad = getchr()) != 0) {
- while (true) {
- getchr();
- if (peek != -1) {
- System.out.print(last_char);
- } else {
- break;
- }
- }
- */
-
- // save current (rough) selection point
- int selectionEnd = editor.getSelectionStop();
-
- // make sure the caret would be past the end of the text
- if (strOut.length() < selectionEnd - 1) {
- selectionEnd = strOut.length() - 1;
- }
-
- reader.close(); // close buff
-
- String formattedText = strOut.toString();
- if (formattedText.equals(originalText)) {
- editor.statusNotice(_("No changes necessary for Auto Format."));
-
- } else if (paren != 0) {
- // warn user if there are too many parens in either direction
- if (paren < 0) {
- editor.statusError(
- _("Auto Format Canceled: Too many right parentheses."));
- } else {
- editor.statusError(
- _("Auto Format Canceled: Too many left parentheses."));
- }
-
- } else if (c_level != 0) { // check braces only if parens are ok
- if (c_level < 0) {
- editor.statusError(
- _("Auto Format Canceled: Too many right curly braces."));
- } else {
- editor.statusError(
- _("Auto Format Canceled: Too many left curly braces."));
- }
-
- } else {
- // replace with new bootiful text
- // selectionEnd hopefully at least in the neighborhood
- editor.setText(formattedText);
- editor.setSelection(selectionEnd, selectionEnd);
- editor.getSketch().setModified(true);
- // mark as finished
- editor.statusNotice(_("Auto Format finished."));
- }
-
- } catch (Exception e) {
- editor.statusError(e);
- }
- }
-}
diff --git a/app/src/processing/app/tools/FixEncoding.java b/app/src/processing/app/tools/FixEncoding.java
index 5bfb52462..926fed6e9 100644
--- a/app/src/processing/app/tools/FixEncoding.java
+++ b/app/src/processing/app/tools/FixEncoding.java
@@ -29,6 +29,7 @@ import java.io.IOException;
import javax.swing.JOptionPane;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.*;
import static processing.app.I18n._;
@@ -83,16 +84,19 @@ public class FixEncoding implements Tool {
protected String loadWithLocalEncoding(File file) throws IOException {
// FileReader uses the default encoding, which is what we want.
- FileReader fr = new FileReader(file);
- BufferedReader reader = new BufferedReader(fr);
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(file));
- StringBuffer buffer = new StringBuffer();
- String line = null;
- while ((line = reader.readLine()) != null) {
- buffer.append(line);
- buffer.append('\n');
+ StringBuffer buffer = new StringBuffer();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ buffer.append(line);
+ buffer.append('\n');
+ }
+ return buffer.toString();
+ } finally {
+ IOUtils.closeQuietly(reader);
}
- reader.close();
- return buffer.toString();
}
}
diff --git a/app/src/processing/app/tools/MenuScroller.java b/app/src/processing/app/tools/MenuScroller.java
index cb7495650..d92c33a48 100644
--- a/app/src/processing/app/tools/MenuScroller.java
+++ b/app/src/processing/app/tools/MenuScroller.java
@@ -3,43 +3,31 @@
*/
package processing.app.tools;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Graphics;
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
-import javax.swing.Icon;
-import javax.swing.JComponent;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-import javax.swing.MenuSelectionManager;
-import javax.swing.Timer;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
-import javax.swing.plaf.ButtonUI;
-
/**
* A class that provides scrolling capabilities to a long menu dropdown or
* popup menu. A number of items can optionally be frozen at the top and/or
* bottom of the menu.
- *
+ *
* Implementation note: The default number of items to display
* at a time is 15, and the default scrolling interval is 125 milliseconds.
- *
+ *
*
- * @version 1.5.0 04/05/12
* @author Darryl
+ * @version 1.5.0 04/05/12
*/
public class MenuScroller {
- //private JMenu menu;
private JPopupMenu menu;
private Component[] menuItems;
private MenuScrollItem upItem;
@@ -53,32 +41,13 @@ public class MenuScroller {
private int firstIndex = 0;
private int keepVisibleIndex = -1;
- private static int getMaximumItems(JPopupMenu menu) {
- JMenuItem test = new JMenuItem("test");
- ButtonUI ui = test.getUI();
- Dimension d = ui.getPreferredSize(test);
- double item_height = d.getHeight();
- //System.out.println("JMenuItem Height " + item_height);
- JMenuItem up = new JMenuItem(MenuIcon.UP);
- ui = up.getUI();
- d = ui.getPreferredSize(up);
- double icon_height = d.getHeight();
- //System.out.println("icon item height " + icon_height);
- double menu_border_height = 8.0; // kludge - how to detect this?
- double screen_height = java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight();
- //System.out.println("screen height " + screen_height);
- int n = (int)((screen_height - icon_height * 2 - menu_border_height) / item_height);
- //System.out.println("max items " + n);
- return n;
- }
-
/**
* Registers a menu to be scrolled with the default number of items to
* display at a time and the default scrolling interval.
- *
+ *
* @param menu the menu
* @return the MenuScroller
- */
+ */
public static MenuScroller setScrollerFor(JMenu menu) {
return new MenuScroller(menu);
}
@@ -86,7 +55,7 @@ public class MenuScroller {
/**
* Registers a popup menu to be scrolled with the default number of items to
* display at a time and the default scrolling interval.
- *
+ *
* @param menu the popup menu
* @return the MenuScroller
*/
@@ -97,8 +66,8 @@ public class MenuScroller {
/**
* Registers a menu to be scrolled with the default number of items to
* display at a time and the specified scrolling interval.
- *
- * @param menu the menu
+ *
+ * @param menu the menu
* @param scrollCount the number of items to display at a time
* @return the MenuScroller
* @throws IllegalArgumentException if scrollCount is 0 or negative
@@ -110,8 +79,8 @@ public class MenuScroller {
/**
* Registers a popup menu to be scrolled with the default number of items to
* display at a time and the specified scrolling interval.
- *
- * @param menu the popup menu
+ *
+ * @param menu the popup menu
* @param scrollCount the number of items to display at a time
* @return the MenuScroller
* @throws IllegalArgumentException if scrollCount is 0 or negative
@@ -123,10 +92,10 @@ public class MenuScroller {
/**
* Registers a menu to be scrolled, with the specified number of items to
* display at a time and the specified scrolling interval.
- *
- * @param menu the menu
+ *
+ * @param menu the menu
* @param scrollCount the number of items to be displayed at a time
- * @param interval the scroll interval, in milliseconds
+ * @param interval the scroll interval, in milliseconds
* @return the MenuScroller
* @throws IllegalArgumentException if scrollCount or interval is 0 or negative
*/
@@ -137,10 +106,10 @@ public class MenuScroller {
/**
* Registers a popup menu to be scrolled, with the specified number of items to
* display at a time and the specified scrolling interval.
- *
- * @param menu the popup menu
+ *
+ * @param menu the popup menu
* @param scrollCount the number of items to be displayed at a time
- * @param interval the scroll interval, in milliseconds
+ * @param interval the scroll interval, in milliseconds
* @return the MenuScroller
* @throws IllegalArgumentException if scrollCount or interval is 0 or negative
*/
@@ -153,20 +122,20 @@ public class MenuScroller {
* to display in the scrolling region, the specified scrolling interval,
* and the specified numbers of items fixed at the top and bottom of the
* menu.
- *
- * @param menu the menu
- * @param scrollCount the number of items to display in the scrolling portion
- * @param interval the scroll interval, in milliseconds
- * @param topFixedCount the number of items to fix at the top. May be 0.
+ *
+ * @param menu the menu
+ * @param scrollCount the number of items to display in the scrolling portion
+ * @param interval the scroll interval, in milliseconds
+ * @param topFixedCount the number of items to fix at the top. May be 0.
* @param bottomFixedCount the number of items to fix at the bottom. May be 0
- * @throws IllegalArgumentException if scrollCount or interval is 0 or
- * negative or if topFixedCount or bottomFixedCount is negative
* @return the MenuScroller
+ * @throws IllegalArgumentException if scrollCount or interval is 0 or
+ * negative or if topFixedCount or bottomFixedCount is negative
*/
public static MenuScroller setScrollerFor(JMenu menu, int scrollCount, int interval,
- int topFixedCount, int bottomFixedCount) {
+ int topFixedCount, int bottomFixedCount) {
return new MenuScroller(menu, scrollCount, interval,
- topFixedCount, bottomFixedCount);
+ topFixedCount, bottomFixedCount);
}
/**
@@ -174,50 +143,50 @@ public class MenuScroller {
* to display in the scrolling region, the specified scrolling interval,
* and the specified numbers of items fixed at the top and bottom of the
* popup menu.
- *
- * @param menu the popup menu
- * @param scrollCount the number of items to display in the scrolling portion
- * @param interval the scroll interval, in milliseconds
- * @param topFixedCount the number of items to fix at the top. May be 0
+ *
+ * @param menu the popup menu
+ * @param scrollCount the number of items to display in the scrolling portion
+ * @param interval the scroll interval, in milliseconds
+ * @param topFixedCount the number of items to fix at the top. May be 0
* @param bottomFixedCount the number of items to fix at the bottom. May be 0
- * @throws IllegalArgumentException if scrollCount or interval is 0 or
- * negative or if topFixedCount or bottomFixedCount is negative
* @return the MenuScroller
+ * @throws IllegalArgumentException if scrollCount or interval is 0 or
+ * negative or if topFixedCount or bottomFixedCount is negative
*/
public static MenuScroller setScrollerFor(JPopupMenu menu, int scrollCount, int interval,
- int topFixedCount, int bottomFixedCount) {
+ int topFixedCount, int bottomFixedCount) {
return new MenuScroller(menu, scrollCount, interval,
- topFixedCount, bottomFixedCount);
+ topFixedCount, bottomFixedCount);
}
/**
* Constructs a MenuScroller
that scrolls a menu with the
* default number of items to display at a time, and default scrolling
* interval.
- *
+ *
* @param menu the menu
*/
public MenuScroller(JMenu menu) {
- this(menu, -1);
+ this(menu, 15);
}
/**
* Constructs a MenuScroller
that scrolls a popup menu with the
* default number of items to display at a time, and default scrolling
* interval.
- *
+ *
* @param menu the popup menu
*/
public MenuScroller(JPopupMenu menu) {
- this(menu, -1);
+ this(menu, 15);
}
/**
* Constructs a MenuScroller
that scrolls a menu with the
* specified number of items to display at a time, and default scrolling
* interval.
- *
- * @param menu the menu
+ *
+ * @param menu the menu
* @param scrollCount the number of items to display at a time
* @throws IllegalArgumentException if scrollCount is 0 or negative
*/
@@ -229,8 +198,8 @@ public class MenuScroller {
* Constructs a MenuScroller
that scrolls a popup menu with the
* specified number of items to display at a time, and default scrolling
* interval.
- *
- * @param menu the popup menu
+ *
+ * @param menu the popup menu
* @param scrollCount the number of items to display at a time
* @throws IllegalArgumentException if scrollCount is 0 or negative
*/
@@ -242,10 +211,10 @@ public class MenuScroller {
* Constructs a MenuScroller
that scrolls a menu with the
* specified number of items to display at a time, and specified scrolling
* interval.
- *
- * @param menu the menu
+ *
+ * @param menu the menu
* @param scrollCount the number of items to display at a time
- * @param interval the scroll interval, in milliseconds
+ * @param interval the scroll interval, in milliseconds
* @throws IllegalArgumentException if scrollCount or interval is 0 or negative
*/
public MenuScroller(JMenu menu, int scrollCount, int interval) {
@@ -256,10 +225,10 @@ public class MenuScroller {
* Constructs a MenuScroller
that scrolls a popup menu with the
* specified number of items to display at a time, and specified scrolling
* interval.
- *
- * @param menu the popup menu
+ *
+ * @param menu the popup menu
* @param scrollCount the number of items to display at a time
- * @param interval the scroll interval, in milliseconds
+ * @param interval the scroll interval, in milliseconds
* @throws IllegalArgumentException if scrollCount or interval is 0 or negative
*/
public MenuScroller(JPopupMenu menu, int scrollCount, int interval) {
@@ -271,17 +240,17 @@ public class MenuScroller {
* specified number of items to display in the scrolling region, the
* specified scrolling interval, and the specified numbers of items fixed at
* the top and bottom of the menu.
- *
- * @param menu the menu
- * @param scrollCount the number of items to display in the scrolling portion
- * @param interval the scroll interval, in milliseconds
- * @param topFixedCount the number of items to fix at the top. May be 0
+ *
+ * @param menu the menu
+ * @param scrollCount the number of items to display in the scrolling portion
+ * @param interval the scroll interval, in milliseconds
+ * @param topFixedCount the number of items to fix at the top. May be 0
* @param bottomFixedCount the number of items to fix at the bottom. May be 0
* @throws IllegalArgumentException if scrollCount or interval is 0 or
- * negative or if topFixedCount or bottomFixedCount is negative
+ * negative or if topFixedCount or bottomFixedCount is negative
*/
public MenuScroller(JMenu menu, int scrollCount, int interval,
- int topFixedCount, int bottomFixedCount) {
+ int topFixedCount, int bottomFixedCount) {
this(menu.getPopupMenu(), scrollCount, interval, topFixedCount, bottomFixedCount);
}
@@ -290,24 +259,23 @@ public class MenuScroller {
* specified number of items to display in the scrolling region, the
* specified scrolling interval, and the specified numbers of items fixed at
* the top and bottom of the popup menu.
- *
- * @param menu the popup menu
- * @param scrollCount the number of items to display in the scrolling portion
- * @param interval the scroll interval, in milliseconds
- * @param topFixedCount the number of items to fix at the top. May be 0
+ *
+ * @param menu the popup menu
+ * @param scrollCount the number of items to display in the scrolling portion
+ * @param interval the scroll interval, in milliseconds
+ * @param topFixedCount the number of items to fix at the top. May be 0
* @param bottomFixedCount the number of items to fix at the bottom. May be 0
* @throws IllegalArgumentException if scrollCount or interval is 0 or
- * negative or if topFixedCount or bottomFixedCount is negative
+ * negative or if topFixedCount or bottomFixedCount is negative
*/
public MenuScroller(JPopupMenu menu, int scrollCount, int interval,
- int topFixedCount, int bottomFixedCount) {
-
- if(scrollCount == -1)
- scrollCount = getMaximumItems(menu)-topFixedCount-bottomFixedCount; // Autosize
-
- if(interval == -1)
- interval = 150; // Default value
-
+ int topFixedCount, int bottomFixedCount) {
+
+ int autoSizeScrollCount = getMaximumDrawableMenuItems();
+ if (autoSizeScrollCount > scrollCount) {
+ scrollCount = autoSizeScrollCount;
+ }
+
if (scrollCount <= 0 || interval <= 0) {
throw new IllegalArgumentException("scrollCount and interval must be greater than 0");
}
@@ -329,7 +297,7 @@ public class MenuScroller {
/**
* Returns the scroll interval in milliseconds
- *
+ *
* @return the scroll interval in milliseconds
*/
public int getInterval() {
@@ -338,7 +306,7 @@ public class MenuScroller {
/**
* Sets the scroll interval in milliseconds
- *
+ *
* @param interval the scroll interval in milliseconds
* @throws IllegalArgumentException if interval is 0 or negative
*/
@@ -362,7 +330,7 @@ public class MenuScroller {
/**
* Sets the number of items in the scrolling portion of the menu.
- *
+ *
* @param scrollCount the number of items to display at a time
* @throws IllegalArgumentException if scrollCount is 0 or negative
*/
@@ -376,7 +344,7 @@ public class MenuScroller {
/**
* Returns the number of items fixed at the top of the menu or popup menu.
- *
+ *
* @return the number of items
*/
public int getTopFixedCount() {
@@ -385,7 +353,7 @@ public class MenuScroller {
/**
* Sets the number of items to fix at the top of the menu or popup menu.
- *
+ *
* @param topFixedCount the number of items
*/
public void setTopFixedCount(int topFixedCount) {
@@ -399,7 +367,7 @@ public class MenuScroller {
/**
* Returns the number of items fixed at the bottom of the menu or popup menu.
- *
+ *
* @return the number of items
*/
public int getBottomFixedCount() {
@@ -408,7 +376,7 @@ public class MenuScroller {
/**
* Sets the number of items to fix at the bottom of the menu or popup menu.
- *
+ *
* @param bottomFixedCount the number of items
*/
public void setBottomFixedCount(int bottomFixedCount) {
@@ -427,8 +395,7 @@ public class MenuScroller {
if (item == null) {
keepVisibleIndex = -1;
} else {
- int index = menu.getComponentIndex(item);
- keepVisibleIndex = index;
+ keepVisibleIndex = menu.getComponentIndex(item);
}
}
@@ -459,56 +426,64 @@ public class MenuScroller {
/**
* Ensures that the dispose
method of this MenuScroller is
* called when there are no more refrences to it.
- *
- * @exception Throwable if an error occurs.
+ *
+ * @throws Throwable if an error occurs.
* @see MenuScroller#dispose()
*/
@Override
public void finalize() throws Throwable {
+ super.finalize();
dispose();
}
private void refreshMenu() {
- if (menuItems == null || menuItems.length == 0) {
- return;
- }
+ if (menuItems != null && menuItems.length > 0) {
+ firstIndex = Math.max(topFixedCount, firstIndex);
+ firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);
- int newFirstIndex = Math.max(topFixedCount, firstIndex);
- newFirstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, newFirstIndex);
+ upItem.setEnabled(firstIndex > topFixedCount);
+ downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);
- if (newFirstIndex < 0) {
- return;
- }
-
- firstIndex = newFirstIndex;
-
- upItem.setEnabled(firstIndex > topFixedCount);
- downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);
-
- menu.removeAll();
- for (int i = 0; i < topFixedCount; i++) {
- menu.add(menuItems[i]);
- }
- /*if (topFixedCount > 0) {
+ menu.removeAll();
+ for (int i = 0; i < topFixedCount; i++) {
+ menu.add(menuItems[i]);
+ }
+ if (topFixedCount > 0) {
menu.addSeparator();
- }*/
+ }
- menu.add(upItem);
- for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
- menu.add(menuItems[i]);
- }
- menu.add(downItem);
+ menu.add(upItem);
+ for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
+ menu.add(menuItems[i]);
+ }
+ menu.add(downItem);
- /*if (bottomFixedCount > 0) {
+ if (bottomFixedCount > 0) {
menu.addSeparator();
- }*/
- for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
- menu.add(menuItems[i]);
- }
+ }
+ for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
+ menu.add(menuItems[i]);
+ }
- JComponent parent = (JComponent) upItem.getParent();
- parent.revalidate();
- parent.repaint();
+ JComponent parent = (JComponent) upItem.getParent();
+ parent.revalidate();
+ parent.repaint();
+ }
+ }
+
+ private int getMaximumDrawableMenuItems() {
+ JMenuItem test = new JMenuItem("test");
+ double itemHeight = test.getUI().getPreferredSize(test).getHeight();
+
+ JMenuItem arrowMenuItem = new JMenuItem(MenuIcon.UP);
+ double arrowMenuItemHeight = arrowMenuItem.getUI().getPreferredSize(arrowMenuItem).getHeight();
+
+ double menuBorderHeight = 8.0; // kludge - how to detect this?
+ double screenHeight = java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight();
+
+ int maxItems = (int) ((screenHeight - arrowMenuItemHeight * 2 - menuBorderHeight) / itemHeight);
+ maxItems -= maxItems / 4;
+ return maxItems;
}
private class MouseScrollListener implements MouseWheelListener {
@@ -518,7 +493,7 @@ public class MenuScroller {
mwe.consume();
}
}
-
+
private class MenuScrollListener implements PopupMenuListener {
@Override
@@ -538,29 +513,10 @@ public class MenuScroller {
private void setMenuItems() {
menuItems = menu.getComponents();
-
- // Hack for auto detect the topFixed total
- /*int topFixedCountPrev = topFixedCount;
- for(int i=menuItems.length-1;i>0;i--)
- {
- if(menuItems[i].getClass().getName().endsWith("Separator"))
- {
- System.out.println(i);
- setTopFixedCount(i+1);
-
- if(topFixedCount!=topFixedCountPrev)
- {
- scrollCount = getMaximumItems()-topFixedCount;
- System.out.println(getMaximumItems()-topFixedCount);
- }
- break;
- }
- }*/
-
if (keepVisibleIndex >= topFixedCount
- && keepVisibleIndex <= menuItems.length - bottomFixedCount
- && (keepVisibleIndex > firstIndex + scrollCount
- || keepVisibleIndex < firstIndex)) {
+ && keepVisibleIndex <= menuItems.length - bottomFixedCount
+ && (keepVisibleIndex > firstIndex + scrollCount
+ || keepVisibleIndex < firstIndex)) {
firstIndex = Math.min(firstIndex, keepVisibleIndex);
firstIndex = Math.max(firstIndex, keepVisibleIndex - scrollCount + 1);
}
@@ -577,7 +533,6 @@ public class MenuScroller {
}
}
- @SuppressWarnings("serial")
private class MenuScrollTimer extends Timer {
public MenuScrollTimer(final int increment, int interval) {
@@ -592,11 +547,10 @@ public class MenuScroller {
}
}
- @SuppressWarnings("serial")
private class MenuScrollItem extends JMenuItem
- implements ChangeListener {
+ implements ChangeListener {
- private MenuScrollTimer timer;
+ private final MenuScrollTimer timer;
public MenuScrollItem(MenuIcon icon, int increment) {
setIcon(icon);
@@ -620,7 +574,7 @@ public class MenuScroller {
}
}
- private static enum MenuIcon implements Icon {
+ private enum MenuIcon implements Icon {
UP(9, 1, 9),
DOWN(1, 9, 1);
diff --git a/app/src/processing/app/tools/ZipDeflater.java b/app/src/processing/app/tools/ZipDeflater.java
index 55f0c0c8b..1425d8802 100644
--- a/app/src/processing/app/tools/ZipDeflater.java
+++ b/app/src/processing/app/tools/ZipDeflater.java
@@ -10,6 +10,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.helpers.FileUtils;
public class ZipDeflater {
@@ -54,12 +55,8 @@ public class ZipDeflater {
fos.write(buffer, 0, len);
}
} finally {
- if (fos != null) {
- fos.close();
- }
- if (zipInputStream != null) {
- zipInputStream.close();
- }
+ IOUtils.closeQuietly(fos);
+ IOUtils.closeQuietly(zipInputStream);
}
}
}
diff --git a/app/test/cc/arduino/contributions/GzippedJsonDownloaderTest.java b/app/test/cc/arduino/contributions/GzippedJsonDownloaderTest.java
new file mode 100644
index 000000000..a762b6801
--- /dev/null
+++ b/app/test/cc/arduino/contributions/GzippedJsonDownloaderTest.java
@@ -0,0 +1,53 @@
+package cc.arduino.contributions;
+
+import cc.arduino.contributions.libraries.LibrariesIndex;
+import cc.arduino.utils.MultiStepProgress;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.module.mrbean.MrBeanModule;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import processing.app.helpers.FileUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+
+import static org.junit.Assert.assertTrue;
+
+public class GzippedJsonDownloaderTest {
+
+ private File tempFolder;
+ private File tempFile;
+ private DownloadableContributionsDownloader downloader;
+
+ @Before
+ public void setUp() throws Exception {
+ tempFolder = FileUtils.createTempFolder();
+ tempFile = File.createTempFile("test", ".json");
+ downloader = new DownloadableContributionsDownloader(tempFolder);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ FileUtils.recursiveDelete(tempFolder);
+ FileUtils.recursiveDelete(tempFile);
+ }
+
+ @Test
+ public void testJsonDownload() throws Exception {
+ new GZippedJsonDownloader(downloader, new URL("http://downloads.arduino.cc/libraries/library_index.json"), new URL("http://downloads.arduino.cc/libraries/library_index.json.gz")).download(tempFile, new MultiStepProgress(1), "");
+
+ InputStream indexIn = new FileInputStream(tempFile);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.registerModule(new MrBeanModule());
+ mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
+ mapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ LibrariesIndex librariesIndex = mapper.readValue(indexIn, LibrariesIndex.class);
+
+ assertTrue(librariesIndex != null);
+ }
+}
diff --git a/app/test/cc/arduino/contributions/JsonDownloaderTest.java b/app/test/cc/arduino/contributions/JsonDownloaderTest.java
new file mode 100644
index 000000000..98cefef49
--- /dev/null
+++ b/app/test/cc/arduino/contributions/JsonDownloaderTest.java
@@ -0,0 +1,53 @@
+package cc.arduino.contributions;
+
+import cc.arduino.contributions.libraries.LibrariesIndex;
+import cc.arduino.utils.MultiStepProgress;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.module.mrbean.MrBeanModule;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import processing.app.helpers.FileUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+
+import static org.junit.Assert.assertTrue;
+
+public class JsonDownloaderTest {
+
+ private File tempFolder;
+ private File tempFile;
+ private DownloadableContributionsDownloader downloader;
+
+ @Before
+ public void setUp() throws Exception {
+ tempFolder = FileUtils.createTempFolder();
+ tempFile = File.createTempFile("test", ".json");
+ downloader = new DownloadableContributionsDownloader(tempFolder);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ FileUtils.recursiveDelete(tempFolder);
+ FileUtils.recursiveDelete(tempFile);
+ }
+
+ @Test
+ public void testJsonDownload() throws Exception {
+ new JsonDownloader(downloader, new URL("http://downloads.arduino.cc/libraries/library_index.json")).download(tempFile, new MultiStepProgress(1), "");
+
+ InputStream indexIn = new FileInputStream(tempFile);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.registerModule(new MrBeanModule());
+ mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
+ mapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ LibrariesIndex librariesIndex = mapper.readValue(indexIn, LibrariesIndex.class);
+
+ assertTrue(librariesIndex != null);
+ }
+}
diff --git a/app/test/cc/arduino/contributions/libraries/LibraryOfTypeComparatorTest.java b/app/test/cc/arduino/contributions/libraries/LibraryOfTypeComparatorTest.java
new file mode 100644
index 000000000..eeb91ee49
--- /dev/null
+++ b/app/test/cc/arduino/contributions/libraries/LibraryOfTypeComparatorTest.java
@@ -0,0 +1,19 @@
+package cc.arduino.contributions.libraries;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class LibraryOfTypeComparatorTest {
+
+ @Test
+ public void testSort() throws Exception {
+ List strings = Arrays.asList("Arduino", "Contributed", "Recommended", "Recommended", "Other", "1yetanother", "Arduino", "Recommended", "Contributed", "Recommended");
+ Collections.sort(strings, new LibraryTypeComparator());
+ assertEquals(Arrays.asList("Arduino", "Arduino", "Recommended", "Recommended", "Recommended", "Recommended", "Contributed", "Contributed", "1yetanother", "Other"), strings);
+ }
+}
diff --git a/app/test/processing/app/AbstractGUITest.java b/app/test/processing/app/AbstractGUITest.java
index b4fe19db0..75c9b864f 100644
--- a/app/test/processing/app/AbstractGUITest.java
+++ b/app/test/processing/app/AbstractGUITest.java
@@ -50,12 +50,13 @@ public abstract class AbstractGUITest {
FailOnThreadViolationRepaintManager.install();
- Base.initPlatform();
- Preferences.init(null);
+ BaseNoGui.initPlatform();
+ BaseNoGui.getPlatform().init();
+ PreferencesData.init(null);
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
Theme.init();
- Base.getPlatform().setLookAndFeel();
- Base.untitledFolder = Base.createTempFolder("untitled");
+ BaseNoGui.getPlatform().setLookAndFeel();
+ Base.untitledFolder = BaseNoGui.createTempFolder("untitled");
DeleteFilesOnShutdown.add(Base.untitledFolder);
window = GuiActionRunner.execute(new GuiQuery() {
diff --git a/app/test/processing/app/AbstractWithPreferencesTest.java b/app/test/processing/app/AbstractWithPreferencesTest.java
index 7ee6e2195..e78eea58b 100644
--- a/app/test/processing/app/AbstractWithPreferencesTest.java
+++ b/app/test/processing/app/AbstractWithPreferencesTest.java
@@ -37,14 +37,14 @@ public abstract class AbstractWithPreferencesTest {
@Before
public void init() throws Exception {
Runtime.getRuntime().addShutdownHook(new Thread(DeleteFilesOnShutdown.INSTANCE));
- Base.initPlatform();
- Base.getPlatform().init();
- Preferences.init(null);
+ BaseNoGui.initPlatform();
+ BaseNoGui.getPlatform().init();
+ PreferencesData.init(null);
Theme.init();
BaseNoGui.initPackages();
- Base.untitledFolder = Base.createTempFolder("untitled");
+ Base.untitledFolder = BaseNoGui.createTempFolder("untitled");
DeleteFilesOnShutdown.add(Base.untitledFolder);
}
diff --git a/app/test/processing/app/I18NTest.java b/app/test/processing/app/I18NTest.java
index 1df455f91..219f6f7ab 100644
--- a/app/test/processing/app/I18NTest.java
+++ b/app/test/processing/app/I18NTest.java
@@ -29,6 +29,7 @@
package processing.app;
+import org.apache.commons.compress.utils.IOUtils;
import org.junit.Ignore;
import org.junit.Test;
@@ -63,9 +64,7 @@ public class I18NTest {
is = new FileInputStream(file);
properties.load(is);
} finally {
- if (is != null) {
- is.close();
- }
+ IOUtils.closeQuietly(is);
}
return properties;
}
diff --git a/app/test/processing/app/macosx/SystemProfilerParserTest.java b/app/test/processing/app/macosx/SystemProfilerParserTest.java
index 30c6f6b63..1476822c4 100644
--- a/app/test/processing/app/macosx/SystemProfilerParserTest.java
+++ b/app/test/processing/app/macosx/SystemProfilerParserTest.java
@@ -74,5 +74,9 @@ public class SystemProfilerParserTest {
assertEquals("0X2341_0X8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem24131"));
assertEquals("0X0403_0X6015", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbserial-DN0031EV"));
assertEquals("0X0403_0X6015", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbserial-DN0031EV"));
+
+ output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output8.txt"));
+
+ assertEquals("0X03EB_0X2157", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodemfd132"));
}
}
diff --git a/app/test/processing/app/macosx/system_profiler_output8.txt b/app/test/processing/app/macosx/system_profiler_output8.txt
new file mode 100644
index 000000000..13a2d7f8e
--- /dev/null
+++ b/app/test/processing/app/macosx/system_profiler_output8.txt
@@ -0,0 +1,96 @@
+USB:
+
+ USB Hi-Speed Bus:
+
+ Host Controller Location: Built-in USB
+ Host Controller Driver: AppleUSBEHCI
+ PCI Device ID: 0x1c2d
+ PCI Revision ID: 0x0005
+ PCI Vendor ID: 0x8086
+ Bus Number: 0xfa
+
+ Hub:
+
+ Product ID: 0x2513
+ Vendor ID: 0x0424 (SMSC)
+ Version: b.b3
+ Speed: Up to 480 Mb/sec
+ Location ID: 0xfa100000 / 2
+ Current Available (mA): 500
+ Current Required (mA): 2
+
+ Arduino Leonardo:
+
+ Product ID: 0x8036
+ Vendor ID: 0x2341
+ Version: 1.00
+ Speed: Up to 12 Mb/sec
+ Manufacturer: Arduino LLC
+ Location ID: 0xfa120000 / 5
+ Current Available (mA): 500
+ Current Required (mA): 500
+
+ BRCM20702 Hub:
+
+ Product ID: 0x4500
+ Vendor ID: 0x0a5c (Broadcom Corp.)
+ Version: 1.00
+ Speed: Up to 12 Mb/sec
+ Manufacturer: Apple Inc.
+ Location ID: 0xfa110000 / 3
+ Current Available (mA): 500
+ Current Required (mA): 94
+
+ Bluetooth USB Host Controller:
+
+ Product ID: 0x8281
+ Vendor ID: 0x05ac (Apple Inc.)
+ Version: 1.25
+ Speed: Up to 12 Mb/sec
+ Manufacturer: Apple Inc.
+ Location ID: 0xfa113000 / 4
+ Current Available (mA): 500
+ Current Required (mA): 0
+
+ USB Hi-Speed Bus:
+
+ Host Controller Location: Built-in USB
+ Host Controller Driver: AppleUSBEHCI
+ PCI Device ID: 0x1c26
+ PCI Revision ID: 0x0005
+ PCI Vendor ID: 0x8086
+ Bus Number: 0xfd
+
+ Hub:
+
+ Product ID: 0x2513
+ Vendor ID: 0x0424 (SMSC)
+ Version: b.b3
+ Speed: Up to 480 Mb/sec
+ Location ID: 0xfd100000 / 2
+ Current Available (mA): 500
+ Current Required (mA): 2
+
+ EDBG CMSIS-DAP:
+
+ Product ID: 0x2157
+ Vendor ID: 0x03eb (Atmel Corporation)
+ Version: 1.01
+ Serial Number: 00000000AZE000000310
+ Speed: Up to 480 Mb/sec
+ Manufacturer: Atmel Corp.
+ Location ID: 0xfd130000 / 4
+ Current Available (mA): 500
+ Current Required (mA): 500
+
+ IR Receiver:
+
+ Product ID: 0x8242
+ Vendor ID: 0x05ac (Apple Inc.)
+ Version: 0.16
+ Speed: Up to 1.5 Mb/sec
+ Manufacturer: Apple Computer, Inc.
+ Location ID: 0xfd110000 / 3
+ Current Available (mA): 500
+ Current Required (mA): 100
+
diff --git a/app/test/processing/app/windows/RegQueryParserTest.java b/app/test/processing/app/windows/RegQueryParserTest.java
new file mode 100644
index 000000000..469f4db53
--- /dev/null
+++ b/app/test/processing/app/windows/RegQueryParserTest.java
@@ -0,0 +1,42 @@
+package processing.app.windows;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class RegQueryParserTest {
+
+ @Test
+ public void testRegQueryParser() throws Exception {
+ String output = "! REG.EXE VERSION 3.0\n" +
+ "\n" +
+ "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\n" +
+ "\n" +
+ " Local AppData REG_SZ C:\\Documents and Settings\\username\\My Documents";
+
+ String folderPath = new RegQueryParser(output).getValueOfKey();
+ assertEquals("C:\\Documents and Settings\\username\\My Documents", folderPath);
+ }
+
+ @Test
+ public void testRegQueryParser2() throws Exception {
+ String output = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\n" +
+ " Local AppData REG_SZ C:\\Users\\username\\AppData\\Local";
+
+ String folderPath = new RegQueryParser(output).getValueOfKey();
+ assertEquals("C:\\Users\\username\\AppData\\Local", folderPath);
+ }
+
+ @Test
+ public void testRegQueryParserXP() throws Exception {
+ String output = "! REG.EXE VERSION 3.0\n" +
+ "\n" +
+ "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\n" +
+ "\n" +
+ "\tLocal AppData REG_SZ C:\\Documents and Settings\\username\\My Documents";
+
+ String folderPath = new RegQueryParser(output).getValueOfKey();
+ assertEquals("C:\\Documents and Settings\\username\\My Documents", folderPath);
+ }
+
+}
diff --git a/arduino-core/.classpath b/arduino-core/.classpath
index cd3604c15..b0e162044 100644
--- a/arduino-core/.classpath
+++ b/arduino-core/.classpath
@@ -2,7 +2,6 @@
-
diff --git a/arduino-core/build.xml b/arduino-core/build.xml
index 6245ed6b5..cef9fe404 100644
--- a/arduino-core/build.xml
+++ b/arduino-core/build.xml
@@ -31,8 +31,8 @@
- {
diff --git a/arduino-core/src/cc/arduino/contributions/DownloadableContributionVersionComparator.java b/arduino-core/src/cc/arduino/contributions/DownloadableContributionVersionComparator.java
index f23fa552d..b7f9959a4 100644
--- a/arduino-core/src/cc/arduino/contributions/DownloadableContributionVersionComparator.java
+++ b/arduino-core/src/cc/arduino/contributions/DownloadableContributionVersionComparator.java
@@ -29,8 +29,6 @@
package cc.arduino.contributions;
-import cc.arduino.contributions.packages.DownloadableContribution;
-
import java.util.Comparator;
public class DownloadableContributionVersionComparator implements Comparator {
diff --git a/arduino-core/src/cc/arduino/contributions/packages/DownloadableContributionsDownloader.java b/arduino-core/src/cc/arduino/contributions/DownloadableContributionsDownloader.java
similarity index 98%
rename from arduino-core/src/cc/arduino/contributions/packages/DownloadableContributionsDownloader.java
rename to arduino-core/src/cc/arduino/contributions/DownloadableContributionsDownloader.java
index a3ac4d9ec..0dfcba840 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/DownloadableContributionsDownloader.java
+++ b/arduino-core/src/cc/arduino/contributions/DownloadableContributionsDownloader.java
@@ -26,7 +26,8 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
-package cc.arduino.contributions.packages;
+
+package cc.arduino.contributions;
import cc.arduino.utils.FileHash;
import cc.arduino.utils.Progress;
diff --git a/arduino-core/src/cc/arduino/contributions/GPGDetachedSignatureVerifier.java b/arduino-core/src/cc/arduino/contributions/GPGDetachedSignatureVerifier.java
index 2b23c3387..a3ed88148 100644
--- a/arduino-core/src/cc/arduino/contributions/GPGDetachedSignatureVerifier.java
+++ b/arduino-core/src/cc/arduino/contributions/GPGDetachedSignatureVerifier.java
@@ -77,12 +77,8 @@ public class GPGDetachedSignatureVerifier {
return pgpSignature.verify();
} finally {
- if (signatureInputStream != null) {
- signatureInputStream.close();
- }
- if (signedFileInputStream != null) {
- signedFileInputStream.close();
- }
+ IOUtils.closeQuietly(signatureInputStream);
+ IOUtils.closeQuietly(signedFileInputStream);
}
}
@@ -92,9 +88,7 @@ public class GPGDetachedSignatureVerifier {
keyIn = new BufferedInputStream(new FileInputStream(file));
return readPublicKey(keyIn, keyId);
} finally {
- if (keyIn != null) {
- keyIn.close();
- }
+ IOUtils.closeQuietly(keyIn);
}
}
diff --git a/arduino-core/src/cc/arduino/contributions/GZippedJsonDownloader.java b/arduino-core/src/cc/arduino/contributions/GZippedJsonDownloader.java
new file mode 100644
index 000000000..089d20c4b
--- /dev/null
+++ b/arduino-core/src/cc/arduino/contributions/GZippedJsonDownloader.java
@@ -0,0 +1,79 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
+package cc.arduino.contributions;
+
+import cc.arduino.utils.Progress;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import org.apache.commons.compress.compressors.gzip.GzipUtils;
+import org.apache.commons.compress.utils.IOUtils;
+
+import java.io.*;
+import java.net.URL;
+
+public class GZippedJsonDownloader {
+
+ private final DownloadableContributionsDownloader downloader;
+ private final URL url;
+ private final URL gzippedUrl;
+
+ public GZippedJsonDownloader(DownloadableContributionsDownloader downloader, URL url, URL gzippedUrl) {
+ this.downloader = downloader;
+ this.url = url;
+ this.gzippedUrl = gzippedUrl;
+ }
+
+ public void download(File tmpFile, Progress progress, String statusText) throws Exception {
+ try {
+ new JsonDownloader(downloader, gzippedUrl).download(tmpFile, progress, statusText);
+ File gzipTmpFile = new File(tmpFile.getParentFile(), GzipUtils.getCompressedFilename(tmpFile.getName()));
+ tmpFile.renameTo(gzipTmpFile);
+ decompress(gzipTmpFile, tmpFile);
+ } catch (Exception e) {
+ new JsonDownloader(downloader, url).download(tmpFile, progress, statusText);
+ }
+ }
+
+ private void decompress(File gzipTmpFile, File tmpFile) throws IOException {
+ OutputStream os = null;
+ GzipCompressorInputStream gzipIs = null;
+ try {
+ os = new FileOutputStream(tmpFile);
+ gzipIs = new GzipCompressorInputStream(new FileInputStream(gzipTmpFile));
+ final byte[] buffer = new byte[4096];
+ int n = 0;
+ while (-1 != (n = gzipIs.read(buffer))) {
+ os.write(buffer, 0, n);
+ }
+ } finally {
+ IOUtils.closeQuietly(os);
+ IOUtils.closeQuietly(gzipIs);
+ }
+ }
+}
diff --git a/arduino-core/src/cc/arduino/contributions/JsonDownloader.java b/arduino-core/src/cc/arduino/contributions/JsonDownloader.java
new file mode 100644
index 000000000..79a9b1b80
--- /dev/null
+++ b/arduino-core/src/cc/arduino/contributions/JsonDownloader.java
@@ -0,0 +1,55 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
+package cc.arduino.contributions;
+
+import cc.arduino.utils.Progress;
+
+import java.io.File;
+import java.net.URL;
+
+public class JsonDownloader {
+
+ private final DownloadableContributionsDownloader downloader;
+ private final URL url;
+
+ public JsonDownloader(DownloadableContributionsDownloader downloader, URL url) {
+ this.downloader = downloader;
+ this.url = url;
+ }
+
+ public void download(File tmpFile, Progress progress, String statusText) throws Exception {
+ try {
+ downloader.download(url, tmpFile, progress, statusText);
+ } catch (InterruptedException e) {
+ // Download interrupted... just exit
+ return;
+ }
+ }
+}
diff --git a/arduino-core/src/cc/arduino/contributions/SignatureVerificationFailedException.java b/arduino-core/src/cc/arduino/contributions/SignatureVerificationFailedException.java
index 201e7ec45..eba7fd5cd 100644
--- a/arduino-core/src/cc/arduino/contributions/SignatureVerificationFailedException.java
+++ b/arduino-core/src/cc/arduino/contributions/SignatureVerificationFailedException.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.contributions;
import processing.app.I18n;
diff --git a/arduino-core/src/cc/arduino/contributions/VersionComparator.java b/arduino-core/src/cc/arduino/contributions/VersionComparator.java
index d4bd52a85..817f9bb5b 100644
--- a/arduino-core/src/cc/arduino/contributions/VersionComparator.java
+++ b/arduino-core/src/cc/arduino/contributions/VersionComparator.java
@@ -26,6 +26,7 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions;
import com.github.zafarkhaja.semver.Version;
diff --git a/arduino-core/src/cc/arduino/contributions/filters/BuiltInPredicate.java b/arduino-core/src/cc/arduino/contributions/filters/BuiltInPredicate.java
index 3b6f40a02..b7e1c7ab2 100644
--- a/arduino-core/src/cc/arduino/contributions/filters/BuiltInPredicate.java
+++ b/arduino-core/src/cc/arduino/contributions/filters/BuiltInPredicate.java
@@ -29,7 +29,7 @@
package cc.arduino.contributions.filters;
-import cc.arduino.contributions.packages.DownloadableContribution;
+import cc.arduino.contributions.DownloadableContribution;
import com.google.common.base.Predicate;
public class BuiltInPredicate implements Predicate {
diff --git a/arduino-core/src/cc/arduino/contributions/filters/DownloadableContributionWithVersionPredicate.java b/arduino-core/src/cc/arduino/contributions/filters/DownloadableContributionWithVersionPredicate.java
index b2954fae3..576103bfa 100644
--- a/arduino-core/src/cc/arduino/contributions/filters/DownloadableContributionWithVersionPredicate.java
+++ b/arduino-core/src/cc/arduino/contributions/filters/DownloadableContributionWithVersionPredicate.java
@@ -29,7 +29,7 @@
package cc.arduino.contributions.filters;
-import cc.arduino.contributions.packages.DownloadableContribution;
+import cc.arduino.contributions.DownloadableContribution;
import com.google.common.base.Predicate;
public class DownloadableContributionWithVersionPredicate implements Predicate {
diff --git a/arduino-core/src/cc/arduino/contributions/filters/InstalledPredicate.java b/arduino-core/src/cc/arduino/contributions/filters/InstalledPredicate.java
index 9ffc43234..87066da68 100644
--- a/arduino-core/src/cc/arduino/contributions/filters/InstalledPredicate.java
+++ b/arduino-core/src/cc/arduino/contributions/filters/InstalledPredicate.java
@@ -29,7 +29,7 @@
package cc.arduino.contributions.filters;
-import cc.arduino.contributions.packages.DownloadableContribution;
+import cc.arduino.contributions.DownloadableContribution;
import com.google.common.base.Predicate;
public class InstalledPredicate implements Predicate {
diff --git a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java
index c368f7319..9cd3755a6 100644
--- a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java
+++ b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java
@@ -26,9 +26,10 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.libraries;
-import cc.arduino.contributions.packages.DownloadableContribution;
+import cc.arduino.contributions.DownloadableContribution;
import processing.app.I18n;
import java.util.Comparator;
diff --git a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryReference.java b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryReference.java
index e04a7ec7a..f4edd5732 100644
--- a/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryReference.java
+++ b/arduino-core/src/cc/arduino/contributions/libraries/ContributedLibraryReference.java
@@ -26,6 +26,7 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.libraries;
public abstract class ContributedLibraryReference {
diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java
index c285ade68..dd7c18196 100644
--- a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java
+++ b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java
@@ -26,11 +26,19 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.libraries;
+import cc.arduino.contributions.libraries.filters.LibraryInstalledInsideCore;
+import cc.arduino.contributions.libraries.filters.TypePredicate;
+import cc.arduino.contributions.packages.ContributedPlatform;
+import cc.arduino.contributions.packages.ContributionsIndexer;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.mrbean.MrBeanModule;
+import com.google.common.base.Function;
+import com.google.common.collect.FluentIterable;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.BaseNoGui;
import processing.app.I18n;
import processing.app.helpers.FileUtils;
@@ -43,6 +51,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -50,6 +59,7 @@ import static processing.app.I18n._;
public class LibrariesIndexer {
+ private final ContributionsIndexer contributionsIndexer;
private LibrariesIndex index;
private final LibraryList installedLibraries = new LibraryList();
private final LibraryList installedLibrariesWithDuplicates = new LibraryList();
@@ -57,11 +67,13 @@ public class LibrariesIndexer {
private final File indexFile;
private final File stagingFolder;
private File sketchbookLibrariesFolder;
+
+ private final List badLibNotified = new ArrayList();
- public LibrariesIndexer(File preferencesFolder) {
- indexFile = new File(preferencesFolder, "library_index.json");
- stagingFolder = new File(preferencesFolder, "staging" + File.separator +
- "libraries");
+ public LibrariesIndexer(File preferencesFolder, ContributionsIndexer contributionsIndexer) {
+ this.contributionsIndexer = contributionsIndexer;
+ this.indexFile = new File(preferencesFolder, "library_index.json");
+ this.stagingFolder = new File(new File(preferencesFolder, "staging"), "libraries");
}
public void parseIndex() throws IOException {
@@ -86,9 +98,7 @@ public class LibrariesIndexer {
}
}
} finally {
- if (indexIn != null) {
- indexIn.close();
- }
+ IOUtils.closeQuietly(indexIn);
}
}
@@ -101,12 +111,23 @@ public class LibrariesIndexer {
// Clear all installed flags
installedLibraries.clear();
installedLibrariesWithDuplicates.clear();
- for (ContributedLibrary lib : index.getLibraries())
+ for (ContributedLibrary lib : index.getLibraries()) {
lib.setInstalled(false);
+ }
// Rescan libraries
- for (File folder : librariesFolders)
+ for (File folder : librariesFolders) {
scanInstalledLibraries(folder, folder.equals(sketchbookLibrariesFolder));
+ }
+
+ FluentIterable.from(installedLibraries).filter(new TypePredicate("Contributed")).filter(new LibraryInstalledInsideCore(contributionsIndexer)).transform(new Function() {
+ @Override
+ public Object apply(UserLibrary userLibrary) {
+ ContributedPlatform platform = contributionsIndexer.getPlatformByFolder(userLibrary.getInstalledFolder());
+ userLibrary.setTypes(Arrays.asList(platform.getCategory()));
+ return userLibrary;
+ }
+ }).toList();
}
private void scanInstalledLibraries(File folder, boolean isSketchbook) {
@@ -117,11 +138,18 @@ public class LibrariesIndexer {
for (File subfolder : list) {
if (!BaseNoGui.isSanitaryName(subfolder.getName())) {
- String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
+
+ // Detect whether the current folder name has already had a notification.
+ if(!badLibNotified.contains(subfolder.getName())) {
+
+ badLibNotified.add(subfolder.getName());
+
+ String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
+ "Library names must contain only basic letters and numbers.\n"
+ "(ASCII only and no spaces, and it cannot start with a number)"),
subfolder.getName());
- BaseNoGui.showMessage(_("Ignoring bad library name"), mess);
+ BaseNoGui.showMessage(_("Ignoring bad library name"), mess);
+ }
continue;
}
diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java
index 8da0ed9f2..7d0e8d0f5 100644
--- a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java
+++ b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java
@@ -26,14 +26,16 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.libraries;
-import cc.arduino.contributions.packages.DownloadableContributionsDownloader;
+import cc.arduino.contributions.DownloadableContributionsDownloader;
+import cc.arduino.contributions.GZippedJsonDownloader;
import cc.arduino.utils.ArchiveExtractor;
import cc.arduino.utils.MultiStepProgress;
import cc.arduino.utils.Progress;
-import processing.app.BaseNoGui;
import processing.app.I18n;
+import processing.app.Platform;
import processing.app.helpers.FileUtils;
import java.io.File;
@@ -45,6 +47,7 @@ import static processing.app.I18n._;
public class LibraryInstaller {
private static final String LIBRARY_INDEX_URL;
+ private static final String LIBRARY_INDEX_URL_GZ;
static {
String externalLibraryIndexUrl = System.getProperty("LIBRARY_INDEX_URL");
@@ -53,14 +56,17 @@ public class LibraryInstaller {
} else {
LIBRARY_INDEX_URL = "http://downloads.arduino.cc/libraries/library_index.json";
}
+ LIBRARY_INDEX_URL_GZ = "http://downloads.arduino.cc/libraries/library_index.json.gz";
}
private final LibrariesIndexer indexer;
private final DownloadableContributionsDownloader downloader;
+ private final Platform platform;
- public LibraryInstaller(LibrariesIndexer _indexer) {
- indexer = _indexer;
- File stagingFolder = _indexer.getStagingFolder();
+ public LibraryInstaller(LibrariesIndexer indexer, Platform platform) {
+ this.indexer = indexer;
+ this.platform = platform;
+ File stagingFolder = indexer.getStagingFolder();
downloader = new DownloadableContributionsDownloader(stagingFolder) {
@Override
protected void onProgress(Progress progress) {
@@ -77,8 +83,8 @@ public class LibraryInstaller {
File outputFile = indexer.getIndexFile();
File tmpFile = new File(outputFile.getAbsolutePath() + ".tmp");
try {
- downloader.download(url, tmpFile, progress,
- _("Downloading libraries index..."));
+ GZippedJsonDownloader gZippedJsonDownloader = new GZippedJsonDownloader(downloader, new URL(LIBRARY_INDEX_URL), new URL(LIBRARY_INDEX_URL_GZ));
+ gZippedJsonDownloader.download(tmpFile, progress, _("Downloading libraries index..."));
} catch (InterruptedException e) {
// Download interrupted... just exit
return;
@@ -91,8 +97,7 @@ public class LibraryInstaller {
if (outputFile.exists())
outputFile.delete();
if (!tmpFile.renameTo(outputFile))
- throw new Exception(
- _("An error occurred while updating libraries index!"));
+ throw new Exception(_("An error occurred while updating libraries index!"));
// Step 2: Rescan index
rescanLibraryIndex(progress);
@@ -124,7 +129,7 @@ public class LibraryInstaller {
File libsFolder = indexer.getSketchbookLibrariesFolder();
File tmpFolder = FileUtils.createTempFolderIn(libsFolder);
try {
- new ArchiveExtractor(BaseNoGui.getPlatform()).extract(lib.getDownloadedFile(), tmpFolder, 1);
+ new ArchiveExtractor(platform).extract(lib.getDownloadedFile(), tmpFolder, 1);
} catch (Exception e) {
if (tmpFolder.exists())
FileUtils.recursiveDelete(tmpFolder);
diff --git a/arduino-core/src/cc/arduino/contributions/libraries/filters/LibraryInstalledInsideCore.java b/arduino-core/src/cc/arduino/contributions/libraries/filters/LibraryInstalledInsideCore.java
new file mode 100644
index 000000000..6f18834f3
--- /dev/null
+++ b/arduino-core/src/cc/arduino/contributions/libraries/filters/LibraryInstalledInsideCore.java
@@ -0,0 +1,49 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
+package cc.arduino.contributions.libraries.filters;
+
+import cc.arduino.contributions.libraries.ContributedLibrary;
+import cc.arduino.contributions.packages.ContributionsIndexer;
+import com.google.common.base.Predicate;
+
+public class LibraryInstalledInsideCore implements Predicate {
+
+ private final ContributionsIndexer indexer;
+
+ public LibraryInstalledInsideCore(ContributionsIndexer indexer) {
+ this.indexer = indexer;
+ }
+
+ @Override
+ public boolean apply(ContributedLibrary contributedLibrary) {
+ return indexer.isFolderInsidePlatform(contributedLibrary.getInstalledFolder());
+ }
+
+}
diff --git a/app/src/cc/arduino/contributions/libraries/filters/TypePredicate.java b/arduino-core/src/cc/arduino/contributions/libraries/filters/TypePredicate.java
similarity index 100%
rename from app/src/cc/arduino/contributions/libraries/filters/TypePredicate.java
rename to arduino-core/src/cc/arduino/contributions/libraries/filters/TypePredicate.java
diff --git a/arduino-core/src/cc/arduino/contributions/packages/Constants.java b/arduino-core/src/cc/arduino/contributions/packages/Constants.java
index 1afbe0075..621c47f4f 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/Constants.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/Constants.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.contributions.packages;
import java.util.Arrays;
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedBoard.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedBoard.java
index 9a115ad8d..7017ced5d 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributedBoard.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedBoard.java
@@ -26,6 +26,7 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
public interface ContributedBoard {
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedHelp.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedHelp.java
index 1c13a2d7f..a8f998f66 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributedHelp.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedHelp.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.contributions.packages;
public abstract class ContributedHelp {
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedPackage.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedPackage.java
index 18e8d58a5..3b2a91759 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributedPackage.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedPackage.java
@@ -26,9 +26,8 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
-package cc.arduino.contributions.packages;
-import cc.arduino.contributions.VersionComparator;
+package cc.arduino.contributions.packages;
import java.util.List;
@@ -80,16 +79,16 @@ public abstract class ContributedPackage {
}
res += "\n category : " + plat.getCategory();
res += "\n architecture : " +
- plat.getArchitecture() + " " + plat.getParsedVersion() + "\n";
+ plat.getArchitecture() + " " + plat.getParsedVersion() + "\n";
if (plat.getToolsDependencies() != null)
for (ContributedToolReference t : plat.getToolsDependencies()) {
res += " tool dep : " + t.getName() + " " +
- t.getVersion() + "\n";
+ t.getVersion() + "\n";
}
if (plat.getBoards() != null)
for (ContributedBoard board : plat.getBoards())
res += " board : " + board.getName() +
- "\n";
+ "\n";
}
}
if (getTools() != null) {
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedPlatform.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedPlatform.java
index 83565f912..0626fd851 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributedPlatform.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedPlatform.java
@@ -26,8 +26,11 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
+import cc.arduino.contributions.DownloadableContribution;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPackage.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPackage.java
index 1a481a5a2..f00836ed8 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPackage.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPackage.java
@@ -26,15 +26,16 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
+import processing.app.debug.TargetPackage;
+import processing.app.debug.TargetPlatform;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import processing.app.debug.TargetPackage;
-import processing.app.debug.TargetPlatform;
-
public class ContributedTargetPackage implements TargetPackage {
private final String id;
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPlatform.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPlatform.java
index b7e1a0681..bb099bf8c 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPlatform.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPlatform.java
@@ -26,14 +26,15 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
-package cc.arduino.contributions.packages;
-import java.io.File;
+package cc.arduino.contributions.packages;
import processing.app.debug.LegacyTargetPlatform;
import processing.app.debug.TargetPackage;
import processing.app.debug.TargetPlatformException;
+import java.io.File;
+
public class ContributedTargetPlatform extends LegacyTargetPlatform {
public ContributedTargetPlatform(String _name, File _folder,
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedTool.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedTool.java
index a8f346b79..229df5470 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributedTool.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedTool.java
@@ -26,9 +26,11 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
-import processing.app.BaseNoGui;
+import cc.arduino.contributions.DownloadableContribution;
+import processing.app.Platform;
import java.util.List;
@@ -40,9 +42,9 @@ public abstract class ContributedTool {
public abstract List getSystems();
- public DownloadableContribution getDownloadableContribution() {
+ public DownloadableContribution getDownloadableContribution(Platform platform) {
for (HostDependentDownloadableContribution c : getSystems()) {
- if (c.isCompatible(BaseNoGui.getPlatform()))
+ if (c.isCompatible(platform))
return c;
}
return null;
@@ -50,11 +52,17 @@ public abstract class ContributedTool {
@Override
public String toString() {
+ return toString(null);
+ }
+
+ public String toString(Platform platform) {
String res;
res = "Tool name : " + getName() + " " + getVersion() + "\n";
for (HostDependentDownloadableContribution sys : getSystems()) {
res += " sys";
- res += sys.isCompatible(BaseNoGui.getPlatform()) ? "*" : " ";
+ if (platform != null) {
+ res += sys.isCompatible(platform) ? "*" : " ";
+ }
res += " : " + sys + "\n";
}
return res;
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedToolReference.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedToolReference.java
index ef4c808a8..7d86f234f 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributedToolReference.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedToolReference.java
@@ -26,6 +26,7 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
import java.util.Collection;
@@ -40,6 +41,7 @@ public abstract class ContributedToolReference {
public ContributedTool resolve(Collection packages) {
for (ContributedPackage pack : packages) {
+ assert pack.getTools() != null;
for (ContributedTool tool : pack.getTools())
if (tool.getName().equals(getName()) &&
tool.getVersion().equals(getVersion()) &&
@@ -54,4 +56,4 @@ public abstract class ContributedToolReference {
return "name=" + getName() + " version=" + getVersion() + " packager=" +
getPackager();
}
-}
\ No newline at end of file
+}
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java b/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java
index c083193ee..0de0dd562 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java
@@ -26,8 +26,11 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
+import cc.arduino.contributions.DownloadableContribution;
+import cc.arduino.contributions.DownloadableContributionsDownloader;
import cc.arduino.contributions.GPGDetachedSignatureVerifier;
import cc.arduino.filters.FileExecutablePredicate;
import cc.arduino.utils.ArchiveExtractor;
@@ -35,13 +38,15 @@ import cc.arduino.utils.MultiStepProgress;
import cc.arduino.utils.Progress;
import com.google.common.collect.Collections2;
import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
import processing.app.BaseNoGui;
import processing.app.I18n;
+import processing.app.Platform;
import processing.app.PreferencesData;
import processing.app.helpers.FileUtils;
import processing.app.helpers.filefilters.OnlyDirs;
-import processing.app.tools.CollectStdOutStdErrExecutor;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -56,8 +61,10 @@ public class ContributionInstaller {
private final ContributionsIndexer indexer;
private final DownloadableContributionsDownloader downloader;
+ private final Platform platform;
- public ContributionInstaller(ContributionsIndexer contributionsIndexer) {
+ public ContributionInstaller(ContributionsIndexer contributionsIndexer, Platform platform) {
+ this.platform = platform;
File stagingFolder = contributionsIndexer.getStagingFolder();
indexer = contributionsIndexer;
downloader = new DownloadableContributionsDownloader(stagingFolder) {
@@ -68,18 +75,18 @@ public class ContributionInstaller {
};
}
- public List install(ContributedPlatform platform) throws Exception {
+ public List install(ContributedPlatform contributedPlatform) throws Exception {
List errors = new LinkedList();
- if (platform.isInstalled()) {
+ if (contributedPlatform.isInstalled()) {
throw new Exception("Platform is already installed!");
}
// Do not download already installed tools
- List tools = new LinkedList(platform.getResolvedTools());
+ List tools = new LinkedList(contributedPlatform.getResolvedTools());
Iterator toolsIterator = tools.iterator();
while (toolsIterator.hasNext()) {
ContributedTool tool = toolsIterator.next();
- DownloadableContribution downloadable = tool.getDownloadableContribution();
+ DownloadableContribution downloadable = tool.getDownloadableContribution(platform);
if (downloadable == null) {
throw new Exception(format(_("Tool {0} is not available for your operating system."), tool.getName()));
}
@@ -94,7 +101,7 @@ public class ContributionInstaller {
// Download all
try {
// Download platform
- downloader.download(platform, progress, _("Downloading boards definitions."));
+ downloader.download(contributedPlatform, progress, _("Downloading boards definitions."));
progress.stepDone();
// Download tools
@@ -102,7 +109,7 @@ public class ContributionInstaller {
for (ContributedTool tool : tools) {
String msg = format(_("Downloading tools ({0}/{1})."), i, tools.size());
i++;
- downloader.download(tool.getDownloadableContribution(), progress, msg);
+ downloader.download(tool.getDownloadableContribution(platform), progress, msg);
progress.stepDone();
}
} catch (InterruptedException e) {
@@ -110,7 +117,7 @@ public class ContributionInstaller {
return errors;
}
- ContributedPackage pack = platform.getParentPackage();
+ ContributedPackage pack = contributedPlatform.getParentPackage();
File packageFolder = new File(indexer.getPackagesFolder(), pack.getName());
// TODO: Extract to temporary folders and move to the final destination only
@@ -124,12 +131,12 @@ public class ContributionInstaller {
progress.setStatus(format(_("Installing tools ({0}/{1})..."), i, tools.size()));
onProgress(progress);
i++;
- DownloadableContribution toolContrib = tool.getDownloadableContribution();
+ DownloadableContribution toolContrib = tool.getDownloadableContribution(platform);
File destFolder = new File(toolsFolder, tool.getName() + File.separator + tool.getVersion());
destFolder.mkdirs();
assert toolContrib.getDownloadedFile() != null;
- new ArchiveExtractor(BaseNoGui.getPlatform()).extract(toolContrib.getDownloadedFile(), destFolder, 1);
+ new ArchiveExtractor(platform).extract(toolContrib.getDownloadedFile(), destFolder, 1);
try {
executePostInstallScriptIfAny(destFolder);
} catch (IOException e) {
@@ -143,12 +150,12 @@ public class ContributionInstaller {
// Unpack platform on the correct location
progress.setStatus(_("Installing boards..."));
onProgress(progress);
- File platformFolder = new File(packageFolder, "hardware" + File.separator + platform.getArchitecture());
- File destFolder = new File(platformFolder, platform.getParsedVersion());
+ File platformFolder = new File(packageFolder, "hardware" + File.separator + contributedPlatform.getArchitecture());
+ File destFolder = new File(platformFolder, contributedPlatform.getParsedVersion());
destFolder.mkdirs();
- new ArchiveExtractor(BaseNoGui.getPlatform()).extract(platform.getDownloadedFile(), destFolder, 1);
- platform.setInstalled(true);
- platform.setInstalledFolder(destFolder);
+ new ArchiveExtractor(platform).extract(contributedPlatform.getDownloadedFile(), destFolder, 1);
+ contributedPlatform.setInstalled(true);
+ contributedPlatform.setInstalledFolder(destFolder);
progress.stepDone();
progress.setStatus(_("Installation completed!"));
@@ -158,7 +165,7 @@ public class ContributionInstaller {
}
private void executePostInstallScriptIfAny(File folder) throws IOException {
- Collection postInstallScripts = Collections2.filter(BaseNoGui.getPlatform().postInstallScripts(folder), new FileExecutablePredicate());
+ Collection postInstallScripts = Collections2.filter(platform.postInstallScripts(folder), new FileExecutablePredicate());
if (postInstallScripts.isEmpty()) {
String[] subfolders = folder.list(new OnlyDirs());
@@ -174,7 +181,8 @@ public class ContributionInstaller {
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
- Executor executor = new CollectStdOutStdErrExecutor(stdout, stderr);
+ Executor executor = new DefaultExecutor();
+ executor.setStreamHandler(new PumpStreamHandler(stdout, stderr));
executor.setWorkingDirectory(folder);
executor.setExitValues(null);
int exitValue = executor.execute(new CommandLine(postInstallScript));
@@ -188,22 +196,22 @@ public class ContributionInstaller {
}
}
- public List remove(ContributedPlatform platform) {
- if (platform == null || platform.isReadOnly()) {
+ public List remove(ContributedPlatform contributedPlatform) {
+ if (contributedPlatform == null || contributedPlatform.isReadOnly()) {
return new LinkedList();
}
List errors = new LinkedList();
- FileUtils.recursiveDelete(platform.getInstalledFolder());
- platform.setInstalled(false);
- platform.setInstalledFolder(null);
+ FileUtils.recursiveDelete(contributedPlatform.getInstalledFolder());
+ contributedPlatform.setInstalled(false);
+ contributedPlatform.setInstalledFolder(null);
// Check if the tools are no longer needed
- for (ContributedTool tool : platform.getResolvedTools()) {
+ for (ContributedTool tool : contributedPlatform.getResolvedTools()) {
if (indexer.isContributedToolUsed(tool)) {
continue;
}
- DownloadableContribution toolContrib = tool.getDownloadableContribution();
+ DownloadableContribution toolContrib = tool.getDownloadableContribution(platform);
File destFolder = toolContrib.getInstalledFolder();
FileUtils.recursiveDelete(destFolder);
toolContrib.setInstalled(false);
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndex.java b/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndex.java
index 1804e719f..80d69b045 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndex.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndex.java
@@ -26,6 +26,7 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomComparator;
@@ -83,7 +84,11 @@ public abstract class ContributionsIndex {
return platforms.iterator().next();
}
- public ContributedPlatform getInstalled(String packageName, String platformArch) {
+ public List getInstalledPlatforms() {
+ return Lists.newLinkedList(Collections2.filter(getPlatforms(), new InstalledPredicate()));
+ }
+
+ public ContributedPlatform getInstalledPlatform(String packageName, String platformArch) {
List installedPlatforms = new LinkedList(Collections2.filter(findPlatforms(packageName, platformArch), new InstalledPredicate()));
Collections.sort(installedPlatforms, new DownloadableContributionBuiltInAtTheBottomComparator());
diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java b/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java
index fd26b7e68..ab29cff11 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java
@@ -26,8 +26,10 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
+import cc.arduino.contributions.DownloadableContribution;
import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomComparator;
import cc.arduino.contributions.GPGDetachedSignatureVerifier;
import cc.arduino.contributions.SignatureVerificationFailedException;
@@ -37,14 +39,19 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.mrbean.MrBeanModule;
import com.google.common.base.Function;
+import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Multimaps;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.BaseNoGui;
+import processing.app.Platform;
import processing.app.debug.TargetPackage;
import processing.app.debug.TargetPlatform;
import processing.app.debug.TargetPlatformException;
+import processing.app.helpers.FileUtils;
import processing.app.helpers.PreferencesMap;
import java.io.File;
@@ -60,10 +67,12 @@ public class ContributionsIndexer {
private final File packagesFolder;
private final File stagingFolder;
private final File preferencesFolder;
+ private final Platform platform;
private ContributionsIndex index;
- public ContributionsIndexer(File preferencesFolder) {
+ public ContributionsIndexer(File preferencesFolder, Platform platform) {
this.preferencesFolder = preferencesFolder;
+ this.platform = platform;
packagesFolder = new File(preferencesFolder, "packages");
stagingFolder = new File(preferencesFolder, "staging" + File.separator + "packages");
}
@@ -83,13 +92,20 @@ public class ContributionsIndexer {
}
List packages = index.getPackages();
+ Collection packagesWithTools = Collections2.filter(packages, new Predicate() {
+ @Override
+ public boolean apply(ContributedPackage input) {
+ return input.getTools() != null;
+ }
+ });
+
for (ContributedPackage pack : packages) {
for (ContributedPlatform platform : pack.getPlatforms()) {
// Set a reference to parent packages
platform.setParentPackage(pack);
// Resolve tools dependencies (works also as a check for file integrity)
- platform.resolveToolsDependencies(packages);
+ platform.resolveToolsDependencies(packagesWithTools);
}
}
@@ -168,9 +184,7 @@ public class ContributionsIndexer {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper.readValue(inputStream, ContributionsIndex.class);
} finally {
- if (inputStream != null) {
- inputStream.close();
- }
+ IOUtils.closeQuietly(inputStream);
}
}
@@ -263,7 +277,7 @@ public class ContributionsIndexer {
if (tool == null) {
return;
}
- DownloadableContribution contrib = tool.getDownloadableContribution();
+ DownloadableContribution contrib = tool.getDownloadableContribution(platform);
if (contrib == null) {
System.err.println(tool + " seems to have no downloadable contributions for your operating system, but it is installed in\n" + installationFolder);
return;
@@ -287,7 +301,7 @@ public class ContributionsIndexer {
return index.toString();
}
- public List createTargetPackages() throws TargetPlatformException {
+ public List createTargetPackages() {
List packages = new ArrayList();
if (index == null) {
@@ -304,9 +318,13 @@ public class ContributionsIndexer {
String arch = platform.getArchitecture();
File folder = platform.getInstalledFolder();
- TargetPlatform targetPlatform = new ContributedTargetPlatform(arch, folder, targetPackage, index);
- if (!targetPackage.hasPlatform(targetPlatform)) {
- targetPackage.addPlatform(targetPlatform);
+ try {
+ TargetPlatform targetPlatform = new ContributedTargetPlatform(arch, folder, targetPackage, index);
+ if (!targetPackage.hasPlatform(targetPlatform)) {
+ targetPackage.addPlatform(targetPlatform);
+ }
+ } catch (TargetPlatformException e) {
+ System.err.println(e.getMessage());
}
}
@@ -314,6 +332,15 @@ public class ContributionsIndexer {
packages.add(targetPackage);
}
}
+
+ Collections.sort(packages, new Comparator() {
+ @Override
+ public int compare(TargetPackage p1, TargetPackage p2) {
+ assert p1.getId() != null && p2.getId() != null;
+ return p1.getId().toLowerCase().compareTo(p2.getId().toLowerCase());
+ }
+ });
+
return packages;
}
@@ -398,6 +425,29 @@ public class ContributionsIndexer {
if (index == null) {
return null;
}
- return index.getInstalled(packageName, platformArch);
+ return index.getInstalledPlatform(packageName, platformArch);
+ }
+
+ public List getInstalledPlatforms() {
+ if (index == null) {
+ return new LinkedList();
+ }
+ return index.getInstalledPlatforms();
+ }
+
+ public boolean isFolderInsidePlatform(final File folder) {
+ return getPlatformByFolder(folder) != null;
+ }
+
+ public ContributedPlatform getPlatformByFolder(final File folder) {
+ com.google.common.base.Optional platformOptional = Iterables.tryFind(getInstalledPlatforms(), new Predicate() {
+ @Override
+ public boolean apply(ContributedPlatform contributedPlatform) {
+ assert contributedPlatform.getInstalledFolder() != null;
+ return FileUtils.isSubDirectory(contributedPlatform.getInstalledFolder(), folder);
+ }
+ });
+
+ return platformOptional.orNull();
}
}
diff --git a/arduino-core/src/cc/arduino/contributions/packages/HostDependentDownloadableContribution.java b/arduino-core/src/cc/arduino/contributions/packages/HostDependentDownloadableContribution.java
index c9c7ec1b6..e63f332e7 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/HostDependentDownloadableContribution.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/HostDependentDownloadableContribution.java
@@ -26,8 +26,10 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.contributions.packages;
+import cc.arduino.contributions.DownloadableContribution;
import processing.app.Platform;
public abstract class HostDependentDownloadableContribution extends DownloadableContribution {
diff --git a/arduino-core/src/cc/arduino/contributions/packages/PackageIndexFilenameFilter.java b/arduino-core/src/cc/arduino/contributions/packages/PackageIndexFilenameFilter.java
index 61e7c2663..bfc016750 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/PackageIndexFilenameFilter.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/PackageIndexFilenameFilter.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.contributions.packages;
import java.io.File;
diff --git a/arduino-core/src/cc/arduino/contributions/packages/TestPackageIndexFilenameFilter.java b/arduino-core/src/cc/arduino/contributions/packages/TestPackageIndexFilenameFilter.java
index 6d134eb77..fdcd08384 100644
--- a/arduino-core/src/cc/arduino/contributions/packages/TestPackageIndexFilenameFilter.java
+++ b/arduino-core/src/cc/arduino/contributions/packages/TestPackageIndexFilenameFilter.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.contributions.packages;
import java.io.File;
diff --git a/arduino-core/src/cc/arduino/files/DeleteFilesOnShutdown.java b/arduino-core/src/cc/arduino/files/DeleteFilesOnShutdown.java
index 7d9f60139..50cca37e9 100644
--- a/arduino-core/src/cc/arduino/files/DeleteFilesOnShutdown.java
+++ b/arduino-core/src/cc/arduino/files/DeleteFilesOnShutdown.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.files;
import processing.app.PreferencesData;
diff --git a/arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java b/arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java
index b7ede72c2..48d9cdd4b 100644
--- a/arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java
+++ b/arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java
@@ -33,6 +33,7 @@ import cc.arduino.packages.BoardPort;
import cc.arduino.packages.Discovery;
import cc.arduino.packages.discoverers.network.BoardReachabilityFilter;
import cc.arduino.packages.discoverers.network.NetworkChecker;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.BaseNoGui;
import processing.app.helpers.PreferencesMap;
import processing.app.zeroconf.jmdns.ArduinoDNSTaskStarter;
@@ -199,12 +200,6 @@ public class NetworkDiscovery implements Discovery, ServiceListener, cc.arduino.
@Override
public void inetAddressRemoved(InetAddress address) {
JmDNS jmDNS = mappedJmDNSs.remove(address);
- if (jmDNS != null) {
- try {
- jmDNS.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ IOUtils.closeQuietly(jmDNS);
}
}
diff --git a/arduino-core/src/cc/arduino/packages/discoverers/SerialDiscovery.java b/arduino-core/src/cc/arduino/packages/discoverers/SerialDiscovery.java
index 354e88da3..4a09d606f 100644
--- a/arduino-core/src/cc/arduino/packages/discoverers/SerialDiscovery.java
+++ b/arduino-core/src/cc/arduino/packages/discoverers/SerialDiscovery.java
@@ -37,8 +37,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Timer;
-import static processing.app.I18n._;
-
public class SerialDiscovery implements Discovery {
private Timer serialBoardsListerTimer;
diff --git a/arduino-core/src/cc/arduino/packages/discoverers/serial/SerialBoardsLister.java b/arduino-core/src/cc/arduino/packages/discoverers/serial/SerialBoardsLister.java
index 58ad2e509..fa9b80490 100644
--- a/arduino-core/src/cc/arduino/packages/discoverers/serial/SerialBoardsLister.java
+++ b/arduino-core/src/cc/arduino/packages/discoverers/serial/SerialBoardsLister.java
@@ -41,8 +41,6 @@ import java.util.*;
public class SerialBoardsLister extends TimerTask {
- private static final int MAX_TIME_AWAITING_FOR_PACKAGES = 5000;
-
private final SerialDiscovery serialDiscovery;
public SerialBoardsLister(SerialDiscovery serialDiscovery) {
@@ -55,13 +53,11 @@ public class SerialBoardsLister extends TimerTask {
@Override
public void run() {
- int sleptFor = 0;
- while (BaseNoGui.packages == null && sleptFor <= MAX_TIME_AWAITING_FOR_PACKAGES) {
+ while (BaseNoGui.packages == null) {
try {
Thread.sleep(1000);
- sleptFor += 1000;
} catch (InterruptedException e) {
- e.printStackTrace();
+ // noop
}
}
diff --git a/arduino-core/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java b/arduino-core/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java
index a689dc957..fb0331052 100644
--- a/arduino-core/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java
+++ b/arduino-core/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.packages.ssh;
import com.jcraft.jsch.UserInfo;
diff --git a/arduino-core/src/cc/arduino/packages/ssh/SCP.java b/arduino-core/src/cc/arduino/packages/ssh/SCP.java
index 458e1b8d5..efeb761e0 100644
--- a/arduino-core/src/cc/arduino/packages/ssh/SCP.java
+++ b/arduino-core/src/cc/arduino/packages/ssh/SCP.java
@@ -32,6 +32,7 @@ package cc.arduino.packages.ssh;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.Session;
+import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
@@ -61,12 +62,8 @@ public class SCP extends SSH {
}
public void close() throws IOException {
- if (out != null) {
- out.close();
- }
- if (in != null) {
- in.close();
- }
+ IOUtils.closeQuietly(out);
+ IOUtils.closeQuietly(in);
if (channel != null) {
channel.disconnect();
}
@@ -118,9 +115,7 @@ public class SCP extends SSH {
buf[0] = 0;
out.write(buf, 0, 1);
} finally {
- if (fis != null) {
- fis.close();
- }
+ IOUtils.closeQuietly(fis);
}
ensureAcknowledged();
diff --git a/arduino-core/src/cc/arduino/packages/ssh/SSH.java b/arduino-core/src/cc/arduino/packages/ssh/SSH.java
index 0bb6f8a34..1e20adebb 100644
--- a/arduino-core/src/cc/arduino/packages/ssh/SSH.java
+++ b/arduino-core/src/cc/arduino/packages/ssh/SSH.java
@@ -33,6 +33,7 @@ import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
+import org.apache.commons.compress.utils.IOUtils;
import java.io.IOException;
import java.io.InputStream;
@@ -70,12 +71,8 @@ public class SSH {
return exitCode == 0;
} finally {
- if (stdout != null) {
- stdout.close();
- }
- if (stderr != null) {
- stderr.close();
- }
+ IOUtils.closeQuietly(stdout);
+ IOUtils.closeQuietly(stderr);
if (channel != null) {
channel.disconnect();
}
diff --git a/arduino-core/src/cc/arduino/packages/ssh/SSHClientSetupChainRing.java b/arduino-core/src/cc/arduino/packages/ssh/SSHClientSetupChainRing.java
index 7590e8427..c66e7bcd8 100644
--- a/arduino-core/src/cc/arduino/packages/ssh/SSHClientSetupChainRing.java
+++ b/arduino-core/src/cc/arduino/packages/ssh/SSHClientSetupChainRing.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.packages.ssh;
import cc.arduino.packages.BoardPort;
diff --git a/arduino-core/src/cc/arduino/packages/ssh/SSHConfigFileSetup.java b/arduino-core/src/cc/arduino/packages/ssh/SSHConfigFileSetup.java
index c3432a023..be2116f8f 100644
--- a/arduino-core/src/cc/arduino/packages/ssh/SSHConfigFileSetup.java
+++ b/arduino-core/src/cc/arduino/packages/ssh/SSHConfigFileSetup.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.packages.ssh;
import cc.arduino.packages.BoardPort;
diff --git a/arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java b/arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
index 3eedcd819..2465956cc 100644
--- a/arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
+++ b/arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.packages.ssh;
import cc.arduino.packages.BoardPort;
diff --git a/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java b/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java
index c98d3eab7..1b5c8c9fe 100644
--- a/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java
+++ b/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java
@@ -26,23 +26,19 @@
package cc.arduino.packages.uploaders;
-import static processing.app.I18n._;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import processing.app.BaseNoGui;
-import processing.app.I18n;
-import processing.app.PreferencesData;
-import processing.app.Serial;
-import processing.app.SerialException;
+import cc.arduino.packages.Uploader;
+import processing.app.*;
import processing.app.debug.RunnerException;
import processing.app.debug.TargetPlatform;
import processing.app.helpers.OSUtils;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.StringReplacer;
-import cc.arduino.packages.Uploader;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import static processing.app.I18n._;
public class SerialUploader extends Uploader {
@@ -110,16 +106,18 @@ public class SerialUploader extends Uploader {
t = prefs.get("upload.wait_for_upload_port");
boolean waitForUploadPort = (t != null) && t.equals("true");
+ String userSelectedUploadPort = prefs.getOrExcept("serial.port");
+ String actualUploadPort = null;
+
if (doTouch) {
- String uploadPort = prefs.getOrExcept("serial.port");
try {
// Toggle 1200 bps on selected serial port to force board reset.
List before = Serial.list();
- if (before.contains(uploadPort)) {
+ if (before.contains(userSelectedUploadPort)) {
if (verbose)
System.out.println(
- I18n.format(_("Forcing reset using 1200bps open/close on port {0}"), uploadPort));
- Serial.touchForCDCReset(uploadPort);
+ I18n.format(_("Forcing reset using 1200bps open/close on port {0}"), userSelectedUploadPort));
+ Serial.touchForCDCReset(userSelectedUploadPort);
}
Thread.sleep(400);
if (waitForUploadPort) {
@@ -127,34 +125,34 @@ public class SerialUploader extends Uploader {
// otherwise assert DTR, which would cancel the WDT reset if
// it happened within 250 ms. So we wait until the reset should
// have already occured before we start scanning.
- uploadPort = waitForUploadPort(uploadPort, before);
+ actualUploadPort = waitForUploadPort(userSelectedUploadPort, before);
}
} catch (SerialException e) {
throw new RunnerException(e);
} catch (InterruptedException e) {
throw new RunnerException(e.getMessage());
}
- prefs.put("serial.port", uploadPort);
- if (uploadPort.startsWith("/dev/"))
- prefs.put("serial.port.file", uploadPort.substring(5));
- else
- prefs.put("serial.port.file", uploadPort);
+ if (actualUploadPort == null) {
+ actualUploadPort = userSelectedUploadPort;
+ }
+ prefs.put("serial.port", actualUploadPort);
+ if (actualUploadPort.startsWith("/dev/")) {
+ prefs.put("serial.port.file", actualUploadPort.substring(5));
+ } else {
+ prefs.put("serial.port.file", actualUploadPort);
+ }
}
prefs.put("build.path", buildPath);
prefs.put("build.project_name", className);
- if (verbose)
+ if (verbose) {
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.verbose"));
- else
+ } else {
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.quiet"));
+ }
boolean uploadResult;
try {
-// if (prefs.get("upload.disable_flushing") == null
-// || prefs.get("upload.disable_flushing").toLowerCase().equals("false")) {
-// flushSerialBuffer();
-// }
-
String pattern = prefs.getOrExcept("upload.pattern");
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
uploadResult = executeUploadCommand(cmd);
@@ -164,9 +162,9 @@ public class SerialUploader extends Uploader {
throw new RunnerException(e);
}
- try {
- if (uploadResult && doTouch) {
- String uploadPort = PreferencesData.get("serial.port");
+ String finalUploadPort = null;
+ if (uploadResult && doTouch) {
+ try {
if (waitForUploadPort) {
// For Due/Leonardo wait until the bootloader serial port disconnects and the
// sketch serial port reconnects (or timeout after a few seconds if the
@@ -176,15 +174,28 @@ public class SerialUploader extends Uploader {
long started = System.currentTimeMillis();
while (System.currentTimeMillis() - started < 2000) {
List portList = Serial.list();
- if (portList.contains(uploadPort))
+ if (portList.contains(actualUploadPort)) {
+ finalUploadPort = actualUploadPort;
break;
+ } else if (portList.contains(userSelectedUploadPort)) {
+ finalUploadPort = userSelectedUploadPort;
+ break;
+ }
Thread.sleep(250);
}
}
+ } catch (InterruptedException ex) {
+ // noop
}
- } catch (InterruptedException ex) {
- // noop
}
+
+ if (finalUploadPort == null) {
+ finalUploadPort = actualUploadPort;
+ }
+ if (finalUploadPort == null) {
+ finalUploadPort = userSelectedUploadPort;
+ }
+ BaseNoGui.selectSerialPort(finalUploadPort);
return uploadResult;
}
diff --git a/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java b/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java
index fe68fa870..4620d46c3 100644
--- a/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java
+++ b/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java
@@ -26,6 +26,7 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.utils;
import org.apache.commons.compress.archivers.ArchiveEntry;
@@ -35,6 +36,7 @@ import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.I18n;
import processing.app.Platform;
@@ -258,9 +260,7 @@ public class ArchiveExtractor {
}
} finally {
- if (in != null) {
- in.close();
- }
+ IOUtils.closeQuietly(in);
}
// Set folders timestamps
@@ -294,9 +294,7 @@ public class ArchiveExtractor {
size -= length;
}
} finally {
- if (fos != null) {
- fos.close();
- }
+ IOUtils.closeQuietly(fos);
}
}
diff --git a/arduino-core/src/cc/arduino/utils/FileHash.java b/arduino-core/src/cc/arduino/utils/FileHash.java
index 0ce8afd4c..94b6ec816 100644
--- a/arduino-core/src/cc/arduino/utils/FileHash.java
+++ b/arduino-core/src/cc/arduino/utils/FileHash.java
@@ -26,8 +26,11 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.utils;
+import org.apache.commons.compress.utils.IOUtils;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -68,9 +71,7 @@ public class FileHash {
}
return algorithm + ":" + res;
} finally {
- if (in != null) {
- in.close();
- }
+ IOUtils.closeQuietly(in);
}
}
}
diff --git a/arduino-core/src/cc/arduino/utils/MultiStepProgress.java b/arduino-core/src/cc/arduino/utils/MultiStepProgress.java
index 6846ab79a..c911b64bf 100644
--- a/arduino-core/src/cc/arduino/utils/MultiStepProgress.java
+++ b/arduino-core/src/cc/arduino/utils/MultiStepProgress.java
@@ -26,6 +26,7 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.utils;
public class MultiStepProgress implements Progress {
diff --git a/arduino-core/src/cc/arduino/utils/Progress.java b/arduino-core/src/cc/arduino/utils/Progress.java
index cc63ff3a8..b25aa2884 100644
--- a/arduino-core/src/cc/arduino/utils/Progress.java
+++ b/arduino-core/src/cc/arduino/utils/Progress.java
@@ -26,6 +26,7 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.utils;
public interface Progress {
diff --git a/arduino-core/src/cc/arduino/utils/ReverseComparator.java b/arduino-core/src/cc/arduino/utils/ReverseComparator.java
index 50c0ccd45..340821280 100644
--- a/arduino-core/src/cc/arduino/utils/ReverseComparator.java
+++ b/arduino-core/src/cc/arduino/utils/ReverseComparator.java
@@ -1,3 +1,32 @@
+/*
+ * This file is part of Arduino.
+ *
+ * Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+ *
+ * Arduino is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ */
+
package cc.arduino.utils;
import java.util.Comparator;
diff --git a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java
index 358de9759..c874c556d 100644
--- a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java
+++ b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java
@@ -26,18 +26,17 @@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/
+
package cc.arduino.utils.network;
import org.apache.commons.codec.binary.Base64;
-import processing.app.PreferencesData;
+import org.apache.commons.compress.utils.IOUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
-import java.net.HttpURLConnection;
-import java.net.SocketTimeoutException;
-import java.net.URL;
+import java.net.*;
import java.util.Observable;
public class FileDownloader extends Observable {
@@ -121,29 +120,9 @@ public class FileDownloader extends Observable {
setStatus(Status.CONNECTING);
- System.getProperties().remove("http.proxyHost");
- System.getProperties().remove("http.proxyPort");
- System.getProperties().remove("https.proxyHost");
- System.getProperties().remove("https.proxyPort");
- System.getProperties().remove("http.proxyUser");
- System.getProperties().remove("http.proxyPassword");
+ Proxy proxy = ProxySelector.getDefault().select(downloadUrl.toURI()).get(0);
- if (PreferencesData.has("proxy.http.server") && PreferencesData.get("proxy.http.server") != null && !PreferencesData.get("proxy.http.server").equals("")) {
- System.getProperties().put("http.proxyHost", PreferencesData.get("proxy.http.server"));
- System.getProperties().put("http.proxyPort", PreferencesData.get("proxy.http.port"));
- }
- if (PreferencesData.has("proxy.https.server") && PreferencesData.get("proxy.https.server") != null && !PreferencesData.get("proxy.https.server").equals("")) {
- System.getProperties().put("https.proxyHost", PreferencesData.get("proxy.https.server"));
- System.getProperties().put("https.proxyPort", PreferencesData.get("proxy.https.port"));
- }
- if (PreferencesData.has("proxy.user") && PreferencesData.get("proxy.user") != null && !PreferencesData.get("proxy.user").equals("")) {
- System.getProperties().put("http.proxyUser", PreferencesData.get("proxy.user"));
- System.getProperties().put("http.proxyPassword", PreferencesData.get("proxy.password"));
- System.getProperties().put("https.proxyUser", PreferencesData.get("proxy.user"));
- System.getProperties().put("https.proxyPassword", PreferencesData.get("proxy.password"));
- }
-
- HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection();
+ HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection(proxy);
if (downloadUrl.getUserInfo() != null) {
String auth = "Basic " + new String(new Base64().encode(downloadUrl.getUserInfo().getBytes()));
@@ -159,10 +138,12 @@ public class FileDownloader extends Observable {
int resp = connection.getResponseCode();
if (resp == HttpURLConnection.HTTP_MOVED_PERM || resp == HttpURLConnection.HTTP_MOVED_TEMP) {
- String newUrl = connection.getHeaderField("Location");
+ URL newUrl = new URL(connection.getHeaderField("Location"));
+
+ proxy = ProxySelector.getDefault().select(newUrl.toURI()).get(0);
// open the new connnection again
- connection = (HttpURLConnection) new URL(newUrl).openConnection();
+ connection = (HttpURLConnection) newUrl.openConnection(proxy);
if (downloadUrl.getUserInfo() != null) {
String auth = "Basic " + new String(new Base64().encode(downloadUrl.getUserInfo().getBytes()));
connection.setRequestProperty("Authorization", auth);
@@ -176,7 +157,7 @@ public class FileDownloader extends Observable {
}
if (resp < 200 || resp >= 300) {
- throw new IOException("Recevied invalid http status code from server: " + resp);
+ throw new IOException("Received invalid http status code from server: " + resp);
}
// Check for valid content length.
@@ -221,22 +202,10 @@ public class FileDownloader extends Observable {
setError(e);
} finally {
- if (file != null) {
- try {
- file.close();
- } catch (Exception e) {
- //ignore
- }
- }
+ IOUtils.closeQuietly(file);
synchronized (this) {
- if (stream != null) {
- try {
- stream.close();
- } catch (Exception e) {
- //ignore
- }
- }
+ IOUtils.closeQuietly(stream);
}
}
}
diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java
index da2fcfdd9..85d951dd4 100644
--- a/arduino-core/src/processing/app/BaseNoGui.java
+++ b/arduino-core/src/processing/app/BaseNoGui.java
@@ -8,6 +8,7 @@ import cc.arduino.files.DeleteFilesOnShutdown;
import cc.arduino.packages.DiscoveryManager;
import cc.arduino.packages.Uploader;
import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.logging.impl.LogFactoryImpl;
import org.apache.commons.logging.impl.NoOpLog;
import processing.app.debug.Compiler;
@@ -30,9 +31,9 @@ import static processing.app.I18n._;
public class BaseNoGui {
/** Version string to be used for build */
- public static final int REVISION = 10605;
+ public static final int REVISION = 10606;
/** Extended version string displayed on GUI */
- public static final String VERSION_NAME = "1.6.5";
+ public static final String VERSION_NAME = "1.6.6";
public static final String VERSION_NAME_LONG;
static {
@@ -315,14 +316,15 @@ public class BaseNoGui {
static public File getSketchbookLibrariesFolder() {
File libdir = new File(getSketchbookFolder(), "libraries");
if (!libdir.exists()) {
+ FileWriter freadme = null;
try {
libdir.mkdirs();
- File readme = new File(libdir, "readme.txt");
- FileWriter freadme = new FileWriter(readme);
+ freadme = new FileWriter(new File(libdir, "readme.txt"));
freadme.write(_("For information on installing libraries, see: " +
- "http://arduino.cc/en/Guide/Libraries\n"));
- freadme.close();
+ "http://www.arduino.cc/en/Guide/Libraries\n"));
} catch (Exception e) {
+ } finally {
+ IOUtils.closeQuietly(freadme);
}
}
return libdir;
@@ -417,7 +419,7 @@ public class BaseNoGui {
* within the header files at the top-level).
*/
static public String[] headerListFromIncludePath(File path) throws IOException {
- String[] list = path.list(new OnlyFilesWithExtension(".h"));
+ String[] list = path.list(new OnlyFilesWithExtension(".h", ".hh", ".hpp"));
if (list == null) {
throw new IOException();
}
@@ -425,8 +427,9 @@ public class BaseNoGui {
}
static public void init(String[] args) throws Exception {
- getPlatform().init();
-
+ CommandlineParser parser = new CommandlineParser(args);
+ parser.parseArgumentsPhase1();
+
String sketchbookPath = getSketchbookPath();
// If no path is set, get the default sketchbook folder for this platform
@@ -436,13 +439,13 @@ public class BaseNoGui {
else
showError(_("No sketchbook"), _("Sketchbook path not defined"), null);
}
-
+
BaseNoGui.initPackages();
// Setup board-dependent variables.
onBoardOrPortChange();
-
- CommandlineParser parser = CommandlineParser.newCommandlineParser(args);
+
+ parser.parseArgumentsPhase2();
for (String path: parser.getFilenames()) {
// Correctly resolve relative paths
@@ -570,6 +573,12 @@ public class BaseNoGui {
System.exit(0);
}
else if (parser.isGetPrefMode()) {
+ dumpPrefs(parser);
+ }
+ }
+
+ protected static void dumpPrefs(CommandlineParser parser) {
+ if (parser.getGetPref() != null) {
String value = PreferencesData.get(parser.getGetPref(), null);
if (value != null) {
System.out.println(value);
@@ -577,6 +586,13 @@ public class BaseNoGui {
} else {
System.exit(4);
}
+ } else {
+ System.out.println("#PREFDUMP#");
+ PreferencesMap prefs = PreferencesData.getMap();
+ for (Map.Entry entry : prefs.entrySet()) {
+ System.out.println(entry.getKey() + "=" + entry.getValue());
+ }
+ System.exit(0);
}
}
@@ -586,7 +602,7 @@ public class BaseNoGui {
}
static public void initPackages() throws Exception {
- indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder());
+ indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder(), BaseNoGui.getPlatform());
File indexFile = indexer.getIndexFile("package_index.json");
File defaultPackageJsonFile = new File(getContentFile("dist"), "package_index.json");
if (!indexFile.isFile() || (defaultPackageJsonFile.isFile() && defaultPackageJsonFile.lastModified() > indexFile.lastModified())) {
@@ -597,11 +613,8 @@ public class BaseNoGui {
try {
out = new FileOutputStream(indexFile);
out.write("{ \"packages\" : [ ] }".getBytes());
- out.close();
} finally {
- if (out != null) {
- out.close();
- }
+ IOUtils.closeQuietly(out);
}
}
@@ -624,13 +637,13 @@ public class BaseNoGui {
}
indexer.syncWithFilesystem(getHardwareFolder());
- packages = new HashMap();
+ packages = new LinkedHashMap();
loadHardware(getHardwareFolder());
- loadHardware(getSketchbookHardwareFolder());
loadContributedHardware(indexer);
+ loadHardware(getSketchbookHardwareFolder());
createToolPreferences(indexer);
- librariesIndexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder());
+ librariesIndexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder(), indexer);
File librariesIndexFile = librariesIndexer.getIndexFile();
if (!librariesIndexFile.isFile()) {
File defaultLibraryJsonFile = new File(getContentFile("dist"), "library_index.json");
@@ -645,9 +658,7 @@ public class BaseNoGui {
} catch (IOException e) {
e.printStackTrace();
} finally {
- if (out != null) {
- out.close();
- }
+ IOUtils.closeQuietly(out);
}
}
}
@@ -734,20 +745,47 @@ public class BaseNoGui {
}
static public void main(String args[]) throws Exception {
- if (args.length == 0)
+ if (args.length == 0) {
showError(_("No parameters"), _("No command line parameters found"), null);
+ }
+ System.setProperty("java.net.useSystemProxies", "true");
Runtime.getRuntime().addShutdownHook(new Thread(DeleteFilesOnShutdown.INSTANCE));
initPlatform();
-
+
+ getPlatform().init();
+
initPortableFolder();
initParameters(args);
-
+
+ checkInstallationFolder();
+
init(args);
}
+ public static void checkInstallationFolder() {
+ if (isIDEInstalledIntoSettingsFolder()) {
+ showError(_("Incorrect IDE installation folder"), _("Your copy of the IDE is installed in a subfolder of your settings folder.\nPlease move the IDE to another folder."), 10);
+ }
+ if (isIDEInstalledIntoSketchbookFolder()) {
+ showError(_("Incorrect IDE installation folder"), _("Your copy of the IDE is installed in a subfolder of your sketchbook.\nPlease move the IDE to another folder."), 10);
+ }
+ }
+
+ public static boolean isIDEInstalledIntoSketchbookFolder() {
+ return PreferencesData.has("sketchbook.path") && FileUtils.isSubDirectory(new File(PreferencesData.get("sketchbook.path")), new File(PreferencesData.get("runtime.ide.path")));
+ }
+
+ public static boolean isIDEInstalledIntoSettingsFolder() {
+ try {
+ return FileUtils.isSubDirectory(BaseNoGui.getPlatform().getSettingsFolder(), new File(PreferencesData.get("runtime.ide.path")));
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
static public void onBoardOrPortChange() {
examplesFolder = getContentFile("examples");
toolsFolder = getContentFile("tools");
@@ -788,7 +826,7 @@ public class BaseNoGui {
populateImportToLibraryTable();
}
- static protected void loadContributedHardware(ContributionsIndexer indexer) throws TargetPlatformException {
+ static protected void loadContributedHardware(ContributionsIndexer indexer) {
for (TargetPackage pack : indexer.createTargetPackages()) {
packages.put(pack.getId(), pack);
}
@@ -800,7 +838,7 @@ public class BaseNoGui {
PreferencesData.removeAllKeysWithPrefix(prefix);
for (ContributedTool tool : indexer.getInstalledTools()) {
- File installedFolder = tool.getDownloadableContribution().getInstalledFolder();
+ File installedFolder = tool.getDownloadableContribution(getPlatform()).getInstalledFolder();
if (installedFolder != null) {
PreferencesData.set(prefix + tool.getName() + ".path", installedFolder.getAbsolutePath());
PreferencesData.set(prefix + tool.getName() + "-" + tool.getVersion() + ".path", installedFolder.getAbsolutePath());
@@ -956,14 +994,18 @@ public class BaseNoGui {
if (!dir.exists()) return;
String files[] = dir.list();
- for (int i = 0; i < files.length; i++) {
- if (files[i].equals(".") || files[i].equals("..")) continue;
- File dead = new File(dir, files[i]);
+ if (files == null) {
+ return;
+ }
+
+ for (String file : files) {
+ if (file.equals(".") || file.equals("..")) continue;
+ File dead = new File(dir, file);
if (!dead.isDirectory()) {
if (!PreferencesData.getBoolean("compiler.save_build_files")) {
if (!dead.delete()) {
// temporarily disabled
- System.err.println(I18n.format(_("Could not delete {0}"), dead));
+ System.err.println(I18n.format(_("Could not delete {0}"), dead));
}
}
} else {
@@ -1068,10 +1110,11 @@ public class BaseNoGui {
public static void selectSerialPort(String port) {
PreferencesData.set("serial.port", port);
- if (port.startsWith("/dev/"))
- PreferencesData.set("serial.port.file", port.substring(5));
- else
- PreferencesData.set("serial.port.file", port);
+ String portFile = port;
+ if (port.startsWith("/dev/")) {
+ portFile = portFile.substring(5);
+ }
+ PreferencesData.set("serial.port.file", portFile);
}
public static void setBuildFolder(File newBuildFolder) {
diff --git a/arduino-core/src/processing/app/Platform.java b/arduino-core/src/processing/app/Platform.java
index b2deee2f8..1d39b27eb 100644
--- a/arduino-core/src/processing/app/Platform.java
+++ b/arduino-core/src/processing/app/Platform.java
@@ -29,8 +29,12 @@ import processing.app.debug.TargetPlatform;
import processing.app.legacy.PConstants;
import javax.swing.*;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import static processing.app.I18n._;
@@ -38,42 +42,42 @@ import static processing.app.I18n._;
/**
* Used by Base for platform-specific tweaking, for instance finding the
* sketchbook location using the Windows registry, or OS X event handling.
- *
- * The methods in this implementation are used by default, and can be
- * overridden by a subclass, if loaded by Base.main().
- *
+ *
+ * The methods in this implementation are used by default, and can be
+ * overridden by a subclass, if loaded by Base.main().
+ *
* These methods throw vanilla-flavored Exceptions, so that error handling
- * occurs inside Base.
- *
- * There is currently no mechanism for adding new platforms, as the setup is
- * not automated. We could use getProperty("os.arch") perhaps, but that's
- * debatable (could be upper/lowercase, have spaces, etc.. basically we don't
+ * occurs inside Base.
+ *
+ * There is currently no mechanism for adding new platforms, as the setup is
+ * not automated. We could use getProperty("os.arch") perhaps, but that's
+ * debatable (could be upper/lowercase, have spaces, etc.. basically we don't
* know if name is proper Java package syntax.)
*/
public class Platform {
-
-
+
+
/**
* Set the default L & F. While I enjoy the bounty of the sixteen possible
- * exception types that this UIManager method might throw, I feel that in
+ * exception types that this UIManager method might throw, I feel that in
* just this one particular case, I'm being spoiled by those engineers
* at Sun, those Masters of the Abstractionverse. It leaves me feeling sad
* and overweight. So instead, I'll pretend that I'm not offered eleven dozen
* ways to report to the user exactly what went wrong, and I'll bundle them
- * all into a single catch-all "Exception". Because in the end, all I really
+ * all into a single catch-all "Exception". Because in the end, all I really
* care about is whether things worked or not. And even then, I don't care.
- *
+ *
* @throws Exception Just like I said.
*/
public void setLookAndFeel() throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
-
-
+
+
public void init() throws IOException {
}
-
-
+
+
public File getSettingsFolder() throws Exception {
// otherwise make a .processing directory int the user's home dir
File home = new File(System.getProperty("user.home"));
@@ -95,37 +99,46 @@ public class Platform {
}
*/
}
-
+
/**
- * @return null if not overridden, which will cause a prompt to show instead.
+ * @return null if not overridden, which will cause a prompt to show instead.
* @throws Exception
*/
public File getDefaultSketchbookFolder() throws Exception {
return null;
}
-
-
+
+ public void openURL(File folder, String url) throws Exception {
+ if (!url.startsWith("file://./")) {
+ openURL(url);
+ return;
+ }
+
+ url = url.replaceAll("file://./", folder.getCanonicalFile().toURI().toASCIIString());
+ openURL(url);
+ }
+
public void openURL(String url) throws Exception {
String launcher = PreferencesData.get("launcher");
if (launcher != null) {
- Runtime.getRuntime().exec(new String[] { launcher, url });
+ Runtime.getRuntime().exec(new String[]{launcher, url});
} else {
showLauncherWarning();
- }
+ }
}
public boolean openFolderAvailable() {
return PreferencesData.get("launcher") != null;
}
-
-
+
+
public void openFolder(File file) throws Exception {
String launcher = PreferencesData.get("launcher");
if (launcher != null) {
String folder = file.getAbsolutePath();
- Runtime.getRuntime().exec(new String[] { launcher, folder });
+ Runtime.getRuntime().exec(new String[]{launcher, folder});
} else {
showLauncherWarning();
}
@@ -184,14 +197,14 @@ public class Platform {
return PConstants.platformNames[PConstants.OTHER];
}
-
+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
protected void showLauncherWarning() {
- BaseNoGui.showWarning(_("No launcher available"),
- _("Unspecified platform, no launcher available.\nTo enable opening URLs or folders, add a \n\"launcher=/path/to/app\" line to preferences.txt"),
- null);
+ BaseNoGui.showWarning(_("No launcher available"),
+ _("Unspecified platform, no launcher available.\nTo enable opening URLs or folders, add a \n\"launcher=/path/to/app\" line to preferences.txt"),
+ null);
}
public List filterPorts(List ports, boolean aBoolean) {
diff --git a/arduino-core/src/processing/app/PreferencesData.java b/arduino-core/src/processing/app/PreferencesData.java
index 7733b08e4..380070001 100644
--- a/arduino-core/src/processing/app/PreferencesData.java
+++ b/arduino-core/src/processing/app/PreferencesData.java
@@ -1,23 +1,23 @@
package processing.app;
-import static processing.app.I18n._;
-
-import java.awt.*;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.MissingResourceException;
-
+import com.google.common.base.Joiner;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.helpers.PreferencesHelper;
import processing.app.helpers.PreferencesMap;
import processing.app.legacy.PApplet;
import processing.app.legacy.PConstants;
+import java.awt.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.MissingResourceException;
+
+import static processing.app.I18n._;
+
public class PreferencesData {
@@ -50,14 +50,14 @@ public class PreferencesData {
prefs.load(new File(BaseNoGui.getContentFile("lib"), PREFS_FILE));
} catch (IOException e) {
BaseNoGui.showError(null, _("Could not read default settings.\n" +
- "You'll need to reinstall Arduino."), e);
+ "You'll need to reinstall Arduino."), e);
}
// set some runtime constants (not saved on preferences file)
File hardwareFolder = BaseNoGui.getHardwareFolder();
prefs.put("runtime.ide.path", hardwareFolder.getParentFile().getAbsolutePath());
prefs.put("runtime.ide.version", "" + BaseNoGui.REVISION);
-
+
// clone the hash table
defaults = new PreferencesMap(prefs);
@@ -67,10 +67,10 @@ public class PreferencesData {
prefs.load(preferencesFile);
} catch (IOException ex) {
BaseNoGui.showError(_("Error reading preferences"),
- I18n.format(_("Error reading the preferences file. "
- + "Please delete (or move)\n"
- + "{0} and restart Arduino."),
- preferencesFile.getAbsolutePath()), ex);
+ I18n.format(_("Error reading the preferences file. "
+ + "Please delete (or move)\n"
+ + "{0} and restart Arduino."),
+ preferencesFile.getAbsolutePath()), ex);
}
}
@@ -124,9 +124,7 @@ public class PreferencesData {
writer.flush();
} finally {
- if (writer != null) {
- writer.close();
- }
+ IOUtils.closeQuietly(writer);
}
try {
@@ -198,8 +196,7 @@ public class PreferencesData {
}
// get a copy of the Preferences
- static public PreferencesMap getMap()
- {
+ static public PreferencesMap getMap() {
return new PreferencesMap(prefs);
}
@@ -212,8 +209,7 @@ public class PreferencesData {
// Decide wether changed preferences will be saved. When value is
// false, Preferences.save becomes a no-op.
- static public void setDoSave(boolean value)
- {
+ static public void setDoSave(boolean value) {
doSave = value;
}
@@ -226,4 +222,13 @@ public class PreferencesData {
}
return font;
}
+
+ public static Collection getCollection(String key) {
+ return Arrays.asList(get(key, "").split(","));
+ }
+
+ public static void setCollection(String key, Collection values) {
+ String value = Joiner.on(',').join(values);
+ set(key, value);
+ }
}
diff --git a/arduino-core/src/processing/app/Serial.java b/arduino-core/src/processing/app/Serial.java
index e442299d3..efec07cf2 100644
--- a/arduino-core/src/processing/app/Serial.java
+++ b/arduino-core/src/processing/app/Serial.java
@@ -22,16 +22,16 @@
package processing.app;
-import static processing.app.I18n._;
+import jssc.SerialPort;
+import jssc.SerialPortEvent;
+import jssc.SerialPortEventListener;
+import jssc.SerialPortException;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
-import jssc.SerialPort;
-import jssc.SerialPortEvent;
-import jssc.SerialPortEventListener;
-import jssc.SerialPortException;
+import static processing.app.I18n._;
public class Serial implements SerialPortEventListener {
@@ -45,19 +45,14 @@ public class Serial implements SerialPortEventListener {
// for the classloading problem.. because if code ran again,
// the static class would have an object that could be closed
- SerialPort port;
-
- int rate;
- int parity;
- int databits;
- int stopbits;
+ private SerialPort port;
public Serial() throws SerialException {
this(PreferencesData.get("serial.port"),
PreferencesData.getInteger("serial.debug_rate"),
PreferencesData.get("serial.parity").charAt(0),
PreferencesData.getInteger("serial.databits"),
- new Float(PreferencesData.get("serial.stopbits")).floatValue(),
+ Float.parseFloat(PreferencesData.get("serial.stopbits"))),
BaseNoGui.getBoardPreferences().get("serial.disableRTS") == null,
BaseNoGui.getBoardPreferences().get("serial.disableDTR") == null);
}
@@ -66,7 +61,7 @@ public class Serial implements SerialPortEventListener {
this(PreferencesData.get("serial.port"), irate,
PreferencesData.get("serial.parity").charAt(0),
PreferencesData.getInteger("serial.databits"),
- new Float(PreferencesData.get("serial.stopbits")).floatValue(),
+ Float.parseFloat(PreferencesData.get("serial.stopbits"))),
BaseNoGui.getBoardPreferences().get("serial.disableRTS") == null,
BaseNoGui.getBoardPreferences().get("serial.disableDTR") == null);
}
@@ -74,7 +69,7 @@ public class Serial implements SerialPortEventListener {
public Serial(String iname, int irate) throws SerialException {
this(iname, irate, PreferencesData.get("serial.parity").charAt(0),
PreferencesData.getInteger("serial.databits"),
- new Float(PreferencesData.get("serial.stopbits")).floatValue(),
+ Float.parseFloat(PreferencesData.get("serial.stopbits"))),
BaseNoGui.getBoardPreferences().get("serial.disableRTS") == null,
BaseNoGui.getBoardPreferences().get("serial.disableDTR") == null);
}
@@ -83,7 +78,7 @@ public class Serial implements SerialPortEventListener {
this(iname, PreferencesData.getInteger("serial.debug_rate"),
PreferencesData.get("serial.parity").charAt(0),
PreferencesData.getInteger("serial.databits"),
- new Float(PreferencesData.get("serial.stopbits")).floatValue(),
+ Float.parseFloat(PreferencesData.get("serial.stopbits"))),
BaseNoGui.getBoardPreferences().get("serial.disableRTS") == null,
BaseNoGui.getBoardPreferences().get("serial.disableDTR") == null);
}
@@ -109,29 +104,28 @@ public class Serial implements SerialPortEventListener {
}
}
- public Serial(String iname, int irate, char iparity, int idatabits, float istopbits, boolean setRTS, boolean setDTR) throws SerialException {
+ private Serial(String iname, int irate, char iparity, int idatabits, float istopbits, boolean setRTS, boolean setDTR) throws SerialException {
//if (port != null) port.close();
//this.parent = parent;
//parent.attach(this);
- this.rate = irate;
-
- parity = SerialPort.PARITY_NONE;
+ int parity = SerialPort.PARITY_NONE;
if (iparity == 'E') parity = SerialPort.PARITY_EVEN;
if (iparity == 'O') parity = SerialPort.PARITY_ODD;
- this.databits = idatabits;
-
- stopbits = SerialPort.STOPBITS_1;
+ int stopbits = SerialPort.STOPBITS_1;
if (istopbits == 1.5f) stopbits = SerialPort.STOPBITS_1_5;
if (istopbits == 2) stopbits = SerialPort.STOPBITS_2;
try {
port = new SerialPort(iname);
port.openPort();
- port.setParams(rate, databits, stopbits, parity, setRTS, setDTR);
+ port.setParams(irate, idatabits, stopbits, parity, setRTS, setDTR);
port.addEventListener(this);
- } catch (Exception e) {
+ } catch (SerialPortException e) {
+ if (e.getPortName().startsWith("/dev") && SerialPortException.TYPE_PERMISSION_DENIED.equals(e.getExceptionType())) {
+ throw new SerialException(I18n.format(_("Error opening serial port ''{0}''. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission"), iname));
+ }
throw new SerialException(I18n.format(_("Error opening serial port ''{0}''."), iname), e);
}
@@ -176,9 +170,6 @@ public class Serial implements SerialPortEventListener {
/**
* This method is intented to be extended to receive messages
* coming from serial port.
- *
- * @param chars
- * @param length
*/
protected void message(char[] chars, int length) {
// Empty
@@ -197,7 +188,7 @@ public class Serial implements SerialPortEventListener {
}
- public void write(byte bytes[]) {
+ private void write(byte bytes[]) {
try {
port.writeBytes(bytes);
} catch (SerialPortException e) {
@@ -213,7 +204,7 @@ public class Serial implements SerialPortEventListener {
* (most often the case for networking and serial i/o) and
* will only use the bottom 8 bits of each char in the string.
* (Meaning that internally it uses String.getBytes)
- *
+ *
* If you want to move Unicode data, you can first convert the
* String to a byte stream in the representation of your choice
* (i.e. UTF8 or two-byte Unicode data), and send it as a byte array.
@@ -247,92 +238,8 @@ public class Serial implements SerialPortEventListener {
* General error reporting, all corraled here just in case
* I think of something slightly more intelligent to do.
*/
- static public void errorMessage(String where, Throwable e) {
+ private static void errorMessage(String where, Throwable e) {
System.err.println(I18n.format(_("Error inside Serial.{0}()"), where));
e.printStackTrace();
}
}
-
-
- /*
- class SerialMenuListener implements ItemListener {
- //public SerialMenuListener() { }
-
- public void itemStateChanged(ItemEvent e) {
- int count = serialMenu.getItemCount();
- for (int i = 0; i < count; i++) {
- ((CheckboxMenuItem)serialMenu.getItem(i)).setState(false);
- }
- CheckboxMenuItem item = (CheckboxMenuItem)e.getSource();
- item.setState(true);
- String name = item.getLabel();
- //System.out.println(item.getLabel());
- PdeBase.properties.put("serial.port", name);
- //System.out.println("set to " + get("serial.port"));
- }
- }
- */
-
-
- /*
- protected Vector buildPortList() {
- // get list of names for serial ports
- // have the default port checked (if present)
- Vector list = new Vector();
-
- //SerialMenuListener listener = new SerialMenuListener();
- boolean problem = false;
-
- // if this is failing, it may be because
- // lib/javax.comm.properties is missing.
- // java is weird about how it searches for java.comm.properties
- // so it tends to be very fragile. i.e. quotes in the CLASSPATH
- // environment variable will hose things.
- try {
- //System.out.println("building port list");
- Enumeration portList = CommPortIdentifier.getPortIdentifiers();
- while (portList.hasMoreElements()) {
- CommPortIdentifier portId =
- (CommPortIdentifier) portList.nextElement();
- //System.out.println(portId);
-
- if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
- //if (portId.getName().equals(port)) {
- String name = portId.getName();
- //CheckboxMenuItem mi =
- //new CheckboxMenuItem(name, name.equals(defaultName));
-
- //mi.addItemListener(listener);
- //serialMenu.add(mi);
- list.addElement(name);
- }
- }
- } catch (UnsatisfiedLinkError e) {
- e.printStackTrace();
- problem = true;
-
- } catch (Exception e) {
- System.out.println("exception building serial menu");
- e.printStackTrace();
- }
-
- //if (serialMenu.getItemCount() == 0) {
- //System.out.println("dimming serial menu");
- //serialMenu.setEnabled(false);
- //}
-
- // only warn them if this is the first time
- if (problem && PdeBase.firstTime) {
- JOptionPane.showMessageDialog(this, //frame,
- "Serial port support not installed.\n" +
- "Check the readme for instructions\n" +
- "if you need to use the serial port. ",
- "Serial Port Warning",
- JOptionPane.WARNING_MESSAGE);
- }
- return list;
- }
- */
-
-
-
diff --git a/arduino-core/src/processing/app/SketchCode.java b/arduino-core/src/processing/app/SketchCode.java
index a8f2c16f1..b50b9d57f 100644
--- a/arduino-core/src/processing/app/SketchCode.java
+++ b/arduino-core/src/processing/app/SketchCode.java
@@ -22,31 +22,37 @@
package processing.app;
-import java.io.*;
-import java.util.List;
-import java.util.Arrays;
-
-import static processing.app.I18n._;
import processing.app.helpers.FileUtils;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import static processing.app.I18n._;
+
/**
- * Represents a single tab of a sketch.
+ * Represents a single tab of a sketch.
*/
public class SketchCode {
-
- /** Pretty name (no extension), not the full file name */
- private String prettyName;
- /** File object for where this code is located */
+ /**
+ * File object for where this code is located
+ */
private File file;
- /** Text of the program text for this tab */
+ /**
+ * Text of the program text for this tab
+ */
private String program;
private boolean modified;
- /** where this code starts relative to the concat'd code */
- private int preprocOffset;
+ /**
+ * where this code starts relative to the concat'd code
+ */
+ private int preprocOffset;
private Object metadata;
@@ -62,8 +68,6 @@ public class SketchCode {
this.file = file;
this.metadata = metadata;
- makePrettyName();
-
try {
load();
} catch (IOException e) {
@@ -73,28 +77,21 @@ public class SketchCode {
}
- protected void makePrettyName() {
- prettyName = file.getName();
- int dot = prettyName.lastIndexOf('.');
- prettyName = prettyName.substring(0, dot);
- }
-
-
public File getFile() {
return file;
}
-
-
+
+
protected boolean fileExists() {
return file.exists();
}
-
-
+
+
protected boolean fileReadOnly() {
return !file.canWrite();
}
-
-
+
+
protected boolean deleteFile(File tempBuildFolder) {
if (!file.delete()) {
return false;
@@ -106,38 +103,42 @@ public class SketchCode {
}
});
for (File compiledFile : compiledFiles) {
- compiledFile.delete();
+ if (!compiledFile.delete()) {
+ return false;
+ }
}
return true;
}
-
-
+
+
protected boolean renameTo(File what) {
boolean success = file.renameTo(what);
if (success) {
file = what;
- makePrettyName();
}
return success;
}
-
-
- protected void copyTo(File dest) throws IOException {
- BaseNoGui.saveFile(program, dest);
- }
-
+
public String getFileName() {
return file.getName();
}
-
-
+
+
public String getPrettyName() {
- return prettyName;
+ String prettyName = getFileName();
+ int dot = prettyName.lastIndexOf('.');
+ return prettyName.substring(0, dot);
}
-
-
+
+ public String getFileNameWithExtensionIfNotIno() {
+ if (getFileName().endsWith(".ino")) {
+ return getPrettyName();
+ }
+ return getFileName();
+ }
+
public boolean isExtension(String... extensions) {
return isExtension(Arrays.asList(extensions));
}
@@ -145,23 +146,23 @@ public class SketchCode {
public boolean isExtension(List extensions) {
return FileUtils.hasExtension(file, extensions);
}
-
-
+
+
public String getProgram() {
return program;
}
-
-
+
+
public void setProgram(String replacement) {
program = replacement;
}
-
-
+
+
public int getLineCount() {
return BaseNoGui.countLines(program);
}
-
-
+
+
public void setModified(boolean modified) {
this.modified = modified;
}
@@ -177,25 +178,21 @@ public class SketchCode {
}
- public int getPreprocOffset() {
- return preprocOffset;
- }
-
-
public void addPreprocOffset(int extra) {
preprocOffset += extra;
}
- // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
-
/**
* Load this piece of code from a file.
*/
- public void load() throws IOException {
+ private void load() throws IOException {
program = BaseNoGui.loadFile(file);
+ if (program == null) {
+ throw new IOException();
+ }
+
if (program.indexOf('\uFFFD') != -1) {
System.err.println(
I18n.format(
@@ -209,7 +206,7 @@ public class SketchCode {
);
System.err.println();
}
-
+
setModified(false);
}
diff --git a/arduino-core/src/processing/app/SketchData.java b/arduino-core/src/processing/app/SketchData.java
index 36f5a8fce..cef17433e 100644
--- a/arduino-core/src/processing/app/SketchData.java
+++ b/arduino-core/src/processing/app/SketchData.java
@@ -1,17 +1,19 @@
package processing.app;
+import com.google.common.collect.FluentIterable;
+
import static processing.app.I18n._;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+import java.util.*;
public class SketchData {
+ public static final List SKETCH_EXTENSIONS = Arrays.asList("ino", "pde");
+ public static final List OTHER_ALLOWED_EXTENSIONS = Arrays.asList("c", "cpp", "h", "s");
+ public static final List EXTENSIONS = new LinkedList(FluentIterable.from(SKETCH_EXTENSIONS).append(OTHER_ALLOWED_EXTENSIONS).toList());
+
/** main pde file for this sketch. */
private File primaryFile;
@@ -95,6 +97,9 @@ public class SketchData {
// get list of files in the sketch folder
String list[] = folder.list();
+ if (list == null) {
+ throw new IOException("Unable to list files from " + folder);
+ }
// reset these because load() may be called after an
// external editor event. (fix for 0099)
@@ -102,8 +107,6 @@ public class SketchData {
clearCodeDocs();
// data.setCodeDocs(codeDocs);
- List extensions = getExtensions();
-
for (String filename : list) {
// Ignoring the dot prefix files is especially important to avoid files
// with the ._ prefix on Mac OS X. (You'll see this with Mac files on
@@ -116,7 +119,7 @@ public class SketchData {
// figure out the name without any extension
String base = filename;
// now strip off the .pde and .java extensions
- for (String extension : extensions) {
+ for (String extension : EXTENSIONS) {
if (base.toLowerCase().endsWith("." + extension)) {
base = base.substring(0, base.length() - (extension.length() + 1));
@@ -170,13 +173,6 @@ public class SketchData {
return "ino";
}
- /**
- * Returns a String[] array of proper extensions.
- */
- public List getExtensions() {
- return Arrays.asList("ino", "pde", "c", "cpp", "h");
- }
-
/**
* Returns a file object for the primary .pde of this sketch.
*/
diff --git a/arduino-core/src/processing/app/debug/Compiler.java b/arduino-core/src/processing/app/debug/Compiler.java
index b37876ddd..14ab00210 100644
--- a/arduino-core/src/processing/app/debug/Compiler.java
+++ b/arduino-core/src/processing/app/debug/Compiler.java
@@ -34,14 +34,16 @@ import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import cc.arduino.MyStreamPumper;
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.Uploader;
import cc.arduino.packages.UploaderFactory;
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.ExecuteStreamHandler;
+import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.exec.*;
import processing.app.BaseNoGui;
import processing.app.I18n;
import processing.app.PreferencesData;
@@ -100,12 +102,14 @@ public class Compiler implements MessageConsumer {
compiler.cleanup(prefsChanged, tempBuildFolder);
if (prefsChanged) {
+ PrintWriter out = null;
try {
- PrintWriter out = new PrintWriter(buildPrefsFile);
+ out = new PrintWriter(buildPrefsFile);
out.print(newBuildPrefs);
- out.close();
} catch (IOException e) {
System.err.println(_("Could not write build preferences file"));
+ } finally {
+ IOUtils.closeQuietly(out);
}
}
@@ -131,15 +135,12 @@ public class Compiler implements MessageConsumer {
TargetPlatform target = BaseNoGui.getTargetPlatform();
String board = PreferencesData.get("board");
- if (noUploadPort)
- {
- return new UploaderFactory().newUploader(target.getBoards().get(board), null, noUploadPort);
- }
- else
- {
- BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
- return new UploaderFactory().newUploader(target.getBoards().get(board), boardPort, noUploadPort);
+ BoardPort boardPort = null;
+ if (!noUploadPort) {
+ boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
}
+
+ return new UploaderFactory().newUploader(target.getBoards().get(board), boardPort, noUploadPort);
}
static public boolean upload(SketchData data, Uploader uploader, String buildPath, String suggestedClassName, boolean usingProgrammer, boolean noUploadPort, List warningsAccumulator) throws Exception {
@@ -151,7 +152,7 @@ public class Compiler implements MessageConsumer {
if (uploader.requiresAuthorization() && !PreferencesData.has(uploader.getAuthorizationKey())) {
BaseNoGui.showError(_("Authorization required"),
- _("No athorization data found"), null);
+ _("No authorization data found"), null);
}
boolean useNewWarningsAccumulator = false;
@@ -277,11 +278,13 @@ public class Compiler implements MessageConsumer {
// used. Keep everything else, which might be reusable
if (tempBuildFolder.exists()) {
String files[] = tempBuildFolder.list();
- for (String file : files) {
- if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
- File deleteMe = new File(tempBuildFolder, file);
- if (!deleteMe.delete()) {
- System.err.println("Could not delete " + deleteMe);
+ if (files != null) {
+ for (String file : files) {
+ if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
+ File deleteMe = new File(tempBuildFolder, file);
+ if (!deleteMe.delete()) {
+ System.err.println("Could not delete " + deleteMe);
+ }
}
}
}
@@ -399,26 +402,44 @@ public class Compiler implements MessageConsumer {
System.err.println();
}
}
-
+
+ runActions("hooks.sketch.prebuild", prefs);
+
// 1. compile the sketch (already in the buildPath)
progressListener.progress(20);
compileSketch(includeFolders);
sketchIsCompiled = true;
+ runActions("hooks.sketch.postbuild", prefs);
+
+ runActions("hooks.libraries.prebuild", prefs);
+
// 2. compile the libraries, outputting .o files to: //
// Doesn't really use configPreferences
progressListener.progress(30);
compileLibraries(includeFolders);
+ runActions("hooks.libraries.postbuild", prefs);
+
+ runActions("hooks.core.prebuild", prefs);
+
// 3. compile the core, outputting .o files to and then
// collecting them into the core.a library file.
progressListener.progress(40);
compileCore();
+ runActions("hooks.core.postbuild", prefs);
+
+ runActions("hooks.linking.prelink", prefs);
+
// 4. link it all together into the .elf file
progressListener.progress(50);
compileLink();
+ runActions("hooks.linking.postlink", prefs);
+
+ runActions("hooks.objcopy.preobjcopy", prefs);
+
// 5. run objcopy to generate output files
progressListener.progress(60);
List objcopyPatterns = new ArrayList();
@@ -431,10 +452,16 @@ public class Compiler implements MessageConsumer {
runRecipe(recipe);
}
+ runActions("hooks.objcopy.postobjcopy", prefs);
+
// 7. save the hex file
if (saveHex) {
+ runActions("hooks.savehex.presavehex", prefs);
+
progressListener.progress(80);
saveHex();
+
+ runActions("hooks.savehex.postsavehex", prefs);
}
progressListener.progress(90);
@@ -557,6 +584,17 @@ public class Compiler implements MessageConsumer {
p.put("build.variant.path", "");
}
+ // Build Time
+ Date d = new Date();
+ GregorianCalendar cal = new GregorianCalendar();
+ long current = d.getTime()/1000;
+ long timezone = cal.get(cal.ZONE_OFFSET)/1000;
+ long daylight = cal.get(cal.DST_OFFSET)/1000;
+ p.put("extra.time.utc", Long.toString(current));
+ p.put("extra.time.local", Long.toString(current + timezone + daylight));
+ p.put("extra.time.zone", Long.toString(timezone));
+ p.put("extra.time.dst", Long.toString(daylight));
+
return p;
}
@@ -617,6 +655,7 @@ public class Compiler implements MessageConsumer {
private boolean isAlreadyCompiled(File src, File obj, File dep, Map prefs) {
boolean ret=true;
+ BufferedReader reader = null;
try {
//System.out.println("\n isAlreadyCompiled: begin checks: " + obj.getPath());
if (!obj.exists()) return false; // object file (.o) does not exist
@@ -625,7 +664,7 @@ public class Compiler implements MessageConsumer {
long obj_modified = obj.lastModified();
if (src_modified >= obj_modified) return false; // source modified since object compiled
if (src_modified >= dep.lastModified()) return false; // src modified since dep compiled
- BufferedReader reader = new BufferedReader(new FileReader(dep.getPath()));
+ reader = new BufferedReader(new FileReader(dep.getPath()));
String line;
boolean need_obj_parse = true;
while ((line = reader.readLine()) != null) {
@@ -669,9 +708,10 @@ public class Compiler implements MessageConsumer {
//System.out.println(" isAlreadyCompiled: prerequisite ok");
}
}
- reader.close();
} catch (Exception e) {
return false; // any error reading dep file = recompile it
+ } finally {
+ IOUtils.closeQuietly(reader);
}
if (ret && verbose) {
System.out.println(I18n.format(_("Using previously compiled file: {0}"), obj.getPath()));
@@ -703,37 +743,13 @@ public class Compiler implements MessageConsumer {
}
DefaultExecutor executor = new DefaultExecutor();
- executor.setStreamHandler(new ExecuteStreamHandler() {
- @Override
- public void setProcessInputStream(OutputStream os) throws IOException {
-
- }
+ executor.setStreamHandler(new PumpStreamHandler() {
@Override
- public void setProcessErrorStream(InputStream is) throws IOException {
- forwardToMessage(is);
- }
-
- @Override
- public void setProcessOutputStream(InputStream is) throws IOException {
- forwardToMessage(is);
- }
-
- private void forwardToMessage(InputStream is) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- String line;
- while ((line = reader.readLine()) != null) {
- message(line + "\n");
- }
- }
-
- @Override
- public void start() throws IOException {
-
- }
-
- @Override
- public void stop() {
+ protected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted) {
+ final Thread result = new Thread(new MyStreamPumper(is, Compiler.this));
+ result.setDaemon(true);
+ return result;
}
});
@@ -1149,6 +1165,7 @@ public class Compiler implements MessageConsumer {
void runRecipe(String recipe) throws RunnerException, PreferencesMapException {
PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + BaseNoGui.REVISION);
+ dict.put("sketch_path", sketch.getFolder().getAbsolutePath());
String[] cmdArray;
String cmd = prefs.getOrExcept(recipe);
@@ -1226,7 +1243,7 @@ public class Compiler implements MessageConsumer {
StringBuffer bigCode = new StringBuffer();
int bigCount = 0;
for (SketchCode sc : sketch.getCodes()) {
- if (sc.isExtension("ino") || sc.isExtension("pde")) {
+ if (sc.isExtension(SketchData.SKETCH_EXTENSIONS)) {
sc.setPreprocOffset(bigCount);
// These #line directives help the compiler report errors with
// correct the filename and line number (issue 281 & 907)
@@ -1272,13 +1289,7 @@ public class Compiler implements MessageConsumer {
ex.printStackTrace();
throw new RunnerException(ex.toString());
} finally {
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (IOException e) {
- //noop
- }
- }
+ IOUtils.closeQuietly(outputStream);
}
// grab the imports from the code just preproc'd
@@ -1303,7 +1314,7 @@ public class Compiler implements MessageConsumer {
// 3. then loop over the code[] and save each .java file
for (SketchCode sc : sketch.getCodes()) {
- if (sc.isExtension("c") || sc.isExtension("cpp") || sc.isExtension("h")) {
+ if (sc.isExtension(SketchData.OTHER_ALLOWED_EXTENSIONS)) {
// no pre-processing services necessary for java files
// just write the the contents of 'program' to a .java file
// into the build directory. uses byte stream and reader/writer
diff --git a/arduino-core/src/processing/app/debug/LegacyTargetBoard.java b/arduino-core/src/processing/app/debug/LegacyTargetBoard.java
index ff06ab29d..5684d8640 100644
--- a/arduino-core/src/processing/app/debug/LegacyTargetBoard.java
+++ b/arduino-core/src/processing/app/debug/LegacyTargetBoard.java
@@ -58,7 +58,7 @@ public class LegacyTargetBoard implements TargetBoard {
String board = containerPlatform.getId() + "_" + id;
board = board.toUpperCase();
prefs.put("build.board", board);
- System.out
+ System.err
.println(format(_("Board {0}:{1}:{2} doesn''t define a ''build.board'' preference. Auto-set to: {3}"),
containerPlatform.getContainerPackage().getId(),
containerPlatform.getId(), id, board));
diff --git a/arduino-core/src/processing/app/debug/LegacyTargetPackage.java b/arduino-core/src/processing/app/debug/LegacyTargetPackage.java
index 42d6b0730..c7b315a34 100644
--- a/arduino-core/src/processing/app/debug/LegacyTargetPackage.java
+++ b/arduino-core/src/processing/app/debug/LegacyTargetPackage.java
@@ -51,7 +51,7 @@ public class LegacyTargetPackage implements TargetPackage {
TargetPlatform platform = new LegacyTargetPlatform(arch, subFolder, this);
platforms.put(arch, platform);
} catch (TargetPlatformException e) {
- System.out.println(e.getMessage());
+ System.err.println(e.getMessage());
}
}
diff --git a/arduino-core/src/processing/app/helpers/CommandlineParser.java b/arduino-core/src/processing/app/helpers/CommandlineParser.java
index 2e66e6361..069c037e0 100644
--- a/arduino-core/src/processing/app/helpers/CommandlineParser.java
+++ b/arduino-core/src/processing/app/helpers/CommandlineParser.java
@@ -9,10 +9,7 @@ import processing.app.debug.TargetPlatform;
import processing.app.legacy.PApplet;
import java.io.File;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static processing.app.I18n._;
@@ -32,6 +29,8 @@ public class CommandlineParser {
}
}
+ private final String[] args;
+ private final Map actions;
private ACTION action = ACTION.GUI;
private boolean doVerboseBuild = false;
private boolean doVerboseUpload = false;
@@ -44,39 +43,32 @@ public class CommandlineParser {
private String libraryToInstall;
private List filenames = new LinkedList();
- public static CommandlineParser newCommandlineParser(String[] args) {
- return new CommandlineParser(args);
- }
+ public CommandlineParser(String[] args) {
+ this.args = args;
- private CommandlineParser(String[] args) {
- parseArguments(args);
- checkAction();
- }
-
- private void parseArguments(String[] args) {
- // Map of possible actions and corresponding options
- final Map actions = new HashMap();
+ actions = new HashMap();
actions.put("--verify", ACTION.VERIFY);
actions.put("--upload", ACTION.UPLOAD);
actions.put("--get-pref", ACTION.GET_PREF);
actions.put("--install-boards", ACTION.INSTALL_BOARD);
actions.put("--install-library", ACTION.INSTALL_LIBRARY);
+ }
- // Check if any files were passed in on the command line
+ public void parseArgumentsPhase1() {
for (int i = 0; i < args.length; i++) {
ACTION a = actions.get(args[i]);
if (a != null) {
if (action != ACTION.GUI && action != ACTION.NOOP) {
- String[] valid = actions.keySet().toArray(new String[0]);
+ Set strings = actions.keySet();
+ String[] valid = strings.toArray(new String[strings.size()]);
String mess = I18n.format(_("Can only pass one of: {0}"), PApplet.join(valid, ", "));
BaseNoGui.showError(null, mess, 3);
}
if (a == ACTION.GET_PREF) {
i++;
- if (i >= args.length) {
- BaseNoGui.showError(null, I18n.format(_("Argument required for {0}"), a.value), 3);
+ if (i < args.length) {
+ getPref = args[i];
}
- getPref = args[i];
}
if (a == ACTION.INSTALL_BOARD) {
i++;
@@ -140,7 +132,6 @@ public class CommandlineParser {
i++;
if (i >= args.length)
BaseNoGui.showError(null, _("Argument required for --board"), 3);
- processBoardArgument(args[i]);
if (action == ACTION.GUI)
action = ACTION.NOOP;
continue;
@@ -201,6 +192,23 @@ public class CommandlineParser {
filenames.add(args[i]);
}
+
+ checkAction();
+ }
+
+ public void parseArgumentsPhase2() {
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("--board")) {
+ i++;
+ if (i >= args.length) {
+ BaseNoGui.showError(null, _("Argument required for --board"), 3);
+ }
+ processBoardArgument(args[i]);
+ if (action == ACTION.GUI) {
+ action = ACTION.NOOP;
+ }
+ }
+ }
}
private void checkAction() {
diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java
index 186141cf5..9d138b841 100644
--- a/arduino-core/src/processing/app/helpers/FileUtils.java
+++ b/arduino-core/src/processing/app/helpers/FileUtils.java
@@ -1,5 +1,7 @@
package processing.app.helpers;
+import org.apache.commons.compress.utils.IOUtils;
+
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -49,12 +51,8 @@ public class FileUtils {
fos.write(buf, 0, readBytes);
}
} finally {
- if (fis != null) {
- fis.close();
- }
- if (fos != null) {
- fos.close();
- }
+ IOUtils.closeQuietly(fis);
+ IOUtils.closeQuietly(fos);
}
}
@@ -171,7 +169,15 @@ public class FileUtils {
}
public static boolean isSCCSOrHiddenFile(File file) {
- return file.isHidden() || file.getName().charAt(0) == '.' || (file.isDirectory() && SOURCE_CONTROL_FOLDERS.contains(file.getName()));
+ return isSCCSFolder(file) || isHiddenFile(file);
+ }
+
+ public static boolean isHiddenFile(File file) {
+ return file.isHidden() || file.getName().charAt(0) == '.';
+ }
+
+ public static boolean isSCCSFolder(File file) {
+ return file.isDirectory() && SOURCE_CONTROL_FOLDERS.contains(file.getName());
}
public static String readFileToString(File file) throws IOException {
@@ -185,13 +191,7 @@ public class FileUtils {
}
return sb.toString();
} finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- // noop
- }
- }
+ IOUtils.closeQuietly(reader);
}
}
diff --git a/arduino-core/src/processing/app/helpers/PreferencesMap.java b/arduino-core/src/processing/app/helpers/PreferencesMap.java
index 185e1bee4..2e3bf83b3 100644
--- a/arduino-core/src/processing/app/helpers/PreferencesMap.java
+++ b/arduino-core/src/processing/app/helpers/PreferencesMap.java
@@ -21,6 +21,7 @@
*/
package processing.app.helpers;
+import org.apache.commons.compress.utils.IOUtils;
import processing.app.legacy.PApplet;
import java.io.*;
@@ -72,9 +73,7 @@ public class PreferencesMap extends LinkedHashMap {
fileInputStream = new FileInputStream(file);
load(fileInputStream);
} finally {
- if (fileInputStream != null) {
- fileInputStream.close();
- }
+ IOUtils.closeQuietly(fileInputStream);
}
}
diff --git a/arduino-core/src/processing/app/legacy/PApplet.java b/arduino-core/src/processing/app/legacy/PApplet.java
index e89955263..2a9abc56e 100644
--- a/arduino-core/src/processing/app/legacy/PApplet.java
+++ b/arduino-core/src/processing/app/legacy/PApplet.java
@@ -1,5 +1,7 @@
package processing.app.legacy;
+import org.apache.commons.compress.utils.IOUtils;
+
import java.io.*;
import java.text.NumberFormat;
import java.util.ArrayList;
@@ -272,13 +274,7 @@ public class PApplet {
if (is != null) return loadStrings(is);
return null;
} finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- // noop
- }
- }
+ IOUtils.closeQuietly(is);
}
}
@@ -312,14 +308,7 @@ public class PApplet {
e.printStackTrace();
//throw new RuntimeException("Error inside loadStrings()");
} finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- //ignore
- }
- }
-
+ IOUtils.closeQuietly(reader);
}
return null;
}
@@ -335,27 +324,25 @@ public class PApplet {
outputStream = createOutput(file);
saveStrings(outputStream, strings);
} finally {
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (IOException e) {
- //noop
- }
- }
+ IOUtils.closeQuietly(outputStream);
}
}
static public void saveStrings(OutputStream output, String strings[]) {
- PrintWriter writer = createWriter(output);
- if (writer == null) {
- return;
+ PrintWriter writer = null;
+ try {
+ writer = createWriter(output);
+ if (writer == null) {
+ return;
+ }
+ for (String string : strings) {
+ writer.println(string);
+ }
+ writer.flush();
+ } finally {
+ IOUtils.closeQuietly(writer);
}
- for (String string : strings) {
- writer.println(string);
- }
- writer.flush();
- writer.close();
}
diff --git a/arduino-core/src/processing/app/linux/Platform.java b/arduino-core/src/processing/app/linux/Platform.java
index ed91ea0a7..7a8024f46 100644
--- a/arduino-core/src/processing/app/linux/Platform.java
+++ b/arduino-core/src/processing/app/linux/Platform.java
@@ -23,11 +23,12 @@
package processing.app.linux;
import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
import processing.app.PreferencesData;
import processing.app.debug.TargetPackage;
import processing.app.legacy.PConstants;
-import processing.app.tools.CollectStdOutExecutor;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -124,7 +125,8 @@ public class Platform extends processing.app.Platform {
public Map resolveDeviceAttachedTo(String serial, Map packages, String devicesListOutput) {
assert packages != null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Executor executor = new CollectStdOutExecutor(baos);
+ Executor executor = new DefaultExecutor();
+ executor.setStreamHandler(new PumpStreamHandler(baos, null));
try {
CommandLine toDevicePath = CommandLine.parse("udevadm info -q path -n " + serial);
diff --git a/arduino-core/src/processing/app/macosx/Platform.java b/arduino-core/src/processing/app/macosx/Platform.java
index 7dc206635..a7a6a75bb 100644
--- a/arduino-core/src/processing/app/macosx/Platform.java
+++ b/arduino-core/src/processing/app/macosx/Platform.java
@@ -25,19 +25,23 @@ package processing.app.macosx;
import cc.arduino.packages.BoardPort;
import com.apple.eio.FileManager;
import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.lang3.StringUtils;
import processing.app.debug.TargetPackage;
import processing.app.legacy.PApplet;
import processing.app.legacy.PConstants;
-import processing.app.tools.CollectStdOutExecutor;
import java.awt.*;
-import java.io.*;
-import java.lang.reflect.Method;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.net.URI;
-import java.util.*;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
/**
@@ -57,6 +61,8 @@ public class Platform extends processing.app.Platform {
}
public void init() throws IOException {
+ super.init();
+
System.setProperty("apple.laf.useScreenMenuBar", "true");
discoverRealOsArch();
@@ -65,7 +71,8 @@ public class Platform extends processing.app.Platform {
private void discoverRealOsArch() throws IOException {
CommandLine uname = CommandLine.parse("uname -m");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- CollectStdOutExecutor executor = new CollectStdOutExecutor(baos);
+ Executor executor = new DefaultExecutor();
+ executor.setStreamHandler(new PumpStreamHandler(baos, null));
executor.execute(uname);
osArch = StringUtils.trim(new String(baos.toByteArray()));
}
@@ -94,45 +101,13 @@ public class Platform extends processing.app.Platform {
public void openURL(String url) throws Exception {
- if (PApplet.javaVersion < 1.6f) {
- if (url.startsWith("http")) {
- // formerly com.apple.eio.FileManager.openURL(url);
- // but due to deprecation, instead loading dynamically
- try {
- Class> eieio = Class.forName("com.apple.eio.FileManager");
- Method openMethod =
- eieio.getMethod("openURL", new Class[] { String.class });
- openMethod.invoke(null, new Object[] { url });
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- // Assume this is a file instead, and just open it.
- // Extension of http://dev.processing.org/bugs/show_bug.cgi?id=1010
- PApplet.open(url);
- }
+ Desktop desktop = Desktop.getDesktop();
+ if (url.startsWith("http") || url.startsWith("file:")) {
+ desktop.browse(new URI(url));
} else {
- try {
- Class> desktopClass = Class.forName("java.awt.Desktop");
- Method getMethod = desktopClass.getMethod("getDesktop");
- Object desktop = getMethod.invoke(null, new Object[] { });
-
- // for Java 1.6, replacing with java.awt.Desktop.browse()
- // and java.awt.Desktop.open()
- if (url.startsWith("http")) { // browse to a location
- Method browseMethod =
- desktopClass.getMethod("browse", new Class[] { URI.class });
- browseMethod.invoke(desktop, new Object[] { new URI(url) });
- } else { // open a file
- Method openMethod =
- desktopClass.getMethod("open", new Class[] { File.class });
- openMethod.invoke(desktop, new Object[] { new File(url) });
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ desktop.open(new File(url));
}
+ }
public boolean openFolderAvailable() {
@@ -152,13 +127,13 @@ public class Platform extends processing.app.Platform {
// Some of these are supposedly constants in com.apple.eio.FileManager,
// however they don't seem to link properly from Eclipse.
- static final int kDocumentsFolderType =
+ private static final int kDocumentsFolderType =
('d' << 24) | ('o' << 16) | ('c' << 8) | 's';
//static final int kPreferencesFolderType =
// ('p' << 24) | ('r' << 16) | ('e' << 8) | 'f';
- static final int kDomainLibraryFolderType =
+ private static final int kDomainLibraryFolderType =
('d' << 24) | ('l' << 16) | ('i' << 8) | 'b';
- static final short kUserDomain = -32763;
+ private static final short kUserDomain = -32763;
// apple java extensions documentation
@@ -175,12 +150,12 @@ public class Platform extends processing.app.Platform {
// /Versions/Current/Frameworks/CarbonCore.framework/Headers/
- protected String getLibraryFolder() throws FileNotFoundException {
+ private String getLibraryFolder() throws FileNotFoundException {
return FileManager.findFolder(kUserDomain, kDomainLibraryFolderType);
}
- protected String getDocumentsFolder() throws FileNotFoundException {
+ private String getDocumentsFolder() throws FileNotFoundException {
return FileManager.findFolder(kUserDomain, kDocumentsFolderType);
}
@@ -193,7 +168,7 @@ public class Platform extends processing.app.Platform {
public Map resolveDeviceAttachedTo(String serial, Map packages, String devicesListOutput) {
assert packages != null;
if (devicesListOutput == null) {
- return super.resolveDeviceAttachedTo(serial, packages, devicesListOutput);
+ return super.resolveDeviceAttachedTo(serial, packages, null);
}
try {
@@ -212,7 +187,8 @@ public class Platform extends processing.app.Platform {
@Override
public String preListAllCandidateDevices() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Executor executor = new CollectStdOutExecutor(baos);
+ Executor executor = new DefaultExecutor();
+ executor.setStreamHandler(new PumpStreamHandler(baos, null));
try {
CommandLine toDevicePath = CommandLine.parse("/usr/sbin/system_profiler SPUSBDataType");
diff --git a/arduino-core/src/processing/app/macosx/SystemProfilerParser.java b/arduino-core/src/processing/app/macosx/SystemProfilerParser.java
index bef99387c..2e1d77462 100644
--- a/arduino-core/src/processing/app/macosx/SystemProfilerParser.java
+++ b/arduino-core/src/processing/app/macosx/SystemProfilerParser.java
@@ -55,7 +55,7 @@ public class SystemProfilerParser {
if ((matcher = serialNumberRegex.matcher(line)).matches()) {
device.put(SERIAL_NUMBER, matcher.group(1));
- if ((serial.startsWith(DEV_TTY_USBSERIAL) || serial.startsWith(DEV_CU_USBSERIAL))) {
+ if (serial.startsWith(DEV_TTY_USBSERIAL) || serial.startsWith(DEV_CU_USBSERIAL)) {
String devicePath = devicePrefix + matcher.group(1);
device.put(DEVICE_PATH, devicePath);
}
@@ -65,17 +65,24 @@ public class SystemProfilerParser {
device.put(DEVICE_PATH, devicePath);
} else if ((matcher = pidRegex.matcher(line)).matches()) {
String pid = matcher.group(1);
- if (pid.indexOf(" ") > 0)
+ if (pid.indexOf(" ") > 0) {
pid = pid.substring(0, pid.indexOf(" ")); // Remove any text after the hex number
+ }
device.put(PID, pid);
} else if ((matcher = vidRegex.matcher(line)).matches()) {
String vid = matcher.group(1);
- if (vid.indexOf(" ") > 0)
+ if (vid.indexOf(" ") > 0) {
vid = vid.substring(0, vid.indexOf(" ")); // Remove any text after the hex number
+ }
device.put(VID, vid);
} else if (line.equals("")) {
- if (device.containsKey(DEVICE_PATH) && device.get(DEVICE_PATH).equals(serial)) {
- return (device.get(VID) + "_" + device.get(PID)).toUpperCase();
+ if (device.containsKey(DEVICE_PATH)) {
+ String computedDevicePath = device.get(DEVICE_PATH);
+ String computedDevicePathMinusChar = computedDevicePath.substring(0, computedDevicePath.length() - 1);
+ String serialMinusChar = serial.substring(0, serial.length() - 1);
+ if (computedDevicePath.equals(serial) || computedDevicePathMinusChar.equals(serialMinusChar)) {
+ return (device.get(VID) + "_" + device.get(PID)).toUpperCase();
+ }
}
device = new HashMap();
}
diff --git a/arduino-core/src/processing/app/packages/LegacyUserLibrary.java b/arduino-core/src/processing/app/packages/LegacyUserLibrary.java
index b98aeb621..56a86ccb9 100644
--- a/arduino-core/src/processing/app/packages/LegacyUserLibrary.java
+++ b/arduino-core/src/processing/app/packages/LegacyUserLibrary.java
@@ -32,8 +32,6 @@ import java.io.File;
import java.util.Arrays;
import java.util.List;
-import cc.arduino.contributions.libraries.ContributedLibraryReference;
-
public class LegacyUserLibrary extends UserLibrary {
private String name;
@@ -45,6 +43,8 @@ public class LegacyUserLibrary extends UserLibrary {
res.setInstalled(true);
res.layout = LibraryLayout.FLAT;
res.name = libFolder.getName();
+ res.setTypes(Arrays.asList("Contributed"));
+ res.setCategory("Uncategorized");
return res;
}
@@ -58,66 +58,6 @@ public class LegacyUserLibrary extends UserLibrary {
return Arrays.asList("*");
}
- @Override
- public String getAuthor() {
- return null;
- }
-
- @Override
- public String getParagraph() {
- return null;
- }
-
- @Override
- public String getSentence() {
- return null;
- }
-
- @Override
- public String getWebsite() {
- return null;
- }
-
- @Override
- public String getCategory() {
- return "Uncategorized";
- }
-
- @Override
- public String getLicense() {
- return null;
- }
-
- @Override
- public String getVersion() {
- return null;
- }
-
- @Override
- public String getMaintainer() {
- return null;
- }
-
- @Override
- public String getChecksum() {
- return null;
- }
-
- @Override
- public long getSize() {
- return 0;
- }
-
- @Override
- public String getUrl() {
- return null;
- }
-
- @Override
- public List getRequires() {
- return null;
- }
-
@Override
public String toString() {
return "LegacyLibrary:" + name + "\n";
diff --git a/arduino-core/src/processing/app/packages/UserLibrary.java b/arduino-core/src/processing/app/packages/UserLibrary.java
index 82d2d01ff..ef24022ab 100644
--- a/arduino-core/src/processing/app/packages/UserLibrary.java
+++ b/arduino-core/src/processing/app/packages/UserLibrary.java
@@ -56,13 +56,13 @@ public class UserLibrary extends ContributedLibrary {
private List declaredTypes;
private static final List MANDATORY_PROPERTIES = Arrays
- .asList(new String[]{"name", "version", "author", "maintainer",
- "sentence", "paragraph", "url"});
+ .asList("name", "version", "author", "maintainer",
+ "sentence", "paragraph", "url");
- private static final List CATEGORIES = Arrays.asList(new String[]{
- "Display", "Communication", "Signal Input/Output", "Sensors",
- "Device Control", "Timing", "Data Storage", "Data Processing", "Other",
- "Uncategorized"});
+ private static final List CATEGORIES = Arrays.asList(
+ "Display", "Communication", "Signal Input/Output", "Sensors",
+ "Device Control", "Timing", "Data Storage", "Data Processing", "Other",
+ "Uncategorized");
public static UserLibrary create(File libFolder) throws IOException {
// Parse metadata
@@ -83,8 +83,7 @@ public class UserLibrary extends ContributedLibrary {
// "arch" folder no longer supported
File archFolder = new File(libFolder, "arch");
if (archFolder.isDirectory())
- throw new IOException("'arch' folder is no longer supported! See "
- + "http://goo.gl/gfFJzU for more information");
+ throw new IOException("'arch' folder is no longer supported! See http://goo.gl/gfFJzU for more information");
// Check mandatory properties
for (String p : MANDATORY_PROPERTIES)
@@ -101,8 +100,7 @@ public class UserLibrary extends ContributedLibrary {
File utilFolder = new File(libFolder, "utility");
if (utilFolder.exists() && utilFolder.isDirectory()) {
- throw new IOException(
- "Library can't use both 'src' and 'utility' folders.");
+ throw new IOException("Library can't use both 'src' and 'utility' folders.");
}
} else {
// Layout with source code on library's root and "utility" folders
@@ -110,11 +108,14 @@ public class UserLibrary extends ContributedLibrary {
}
// Warn if root folder contains development leftovers
- for (File file : libFolder.listFiles()) {
- if (file.isDirectory()) {
- if (FileUtils.isSCCSOrHiddenFile(file)) {
+ File[] files = libFolder.listFiles();
+ if (files == null) {
+ throw new IOException("Unable to list files of library in " + libFolder);
+ }
+ for (File file : files) {
+ if (file.isDirectory() && FileUtils.isSCCSOrHiddenFile(file)) {
+ if (!FileUtils.isSCCSFolder(file) && FileUtils.isHiddenFile(file)) {
System.out.println("WARNING: Spurious " + file.getName() + " folder in '" + properties.get("name") + "' library");
- continue;
}
}
}
@@ -131,8 +132,7 @@ public class UserLibrary extends ContributedLibrary {
if (category == null)
category = "Uncategorized";
if (!CATEGORIES.contains(category)) {
- System.out.println("WARNING: Category '" + category + "' in library " +
- properties.get("name") + " is not valid. Setting to 'Uncategorized'");
+ System.out.println("WARNING: Category '" + category + "' in library " + properties.get("name") + " is not valid. Setting to 'Uncategorized'");
category = "Uncategorized";
}
diff --git a/arduino-core/src/processing/app/tools/CollectStdOutExecutor.java b/arduino-core/src/processing/app/tools/CollectStdOutExecutor.java
deleted file mode 100644
index b2b5f3559..000000000
--- a/arduino-core/src/processing/app/tools/CollectStdOutExecutor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package processing.app.tools;
-
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.ExecuteStreamHandler;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Handy process executor, collecting stdout into a given OutputStream
- */
-public class CollectStdOutExecutor extends DefaultExecutor {
-
- public CollectStdOutExecutor(final OutputStream stdout) {
- this.setStreamHandler(new ExecuteStreamHandler() {
- @Override
- public void setProcessInputStream(OutputStream outputStream) throws IOException {
- }
-
- @Override
- public void setProcessErrorStream(InputStream inputStream) throws IOException {
- }
-
- @Override
- public void setProcessOutputStream(InputStream inputStream) throws IOException {
- byte[] buf = new byte[4096];
- int bytes = -1;
- while ((bytes = inputStream.read(buf)) != -1) {
- stdout.write(buf, 0, bytes);
- }
- }
-
- @Override
- public void start() throws IOException {
- }
-
- @Override
- public void stop() {
- }
- });
-
- }
-}
diff --git a/arduino-core/src/processing/app/tools/CollectStdOutStdErrExecutor.java b/arduino-core/src/processing/app/tools/CollectStdOutStdErrExecutor.java
deleted file mode 100644
index 65bc3efaa..000000000
--- a/arduino-core/src/processing/app/tools/CollectStdOutStdErrExecutor.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package processing.app.tools;
-
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.ExecuteStreamHandler;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Handy process executor, collecting stdout and stderr into given OutputStreams
- */
-public class CollectStdOutStdErrExecutor extends DefaultExecutor {
-
- public CollectStdOutStdErrExecutor(final OutputStream stdout, final OutputStream stderr) {
- this.setStreamHandler(new ExecuteStreamHandler() {
- @Override
- public void setProcessInputStream(OutputStream outputStream) throws IOException {
- }
-
- @Override
- public void setProcessErrorStream(InputStream inputStream) throws IOException {
- byte[] buf = new byte[4096];
- int bytes = -1;
- while ((bytes = inputStream.read(buf)) != -1) {
- stderr.write(buf, 0, bytes);
- }
- }
-
- @Override
- public void setProcessOutputStream(InputStream inputStream) throws IOException {
- byte[] buf = new byte[4096];
- int bytes = -1;
- while ((bytes = inputStream.read(buf)) != -1) {
- stdout.write(buf, 0, bytes);
- }
- }
-
- @Override
- public void start() throws IOException {
- }
-
- @Override
- public void stop() {
- }
- });
-
- }
-}
diff --git a/arduino-core/src/processing/app/windows/Advapi32.java b/arduino-core/src/processing/app/windows/Advapi32.java
deleted file mode 100644
index 203fb74d7..000000000
--- a/arduino-core/src/processing/app/windows/Advapi32.java
+++ /dev/null
@@ -1,335 +0,0 @@
-package processing.app.windows;
-
-/*
- * Advapi32.java
- *
- * Created on 6. August 2007, 11:24
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-import com.sun.jna.*;
-import com.sun.jna.ptr.*;
-import com.sun.jna.win32.*;
-
-/**
- *
- * @author TB
- */
-public interface Advapi32 extends StdCallLibrary {
- Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS);
-
-/*
-BOOL WINAPI LookupAccountName(
- LPCTSTR lpSystemName,
- LPCTSTR lpAccountName,
- PSID Sid,
- LPDWORD cbSid,
- LPTSTR ReferencedDomainName,
- LPDWORD cchReferencedDomainName,
- PSID_NAME_USE peUse
-);*/
- public boolean LookupAccountName(String lpSystemName, String lpAccountName,
- byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName,
- IntByReference cchReferencedDomainName, PointerByReference peUse);
-
-/*
-BOOL WINAPI LookupAccountSid(
- LPCTSTR lpSystemName,
- PSID lpSid,
- LPTSTR lpName,
- LPDWORD cchName,
- LPTSTR lpReferencedDomainName,
- LPDWORD cchReferencedDomainName,
- PSID_NAME_USE peUse
-);*/
- public boolean LookupAccountSid(String lpSystemName, byte[] Sid,
- char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
- IntByReference cchReferencedDomainName, PointerByReference peUse);
-
-/*
-BOOL ConvertSidToStringSid(
- PSID Sid,
- LPTSTR* StringSid
-);*/
- public boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid);
-
-/*
-BOOL WINAPI ConvertStringSidToSid(
- LPCTSTR StringSid,
- PSID* Sid
-);*/
- public boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid);
-
-/*
-SC_HANDLE WINAPI OpenSCManager(
- LPCTSTR lpMachineName,
- LPCTSTR lpDatabaseName,
- DWORD dwDesiredAccess
-);*/
- public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess);
-
-/*
-BOOL WINAPI CloseServiceHandle(
- SC_HANDLE hSCObject
-);*/
- public boolean CloseServiceHandle(Pointer hSCObject);
-
-/*
-SC_HANDLE WINAPI OpenService(
- SC_HANDLE hSCManager,
- LPCTSTR lpServiceName,
- DWORD dwDesiredAccess
-);*/
- public Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess);
-
-/*
-BOOL WINAPI StartService(
- SC_HANDLE hService,
- DWORD dwNumServiceArgs,
- LPCTSTR* lpServiceArgVectors
-);*/
- public boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors);
-
-/*
-BOOL WINAPI ControlService(
- SC_HANDLE hService,
- DWORD dwControl,
- LPSERVICE_STATUS lpServiceStatus
-);*/
- public boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus);
-
-/*
-BOOL WINAPI StartServiceCtrlDispatcher(
- const SERVICE_TABLE_ENTRY* lpServiceTable
-);*/
- public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
-
-/*
-SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler(
- LPCTSTR lpServiceName,
- LPHANDLER_FUNCTION lpHandlerProc
-);*/
- public Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc);
-
-/*
-SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
- LPCTSTR lpServiceName,
- LPHANDLER_FUNCTION_EX lpHandlerProc,
- LPVOID lpContext
-);*/
- public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext);
-
-/*
-BOOL WINAPI SetServiceStatus(
- SERVICE_STATUS_HANDLE hServiceStatus,
- LPSERVICE_STATUS lpServiceStatus
-);*/
- public boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus);
-
-/*
-SC_HANDLE WINAPI CreateService(
- SC_HANDLE hSCManager,
- LPCTSTR lpServiceName,
- LPCTSTR lpDisplayName,
- DWORD dwDesiredAccess,
- DWORD dwServiceType,
- DWORD dwStartType,
- DWORD dwErrorControl,
- LPCTSTR lpBinaryPathName,
- LPCTSTR lpLoadOrderGroup,
- LPDWORD lpdwTagId,
- LPCTSTR lpDependencies,
- LPCTSTR lpServiceStartName,
- LPCTSTR lpPassword
-);*/
- public Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName,
- int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl,
- String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId,
- String lpDependencies, String lpServiceStartName, String lpPassword);
-
-/*
-BOOL WINAPI DeleteService(
- SC_HANDLE hService
-);*/
- public boolean DeleteService(Pointer hService);
-
-/*
-BOOL WINAPI ChangeServiceConfig2(
- SC_HANDLE hService,
- DWORD dwInfoLevel,
- LPVOID lpInfo
-);*/
- public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
-
-/*
-LONG WINAPI RegOpenKeyEx(
- HKEY hKey,
- LPCTSTR lpSubKey,
- DWORD ulOptions,
- REGSAM samDesired,
- PHKEY phkResult
-);*/
- public int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult);
-
-/*
-LONG WINAPI RegQueryValueEx(
- HKEY hKey,
- LPCTSTR lpValueName,
- LPDWORD lpReserved,
- LPDWORD lpType,
- LPBYTE lpData,
- LPDWORD lpcbData
-);*/
- public int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData);
-
-/*
-LONG WINAPI RegCloseKey(
- HKEY hKey
-);*/
- public int RegCloseKey(int hKey);
-
-/*
-LONG WINAPI RegDeleteValue(
- HKEY hKey,
- LPCTSTR lpValueName
-);*/
- public int RegDeleteValue(int hKey, String lpValueName);
-
-/*
-LONG WINAPI RegSetValueEx(
- HKEY hKey,
- LPCTSTR lpValueName,
- DWORD Reserved,
- DWORD dwType,
- const BYTE* lpData,
- DWORD cbData
-);*/
- public int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData);
-
-/*
-LONG WINAPI RegCreateKeyEx(
- HKEY hKey,
- LPCTSTR lpSubKey,
- DWORD Reserved,
- LPTSTR lpClass,
- DWORD dwOptions,
- REGSAM samDesired,
- LPSECURITY_ATTRIBUTES lpSecurityAttributes,
- PHKEY phkResult,
- LPDWORD lpdwDisposition
-);*/
- public int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions,
- int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult,
- IntByReference lpdwDisposition);
-
-/*
-LONG WINAPI RegDeleteKey(
- HKEY hKey,
- LPCTSTR lpSubKey
-);*/
- public int RegDeleteKey(int hKey, String name);
-
-/*
-LONG WINAPI RegEnumKeyEx(
- HKEY hKey,
- DWORD dwIndex,
- LPTSTR lpName,
- LPDWORD lpcName,
- LPDWORD lpReserved,
- LPTSTR lpClass,
- LPDWORD lpcClass,
- PFILETIME lpftLastWriteTime
-);*/
- public int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved,
- char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime);
-
-/*
-LONG WINAPI RegEnumValue(
- HKEY hKey,
- DWORD dwIndex,
- LPTSTR lpValueName,
- LPDWORD lpcchValueName,
- LPDWORD lpReserved,
- LPDWORD lpType,
- LPBYTE lpData,
- LPDWORD lpcbData
-);*/
- public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved,
- IntByReference lpType, byte[] lpData, IntByReference lpcbData);
-
- interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
- /*
- VOID WINAPI ServiceMain(
- DWORD dwArgc,
- LPTSTR* lpszArgv
- );*/
- public void callback(int dwArgc, Pointer lpszArgv);
- }
-
- interface Handler extends StdCallCallback {
- /*
- VOID WINAPI Handler(
- DWORD fdwControl
- );*/
- public void callback(int fdwControl);
- }
-
- interface HandlerEx extends StdCallCallback {
- /*
- DWORD WINAPI HandlerEx(
- DWORD dwControl,
- DWORD dwEventType,
- LPVOID lpEventData,
- LPVOID lpContext
- );*/
- public void callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext);
- }
-
-/*
-typedef struct _SERVICE_STATUS {
- DWORD dwServiceType;
- DWORD dwCurrentState;
- DWORD dwControlsAccepted;
- DWORD dwWin32ExitCode;
- DWORD dwServiceSpecificExitCode;
- DWORD dwCheckPoint;
- DWORD dwWaitHint;
-} SERVICE_STATUS,
- *LPSERVICE_STATUS;*/
- public static class SERVICE_STATUS extends Structure {
- public int dwServiceType;
- public int dwCurrentState;
- public int dwControlsAccepted;
- public int dwWin32ExitCode;
- public int dwServiceSpecificExitCode;
- public int dwCheckPoint;
- public int dwWaitHint;
- }
-
-/*
-typedef struct _SERVICE_TABLE_ENTRY {
- LPTSTR lpServiceName;
- LPSERVICE_MAIN_FUNCTION lpServiceProc;
-} SERVICE_TABLE_ENTRY,
- *LPSERVICE_TABLE_ENTRY;*/
- public static class SERVICE_TABLE_ENTRY extends Structure {
- public String lpServiceName;
- public SERVICE_MAIN_FUNCTION lpServiceProc;
- }
-
- public static class ChangeServiceConfig2Info extends Structure {
- }
-
-/*
- typedef struct _SERVICE_DESCRIPTION {
- LPTSTR lpDescription;
-} SERVICE_DESCRIPTION,
- *LPSERVICE_DESCRIPTION;*/
- public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
- public String lpDescription;
- }
-}
-
-
diff --git a/arduino-core/src/processing/app/windows/Options.java b/arduino-core/src/processing/app/windows/Options.java
deleted file mode 100644
index acbf43d7c..000000000
--- a/arduino-core/src/processing/app/windows/Options.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Options.java
- *
- * Created on 8. August 2007, 17:07
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-import static com.sun.jna.Library.*;
-import com.sun.jna.win32.*;
-import java.util.*;
-
-/**
- *
- * @author TB
- */
-public interface Options {
- @SuppressWarnings("serial")
- Map UNICODE_OPTIONS = new HashMap() {
- {
- put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
- put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
- }
- };
-}
diff --git a/arduino-core/src/processing/app/windows/Platform.java b/arduino-core/src/processing/app/windows/Platform.java
index cfc2f497d..d784bef37 100644
--- a/arduino-core/src/processing/app/windows/Platform.java
+++ b/arduino-core/src/processing/app/windows/Platform.java
@@ -23,127 +23,54 @@
package processing.app.windows;
import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.Executor;
-import processing.app.PreferencesData;
+import org.apache.commons.exec.PumpStreamHandler;
import processing.app.debug.TargetPackage;
import processing.app.legacy.PApplet;
import processing.app.legacy.PConstants;
-import processing.app.tools.CollectStdOutExecutor;
-import processing.app.windows.Registry.REGISTRY_ROOT_KEY;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-// http://developer.apple.com/documentation/QuickTime/Conceptual/QT7Win_Update_Guide/Chapter03/chapter_3_section_1.html
-// HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\QuickTime\QTSysDir
-
-// HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\CurrentVersion -> 1.6 (String)
-// HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\CurrentVersion\1.6\JavaHome -> c:\jdk-1.6.0_05
-
public class Platform extends processing.app.Platform {
- static final String openCommand =
- System.getProperty("user.dir").replace('/', '\\') +
- "\\arduino.exe \"%1\"";
- static final String DOC = "Arduino.Document";
+ private File settingsFolder;
+ private File defaultSketchbookFolder;
public void init() throws IOException {
super.init();
- checkAssociations();
- checkQuickTime();
checkPath();
+ recoverSettingsFolderPath();
+ recoverDefaultSketchbookFolder();
}
-
- /**
- * Make sure that .pde files are associated with processing.exe.
- */
- protected void checkAssociations() {
- try {
- String knownCommand =
- Registry.getStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
- DOC + "\\shell\\open\\command", "");
- if (knownCommand == null) {
- if (PreferencesData.getBoolean("platform.auto_file_type_associations")) {
- setAssociations();
- }
-
- } else if (!knownCommand.equals(openCommand)) {
- // If the value is set differently, just change the registry setting.
- if (PreferencesData.getBoolean("platform.auto_file_type_associations")) {
- setAssociations();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
+ private void recoverSettingsFolderPath() throws IOException {
+ String path = getFolderPathFromRegistry("AppData");
+ this.settingsFolder = new File(path, "Arduino15");
}
-
- /**
- * Associate .pde files with this version of Processing.
- */
- protected void setAssociations() throws UnsupportedEncodingException {
- if (Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
- "", ".ino") &&
- Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
- ".ino", "", DOC) &&
-
- Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT, "", DOC) &&
- Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT, DOC, "",
- "Arduino Source Code") &&
-
- Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
- DOC, "shell") &&
- Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
- DOC + "\\shell", "open") &&
- Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT,
- DOC + "\\shell\\open", "command") &&
- Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
- DOC + "\\shell\\open\\command", "",
- openCommand)) {
- // everything ok
- // hooray!
-
- } else {
- PreferencesData.setBoolean("platform.auto_file_type_associations", false);
- }
+ private void recoverDefaultSketchbookFolder() throws IOException {
+ String path = getFolderPathFromRegistry("Personal");
+ this.defaultSketchbookFolder = new File(path, "Arduino");
}
+ private String getFolderPathFromRegistry(String folderType) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Executor executor = new DefaultExecutor();
+ executor.setStreamHandler(new PumpStreamHandler(baos, null));
- /**
- * Find QuickTime for Java installation.
- */
- protected void checkQuickTime() {
- try {
- String qtsystemPath =
- Registry.getStringValue(REGISTRY_ROOT_KEY.LOCAL_MACHINE,
- "Software\\Apple Computer, Inc.\\QuickTime",
- "QTSysDir");
- // Could show a warning message here if QT not installed, but that
- // would annoy people who don't want anything to do with QuickTime.
- if (qtsystemPath != null) {
- File qtjavaZip = new File(qtsystemPath, "QTJava.zip");
- if (qtjavaZip.exists()) {
- String qtjavaZipPath = qtjavaZip.getAbsolutePath();
- String cp = System.getProperty("java.class.path");
- System.setProperty("java.class.path",
- cp + File.pathSeparator + qtjavaZipPath);
- }
- }
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
+ CommandLine toDevicePath = CommandLine.parse("reg query \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\" /v \"" + folderType + "\"");
+ executor.execute(toDevicePath);
+ return new RegQueryParser(new String(baos.toByteArray())).getValueOfKey();
}
-
-
+
/**
* Remove extra quotes, slashes, and garbage from the Windows PATH.
*/
@@ -178,54 +105,15 @@ public class Platform extends processing.app.Platform {
}
}
-
- // looking for Documents and Settings/blah/Application Data/Processing
- public File getSettingsFolder() throws Exception {
- // HKEY_CURRENT_USER\Software\Microsoft
- // \Windows\CurrentVersion\Explorer\Shell Folders
- // Value Name: AppData
- // Value Type: REG_SZ
- // Value Data: path
-
- String keyPath =
- "Software\\Microsoft\\Windows\\CurrentVersion" +
- "\\Explorer\\Shell Folders";
- String appDataPath =
- Registry.getStringValue(REGISTRY_ROOT_KEY.CURRENT_USER, keyPath, "AppData");
-
- File dataFolder = new File(appDataPath, "Arduino15");
- return dataFolder;
+ public File getSettingsFolder() {
+ return settingsFolder;
}
- // looking for Documents and Settings/blah/My Documents/Processing
- // (though using a reg key since it's different on other platforms)
public File getDefaultSketchbookFolder() throws Exception {
-
- // http://support.microsoft.com/?kbid=221837&sd=RMVP
- // http://support.microsoft.com/kb/242557/en-us
-
- // The path to the My Documents folder is stored in the following
- // registry key, where path is the complete path to your storage location
-
- // HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
- // Value Name: Personal
- // Value Type: REG_SZ
- // Value Data: path
-
- // in some instances, this may be overridden by a policy, in which case check:
- // HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
-
- String keyPath =
- "Software\\Microsoft\\Windows\\CurrentVersion" +
- "\\Explorer\\Shell Folders";
- String personalPath =
- Registry.getStringValue(REGISTRY_ROOT_KEY.CURRENT_USER, keyPath, "Personal");
-
- return new File(personalPath, "Arduino");
+ return defaultSketchbookFolder;
}
-
public void openURL(String url) throws Exception {
// this is not guaranteed to work, because who knows if the
// path will always be c:\progra~1 et al. also if the user has
@@ -242,7 +130,7 @@ public class Platform extends processing.app.Platform {
// "Access is denied" in both cygwin and the "dos" prompt.
//Runtime.getRuntime().exec("cmd /c " + currentDir + "\\reference\\" +
// referenceFile + ".html");
- if (url.startsWith("http")) {
+ if (url.startsWith("http") || url.startsWith("file:")) {
// open dos prompt, give it 'start' command, which will
// open the url properly. start by itself won't work since
// it appears to need cmd
@@ -307,7 +195,8 @@ public class Platform extends processing.app.Platform {
@Override
public String preListAllCandidateDevices() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Executor executor = new CollectStdOutExecutor(baos);
+ Executor executor = new DefaultExecutor();
+ executor.setStreamHandler(new PumpStreamHandler(baos, null));
try {
String listComPorts = new File(System.getProperty("user.dir"), "hardware/tools/listComPorts.exe").getCanonicalPath();
diff --git a/arduino-core/src/processing/app/windows/RegQueryParser.java b/arduino-core/src/processing/app/windows/RegQueryParser.java
new file mode 100644
index 000000000..4d75b747e
--- /dev/null
+++ b/arduino-core/src/processing/app/windows/RegQueryParser.java
@@ -0,0 +1,35 @@
+package processing.app.windows;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class RegQueryParser {
+
+ private String valueOfKey;
+
+ public RegQueryParser(String regQueryOutput) {
+ parse(regQueryOutput);
+ }
+
+ private void parse(String regQueryOutput) {
+ List rows = Arrays.asList(regQueryOutput.replace(" ", "\t").replace("\r", "\n").replace("\n\n", "\n").split("\n"));
+
+ String row = Iterables.find(rows, new Predicate() {
+ @Override
+ public boolean apply(String input) {
+ return input.startsWith("\t");
+ }
+ });
+
+ String[] cols = row.split("\t");
+ assert cols.length == 4;
+ this.valueOfKey = cols[3];
+ }
+
+ public String getValueOfKey() {
+ return valueOfKey;
+ }
+}
diff --git a/arduino-core/src/processing/app/windows/Registry.java b/arduino-core/src/processing/app/windows/Registry.java
deleted file mode 100644
index 71fa5eebe..000000000
--- a/arduino-core/src/processing/app/windows/Registry.java
+++ /dev/null
@@ -1,456 +0,0 @@
-package processing.app.windows;
-
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import com.sun.jna.ptr.IntByReference;
-
-/**
- * Methods for accessing the Windows Registry. Only String and DWORD values supported at the moment.
- */
-public class Registry {
- public static enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS};
- private final static HashMap rootKeyMap = new HashMap();
-
- static {
- rootKeyMap.put(REGISTRY_ROOT_KEY.CLASSES_ROOT, WINREG.HKEY_CLASSES_ROOT);
- rootKeyMap.put(REGISTRY_ROOT_KEY.CURRENT_USER, WINREG.HKEY_CURRENT_USER);
- rootKeyMap.put(REGISTRY_ROOT_KEY.LOCAL_MACHINE, WINREG.HKEY_LOCAL_MACHINE);
- rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WINREG.HKEY_USERS);
- }
-
- /**
- * Testing.
- *
- * @param args arguments
- * @throws java.lang.Exception on error
- */
- public static void main(String[] args) throws Exception {
- }
-
- /**
- * Gets one of the root keys.
- *
- * @param key key type
- * @return root key
- */
- private static int getRegistryRootKey(REGISTRY_ROOT_KEY key) {
- Advapi32 advapi32;
- IntByReference pHandle;
- int handle = 0;
-
- advapi32 = Advapi32.INSTANCE;
- pHandle = new IntByReference();
-
- if(advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WINERROR.ERROR_SUCCESS) {
- handle = pHandle.getValue();
- }
- return(handle);
- }
-
- /**
- * Opens a key.
- *
- * @param rootKey root key
- * @param subKeyName name of the key
- * @param access access mode
- * @return handle to the key or 0
- */
- private static int openKey(REGISTRY_ROOT_KEY rootKey, String subKeyName, int access) {
- Advapi32 advapi32;
- IntByReference pHandle;
- int rootKeyHandle;
-
- advapi32 = Advapi32.INSTANCE;
- rootKeyHandle = getRegistryRootKey(rootKey);
- pHandle = new IntByReference();
-
- if(advapi32.RegOpenKeyEx(rootKeyHandle, subKeyName, 0, access, pHandle) == WINERROR.ERROR_SUCCESS) {
- return(pHandle.getValue());
-
- } else {
- return(0);
- }
- }
-
- /**
- * Converts a Windows buffer to a Java String.
- *
- * @param buf buffer
- * @throws java.io.UnsupportedEncodingException on error
- * @return String
- */
- private static String convertBufferToString(byte[] buf) throws UnsupportedEncodingException {
- return(new String(buf, 0, buf.length - 2, "UTF-16LE"));
- }
-
- /**
- * Converts a Windows buffer to an int.
- *
- * @param buf buffer
- * @return int
- */
- private static int convertBufferToInt(byte[] buf) {
- return(((int)(buf[0] & 0xff)) + (((int)(buf[1] & 0xff)) << 8) + (((int)(buf[2] & 0xff)) << 16) + (((int)(buf[3] & 0xff)) << 24));
- }
-
- /**
- * Read a String value.
- *
- * @param rootKey root key
- * @param subKeyName key name
- * @param name value name
- * @throws java.io.UnsupportedEncodingException on error
- * @return String or null
- */
- public static String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) throws UnsupportedEncodingException {
- Advapi32 advapi32;
- IntByReference pType, lpcbData;
- byte[] lpData = new byte[1];
- int handle = 0;
- String ret = null;
-
- advapi32 = Advapi32.INSTANCE;
- pType = new IntByReference();
- lpcbData = new IntByReference();
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
-
- if(handle != 0) {
-
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA) {
- lpData = new byte[lpcbData.getValue()];
-
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS) {
- ret = convertBufferToString(lpData);
- }
- }
- advapi32.RegCloseKey(handle);
- }
- return(ret);
- }
-
- /**
- * Read an int value.
- *
- *
- * @return int or 0
- * @param rootKey root key
- * @param subKeyName key name
- * @param name value name
- */
- public static int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
- Advapi32 advapi32;
- IntByReference pType, lpcbData;
- byte[] lpData = new byte[1];
- int handle = 0;
- int ret = 0;
-
- advapi32 = Advapi32.INSTANCE;
- pType = new IntByReference();
- lpcbData = new IntByReference();
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
-
- if(handle != 0) {
-
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA) {
- lpData = new byte[lpcbData.getValue()];
-
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS) {
- ret = convertBufferToInt(lpData);
- }
- }
- advapi32.RegCloseKey(handle);
- }
- return(ret);
- }
-
- /**
- * Delete a value.
- *
- * @param rootKey root key
- * @param subKeyName key name
- * @param name value name
- * @return true on success
- */
- public static boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
- Advapi32 advapi32;
- int handle;
- boolean ret = true;
-
- advapi32 = Advapi32.INSTANCE;
-
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
-
- if(handle != 0) {
- if(advapi32.RegDeleteValue(handle, name) == WINERROR.ERROR_SUCCESS) {
- ret = true;
- }
- advapi32.RegCloseKey(handle);
- }
- return(ret);
- }
-
- /**
- * Writes a String value.
- *
- * @param rootKey root key
- * @param subKeyName key name
- * @param name value name
- * @param value value
- * @throws java.io.UnsupportedEncodingException on error
- * @return true on success
- */
- public static boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value) throws UnsupportedEncodingException {
- Advapi32 advapi32;
- int handle;
- byte[] data;
- boolean ret = false;
-
- // appears to be Java 1.6 syntax, removing [fry]
- //data = Arrays.copyOf(value.getBytes("UTF-16LE"), value.length() * 2 + 2);
- data = new byte[value.length() * 2 + 2];
- byte[] src = value.getBytes("UTF-16LE");
- System.arraycopy(src, 0, data, 0, src.length);
-
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
-
- if(handle != 0) {
- if(advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_SZ, data, data.length) == WINERROR.ERROR_SUCCESS) {
- ret = true;
- }
- advapi32.RegCloseKey(handle);
- }
- return(ret);
- }
-
- /**
- * Writes an int value.
- *
- *
- * @return true on success
- * @param rootKey root key
- * @param subKeyName key name
- * @param name value name
- * @param value value
- */
- public static boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value) {
- Advapi32 advapi32;
- int handle;
- byte[] data;
- boolean ret = false;
-
- data = new byte[4];
- data[0] = (byte)(value & 0xff);
- data[1] = (byte)((value >> 8) & 0xff);
- data[2] = (byte)((value >> 16) & 0xff);
- data[3] = (byte)((value >> 24) & 0xff);
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
-
- if(handle != 0) {
-
- if(advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_DWORD, data, data.length) == WINERROR.ERROR_SUCCESS) {
- ret = true;
- }
- advapi32.RegCloseKey(handle);
- }
- return(ret);
- }
-
- /**
- * Check for existence of a value.
- *
- * @param rootKey root key
- * @param subKeyName key name
- * @param name value name
- * @return true if exists
- */
- public static boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
- Advapi32 advapi32;
- IntByReference pType, lpcbData;
- byte[] lpData = new byte[1];
- int handle = 0;
- boolean ret = false;
-
- advapi32 = Advapi32.INSTANCE;
- pType = new IntByReference();
- lpcbData = new IntByReference();
- handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
-
- if(handle != 0) {
-
- if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) != WINERROR.ERROR_FILE_NOT_FOUND) {
- ret = true;
-
- } else {
- ret = false;
- }
- advapi32.RegCloseKey(handle);
- }
- return(ret);
- }
-
- /**
- * Create a new key.
- *
- * @param rootKey root key
- * @param parent name of parent key
- * @param name key name
- * @return true on success
- */
- public static boolean createKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
- Advapi32 advapi32;
- IntByReference hkResult, dwDisposition;
- int handle = 0;
- boolean ret = false;
-
- advapi32 = Advapi32.INSTANCE;
- hkResult = new IntByReference();
- dwDisposition = new IntByReference();
- handle = openKey(rootKey, parent, WINNT.KEY_READ);
-
- if(handle != 0) {
-
- if(advapi32.RegCreateKeyEx(handle, name, 0, null, WINNT.REG_OPTION_NON_VOLATILE, WINNT.KEY_READ, null,
- hkResult, dwDisposition) == WINERROR.ERROR_SUCCESS) {
- ret = true;
- advapi32.RegCloseKey(hkResult.getValue());
-
- } else {
- ret = false;
- }
- advapi32.RegCloseKey(handle);
- }
- return(ret);
- }
-
- /**
- * Delete a key.
- *
- * @param rootKey root key
- * @param parent name of parent key
- * @param name key name
- * @return true on success
- */
- public static boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
- Advapi32 advapi32;
- int handle = 0;
- boolean ret = false;
-
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, parent, WINNT.KEY_READ);
-
- if(handle != 0) {
-
- if(advapi32.RegDeleteKey(handle, name) == WINERROR.ERROR_SUCCESS) {
- ret = true;
-
- } else {
- ret = false;
- }
- advapi32.RegCloseKey(handle);
- }
- return(ret);
- }
-
- /**
- * Get all sub keys of a key.
- *
- * @param rootKey root key
- * @param parent key name
- * @return array with all sub key names
- */
- public static String[] getSubKeys(REGISTRY_ROOT_KEY rootKey, String parent) {
- Advapi32 advapi32;
- int handle = 0, dwIndex;
- char[] lpName;
- IntByReference lpcName;
- WINBASE.FILETIME lpftLastWriteTime;
- TreeSet subKeys = new TreeSet();
-
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, parent, WINNT.KEY_READ);
- lpName = new char[256];
- lpcName = new IntByReference(256);
- lpftLastWriteTime = new WINBASE.FILETIME();
-
- if(handle != 0) {
- dwIndex = 0;
-
- while(advapi32.RegEnumKeyEx(handle, dwIndex, lpName, lpcName, null,
- null, null, lpftLastWriteTime) == WINERROR.ERROR_SUCCESS) {
- subKeys.add(new String(lpName, 0, lpcName.getValue()));
- lpcName.setValue(256);
- dwIndex++;
- }
- advapi32.RegCloseKey(handle);
- }
-
- return(subKeys.toArray(new String[]{}));
- }
-
- /**
- * Get all values under a key.
- *
- * @param rootKey root key
- * @param key jey name
- * @throws java.io.UnsupportedEncodingException on error
- * @return TreeMap with name and value pairs
- */
- public static TreeMap getValues(REGISTRY_ROOT_KEY rootKey, String key) throws UnsupportedEncodingException {
- Advapi32 advapi32;
- int handle = 0, dwIndex, result = 0;
- char[] lpValueName;
- byte[] lpData;
- IntByReference lpcchValueName, lpType, lpcbData;
- String name;
- TreeMap values = new TreeMap(String.CASE_INSENSITIVE_ORDER);
-
- advapi32 = Advapi32.INSTANCE;
- handle = openKey(rootKey, key, WINNT.KEY_READ);
- lpValueName = new char[16384];
- lpcchValueName = new IntByReference(16384);
- lpType = new IntByReference();
- lpData = new byte[1];
- lpcbData = new IntByReference();
-
- if(handle != 0) {
- dwIndex = 0;
-
- do {
- lpcbData.setValue(0);
- result = advapi32.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null,
- lpType, lpData, lpcbData);
-
- if(result == WINERROR.ERROR_MORE_DATA) {
- lpData = new byte[lpcbData.getValue()];
- lpcchValueName = new IntByReference(16384);
- result = advapi32.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null,
- lpType, lpData, lpcbData);
-
- if(result == WINERROR.ERROR_SUCCESS) {
- name = new String(lpValueName, 0, lpcchValueName.getValue());
-
- switch(lpType.getValue()) {
- case WINNT.REG_SZ:
- values.put(name, convertBufferToString(lpData));
- break;
- case WINNT.REG_DWORD:
- values.put(name, convertBufferToInt(lpData));
- break;
- default:
- break;
- }
- }
- }
- dwIndex++;
- } while(result == WINERROR.ERROR_SUCCESS);
-
- advapi32.RegCloseKey(handle);
- }
- return(values);
- }
-}
diff --git a/arduino-core/src/processing/app/windows/WINBASE.java b/arduino-core/src/processing/app/windows/WINBASE.java
deleted file mode 100644
index 78a386f04..000000000
--- a/arduino-core/src/processing/app/windows/WINBASE.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * WINBASE.java
- *
- * Created on 5. September 2007, 11:24
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-import com.sun.jna.Pointer;
-import com.sun.jna.Structure;
-
-/**
- *
- * @author TB
- */
-public interface WINBASE {
-/*
-typedef struct _SECURITY_ATTRIBUTES {
- DWORD nLength;
- LPVOID lpSecurityDescriptor;
- BOOL bInheritHandle;
-} SECURITY_ATTRIBUTES,
- *PSECURITY_ATTRIBUTES,
- *LPSECURITY_ATTRIBUTES;*/
- public static class SECURITY_ATTRIBUTES extends Structure {
- public int nLength;
- public Pointer lpSecurityDescriptor;
- public boolean bInheritHandle;
- }
-
-/*
-typedef struct _FILETIME {
- DWORD dwLowDateTime;
- DWORD dwHighDateTime;
-} FILETIME, *PFILETIME, *LPFILETIME;*/
- public static class FILETIME extends Structure {
- public int dwLowDateTime;
- public int dwHighDateTime;
- }
-}
diff --git a/arduino-core/src/processing/app/windows/WINERROR.java b/arduino-core/src/processing/app/windows/WINERROR.java
deleted file mode 100644
index a9382cfcb..000000000
--- a/arduino-core/src/processing/app/windows/WINERROR.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * WINERROR.java
- *
- * Created on 7. August 2007, 08:09
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-
-/**
- *
- * @author TB
- */
-public interface WINERROR {
- public final static int ERROR_SUCCESS = 0;
- public final static int NO_ERROR = 0;
- public final static int ERROR_FILE_NOT_FOUND = 2;
- public final static int ERROR_MORE_DATA = 234;
-}
diff --git a/arduino-core/src/processing/app/windows/WINNT.java b/arduino-core/src/processing/app/windows/WINNT.java
deleted file mode 100644
index c08c9f5a3..000000000
--- a/arduino-core/src/processing/app/windows/WINNT.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * WINNT.java
- *
- * Created on 8. August 2007, 13:41
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-/**
- *
- * @author TB
- */
-public interface WINNT {
- public final static int DELETE = 0x00010000;
- public final static int READ_CONTROL = 0x00020000;
- public final static int WRITE_DAC = 0x00040000;
- public final static int WRITE_OWNER = 0x00080000;
- public final static int SYNCHRONIZE = 0x00100000;
-
- public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
-
- public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
- public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
- public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
-
- public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
-
- public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
-
- public final static int GENERIC_EXECUTE = 0x20000000;
-
- public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
-
- public final static int KEY_QUERY_VALUE = 0x0001;
- public final static int KEY_SET_VALUE = 0x0002;
- public final static int KEY_CREATE_SUB_KEY = 0x0004;
- public final static int KEY_ENUMERATE_SUB_KEYS = 0x0008;
- public final static int KEY_NOTIFY = 0x0010;
- public final static int KEY_CREATE_LINK = 0x0020;
-
- public final static int KEY_READ = ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE));
- public final static int KEY_WRITE = ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE));
-
- public final static int REG_NONE = 0; // No value type
- public final static int REG_SZ = 1; // Unicode nul terminated string
- public final static int REG_EXPAND_SZ = 2; // Unicode nul terminated string
- // (with environment variable references)
- public final static int REG_BINARY = 3; // Free form binary
- public final static int REG_DWORD = 4; // 32-bit number
- public final static int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD)
- public final static int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number
- public final static int REG_LINK = 6; // Symbolic Link (unicode)
- public final static int REG_MULTI_SZ = 7; // Multiple Unicode strings
- public final static int REG_RESOURCE_LIST = 8; // Resource list in the resource map
- public final static int REG_FULL_RESOURCE_DESCRIPTOR = 9; // Resource list in the hardware description
- public final static int REG_RESOURCE_REQUIREMENTS_LIST = 10;
-
- public final static int REG_OPTION_RESERVED = 0x00000000; // Parameter is reserved
- public final static int REG_OPTION_NON_VOLATILE = 0x00000000; // Key is preserved
- // when system is rebooted
- public final static int REG_OPTION_VOLATILE = 0x00000001; // Key is not preserved
- // when system is rebooted
- public final static int REG_OPTION_CREATE_LINK = 0x00000002; // Created key is a
- // symbolic link
- public final static int REG_OPTION_BACKUP_RESTORE = 0x00000004; // open for backup or restore
- // special access rules
- // privilege required
- public final static int REG_OPTION_OPEN_LINK = 0x00000008; // Open symbolic link
-
-}
diff --git a/arduino-core/src/processing/app/windows/WINREG.java b/arduino-core/src/processing/app/windows/WINREG.java
deleted file mode 100644
index 07a7c23cb..000000000
--- a/arduino-core/src/processing/app/windows/WINREG.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * WINREG.java
- *
- * Created on 17. August 2007, 14:32
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-/**
- *
- * @author TB
- */
-public interface WINREG {
- public final static int HKEY_CLASSES_ROOT = 0x80000000;
- public final static int HKEY_CURRENT_USER = 0x80000001;
- public final static int HKEY_LOCAL_MACHINE = 0x80000002;
- public final static int HKEY_USERS = 0x80000003;
-}
diff --git a/build/.editorconfig b/build/.editorconfig
new file mode 100644
index 000000000..bd8c8987e
--- /dev/null
+++ b/build/.editorconfig
@@ -0,0 +1,16 @@
+# EditorConfig is awesome: http://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+indent_size = 2
+charset = utf-8
+
+[*.{md,adoc}]
+indent_style = space
+trim_trailing_whitespace = false
diff --git a/build/Firmata-2.4.3.zip.sha b/build/Firmata-2.4.3.zip.sha
new file mode 100644
index 000000000..dbb83e981
--- /dev/null
+++ b/build/Firmata-2.4.3.zip.sha
@@ -0,0 +1 @@
+a1c86eb5223801d046c7158dc98be6a74a73da2d
diff --git a/build/Temboo-1.1.2.zip.sha b/build/Temboo-1.1.2.zip.sha
new file mode 100644
index 000000000..c8e58c81c
--- /dev/null
+++ b/build/Temboo-1.1.2.zip.sha
@@ -0,0 +1 @@
+3765428c8af45e7ef085b53f6408bbb1c0133f6d
diff --git a/build/build.xml b/build/build.xml
index b0d39a966..663bc63d9 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -52,6 +52,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -164,6 +182,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -641,6 +673,10 @@
+
+
+
+
@@ -653,6 +689,10 @@
+
+
+
+
@@ -683,6 +723,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -881,8 +933,8 @@
-
-
+
+
diff --git a/build/build_pull_request.bash b/build/build_pull_request.bash
index 0553a4bcd..2ca6a7092 100755
--- a/build/build_pull_request.bash
+++ b/build/build_pull_request.bash
@@ -18,5 +18,5 @@ fi
VERSION="PR-${ghprbPullId}-BUILD-${BUILD_NUMBER}"
-./build_all_dist.bash -Dversion="${VERSION}" -DMACOSX_BUNDLED_JVM=$MACOSX_BUNDLED_JVM -DWINDOWS_BUNDLED_JVM=$WINDOWS_BUNDLED_JVM
+./build_all_dist.bash -Dversion="${VERSION}" -DMACOSX_BUNDLED_JVM=$MACOSX_BUNDLED_JVM -DWINDOWS_BUNDLED_JVM=$WINDOWS_BUNDLED_JVM -DLINUX32_BUNDLED_JVM=$LINUX32_BUNDLED_JVM -DLINUX64_BUNDLED_JVM=$LINUX64_BUNDLED_JVM
diff --git a/build/cmd/dist.sh b/build/cmd/dist.sh
index 38d295365..7298197c5 100755
--- a/build/cmd/dist.sh
+++ b/build/cmd/dist.sh
@@ -26,7 +26,6 @@ cp -r ../shared/lib processing/
cp -r ../shared/libraries processing/
cp ../../app/lib/antlr.jar processing/lib/
cp ../../app/lib/ecj.jar processing/lib/
-cp ../../app/lib/jna.jar processing/lib/
cp ../shared/revisions.txt processing/
# add the libraries folder with source
diff --git a/build/create_reference.pl b/build/create_reference.pl
index 41d14ee74..847ae584b 100644
--- a/build/create_reference.pl
+++ b/build/create_reference.pl
@@ -16,7 +16,7 @@ my $verbose = 1;
my $CURL_OPTIONS = "--silent --show-error -u $user:$pass";
my $ARDUINO = 'http://edit.arduino.cc/en_ref'; # base url for reference site
-my $PUBLIC = 'http://arduino.cc/en'; # base url for public site
+my $PUBLIC = 'http://www.arduino.cc/en'; # base url for public site
my %downloaded = (); # keep track of the pages we download
diff --git a/build/fetch.sh b/build/fetch.sh
index e75a0dcf4..f8b239289 100755
--- a/build/fetch.sh
+++ b/build/fetch.sh
@@ -13,7 +13,7 @@ cd reference
perl ../create_reference.pl || die 'unable to create local reference pages'
mkdir img
-curl http://arduino.cc/en/pub/skins/arduinoUno/img/logo.png > img/logo.png
+curl http://www.arduino.cc/en/pub/skins/arduinoUno/img/logo.png > img/logo.png
cd ..
zip -r shared/reference.zip reference || die 'unable to create reference.zip archive'
diff --git a/build/javadoc/make.sh b/build/javadoc/make.sh
index 1dbc46ce6..0b31b88e8 100755
--- a/build/javadoc/make.sh
+++ b/build/javadoc/make.sh
@@ -9,7 +9,7 @@ javadoc -public -notimestamp -d core \
# setting this up right, so if anyone knows how to do it without specifying
# all the directories like this, please let us know.
javadoc -public -notimestamp -d everything \
- -classpath ../../app/lib/antlr.jar:../../app/lib/jna.jar:../../serial/library/jssc-2.6.0.jar:../../opengl/library/jogl.jar:../../pdf/library/itext.jar:../../app/lib/ecj.jar \
+ -classpath ../../app/lib/antlr.jar:../../serial/library/jssc-2.6.0.jar:../../opengl/library/jogl.jar:../../pdf/library/itext.jar:../../app/lib/ecj.jar \
../../core/src/processing/core/*.java \
../../core/src/processing/xml/*.java \
../../app/src/antlr/*.java \
diff --git a/build/linux/dist/appdata.xml b/build/linux/dist/appdata.xml
index 29baec2d2..410f4b646 100644
--- a/build/linux/dist/appdata.xml
+++ b/build/linux/dist/appdata.xml
@@ -19,6 +19,6 @@
http://mavit.fedorapeople.org/appdata/arduino-screenshot.png
http://mavit.fedorapeople.org/appdata/arduino-photo.jpg
- http://arduino.cc/
+ http://www.arduino.cc/
arduino.appdata.xml@mavit.org.uk
diff --git a/build/linux/dist/arduino b/build/linux/dist/arduino
index 94cf80db0..4e58bce3a 100755
--- a/build/linux/dist/arduino
+++ b/build/linux/dist/arduino
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
CURDIR=`pwd`
APPDIR="$(dirname -- "$(readlink -f -- "${0}")" )"
@@ -28,5 +28,9 @@ fi
export JAVA_TOOL_OPTIONS=`echo $JAVA_TOOL_OPTIONS | sed 's|-javaagent:/usr/share/java/jayatanaag.jar||g'`
-java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel $SPLASH processing.app.Base --curdir $CURDIR "$@"
+JAVA=java
+if [ -x ./java/bin/java ]; then
+ JAVA=./java/bin/java
+fi
+$JAVA -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel $SPLASH processing.app.Base --curdir "$CURDIR" "$@"
diff --git a/build/linux/dist/install.sh b/build/linux/dist/install.sh
index d34c8aac8..28bea92ae 100644
--- a/build/linux/dist/install.sh
+++ b/build/linux/dist/install.sh
@@ -13,5 +13,5 @@ rm arduino.desktop-bak
cp arduino.desktop ~/.local/share/applications/arduino.desktop
cp arduino.desktop ~/Desktop/arduino.desktop
-echo "Instaled Arduino IDE icons on menu and desktop !"
+echo "Installed Arduino IDE icons on menu and desktop !"
diff --git a/build/macosx/template.app/Contents/Info.plist b/build/macosx/template.app/Contents/Info.plist
index 6d49f00a5..5fa1337eb 100755
--- a/build/macosx/template.app/Contents/Info.plist
+++ b/build/macosx/template.app/Contents/Info.plist
@@ -97,7 +97,7 @@
- $JAVAROOT/antlr.jar:$JAVAROOT/apple.jar:$JAVAROOT/arduino-core.jar:$JAVAROOT/bcpg-jdk15on-152.jar:$JAVAROOT/bcprov-jdk15on-152.jar:$JAVAROOT/commons-codec-1.7.jar:$JAVAROOT/commons-compress-1.8.jar:$JAVAROOT/commons-exec-1.1.jar:$JAVAROOT/commons-httpclient-3.1.jar:$JAVAROOT/commons-lang3-3.3.2.jar:$JAVAROOT/commons-logging-1.0.4.jar:$JAVAROOT/ecj.jar:$JAVAROOT/guava-18.0.jar:$JAVAROOT/jackson-annotations-2.2.3.jar:$JAVAROOT/jackson-core-2.2.3.jar:$JAVAROOT/jackson-databind-2.2.3.jar:$JAVAROOT/jackson-module-mrbean-2.2.3.jar:$JAVAROOT/java-semver-0.8.0.jar:$JAVAROOT/jmdns-3.4.1.jar:$JAVAROOT/jna.jar:$JAVAROOT/jsch-0.1.50.jar:$JAVAROOT/jssc-2.8.0.jar:$JAVAROOT/pde.jar:$JAVAROOT/quaqua.jar:$JAVAROOT/rsyntaxtextarea-2.5.6.1+arduino.jar
+ $JAVAROOT/antlr.jar:$JAVAROOT/apple.jar:$JAVAROOT/arduino-core.jar:$JAVAROOT/bcpg-jdk15on-152.jar:$JAVAROOT/bcprov-jdk15on-152.jar:$JAVAROOT/commons-codec-1.7.jar:$JAVAROOT/commons-compress-1.8.jar:$JAVAROOT/commons-exec-1.1.jar:$JAVAROOT/commons-httpclient-3.1.jar:$JAVAROOT/commons-lang3-3.3.2.jar:$JAVAROOT/commons-logging-1.0.4.jar:$JAVAROOT/ecj.jar:$JAVAROOT/guava-18.0.jar:$JAVAROOT/jackson-annotations-2.2.3.jar:$JAVAROOT/jackson-core-2.2.3.jar:$JAVAROOT/jackson-databind-2.2.3.jar:$JAVAROOT/jackson-module-mrbean-2.2.3.jar:$JAVAROOT/java-semver-0.8.0.jar:$JAVAROOT/jmdns-3.4.1.jar:$JAVAROOT/jsch-0.1.50.jar:$JAVAROOT/jssc-2.8.0.jar:$JAVAROOT/pde.jar:$JAVAROOT/quaqua.jar:$JAVAROOT/rsyntaxtextarea-2.5.6.1+arduino.jar
JVMArchs
diff --git a/build/shared/examples/01.Basics/Blink/Blink.ino b/build/shared/examples/01.Basics/Blink/Blink.ino
index b0db92b86..3f42e4d43 100644
--- a/build/shared/examples/01.Basics/Blink/Blink.ino
+++ b/build/shared/examples/01.Basics/Blink/Blink.ino
@@ -5,7 +5,7 @@
Most Arduinos have an on-board LED you can control. On the Uno and
Leonardo, it is attached to digital pin 13. If you're unsure what
pin the on-board LED is connected to on your Arduino model, check
- the documentation at http://arduino.cc
+ the documentation at http://www.arduino.cc
This example code is in the public domain.
diff --git a/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino b/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino
index bb3036931..148d5b202 100644
--- a/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino
+++ b/build/shared/examples/02.Digital/StateChangeDetection/StateChangeDetection.ino
@@ -21,7 +21,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/ButtonStateChange
+ http://www.arduino.cc/en/Tutorial/ButtonStateChange
*/
diff --git a/build/shared/examples/02.Digital/toneKeyboard/toneKeyboard.ino b/build/shared/examples/02.Digital/toneKeyboard/toneKeyboard.ino
index fbd4f726c..1a9c9685c 100644
--- a/build/shared/examples/02.Digital/toneKeyboard/toneKeyboard.ino
+++ b/build/shared/examples/02.Digital/toneKeyboard/toneKeyboard.ino
@@ -14,7 +14,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/Tone3
+ http://www.arduino.cc/en/Tutorial/Tone3
*/
diff --git a/build/shared/examples/02.Digital/toneMelody/toneMelody.ino b/build/shared/examples/02.Digital/toneMelody/toneMelody.ino
index bbb987220..9aa81589c 100644
--- a/build/shared/examples/02.Digital/toneMelody/toneMelody.ino
+++ b/build/shared/examples/02.Digital/toneMelody/toneMelody.ino
@@ -12,7 +12,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/Tone
+ http://www.arduino.cc/en/Tutorial/Tone
*/
#include "pitches.h"
diff --git a/build/shared/examples/02.Digital/toneMultiple/toneMultiple.ino b/build/shared/examples/02.Digital/toneMultiple/toneMultiple.ino
index dea838f7d..a95ad1c88 100644
--- a/build/shared/examples/02.Digital/toneMultiple/toneMultiple.ino
+++ b/build/shared/examples/02.Digital/toneMultiple/toneMultiple.ino
@@ -12,7 +12,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/Tone4
+ http://www.arduino.cc/en/Tutorial/Tone4
*/
diff --git a/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino b/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino
index 3e6899911..28c780d89 100644
--- a/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino
+++ b/build/shared/examples/02.Digital/tonePitchFollower/tonePitchFollower.ino
@@ -14,7 +14,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/Tone2
+ http://www.arduino.cc/en/Tutorial/Tone2
*/
diff --git a/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino b/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino
index 32d44c625..0e5b212a6 100644
--- a/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino
+++ b/build/shared/examples/03.Analog/AnalogInput/AnalogInput.ino
@@ -23,7 +23,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/AnalogInput
+ http://www.arduino.cc/en/Tutorial/AnalogInput
*/
diff --git a/build/shared/examples/03.Analog/Calibration/Calibration.ino b/build/shared/examples/03.Analog/Calibration/Calibration.ino
index bd87cad58..7c83174e2 100644
--- a/build/shared/examples/03.Analog/Calibration/Calibration.ino
+++ b/build/shared/examples/03.Analog/Calibration/Calibration.ino
@@ -20,7 +20,7 @@
modified 30 Aug 2011
By Tom Igoe
- http://arduino.cc/en/Tutorial/Calibration
+ http://www.arduino.cc/en/Tutorial/Calibration
This example code is in the public domain.
diff --git a/build/shared/examples/03.Analog/Fading/Fading.ino b/build/shared/examples/03.Analog/Fading/Fading.ino
index 2ed8bc4f4..f02069e0c 100644
--- a/build/shared/examples/03.Analog/Fading/Fading.ino
+++ b/build/shared/examples/03.Analog/Fading/Fading.ino
@@ -11,7 +11,7 @@
modified 30 Aug 2011
By Tom Igoe
- http://arduino.cc/en/Tutorial/Fading
+ http://www.arduino.cc/en/Tutorial/Fading
This example code is in the public domain.
diff --git a/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino b/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino
index cbaaf88f3..be3c4d0b5 100644
--- a/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino
+++ b/build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino
@@ -28,6 +28,7 @@ void setup() {
}
void loop() {
+ serialEvent(); //call the function
// print the string when a newline arrives:
if (stringComplete) {
Serial.println(inputString);
diff --git a/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino b/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino
index 1ee4e9dfb..2e7ce8f26 100644
--- a/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino
+++ b/build/shared/examples/05.Control/IfStatementConditional/IfStatementConditional.ino
@@ -21,7 +21,7 @@
This example code is in the public domain.
-http://arduino.cc/en/Tutorial/IfStatement
+http://www.arduino.cc/en/Tutorial/IfStatement
*/
diff --git a/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino b/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino
index 36d25a191..543303eea 100644
--- a/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino
+++ b/build/shared/examples/05.Control/WhileStatementConditional/WhileStatementConditional.ino
@@ -22,7 +22,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/WhileLoop
+ http://www.arduino.cc/en/Tutorial/WhileLoop
*/
diff --git a/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino b/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino
index ff8f393d6..7386d2f50 100644
--- a/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino
+++ b/build/shared/examples/08.Strings/StringAdditionOperator/StringAdditionOperator.ino
@@ -8,7 +8,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringAdditionOperator
+ http://www.arduino.cc/en/Tutorial/StringAdditionOperator
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino b/build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino
index 4e9062fef..854280d27 100644
--- a/build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino
+++ b/build/shared/examples/08.Strings/StringAppendOperator/StringAppendOperator.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringAppendOperator
+ http://www.arduino.cc/en/Tutorial/StringAppendOperator
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino b/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino
index 6efc3aed7..fba798064 100644
--- a/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino
+++ b/build/shared/examples/08.Strings/StringCaseChanges/StringCaseChanges.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringCaseChanges
+ http://www.arduino.cc/en/Tutorial/StringCaseChanges
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino b/build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino
index f961c0738..b0cf0274f 100644
--- a/build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino
+++ b/build/shared/examples/08.Strings/StringCharacters/StringCharacters.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringCharacters
+ http://www.arduino.cc/en/Tutorial/StringCharacters
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino b/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino
index 85bcfb5a3..f58ca0ff5 100644
--- a/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino
+++ b/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringComparisonOperators
+ http://www.arduino.cc/en/Tutorial/StringComparisonOperators
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringConstructors/StringConstructors.ino b/build/shared/examples/08.Strings/StringConstructors/StringConstructors.ino
index 08810e448..30ac20cdd 100644
--- a/build/shared/examples/08.Strings/StringConstructors/StringConstructors.ino
+++ b/build/shared/examples/08.Strings/StringConstructors/StringConstructors.ino
@@ -7,7 +7,7 @@
modified 30 Aug 2011
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringConstructors
+ http://www.arduino.cc/en/Tutorial/StringConstructors
This example code is in the public domain.
*/
@@ -66,6 +66,14 @@ void loop() {
// prints "123456" or whatever the value of millis() is:
Serial.println(stringOne);
+ //using a float and the right decimal places:
+ stringOne = String(5.698, 3);
+ Serial.println(stringOne);
+
+ //using a float and less decimal places to use rounding:
+ stringOne = String(5.698, 2);
+ Serial.println(stringOne);
+
// do nothing while true:
while (true);
diff --git a/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino b/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino
index 97b5c84a1..d9cff117b 100644
--- a/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino
+++ b/build/shared/examples/08.Strings/StringIndexOf/StringIndexOf.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringIndexOf
+ http://www.arduino.cc/en/Tutorial/StringIndexOf
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringLength/StringLength.ino b/build/shared/examples/08.Strings/StringLength/StringLength.ino
index 070412462..5ce9f29dd 100644
--- a/build/shared/examples/08.Strings/StringLength/StringLength.ino
+++ b/build/shared/examples/08.Strings/StringLength/StringLength.ino
@@ -7,7 +7,7 @@
created 1 Aug 2010
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringLengthTrim
+ http://www.arduino.cc/en/Tutorial/StringLengthTrim
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino b/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino
index 055b24945..5d1dfda1d 100644
--- a/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino
+++ b/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringLengthTrim
+ http://www.arduino.cc/en/Tutorial/StringLengthTrim
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringReplace/StringReplace.ino b/build/shared/examples/08.Strings/StringReplace/StringReplace.ino
index 311974168..1825b7380 100644
--- a/build/shared/examples/08.Strings/StringReplace/StringReplace.ino
+++ b/build/shared/examples/08.Strings/StringReplace/StringReplace.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringReplace
+ http://www.arduino.cc/en/Tutorial/StringReplace
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino b/build/shared/examples/08.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino
index 4367d128b..feba23395 100644
--- a/build/shared/examples/08.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino
+++ b/build/shared/examples/08.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Tom Igoe
- http://arduino.cc/en/Tutorial/StringStartsWithEndsWith
+ http://www.arduino.cc/en/Tutorial/StringStartsWithEndsWith
This example code is in the public domain.
*/
diff --git a/build/shared/examples/08.Strings/StringSubstring/StringSubstring.ino b/build/shared/examples/08.Strings/StringSubstring/StringSubstring.ino
index 80404270e..6b1036f84 100644
--- a/build/shared/examples/08.Strings/StringSubstring/StringSubstring.ino
+++ b/build/shared/examples/08.Strings/StringSubstring/StringSubstring.ino
@@ -7,7 +7,7 @@
modified 2 Apr 2012
by Zach Eveland
- http://arduino.cc/en/Tutorial/StringSubstring
+ http://www.arduino.cc/en/Tutorial/StringSubstring
This example code is in the public domain.
*/
diff --git a/build/shared/examples/10.StarterKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino b/build/shared/examples/10.StarterKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino
index 24a8d8beb..db07cb4b4 100644
--- a/build/shared/examples/10.StarterKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino
+++ b/build/shared/examples/10.StarterKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino
@@ -15,7 +15,7 @@
Created 13 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p03_LoveOMeter/p03_LoveOMeter.ino b/build/shared/examples/10.StarterKit/p03_LoveOMeter/p03_LoveOMeter.ino
index 1a937cafa..b00e3fe48 100644
--- a/build/shared/examples/10.StarterKit/p03_LoveOMeter/p03_LoveOMeter.ino
+++ b/build/shared/examples/10.StarterKit/p03_LoveOMeter/p03_LoveOMeter.ino
@@ -13,7 +13,7 @@
Created 13 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
@@ -60,7 +60,7 @@ void loop() {
// if the current temperature is lower than the baseline
// turn off all LEDs
- if (temperature < baselineTemp) {
+ if (temperature < baselineTemp + 2) {
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
diff --git a/build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino b/build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino
index 5114694f8..d3229f2ad 100644
--- a/build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino
+++ b/build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino
@@ -17,7 +17,7 @@
by Scott Fitzgerald
Thanks to Federico Vanzati for improvements
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p05_ServoMoodIndicator/p05_ServoMoodIndicator.ino b/build/shared/examples/10.StarterKit/p05_ServoMoodIndicator/p05_ServoMoodIndicator.ino
index 5a6ca0e18..075555dfe 100644
--- a/build/shared/examples/10.StarterKit/p05_ServoMoodIndicator/p05_ServoMoodIndicator.ino
+++ b/build/shared/examples/10.StarterKit/p05_ServoMoodIndicator/p05_ServoMoodIndicator.ino
@@ -13,7 +13,7 @@
Created 13 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p06_LightTheremin/p06_LightTheremin.ino b/build/shared/examples/10.StarterKit/p06_LightTheremin/p06_LightTheremin.ino
index 04196c491..f0c8c2570 100644
--- a/build/shared/examples/10.StarterKit/p06_LightTheremin/p06_LightTheremin.ino
+++ b/build/shared/examples/10.StarterKit/p06_LightTheremin/p06_LightTheremin.ino
@@ -13,7 +13,7 @@
Created 13 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p07_Keyboard/p07_Keyboard.ino b/build/shared/examples/10.StarterKit/p07_Keyboard/p07_Keyboard.ino
index 0521b0a69..379a7dde9 100644
--- a/build/shared/examples/10.StarterKit/p07_Keyboard/p07_Keyboard.ino
+++ b/build/shared/examples/10.StarterKit/p07_Keyboard/p07_Keyboard.ino
@@ -15,7 +15,7 @@
Created 13 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p08_DigitalHourglass/p08_DigitalHourglass.ino b/build/shared/examples/10.StarterKit/p08_DigitalHourglass/p08_DigitalHourglass.ino
index 2716a21ff..932d737f7 100644
--- a/build/shared/examples/10.StarterKit/p08_DigitalHourglass/p08_DigitalHourglass.ino
+++ b/build/shared/examples/10.StarterKit/p08_DigitalHourglass/p08_DigitalHourglass.ino
@@ -14,7 +14,7 @@
Created 13 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p09_MotorizedPinwheel/p09_MotorizedPinwheel.ino b/build/shared/examples/10.StarterKit/p09_MotorizedPinwheel/p09_MotorizedPinwheel.ino
index a531ded7b..d4efae454 100644
--- a/build/shared/examples/10.StarterKit/p09_MotorizedPinwheel/p09_MotorizedPinwheel.ino
+++ b/build/shared/examples/10.StarterKit/p09_MotorizedPinwheel/p09_MotorizedPinwheel.ino
@@ -16,7 +16,7 @@
Created 13 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p10_Zoetrope/p10_Zoetrope.ino b/build/shared/examples/10.StarterKit/p10_Zoetrope/p10_Zoetrope.ino
index d0cfbe3c9..7b1b7fa54 100644
--- a/build/shared/examples/10.StarterKit/p10_Zoetrope/p10_Zoetrope.ino
+++ b/build/shared/examples/10.StarterKit/p10_Zoetrope/p10_Zoetrope.ino
@@ -17,7 +17,7 @@
by Scott Fitzgerald
Thanks to Federico Vanzati for improvements
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p11_CrystalBall/p11_CrystalBall.ino b/build/shared/examples/10.StarterKit/p11_CrystalBall/p11_CrystalBall.ino
index b60f60bb4..f17249be6 100644
--- a/build/shared/examples/10.StarterKit/p11_CrystalBall/p11_CrystalBall.ino
+++ b/build/shared/examples/10.StarterKit/p11_CrystalBall/p11_CrystalBall.ino
@@ -16,7 +16,7 @@
Created 13 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p12_KnockLock/p12_KnockLock.ino b/build/shared/examples/10.StarterKit/p12_KnockLock/p12_KnockLock.ino
index 6c0cbb427..042cdec8e 100644
--- a/build/shared/examples/10.StarterKit/p12_KnockLock/p12_KnockLock.ino
+++ b/build/shared/examples/10.StarterKit/p12_KnockLock/p12_KnockLock.ino
@@ -21,7 +21,7 @@
by Scott Fitzgerald
Thanks to Federico Vanzati for improvements
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
@@ -140,6 +140,8 @@ void loop() {
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
Serial.println("the box is unlocked!");
+
+ numberOfKnocks = 0;
}
}
}
diff --git a/build/shared/examples/10.StarterKit/p13_TouchSensorLamp/p13_TouchSensorLamp.ino b/build/shared/examples/10.StarterKit/p13_TouchSensorLamp/p13_TouchSensorLamp.ino
index 2ba3e9ee6..64e3d22ad 100644
--- a/build/shared/examples/10.StarterKit/p13_TouchSensorLamp/p13_TouchSensorLamp.ino
+++ b/build/shared/examples/10.StarterKit/p13_TouchSensorLamp/p13_TouchSensorLamp.ino
@@ -13,12 +13,12 @@
Software required :
CapacitiveSensor library by Paul Badger
- http://arduino.cc/playground/Main/CapacitiveSensor
+ http://www.arduino.cc/playground/Main/CapacitiveSensor
Created 18 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/examples/10.StarterKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino b/build/shared/examples/10.StarterKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino
index a6a2b0d02..a1e94ebc4 100644
--- a/build/shared/examples/10.StarterKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino
+++ b/build/shared/examples/10.StarterKit/p14_TweakTheArduinoLogo/p14_TweakTheArduinoLogo.ino
@@ -15,7 +15,7 @@
Created 18 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
@@ -55,7 +55,7 @@ void loop() {
colorMode(HSB, 255);
// load the Arduino logo into the PImage instance
- logo = loadImage("http://arduino.cc/en/pub/skins/arduinoWide/img/logo.png");
+ logo = loadImage("http://www.arduino.cc/en/pub/skins/arduinoWide/img/logo.png");
// make the window the same size as the image
size(logo.width, logo.height);
diff --git a/build/shared/examples/10.StarterKit/p15_HackingButtons/p15_HackingButtons.ino b/build/shared/examples/10.StarterKit/p15_HackingButtons/p15_HackingButtons.ino
index 9e2ebcbcf..73d52234b 100644
--- a/build/shared/examples/10.StarterKit/p15_HackingButtons/p15_HackingButtons.ino
+++ b/build/shared/examples/10.StarterKit/p15_HackingButtons/p15_HackingButtons.ino
@@ -13,7 +13,7 @@
Created 18 September 2012
by Scott Fitzgerald
- http://arduino.cc/starterKit
+ http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
diff --git a/build/shared/lib/keywords.txt b/build/shared/lib/keywords.txt
index a362fc358..e66da1a1c 100644
--- a/build/shared/lib/keywords.txt
+++ b/build/shared/lib/keywords.txt
@@ -67,6 +67,7 @@ public LITERAL2 RESERVED_WORD_2
short LITERAL2 RESERVED_WORD_2
signed LITERAL2 RESERVED_WORD_2
static LITERAL2 Static RESERVED_WORD_2
+goto LITERAL2 RESERVED_WORD_2
String LITERAL2 String RESERVED_WORD_2
void LITERAL2 Void RESERVED_WORD_2
true LITERAL2 LITERAL_BOOLEAN
diff --git a/build/shared/lib/theme/theme.txt b/build/shared/lib/theme/theme.txt
index 757449f21..17d66d75a 100644
--- a/build/shared/lib/theme/theme.txt
+++ b/build/shared/lib/theme/theme.txt
@@ -97,10 +97,11 @@ editor.literal1.style = #006699,plain
editor.literal2.style = #00979C,plain
editor.variable.style = #00979C,plain
editor.reserved_word_2.style = #00979C,plain
+editor.literal_boolean.style = #00979C,plain
editor.literal_char.style = #00979C,plain
editor.literal_string_double_quote.style = #00979C,plain
-# http://arduino.cc/
+# http://www.arduino.cc/
editor.url.style = #0000ff,underlined
# e.g. + - = /
diff --git a/build/shared/manpage.adoc b/build/shared/manpage.adoc
index 53a23aa6f..541a431b6 100644
--- a/build/shared/manpage.adoc
+++ b/build/shared/manpage.adoc
@@ -27,7 +27,7 @@ SYNOPSIS
*arduino* [*--verify*|*--upload*] [*--board* __package__:__arch__:__board__[:__parameters__]] [*--port* __portname__] [*--pref* __name__=__value__] [*-v*|*--verbose*] [--preserve-temp-files] [__FILE.ino__]
-*arduino* [*--get-pref* __preference__]
+*arduino* [*--get-pref* [__preference__]]
*arduino* [*--install-boards* __package name__:__platform architecture__[:__version__]]
@@ -63,10 +63,11 @@ ACTIONS
*--upload*::
Build and upload the sketch.
-*--get-pref* __preference__::
+*--get-pref* [__preference__]::
Prints the value of the given preference to the standard output
stream. When the value does not exist, nothing is printed and
the exit status is set (see EXIT STATUS below).
+ If no preference is given as parameter, it prints all preferences.
*--install-boards* __package name__:__platform architecture__[:__version__]::
Fetches available board support (platform) list and install the specified one, along with its related tools. If __version__ is omitted, the latest is installed. If a platform with the same version is already installed, nothing is installed and program exits with exit code 1. If a platform with a different version is already installed, it's replaced.
@@ -333,7 +334,7 @@ HISTORY
RESOURCES
---------
-Web site:
+Web site:
Help on projects and programming:
diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt
index 525d9a7f2..84e04686f 100644
--- a/build/shared/revisions.txt
+++ b/build/shared/revisions.txt
@@ -1,4 +1,11 @@
-ARDUINO 1.6.5
+ARDUINO 1.6.6
+
+ARDUINO 1.6.5-r2 - 2015.06.17
+
+[ide]
+* Windows: fixed a problem that prevented opening the IDE when double clicking a .ino file
+
+ARDUINO 1.6.5 - 2015.06.15
[ide]
* File, Sketch and Tools menu items are properly handled when switching between different windows
@@ -6,12 +13,41 @@ ARDUINO 1.6.5
* New editor, based on RSyntaxTextArea. Thanks @ricardojlrufino
* New keywords. Thanks @Chris--A
* Easier "additional boards manager url" field: a wide text area opens by clicking the added button (right side of the text field)
+* Rewritten code of Preferences window: its content is now correctly drawn on every OS
+* Fixed a bug that made the IDE notify users of invalid libraries too many times. Thanks @Chris--A
+* Removed JNA. Less native stuff and less chances of incurring into an UnsatisfiedLinkError
+* Many new and old issues closed. Thanks to many, and @Chris--A in particular
+* Faster libraries list update
+* Serial monitor stays opened during upload, disabled. Thanks @avishorp and @Wackerbarth
+* CLI: --get-pref can now be called without a pref name. If pref name is missing, IDE dumps all preferences
+* Holding SHIFT when hovering the save icon will trigger a "Save As"
+* Removed proxy settings from File > Preferences: IDE will use system settings
+* Linux versions bundle the latest JVM, 1.8.0_45
+* Local docs: if your sketch has a "docs" folder, you can add local links to it. For example file://./docs/index.html
+ will use your browser to open file index.html from the "docs" folder of your sketch
+* When using "external editor" mode, sketch code is updated when the IDE gets focused
+* Added keyboard shortcuts to IDE menus: ALT+F for File, ALT+E for Edit and so on
+* Added support for Dangerous Prototypes Bus Pirate as ISP
+* Added "Close" button to Boards/Libs Managers, in order to help linux people with weird Window Managers
+* Added File > Open Recent menu, showing the last 5 opened sketches
+* Windows: added Arduino Zero drivers
+* Tons of minor fixes
[libraries]
* LiquidCrystal fixes. Thanks @newbie15
+* Added SPI Transactions to TFT lib
+* Stepper: support for 5-phase/5-wires motors. Thanks @rdodesigns
+* Stepper: increased precision in timing calculations. Thanks @ekozlenko
+* Firmata and Temboo: dropped our vesions, tagged released are downloaded from their respective git repos
[core]
-* SAM: added watchdog routing for Due. Thanks @bobc
+* AVR: delayMicroseconds(..) doesn't hang if called with 0. Thanks @cano64
+* AVR: delayMicroseconds(..), added support for 1Mhz, 12Mhz and 24Mhz. Thanks @cano64
+* AVR: added missing case in detachInterrupt(). Thanks @leres, @vicatcu
+* SAM: added watchdog routine for Due. Thanks @bobc
+* AVR+SAM: reworked pulseIn() function to become GCC agnostic
+* AVR+SAM: added pulseInLong() (based on micros()) to help getting good results in interrupt-prone environments
+* AVR: fixed regression in HardwareSerial.flush(). Thanks @chromhelm
ARDUINO 1.6.4 - 2015.05.06
@@ -63,6 +99,7 @@ ARDUINO 1.6.2 - 2015.03.28
* Introduced starting splashscreen with progress status: will be used for notifying user of long running startup tasks
* Available ports list is now generated in background: hence "tools" menu is much faster
* MacOSX: appbundler merged our contribution, switching to upstream version https://bitbucket.org/infinitekind/appbundler/
+* MacOSX: filtering /dev/cu* was not a good idea. Filtering /dev/tty* instead
[core]
* Stream: fixed bug in findUntil routine #2591 @Xuth
@@ -493,7 +530,7 @@ ARDUINO 1.5 BETA - 2012.10.22
* Everything is in beta, most features or libraries are still missing
or incomplete.
* For more info refer to this press release:
- http://arduino.cc/blog/2012/10/22/arduino-1-5-support-for-the-due-and-other-processors-easier-library-installation-simplified-board-menu-etc/
+ http://www.arduino.cc/blog/2012/10/22/arduino-1-5-support-for-the-due-and-other-processors-easier-library-installation-simplified-board-menu-etc/
ARDUINO 1.0.7
@@ -725,7 +762,7 @@ ARDUINO 1.0.1 - 2012.05.21
* The IDE has been internationalized and translated into multiple languages.
Thanks to Shigeru Kanemoto for the internationalization and Japanese
translation and many others for the other translations. For more
- information, see: http://arduino.cc/playground/Main/LanguagesIDE
+ information, see: http://www.arduino.cc/playground/Main/LanguagesIDE
* Added preference for selecting the language in which to display the
Arduino software. Defaults to the operating system locale.
@@ -980,7 +1017,7 @@ ARDUINO 0022 - 2010.12.24
* Adding an SD card library based on sdfatlib by Bill Greiman and the
MemoryCard library by Philip Lindsay (follower) for SparkFun.
- http://arduino.cc/en/Reference/SD
+ http://www.arduino.cc/en/Reference/SD
* Added character manipulation macros (from Wiring): isAlphaNumeric(),
isAlpha(), isAscii(), isWhitespace(), isControl(), isDigit(), isGraph(),
diff --git a/build/windows/dist/drivers/arduino.cat b/build/windows/dist/drivers/arduino.cat
index 228c7104f..4d0aab7ac 100644
Binary files a/build/windows/dist/drivers/arduino.cat and b/build/windows/dist/drivers/arduino.cat differ
diff --git a/build/windows/dist/drivers/arduino.inf b/build/windows/dist/drivers/arduino.inf
index 1bb76ede1..dafa8b013 100644
--- a/build/windows/dist/drivers/arduino.inf
+++ b/build/windows/dist/drivers/arduino.inf
@@ -1,10 +1,37 @@
-; Copyright 2012 Blacklabel Development, Inc.
+;
+; Copyright 2015 Arduino LLC (http://www.arduino.cc/)
+;
+; Developed by Zach Eveland, Blacklabel Development, Inc.
+;
+; Arduino is free software; you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation; either version 2 of the License, or
+; (at your option) any later version.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+;
+; As a special exception, you may use this file as part of a free software
+; library without restriction. Specifically, if other files instantiate
+; templates or use macros or inline functions from this file, or you compile
+; this file and link it with other files to produce an executable, this
+; file does not by itself cause the resulting executable to be covered by
+; the GNU General Public License. This exception does not however
+; invalidate any other reasons why the executable file might be covered by
+; the GNU General Public License.
+;
[Strings]
DriverPackageDisplayName="Arduino USB Driver"
ManufacturerName="Arduino LLC (www.arduino.cc)"
ServiceName="USB RS-232 Emulation Driver"
-due.bossa.name="Bossa Program Port"
+bossa.name="Bossa Program Port"
due.programming_port.name="Arduino Due Programming Port"
due.sketch.name="Arduino Due"
esplora.bootloader.name="Arduino Esplora bootloader"
@@ -19,15 +46,20 @@ megaADK.name="Arduino Mega ADK"
megaADKrev3.name="Arduino Mega ADK"
micro.bootloader.name="Arduino Micro bootloader"
micro.sketch.name="Arduino Micro"
-uno.name="Arduino Uno"
-unoR3.name="Arduino Uno"
-usbserial.name="Arduino USB Serial Light Adapter"
robotControl.bootloader.name="Arduino Robot Control bootloader"
robotControl.sketch.name="Arduino Robot"
robotMotor.bootloader.name="Arduino Robot Motor bootloader"
robotMotor.sketch.name="Arduino Robot"
+uno.name="Arduino Uno"
+unoR3.name="Arduino Uno"
+usbserial.name="Arduino USB Serial Light Adapter"
yun.bootloader.name="Arduino Yun bootloader"
yun.sketch.name="Arduino Yun"
+zero.edbg.name="Atmel Corp. EDBG CMSIS-DAP"
+zero.sketch.name="Arduino Zero"
+zero.bootloader.name="Arduino Zero bootloader"
+sme_fox.sketch.name="SmartEverything Fox"
+sme_fox.bootloader.name="SmartEverything Fox bootloader"
[DefaultInstall]
CopyINF=arduino.inf
@@ -39,7 +71,7 @@ Signature="$Windows NT$"
Provider=%ManufacturerName%
DriverPackageDisplayName=%DriverPackageDisplayName%
CatalogFile=arduino.cat
-DriverVer=01/04/2013,1.0.0.0
+DriverVer=06/15/2015,1.2.2.0
[Manufacturer]
%ManufacturerName%=DeviceList, NTamd64, NTia64
@@ -49,7 +81,7 @@ FakeModemCopyFileSection=12
DefaultDestDir=12
[DeviceList]
-%due.bossa.name%=DriverInstall, USB\VID_03EB&PID_6124
+%bossa.name%=DriverInstall, USB\VID_03EB&PID_6124
%due.programming_port.name%=DriverInstall, USB\VID_2341&PID_003D
%due.sketch.name%=DriverInstall, USB\VID_2341&PID_003E&MI_00
%esplora.bootloader.name%=DriverInstall, USB\VID_2341&PID_003C
@@ -64,18 +96,23 @@ DefaultDestDir=12
%megaADKrev3.name%=DriverInstall, USB\VID_2341&PID_0044
%micro.bootloader.name%=DriverInstall, USB\VID_2341&PID_0037
%micro.sketch.name%=DriverInstall, USB\VID_2341&PID_8037&MI_00
-%uno.name%=DriverInstall, USB\VID_2341&PID_0001
-%unoR3.name%=DriverInstall, USB\VID_2341&PID_0043
-%usbserial.name%=DriverInstall, USB\VID_2341&PID_003B
%robotControl.bootloader.name%=DriverInstall, USB\VID_2341&PID_0038
%robotControl.sketch.name%=DriverInstall, USB\VID_2341&PID_8038&MI_00
%robotMotor.bootloader.name%=DriverInstall, USB\VID_2341&PID_0039
%robotMotor.sketch.name%=DriverInstall, USB\VID_2341&PID_8039&MI_00
+%uno.name%=DriverInstall, USB\VID_2341&PID_0001
+%unoR3.name%=DriverInstall, USB\VID_2341&PID_0043
+%usbserial.name%=DriverInstall, USB\VID_2341&PID_003B
%yun.bootloader.name%=DriverInstall, USB\VID_2341&PID_0041
%yun.sketch.name%=DriverInstall, USB\VID_2341&PID_8041&MI_00
+%zero.edbg.name%=DriverInstall, USB\VID_03EB&PID_2157&MI_01
+%zero.sketch.name%=DriverInstall, USB\VID_2341&PID_804D&MI_00
+%zero.bootloader.name%=DriverInstall, USB\VID_2341&PID_004D
+%sme_fox.sketch.name%=DriverInstall, USB\VID_2341&PID_E002&MI_00
+%sme_fox.bootloader.name%=DriverInstall, USB\VID_2341&PID_E001
[DeviceList.NTamd64]
-%due.bossa.name%=DriverInstall, USB\VID_03EB&PID_6124
+%bossa.name%=DriverInstall, USB\VID_03EB&PID_6124
%due.programming_port.name%=DriverInstall, USB\VID_2341&PID_003D
%due.sketch.name%=DriverInstall, USB\VID_2341&PID_003E&MI_00
%esplora.bootloader.name%=DriverInstall, USB\VID_2341&PID_003C
@@ -99,8 +136,16 @@ DefaultDestDir=12
%robotMotor.sketch.name%=DriverInstall, USB\VID_2341&PID_8039&MI_00
%yun.bootloader.name%=DriverInstall, USB\VID_2341&PID_0041
%yun.sketch.name%=DriverInstall, USB\VID_2341&PID_8041&MI_00
+%zero.edbg.name%=DriverInstall, USB\VID_03EB&PID_2157&MI_01
+%zero.sketch.name%=DriverInstall, USB\VID_2341&PID_804D&MI_00
+%zero.bootloader.name%=DriverInstall, USB\VID_2341&PID_004D
+%sme_fox.sketch.name%=DriverInstall, USB\VID_2341&PID_E002&MI_00
+%sme_fox.bootloader.name%=DriverInstall, USB\VID_2341&PID_E001
[DeviceList.NTia64]
+%bossa.name%=DriverInstall, USB\VID_03EB&PID_6124
+%due.programming_port.name%=DriverInstall, USB\VID_2341&PID_003D
+%due.sketch.name%=DriverInstall, USB\VID_2341&PID_003E&MI_00
%esplora.bootloader.name%=DriverInstall, USB\VID_2341&PID_003C
%esplora.sketch.name%=DriverInstall, USB\VID_2341&PID_803C&MI_00
%leonardo.bootloader.name%=DriverInstall, USB\VID_2341&PID_0036
@@ -122,6 +167,11 @@ DefaultDestDir=12
%robotMotor.sketch.name%=DriverInstall, USB\VID_2341&PID_8039&MI_00
%yun.bootloader.name%=DriverInstall, USB\VID_2341&PID_0041
%yun.sketch.name%=DriverInstall, USB\VID_2341&PID_8041&MI_00
+%zero.edbg.name%=DriverInstall, USB\VID_03EB&PID_2157&MI_01
+%zero.sketch.name%=DriverInstall, USB\VID_2341&PID_804D&MI_00
+%zero.bootloader.name%=DriverInstall, USB\VID_2341&PID_004D
+%sme_fox.sketch.name%=DriverInstall, USB\VID_2341&PID_E002&MI_00
+%sme_fox.bootloader.name%=DriverInstall, USB\VID_2341&PID_E001
[DriverInstall]
include=mdmcpq.inf,usb.inf
diff --git a/build/windows/launcher/config.xml b/build/windows/launcher/config.xml
index 3969ae60a..1df6d0e0b 100644
--- a/build/windows/launcher/config.xml
+++ b/build/windows/launcher/config.xml
@@ -3,15 +3,9 @@
gui
lib
arduino.exe
-
-
.
- normal
- http://java.sun.com/javase/downloads/
-
- false
- false
-
+ Arduino
+ http://www.oracle.com/technetwork/java/javase/downloads/index.html
application.ico
processing.app.Base
@@ -34,7 +28,6 @@
lib/jackson-module-mrbean-2.2.3.jar
lib/java-semver-0.8.0.jar
lib/jmdns-3.4.1.jar
- lib/jna.jar
lib/jsch-0.1.50.jar
lib/jssc-2.8.0.jar
lib/pde.jar
@@ -46,6 +39,14 @@
-splash:./lib/splash.png
-Dsun.java2d.d3d=false
+
+ Arduino IDE
+ Arduino LLC
+ Arduino
+ Arduino LLC
+ arduino
+ arduino.exe
+
An error occurred while starting the application.
This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted.
diff --git a/build/windows/launcher/config_debug.xml b/build/windows/launcher/config_debug.xml
index b847b893d..69ff6c472 100644
--- a/build/windows/launcher/config_debug.xml
+++ b/build/windows/launcher/config_debug.xml
@@ -3,15 +3,9 @@
console
lib
arduino_debug.exe
-
-
.
- normal
- http://java.sun.com/javase/downloads/
-
- false
- false
-
+ Arduino
+ http://www.oracle.com/technetwork/java/javase/downloads/index.html
application.ico
processing.app.Base
@@ -34,7 +28,6 @@
lib/jackson-module-mrbean-2.2.3.jar
lib/java-semver-0.8.0.jar
lib/jmdns-3.4.1.jar
- lib/jna.jar
lib/jsch-0.1.50.jar
lib/jssc-2.8.0.jar
lib/pde.jar
@@ -45,6 +38,14 @@
32
-Dsun.java2d.d3d=false
+
+ Arduino IDE
+ Arduino LLC
+ Arduino
+ Arduino LLC
+ arduino
+ arduino.exe
+
An error occurred while starting the application.
This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted.
diff --git a/hardware/arduino/avr/bootloaders/gemma/README.md b/hardware/arduino/avr/bootloaders/gemma/README.md
new file mode 100644
index 000000000..2653e48c6
--- /dev/null
+++ b/hardware/arduino/avr/bootloaders/gemma/README.md
@@ -0,0 +1,14 @@
+Arduino Gemma Bootloader
+========================
+
+The Arduino Gemma Bootloader is based on the Adafruit Trinket/Gemma Bootloader. In the Arduino Gemma bootloader the USB VID&PID, the Manufacturer name and the Device name parameters are changed.
+
+The source code of the bootloader of the version used at the compile time can be found at the following link: https://github.com/adafruit/Adafruit-Trinket-Gemma-Bootloader/tree/3bc1bb561273535d4d493518a233a3a1fccf6b76
+
+The *'usbconfig.h'* and the *'usbconfig.patch'* files are provided if you want to recompile the bootloader.
+You only need to replace the original *'usbconfig.h'* file with this one or patch it with the provided patch file.
+
+**Please note: you cannot use the Arduino USB VID/PID for your own non-Gemma products or projects. Purchase a USB VID for yourself at** http://www.usb.org/developers/vendor/
+
+
+
diff --git a/hardware/arduino/avr/bootloaders/gemma/usbconfig.h b/hardware/arduino/avr/bootloaders/gemma/usbconfig.h
new file mode 100644
index 000000000..ca0c02134
--- /dev/null
+++ b/hardware/arduino/avr/bootloaders/gemma/usbconfig.h
@@ -0,0 +1,351 @@
+/* Name: usbconfig.h
+ * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
+ * Author: Christian Starkjohann
+ * Creation Date: 2005-04-01
+ * Tabsize: 4
+ * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
+ * License: GNU GPL v2 or v3 (see License.txt)
+ */
+
+/* Modified by me@frank-zhao.com for project GemmaBoot
+ *
+ * GemmaBoot is a bootloader that emulates a USBtinyISP (from Adafruit Industries)
+ *
+ * Gemma will use GemmaBoot
+ *
+ * This code is heavily derived from USBaspLoader, but also from USBtiny, with USBtinyISP's settings
+
+ Copyright (c) 2013 Adafruit Industries
+ All rights reserved.
+
+ GemmaBoot is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ GemmaBoot is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with GemmaBoot. If not, see
+ .
+*/
+
+#ifndef __usbconfig_h_included__
+#define __usbconfig_h_included__
+
+/* YOU SHOULD NOT NEED TO MODIFY THIS FILE! All configurations are supposed
+ * to go into bootloaderconfig.h!
+ */
+
+/* ---------------------------- Hardware Config ---------------------------- */
+
+/* All the port and pin assignments, as well as the clock speed and CRC
+ setting are now in bootloaderconfig.h: */
+
+#include "bootloaderconfig.h"
+
+/* --------------------------- Functional Range ---------------------------- */
+
+#define USB_CFG_HAVE_INTRIN_ENDPOINT 0
+/* Define this to 1 if you want to compile a version with two endpoints: The
+ * default control endpoint 0 and an interrupt-in endpoint (any other endpoint
+ * number).
+ */
+#define USB_CFG_HAVE_INTRIN_ENDPOINT3 0
+/* Define this to 1 if you want to compile a version with three endpoints: The
+ * default control endpoint 0, an interrupt-in endpoint 3 (or the number
+ * configured below) and a catch-all default interrupt-in endpoint as above.
+ * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
+ */
+#define USB_CFG_EP3_NUMBER 3
+/* If the so-called endpoint 3 is used, it can now be configured to any other
+ * endpoint number (except 0) with this macro. Default if undefined is 3.
+ */
+/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
+/* The above macro defines the startup condition for data toggling on the
+ * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.
+ * Since the token is toggled BEFORE sending any data, the first packet is
+ * sent with the oposite value of this configuration!
+ */
+#define USB_CFG_IMPLEMENT_HALT 0
+/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
+ * for endpoint 1 (interrupt endpoint). Although you may not need this feature,
+ * it is required by the standard. We have made it a config option because it
+ * bloats the code considerably.
+ */
+#define USB_CFG_SUPPRESS_INTR_CODE 0
+/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
+ * want to send any data over them. If this macro is defined to 1, functions
+ * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
+ * you need the interrupt-in endpoints in order to comply to an interface
+ * (e.g. HID), but never want to send any data. This option saves a couple
+ * of bytes in flash memory and the transmit buffers in RAM.
+ */
+#define USB_CFG_INTR_POLL_INTERVAL 10
+/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
+ * interval. The value is in milliseconds and must not be less than 10 ms for
+ * low speed devices.
+ */
+#ifndef USB_CFG_IS_SELF_POWERED // allow bootloaderconfig.h to override
+#define USB_CFG_IS_SELF_POWERED 0
+#endif
+/* Define this to 1 if the device has its own power supply. Set it to 0 if the
+ * device is powered from the USB bus.
+ */
+#ifndef USB_CFG_MAX_BUS_POWER // allow bootloaderconfig.h to override
+#define USB_CFG_MAX_BUS_POWER 100
+#endif
+/* Set this variable to the maximum USB bus power consumption of your device.
+ * The value is in milliamperes. [It will be divided by two since USB
+ * communicates power requirements in units of 2 mA.]
+ */
+#define USB_CFG_IMPLEMENT_FN_WRITE 1
+/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
+ * transfers. Set it to 0 if you don't need it and want to save a couple of
+ * bytes.
+ */
+#define USB_CFG_IMPLEMENT_FN_READ 1
+/* Set this to 1 if you need to send control replies which are generated
+ * "on the fly" when usbFunctionRead() is called. If you only want to send
+ * data from a static buffer, set it to 0 and return the data from
+ * usbFunctionSetup(). This saves a couple of bytes.
+ */
+#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
+/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
+ * You must implement the function usbFunctionWriteOut() which receives all
+ * interrupt/bulk data sent to any endpoint other than 0. The endpoint number
+ * can be found in 'usbRxToken'.
+ */
+#define USB_CFG_HAVE_FLOWCONTROL 0
+/* Define this to 1 if you want flowcontrol over USB data. See the definition
+ * of the macros usbDisableAllRequests() and usbEnableAllRequests() in
+ * usbdrv.h.
+ */
+#define USB_CFG_DRIVER_FLASH_PAGE 0
+/* If the device has more than 64 kBytes of flash, define this to the 64 k page
+ * where the driver's constants (descriptors) are located. Or in other words:
+ * Define this to 1 for boot loaders on the ATMega128.
+ */
+#define USB_CFG_LONG_TRANSFERS 0
+/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
+ * in a single control-in or control-out transfer. Note that the capability
+ * for long transfers increases the driver size.
+ */
+#ifndef __ASSEMBLER__
+extern volatile char usbHasRxed;
+#endif
+#define USB_RX_USER_HOOK(data, len) do { usbHasRxed = 1; } while (0);
+/* This macro is a hook if you want to do unconventional things. If it is
+ * defined, it's inserted at the beginning of received message processing.
+ * If you eat the received message and don't want default processing to
+ * proceed, do a return after doing your things. One possible application
+ * (besides debugging) is to flash a status LED on each packet.
+ */
+/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */
+/* This macro is a hook if you need to know when an USB RESET occurs. It has
+ * one parameter which distinguishes between the start of RESET state and its
+ * end.
+ */
+/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */
+/* This macro (if defined) is executed when a USB SET_ADDRESS request was
+ * received.
+ */
+#define USB_COUNT_SOF 0
+/* define this macro to 1 if you need the global variable "usbSofCount" which
+ * counts SOF packets. This feature requires that the hardware interrupt is
+ * connected to D- instead of D+.
+ */
+/* #ifdef __ASSEMBLER__
+ * macro myAssemblerMacro
+ * in YL, TCNT0
+ * sts timer0Snapshot, YL
+ * endm
+ * #endif
+ * #define USB_SOF_HOOK myAssemblerMacro
+ * This macro (if defined) is executed in the assembler module when a
+ * Start Of Frame condition is detected. It is recommended to define it to
+ * the name of an assembler macro which is defined here as well so that more
+ * than one assembler instruction can be used. The macro may use the register
+ * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
+ * immediately after an SOF pulse may be lost and must be retried by the host.
+ * What can you do with this hook? Since the SOF signal occurs exactly every
+ * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
+ * designs running on the internal RC oscillator.
+ * Please note that Start Of Frame detection works only if D- is wired to the
+ * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
+ */
+#define USB_CFG_CHECK_DATA_TOGGLING 0
+/* define this macro to 1 if you want to filter out duplicate data packets
+ * sent by the host. Duplicates occur only as a consequence of communication
+ * errors, when the host does not receive an ACK. Please note that you need to
+ * implement the filtering yourself in usbFunctionWriteOut() and
+ * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
+ * for each control- and out-endpoint to check for duplicate packets.
+ */
+#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 1
+/* define this macro to 1 if you want the function usbMeasureFrameLength()
+ * compiled in. This function can be used to calibrate the AVR's RC oscillator.
+ */
+#define USB_USE_FAST_CRC 0
+/* The assembler module has two implementations for the CRC algorithm. One is
+ * faster, the other is smaller. This CRC routine is only used for transmitted
+ * messages where timing is not critical. The faster routine needs 31 cycles
+ * per byte while the smaller one needs 61 to 69 cycles. The faster routine
+ * may be worth the 32 bytes bigger code size if you transmit lots of data and
+ * run the AVR close to its limit.
+ */
+
+/* -------------------------- Device Description --------------------------- */
+
+#define USB_CFG_VENDOR_ID 0x41, 0x23 /* = 0x16c0 = 5824 = voti.nl */
+/* USB vendor ID for the device, low byte first. If you have registered your
+ * own Vendor ID, define it here. Otherwise you may use one of obdev's free
+ * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
+ */
+#define USB_CFG_DEVICE_ID 0x9F, 0x0c /* = 0x05dc = 1500 */
+/* This is the ID of the product, low byte first. It is interpreted in the
+ * scope of the vendor ID. If you have registered your own VID with usb.org
+ * or if you have licensed a PID from somebody else, define it here. Otherwise
+ * you may use one of obdev's free shared VID/PID pairs. See the file
+ * USB-IDs-for-free.txt for details!
+ */
+#define USB_CFG_DEVICE_VERSION 0x00, 0x01
+/* Version number of the device: Minor number first, then major number.
+ */
+#define USB_CFG_VENDOR_NAME 'A','r','d','u','i','n','o','.','c','c'
+#define USB_CFG_VENDOR_NAME_LEN 10
+/* These two values define the vendor name returned by the USB device. The name
+ * must be given as a list of characters under single quotes. The characters
+ * are interpreted as Unicode (UTF-16) entities.
+ * If you don't want a vendor name string, undefine these macros.
+ * ALWAYS define a vendor name containing your Internet domain name if you use
+ * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
+ * details.
+ */
+#define USB_CFG_DEVICE_NAME 'G','e','m','m','a'
+#define USB_CFG_DEVICE_NAME_LEN 5
+/* Same as above for the device name. If you don't want a device name, undefine
+ * the macros. See the file USB-IDs-for-free.txt before you assign a name if
+ * you use a shared VID/PID.
+ */
+/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
+/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
+/* Same as above for the serial number. If you don't want a serial number,
+ * undefine the macros.
+ * It may be useful to provide the serial number through other means than at
+ * compile time. See the section about descriptor properties below for how
+ * to fine tune control over USB descriptors such as the string descriptor
+ * for the serial number.
+ */
+#define USB_CFG_DEVICE_CLASS 0xFF /* set to 0 if deferred to interface */
+#define USB_CFG_DEVICE_SUBCLASS 0
+/* See USB specification if you want to conform to an existing device class.
+ * Class 0xff is "vendor specific".
+ */
+#define USB_CFG_INTERFACE_CLASS 0 /* define class here if not at device level */
+#define USB_CFG_INTERFACE_SUBCLASS 0
+#define USB_CFG_INTERFACE_PROTOCOL 0
+/* See USB specification if you want to conform to an existing device class or
+ * protocol. The following classes must be set at interface level:
+ * HID class is 3, no subclass and protocol required (but may be useful!)
+ * CDC class is 2, use subclass 2 and protocol 1 for ACM
+ */
+/* #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 42 */
+/* Define this to the length of the HID report descriptor, if you implement
+ * an HID device. Otherwise don't define it or define it to 0.
+ * If you use this define, you must add a PROGMEM character array named
+ * "usbHidReportDescriptor" to your code which contains the report descriptor.
+ * Don't forget to keep the array and this define in sync!
+ */
+
+#define USB_PUBLIC static
+/* Use the define above if you #include usbdrv.c instead of linking against it.
+ * This technique saves a couple of bytes in flash memory.
+ */
+
+/* ------------------- Fine Control over USB Descriptors ------------------- */
+/* If you don't want to use the driver's default USB descriptors, you can
+ * provide our own. These can be provided as (1) fixed length static data in
+ * flash memory, (2) fixed length static data in RAM or (3) dynamically at
+ * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
+ * information about this function.
+ * Descriptor handling is configured through the descriptor's properties. If
+ * no properties are defined or if they are 0, the default descriptor is used.
+ * Possible properties are:
+ * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
+ * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is
+ * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if
+ * you want RAM pointers.
+ * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
+ * in static memory is in RAM, not in flash memory.
+ * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
+ * the driver must know the descriptor's length. The descriptor itself is
+ * found at the address of a well known identifier (see below).
+ * List of static descriptor names (must be declared PROGMEM if in flash):
+ * char usbDescriptorDevice[];
+ * char usbDescriptorConfiguration[];
+ * char usbDescriptorHidReport[];
+ * char usbDescriptorString0[];
+ * int usbDescriptorStringVendor[];
+ * int usbDescriptorStringDevice[];
+ * int usbDescriptorStringSerialNumber[];
+ * Other descriptors can't be provided statically, they must be provided
+ * dynamically at runtime.
+ *
+ * Descriptor properties are or-ed or added together, e.g.:
+ * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
+ *
+ * The following descriptors are defined:
+ * USB_CFG_DESCR_PROPS_DEVICE
+ * USB_CFG_DESCR_PROPS_CONFIGURATION
+ * USB_CFG_DESCR_PROPS_STRINGS
+ * USB_CFG_DESCR_PROPS_STRING_0
+ * USB_CFG_DESCR_PROPS_STRING_VENDOR
+ * USB_CFG_DESCR_PROPS_STRING_PRODUCT
+ * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
+ * USB_CFG_DESCR_PROPS_HID
+ * USB_CFG_DESCR_PROPS_HID_REPORT
+ * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
+ *
+ * Note about string descriptors: String descriptors are not just strings, they
+ * are Unicode strings prefixed with a 2 byte header. Example:
+ * int serialNumberDescriptor[] = {
+ * USB_STRING_DESCRIPTOR_HEADER(6),
+ * 'S', 'e', 'r', 'i', 'a', 'l'
+ * };
+ */
+
+#define USB_CFG_DESCR_PROPS_DEVICE 0
+#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
+#define USB_CFG_DESCR_PROPS_STRINGS 0
+#define USB_CFG_DESCR_PROPS_STRING_0 0
+#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
+#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
+#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
+#define USB_CFG_DESCR_PROPS_HID 0
+#define USB_CFG_DESCR_PROPS_HID_REPORT 0
+#define USB_CFG_DESCR_PROPS_UNKNOWN 0
+
+#define usbMsgPtr_t unsigned short // scalar type yields shortest code
+
+/* ----------------------- Optional MCU Description ------------------------ */
+
+/* The following configurations have working defaults in usbdrv.h. You
+ * usually don't need to set them explicitly. Only if you want to run
+ * the driver on a device which is not yet supported or with a compiler
+ * which is not fully supported (such as IAR C) or if you use a differnt
+ * interrupt than INT0, you may have to define some of these.
+ */
+#define USB_INTR_CFG PCMSK
+#define USB_INTR_CFG_SET (1 << USB_CFG_DPLUS_BIT)
+#define USB_INTR_CFG_CLR 0
+#define USB_INTR_ENABLE GIMSK
+#define USB_INTR_ENABLE_BIT PCIE
+#define USB_INTR_PENDING GIFR
+#define USB_INTR_PENDING_BIT PCIF
+#define USB_INTR_VECTOR PCINT0_vect
+
+#endif /* __usbconfig_h_included__ */
diff --git a/hardware/arduino/avr/bootloaders/gemma/usbconfig.patch b/hardware/arduino/avr/bootloaders/gemma/usbconfig.patch
new file mode 100644
index 000000000..1abb15832
--- /dev/null
+++ b/hardware/arduino/avr/bootloaders/gemma/usbconfig.patch
@@ -0,0 +1,24 @@
+203c203
+< #define USB_CFG_VENDOR_ID 0x81, 0x17 /* = 0x16c0 = 5824 = voti.nl */
+---
+> #define USB_CFG_VENDOR_ID 0x41, 0x23 /* = 0x16c0 = 5824 = voti.nl */
+208c208
+< #define USB_CFG_DEVICE_ID 0x9F, 0x0C /* = 0x05dc = 1500 */
+---
+> #define USB_CFG_DEVICE_ID 0x9F, 0x0c /* = 0x05dc = 1500 */
+215c215
+< #define USB_CFG_DEVICE_VERSION 0x05, 0x01
+---
+> #define USB_CFG_DEVICE_VERSION 0x00, 0x01
+218,219c218,219
+< #define USB_CFG_VENDOR_NAME 'A','d','a','f','r','u','i','t'
+< #define USB_CFG_VENDOR_NAME_LEN 8
+---
+> #define USB_CFG_VENDOR_NAME 'A','r','d','u','i','n','o','.','c','c'
+> #define USB_CFG_VENDOR_NAME_LEN 10
+228,229c228,229
+< #define USB_CFG_DEVICE_NAME 'T','r','i','n','k','e','t'
+< #define USB_CFG_DEVICE_NAME_LEN 7
+---
+> #define USB_CFG_DEVICE_NAME 'G','e','m','m','a'
+> #define USB_CFG_DEVICE_NAME_LEN 5
diff --git a/hardware/arduino/avr/bootloaders/optiboot/optiboot.c b/hardware/arduino/avr/bootloaders/optiboot/optiboot.c
index d499d85e8..41545b777 100644
--- a/hardware/arduino/avr/bootloaders/optiboot/optiboot.c
+++ b/hardware/arduino/avr/bootloaders/optiboot/optiboot.c
@@ -50,7 +50,7 @@
/* */
/* Code builds on code, libraries and optimisations from: */
/* stk500boot.c by Jason P. Kyle */
-/* Arduino bootloader http://arduino.cc */
+/* Arduino bootloader http://www.arduino.cc */
/* Spiff's 1K bootloader http://spiffie.org/know/arduino_1k_bootloader/bootloader.shtml */
/* avr-libc project http://nongnu.org/avr-libc */
/* Adaboot http://www.ladyada.net/library/arduino/bootloader.html */
diff --git a/hardware/arduino/avr/cores/arduino/Arduino.h b/hardware/arduino/avr/cores/arduino/Arduino.h
index 16dd759b3..f1da68da7 100644
--- a/hardware/arduino/avr/cores/arduino/Arduino.h
+++ b/hardware/arduino/avr/cores/arduino/Arduino.h
@@ -134,6 +134,7 @@ unsigned long micros(void);
void delay(unsigned long);
void delayMicroseconds(unsigned int us);
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
+unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
@@ -232,6 +233,7 @@ uint16_t makeWord(byte h, byte l);
#define word(...) makeWord(__VA_ARGS__)
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
+unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
void noTone(uint8_t _pin);
@@ -239,7 +241,7 @@ void noTone(uint8_t _pin);
// WMath prototypes
long random(long);
long random(long, long);
-void randomSeed(unsigned int);
+void randomSeed(unsigned long);
long map(long, long, long, long, long);
#endif
diff --git a/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp b/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp
index 41935e320..a2029a8b0 100644
--- a/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp
+++ b/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp
@@ -213,6 +213,7 @@ void HardwareSerial::flush()
size_t HardwareSerial::write(uint8_t c)
{
+ _written = true;
// If the buffer and the data register is empty, just write the byte
// to the data register and be done. This shortcut helps
// significantly improve the effective datarate at high (>
@@ -243,10 +244,8 @@ size_t HardwareSerial::write(uint8_t c)
_tx_buffer_head = i;
sbi(*_ucsrb, UDRIE0);
- _written = true;
return 1;
}
-
#endif // whole file
diff --git a/hardware/arduino/avr/cores/arduino/Print.cpp b/hardware/arduino/avr/cores/arduino/Print.cpp
index 5df56306e..782d50b4e 100644
--- a/hardware/arduino/avr/cores/arduino/Print.cpp
+++ b/hardware/arduino/avr/cores/arduino/Print.cpp
@@ -122,9 +122,7 @@ size_t Print::print(const Printable& x)
size_t Print::println(void)
{
- size_t n = print('\r');
- n += print('\n');
- return n;
+ return write("\r\n");
}
size_t Print::println(const String &s)
diff --git a/hardware/arduino/avr/cores/arduino/Stream.h b/hardware/arduino/avr/cores/arduino/Stream.h
index a8101320c..15f6761f0 100644
--- a/hardware/arduino/avr/cores/arduino/Stream.h
+++ b/hardware/arduino/avr/cores/arduino/Stream.h
@@ -64,6 +64,8 @@ class Stream : public Print
bool find(uint8_t *target, size_t length) { return find ((char *)target, length); }
// returns true if target string is found, false if timed out
+ bool find(char target) { return find (&target, 1); }
+
bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found
bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); }
diff --git a/hardware/arduino/avr/cores/arduino/WInterrupts.c b/hardware/arduino/avr/cores/arduino/WInterrupts.c
index d3fbf100e..71dd45cac 100644
--- a/hardware/arduino/avr/cores/arduino/WInterrupts.c
+++ b/hardware/arduino/avr/cores/arduino/WInterrupts.c
@@ -223,6 +223,18 @@ void detachInterrupt(uint8_t interruptNum) {
#warning detachInterrupt may need some more work for this cpu (case 1)
#endif
break;
+
+ case 2:
+ #if defined(EIMSK) && defined(INT2)
+ EIMSK &= ~(1 << INT2);
+ #elif defined(GICR) && defined(INT2)
+ GICR &= ~(1 << INT2); // atmega32
+ #elif defined(GIMSK) && defined(INT2)
+ GIMSK &= ~(1 << INT2);
+ #elif defined(INT2)
+ #warning detachInterrupt may need some more work for this cpu (case 2)
+ #endif
+ break;
#endif
}
diff --git a/hardware/arduino/avr/cores/arduino/WMath.cpp b/hardware/arduino/avr/cores/arduino/WMath.cpp
index 2120c4cc1..214ccdc5f 100644
--- a/hardware/arduino/avr/cores/arduino/WMath.cpp
+++ b/hardware/arduino/avr/cores/arduino/WMath.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "stdlib.h"
}
-void randomSeed(unsigned int seed)
+void randomSeed(unsigned long seed)
{
if (seed != 0) {
srandom(seed);
diff --git a/hardware/arduino/avr/cores/arduino/main.cpp b/hardware/arduino/avr/cores/arduino/main.cpp
index a60980da5..72074de4b 100644
--- a/hardware/arduino/avr/cores/arduino/main.cpp
+++ b/hardware/arduino/avr/cores/arduino/main.cpp
@@ -19,8 +19,8 @@
#include
-//Declared weak in Arduino.h to allow user redefinitions.
-int atexit(void (*func)()) { return 0; }
+// Declared weak in Arduino.h to allow user redefinitions.
+int atexit(void (* /*func*/ )()) { return 0; }
// Weak empty variant initialization function.
// May be redefined by variant files.
diff --git a/hardware/arduino/avr/cores/arduino/wiring.c b/hardware/arduino/avr/cores/arduino/wiring.c
index 5cbe24195..6cb22c003 100644
--- a/hardware/arduino/avr/cores/arduino/wiring.c
+++ b/hardware/arduino/avr/cores/arduino/wiring.c
@@ -92,7 +92,6 @@ unsigned long micros() {
#error TIMER 0 not defined
#endif
-
#ifdef TIFR0
if ((TIFR0 & _BV(TOV0)) && (t < 255))
m++;
@@ -119,65 +118,118 @@ void delay(unsigned long ms)
}
}
-/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock. */
+/* Delay for the given number of microseconds. Assumes a 1, 8, 12, 16, 20 or 24 MHz clock. */
void delayMicroseconds(unsigned int us)
{
+ // call = 4 cycles + 2 to 4 cycles to init us(2 for constant delay, 4 for variable)
+
// calling avrlib's delay_us() function with low values (e.g. 1 or
// 2 microseconds) gives delays longer than desired.
//delay_us(us);
-#if F_CPU >= 20000000L
+#if F_CPU >= 24000000L
+ // for the 24 MHz clock for the aventurous ones, trying to overclock
+
+ // zero delay fix
+ if (!us) return; // = 3 cycles, (4 when true)
+
+ // the following loop takes a 1/6 of a microsecond (4 cycles)
+ // per iteration, so execute it six times for each microsecond of
+ // delay requested.
+ us *= 6; // x6 us, = 7 cycles
+
+ // account for the time taken in the preceeding commands.
+ // we just burned 22 (24) cycles above, remove 5, (5*4=20)
+ // us is at least 6 so we can substract 5
+ us -= 5; //=2 cycles
+
+#elif F_CPU >= 20000000L
// for the 20 MHz clock on rare Arduino boards
- // for a one-microsecond delay, simply wait 2 cycle and return. The overhead
- // of the function call yields a delay of exactly a one microsecond.
+ // for a one-microsecond delay, simply return. the overhead
+ // of the function call takes 18 (20) cycles, which is 1us
__asm__ __volatile__ (
"nop" "\n\t"
- "nop"); //just waiting 2 cycle
- if (--us == 0)
- return;
+ "nop" "\n\t"
+ "nop" "\n\t"
+ "nop"); //just waiting 4 cycles
+ if (us <= 1) return; // = 3 cycles, (4 when true)
// the following loop takes a 1/5 of a microsecond (4 cycles)
// per iteration, so execute it five times for each microsecond of
// delay requested.
- us = (us<<2) + us; // x5 us
+ us = (us << 2) + us; // x5 us, = 7 cycles
// account for the time taken in the preceeding commands.
- us -= 2;
+ // we just burned 26 (28) cycles above, remove 7, (7*4=28)
+ // us is at least 10 so we can substract 7
+ us -= 7; // 2 cycles
#elif F_CPU >= 16000000L
// for the 16 MHz clock on most Arduino boards
// for a one-microsecond delay, simply return. the overhead
- // of the function call yields a delay of approximately 1 1/8 us.
- if (--us == 0)
- return;
+ // of the function call takes 14 (16) cycles, which is 1us
+ if (us <= 1) return; // = 3 cycles, (4 when true)
- // the following loop takes a quarter of a microsecond (4 cycles)
+ // the following loop takes 1/4 of a microsecond (4 cycles)
// per iteration, so execute it four times for each microsecond of
// delay requested.
- us <<= 2;
+ us <<= 2; // x4 us, = 4 cycles
// account for the time taken in the preceeding commands.
- us -= 2;
-#else
- // for the 8 MHz internal clock on the ATmega168
+ // we just burned 19 (21) cycles above, remove 5, (5*4=20)
+ // us is at least 8 so we can substract 5
+ us -= 5; // = 2 cycles,
- // for a one- or two-microsecond delay, simply return. the overhead of
- // the function calls takes more than two microseconds. can't just
- // subtract two, since us is unsigned; we'd overflow.
- if (--us == 0)
- return;
- if (--us == 0)
- return;
+#elif F_CPU >= 12000000L
+ // for the 12 MHz clock if somebody is working with USB
- // the following loop takes half of a microsecond (4 cycles)
+ // for a 1 microsecond delay, simply return. the overhead
+ // of the function call takes 14 (16) cycles, which is 1.5us
+ if (us <= 1) return; // = 3 cycles, (4 when true)
+
+ // the following loop takes 1/3 of a microsecond (4 cycles)
+ // per iteration, so execute it three times for each microsecond of
+ // delay requested.
+ us = (us << 1) + us; // x3 us, = 5 cycles
+
+ // account for the time taken in the preceeding commands.
+ // we just burned 20 (22) cycles above, remove 5, (5*4=20)
+ // us is at least 6 so we can substract 5
+ us -= 5; //2 cycles
+
+#elif F_CPU >= 8000000L
+ // for the 8 MHz internal clock
+
+ // for a 1 and 2 microsecond delay, simply return. the overhead
+ // of the function call takes 14 (16) cycles, which is 2us
+ if (us <= 2) return; // = 3 cycles, (4 when true)
+
+ // the following loop takes 1/2 of a microsecond (4 cycles)
// per iteration, so execute it twice for each microsecond of
// delay requested.
- us <<= 1;
-
- // partially compensate for the time taken by the preceeding commands.
- // we can't subtract any more than this or we'd overflow w/ small delays.
- us--;
+ us <<= 1; //x2 us, = 2 cycles
+
+ // account for the time taken in the preceeding commands.
+ // we just burned 17 (19) cycles above, remove 4, (4*4=16)
+ // us is at least 6 so we can substract 4
+ us -= 4; // = 2 cycles
+
+#else
+ // for the 1 MHz internal clock (default settings for common Atmega microcontrollers)
+
+ // the overhead of the function calls is 14 (16) cycles
+ if (us <= 16) return; //= 3 cycles, (4 when true)
+ if (us <= 25) return; //= 3 cycles, (4 when true), (must be at least 25 if we want to substract 22)
+
+ // compensate for the time taken by the preceeding and next commands (about 22 cycles)
+ us -= 22; // = 2 cycles
+ // the following loop takes 4 microseconds (4 cycles)
+ // per iteration, so execute it us/4 times
+ // us is at least 4, divided by 4 gives us 1 (no zero delay bug)
+ us >>= 2; // us div 4, = 4 cycles
+
+
#endif
// busy wait
@@ -185,6 +237,7 @@ void delayMicroseconds(unsigned int us)
"1: sbiw %0,1" "\n\t" // 2 cycles
"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
);
+ // return = 4 cycles
}
void init()
@@ -199,7 +252,7 @@ void init()
#if defined(TCCR0A) && defined(WGM01)
sbi(TCCR0A, WGM01);
sbi(TCCR0A, WGM00);
-#endif
+#endif
// set timer 0 prescale factor to 64
#if defined(__AVR_ATmega128__)
@@ -302,14 +355,32 @@ void init()
#endif
#if defined(ADCSRA)
- // set a2d prescale factor to 128
- // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
- // XXX: this will not work properly for other clock speeds, and
- // this code should use F_CPU to determine the prescale factor.
- sbi(ADCSRA, ADPS2);
- sbi(ADCSRA, ADPS1);
- sbi(ADCSRA, ADPS0);
-
+ // set a2d prescaler so we are inside the desired 50-200 KHz range.
+ #if F_CPU >= 16000000 // 16 MHz / 128 = 125 KHz
+ sbi(ADCSRA, ADPS2);
+ sbi(ADCSRA, ADPS1);
+ sbi(ADCSRA, ADPS0);
+ #elif F_CPU >= 8000000 // 8 MHz / 64 = 125 KHz
+ sbi(ADCSRA, ADPS2);
+ sbi(ADCSRA, ADPS1);
+ cbi(ADCSRA, ADPS0);
+ #elif F_CPU >= 4000000 // 4 MHz / 32 = 125 KHz
+ sbi(ADCSRA, ADPS2);
+ cbi(ADCSRA, ADPS1);
+ sbi(ADCSRA, ADPS0);
+ #elif F_CPU >= 2000000 // 2 MHz / 16 = 125 KHz
+ sbi(ADCSRA, ADPS2);
+ cbi(ADCSRA, ADPS1);
+ cbi(ADCSRA, ADPS0);
+ #elif F_CPU >= 1000000 // 1 MHz / 8 = 125 KHz
+ cbi(ADCSRA, ADPS2);
+ sbi(ADCSRA, ADPS1);
+ sbi(ADCSRA, ADPS0);
+ #else // 128 kHz / 2 = 64 KHz -> This is the closest you can get, the prescaler is 2
+ cbi(ADCSRA, ADPS2);
+ cbi(ADCSRA, ADPS1);
+ sbi(ADCSRA, ADPS0);
+ #endif
// enable a2d conversions
sbi(ADCSRA, ADEN);
#endif
diff --git a/hardware/arduino/avr/cores/arduino/wiring_private.h b/hardware/arduino/avr/cores/arduino/wiring_private.h
index 5dc7d4bed..3bd2900e0 100644
--- a/hardware/arduino/avr/cores/arduino/wiring_private.h
+++ b/hardware/arduino/avr/cores/arduino/wiring_private.h
@@ -43,6 +43,8 @@ extern "C"{
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
+uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops);
+
#define EXTERNAL_INT_0 0
#define EXTERNAL_INT_1 1
#define EXTERNAL_INT_2 2
diff --git a/hardware/arduino/avr/cores/arduino/wiring_pulse.S b/hardware/arduino/avr/cores/arduino/wiring_pulse.S
new file mode 100644
index 000000000..1dd22e625
--- /dev/null
+++ b/hardware/arduino/avr/cores/arduino/wiring_pulse.S
@@ -0,0 +1,178 @@
+/*
+ wiring_pulse.s - pulseInASM() function in different flavours
+ Part of Arduino - http://www.arduino.cc/
+
+ Copyright (c) 2014 Martino Facchin
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General
+ Public License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+*/
+
+/*
+ * The following routine was generated by avr-gcc 4.8.3 with the following parameters
+ * -gstabs -Wa,-ahlmsd=output.lst -dp -fverbose-asm -O2
+ * on the original C function
+ *
+ * unsigned long pulseInSimpl(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops)
+ * {
+ * unsigned long width = 0;
+ * // wait for any previous pulse to end
+ * while ((*port & bit) == stateMask)
+ * if (--maxloops == 0)
+ * return 0;
+ *
+ * // wait for the pulse to start
+ * while ((*port & bit) != stateMask)
+ * if (--maxloops == 0)
+ * return 0;
+ *
+ * // wait for the pulse to stop
+ * while ((*port & bit) == stateMask) {
+ * if (++width == maxloops)
+ * return 0;
+ * }
+ * return width;
+ * }
+ *
+ * some compiler outputs were removed but the rest of the code is untouched
+ */
+
+#include
+
+.section .text
+
+.global countPulseASM
+
+countPulseASM:
+
+.LM0:
+.LFBB1:
+ push r12 ; ; 130 pushqi1/1 [length = 1]
+ push r13 ; ; 131 pushqi1/1 [length = 1]
+ push r14 ; ; 132 pushqi1/1 [length = 1]
+ push r15 ; ; 133 pushqi1/1 [length = 1]
+ push r16 ; ; 134 pushqi1/1 [length = 1]
+ push r17 ; ; 135 pushqi1/1 [length = 1]
+/* prologue: function */
+/* frame size = 0 */
+/* stack size = 6 */
+.L__stack_usage = 6
+ mov r30,r24 ; port, port ; 2 *movhi/1 [length = 2]
+ mov r31,r25 ; port, port
+/* unsigned long width = 0;
+*** // wait for any previous pulse to end
+*** while ((*port & bit) == stateMask)
+*/
+.LM1:
+ rjmp .L2 ; ; 181 jump [length = 1]
+.L4:
+/* if (--maxloops == 0) */
+.LM2:
+ subi r16,1 ; maxloops, ; 17 addsi3/2 [length = 4]
+ sbc r17, r1 ; maxloops
+ sbc r18, r1 ; maxloops
+ sbc r19, r1 ; maxloops
+ breq .L13 ; , ; 19 branch [length = 1]
+.L2:
+/* if (--maxloops == 0) */
+.LM3:
+ ld r25,Z ; D.1554, *port_7(D) ; 22 movqi_insn/4 [length = 1]
+ and r25,r22 ; D.1554, bit ; 24 andqi3/1 [length = 1]
+ cp r25,r20 ; D.1554, stateMask ; 25 *cmpqi/2 [length = 1]
+ breq .L4 ; , ; 26 branch [length = 1]
+ rjmp .L6 ; ; 184 jump [length = 1]
+.L7:
+/* return 0;
+***
+*** // wait for the pulse to start
+*** while ((*port & bit) != stateMask)
+*** if (--maxloops == 0)
+*/
+.LM4:
+ subi r16,1 ; maxloops, ; 31 addsi3/2 [length = 4]
+ sbc r17, r1 ; maxloops
+ sbc r18, r1 ; maxloops
+ sbc r19, r1 ; maxloops
+ breq .L13 ; , ; 33 branch [length = 1]
+.L6:
+/* if (--maxloops == 0) */
+.LM5:
+ ld r25,Z ; D.1554, *port_7(D) ; 41 movqi_insn/4 [length = 1]
+ and r25,r22 ; D.1554, bit ; 43 andqi3/1 [length = 1]
+ cpse r25,r20 ; D.1554, stateMask ; 44 enable_interrupt-3 [length = 1]
+ rjmp .L7 ;
+ mov r12, r1 ; width ; 7 *movsi/2 [length = 4]
+ mov r13, r1 ; width
+ mov r14, r1 ; width
+ mov r15, r1 ; width
+ rjmp .L9 ; ; 186 jump [length = 1]
+.L10:
+/* return 0;
+***
+*** // wait for the pulse to stop
+*** while ((*port & bit) == stateMask) {
+*** if (++width == maxloops)
+*/
+.LM6:
+ ldi r24,-1 ; , ; 50 addsi3/3 [length = 5]
+ sub r12,r24 ; width,
+ sbc r13,r24 ; width,
+ sbc r14,r24 ; width,
+ sbc r15,r24 ; width,
+ cp r16,r12 ; maxloops, width ; 51 *cmpsi/2 [length = 4]
+ cpc r17,r13 ; maxloops, width
+ cpc r18,r14 ; maxloops, width
+ cpc r19,r15 ; maxloops, width
+ breq .L13 ; , ; 52 branch [length = 1]
+.L9:
+/* if (++width == maxloops) */
+.LM7:
+ ld r24,Z ; D.1554, *port_7(D) ; 60 movqi_insn/4 [length = 1]
+ and r24,r22 ; D.1554, bit ; 62 andqi3/1 [length = 1]
+ cp r24,r20 ; D.1554, stateMask ; 63 *cmpqi/2 [length = 1]
+ breq .L10 ; , ; 64 branch [length = 1]
+/* return 0;
+*** }
+*** return width;
+*/
+.LM8:
+ mov r22,r12 ; D.1553, width ; 108 movqi_insn/1 [length = 1]
+ mov r23,r13 ; D.1553, width ; 109 movqi_insn/1 [length = 1]
+ mov r24,r14 ; D.1553, width ; 110 movqi_insn/1 [length = 1]
+ mov r25,r15 ; D.1553, width ; 111 movqi_insn/1 [length = 1]
+/* epilogue start */
+.LM9:
+ pop r17 ; ; 171 popqi [length = 1]
+ pop r16 ; ; 172 popqi [length = 1]
+ pop r15 ; ; 173 popqi [length = 1]
+ pop r14 ; ; 174 popqi [length = 1]
+ pop r13 ; ; 175 popqi [length = 1]
+ pop r12 ; ; 176 popqi [length = 1]
+ ret ; 177 return_from_epilogue [length = 1]
+.L13:
+.LM10:
+ ldi r22,0 ; D.1553 ; 120 movqi_insn/1 [length = 1]
+ ldi r23,0 ; D.1553 ; 121 movqi_insn/1 [length = 1]
+ ldi r24,0 ; D.1553 ; 122 movqi_insn/1 [length = 1]
+ ldi r25,0 ; D.1553 ; 123 movqi_insn/1 [length = 1]
+/* epilogue start */
+.LM11:
+ pop r17 ; ; 138 popqi [length = 1]
+ pop r16 ; ; 139 popqi [length = 1]
+ pop r15 ; ; 140 popqi [length = 1]
+ pop r14 ; ; 141 popqi [length = 1]
+ pop r13 ; ; 142 popqi [length = 1]
+ pop r12 ; ; 143 popqi [length = 1]
+ ret ; 144 return_from_epilogue [length = 1]
diff --git a/hardware/arduino/avr/cores/arduino/wiring_pulse.c b/hardware/arduino/avr/cores/arduino/wiring_pulse.c
index 830c45408..4c44d1c3f 100644
--- a/hardware/arduino/avr/cores/arduino/wiring_pulse.c
+++ b/hardware/arduino/avr/cores/arduino/wiring_pulse.c
@@ -28,7 +28,10 @@
/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
* to 3 minutes in length, but must be called at least a few dozen microseconds
- * before the start of the pulse. */
+ * before the start of the pulse.
+ *
+ * This function performs better with short pulses in noInterrupt() context
+ */
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
{
// cache the port and bit of the pin in order to speed up the
@@ -37,49 +40,57 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
uint8_t stateMask = (state ? bit : 0);
- unsigned long width = 0; // keep initialization out of time critical area
-
+
+ // convert the timeout from microseconds to a number of times through
+ // the initial loop; it takes approximately 16 clock cycles per iteration
+ unsigned long maxloops = microsecondsToClockCycles(timeout)/16;
+
+ unsigned long width = countPulseASM(portInputRegister(port), bit, stateMask, maxloops);
+
+ // prevent clockCyclesToMicroseconds to return bogus values if countPulseASM timed out
+ if (width)
+ return clockCyclesToMicroseconds(width * 16 + 16);
+ else
+ return 0;
+}
+
+/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
+ * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
+ * to 3 minutes in length, but must be called at least a few dozen microseconds
+ * before the start of the pulse.
+ *
+ * ATTENTION:
+ * this function relies on micros() so cannot be used in noInterrupt() context
+ */
+unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
+{
+ // cache the port and bit of the pin in order to speed up the
+ // pulse width measuring loop and achieve finer resolution. calling
+ // digitalRead() instead yields much coarser resolution.
+ uint8_t bit = digitalPinToBitMask(pin);
+ uint8_t port = digitalPinToPort(pin);
+ uint8_t stateMask = (state ? bit : 0);
+
// convert the timeout from microseconds to a number of times through
// the initial loop; it takes 16 clock cycles per iteration.
unsigned long numloops = 0;
- unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
-
+ unsigned long maxloops = microsecondsToClockCycles(timeout);
+
// wait for any previous pulse to end
while ((*portInputRegister(port) & bit) == stateMask)
if (numloops++ == maxloops)
return 0;
-
+
// wait for the pulse to start
while ((*portInputRegister(port) & bit) != stateMask)
if (numloops++ == maxloops)
return 0;
-
+
+ unsigned long start = micros();
// wait for the pulse to stop
while ((*portInputRegister(port) & bit) == stateMask) {
if (numloops++ == maxloops)
return 0;
- width++;
}
-
- // convert the reading to microseconds. There will be some error introduced by
- // the interrupt handlers.
-
- // Conversion constants are compiler-dependent, different compiler versions
- // have different levels of optimization.
-#if __GNUC__==4 && __GNUC_MINOR__==3 && __GNUC_PATCHLEVEL__==2
- // avr-gcc 4.3.2
- return clockCyclesToMicroseconds(width * 21 + 16);
-#elif __GNUC__==4 && __GNUC_MINOR__==8 && __GNUC_PATCHLEVEL__==1
- // avr-gcc 4.8.1
- return clockCyclesToMicroseconds(width * 24 + 16);
-#elif __GNUC__<=4 && __GNUC_MINOR__<=3
- // avr-gcc <=4.3.x
- #warning "pulseIn() results may not be accurate"
- return clockCyclesToMicroseconds(width * 21 + 16);
-#else
- // avr-gcc >4.3.x
- #warning "pulseIn() results may not be accurate"
- return clockCyclesToMicroseconds(width * 24 + 16);
-#endif
-
+ return micros() - start;
}
diff --git a/hardware/arduino/avr/libraries/EEPROM/library.properties b/hardware/arduino/avr/libraries/EEPROM/library.properties
index 765aa41a2..21437ffdf 100644
--- a/hardware/arduino/avr/libraries/EEPROM/library.properties
+++ b/hardware/arduino/avr/libraries/EEPROM/library.properties
@@ -4,7 +4,6 @@ author=Arduino, Christopher Andrews
maintainer=Arduino
sentence=Enables reading and writing to the permanent board storage. For all Arduino boards BUT Arduino DUE.
paragraph=
-url=http://arduino.cc/en/Reference/EEPROM
+url=http://www.arduino.cc/en/Reference/EEPROM
architectures=avr
-types=Arduino
diff --git a/hardware/arduino/avr/libraries/SPI/library.properties b/hardware/arduino/avr/libraries/SPI/library.properties
index 07af86961..2964aecfe 100644
--- a/hardware/arduino/avr/libraries/SPI/library.properties
+++ b/hardware/arduino/avr/libraries/SPI/library.properties
@@ -4,7 +4,6 @@ author=Arduino
maintainer=Arduino
sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. For all Arduino boards, BUT Arduino DUE.
paragraph=
-url=http://arduino.cc/en/Reference/SPI
+url=http://www.arduino.cc/en/Reference/SPI
architectures=avr
-types=Arduino
diff --git a/hardware/arduino/avr/libraries/SoftwareSerial/library.properties b/hardware/arduino/avr/libraries/SoftwareSerial/library.properties
index 8b433d94a..37eb04b3d 100644
--- a/hardware/arduino/avr/libraries/SoftwareSerial/library.properties
+++ b/hardware/arduino/avr/libraries/SoftwareSerial/library.properties
@@ -4,7 +4,6 @@ author=Arduino
maintainer=Arduino
sentence=Enables serial communication on digital pins. For all Arduino boards, BUT Arduino DUE.
paragraph=
-url=http://arduino.cc/en/Reference/SoftwareSerial
+url=http://www.arduino.cc/en/Reference/SoftwareSerial
architectures=avr
-types=Arduino
diff --git a/hardware/arduino/avr/libraries/Wire/library.properties b/hardware/arduino/avr/libraries/Wire/library.properties
index 32c074525..080584743 100644
--- a/hardware/arduino/avr/libraries/Wire/library.properties
+++ b/hardware/arduino/avr/libraries/Wire/library.properties
@@ -4,7 +4,6 @@ author=Arduino
maintainer=Arduino
sentence=Allows the communication between devices or sensors connected via Two Wire Interface Bus. For all Arduino boards, BUT Arduino DUE.
paragraph=
-url=http://arduino.cc/en/Reference/Wire
+url=http://www.arduino.cc/en/Reference/Wire
architectures=avr
-types=Arduino
diff --git a/hardware/arduino/avr/platform.txt b/hardware/arduino/avr/platform.txt
index b3c99864c..51e0e6386 100644
--- a/hardware/arduino/avr/platform.txt
+++ b/hardware/arduino/avr/platform.txt
@@ -8,6 +8,10 @@
name=Arduino AVR Boards
version=1.6.7
+
+runtime.tools.avr-gcc.path={runtime.platform.path}/../../tools/avr
+runtime.tools.avrdude.path={runtime.platform.path}/../../tools/avr
+
# AVR compile variables
# ---------------------
diff --git a/hardware/arduino/avr/programmers.txt b/hardware/arduino/avr/programmers.txt
index 732b6b091..0c38151b0 100644
--- a/hardware/arduino/avr/programmers.txt
+++ b/hardware/arduino/avr/programmers.txt
@@ -51,3 +51,28 @@ usbGemma.program.tool=avrdude
usbGemma.program.extra_params=
usbGemma.config.path={runtime.platform.path}/bootloaders/gemma/avrdude.conf
+# STK500 firmware version v1 and v2 use different serial protocols.
+# Using the 'stk500' protocol tells avrdude to try and autodetect the
+# firmware version. If this leads to problems, we might need to add
+# stk500v1 and stk500v2 entries to allow explicitely selecting the
+# firmware version.
+stk500.name=Atmel STK500 development board
+stk500.communication=serial
+stk500.protocol=stk500
+stk500.program.protocol=stk500
+stk500.program.tool=avrdude
+stk500.program.extra_params=-P{serial.port}
+
+## Notes about Dangerous Prototypes Bus Pirate as ISP
+## Bus Pirate V3 need Firmware v5.10 or later
+## Bus Pirate V4 need Firmware v6.3-r2151 or later
+## Could happen that BP does not have enough current to power an Arduino board
+## through the ICSP connector. In this case disconnect the +Vcc from ICSP connector
+## and power Arduino board in the normal way.
+buspirate.name=BusPirate as ISP
+buspirate.communication=serial
+buspirate.protocol=buspirate
+buspirate.program.protocol=buspirate
+buspirate.program.tool=avrdude
+buspirate.program.extra_params=-P{serial.port}
+
diff --git a/hardware/arduino/sam/cores/arduino/Print.cpp b/hardware/arduino/sam/cores/arduino/Print.cpp
index 23f6a2372..379631955 100644
--- a/hardware/arduino/sam/cores/arduino/Print.cpp
+++ b/hardware/arduino/sam/cores/arduino/Print.cpp
@@ -115,9 +115,7 @@ size_t Print::print(const Printable& x)
size_t Print::println(void)
{
- size_t n = print('\r');
- n += print('\n');
- return n;
+ return write("\r\n");
}
size_t Print::println(const String &s)
diff --git a/hardware/arduino/sam/cores/arduino/avr/pgmspace.h b/hardware/arduino/sam/cores/arduino/avr/pgmspace.h
index 7d3e20e5c..003e67829 100644
--- a/hardware/arduino/sam/cores/arduino/avr/pgmspace.h
+++ b/hardware/arduino/sam/cores/arduino/avr/pgmspace.h
@@ -1,3 +1,29 @@
+/*
+ pgmspace.h - Definitions for compatibility with AVR pgmspace macros
+
+ Copyright (c) 2015 Arduino LLC
+
+ Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE
+*/
+
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_ 1
diff --git a/hardware/arduino/sam/cores/arduino/wiring_pulse.cpp b/hardware/arduino/sam/cores/arduino/wiring_pulse.cpp
index bf250ff69..241b6f19a 100644
--- a/hardware/arduino/sam/cores/arduino/wiring_pulse.cpp
+++ b/hardware/arduino/sam/cores/arduino/wiring_pulse.cpp
@@ -22,40 +22,72 @@
/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
* to 3 minutes in length, but must be called at least a few dozen microseconds
- * before the start of the pulse. */
-extern uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout )
+ * before the start of the pulse.
+ *
+ * ATTENTION:
+ * This function performs better with short pulses in noInterrupt() context
+ */
+uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout )
{
// cache the port and bit of the pin in order to speed up the
// pulse width measuring loop and achieve finer resolution. calling
// digitalRead() instead yields much coarser resolution.
PinDescription p = g_APinDescription[pin];
- uint32_t width = 0; // keep initialization out of time critical area
+ uint32_t bit = p.ulPin;
+ uint32_t stateMask = state ? bit : 0;
// convert the timeout from microseconds to a number of times through
- // the initial loop; it takes 22 clock cycles per iteration.
- uint32_t numloops = 0;
- uint32_t maxloops = microsecondsToClockCycles(timeout) / 22;
-
- // wait for any previous pulse to end
- while (PIO_Get(p.pPort, PIO_INPUT, p.ulPin) == state)
- if (numloops++ == maxloops)
- return 0;
-
- // wait for the pulse to start
- while (PIO_Get(p.pPort, PIO_INPUT, p.ulPin) != state)
- if (numloops++ == maxloops)
- return 0;
-
- // wait for the pulse to stop
- while (PIO_Get(p.pPort, PIO_INPUT, p.ulPin) == state) {
- if (numloops++ == maxloops)
- return 0;
- width++;
- }
+ // the initial loop; it takes (roughly) 18 clock cycles per iteration.
+ uint32_t maxloops = microsecondsToClockCycles(timeout) / 18;
+
+ uint32_t width = countPulseASM(&(p.pPort->PIO_PDSR), bit, stateMask, maxloops);
// convert the reading to microseconds. The loop has been determined
- // to be 52 clock cycles long and have about 16 clocks between the edge
+ // to be 18 clock cycles long and have about 16 clocks between the edge
// and the start of the loop. There will be some error introduced by
// the interrupt handlers.
- return clockCyclesToMicroseconds(width * 52 + 16);
+ if (width)
+ return clockCyclesToMicroseconds(width * 18 + 16);
+ else
+ return 0;
+}
+
+/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
+ * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
+ * to 3 minutes in length, but must be called at least a few dozen microseconds
+ * before the start of the pulse.
+ *
+ * ATTENTION:
+ * this function relies on micros() so cannot be used in noInterrupt() context
+ */
+uint32_t pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
+{
+ // cache the port and bit of the pin in order to speed up the
+ // pulse width measuring loop and achieve finer resolution. calling
+ // digitalRead() instead yields much coarser resolution.
+ PinDescription p = g_APinDescription[pin];
+ uint32_t bit = p.ulPin;
+ uint32_t stateMask = state ? bit : 0;
+
+ // convert the timeout from microseconds to a number of times through
+ // the initial loop; it takes 18 clock cycles per iteration.
+ unsigned long maxloops = microsecondsToClockCycles(timeout) / 10;
+
+ // wait for any previous pulse to end
+ while ((p.pPort->PIO_PDSR & bit) == stateMask)
+ if (--maxloops == 0)
+ return 0;
+
+ // wait for the pulse to start
+ while ((p.pPort->PIO_PDSR & bit) != stateMask)
+ if (--maxloops == 0)
+ return 0;
+
+ unsigned long start = micros();
+ // wait for the pulse to stop
+ while ((p.pPort->PIO_PDSR & bit) == stateMask) {
+ if (--maxloops == 0)
+ return 0;
+ }
+ return micros() - start;
}
diff --git a/hardware/arduino/sam/cores/arduino/wiring_pulse.h b/hardware/arduino/sam/cores/arduino/wiring_pulse.h
index f32896984..3087cb93c 100644
--- a/hardware/arduino/sam/cores/arduino/wiring_pulse.h
+++ b/hardware/arduino/sam/cores/arduino/wiring_pulse.h
@@ -23,6 +23,7 @@
extern "C" {
#endif
+unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_t stateMask, unsigned long maxloops);
/*
* \brief Measures the length (in microseconds) of a pulse on the pin; state is HIGH
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
@@ -30,7 +31,7 @@
* before the start of the pulse.
*/
extern uint32_t pulseIn( uint32_t ulPin, uint32_t ulState, uint32_t ulTimeout = 1000000L ) ;
-
+extern uint32_t pulseInLong( uint8_t pin, uint8_t state, unsigned long timeout = 1000000L ) ;
#ifdef __cplusplus
}
diff --git a/hardware/arduino/sam/cores/arduino/wiring_pulse_asm.S b/hardware/arduino/sam/cores/arduino/wiring_pulse_asm.S
new file mode 100644
index 000000000..ad1835fa9
--- /dev/null
+++ b/hardware/arduino/sam/cores/arduino/wiring_pulse_asm.S
@@ -0,0 +1,166 @@
+/*
+ Copyright (c) 2015 Arduino LLC. All right reserved.
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+/*
+The following function has been compiled to ASM with gcc
+ unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_t stateMask, unsigned long maxloops)
+ {
+ unsigned long width = 0;
+ // wait for any previous pulse to end
+ while ((*port & bit) == stateMask)
+ if (--maxloops == 0)
+ return 0;
+ // wait for the pulse to start
+ while ((*port & bit) != stateMask)
+ if (--maxloops == 0)
+ return 0;
+ // wait for the pulse to stop
+ while ((*port & bit) == stateMask) {
+ if (++width == maxloops)
+ return 0;
+ }
+ return width;
+ }
+
+using the command line:
+
+ arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -c -O2 -W -ffunction-sections -fdata-sections -nostdlib \
+ countPulseASM.c -Wa,-ahlmsd=output.lst -dp -fverbose-asm -S \
+ -I.arduino15/packages/arduino/hardware/sam/1.6.3/cores/arduino \
+ -I.arduino15/packages/arduino/hardware/sam/1.6.3/system/CMSIS/CMSIS/Include \
+ -I.arduino15/packages/arduino/hardware/sam/1.6.3/system/CMSIS/Device/ATMEL \
+ -I.arduino15/packages/arduino/hardware/sam/1.6.3/system/libsam/include \
+ -I.arduino15/packages/arduino/hardware/sam/1.6.3/variants/arduino_due_x
+
+The result has been slightly edited to increase readability.
+*/
+
+ .syntax unified
+ .cpu cortex-m3
+ .fpu softvfp
+ .eabi_attribute 20, 1 @ Tag_ABI_FP_denormal
+ .eabi_attribute 21, 1 @ Tag_ABI_FP_exceptions
+ .eabi_attribute 23, 3 @ Tag_ABI_FP_number_model
+ .eabi_attribute 24, 1 @ Tag_ABI_align8_needed
+ .eabi_attribute 25, 1 @ Tag_ABI_align8_preserved
+ .eabi_attribute 26, 1 @ Tag_ABI_enum_size
+ .eabi_attribute 30, 2 @ Tag_ABI_optimization_goals
+ .eabi_attribute 34, 1 @ Tag_CPU_unaligned_access
+ .eabi_attribute 18, 4 @ Tag_ABI_PCS_wchar_t
+ .file "countPulseASM.c"
+@ GNU C (GNU Tools for ARM Embedded Processors) version 4.9.3 20150303 (release) [ARM/embedded-4_9-branch revision 221220] (arm-none-eabi)
+@ compiled by GNU C version 4.7.4, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
+@ GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+@ options passed:
+@ -I .arduino15/packages/arduino/hardware/sam/1.6.3/cores/arduino
+@ -I .arduino15/packages/arduino/hardware/sam/1.6.3/system/CMSIS/CMSIS/Include
+@ -I .arduino15/packages/arduino/hardware/sam/1.6.3/system/CMSIS/Device/ATMEL
+@ -I .arduino15/packages/arduino/hardware/sam/1.6.3/system/libsam/include
+@ -I .arduino15/packages/arduino/hardware/sam/1.6.3/variants/arduino_due_x
+@ -imultilib armv7-m -iprefix /usr/bin/../lib/gcc/arm-none-eabi/4.9.3/
+@ -isysroot /usr/bin/../arm-none-eabi -D__USES_INITFINI__ countPulseASM.c
+@ -mcpu=cortex-m3 -mthumb -O2 -Wextra -ffunction-sections -fdata-sections
+@ -fverbose-asm
+@ options enabled: -faggressive-loop-optimizations -fauto-inc-dec
+@ -fbranch-count-reg -fcaller-saves -fcombine-stack-adjustments -fcommon
+@ -fcompare-elim -fcprop-registers -fcrossjumping -fcse-follow-jumps
+@ -fdata-sections -fdefer-pop -fdelete-null-pointer-checks -fdevirtualize
+@ -fdevirtualize-speculatively -fdwarf2-cfi-asm -fearly-inlining
+@ -feliminate-unused-debug-types -fexpensive-optimizations
+@ -fforward-propagate -ffunction-cse -ffunction-sections -fgcse -fgcse-lm
+@ -fgnu-runtime -fgnu-unique -fguess-branch-probability
+@ -fhoist-adjacent-loads -fident -fif-conversion -fif-conversion2
+@ -findirect-inlining -finline -finline-atomics
+@ -finline-functions-called-once -finline-small-functions -fipa-cp
+@ -fipa-profile -fipa-pure-const -fipa-reference -fipa-sra
+@ -fira-hoist-pressure -fira-share-save-slots -fira-share-spill-slots
+@ -fisolate-erroneous-paths-dereference -fivopts -fkeep-static-consts
+@ -fleading-underscore -flifetime-dse -fmath-errno -fmerge-constants
+@ -fmerge-debug-strings -fmove-loop-invariants -fomit-frame-pointer
+@ -foptimize-sibling-calls -foptimize-strlen -fpartial-inlining -fpeephole
+@ -fpeephole2 -fprefetch-loop-arrays -freg-struct-return -freorder-blocks
+@ -freorder-functions -frerun-cse-after-loop
+@ -fsched-critical-path-heuristic -fsched-dep-count-heuristic
+@ -fsched-group-heuristic -fsched-interblock -fsched-last-insn-heuristic
+@ -fsched-pressure -fsched-rank-heuristic -fsched-spec
+@ -fsched-spec-insn-heuristic -fsched-stalled-insns-dep -fschedule-insns
+@ -fschedule-insns2 -fsection-anchors -fshow-column -fshrink-wrap
+@ -fsigned-zeros -fsplit-ivs-in-unroller -fsplit-wide-types
+@ -fstrict-aliasing -fstrict-overflow -fstrict-volatile-bitfields
+@ -fsync-libcalls -fthread-jumps -ftoplevel-reorder -ftrapping-math
+@ -ftree-bit-ccp -ftree-builtin-call-dce -ftree-ccp -ftree-ch
+@ -ftree-coalesce-vars -ftree-copy-prop -ftree-copyrename -ftree-cselim
+@ -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre
+@ -ftree-loop-if-convert -ftree-loop-im -ftree-loop-ivcanon
+@ -ftree-loop-optimize -ftree-parallelize-loops= -ftree-phiprop -ftree-pre
+@ -ftree-pta -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr
+@ -ftree-sra -ftree-switch-conversion -ftree-tail-merge -ftree-ter
+@ -ftree-vrp -funit-at-a-time -fverbose-asm -fzero-initialized-in-bss
+@ -mfix-cortex-m3-ldrd -mlittle-endian -mlra -mpic-data-is-text-relative
+@ -msched-prolog -mthumb -munaligned-access -mvectorize-with-neon-quad
+
+ .section .text.countPulseASM,"ax",%progbits
+ .align 2
+ .global countPulseASM
+ .thumb
+ .thumb_func
+ .type countPulseASM, %function
+countPulseASM:
+ @ args = 0, pretend = 0, frame = 0
+ @ frame_needed = 0, uses_anonymous_args = 0
+ @ link register save eliminated.
+ push {r4, r5} @ @ 132 *push_multi [length = 2]
+ b .L2 @ @ 178 *arm_jump [length = 2]
+.L4:
+ subs r3, r3, #1 @ maxloops, maxloops, @ 18 thumb2_addsi3_compare0/1 [length = 2]
+ beq .L12 @, @ 19 arm_cond_branch [length = 2]
+.L2:
+ ldr r4, [r0] @ D.4169, *port_7(D) @ 22 *thumb2_movsi_insn/6 [length = 4]
+ ands r4, r4, r1 @, D.4169, D.4169, bit @ 24 *thumb2_alusi3_short [length = 2]
+ cmp r4, r2 @ D.4169, stateMask @ 25 *arm_cmpsi_insn/2 [length = 2]
+ beq .L4 @, @ 26 arm_cond_branch [length = 2]
+ b .L6 @ @ 181 *arm_jump [length = 2]
+.L7:
+ subs r3, r3, #1 @ maxloops, maxloops, @ 32 thumb2_addsi3_compare0/1 [length = 2]
+ beq .L12 @, @ 33 arm_cond_branch [length = 2]
+.L6:
+ ldr r4, [r0] @ D.4169, *port_7(D) @ 41 *thumb2_movsi_insn/6 [length = 4]
+ ands r4, r4, r1 @, D.4169, D.4169, bit @ 43 *thumb2_alusi3_short [length = 2]
+ cmp r4, r2 @ D.4169, stateMask @ 44 *arm_cmpsi_insn/2 [length = 2]
+ bne .L7 @, @ 45 arm_cond_branch [length = 2]
+ movs r5, #0 @ width, @ 7 *thumb2_movsi_shortim [length = 2]
+ b .L9 @ @ 183 *arm_jump [length = 2]
+.L10:
+ adds r5, r5, #1 @ width, width, @ 50 *thumb2_addsi_short/1 [length = 2]
+ cmp r3, r5 @ maxloops, width @ 51 *arm_cmpsi_insn/2 [length = 2]
+ beq .L22 @, @ 52 arm_cond_branch [length = 2]
+.L9:
+ ldr r4, [r0] @ D.4169, *port_7(D) @ 60 *thumb2_movsi_insn/6 [length = 4]
+ ands r4, r4, r1 @, D.4169, D.4169, bit @ 62 *thumb2_alusi3_short [length = 2]
+ cmp r4, r2 @ D.4169, stateMask @ 63 *arm_cmpsi_insn/2 [length = 2]
+ beq .L10 @, @ 64 arm_cond_branch [length = 2]
+ mov r0, r5 @ D.4169, width @ 9 *thumb2_movsi_insn/1 [length = 2]
+ pop {r4, r5} @ @ 165 *load_multiple_with_writeback [length = 4]
+ bx lr @ @ 166 *thumb2_return [length = 4]
+.L12:
+ mov r0, r3 @ D.4169, maxloops @ 8 *thumb2_movsi_insn/1 [length = 2]
+ pop {r4, r5} @ @ 137 *load_multiple_with_writeback [length = 4]
+ bx lr @ @ 138 *thumb2_return [length = 4]
+.L22:
+ movs r0, #0 @ D.4169, @ 11 *thumb2_movsi_shortim [length = 2]
+ pop {r4, r5} @ @ 173 *load_multiple_with_writeback [length = 4]
+ bx lr @ @ 174 *thumb2_return [length = 4]
+ .size countPulseASM, .-countPulseASM
+ .ident "GCC: (GNU Tools for ARM Embedded Processors) 4.9.3 20150303 (release) [ARM/embedded-4_9-branch revision 221220]"
diff --git a/hardware/arduino/sam/libraries/SPI/library.properties b/hardware/arduino/sam/libraries/SPI/library.properties
index d3d378872..0e358df5f 100644
--- a/hardware/arduino/sam/libraries/SPI/library.properties
+++ b/hardware/arduino/sam/libraries/SPI/library.properties
@@ -4,7 +4,6 @@ author=Arduino
maintainer=Arduino
sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. For Arduino DUE only.
paragraph=
-url=http://arduino.cc/en/Reference/SPI
+url=http://www.arduino.cc/en/Reference/SPI
architectures=sam
-types=Arduino
diff --git a/hardware/arduino/sam/libraries/Wire/library.properties b/hardware/arduino/sam/libraries/Wire/library.properties
index aabdececc..607cf0dde 100644
--- a/hardware/arduino/sam/libraries/Wire/library.properties
+++ b/hardware/arduino/sam/libraries/Wire/library.properties
@@ -4,7 +4,6 @@ author=Arduino
maintainer=Arduino
sentence=Allows the communication between devices or sensors connected via Two Wire Interface Bus. For Arduino DUE only.
paragraph=
-url=http://arduino.cc/en/Reference/Wire
+url=http://www.arduino.cc/en/Reference/Wire
architectures=sam
-types=Arduino
diff --git a/hardware/arduino/sam/platform.txt b/hardware/arduino/sam/platform.txt
index af846086a..d52fb98a4 100644
--- a/hardware/arduino/sam/platform.txt
+++ b/hardware/arduino/sam/platform.txt
@@ -22,7 +22,8 @@ compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD
compiler.c.elf.cmd=arm-none-eabi-gcc
compiler.c.elf.flags=-Os -Wl,--gc-sections
-compiler.S.flags=-c -g -x assembler-with-cpp
+compiler.S.cmd=arm-none-eabi-gcc
+compiler.S.flags=-c -g -x assembler-with-cpp -mthumb
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD
compiler.ar.cmd=arm-none-eabi-ar
@@ -42,6 +43,7 @@ build.extra_flags=
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.cpp.extra_flags=
+compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
@@ -66,6 +68,9 @@ recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={b
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.libsam.c.flags} {includes} "{source_file}" -o "{object_file}"
+## Compile S files
+recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {compiler.libsam.c.flags} {includes} "{source_file}" -o "{object_file}"
+
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
diff --git a/hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp b/hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp
index 32b4aecd3..cdf38dde3 100644
--- a/hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp
+++ b/hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp
@@ -291,7 +291,7 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) {
String EspClass::getResetInfo(void) {
if(resetInfo.reason != 0) {
char buff[200];
- sprintf(&buff[0], "Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, (resetInfo.reason == 0 ? "DEFAULT" : resetInfo.reason == 1 ? "WDT" : resetInfo.reason == 2 ? "EXCEPTION" : resetInfo.reason == 3 ? "SOFT_WDT" : resetInfo.reason == 4 ? "SOFT_RESTART" : resetInfo.reason == 5 ? "DEEP_SLEEP_AWAKE" : "???"), resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
+ sprintf(&buff[0], "Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, (resetInfo.reason == 0 ? "DEFAULT" : resetInfo.reason == 1 ? "WDT" : resetInfo.reason == 2 ? "EXCEPTION" : resetInfo.reason == 3 ? "SOFT_WDT" : resetInfo.reason == 4 ? "SOFT_RESTART" : resetInfo.reason == 5 ? "DEEP_SLEEP_AWAKE" : "???"), resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
return String(buff);
}
return String("flag: 0");
diff --git a/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.h b/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.h
index 63c180c31..3f2692a50 100644
--- a/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.h
+++ b/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.h
@@ -32,7 +32,7 @@
#undef max
#include
-//#define DEBUG_WIFI_MULTI(...) Serial1.printf( __VA_ARGS__ )
+#define DEBUG_WIFI_MULTI(...) Serial1.printf( __VA_ARGS__ )
#ifndef DEBUG_WIFI_MULTI
#define DEBUG_WIFI_MULTI(...)
diff --git a/libraries/Audio/README.adoc b/libraries/Audio/README.adoc
index 77f06bf0e..1778afa04 100644
--- a/libraries/Audio/README.adoc
+++ b/libraries/Audio/README.adoc
@@ -3,7 +3,7 @@
The Audio library enables an Arduino Due board to play back .wav files from a storage device like an SD card.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/Audio
+http://www.arduino.cc/en/Reference/Audio
== License ==
diff --git a/libraries/Audio/examples/SimpleAudioPlayer/SimpleAudioPlayer.ino b/libraries/Audio/examples/SimpleAudioPlayer/SimpleAudioPlayer.ino
index 1512b85be..f8e12bedd 100644
--- a/libraries/Audio/examples/SimpleAudioPlayer/SimpleAudioPlayer.ino
+++ b/libraries/Audio/examples/SimpleAudioPlayer/SimpleAudioPlayer.ino
@@ -14,7 +14,7 @@
This example code is in the public domain
- http://arduino.cc/en/Tutorial/SimpleAudioPlayer
+ http://www.arduino.cc/en/Tutorial/SimpleAudioPlayer
*/
diff --git a/libraries/Audio/library.properties b/libraries/Audio/library.properties
index 3caa70522..93dea94fd 100644
--- a/libraries/Audio/library.properties
+++ b/libraries/Audio/library.properties
@@ -1,9 +1,9 @@
name=Audio
-version=1.0.2
+version=1.0.3
author=Arduino
maintainer=Arduino
sentence=Allows playing audio files from an SD card. For Arduino DUE only.
paragraph=With this library you can use the Arduino Due DAC outputs to play audio files.
The audio files must be in the raw .wav format.
category=Signal Input/Output
-url=http://arduino.cc/en/Reference/Audio
+url=http://www.arduino.cc/en/Reference/Audio
architectures=sam
diff --git a/libraries/Bridge/README.adoc b/libraries/Bridge/README.adoc
index 8b5e970a6..c660f86ee 100644
--- a/libraries/Bridge/README.adoc
+++ b/libraries/Bridge/README.adoc
@@ -3,7 +3,7 @@
The Bridge library simplifies communication between the ATmega32U4 and the AR9331.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/YunBridgeLibrary
+http://www.arduino.cc/en/Reference/YunBridgeLibrary
== License ==
diff --git a/libraries/Bridge/examples/Bridge/Bridge.ino b/libraries/Bridge/examples/Bridge/Bridge.ino
index 74c912d4c..025923d0c 100644
--- a/libraries/Bridge/examples/Bridge/Bridge.ino
+++ b/libraries/Bridge/examples/Bridge/Bridge.ino
@@ -18,7 +18,7 @@
This example code is part of the public domain
- http://arduino.cc/en/Tutorial/Bridge
+ http://www.arduino.cc/en/Tutorial/Bridge
*/
diff --git a/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino b/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino
index 2b6d87249..79d5aff7e 100644
--- a/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino
+++ b/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino
@@ -19,7 +19,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/ConsoleAsciiTable
+ http://www.arduino.cc/en/Tutorial/ConsoleAsciiTable
*/
diff --git a/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino b/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino
index 61036d3c6..ee78f4c61 100644
--- a/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino
+++ b/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino
@@ -23,7 +23,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/ConsolePixel
+ http://www.arduino.cc/en/Tutorial/ConsolePixel
*/
diff --git a/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino b/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino
index b9a8dd7ce..cf4e149b4 100644
--- a/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino
+++ b/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino
@@ -17,7 +17,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/ConsoleRead
+ http://www.arduino.cc/en/Tutorial/ConsoleRead
*/
diff --git a/libraries/Bridge/examples/Datalogger/Datalogger.ino b/libraries/Bridge/examples/Datalogger/Datalogger.ino
index 7112389c6..1aa5f5db3 100644
--- a/libraries/Bridge/examples/Datalogger/Datalogger.ino
+++ b/libraries/Bridge/examples/Datalogger/Datalogger.ino
@@ -26,7 +26,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/YunDatalogger
+ http://www.arduino.cc/en/Tutorial/YunDatalogger
*/
diff --git a/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino b/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino
index c59d873d5..0ca7d2cfb 100644
--- a/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino
+++ b/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino
@@ -9,7 +9,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/FileWriteScript
+ http://www.arduino.cc/en/Tutorial/FileWriteScript
*/
diff --git a/libraries/Bridge/examples/HttpClient/HttpClient.ino b/libraries/Bridge/examples/HttpClient/HttpClient.ino
index da0157c07..1107b4d05 100644
--- a/libraries/Bridge/examples/HttpClient/HttpClient.ino
+++ b/libraries/Bridge/examples/HttpClient/HttpClient.ino
@@ -11,7 +11,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/HttpClient
+ http://www.arduino.cc/en/Tutorial/HttpClient
*/
@@ -37,7 +37,7 @@ void loop() {
HttpClient client;
// Make a HTTP request:
- client.get("http://arduino.cc/asciilogo.txt");
+ client.get("http://www.arduino.cc/asciilogo.txt");
// if there are incoming bytes available
// from the server, read them and print them:
diff --git a/libraries/Bridge/examples/MailboxReadMessage/MailboxReadMessage.ino b/libraries/Bridge/examples/MailboxReadMessage/MailboxReadMessage.ino
index 09c0bef57..3e8115d9f 100644
--- a/libraries/Bridge/examples/MailboxReadMessage/MailboxReadMessage.ino
+++ b/libraries/Bridge/examples/MailboxReadMessage/MailboxReadMessage.ino
@@ -15,7 +15,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/MailboxReadMessage
+ http://www.arduino.cc/en/Tutorial/MailboxReadMessage
*/
diff --git a/libraries/Bridge/examples/Process/Process.ino b/libraries/Bridge/examples/Process/Process.ino
index 409b6d3a2..4f540120c 100644
--- a/libraries/Bridge/examples/Process/Process.ino
+++ b/libraries/Bridge/examples/Process/Process.ino
@@ -9,7 +9,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/Process
+ http://www.arduino.cc/en/Tutorial/Process
*/
@@ -39,7 +39,7 @@ void runCurl() {
// curl is command line program for transferring data using different internet protocols
Process p; // Create a process and call it "p"
p.begin("curl"); // Process that launch the "curl" command
- p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
+ p.addParameter("http://www.arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
p.run(); // Run the process and wait for its termination
// Print arduino logo over the Serial
diff --git a/libraries/Bridge/examples/ShellCommands/ShellCommands.ino b/libraries/Bridge/examples/ShellCommands/ShellCommands.ino
index 66fc11a62..3e5ef9dee 100644
--- a/libraries/Bridge/examples/ShellCommands/ShellCommands.ino
+++ b/libraries/Bridge/examples/ShellCommands/ShellCommands.ino
@@ -17,7 +17,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/ShellCommands
+ http://www.arduino.cc/en/Tutorial/ShellCommands
*/
diff --git a/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino b/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino
index 63717a4c4..bb6b09b96 100644
--- a/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino
+++ b/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino
@@ -3,15 +3,44 @@
Demonstrates sending an email via a Google Gmail account using Temboo from an Arduino Yún.
- Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+ Check out the latest Arduino & Temboo examples and tutorials at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
- Since this sketch uses Gmail to send the email, you'll also need a valid
- Google Gmail account. The sketch needs the username and password you use
- to log into your Gmail account - substitute the placeholders below for these values.
+ Instructions:
+
+ 1. Create a Temboo account: http://www.temboo.com
+
+ 2. Retrieve your Temboo application details: http://www.temboo.com/account/applications
+
+ 3. Replace the values in the TembooAccount.h tab with your Temboo application details
+
+ 4. You'll also need a Gmail account. Update the placeholder Gmail address in the code
+ below with your own details.
+
+ https://www.gmail.com
+
+ 5. Once you have a Gmail account, turn on 2-step authentication, and create an application-specific
+ password to allow Temboo to access your Google account: https://www.google.com/landing/2step/.
+
+ 6. After you've enabled 2-Step authentication, you'll need to create an App Password:
+ https://security.google.com/settings/security/apppasswords
+
+ 7. In the "Select app" dropdown menu, choose "Other", and give your app a name (e.g., TembooApp).
+
+ 8. Click "Generate". You'll be given a 16-digit passcode that can be used to access your Google Account from Temboo.
+
+ 9. Copy and paste this password into the code below, updating the GMAIL_APP_PASSWORD variable
+
+ 10. Upload the sketch to your Arduino Yún and open the serial monitor
+
+ NOTE: You can test this Choreo and find the latest instructions on our website:
+ https://temboo.com/library/Library/Google/Gmail/SendEmail
+
+ You can also find an in-depth version of this example here:
+ https://temboo.com/arduino/yun/send-an-email
This example assumes basic familiarity with Arduino sketches, and that your Yún is connected
to the Internet.
@@ -34,8 +63,8 @@
// your Gmail username, formatted as a complete email address, eg "bob.smith@gmail.com"
const String GMAIL_USER_NAME = "xxxxxxxxxx";
-// your Gmail password
-const String GMAIL_PASSWORD = "xxxxxxxxxx";
+// your application specific password (see instructions above)
+const String GMAIL_APP_PASSWORD = "xxxxxxxxxx";
// the email address you want to send the email to, eg "jane.doe@temboo.com"
const String TO_EMAIL_ADDRESS = "xxxxxxxxxx";
@@ -82,8 +111,8 @@ void loop()
// the first input is your Gmail email address.
SendEmailChoreo.addInput("Username", GMAIL_USER_NAME);
- // next is your Gmail password.
- SendEmailChoreo.addInput("Password", GMAIL_PASSWORD);
+ // next is your application specific password
+ SendEmailChoreo.addInput("Password", GMAIL_APP_PASSWORD);
// who to send the email to
SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS);
// then a subject line
diff --git a/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino b/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino
index 8918f9985..6bae2796e 100644
--- a/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino
+++ b/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino
@@ -3,31 +3,49 @@
Demonstrates appending a row of data to a Google spreadsheet using Temboo from an Arduino Yún.
- Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino
+ Check out the latest Arduino & Temboo examples and tutorials at http://www.temboo.com/arduino
A Temboo account and application key are necessary to run all Temboo examples.
If you don't already have one, you can register for a free Temboo account at
http://www.temboo.com
- Since this sketch uses a Google spreadsheet, you'll also need a
- Google account: substitute the placeholders below for your Google account values.
-
- This example assumes basic familiarity with Arduino sketches, and that your
- Yún is connected to the Internet.
-
- The columns in your spreadsheet must have labels for the Choreo to
- work properly. It doesn't matter what the column labels actually are,
- but there must be text in the first row of each column. This example
- assumes there are two columns. The first column is the time (in milliseconds)
- that the row was appended, and the second column is a sensor value.
- In other words, your spreadsheet should look like:
+ Instructions:
+
+ 1. Create a Temboo account: http://www.temboo.com
- Time | Sensor Value |
- ------+-----------------
- | |
+ 2. Retrieve your Temboo application details: http://www.temboo.com/account/applications
- NOTE that the first time you run this sketch, you may receive a warning from
- Google, prompting you to authorize access from a 3rd party system.
+ 3. Replace the values in the TembooAccount.h tab with your Temboo application details
+
+ 4. You'll also need a Google Spreadsheet that includes a title in the first row
+ of each column that data will be written to. This example assumes there are two columns.
+ The first column is the time (in milliseconds) that the row was appended, and the second
+ column is a sensor value. In other words, your spreadsheet should look like:
+
+ Time | Sensor Value |
+ ------+-----------------
+ | |
+
+ 5. Google Spreadsheets requires you to authenticate via OAuth. Follow the steps
+ in the link below to find your ClientID, ClientSecret, and RefreshToken, and then
+ use those values to overwrite the placeholders in the code below.
+
+ https://temboo.com/library/Library/Google/OAuth/
+
+ For the scope field, you need to use: https://spreadsheets.google.com/feeds/
+
+ Here's a video outlines how Temboo helps with the OAuth process:
+
+ https://www.temboo.com/videos#oauthchoreos
+
+ And here's a more in-depth version of this example on our website:
+
+ https://temboo.com/arduino/yun/update-google-spreadsheet
+
+ 6. Next, upload the sketch to your Arduino Yún and open the serial monitor
+
+ Note: you can test this Choreo and find the latest instructions on our website:
+ https://temboo.com/library/Library/Google/Spreadsheets/AppendRow/
Looking for another API to use with your Arduino Yún? We've got over 100 in our Library!
@@ -46,8 +64,14 @@
// Note that for additional security and reusability, you could
// use #define statements to specify these values in a .h file.
-const String GOOGLE_USERNAME = "your-google-username";
-const String GOOGLE_PASSWORD = "your-google-password";
+// the clientID found in Google's Developer Console under APIs & Auth > Credentials
+const String CLIENT_ID = "your-client-id";
+
+// the clientSecret found in Google's Developer Console under APIs & Auth > Credentials
+const String CLIENT_SECRET = "your-client-secret";
+
+// returned after running FinalizeOAuth
+const String REFRESH_TOKEN = "your-oauth-refresh-token";
// the title of the spreadsheet you want to send data to
// (Note that this must actually be the title of a Google spreadsheet
@@ -112,11 +136,12 @@ void loop()
// see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/
// for complete details about the inputs for this Choreo
- // your Google username (usually your email address)
- AppendRowChoreo.addInput("Username", GOOGLE_USERNAME);
-
- // your Google account password
- AppendRowChoreo.addInput("Password", GOOGLE_PASSWORD);
+ // your Google application client ID
+ AppendRowChoreo.addInput("ClientID", CLIENT_ID);
+ // your Google application client secert
+ AppendRowChoreo.addInput("ClientSecret", CLIENT_SECRET);
+ // your Google OAuth refresh token
+ AppendRowChoreo.addInput("RefreshToken", REFRESH_TOKEN);
// the title of the spreadsheet you want to append to
// NOTE: substitute your own value, retaining the "SpreadsheetTitle:" prefix.
diff --git a/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino b/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino
index a695fbdd5..fa881b533 100644
--- a/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino
+++ b/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino
@@ -31,7 +31,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/TemperatureWebPanel
+ http://www.arduino.cc/en/Tutorial/TemperatureWebPanel
*/
@@ -98,9 +98,9 @@ void loop() {
Serial.println(timeString);
int sensorValue = analogRead(A1);
// convert the reading to millivolts:
- float voltage = sensorValue * (5000 / 1024);
+ float voltage = sensorValue * (5000.0f / 1024.0f);
// convert the millivolts to temperature celsius:
- float temperature = (voltage - 500) / 10;
+ float temperature = (voltage - 500.0f) / 10.0f;
// print the temperature:
client.print("Current time on the Yún: ");
client.println(timeString);
diff --git a/libraries/Bridge/examples/TimeCheck/TimeCheck.ino b/libraries/Bridge/examples/TimeCheck/TimeCheck.ino
index 6240780db..f31b2b0d0 100644
--- a/libraries/Bridge/examples/TimeCheck/TimeCheck.ino
+++ b/libraries/Bridge/examples/TimeCheck/TimeCheck.ino
@@ -10,7 +10,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/TimeCheck
+ http://www.arduino.cc/en/Tutorial/TimeCheck
*/
diff --git a/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino b/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino
index fe7c887b9..fb4126978 100644
--- a/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino
+++ b/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino
@@ -14,7 +14,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/YunWiFiStatus
+ http://www.arduino.cc/en/Tutorial/YunWiFiStatus
*/
diff --git a/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino b/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino
index 53b9eead4..91b911b65 100644
--- a/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino
+++ b/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino
@@ -27,7 +27,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/YunSerialTerminal
+ http://www.arduino.cc/en/Tutorial/YunSerialTerminal
*/
diff --git a/libraries/Bridge/library.properties b/libraries/Bridge/library.properties
index dd8eba068..ac8ebd9bb 100644
--- a/libraries/Bridge/library.properties
+++ b/libraries/Bridge/library.properties
@@ -1,9 +1,9 @@
name=Bridge
-version=1.0.4
+version=1.0.7
author=Arduino
maintainer=Arduino
sentence=Enables the communication between the Linux processor and the AVR. For Arduino Yún and TRE only.
paragraph=The Bridge library feature: access to the shared storage, run and manage linux processes, open a remote console, access to the linux file system, including the SD card, enstablish http clients or servers.
category=Communication
-url=http://arduino.cc/en/Reference/YunBridgeLibrary
+url=http://www.arduino.cc/en/Reference/YunBridgeLibrary
architectures=*
diff --git a/libraries/Esplora/README.adoc b/libraries/Esplora/README.adoc
index 1f71b38ed..a24a480b2 100644
--- a/libraries/Esplora/README.adoc
+++ b/libraries/Esplora/README.adoc
@@ -3,7 +3,7 @@
The library offers easy access to the data from the onboard Esplora's sensors, and provides the ability to change the state of the outputs.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/EsploraLibrary
+http://www.arduino.cc/en/Reference/EsploraLibrary
== License ==
diff --git a/libraries/Esplora/examples/Beginners/EsploraJoystickMouse/EsploraJoystickMouse.ino b/libraries/Esplora/examples/Beginners/EsploraJoystickMouse/EsploraJoystickMouse.ino
index 9324fb5bc..197f8fcad 100644
--- a/libraries/Esplora/examples/Beginners/EsploraJoystickMouse/EsploraJoystickMouse.ino
+++ b/libraries/Esplora/examples/Beginners/EsploraJoystickMouse/EsploraJoystickMouse.ino
@@ -20,7 +20,7 @@
Updated 8 March 2014
by Scott Fitzgerald
- http://arduino.cc/en/Reference/EsploraReadJoystickSwitch
+ http://www.arduino.cc/en/Reference/EsploraReadJoystickSwitch
This example is in the public domain.
*/
diff --git a/libraries/Esplora/library.properties b/libraries/Esplora/library.properties
index f54617f12..26ad29b1f 100644
--- a/libraries/Esplora/library.properties
+++ b/libraries/Esplora/library.properties
@@ -1,9 +1,9 @@
name=Esplora
-version=1.0.3
+version=1.0.4
author=Arduino
maintainer=Arduino
sentence=Grants easy access to the various sensors and actuators of the Esplora. For Arduino Esplora only.
paragraph=The sensors available on the board are:2-Axis analog joystick with center push-button,4 push-buttons,microphone, light sensor, temperature sensor, 3-axis accelerometer, 2 TinkerKit input connectors.The actuators available on the board are: bright RGB LED, piezo buzzer, 2 TinkerKit output connectors.
category=Device Control
-url=http://arduino.cc/en/Reference/EsploraLibrary
+url=http://www.arduino.cc/en/Reference/EsploraLibrary
architectures=avr
diff --git a/libraries/Ethernet/README.adoc b/libraries/Ethernet/README.adoc
index c01060742..8f890f045 100644
--- a/libraries/Ethernet/README.adoc
+++ b/libraries/Ethernet/README.adoc
@@ -3,7 +3,7 @@
With the Arduino Ethernet Shield, this library allows an Arduino board to connect to the internet.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/Ethernet
+http://www.arduino.cc/en/Reference/Ethernet
== License ==
diff --git a/libraries/Ethernet/examples/WebClientRepeating/WebClientRepeating.ino b/libraries/Ethernet/examples/WebClientRepeating/WebClientRepeating.ino
index a0ae8b782..ad3f461c2 100644
--- a/libraries/Ethernet/examples/WebClientRepeating/WebClientRepeating.ino
+++ b/libraries/Ethernet/examples/WebClientRepeating/WebClientRepeating.ino
@@ -17,7 +17,7 @@
modified 21 Jan 2014
by Federico Vanzati
- http://arduino.cc/en/Tutorial/WebClientRepeating
+ http://www.arduino.cc/en/Tutorial/WebClientRepeating
This code is in the public domain.
*/
diff --git a/libraries/Ethernet/library.properties b/libraries/Ethernet/library.properties
index 1634bfea7..8fdc11d2e 100644
--- a/libraries/Ethernet/library.properties
+++ b/libraries/Ethernet/library.properties
@@ -1,9 +1,9 @@
name=Ethernet
-version=1.0.2
+version=1.0.4
author=Arduino
maintainer=Arduino
sentence=Enables network connection (local and Internet) using the Arduino Ethernet board or shield. For all Arduino boards.
paragraph=With this library you can use the Arduino Ethernet (shield or board) to connect to Internet. The library provides both Client and server functionalities. The library permits you to connect to a local network also with DHCP and to resolve DNS.
category=Communication
-url=http://arduino.cc/en/Reference/Ethernet
+url=http://www.arduino.cc/en/Reference/Ethernet
architectures=*
diff --git a/libraries/Ethernet/src/EthernetClient.cpp b/libraries/Ethernet/src/EthernetClient.cpp
index a592bfdc9..1feed4c42 100644
--- a/libraries/Ethernet/src/EthernetClient.cpp
+++ b/libraries/Ethernet/src/EthernetClient.cpp
@@ -131,12 +131,17 @@ void EthernetClient::stop() {
disconnect(_sock);
unsigned long start = millis();
- // wait a second for the connection to close
- while (status() != SnSR::CLOSED && millis() - start < 1000)
+ // wait up to a second for the connection to close
+ uint8_t s;
+ do {
+ s = status();
+ if (s == SnSR::CLOSED)
+ break; // exit the loop
delay(1);
+ } while (millis() - start < 1000);
// if it hasn't closed, close it forcefully
- if (status() != SnSR::CLOSED)
+ if (s != SnSR::CLOSED)
close(_sock);
EthernetClass::_server_port[_sock] = 0;
diff --git a/libraries/Ethernet/src/EthernetServer.cpp b/libraries/Ethernet/src/EthernetServer.cpp
index 6d6ce8c80..cfa813eb7 100644
--- a/libraries/Ethernet/src/EthernetServer.cpp
+++ b/libraries/Ethernet/src/EthernetServer.cpp
@@ -54,12 +54,13 @@ EthernetClient EthernetServer::available()
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
EthernetClient client(sock);
- if (EthernetClass::_server_port[sock] == _port &&
- (client.status() == SnSR::ESTABLISHED ||
- client.status() == SnSR::CLOSE_WAIT)) {
- if (client.available()) {
- // XXX: don't always pick the lowest numbered socket.
- return client;
+ if (EthernetClass::_server_port[sock] == _port) {
+ uint8_t s = client.status();
+ if (s == SnSR::ESTABLISHED || s == SnSR::CLOSE_WAIT) {
+ if (client.available()) {
+ // XXX: don't always pick the lowest numbered socket.
+ return client;
+ }
}
}
}
diff --git a/libraries/Firmata/README.adoc b/libraries/Firmata/README.adoc
deleted file mode 100644
index a85d48540..000000000
--- a/libraries/Firmata/README.adoc
+++ /dev/null
@@ -1,25 +0,0 @@
-= Firmata Library for Arduino =
-
-The Firmata library implements the Firmata protocol for communicating with software on the host computer. This allows you to write custom firmware without having to create your own protocol and objects for the programming environment that you are using.
-
-For more information about this library please visit us at
-http://arduino.cc/en/Reference/Firmata
-
-== License ==
-
-Copyright (c) 2006-2008 Hans-Christoph Steiner. All rights reserved.
-Copyright (c) 2010 Arduino LLC. All right reserved.
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
diff --git a/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.ino b/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.ino
deleted file mode 100644
index cfe44820a..000000000
--- a/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.ino
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/*
- * This firmware reads all inputs and sends them as fast as it can. It was
- * inspired by the ease-of-use of the Arduino2Max program.
- *
- * This example code is in the public domain.
- */
-#include
-
-byte pin;
-
-int analogValue;
-int previousAnalogValues[TOTAL_ANALOG_PINS];
-
-byte portStatus[TOTAL_PORTS]; // each bit: 1=pin is digital input, 0=other/ignore
-byte previousPINs[TOTAL_PORTS];
-
-/* timer variables */
-unsigned long currentMillis; // store the current value from millis()
-unsigned long previousMillis; // for comparison with currentMillis
-/* make sure that the FTDI buffer doesn't go over 60 bytes, otherwise you
- get long, random delays. So only read analogs every 20ms or so */
-int samplingInterval = 19; // how often to run the main loop (in ms)
-
-void sendPort(byte portNumber, byte portValue)
-{
- portValue = portValue & portStatus[portNumber];
- if (previousPINs[portNumber] != portValue) {
- Firmata.sendDigitalPort(portNumber, portValue);
- previousPINs[portNumber] = portValue;
- }
-}
-
-void setup()
-{
- byte i, port, status;
-
- Firmata.setFirmwareVersion(0, 1);
-
- for (pin = 0; pin < TOTAL_PINS; pin++) {
- if IS_PIN_DIGITAL(pin) pinMode(PIN_TO_DIGITAL(pin), INPUT);
- }
-
- for (port = 0; port < TOTAL_PORTS; port++) {
- status = 0;
- for (i = 0; i < 8; i++) {
- if (IS_PIN_DIGITAL(port * 8 + i)) status |= (1 << i);
- }
- portStatus[port] = status;
- }
-
- Firmata.begin(57600);
-}
-
-void loop()
-{
- byte i;
-
- for (i = 0; i < TOTAL_PORTS; i++) {
- sendPort(i, readPort(i, 0xff));
- }
- /* make sure that the FTDI buffer doesn't go over 60 bytes, otherwise you
- get long, random delays. So only read analogs every 20ms or so */
- currentMillis = millis();
- if (currentMillis - previousMillis > samplingInterval) {
- previousMillis += samplingInterval;
- while (Firmata.available()) {
- Firmata.processInput();
- }
- for (pin = 0; pin < TOTAL_ANALOG_PINS; pin++) {
- analogValue = analogRead(pin);
- if (analogValue != previousAnalogValues[pin]) {
- Firmata.sendAnalog(pin, analogValue);
- previousAnalogValues[pin] = analogValue;
- }
- }
- }
-}
-
-
diff --git a/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.ino b/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.ino
deleted file mode 100644
index 8c4d9cd49..000000000
--- a/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.ino
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/* This firmware supports as many analog ports as possible, all analog inputs,
- * four PWM outputs, and two with servo support.
- *
- * This example code is in the public domain.
- */
-#include
-#include
-
-/*==============================================================================
- * GLOBAL VARIABLES
- *============================================================================*/
-
-/* servos */
-Servo servo9, servo10; // one instance per pin
-/* analog inputs */
-int analogInputsToReport = 0; // bitwise array to store pin reporting
-int analogPin = 0; // counter for reading analog pins
-/* timer variables */
-unsigned long currentMillis; // store the current value from millis()
-unsigned long previousMillis; // for comparison with currentMillis
-
-
-/*==============================================================================
- * FUNCTIONS
- *============================================================================*/
-
-void analogWriteCallback(byte pin, int value)
-{
- switch (pin) {
- case 9: servo9.write(value); break;
- case 10: servo10.write(value); break;
- case 3:
- case 5:
- case 6:
- case 11: // PWM pins
- analogWrite(pin, value);
- break;
- }
-}
-// -----------------------------------------------------------------------------
-// sets bits in a bit array (int) to toggle the reporting of the analogIns
-void reportAnalogCallback(byte pin, int value)
-{
- if (value == 0) {
- analogInputsToReport = analogInputsToReport &~ (1 << pin);
- }
- else { // everything but 0 enables reporting of that pin
- analogInputsToReport = analogInputsToReport | (1 << pin);
- }
- // TODO: save status to EEPROM here, if changed
-}
-
-/*==============================================================================
- * SETUP()
- *============================================================================*/
-void setup()
-{
- Firmata.setFirmwareVersion(0, 2);
- Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
- Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
-
- servo9.attach(9);
- servo10.attach(10);
- Firmata.begin(57600);
-}
-
-/*==============================================================================
- * LOOP()
- *============================================================================*/
-void loop()
-{
- while (Firmata.available())
- Firmata.processInput();
- currentMillis = millis();
- if (currentMillis - previousMillis > 20) {
- previousMillis += 20; // run this every 20ms
- for (analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) {
- if ( analogInputsToReport & (1 << analogPin) )
- Firmata.sendAnalog(analogPin, analogRead(analogPin));
- }
- }
-}
-
diff --git a/libraries/Firmata/examples/EchoString/EchoString.ino b/libraries/Firmata/examples/EchoString/EchoString.ino
deleted file mode 100644
index eea909587..000000000
--- a/libraries/Firmata/examples/EchoString/EchoString.ino
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/* This sketch accepts strings and raw sysex messages and echos them back.
- *
- * This example code is in the public domain.
- */
-#include
-
-void stringCallback(char *myString)
-{
- Firmata.sendString(myString);
-}
-
-
-void sysexCallback(byte command, byte argc, byte*argv)
-{
- Firmata.sendSysex(command, argc, argv);
-}
-
-void setup()
-{
- Firmata.setFirmwareVersion(0, 1);
- Firmata.attach(STRING_DATA, stringCallback);
- Firmata.attach(START_SYSEX, sysexCallback);
- Firmata.begin(57600);
-}
-
-void loop()
-{
- while (Firmata.available()) {
- Firmata.processInput();
- }
-}
-
-
diff --git a/libraries/Firmata/examples/OldStandardFirmata/LICENSE.txt b/libraries/Firmata/examples/OldStandardFirmata/LICENSE.txt
deleted file mode 100644
index 77cec6dd1..000000000
--- a/libraries/Firmata/examples/OldStandardFirmata/LICENSE.txt
+++ /dev/null
@@ -1,458 +0,0 @@
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
diff --git a/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.ino b/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.ino
deleted file mode 100644
index 761f38880..000000000
--- a/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.ino
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/*
- Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- See file LICENSE.txt for further informations on licensing terms.
- */
-
-/*
- * This is an old version of StandardFirmata (v2.0). It is kept here because
- * its the last version that works on an ATMEGA8 chip. Also, it can be used
- * for host software that has not been updated to a newer version of the
- * protocol. It also uses the old baud rate of 115200 rather than 57600.
- */
-
-#include
-#include
-
-/*==============================================================================
- * GLOBAL VARIABLES
- *============================================================================*/
-
-/* analog inputs */
-int analogInputsToReport = 0; // bitwise array to store pin reporting
-int analogPin = 0; // counter for reading analog pins
-
-/* digital pins */
-byte reportPINs[TOTAL_PORTS]; // PIN == input port
-byte previousPINs[TOTAL_PORTS]; // PIN == input port
-byte pinStatus[TOTAL_PINS]; // store pin status, default OUTPUT
-byte portStatus[TOTAL_PORTS];
-
-/* timer variables */
-unsigned long currentMillis; // store the current value from millis()
-unsigned long previousMillis; // for comparison with currentMillis
-
-
-/*==============================================================================
- * FUNCTIONS
- *============================================================================*/
-
-void outputPort(byte portNumber, byte portValue)
-{
- portValue = portValue &~ portStatus[portNumber];
- if (previousPINs[portNumber] != portValue) {
- Firmata.sendDigitalPort(portNumber, portValue);
- previousPINs[portNumber] = portValue;
- Firmata.sendDigitalPort(portNumber, portValue);
- }
-}
-
-/* -----------------------------------------------------------------------------
- * check all the active digital inputs for change of state, then add any events
- * to the Serial output queue using Serial.print() */
-void checkDigitalInputs(void)
-{
- byte i, tmp;
- for (i = 0; i < TOTAL_PORTS; i++) {
- if (reportPINs[i]) {
- switch (i) {
- case 0: outputPort(0, PIND &~ B00000011); break; // ignore Rx/Tx 0/1
- case 1: outputPort(1, PINB); break;
- case 2: outputPort(2, PINC); break;
- }
- }
- }
-}
-
-// -----------------------------------------------------------------------------
-/* sets the pin mode to the correct state and sets the relevant bits in the
- * two bit-arrays that track Digital I/O and PWM status
- */
-void setPinModeCallback(byte pin, int mode) {
- byte port = 0;
- byte offset = 0;
-
- if (pin < 8) {
- port = 0;
- offset = 0;
- } else if (pin < 14) {
- port = 1;
- offset = 8;
- } else if (pin < 22) {
- port = 2;
- offset = 14;
- }
-
- if (pin > 1) { // ignore RxTx (pins 0 and 1)
- pinStatus[pin] = mode;
- switch (mode) {
- case INPUT:
- pinMode(pin, INPUT);
- portStatus[port] = portStatus[port] &~ (1 << (pin - offset));
- break;
- case OUTPUT:
- digitalWrite(pin, LOW); // disable PWM
- case PWM:
- pinMode(pin, OUTPUT);
- portStatus[port] = portStatus[port] | (1 << (pin - offset));
- break;
- //case ANALOG: // TODO figure this out
- default:
- Firmata.sendString("");
- }
- // TODO: save status to EEPROM here, if changed
- }
-}
-
-void analogWriteCallback(byte pin, int value)
-{
- setPinModeCallback(pin, PWM);
- analogWrite(pin, value);
-}
-
-void digitalWriteCallback(byte port, int value)
-{
- switch (port) {
- case 0: // pins 2-7 (don't change Rx/Tx, pins 0 and 1)
- // 0xFF03 == B1111111100000011 0x03 == B00000011
- PORTD = (value &~ 0xFF03) | (PORTD & 0x03);
- break;
- case 1: // pins 8-13 (14,15 are disabled for the crystal)
- PORTB = (byte)value;
- break;
- case 2: // analog pins used as digital
- PORTC = (byte)value;
- break;
- }
-}
-
-// -----------------------------------------------------------------------------
-/* sets bits in a bit array (int) to toggle the reporting of the analogIns
- */
-//void FirmataClass::setAnalogPinReporting(byte pin, byte state) {
-//}
-void reportAnalogCallback(byte pin, int value)
-{
- if (value == 0) {
- analogInputsToReport = analogInputsToReport &~ (1 << pin);
- }
- else { // everything but 0 enables reporting of that pin
- analogInputsToReport = analogInputsToReport | (1 << pin);
- }
- // TODO: save status to EEPROM here, if changed
-}
-
-void reportDigitalCallback(byte port, int value)
-{
- reportPINs[port] = (byte)value;
- if (port == 2) // turn off analog reporting when used as digital
- analogInputsToReport = 0;
-}
-
-/*==============================================================================
- * SETUP()
- *============================================================================*/
-void setup()
-{
- byte i;
-
- Firmata.setFirmwareVersion(2, 0);
-
- Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
- Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
- Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
- Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
- Firmata.attach(SET_PIN_MODE, setPinModeCallback);
-
- portStatus[0] = B00000011; // ignore Tx/RX pins
- portStatus[1] = B11000000; // ignore 14/15 pins
- portStatus[2] = B00000000;
-
- // for(i=0; i 20) {
- previousMillis += 20; // run this every 20ms
- /* SERIALREAD - Serial.read() uses a 128 byte circular buffer, so handle
- * all serialReads at once, i.e. empty the buffer */
- while (Firmata.available())
- Firmata.processInput();
- /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over
- * 60 bytes. use a timer to sending an event character every 4 ms to
- * trigger the buffer to dump. */
-
- /* ANALOGREAD - right after the event character, do all of the
- * analogReads(). These only need to be done every 4ms. */
- for (analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) {
- if ( analogInputsToReport & (1 << analogPin) ) {
- Firmata.sendAnalog(analogPin, analogRead(analogPin));
- }
- }
- }
-}
diff --git a/libraries/Firmata/examples/ServoFirmata/ServoFirmata.ino b/libraries/Firmata/examples/ServoFirmata/ServoFirmata.ino
deleted file mode 100644
index aab189bd7..000000000
--- a/libraries/Firmata/examples/ServoFirmata/ServoFirmata.ino
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/* This firmware supports as many servos as possible using the Servo library
- * included in Arduino 0017
- *
- * TODO add message to configure minPulse/maxPulse/degrees
- *
- * This example code is in the public domain.
- */
-
-#include
-#include
-
-Servo servos[MAX_SERVOS];
-
-void analogWriteCallback(byte pin, int value)
-{
- if (IS_PIN_SERVO(pin)) {
- servos[PIN_TO_SERVO(pin)].write(value);
- }
-}
-
-void setup()
-{
- byte pin;
-
- Firmata.setFirmwareVersion(0, 2);
- Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
-
- for (pin = 0; pin < TOTAL_PINS; pin++) {
- if (IS_PIN_SERVO(pin)) {
- servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin));
- }
- }
-
- Firmata.begin(57600);
-}
-
-void loop()
-{
- while (Firmata.available())
- Firmata.processInput();
-}
-
diff --git a/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.ino b/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.ino
deleted file mode 100644
index 63ef465c6..000000000
--- a/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.ino
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/* Supports as many analog inputs and analog PWM outputs as possible.
- *
- * This example code is in the public domain.
- */
-#include
-
-byte analogPin = 0;
-
-void analogWriteCallback(byte pin, int value)
-{
- if (IS_PIN_PWM(pin)) {
- pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
- analogWrite(PIN_TO_PWM(pin), value);
- }
-}
-
-void setup()
-{
- Firmata.setFirmwareVersion(0, 1);
- Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
- Firmata.begin(57600);
-}
-
-void loop()
-{
- while (Firmata.available()) {
- Firmata.processInput();
- }
- // do one analogRead per loop, so if PC is sending a lot of
- // analog write messages, we will only delay 1 analogRead
- Firmata.sendAnalog(analogPin, analogRead(analogPin));
- analogPin = analogPin + 1;
- if (analogPin >= TOTAL_ANALOG_PINS) analogPin = 0;
-}
-
diff --git a/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.ino b/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.ino
deleted file mode 100644
index 016c22091..000000000
--- a/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.ino
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/* Supports as many digital inputs and outputs as possible.
- *
- * This example code is in the public domain.
- */
-#include
-
-byte previousPIN[TOTAL_PORTS]; // PIN means PORT for input
-byte previousPORT[TOTAL_PORTS];
-
-void outputPort(byte portNumber, byte portValue)
-{
- // only send the data when it changes, otherwise you get too many messages!
- if (previousPIN[portNumber] != portValue) {
- Firmata.sendDigitalPort(portNumber, portValue);
- previousPIN[portNumber] = portValue;
- }
-}
-
-void setPinModeCallback(byte pin, int mode) {
- if (IS_PIN_DIGITAL(pin)) {
- pinMode(PIN_TO_DIGITAL(pin), mode);
- }
-}
-
-void digitalWriteCallback(byte port, int value)
-{
- byte i;
- byte currentPinValue, previousPinValue;
-
- if (port < TOTAL_PORTS && value != previousPORT[port]) {
- for (i = 0; i < 8; i++) {
- currentPinValue = (byte) value & (1 << i);
- previousPinValue = previousPORT[port] & (1 << i);
- if (currentPinValue != previousPinValue) {
- digitalWrite(i + (port * 8), currentPinValue);
- }
- }
- previousPORT[port] = value;
- }
-}
-
-void setup()
-{
- Firmata.setFirmwareVersion(0, 1);
- Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
- Firmata.attach(SET_PIN_MODE, setPinModeCallback);
- Firmata.begin(57600);
-}
-
-void loop()
-{
- byte i;
-
- for (i = 0; i < TOTAL_PORTS; i++) {
- outputPort(i, readPort(i, 0xff));
- }
-
- while (Firmata.available()) {
- Firmata.processInput();
- }
-}
diff --git a/libraries/Firmata/examples/StandardFirmata/LICENSE.txt b/libraries/Firmata/examples/StandardFirmata/LICENSE.txt
deleted file mode 100644
index 77cec6dd1..000000000
--- a/libraries/Firmata/examples/StandardFirmata/LICENSE.txt
+++ /dev/null
@@ -1,458 +0,0 @@
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
diff --git a/libraries/Firmata/examples/StandardFirmata/StandardFirmata.ino b/libraries/Firmata/examples/StandardFirmata/StandardFirmata.ino
deleted file mode 100644
index 330f39663..000000000
--- a/libraries/Firmata/examples/StandardFirmata/StandardFirmata.ino
+++ /dev/null
@@ -1,640 +0,0 @@
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/*
- Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved.
- Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved.
- Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.
- Copyright (C) 2009-2011 Jeff Hoefs. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- See file LICENSE.txt for further informations on licensing terms.
-
- formatted using the GNU C formatting and indenting
-*/
-
-/*
- * TODO: use Program Control to load stored profiles from EEPROM
- */
-
-#include
-#include
-#include
-
-// move the following defines to Firmata.h?
-#define I2C_WRITE B00000000
-#define I2C_READ B00001000
-#define I2C_READ_CONTINUOUSLY B00010000
-#define I2C_STOP_READING B00011000
-#define I2C_READ_WRITE_MODE_MASK B00011000
-#define I2C_10BIT_ADDRESS_MODE_MASK B00100000
-
-#define MAX_QUERIES 8
-#define MINIMUM_SAMPLING_INTERVAL 10
-
-#define REGISTER_NOT_SPECIFIED -1
-
-/*==============================================================================
- * GLOBAL VARIABLES
- *============================================================================*/
-
-/* analog inputs */
-int analogInputsToReport = 0; // bitwise array to store pin reporting
-
-/* digital input ports */
-byte reportPINs[TOTAL_PORTS]; // 1 = report this port, 0 = silence
-byte previousPINs[TOTAL_PORTS]; // previous 8 bits sent
-
-/* pins configuration */
-byte pinConfig[TOTAL_PINS]; // configuration of every pin
-byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 = anything else
-int pinState[TOTAL_PINS]; // any value that has been written
-
-/* timer variables */
-unsigned long currentMillis; // store the current value from millis()
-unsigned long previousMillis; // for comparison with currentMillis
-int samplingInterval = 19; // how often to run the main loop (in ms)
-
-/* i2c data */
-struct i2c_device_info {
- byte addr;
- byte reg;
- byte bytes;
-};
-
-/* for i2c read continuous more */
-i2c_device_info query[MAX_QUERIES];
-
-byte i2cRxData[32];
-boolean isI2CEnabled = false;
-signed char queryIndex = -1;
-unsigned int i2cReadDelayTime = 0; // default delay time between i2c read request and Wire.requestFrom()
-
-Servo servos[MAX_SERVOS];
-/*==============================================================================
- * FUNCTIONS
- *============================================================================*/
-
-void readAndReportData(byte address, int theRegister, byte numBytes) {
- // allow I2C requests that don't require a register read
- // for example, some devices using an interrupt pin to signify new data available
- // do not always require the register read so upon interrupt you call Wire.requestFrom()
- if (theRegister != REGISTER_NOT_SPECIFIED) {
- Wire.beginTransmission(address);
-#if ARDUINO >= 100
- Wire.write((byte)theRegister);
-#else
- Wire.send((byte)theRegister);
-#endif
- Wire.endTransmission();
- // do not set a value of 0
- if (i2cReadDelayTime > 0) {
- // delay is necessary for some devices such as WiiNunchuck
- delayMicroseconds(i2cReadDelayTime);
- }
- } else {
- theRegister = 0; // fill the register with a dummy value
- }
-
- Wire.requestFrom(address, numBytes); // all bytes are returned in requestFrom
-
- // check to be sure correct number of bytes were returned by slave
- if (numBytes == Wire.available()) {
- i2cRxData[0] = address;
- i2cRxData[1] = theRegister;
- for (int i = 0; i < numBytes; i++) {
-#if ARDUINO >= 100
- i2cRxData[2 + i] = Wire.read();
-#else
- i2cRxData[2 + i] = Wire.receive();
-#endif
- }
- }
- else {
- if (numBytes > Wire.available()) {
- Firmata.sendString("I2C Read Error: Too many bytes received");
- } else {
- Firmata.sendString("I2C Read Error: Too few bytes received");
- }
- }
-
- // send slave address, register and received bytes
- Firmata.sendSysex(SYSEX_I2C_REPLY, numBytes + 2, i2cRxData);
-}
-
-void outputPort(byte portNumber, byte portValue, byte forceSend)
-{
- // pins not configured as INPUT are cleared to zeros
- portValue = portValue & portConfigInputs[portNumber];
- // only send if the value is different than previously sent
- if (forceSend || previousPINs[portNumber] != portValue) {
- Firmata.sendDigitalPort(portNumber, portValue);
- previousPINs[portNumber] = portValue;
- }
-}
-
-/* -----------------------------------------------------------------------------
- * check all the active digital inputs for change of state, then add any events
- * to the Serial output queue using Serial.print() */
-void checkDigitalInputs(void)
-{
- /* Using non-looping code allows constants to be given to readPort().
- * The compiler will apply substantial optimizations if the inputs
- * to readPort() are compile-time constants. */
- if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0, portConfigInputs[0]), false);
- if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1, portConfigInputs[1]), false);
- if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2, portConfigInputs[2]), false);
- if (TOTAL_PORTS > 3 && reportPINs[3]) outputPort(3, readPort(3, portConfigInputs[3]), false);
- if (TOTAL_PORTS > 4 && reportPINs[4]) outputPort(4, readPort(4, portConfigInputs[4]), false);
- if (TOTAL_PORTS > 5 && reportPINs[5]) outputPort(5, readPort(5, portConfigInputs[5]), false);
- if (TOTAL_PORTS > 6 && reportPINs[6]) outputPort(6, readPort(6, portConfigInputs[6]), false);
- if (TOTAL_PORTS > 7 && reportPINs[7]) outputPort(7, readPort(7, portConfigInputs[7]), false);
- if (TOTAL_PORTS > 8 && reportPINs[8]) outputPort(8, readPort(8, portConfigInputs[8]), false);
- if (TOTAL_PORTS > 9 && reportPINs[9]) outputPort(9, readPort(9, portConfigInputs[9]), false);
- if (TOTAL_PORTS > 10 && reportPINs[10]) outputPort(10, readPort(10, portConfigInputs[10]), false);
- if (TOTAL_PORTS > 11 && reportPINs[11]) outputPort(11, readPort(11, portConfigInputs[11]), false);
- if (TOTAL_PORTS > 12 && reportPINs[12]) outputPort(12, readPort(12, portConfigInputs[12]), false);
- if (TOTAL_PORTS > 13 && reportPINs[13]) outputPort(13, readPort(13, portConfigInputs[13]), false);
- if (TOTAL_PORTS > 14 && reportPINs[14]) outputPort(14, readPort(14, portConfigInputs[14]), false);
- if (TOTAL_PORTS > 15 && reportPINs[15]) outputPort(15, readPort(15, portConfigInputs[15]), false);
-}
-
-// -----------------------------------------------------------------------------
-/* sets the pin mode to the correct state and sets the relevant bits in the
- * two bit-arrays that track Digital I/O and PWM status
- */
-void setPinModeCallback(byte pin, int mode)
-{
- if (pinConfig[pin] == I2C && isI2CEnabled && mode != I2C) {
- // disable i2c so pins can be used for other functions
- // the following if statements should reconfigure the pins properly
- disableI2CPins();
- }
- if (IS_PIN_SERVO(pin) && mode != SERVO && servos[PIN_TO_SERVO(pin)].attached()) {
- servos[PIN_TO_SERVO(pin)].detach();
- }
- if (IS_PIN_ANALOG(pin)) {
- reportAnalogCallback(PIN_TO_ANALOG(pin), mode == ANALOG ? 1 : 0); // turn on/off reporting
- }
- if (IS_PIN_DIGITAL(pin)) {
- if (mode == INPUT) {
- portConfigInputs[pin / 8] |= (1 << (pin & 7));
- } else {
- portConfigInputs[pin / 8] &= ~(1 << (pin & 7));
- }
- }
- pinState[pin] = 0;
- switch (mode) {
- case ANALOG:
- if (IS_PIN_ANALOG(pin)) {
- if (IS_PIN_DIGITAL(pin)) {
- pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver
- digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups
- }
- pinConfig[pin] = ANALOG;
- }
- break;
- case INPUT:
- if (IS_PIN_DIGITAL(pin)) {
- pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver
- digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups
- pinConfig[pin] = INPUT;
- }
- break;
- case OUTPUT:
- if (IS_PIN_DIGITAL(pin)) {
- digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable PWM
- pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
- pinConfig[pin] = OUTPUT;
- }
- break;
- case PWM:
- if (IS_PIN_PWM(pin)) {
- pinMode(PIN_TO_PWM(pin), OUTPUT);
- analogWrite(PIN_TO_PWM(pin), 0);
- pinConfig[pin] = PWM;
- }
- break;
- case SERVO:
- if (IS_PIN_SERVO(pin)) {
- pinConfig[pin] = SERVO;
- if (!servos[PIN_TO_SERVO(pin)].attached()) {
- servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin));
- }
- }
- break;
- case I2C:
- if (IS_PIN_I2C(pin)) {
- // mark the pin as i2c
- // the user must call I2C_CONFIG to enable I2C for a device
- pinConfig[pin] = I2C;
- }
- break;
- default:
- Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM
- }
- // TODO: save status to EEPROM here, if changed
-}
-
-void analogWriteCallback(byte pin, int value)
-{
- if (pin < TOTAL_PINS) {
- switch (pinConfig[pin]) {
- case SERVO:
- if (IS_PIN_SERVO(pin))
- servos[PIN_TO_SERVO(pin)].write(value);
- pinState[pin] = value;
- break;
- case PWM:
- if (IS_PIN_PWM(pin))
- analogWrite(PIN_TO_PWM(pin), value);
- pinState[pin] = value;
- break;
- }
- }
-}
-
-void digitalWriteCallback(byte port, int value)
-{
- byte pin, lastPin, mask = 1, pinWriteMask = 0;
-
- if (port < TOTAL_PORTS) {
- // create a mask of the pins on this port that are writable.
- lastPin = port * 8 + 8;
- if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS;
- for (pin = port * 8; pin < lastPin; pin++) {
- // do not disturb non-digital pins (eg, Rx & Tx)
- if (IS_PIN_DIGITAL(pin)) {
- // only write to OUTPUT and INPUT (enables pullup)
- // do not touch pins in PWM, ANALOG, SERVO or other modes
- if (pinConfig[pin] == OUTPUT || pinConfig[pin] == INPUT) {
- pinWriteMask |= mask;
- pinState[pin] = ((byte)value & mask) ? 1 : 0;
- }
- }
- mask = mask << 1;
- }
- writePort(port, (byte)value, pinWriteMask);
- }
-}
-
-
-// -----------------------------------------------------------------------------
-/* sets bits in a bit array (int) to toggle the reporting of the analogIns
- */
-//void FirmataClass::setAnalogPinReporting(byte pin, byte state) {
-//}
-void reportAnalogCallback(byte analogPin, int value)
-{
- if (analogPin < TOTAL_ANALOG_PINS) {
- if (value == 0) {
- analogInputsToReport = analogInputsToReport &~ (1 << analogPin);
- } else {
- analogInputsToReport = analogInputsToReport | (1 << analogPin);
- }
- }
- // TODO: save status to EEPROM here, if changed
-}
-
-void reportDigitalCallback(byte port, int value)
-{
- if (port < TOTAL_PORTS) {
- reportPINs[port] = (byte)value;
- }
- // do not disable analog reporting on these 8 pins, to allow some
- // pins used for digital, others analog. Instead, allow both types
- // of reporting to be enabled, but check if the pin is configured
- // as analog when sampling the analog inputs. Likewise, while
- // scanning digital pins, portConfigInputs will mask off values from any
- // pins configured as analog
-}
-
-/*==============================================================================
- * SYSEX-BASED commands
- *============================================================================*/
-
-void sysexCallback(byte command, byte argc, byte *argv)
-{
- byte mode;
- byte slaveAddress;
- byte slaveRegister;
- byte data;
- unsigned int delayTime;
-
- switch (command) {
- case I2C_REQUEST:
- mode = argv[1] & I2C_READ_WRITE_MODE_MASK;
- if (argv[1] & I2C_10BIT_ADDRESS_MODE_MASK) {
- Firmata.sendString("10-bit addressing mode is not yet supported");
- return;
- }
- else {
- slaveAddress = argv[0];
- }
-
- switch (mode) {
- case I2C_WRITE:
- Wire.beginTransmission(slaveAddress);
- for (byte i = 2; i < argc; i += 2) {
- data = argv[i] + (argv[i + 1] << 7);
-#if ARDUINO >= 100
- Wire.write(data);
-#else
- Wire.send(data);
-#endif
- }
- Wire.endTransmission();
- delayMicroseconds(70);
- break;
- case I2C_READ:
- if (argc == 6) {
- // a slave register is specified
- slaveRegister = argv[2] + (argv[3] << 7);
- data = argv[4] + (argv[5] << 7); // bytes to read
- readAndReportData(slaveAddress, (int)slaveRegister, data);
- }
- else {
- // a slave register is NOT specified
- data = argv[2] + (argv[3] << 7); // bytes to read
- readAndReportData(slaveAddress, (int)REGISTER_NOT_SPECIFIED, data);
- }
- break;
- case I2C_READ_CONTINUOUSLY:
- if ((queryIndex + 1) >= MAX_QUERIES) {
- // too many queries, just ignore
- Firmata.sendString("too many queries");
- break;
- }
- queryIndex++;
- query[queryIndex].addr = slaveAddress;
- query[queryIndex].reg = argv[2] + (argv[3] << 7);
- query[queryIndex].bytes = argv[4] + (argv[5] << 7);
- break;
- case I2C_STOP_READING:
- byte queryIndexToSkip;
- // if read continuous mode is enabled for only 1 i2c device, disable
- // read continuous reporting for that device
- if (queryIndex <= 0) {
- queryIndex = -1;
- } else {
- // if read continuous mode is enabled for multiple devices,
- // determine which device to stop reading and remove it's data from
- // the array, shifiting other array data to fill the space
- for (byte i = 0; i < queryIndex + 1; i++) {
- if (query[i].addr = slaveAddress) {
- queryIndexToSkip = i;
- break;
- }
- }
-
- for (byte i = queryIndexToSkip; i < queryIndex + 1; i++) {
- if (i < MAX_QUERIES) {
- query[i].addr = query[i + 1].addr;
- query[i].reg = query[i + 1].addr;
- query[i].bytes = query[i + 1].bytes;
- }
- }
- queryIndex--;
- }
- break;
- default:
- break;
- }
- break;
- case I2C_CONFIG:
- delayTime = (argv[0] + (argv[1] << 7));
-
- if (delayTime > 0) {
- i2cReadDelayTime = delayTime;
- }
-
- if (!isI2CEnabled) {
- enableI2CPins();
- }
-
- break;
- case SERVO_CONFIG:
- if (argc > 4) {
- // these vars are here for clarity, they'll optimized away by the compiler
- byte pin = argv[0];
- int minPulse = argv[1] + (argv[2] << 7);
- int maxPulse = argv[3] + (argv[4] << 7);
-
- if (IS_PIN_SERVO(pin)) {
- if (servos[PIN_TO_SERVO(pin)].attached())
- servos[PIN_TO_SERVO(pin)].detach();
- servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse);
- setPinModeCallback(pin, SERVO);
- }
- }
- break;
- case SAMPLING_INTERVAL:
- if (argc > 1) {
- samplingInterval = argv[0] + (argv[1] << 7);
- if (samplingInterval < MINIMUM_SAMPLING_INTERVAL) {
- samplingInterval = MINIMUM_SAMPLING_INTERVAL;
- }
- } else {
- //Firmata.sendString("Not enough data");
- }
- break;
- case EXTENDED_ANALOG:
- if (argc > 1) {
- int val = argv[1];
- if (argc > 2) val |= (argv[2] << 7);
- if (argc > 3) val |= (argv[3] << 14);
- analogWriteCallback(argv[0], val);
- }
- break;
- case CAPABILITY_QUERY:
- Firmata.write(START_SYSEX);
- Firmata.write(CAPABILITY_RESPONSE);
- for (byte pin = 0; pin < TOTAL_PINS; pin++) {
- if (IS_PIN_DIGITAL(pin)) {
- Firmata.write((byte)INPUT);
- Firmata.write(1);
- Firmata.write((byte)OUTPUT);
- Firmata.write(1);
- }
- if (IS_PIN_ANALOG(pin)) {
- Firmata.write(ANALOG);
- Firmata.write(10);
- }
- if (IS_PIN_PWM(pin)) {
- Firmata.write(PWM);
- Firmata.write(8);
- }
- if (IS_PIN_SERVO(pin)) {
- Firmata.write(SERVO);
- Firmata.write(14);
- }
- if (IS_PIN_I2C(pin)) {
- Firmata.write(I2C);
- Firmata.write(1); // to do: determine appropriate value
- }
- Firmata.write(127);
- }
- Firmata.write(END_SYSEX);
- break;
- case PIN_STATE_QUERY:
- if (argc > 0) {
- byte pin = argv[0];
- Firmata.write(START_SYSEX);
- Firmata.write(PIN_STATE_RESPONSE);
- Firmata.write(pin);
- if (pin < TOTAL_PINS) {
- Firmata.write((byte)pinConfig[pin]);
- Firmata.write((byte)pinState[pin] & 0x7F);
- if (pinState[pin] & 0xFF80) Firmata.write((byte)(pinState[pin] >> 7) & 0x7F);
- if (pinState[pin] & 0xC000) Firmata.write((byte)(pinState[pin] >> 14) & 0x7F);
- }
- Firmata.write(END_SYSEX);
- }
- break;
- case ANALOG_MAPPING_QUERY:
- Firmata.write(START_SYSEX);
- Firmata.write(ANALOG_MAPPING_RESPONSE);
- for (byte pin = 0; pin < TOTAL_PINS; pin++) {
- Firmata.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
- }
- Firmata.write(END_SYSEX);
- break;
- }
-}
-
-void enableI2CPins()
-{
- byte i;
- // is there a faster way to do this? would probaby require importing
- // Arduino.h to get SCL and SDA pins
- for (i = 0; i < TOTAL_PINS; i++) {
- if (IS_PIN_I2C(i)) {
- // mark pins as i2c so they are ignore in non i2c data requests
- setPinModeCallback(i, I2C);
- }
- }
-
- isI2CEnabled = true;
-
- // is there enough time before the first I2C request to call this here?
- Wire.begin();
-}
-
-/* disable the i2c pins so they can be used for other functions */
-void disableI2CPins() {
- isI2CEnabled = false;
- // disable read continuous mode for all devices
- queryIndex = -1;
- // uncomment the following if or when the end() method is added to Wire library
- // Wire.end();
-}
-
-/*==============================================================================
- * SETUP()
- *============================================================================*/
-
-void systemResetCallback()
-{
- // initialize a defalt state
- // TODO: option to load config from EEPROM instead of default
- if (isI2CEnabled) {
- disableI2CPins();
- }
- for (byte i = 0; i < TOTAL_PORTS; i++) {
- reportPINs[i] = false; // by default, reporting off
- portConfigInputs[i] = 0; // until activated
- previousPINs[i] = 0;
- }
- // pins with analog capability default to analog input
- // otherwise, pins default to digital output
- for (byte i = 0; i < TOTAL_PINS; i++) {
- if (IS_PIN_ANALOG(i)) {
- // turns off pullup, configures everything
- setPinModeCallback(i, ANALOG);
- } else {
- // sets the output to 0, configures portConfigInputs
- setPinModeCallback(i, OUTPUT);
- }
- }
- // by default, do not report any analog inputs
- analogInputsToReport = 0;
-
- /* send digital inputs to set the initial state on the host computer,
- * since once in the loop(), this firmware will only send on change */
- /*
- TODO: this can never execute, since no pins default to digital input
- but it will be needed when/if we support EEPROM stored config
- for (byte i=0; i < TOTAL_PORTS; i++) {
- outputPort(i, readPort(i, portConfigInputs[i]), true);
- }
- */
-}
-
-void setup()
-{
- Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);
-
- Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
- Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
- Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
- Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
- Firmata.attach(SET_PIN_MODE, setPinModeCallback);
- Firmata.attach(START_SYSEX, sysexCallback);
- Firmata.attach(SYSTEM_RESET, systemResetCallback);
-
- Firmata.begin(57600);
- systemResetCallback(); // reset to default config
-}
-
-/*==============================================================================
- * LOOP()
- *============================================================================*/
-void loop()
-{
- byte pin, analogPin;
-
- /* DIGITALREAD - as fast as possible, check for changes and output them to the
- * FTDI buffer using Serial.print() */
- checkDigitalInputs();
-
- /* SERIALREAD - processing incoming messagse as soon as possible, while still
- * checking digital inputs. */
- while (Firmata.available())
- Firmata.processInput();
-
- /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over
- * 60 bytes. use a timer to sending an event character every 4 ms to
- * trigger the buffer to dump. */
-
- currentMillis = millis();
- if (currentMillis - previousMillis > samplingInterval) {
- previousMillis += samplingInterval;
- /* ANALOGREAD - do all analogReads() at the configured sampling interval */
- for (pin = 0; pin < TOTAL_PINS; pin++) {
- if (IS_PIN_ANALOG(pin) && pinConfig[pin] == ANALOG) {
- analogPin = PIN_TO_ANALOG(pin);
- if (analogInputsToReport & (1 << analogPin)) {
- Firmata.sendAnalog(analogPin, analogRead(analogPin));
- }
- }
- }
- // report i2c data for all device with read continuous mode enabled
- if (queryIndex > -1) {
- for (byte i = 0; i < queryIndex + 1; i++) {
- readAndReportData(query[i].addr, query[i].reg, query[i].bytes);
- }
- }
- }
-}
diff --git a/libraries/Firmata/extras/LICENSE.txt b/libraries/Firmata/extras/LICENSE.txt
deleted file mode 100644
index 77cec6dd1..000000000
--- a/libraries/Firmata/extras/LICENSE.txt
+++ /dev/null
@@ -1,458 +0,0 @@
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
diff --git a/libraries/Firmata/extras/readme.md b/libraries/Firmata/extras/readme.md
deleted file mode 100644
index 498a231b9..000000000
--- a/libraries/Firmata/extras/readme.md
+++ /dev/null
@@ -1,71 +0,0 @@
-#Firmata
-
-Firmata is a protocol for communicating with microcontrollers from software on a host computer. The [protocol](http://firmata.org/wiki/Protocol) can be implemented in firmware on any microcontroller architecture as well as software on any host computer software package. The arduino repository described here is a Firmata library for Arduino and Arduino-compatible devices. See the [firmata wiki](http://firmata.org/wiki/Main_Page) for additional informataion. If you would like to contribute to Firmata, please see the [Contributing](#contributing) section below.
-
-##Usage
-
-There are two main models of usage of Firmata. In one model, the author of the Arduino sketch uses the various methods provided by the Firmata library to selectively send and receive data between the Arduino device and the software running on the host computer. For example, a user can send analog data to the host using ``` Firmata.sendAnalog(analogPin, analogRead(analogPin)) ``` or send data packed in a string using ``` Firmata.sendString(stringToSend) ```. See File -> Examples -> Firmata -> AnalogFirmata & EchoString respectively for examples.
-
-The second and more common model is to load a general purpose sketch called StandardFirmata on the Arduino board and then use the host computer exclusively to interact with the Arduino board. StandardFirmata is located in the Arduino IDE in File -> Examples -> Firmata.
-
-##Firmata Client Libraries
-Most of the time you will be interacting with arduino with a client library on the host computers. Several Firmata client libraries have been implemented in a variety of popular programming languages:
-
-* procesing
- * [https://github.com/firmata/processing]
- * [http://funnel.cc]
-* python
- * [https://github.com/firmata/pyduino]
- * [https://github.com/lupeke/python-firmata]
- * [https://github.com/tino/pyFirmata]
-* perl
- * [https://github.com/ntruchsess/perl-firmata]
- * [https://github.com/rcaputo/rx-firmata]
-* ruby
- * [https://github.com/hardbap/firmata]
- * [https://github.com/PlasticLizard/rufinol]
- * [http://funnel.cc]
-* clojure
- * [https://github.com/nakkaya/clodiuno]
-* javascript
- * [https://github.com/jgautier/firmata]
- * [http://breakoutjs.com]
- * [https://github.com/rwldrn/johnny-five]
-* java
- * [https://github.com/4ntoine/Firmata]
- * [https://github.com/shigeodayo/Javarduino]
-* .NET
- * [http://www.imagitronics.org/projects/firmatanet/]
-* Flash/AS3
- * [http://funnel.cc]
- * [http://code.google.com/p/as3glue/]
-* PHP
- * [https://bitbucket.org/ThomasWeinert/carica-firmata]
-
-Note: The above libraries may support various versions of the Firmata protocol and therefore may not support all features of the latest Firmata spec nor all arduino and arduino-compatible boards. Refer to the respective projects for details.
-
-
-
-##Contributing
-
-If you discover a bug or would like to propose a new feature, please open a new [issue](https://github.com/firmata/arduino/issues?sort=created&state=open). Due to the limited memory of standard Arduino boards we cannot add every requested feature to StandardFirmata. Requests to add new features to StandardFirmata will be evaluated by the Firmata developers. However it is still possible to add new features to other Firmata implementations (Firmata is a protocol whereas StandardFirmata is just one of many possible implementations).
-
-To contribute, fork this respository and create a new topic branch for the bug, feature or other existing issue you are addressing. Submit the pull request against the *dev* branch.
-
-If you would like to contribute but don't have a specific bugfix or new feature to contribute, you can take on an existing issue, see issues labeled "pull-request-encouraged". Add a comment to the issue to express your intent to begin work and/or to get any additional information about the issue.
-
-You must thorougly test your contributed code. In your pull request, describe tests performed to ensure that no existing code is broken and that any changes maintain backwards compatibility with the existing api. Test on multiple Arduino board variants if possible. We hope to enable some form of automated (or at least semi-automated) testing in the future, but for now any tests will need to be executed manually by the contributor and reviewsers.
-
-Maintain the existing code style:
-
-- Indentation is 2 spaces
-- Use spaces instead of tabs
-- Use camel case for both private and public properties and methods
-- Document functions (specific doc style is TBD... for now just be sure to document)
-- Insert first block bracket on line following the function definition:
-
-void someFunction()
-{
- // do something
-}
-
diff --git a/libraries/Firmata/keywords.txt b/libraries/Firmata/keywords.txt
deleted file mode 100644
index ca4522c3d..000000000
--- a/libraries/Firmata/keywords.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-#######################################
-# Syntax Coloring Map For Firmata
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-
-Firmata KEYWORD1 Firmata
-callbackFunction KEYWORD1
-systemResetCallbackFunction KEYWORD1
-stringCallbackFunction KEYWORD1
-sysexCallbackFunction KEYWORD1
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-begin KEYWORD2
-begin KEYWORD2
-printVersion KEYWORD2
-blinkVersion KEYWORD2
-printFirmwareVersion KEYWORD2
-setFirmwareVersion KEYWORD2
-setFirmwareNameAndVersion KEYWORD2
-available KEYWORD2
-processInput KEYWORD2
-sendAnalog KEYWORD2
-sendDigital KEYWORD2
-sendDigitalPortPair KEYWORD2
-sendDigitalPort KEYWORD2
-sendString KEYWORD2
-sendString KEYWORD2
-sendSysex KEYWORD2
-attach KEYWORD2
-detach KEYWORD2
-flush KEYWORD2
-
-
-#######################################
-# Constants (LITERAL1)
-#######################################
-
-MAX_DATA_BYTES LITERAL1
-
-DIGITAL_MESSAGE LITERAL1
-ANALOG_MESSAGE LITERAL1
-REPORT_ANALOG LITERAL1
-REPORT_DIGITAL LITERAL1
-REPORT_VERSION LITERAL1
-SET_PIN_MODE LITERAL1
-SYSTEM_RESET LITERAL1
-
-START_SYSEX LITERAL1
-END_SYSEX LITERAL1
-
-PWM LITERAL1
-
-TOTAL_ANALOG_PINS LITERAL1
-TOTAL_DIGITAL_PINS LITERAL1
-TOTAL_PORTS LITERAL1
-ANALOG_PORT LITERAL1
diff --git a/libraries/Firmata/library.properties b/libraries/Firmata/library.properties
deleted file mode 100644
index 4b508d57c..000000000
--- a/libraries/Firmata/library.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-name=Firmata
-version=2.3.8
-author=Firmata Developers
-maintainer=Firmata Developers
-sentence=Enables the communication with computer apps using a standard serial protocol. For all Arduino boards.
-paragraph=The Firmata library implements the Firmata protocol for communicating with software on the host computer. This allows you to write custom firmware without having to create your own protocol and objects for the programming environment that you are using.
-category=Device Control
-url=http://firmata.org
-architectures=*
diff --git a/libraries/Firmata/src/Boards.h b/libraries/Firmata/src/Boards.h
deleted file mode 100644
index 67cae11a8..000000000
--- a/libraries/Firmata/src/Boards.h
+++ /dev/null
@@ -1,425 +0,0 @@
-/* Boards.h - Hardware Abstraction Layer for Firmata library */
-
-#ifndef Firmata_Boards_h
-#define Firmata_Boards_h
-
-#include
-
-#if defined(ARDUINO) && ARDUINO >= 100
-#include "Arduino.h" // for digitalRead, digitalWrite, etc
-#else
-#include "WProgram.h"
-#endif
-
-// Normally Servo.h must be included before Firmata.h (which then includes
-// this file). If Servo.h wasn't included, this allows the code to still
-// compile, but without support for any Servos. Hopefully that's what the
-// user intended by not including Servo.h
-#ifndef MAX_SERVOS
-#define MAX_SERVOS 0
-#endif
-
-/*
- Firmata Hardware Abstraction Layer
-
-Firmata is built on top of the hardware abstraction functions of Arduino,
-specifically digitalWrite, digitalRead, analogWrite, analogRead, and
-pinMode. While these functions offer simple integer pin numbers, Firmata
-needs more information than is provided by Arduino. This file provides
-all other hardware specific details. To make Firmata support a new board,
-only this file should require editing.
-
-The key concept is every "pin" implemented by Firmata may be mapped to
-any pin as implemented by Arduino. Usually a simple 1-to-1 mapping is
-best, but such mapping should not be assumed. This hardware abstraction
-layer allows Firmata to implement any number of pins which map onto the
-Arduino implemented pins in almost any arbitrary way.
-
-
-General Constants:
-
-These constants provide basic information Firmata requires.
-
-TOTAL_PINS: The total number of pins Firmata implemented by Firmata.
- Usually this will match the number of pins the Arduino functions
- implement, including any pins pins capable of analog or digital.
- However, Firmata may implement any number of pins. For example,
- on Arduino Mini with 8 analog inputs, 6 of these may be used
- for digital functions, and 2 are analog only. On such boards,
- Firmata can implement more pins than Arduino's pinMode()
- function, in order to accommodate those special pins. The
- Firmata protocol supports a maximum of 128 pins, so this
- constant must not exceed 128.
-
-TOTAL_ANALOG_PINS: The total number of analog input pins implemented.
- The Firmata protocol allows up to 16 analog inputs, accessed
- using offsets 0 to 15. Because Firmata presents the analog
- inputs using different offsets than the actual pin numbers
- (a legacy of Arduino's analogRead function, and the way the
- analog input capable pins are physically labeled on all
- Arduino boards), the total number of analog input signals
- must be specified. 16 is the maximum.
-
-VERSION_BLINK_PIN: When Firmata starts up, it will blink the version
- number. This constant is the Arduino pin number where a
- LED is connected.
-
-
-Pin Mapping Macros:
-
-These macros provide the mapping between pins as implemented by
-Firmata protocol and the actual pin numbers used by the Arduino
-functions. Even though such mappings are often simple, pin
-numbers received by Firmata protocol should always be used as
-input to these macros, and the result of the macro should be
-used with with any Arduino function.
-
-When Firmata is extended to support a new pin mode or feature,
-a pair of macros should be added and used for all hardware
-access. For simple 1:1 mapping, these macros add no actual
-overhead, yet their consistent use allows source code which
-uses them consistently to be easily adapted to all other boards
-with different requirements.
-
-IS_PIN_XXXX(pin): The IS_PIN macros resolve to true or non-zero
- if a pin as implemented by Firmata corresponds to a pin
- that actually implements the named feature.
-
-PIN_TO_XXXX(pin): The PIN_TO macros translate pin numbers as
- implemented by Firmata to the pin numbers needed as inputs
- to the Arduino functions. The corresponding IS_PIN macro
- should always be tested before using a PIN_TO macro, so
- these macros only need to handle valid Firmata pin
- numbers for the named feature.
-
-
-Port Access Inline Funtions:
-
-For efficiency, Firmata protocol provides access to digital
-input and output pins grouped by 8 bit ports. When these
-groups of 8 correspond to actual 8 bit ports as implemented
-by the hardware, these inline functions can provide high
-speed direct port access. Otherwise, a default implementation
-using 8 calls to digitalWrite or digitalRead is used.
-
-When porting Firmata to a new board, it is recommended to
-use the default functions first and focus only on the constants
-and macros above. When those are working, if optimized port
-access is desired, these inline functions may be extended.
-The recommended approach defines a symbol indicating which
-optimization to use, and then conditional complication is
-used within these functions.
-
-readPort(port, bitmask): Read an 8 bit port, returning the value.
- port: The port number, Firmata pins port*8 to port*8+7
- bitmask: The actual pins to read, indicated by 1 bits.
-
-writePort(port, value, bitmask): Write an 8 bit port.
- port: The port number, Firmata pins port*8 to port*8+7
- value: The 8 bit value to write
- bitmask: The actual pins to write, indicated by 1 bits.
-*/
-
-/*==============================================================================
- * Board Specific Configuration
- *============================================================================*/
-
-#ifndef digitalPinHasPWM
-#define digitalPinHasPWM(p) IS_PIN_DIGITAL(p)
-#endif
-
-// Arduino Duemilanove, Diecimila, and NG
-#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
-#if defined(NUM_ANALOG_INPUTS) && NUM_ANALOG_INPUTS == 6
-#define TOTAL_ANALOG_PINS 6
-#define TOTAL_PINS 20 // 14 digital + 6 analog
-#else
-#define TOTAL_ANALOG_PINS 8
-#define TOTAL_PINS 22 // 14 digital + 8 analog
-#endif
-#define VERSION_BLINK_PIN 13
-#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19)
-#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19)
-#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) ((p) - 14)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) ((p) - 2)
-#define ARDUINO_PINOUT_OPTIMIZE 1
-
-
-// Wiring (and board)
-#elif defined(WIRING)
-#define VERSION_BLINK_PIN WLED
-#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) ((p) >= FIRST_ANALOG_PIN && (p) < (FIRST_ANALOG_PIN+TOTAL_ANALOG_PINS))
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL)
-#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) ((p) - FIRST_ANALOG_PIN)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) (p)
-
-
-// old Arduinos
-#elif defined(__AVR_ATmega8__)
-#define TOTAL_ANALOG_PINS 6
-#define TOTAL_PINS 20 // 14 digital + 6 analog
-#define VERSION_BLINK_PIN 13
-#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19)
-#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) <= 19)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) ((p) - 14)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) ((p) - 2)
-#define ARDUINO_PINOUT_OPTIMIZE 1
-
-
-// Arduino Mega
-#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
-#define TOTAL_ANALOG_PINS 16
-#define TOTAL_PINS 70 // 54 digital + 16 analog
-#define VERSION_BLINK_PIN 13
-#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) ((p) >= 54 && (p) < TOTAL_PINS)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 2 && (p) - 2 < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21)
-#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) ((p) - 54)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) ((p) - 2)
-
-
-// Arduino DUE
-#elif defined(__SAM3X8E__)
-#define TOTAL_ANALOG_PINS 12
-#define TOTAL_PINS 66 // 54 digital + 12 analog
-#define VERSION_BLINK_PIN 13
-#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) ((p) >= 54 && (p) < TOTAL_PINS)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 2 && (p) - 2 < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21) // 70 71
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) ((p) - 54)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) ((p) - 2)
-
-
-// Teensy 1.0
-#elif defined(__AVR_AT90USB162__)
-#define TOTAL_ANALOG_PINS 0
-#define TOTAL_PINS 21 // 21 digital + no analog
-#define VERSION_BLINK_PIN 6
-#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) (0)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
-#define IS_PIN_I2C(p) (0)
-#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) (0)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) (p)
-
-
-// Teensy 2.0
-#elif defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY)
-#define TOTAL_ANALOG_PINS 12
-#define TOTAL_PINS 25 // 11 digital + 12 analog
-#define VERSION_BLINK_PIN 11
-#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) ((p) >= 11 && (p) <= 22)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 5 || (p) == 6)
-#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) (((p)<22)?21-(p):11)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) (p)
-
-
-// Teensy 3.0
-#elif defined(__MK20DX128__)
-#define TOTAL_ANALOG_PINS 14
-#define TOTAL_PINS 38 // 24 digital + 10 analog-digital + 4 analog
-#define VERSION_BLINK_PIN 13
-#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 34)
-#define IS_PIN_ANALOG(p) (((p) >= 14 && (p) <= 23) || ((p) >= 34 && (p) <= 38))
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) (((p)<=23)?(p)-14:(p)-24)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) (p)
-
-
-// Teensy++ 1.0 and 2.0
-#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
-#define TOTAL_ANALOG_PINS 8
-#define TOTAL_PINS 46 // 38 digital + 8 analog
-#define VERSION_BLINK_PIN 6
-#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) ((p) >= 38 && (p) < TOTAL_PINS)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 0 || (p) == 1)
-#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) ((p) - 38)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) (p)
-
-
-// Leonardo
-#elif defined(__AVR_ATmega32U4__)
-#define TOTAL_ANALOG_PINS 12
-#define TOTAL_PINS 30 // 14 digital + 12 analog + 4 SPI (D14-D17 on ISP header)
-#define VERSION_BLINK_PIN 13
-#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) ((p) >= 18 && (p) < TOTAL_PINS)
-#define IS_PIN_PWM(p) ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11 || (p) == 13)
-#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 2 || (p) == 3)
-#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) (p) - 18
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) (p)
-
-
-// Sanguino
-#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
-#define TOTAL_ANALOG_PINS 8
-#define TOTAL_PINS 32 // 24 digital + 8 analog
-#define VERSION_BLINK_PIN 0
-#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) ((p) >= 24 && (p) < TOTAL_PINS)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 16 || (p) == 17)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) ((p) - 24)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) ((p) - 2)
-
-
-// Illuminato
-#elif defined(__AVR_ATmega645__)
-#define TOTAL_ANALOG_PINS 6
-#define TOTAL_PINS 42 // 36 digital + 6 analog
-#define VERSION_BLINK_PIN 13
-#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS)
-#define IS_PIN_ANALOG(p) ((p) >= 36 && (p) < TOTAL_PINS)
-#define IS_PIN_PWM(p) digitalPinHasPWM(p)
-#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
-#define IS_PIN_I2C(p) ((p) == 4 || (p) == 5)
-#define PIN_TO_DIGITAL(p) (p)
-#define PIN_TO_ANALOG(p) ((p) - 36)
-#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
-#define PIN_TO_SERVO(p) ((p) - 2)
-
-
-// anything else
-#else
-#error "Please edit Boards.h with a hardware abstraction for this board"
-#endif
-
-// as long this is not defined for all boards:
-#ifndef IS_PIN_SPI(p)
-#define IS_PIN_SPI(p) 0
-#endif
-
-/*==============================================================================
- * readPort() - Read an 8 bit port
- *============================================================================*/
-
-static inline unsigned char readPort(byte, byte) __attribute__((always_inline, unused));
-static inline unsigned char readPort(byte port, byte bitmask)
-{
-#if defined(ARDUINO_PINOUT_OPTIMIZE)
- if (port == 0) return (PIND & 0xFC) & bitmask; // ignore Rx/Tx 0/1
- if (port == 1) return ((PINB & 0x3F) | ((PINC & 0x03) << 6)) & bitmask;
- if (port == 2) return ((PINC & 0x3C) >> 2) & bitmask;
- return 0;
-#else
- unsigned char out=0, pin=port*8;
- if (IS_PIN_DIGITAL(pin+0) && (bitmask & 0x01) && digitalRead(PIN_TO_DIGITAL(pin+0))) out |= 0x01;
- if (IS_PIN_DIGITAL(pin+1) && (bitmask & 0x02) && digitalRead(PIN_TO_DIGITAL(pin+1))) out |= 0x02;
- if (IS_PIN_DIGITAL(pin+2) && (bitmask & 0x04) && digitalRead(PIN_TO_DIGITAL(pin+2))) out |= 0x04;
- if (IS_PIN_DIGITAL(pin+3) && (bitmask & 0x08) && digitalRead(PIN_TO_DIGITAL(pin+3))) out |= 0x08;
- if (IS_PIN_DIGITAL(pin+4) && (bitmask & 0x10) && digitalRead(PIN_TO_DIGITAL(pin+4))) out |= 0x10;
- if (IS_PIN_DIGITAL(pin+5) && (bitmask & 0x20) && digitalRead(PIN_TO_DIGITAL(pin+5))) out |= 0x20;
- if (IS_PIN_DIGITAL(pin+6) && (bitmask & 0x40) && digitalRead(PIN_TO_DIGITAL(pin+6))) out |= 0x40;
- if (IS_PIN_DIGITAL(pin+7) && (bitmask & 0x80) && digitalRead(PIN_TO_DIGITAL(pin+7))) out |= 0x80;
- return out;
-#endif
-}
-
-/*==============================================================================
- * writePort() - Write an 8 bit port, only touch pins specified by a bitmask
- *============================================================================*/
-
-static inline unsigned char writePort(byte, byte, byte) __attribute__((always_inline, unused));
-static inline unsigned char writePort(byte port, byte value, byte bitmask)
-{
-#if defined(ARDUINO_PINOUT_OPTIMIZE)
- if (port == 0) {
- bitmask = bitmask & 0xFC; // do not touch Tx & Rx pins
- byte valD = value & bitmask;
- byte maskD = ~bitmask;
- cli();
- PORTD = (PORTD & maskD) | valD;
- sei();
- } else if (port == 1) {
- byte valB = (value & bitmask) & 0x3F;
- byte valC = (value & bitmask) >> 6;
- byte maskB = ~(bitmask & 0x3F);
- byte maskC = ~((bitmask & 0xC0) >> 6);
- cli();
- PORTB = (PORTB & maskB) | valB;
- PORTC = (PORTC & maskC) | valC;
- sei();
- } else if (port == 2) {
- bitmask = bitmask & 0x0F;
- byte valC = (value & bitmask) << 2;
- byte maskC = ~(bitmask << 2);
- cli();
- PORTC = (PORTC & maskC) | valC;
- sei();
- }
-#else
- byte pin=port*8;
- if ((bitmask & 0x01)) digitalWrite(PIN_TO_DIGITAL(pin+0), (value & 0x01));
- if ((bitmask & 0x02)) digitalWrite(PIN_TO_DIGITAL(pin+1), (value & 0x02));
- if ((bitmask & 0x04)) digitalWrite(PIN_TO_DIGITAL(pin+2), (value & 0x04));
- if ((bitmask & 0x08)) digitalWrite(PIN_TO_DIGITAL(pin+3), (value & 0x08));
- if ((bitmask & 0x10)) digitalWrite(PIN_TO_DIGITAL(pin+4), (value & 0x10));
- if ((bitmask & 0x20)) digitalWrite(PIN_TO_DIGITAL(pin+5), (value & 0x20));
- if ((bitmask & 0x40)) digitalWrite(PIN_TO_DIGITAL(pin+6), (value & 0x40));
- if ((bitmask & 0x80)) digitalWrite(PIN_TO_DIGITAL(pin+7), (value & 0x80));
-#endif
-}
-
-
-
-
-#ifndef TOTAL_PORTS
-#define TOTAL_PORTS ((TOTAL_PINS + 7) / 8)
-#endif
-
-
-#endif /* Firmata_Boards_h */
-
diff --git a/libraries/Firmata/src/Firmata.cpp b/libraries/Firmata/src/Firmata.cpp
deleted file mode 100644
index 7dddfd465..000000000
--- a/libraries/Firmata/src/Firmata.cpp
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- Firmata.cpp - Firmata library
- Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- See file LICENSE.txt for further informations on licensing terms.
-*/
-
-//******************************************************************************
-//* Includes
-//******************************************************************************
-
-#include "Firmata.h"
-#include "HardwareSerial.h"
-
-extern "C" {
-#include
-#include
-}
-
-//******************************************************************************
-//* Support Functions
-//******************************************************************************
-
-void FirmataClass::sendValueAsTwo7bitBytes(int value)
-{
- FirmataSerial->write(value & B01111111); // LSB
- FirmataSerial->write(value >> 7 & B01111111); // MSB
-}
-
-void FirmataClass::startSysex(void)
-{
- FirmataSerial->write(START_SYSEX);
-}
-
-void FirmataClass::endSysex(void)
-{
- FirmataSerial->write(END_SYSEX);
-}
-
-//******************************************************************************
-//* Constructors
-//******************************************************************************
-
-FirmataClass::FirmataClass()
-{
- firmwareVersionCount = 0;
- firmwareVersionVector = 0;
- systemReset();
-}
-
-//******************************************************************************
-//* Public Methods
-//******************************************************************************
-
-/* begin method with default serial bitrate */
-void FirmataClass::begin(void)
-{
- begin(57600);
-}
-
-/* begin method for overriding default serial bitrate */
-void FirmataClass::begin(long speed)
-{
- Serial.begin(speed);
- FirmataSerial = &Serial;
- blinkVersion();
- printVersion();
- printFirmwareVersion();
-}
-
-/* begin method for overriding default stream */
-void FirmataClass::begin(Stream &s)
-{
- FirmataSerial = &s;
- // do not call blinkVersion() here because some hardware such as the
- // Ethernet shield use pin 13
- printVersion();
- printFirmwareVersion();
-}
-
-// output the protocol version message to the serial port
-void FirmataClass::printVersion(void) {
- FirmataSerial->write(REPORT_VERSION);
- FirmataSerial->write(FIRMATA_MAJOR_VERSION);
- FirmataSerial->write(FIRMATA_MINOR_VERSION);
-}
-
-void FirmataClass::blinkVersion(void)
-{
- // flash the pin with the protocol version
- pinMode(VERSION_BLINK_PIN,OUTPUT);
- strobeBlinkPin(FIRMATA_MAJOR_VERSION, 40, 210);
- delay(250);
- strobeBlinkPin(FIRMATA_MINOR_VERSION, 40, 210);
- delay(125);
-}
-
-void FirmataClass::printFirmwareVersion(void)
-{
- byte i;
-
- if(firmwareVersionCount) { // make sure that the name has been set before reporting
- startSysex();
- FirmataSerial->write(REPORT_FIRMWARE);
- FirmataSerial->write(firmwareVersionVector[0]); // major version number
- FirmataSerial->write(firmwareVersionVector[1]); // minor version number
- for(i=2; iavailable();
-}
-
-
-void FirmataClass::processSysexMessage(void)
-{
- switch(storedInputData[0]) { //first byte in buffer is command
- case REPORT_FIRMWARE:
- printFirmwareVersion();
- break;
- case STRING_DATA:
- if(currentStringCallback) {
- byte bufferLength = (sysexBytesRead - 1) / 2;
- char *buffer = (char*)malloc(bufferLength * sizeof(char));
- byte i = 1;
- byte j = 0;
- while(j < bufferLength) {
- buffer[j] = (char)storedInputData[i];
- i++;
- buffer[j] += (char)(storedInputData[i] << 7);
- i++;
- j++;
- }
- (*currentStringCallback)(buffer);
- }
- break;
- default:
- if(currentSysexCallback)
- (*currentSysexCallback)(storedInputData[0], sysexBytesRead - 1, storedInputData + 1);
- }
-}
-
-void FirmataClass::processInput(void)
-{
- int inputData = FirmataSerial->read(); // this is 'int' to handle -1 when no data
- int command;
-
- // TODO make sure it handles -1 properly
-
- if (parsingSysex) {
- if(inputData == END_SYSEX) {
- //stop sysex byte
- parsingSysex = false;
- //fire off handler function
- processSysexMessage();
- } else {
- //normal data byte - add to buffer
- storedInputData[sysexBytesRead] = inputData;
- sysexBytesRead++;
- }
- } else if( (waitForData > 0) && (inputData < 128) ) {
- waitForData--;
- storedInputData[waitForData] = inputData;
- if( (waitForData==0) && executeMultiByteCommand ) { // got the whole message
- switch(executeMultiByteCommand) {
- case ANALOG_MESSAGE:
- if(currentAnalogCallback) {
- (*currentAnalogCallback)(multiByteChannel,
- (storedInputData[0] << 7)
- + storedInputData[1]);
- }
- break;
- case DIGITAL_MESSAGE:
- if(currentDigitalCallback) {
- (*currentDigitalCallback)(multiByteChannel,
- (storedInputData[0] << 7)
- + storedInputData[1]);
- }
- break;
- case SET_PIN_MODE:
- if(currentPinModeCallback)
- (*currentPinModeCallback)(storedInputData[1], storedInputData[0]);
- break;
- case REPORT_ANALOG:
- if(currentReportAnalogCallback)
- (*currentReportAnalogCallback)(multiByteChannel,storedInputData[0]);
- break;
- case REPORT_DIGITAL:
- if(currentReportDigitalCallback)
- (*currentReportDigitalCallback)(multiByteChannel,storedInputData[0]);
- break;
- }
- executeMultiByteCommand = 0;
- }
- } else {
- // remove channel info from command byte if less than 0xF0
- if(inputData < 0xF0) {
- command = inputData & 0xF0;
- multiByteChannel = inputData & 0x0F;
- } else {
- command = inputData;
- // commands in the 0xF* range don't use channel data
- }
- switch (command) {
- case ANALOG_MESSAGE:
- case DIGITAL_MESSAGE:
- case SET_PIN_MODE:
- waitForData = 2; // two data bytes needed
- executeMultiByteCommand = command;
- break;
- case REPORT_ANALOG:
- case REPORT_DIGITAL:
- waitForData = 1; // two data bytes needed
- executeMultiByteCommand = command;
- break;
- case START_SYSEX:
- parsingSysex = true;
- sysexBytesRead = 0;
- break;
- case SYSTEM_RESET:
- systemReset();
- break;
- case REPORT_VERSION:
- Firmata.printVersion();
- break;
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// Serial Send Handling
-
-// send an analog message
-void FirmataClass::sendAnalog(byte pin, int value)
-{
- // pin can only be 0-15, so chop higher bits
- FirmataSerial->write(ANALOG_MESSAGE | (pin & 0xF));
- sendValueAsTwo7bitBytes(value);
-}
-
-// send a single digital pin in a digital message
-void FirmataClass::sendDigital(byte pin, int value)
-{
- /* TODO add single pin digital messages to the protocol, this needs to
- * track the last digital data sent so that it can be sure to change just
- * one bit in the packet. This is complicated by the fact that the
- * numbering of the pins will probably differ on Arduino, Wiring, and
- * other boards. The DIGITAL_MESSAGE sends 14 bits at a time, but it is
- * probably easier to send 8 bit ports for any board with more than 14
- * digital pins.
- */
-
- // TODO: the digital message should not be sent on the serial port every
- // time sendDigital() is called. Instead, it should add it to an int
- // which will be sent on a schedule. If a pin changes more than once
- // before the digital message is sent on the serial port, it should send a
- // digital message for each change.
-
- // if(value == 0)
- // sendDigitalPortPair();
-}
-
-
-// send 14-bits in a single digital message (protocol v1)
-// send an 8-bit port in a single digital message (protocol v2)
-void FirmataClass::sendDigitalPort(byte portNumber, int portData)
-{
- FirmataSerial->write(DIGITAL_MESSAGE | (portNumber & 0xF));
- FirmataSerial->write((byte)portData % 128); // Tx bits 0-6
- FirmataSerial->write(portData >> 7); // Tx bits 7-13
-}
-
-
-void FirmataClass::sendSysex(byte command, byte bytec, byte* bytev)
-{
- byte i;
- startSysex();
- FirmataSerial->write(command);
- for(i=0; iwrite(c);
-}
-
-
-// Internal Actions/////////////////////////////////////////////////////////////
-
-// generic callbacks
-void FirmataClass::attach(byte command, callbackFunction newFunction)
-{
- switch(command) {
- case ANALOG_MESSAGE: currentAnalogCallback = newFunction; break;
- case DIGITAL_MESSAGE: currentDigitalCallback = newFunction; break;
- case REPORT_ANALOG: currentReportAnalogCallback = newFunction; break;
- case REPORT_DIGITAL: currentReportDigitalCallback = newFunction; break;
- case SET_PIN_MODE: currentPinModeCallback = newFunction; break;
- }
-}
-
-void FirmataClass::attach(byte command, systemResetCallbackFunction newFunction)
-{
- switch(command) {
- case SYSTEM_RESET: currentSystemResetCallback = newFunction; break;
- }
-}
-
-void FirmataClass::attach(byte command, stringCallbackFunction newFunction)
-{
- switch(command) {
- case STRING_DATA: currentStringCallback = newFunction; break;
- }
-}
-
-void FirmataClass::attach(byte command, sysexCallbackFunction newFunction)
-{
- currentSysexCallback = newFunction;
-}
-
-void FirmataClass::detach(byte command)
-{
- switch(command) {
- case SYSTEM_RESET: currentSystemResetCallback = NULL; break;
- case STRING_DATA: currentStringCallback = NULL; break;
- case START_SYSEX: currentSysexCallback = NULL; break;
- default:
- attach(command, (callbackFunction)NULL);
- }
-}
-
-// sysex callbacks
-/*
- * this is too complicated for analogReceive, but maybe for Sysex?
- void FirmataClass::attachSysex(sysexFunction newFunction)
- {
- byte i;
- byte tmpCount = analogReceiveFunctionCount;
- analogReceiveFunction* tmpArray = analogReceiveFunctionArray;
- analogReceiveFunctionCount++;
- analogReceiveFunctionArray = (analogReceiveFunction*) calloc(analogReceiveFunctionCount, sizeof(analogReceiveFunction));
- for(i = 0; i < tmpCount; i++) {
- analogReceiveFunctionArray[i] = tmpArray[i];
- }
- analogReceiveFunctionArray[tmpCount] = newFunction;
- free(tmpArray);
- }
-*/
-
-//******************************************************************************
-//* Private Methods
-//******************************************************************************
-
-
-
-// resets the system state upon a SYSTEM_RESET message from the host software
-void FirmataClass::systemReset(void)
-{
- byte i;
-
- waitForData = 0; // this flag says the next serial input will be data
- executeMultiByteCommand = 0; // execute this after getting multi-byte data
- multiByteChannel = 0; // channel data for multiByteCommands
-
- for(i=0; i
sentence=Enables GSM/GRPS network connection using the Arduino GSM Shield. For all Arduino boards BUT Arduino DUE.
paragraph=Use this library to make/receive voice calls, to send and receive SMS with the Quectel M10 GSM module.This library also allows you to connect to internet through the GPRS networks. You can either use web Clients and Servers.
category=Communication
-url=http://arduino.cc/en/Reference/GSM
+url=http://www.arduino.cc/en/Reference/GSM
architectures=avr
diff --git a/libraries/LiquidCrystal/README.adoc b/libraries/LiquidCrystal/README.adoc
index 6f57eb157..d51cee757 100644
--- a/libraries/LiquidCrystal/README.adoc
+++ b/libraries/LiquidCrystal/README.adoc
@@ -3,7 +3,7 @@
This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/LiquidCrystal
+http://www.arduino.cc/en/Reference/LiquidCrystal
== License ==
diff --git a/libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino b/libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino
index 0acb3affc..f70a1a739 100644
--- a/libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino
+++ b/libraries/LiquidCrystal/examples/Autoscroll/Autoscroll.ino
@@ -32,7 +32,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll
+ http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll
*/
diff --git a/libraries/LiquidCrystal/examples/Blink/Blink.ino b/libraries/LiquidCrystal/examples/Blink/Blink.ino
index 856d522c5..fea13a34b 100644
--- a/libraries/LiquidCrystal/examples/Blink/Blink.ino
+++ b/libraries/LiquidCrystal/examples/Blink/Blink.ino
@@ -32,7 +32,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/LiquidCrystalBlink
+ http://www.arduino.cc/en/Tutorial/LiquidCrystalBlink
*/
diff --git a/libraries/LiquidCrystal/examples/Cursor/Cursor.ino b/libraries/LiquidCrystal/examples/Cursor/Cursor.ino
index 5f68d917d..8699d27fe 100644
--- a/libraries/LiquidCrystal/examples/Cursor/Cursor.ino
+++ b/libraries/LiquidCrystal/examples/Cursor/Cursor.ino
@@ -33,7 +33,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/LiquidCrystalCursor
+ http://www.arduino.cc/en/Tutorial/LiquidCrystalCursor
*/
diff --git a/libraries/LiquidCrystal/examples/Display/Display.ino b/libraries/LiquidCrystal/examples/Display/Display.ino
index 5c9e67cb3..90b14f002 100644
--- a/libraries/LiquidCrystal/examples/Display/Display.ino
+++ b/libraries/LiquidCrystal/examples/Display/Display.ino
@@ -33,7 +33,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/LiquidCrystalDisplay
+ http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay
*/
diff --git a/libraries/LiquidCrystal/examples/Scroll/Scroll.ino b/libraries/LiquidCrystal/examples/Scroll/Scroll.ino
index 3e4479177..0a4a95f90 100644
--- a/libraries/LiquidCrystal/examples/Scroll/Scroll.ino
+++ b/libraries/LiquidCrystal/examples/Scroll/Scroll.ino
@@ -33,7 +33,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/LiquidCrystalScroll
+ http://www.arduino.cc/en/Tutorial/LiquidCrystalScroll
*/
diff --git a/libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino b/libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino
index 5838dc5a0..ec46ff0fd 100644
--- a/libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino
+++ b/libraries/LiquidCrystal/examples/SerialDisplay/SerialDisplay.ino
@@ -32,7 +32,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/LiquidCrystalSerial
+ http://www.arduino.cc/en/Tutorial/LiquidCrystalSerial
*/
// include the library code:
diff --git a/libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino b/libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino
index 3bb8695b3..c838d81b8 100644
--- a/libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino
+++ b/libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino
@@ -32,7 +32,7 @@ by Tom Igoe
This example code is in the public domain.
-http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection
+http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection
*/
diff --git a/libraries/LiquidCrystal/examples/setCursor/setCursor.ino b/libraries/LiquidCrystal/examples/setCursor/setCursor.ino
index df75f7fe9..d2dae9327 100644
--- a/libraries/LiquidCrystal/examples/setCursor/setCursor.ino
+++ b/libraries/LiquidCrystal/examples/setCursor/setCursor.ino
@@ -32,7 +32,7 @@
This example code is in the public domain.
- http://arduino.cc/en/Tutorial/LiquidCrystalSetCursor
+ http://www.arduino.cc/en/Tutorial/LiquidCrystalSetCursor
*/
diff --git a/libraries/LiquidCrystal/library.properties b/libraries/LiquidCrystal/library.properties
index f379f78cc..7aa5b529c 100644
--- a/libraries/LiquidCrystal/library.properties
+++ b/libraries/LiquidCrystal/library.properties
@@ -1,9 +1,9 @@
name=LiquidCrystal
-version=1.0.1
+version=1.0.2
author=Arduino, Adafruit
maintainer=Arduino
sentence=Allows communication with alphanumerical liquid crystal displays (LCDs). For all Arduino boards.
paragraph=This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4 or 8 bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines).
category=Display
-url=http://arduino.cc/en/Reference/LiquidCrystal
+url=http://www.arduino.cc/en/Reference/LiquidCrystal
architectures=*
diff --git a/libraries/RobotIRremote/README.adoc b/libraries/RobotIRremote/README.adoc
index 54ce67c6d..fd27000f8 100644
--- a/libraries/RobotIRremote/README.adoc
+++ b/libraries/RobotIRremote/README.adoc
@@ -3,7 +3,7 @@
The Robot has a number of built in sensors and actuators. The library is designed to easily access the robot's functionality.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/RobotLibrary
+http://www.arduino.cc/en/Reference/RobotLibrary
== License ==
diff --git a/libraries/RobotIRremote/library.properties b/libraries/RobotIRremote/library.properties
index 4db0bfa2b..9f3c426f6 100644
--- a/libraries/RobotIRremote/library.properties
+++ b/libraries/RobotIRremote/library.properties
@@ -1,5 +1,5 @@
name=Robot IR Remote
-version=1.0.1
+version=1.0.2
author=Arduino
maintainer=Arduino
sentence=Allows controlling the Arduino Robot via an IR remote control. For Arduino Robot only.
diff --git a/libraries/Robot_Control/README.adoc b/libraries/Robot_Control/README.adoc
index e0c1c472a..b48580143 100644
--- a/libraries/Robot_Control/README.adoc
+++ b/libraries/Robot_Control/README.adoc
@@ -3,7 +3,7 @@
The Robot has a number of built in sensors and actuators. The library is designed to easily access the robot's functionality.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/RobotLibrary
+http://www.arduino.cc/en/Reference/RobotLibrary
== License ==
diff --git a/libraries/Robot_Control/library.properties b/libraries/Robot_Control/library.properties
index 994b0b0b1..8988767dd 100644
--- a/libraries/Robot_Control/library.properties
+++ b/libraries/Robot_Control/library.properties
@@ -1,9 +1,9 @@
name=Robot Control
-version=1.0.1
+version=1.0.2
author=Arduino
maintainer=Arduino
sentence=Enables easy access to the controls of the Arduino Robot Control board. For Arduino Robot only.
paragraph=The Arduino robot is made by two independent boards. The Control Board is the top board of the Arduino Robot, with this library you can easily write sketches to control the robot.
category=Device Control
-url=http://arduino.cc/en/Reference/RobotLibrary
+url=http://www.arduino.cc/en/Reference/RobotLibrary
architectures=avr
diff --git a/libraries/Robot_Motor/README.adoc b/libraries/Robot_Motor/README.adoc
index 07bad3d83..480fa5223 100644
--- a/libraries/Robot_Motor/README.adoc
+++ b/libraries/Robot_Motor/README.adoc
@@ -3,7 +3,7 @@
The Robot has a number of built in sensors and actuators. The library is designed to easily access the robot's functionality.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/RobotLibrary
+http://www.arduino.cc/en/Reference/RobotLibrary
== License ==
diff --git a/libraries/Robot_Motor/library.properties b/libraries/Robot_Motor/library.properties
index 165412af2..7e697df5e 100644
--- a/libraries/Robot_Motor/library.properties
+++ b/libraries/Robot_Motor/library.properties
@@ -1,9 +1,9 @@
name=Robot Motor
-version=1.0.1
+version=1.0.2
author=Arduino
maintainer=Arduino
sentence=Enables easy access to the motors of the Arduino Robot Motor board. For Arduino Robot only.
paragraph=
category=Device Control
-url=http://arduino.cc/en/Reference/RobotLibrary
+url=http://www.arduino.cc/en/Reference/RobotLibrary
architectures=avr
diff --git a/libraries/SD/README.adoc b/libraries/SD/README.adoc
index 4c6521ed3..fabff563c 100644
--- a/libraries/SD/README.adoc
+++ b/libraries/SD/README.adoc
@@ -3,7 +3,7 @@
The SD library allows for reading from and writing to SD cards.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/SD
+http://www.arduino.cc/en/Reference/SD
== License ==
diff --git a/libraries/SD/library.properties b/libraries/SD/library.properties
index 4658054f8..bc8c4e498 100644
--- a/libraries/SD/library.properties
+++ b/libraries/SD/library.properties
@@ -1,9 +1,9 @@
name=SD
-version=1.0.4
+version=1.0.5
author=Arduino, SparkFun
maintainer=Arduino
sentence=Enables reading and writing on SD cards. For all Arduino boards.
paragraph=Once an SD memory card is connected to the SPI interfare of the Arduino board you are enabled to create files and read/write on them. You can also move through directories on the SD card.
category=Data Storage
-url=http://arduino.cc/en/Reference/SD
+url=http://www.arduino.cc/en/Reference/SD
architectures=*
diff --git a/libraries/SD/src/SD.h b/libraries/SD/src/SD.h
index 62276b4ee..653adabee 100644
--- a/libraries/SD/src/SD.h
+++ b/libraries/SD/src/SD.h
@@ -93,18 +93,23 @@ public:
// write, etc). Returns a File object for interacting with the file.
// Note that currently only one file can be open at a time.
File open(const char *filename, uint8_t mode = FILE_READ);
+ File open(const String &filename, uint8_t mode = FILE_READ) { return open( filename.c_str(), mode ); }
// Methods to determine if the requested file path exists.
boolean exists(char *filepath);
+ boolean exists(const String &filepath) { return exists(filepath.c_str()); }
// Create the requested directory heirarchy--if intermediate directories
// do not exist they will be created.
boolean mkdir(char *filepath);
+ boolean mkdir(const String &filepath) { return mkdir(filepath.c_str()); }
// Delete the file.
boolean remove(char *filepath);
+ boolean remove(const String &filepath) { return remove(filepath.c_str()); }
boolean rmdir(char *filepath);
+ boolean rmdir(const String &filepath) { return rmdir(filepath.c_str()); }
uint8_t type(){ return card.type(); }
uint8_t fatType(){ return volume.fatType(); }
diff --git a/libraries/Scheduler/README.adoc b/libraries/Scheduler/README.adoc
index 628bb1543..aef62e821 100644
--- a/libraries/Scheduler/README.adoc
+++ b/libraries/Scheduler/README.adoc
@@ -3,7 +3,7 @@
The Scheduler library enables the Arduino Due to run multiple functions at the same time. This allows tasks to happen without interrupting each other.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/Scheduler
+http://www.arduino.cc/en/Reference/Scheduler
== License ==
diff --git a/libraries/Scheduler/examples/MultipleBlinks/MultipleBlinks.ino b/libraries/Scheduler/examples/MultipleBlinks/MultipleBlinks.ino
index f3a229cab..bc1be4c47 100644
--- a/libraries/Scheduler/examples/MultipleBlinks/MultipleBlinks.ino
+++ b/libraries/Scheduler/examples/MultipleBlinks/MultipleBlinks.ino
@@ -13,7 +13,7 @@
This example code is in the public domain
- http://arduino.cc/en/Tutorial/MultipleBlinks
+ http://www.arduino.cc/en/Tutorial/MultipleBlinks
*/
// Include Scheduler since we want to manage multiple tasks.
diff --git a/libraries/Scheduler/library.properties b/libraries/Scheduler/library.properties
index 241208ce7..c7d34533b 100644
--- a/libraries/Scheduler/library.properties
+++ b/libraries/Scheduler/library.properties
@@ -1,9 +1,9 @@
name=Scheduler
-version=0.4.2
+version=0.4.3
author=Arduino
maintainer=Arduino
sentence=Allows multiple tasks to run at the same time, without interrupting each other. For Arduino DUE only.
paragraph=The Scheduler library enables the Arduino Due to run multiple functions at the same time. This allows tasks to happen without interrupting each other.This is a cooperative scheduler in that the CPU switches from one task to another. The library includes methods for passing control between tasks.
category=Other
-url=http://arduino.cc/en/Reference/Scheduler
+url=http://www.arduino.cc/en/Reference/Scheduler
architectures=sam
diff --git a/libraries/Servo/README.adoc b/libraries/Servo/README.adoc
index a871b08c5..dd3f0bae3 100644
--- a/libraries/Servo/README.adoc
+++ b/libraries/Servo/README.adoc
@@ -3,7 +3,7 @@
This library allows an Arduino board to control RC (hobby) servo motors.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/Servo
+http://www.arduino.cc/en/Reference/Servo
== License ==
diff --git a/libraries/Servo/examples/Knob/Knob.ino b/libraries/Servo/examples/Knob/Knob.ino
index 06c252c06..5e31f744f 100644
--- a/libraries/Servo/examples/Knob/Knob.ino
+++ b/libraries/Servo/examples/Knob/Knob.ino
@@ -4,7 +4,7 @@
modified on 8 Nov 2013
by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/Knob
+ http://www.arduino.cc/en/Tutorial/Knob
*/
#include
diff --git a/libraries/Servo/examples/Sweep/Sweep.ino b/libraries/Servo/examples/Sweep/Sweep.ino
index bbe6ea9d1..79ef30fc0 100644
--- a/libraries/Servo/examples/Sweep/Sweep.ino
+++ b/libraries/Servo/examples/Sweep/Sweep.ino
@@ -4,7 +4,7 @@
modified 8 Nov 2013
by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/Sweep
+ http://www.arduino.cc/en/Tutorial/Sweep
*/
#include
diff --git a/libraries/Servo/library.properties b/libraries/Servo/library.properties
index 1712ac80f..71231d323 100644
--- a/libraries/Servo/library.properties
+++ b/libraries/Servo/library.properties
@@ -1,9 +1,9 @@
name=Servo
-version=1.0.2
+version=1.0.3
author=Michael Margolis, Arduino
maintainer=Arduino
sentence=Allows Arduino boards to control a variety of servo motors. For all Arduino boards.
paragraph=This library can control a great number of servos.
It makes careful use of timers: the library can control 12 servos using only 1 timer.
On the Arduino Due you can control up to 60 servos.
category=Device Control
-url=http://arduino.cc/en/Reference/Servo
+url=http://www.arduino.cc/en/Reference/Servo
architectures=avr,sam
diff --git a/libraries/Stepper/README.adoc b/libraries/Stepper/README.adoc
index 066623761..9d4d05216 100644
--- a/libraries/Stepper/README.adoc
+++ b/libraries/Stepper/README.adoc
@@ -3,7 +3,7 @@
This library allows you to control unipolar or bipolar stepper motors. To use it you will need a stepper motor, and the appropriate hardware to control it.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/Stepper
+http://www.arduino.cc/en/Reference/Stepper
== License ==
diff --git a/libraries/Stepper/library.properties b/libraries/Stepper/library.properties
index f17170344..b6ec1fea9 100644
--- a/libraries/Stepper/library.properties
+++ b/libraries/Stepper/library.properties
@@ -1,9 +1,9 @@
name=Stepper
-version=1.0.2
+version=1.1.1
author=Arduino
maintainer=Arduino
sentence=Allows Arduino boards to control a variety of stepper motors. For all Arduino boards.
paragraph=This library allows you to control unipolar or bipolar stepper motors. To use it you will need a stepper motor, and the appropriate hardware to control it.
category=Device Control
-url=http://arduino.cc/en/Reference/Stepper
+url=http://www.arduino.cc/en/Reference/Stepper
architectures=*
diff --git a/libraries/Stepper/src/Stepper.cpp b/libraries/Stepper/src/Stepper.cpp
index b1cbee6d1..03d635fad 100644
--- a/libraries/Stepper/src/Stepper.cpp
+++ b/libraries/Stepper/src/Stepper.cpp
@@ -1,63 +1,80 @@
/*
- Stepper.cpp - - Stepper library for Wiring/Arduino - Version 0.4
-
- Original library (0.1) by Tom Igoe.
- Two-wire modifications (0.2) by Sebastian Gassner
- Combination version (0.3) by Tom Igoe and David Mellis
- Bug fix for four-wire (0.4) by Tom Igoe, bug fix from Noah Shibley
-
- Drives a unipolar or bipolar stepper motor using 2 wires or 4 wires
-
- When wiring multiple stepper motors to a microcontroller,
- you quickly run out of output pins, with each motor requiring 4 connections.
-
- By making use of the fact that at any time two of the four motor
- coils are the inverse of the other two, the number of
- control connections can be reduced from 4 to 2.
-
- A slightly modified circuit around a Darlington transistor array or an L293 H-bridge
- connects to only 2 microcontroler pins, inverts the signals received,
- and delivers the 4 (2 plus 2 inverted ones) output signals required
- for driving a stepper motor.
-
- The sequence of control signals for 4 control wires is as follows:
-
- Step C0 C1 C2 C3
- 1 1 0 1 0
- 2 0 1 1 0
- 3 0 1 0 1
- 4 1 0 0 1
-
- The sequence of controls signals for 2 control wires is as follows
- (columns C1 and C2 from above):
-
- Step C0 C1
- 1 0 1
- 2 1 1
- 3 1 0
- 4 0 0
-
- The circuits can be found at
-
-http://www.arduino.cc/en/Tutorial/Stepper
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
+ * Stepper.cpp - Stepper library for Wiring/Arduino - Version 1.1.0
+ *
+ * Original library (0.1) by Tom Igoe.
+ * Two-wire modifications (0.2) by Sebastian Gassner
+ * Combination version (0.3) by Tom Igoe and David Mellis
+ * Bug fix for four-wire (0.4) by Tom Igoe, bug fix from Noah Shibley
+ * High-speed stepping mod by Eugene Kozlenko
+ * Timer rollover fix by Eugene Kozlenko
+ * Five phase five wire (1.1.0) by Ryan Orendorff
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Drives a unipolar, bipolar, or five phase stepper motor.
+ *
+ * When wiring multiple stepper motors to a microcontroller, you quickly run
+ * out of output pins, with each motor requiring 4 connections.
+ *
+ * By making use of the fact that at any time two of the four motor coils are
+ * the inverse of the other two, the number of control connections can be
+ * reduced from 4 to 2 for the unipolar and bipolar motors.
+ *
+ * A slightly modified circuit around a Darlington transistor array or an
+ * L293 H-bridge connects to only 2 microcontroler pins, inverts the signals
+ * received, and delivers the 4 (2 plus 2 inverted ones) output signals
+ * required for driving a stepper motor. Similarly the Arduino motor shields
+ * 2 direction pins may be used.
+ *
+ * The sequence of control signals for 5 phase, 5 control wires is as follows:
+ *
+ * Step C0 C1 C2 C3 C4
+ * 1 0 1 1 0 1
+ * 2 0 1 0 0 1
+ * 3 0 1 0 1 1
+ * 4 0 1 0 1 0
+ * 5 1 1 0 1 0
+ * 6 1 0 0 1 0
+ * 7 1 0 1 1 0
+ * 8 1 0 1 0 0
+ * 9 1 0 1 0 1
+ * 10 0 0 1 0 1
+ *
+ * The sequence of control signals for 4 control wires is as follows:
+ *
+ * Step C0 C1 C2 C3
+ * 1 1 0 1 0
+ * 2 0 1 1 0
+ * 3 0 1 0 1
+ * 4 1 0 0 1
+ *
+ * The sequence of controls signals for 2 control wires is as follows
+ * (columns C1 and C2 from above):
+ *
+ * Step C0 C1
+ * 1 0 1
+ * 2 1 1
+ * 3 1 0
+ * 4 0 0
+ *
+ * The circuits can be found at
+ *
+ * http://www.arduino.cc/en/Tutorial/Stepper
*/
-
#include "Arduino.h"
#include "Stepper.h"
@@ -67,12 +84,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2)
{
- this->step_number = 0; // which step the motor is on
- this->speed = 0; // the motor speed, in revolutions per minute
+ this->step_number = 0; // which step the motor is on
+ this->speed = 0; // the motor speed, in revolutions per minute
this->direction = 0; // motor direction
- this->last_step_time = 0; // time stamp in ms of the last step taken
- this->number_of_steps = number_of_steps; // total number of steps for this motor
-
+ this->last_step_time = 0; // time stamp in us of the last step taken
+ this->number_of_steps = number_of_steps; // total number of steps for this motor
+
// Arduino pins for the motor control connection:
this->motor_pin_1 = motor_pin_1;
this->motor_pin_2 = motor_pin_2;
@@ -80,11 +97,12 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2)
// setup the pins on the microcontroller:
pinMode(this->motor_pin_1, OUTPUT);
pinMode(this->motor_pin_2, OUTPUT);
-
- // When there are only 2 pins, set the other two to 0:
+
+ // When there are only 2 pins, set the others to 0:
this->motor_pin_3 = 0;
this->motor_pin_4 = 0;
-
+ this->motor_pin_5 = 0;
+
// pin_count is used by the stepMotor() method:
this->pin_count = 2;
}
@@ -94,15 +112,15 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2)
* constructor for four-pin version
* Sets which wires should control the motor.
*/
-
-Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2, int motor_pin_3, int motor_pin_4)
+Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
+ int motor_pin_3, int motor_pin_4)
{
- this->step_number = 0; // which step the motor is on
- this->speed = 0; // the motor speed, in revolutions per minute
+ this->step_number = 0; // which step the motor is on
+ this->speed = 0; // the motor speed, in revolutions per minute
this->direction = 0; // motor direction
- this->last_step_time = 0; // time stamp in ms of the last step taken
- this->number_of_steps = number_of_steps; // total number of steps for this motor
-
+ this->last_step_time = 0; // time stamp in us of the last step taken
+ this->number_of_steps = number_of_steps; // total number of steps for this motor
+
// Arduino pins for the motor control connection:
this->motor_pin_1 = motor_pin_1;
this->motor_pin_2 = motor_pin_2;
@@ -115,47 +133,86 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2, int moto
pinMode(this->motor_pin_3, OUTPUT);
pinMode(this->motor_pin_4, OUTPUT);
- // pin_count is used by the stepMotor() method:
- this->pin_count = 4;
+ // When there are 4 pins, set the others to 0:
+ this->motor_pin_5 = 0;
+
+ // pin_count is used by the stepMotor() method:
+ this->pin_count = 4;
}
/*
- Sets the speed in revs per minute
+ * constructor for five phase motor with five wires
+ * Sets which wires should control the motor.
+ */
+Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
+ int motor_pin_3, int motor_pin_4,
+ int motor_pin_5)
+{
+ this->step_number = 0; // which step the motor is on
+ this->speed = 0; // the motor speed, in revolutions per minute
+ this->direction = 0; // motor direction
+ this->last_step_time = 0; // time stamp in us of the last step taken
+ this->number_of_steps = number_of_steps; // total number of steps for this motor
-*/
+ // Arduino pins for the motor control connection:
+ this->motor_pin_1 = motor_pin_1;
+ this->motor_pin_2 = motor_pin_2;
+ this->motor_pin_3 = motor_pin_3;
+ this->motor_pin_4 = motor_pin_4;
+ this->motor_pin_5 = motor_pin_5;
+
+ // setup the pins on the microcontroller:
+ pinMode(this->motor_pin_1, OUTPUT);
+ pinMode(this->motor_pin_2, OUTPUT);
+ pinMode(this->motor_pin_3, OUTPUT);
+ pinMode(this->motor_pin_4, OUTPUT);
+ pinMode(this->motor_pin_5, OUTPUT);
+
+ // pin_count is used by the stepMotor() method:
+ this->pin_count = 5;
+}
+
+/*
+ * Sets the speed in revs per minute
+ */
void Stepper::setSpeed(long whatSpeed)
{
- this->step_delay = 60L * 1000L / this->number_of_steps / whatSpeed;
+ this->step_delay = 60L * 1000L * 1000L / this->number_of_steps / whatSpeed;
}
/*
- Moves the motor steps_to_move steps. If the number is negative,
- the motor moves in the reverse direction.
+ * Moves the motor steps_to_move steps. If the number is negative,
+ * the motor moves in the reverse direction.
*/
void Stepper::step(int steps_to_move)
-{
+{
int steps_left = abs(steps_to_move); // how many steps to take
-
+
// determine direction based on whether steps_to_mode is + or -:
- if (steps_to_move > 0) {this->direction = 1;}
- if (steps_to_move < 0) {this->direction = 0;}
-
-
+ if (steps_to_move > 0) { this->direction = 1; }
+ if (steps_to_move < 0) { this->direction = 0; }
+
+
// decrement the number of steps, moving one step each time:
- while(steps_left > 0) {
- // move only if the appropriate delay has passed:
- if (millis() - this->last_step_time >= this->step_delay) {
+ while (steps_left > 0)
+ {
+ unsigned long now = micros();
+ // move only if the appropriate delay has passed:
+ if (now - this->last_step_time >= this->step_delay)
+ {
// get the timeStamp of when you stepped:
- this->last_step_time = millis();
+ this->last_step_time = now;
// increment or decrement the step number,
// depending on direction:
- if (this->direction == 1) {
+ if (this->direction == 1)
+ {
this->step_number++;
if (this->step_number == this->number_of_steps) {
this->step_number = 0;
}
- }
- else {
+ }
+ else
+ {
if (this->step_number == 0) {
this->step_number = this->number_of_steps;
}
@@ -163,8 +220,11 @@ void Stepper::step(int steps_to_move)
}
// decrement the steps left:
steps_left--;
- // step the motor to step number 0, 1, 2, or 3:
- stepMotor(this->step_number % 4);
+ // step the motor to step number 0, 1, ..., {3 or 10}
+ if (this->pin_count == 5)
+ stepMotor(this->step_number % 10);
+ else
+ stepMotor(this->step_number % 4);
}
}
}
@@ -176,51 +236,126 @@ void Stepper::stepMotor(int thisStep)
{
if (this->pin_count == 2) {
switch (thisStep) {
- case 0: /* 01 */
- digitalWrite(motor_pin_1, LOW);
- digitalWrite(motor_pin_2, HIGH);
+ case 0: // 01
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, HIGH);
break;
- case 1: /* 11 */
- digitalWrite(motor_pin_1, HIGH);
- digitalWrite(motor_pin_2, HIGH);
+ case 1: // 11
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, HIGH);
break;
- case 2: /* 10 */
- digitalWrite(motor_pin_1, HIGH);
- digitalWrite(motor_pin_2, LOW);
+ case 2: // 10
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, LOW);
break;
- case 3: /* 00 */
- digitalWrite(motor_pin_1, LOW);
- digitalWrite(motor_pin_2, LOW);
+ case 3: // 00
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, LOW);
break;
- }
+ }
}
if (this->pin_count == 4) {
switch (thisStep) {
- case 0: // 1010
- digitalWrite(motor_pin_1, HIGH);
- digitalWrite(motor_pin_2, LOW);
- digitalWrite(motor_pin_3, HIGH);
- digitalWrite(motor_pin_4, LOW);
+ case 0: // 1010
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, LOW);
+ digitalWrite(motor_pin_3, HIGH);
+ digitalWrite(motor_pin_4, LOW);
break;
- case 1: // 0110
- digitalWrite(motor_pin_1, LOW);
- digitalWrite(motor_pin_2, HIGH);
- digitalWrite(motor_pin_3, HIGH);
- digitalWrite(motor_pin_4, LOW);
+ case 1: // 0110
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, HIGH);
+ digitalWrite(motor_pin_3, HIGH);
+ digitalWrite(motor_pin_4, LOW);
break;
- case 2: //0101
- digitalWrite(motor_pin_1, LOW);
- digitalWrite(motor_pin_2, HIGH);
- digitalWrite(motor_pin_3, LOW);
- digitalWrite(motor_pin_4, HIGH);
+ case 2: //0101
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, HIGH);
+ digitalWrite(motor_pin_3, LOW);
+ digitalWrite(motor_pin_4, HIGH);
break;
- case 3: //1001
- digitalWrite(motor_pin_1, HIGH);
- digitalWrite(motor_pin_2, LOW);
- digitalWrite(motor_pin_3, LOW);
- digitalWrite(motor_pin_4, HIGH);
+ case 3: //1001
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, LOW);
+ digitalWrite(motor_pin_3, LOW);
+ digitalWrite(motor_pin_4, HIGH);
break;
- }
+ }
+ }
+
+ if (this->pin_count == 5) {
+ switch (thisStep) {
+ case 0: // 01101
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, HIGH);
+ digitalWrite(motor_pin_3, HIGH);
+ digitalWrite(motor_pin_4, LOW);
+ digitalWrite(motor_pin_5, HIGH);
+ break;
+ case 1: // 01001
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, HIGH);
+ digitalWrite(motor_pin_3, LOW);
+ digitalWrite(motor_pin_4, LOW);
+ digitalWrite(motor_pin_5, HIGH);
+ break;
+ case 2: // 01011
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, HIGH);
+ digitalWrite(motor_pin_3, LOW);
+ digitalWrite(motor_pin_4, HIGH);
+ digitalWrite(motor_pin_5, HIGH);
+ break;
+ case 3: // 01010
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, HIGH);
+ digitalWrite(motor_pin_3, LOW);
+ digitalWrite(motor_pin_4, HIGH);
+ digitalWrite(motor_pin_5, LOW);
+ break;
+ case 4: // 11010
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, HIGH);
+ digitalWrite(motor_pin_3, LOW);
+ digitalWrite(motor_pin_4, HIGH);
+ digitalWrite(motor_pin_5, LOW);
+ break;
+ case 5: // 10010
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, LOW);
+ digitalWrite(motor_pin_3, LOW);
+ digitalWrite(motor_pin_4, HIGH);
+ digitalWrite(motor_pin_5, LOW);
+ break;
+ case 6: // 10110
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, LOW);
+ digitalWrite(motor_pin_3, HIGH);
+ digitalWrite(motor_pin_4, HIGH);
+ digitalWrite(motor_pin_5, LOW);
+ break;
+ case 7: // 10100
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, LOW);
+ digitalWrite(motor_pin_3, HIGH);
+ digitalWrite(motor_pin_4, LOW);
+ digitalWrite(motor_pin_5, LOW);
+ break;
+ case 8: // 10101
+ digitalWrite(motor_pin_1, HIGH);
+ digitalWrite(motor_pin_2, LOW);
+ digitalWrite(motor_pin_3, HIGH);
+ digitalWrite(motor_pin_4, LOW);
+ digitalWrite(motor_pin_5, HIGH);
+ break;
+ case 9: // 00101
+ digitalWrite(motor_pin_1, LOW);
+ digitalWrite(motor_pin_2, LOW);
+ digitalWrite(motor_pin_3, HIGH);
+ digitalWrite(motor_pin_4, LOW);
+ digitalWrite(motor_pin_5, HIGH);
+ break;
+ }
}
}
@@ -229,5 +364,5 @@ void Stepper::stepMotor(int thisStep)
*/
int Stepper::version(void)
{
- return 4;
+ return 5;
}
diff --git a/libraries/Stepper/src/Stepper.h b/libraries/Stepper/src/Stepper.h
index e0441ffe7..6c875883a 100644
--- a/libraries/Stepper/src/Stepper.h
+++ b/libraries/Stepper/src/Stepper.h
@@ -1,59 +1,79 @@
/*
- Stepper.h - - Stepper library for Wiring/Arduino - Version 0.4
-
- Original library (0.1) by Tom Igoe.
- Two-wire modifications (0.2) by Sebastian Gassner
- Combination version (0.3) by Tom Igoe and David Mellis
- Bug fix for four-wire (0.4) by Tom Igoe, bug fix from Noah Shibley
-
- Drives a unipolar or bipolar stepper motor using 2 wires or 4 wires
-
- When wiring multiple stepper motors to a microcontroller,
- you quickly run out of output pins, with each motor requiring 4 connections.
-
- By making use of the fact that at any time two of the four motor
- coils are the inverse of the other two, the number of
- control connections can be reduced from 4 to 2.
-
- A slightly modified circuit around a Darlington transistor array or an L293 H-bridge
- connects to only 2 microcontroler pins, inverts the signals received,
- and delivers the 4 (2 plus 2 inverted ones) output signals required
- for driving a stepper motor.
-
- The sequence of control signals for 4 control wires is as follows:
-
- Step C0 C1 C2 C3
- 1 1 0 1 0
- 2 0 1 1 0
- 3 0 1 0 1
- 4 1 0 0 1
-
- The sequence of controls signals for 2 control wires is as follows
- (columns C1 and C2 from above):
-
- Step C0 C1
- 1 0 1
- 2 1 1
- 3 1 0
- 4 0 0
-
- The circuits can be found at
- http://www.arduino.cc/en/Tutorial/Stepper
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ * Stepper.h - Stepper library for Wiring/Arduino - Version 1.1.0
+ *
+ * Original library (0.1) by Tom Igoe.
+ * Two-wire modifications (0.2) by Sebastian Gassner
+ * Combination version (0.3) by Tom Igoe and David Mellis
+ * Bug fix for four-wire (0.4) by Tom Igoe, bug fix from Noah Shibley
+ * High-speed stepping mod by Eugene Kozlenko
+ * Timer rollover fix by Eugene Kozlenko
+ * Five phase five wire (1.1.0) by Ryan Orendorff
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Drives a unipolar, bipolar, or five phase stepper motor.
+ *
+ * When wiring multiple stepper motors to a microcontroller, you quickly run
+ * out of output pins, with each motor requiring 4 connections.
+ *
+ * By making use of the fact that at any time two of the four motor coils are
+ * the inverse of the other two, the number of control connections can be
+ * reduced from 4 to 2 for the unipolar and bipolar motors.
+ *
+ * A slightly modified circuit around a Darlington transistor array or an
+ * L293 H-bridge connects to only 2 microcontroler pins, inverts the signals
+ * received, and delivers the 4 (2 plus 2 inverted ones) output signals
+ * required for driving a stepper motor. Similarly the Arduino motor shields
+ * 2 direction pins may be used.
+ *
+ * The sequence of control signals for 5 phase, 5 control wires is as follows:
+ *
+ * Step C0 C1 C2 C3 C4
+ * 1 0 1 1 0 1
+ * 2 0 1 0 0 1
+ * 3 0 1 0 1 1
+ * 4 0 1 0 1 0
+ * 5 1 1 0 1 0
+ * 6 1 0 0 1 0
+ * 7 1 0 1 1 0
+ * 8 1 0 1 0 0
+ * 9 1 0 1 0 1
+ * 10 0 0 1 0 1
+ *
+ * The sequence of control signals for 4 control wires is as follows:
+ *
+ * Step C0 C1 C2 C3
+ * 1 1 0 1 0
+ * 2 0 1 1 0
+ * 3 0 1 0 1
+ * 4 1 0 0 1
+ *
+ * The sequence of controls signals for 2 control wires is as follows
+ * (columns C1 and C2 from above):
+ *
+ * Step C0 C1
+ * 1 0 1
+ * 2 1 1
+ * 3 1 0
+ * 4 0 0
+ *
+ * The circuits can be found at
+ *
+ * http://www.arduino.cc/en/Tutorial/Stepper
+ */
// ensure this library description is only included once
#ifndef Stepper_h
@@ -64,7 +84,11 @@ class Stepper {
public:
// constructors:
Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2);
- Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2, int motor_pin_3, int motor_pin_4);
+ Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
+ int motor_pin_3, int motor_pin_4);
+ Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
+ int motor_pin_3, int motor_pin_4,
+ int motor_pin_5);
// speed setter method:
void setSpeed(long whatSpeed);
@@ -76,21 +100,22 @@ class Stepper {
private:
void stepMotor(int this_step);
-
- int direction; // Direction of rotation
- int speed; // Speed in RPMs
- unsigned long step_delay; // delay between steps, in ms, based on speed
+
+ int direction; // Direction of rotation
+ int speed; // Speed in RPMs
+ unsigned long step_delay; // delay between steps, in ms, based on speed
int number_of_steps; // total number of steps this motor can take
- int pin_count; // whether you're driving the motor with 2 or 4 pins
- int step_number; // which step the motor is on
-
+ int pin_count; // how many pins are in use.
+ int step_number; // which step the motor is on
+
// motor pin numbers:
int motor_pin_1;
int motor_pin_2;
int motor_pin_3;
int motor_pin_4;
-
- long last_step_time; // time stamp in ms of when the last step was taken
+ int motor_pin_5; // Only 5 phase motor
+
+ unsigned long last_step_time; // time stamp in us of when the last step was taken
};
#endif
diff --git a/libraries/TFT/README.adoc b/libraries/TFT/README.adoc
index ab716292b..0550e2d34 100644
--- a/libraries/TFT/README.adoc
+++ b/libraries/TFT/README.adoc
@@ -3,7 +3,7 @@
This library enables an Arduino board to communicate with the Arduino TFT LCD screen. It simplifies the process for drawing shapes, lines, images, and text to the screen.
For more information about this library please visit us at
-http://arduino.cc/en/Reference/TFTLibrary
+http://www.arduino.cc/en/Reference/TFTLibrary
== License ==
diff --git a/libraries/TFT/examples/Arduino/TFTBitmapLogo/TFTBitmapLogo.ino b/libraries/TFT/examples/Arduino/TFTBitmapLogo/TFTBitmapLogo.ino
index 7a588b62b..92459931d 100644
--- a/libraries/TFT/examples/Arduino/TFTBitmapLogo/TFTBitmapLogo.ino
+++ b/libraries/TFT/examples/Arduino/TFTBitmapLogo/TFTBitmapLogo.ino
@@ -15,7 +15,7 @@
Created 19 April 2013 by Enrico Gueli
- http://arduino.cc/en/Tutorial/TFTBitmapLogo
+ http://www.arduino.cc/en/Tutorial/TFTBitmapLogo
*/
diff --git a/libraries/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino b/libraries/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino
index da921939c..ba71d1e57 100644
--- a/libraries/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino
+++ b/libraries/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino
@@ -10,7 +10,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/TFTColorPicker
+ http://www.arduino.cc/en/Tutorial/TFTColorPicker
*/
diff --git a/libraries/TFT/examples/Arduino/TFTDisplayText/TFTDisplayText.ino b/libraries/TFT/examples/Arduino/TFTDisplayText/TFTDisplayText.ino
index b4d6cd695..a9c1d8699 100644
--- a/libraries/TFT/examples/Arduino/TFTDisplayText/TFTDisplayText.ino
+++ b/libraries/TFT/examples/Arduino/TFTDisplayText/TFTDisplayText.ino
@@ -11,7 +11,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/TFTDisplayText
+ http://www.arduino.cc/en/Tutorial/TFTDisplayText
*/
diff --git a/libraries/TFT/examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino b/libraries/TFT/examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino
index 7facbc31f..2a3d6e713 100644
--- a/libraries/TFT/examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino
+++ b/libraries/TFT/examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino
@@ -10,7 +10,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/TFTEtchASketch
+ http://www.arduino.cc/en/Tutorial/TFTEtchASketch
*/
diff --git a/libraries/TFT/examples/Arduino/TFTGraph/TFTGraph.ino b/libraries/TFT/examples/Arduino/TFTGraph/TFTGraph.ino
index 83fcd328d..6c789593c 100644
--- a/libraries/TFT/examples/Arduino/TFTGraph/TFTGraph.ino
+++ b/libraries/TFT/examples/Arduino/TFTGraph/TFTGraph.ino
@@ -10,7 +10,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/TFTGraph
+ http://www.arduino.cc/en/Tutorial/TFTGraph
*/
diff --git a/libraries/TFT/examples/Arduino/TFTPong/TFTPong.ino b/libraries/TFT/examples/Arduino/TFTPong/TFTPong.ino
index 74c605b83..7a6191538 100644
--- a/libraries/TFT/examples/Arduino/TFTPong/TFTPong.ino
+++ b/libraries/TFT/examples/Arduino/TFTPong/TFTPong.ino
@@ -12,7 +12,7 @@
Created by Tom Igoe December 2012
Modified 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/TFTPong
+ http://www.arduino.cc/en/Tutorial/TFTPong
*/
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino b/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino
index e3ac59800..d6eba2e35 100644
--- a/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino
+++ b/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino
@@ -17,7 +17,7 @@
Created 19 April 2013 by Enrico Gueli
- http://arduino.cc/en/Tutorial/EsploraTFTBitmapLogo
+ http://www.arduino.cc/en/Tutorial/EsploraTFTBitmapLogo
*/
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTColorPicker/EsploraTFTColorPicker.ino b/libraries/TFT/examples/Esplora/EsploraTFTColorPicker/EsploraTFTColorPicker.ino
index 0d9e42599..cdce051e1 100644
--- a/libraries/TFT/examples/Esplora/EsploraTFTColorPicker/EsploraTFTColorPicker.ino
+++ b/libraries/TFT/examples/Esplora/EsploraTFTColorPicker/EsploraTFTColorPicker.ino
@@ -10,7 +10,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/TFTColorPicker
+ http://www.arduino.cc/en/Tutorial/TFTColorPicker
*/
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTEtchASketch/EsploraTFTEtchASketch.ino b/libraries/TFT/examples/Esplora/EsploraTFTEtchASketch/EsploraTFTEtchASketch.ino
index 24f1901f2..9a42ffa0c 100644
--- a/libraries/TFT/examples/Esplora/EsploraTFTEtchASketch/EsploraTFTEtchASketch.ino
+++ b/libraries/TFT/examples/Esplora/EsploraTFTEtchASketch/EsploraTFTEtchASketch.ino
@@ -11,7 +11,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/EsploraTFTEtchASketch
+ http://www.arduino.cc/en/Tutorial/EsploraTFTEtchASketch
*/
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTGraph/EsploraTFTGraph.ino b/libraries/TFT/examples/Esplora/EsploraTFTGraph/EsploraTFTGraph.ino
index e46c03c50..06364c20e 100644
--- a/libraries/TFT/examples/Esplora/EsploraTFTGraph/EsploraTFTGraph.ino
+++ b/libraries/TFT/examples/Esplora/EsploraTFTGraph/EsploraTFTGraph.ino
@@ -10,7 +10,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/EsploraTFTGraph
+ http://www.arduino.cc/en/Tutorial/EsploraTFTGraph
*/
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTHorizon/EsploraTFTHorizon.ino b/libraries/TFT/examples/Esplora/EsploraTFTHorizon/EsploraTFTHorizon.ino
index 3be485d8d..34abf29d2 100644
--- a/libraries/TFT/examples/Esplora/EsploraTFTHorizon/EsploraTFTHorizon.ino
+++ b/libraries/TFT/examples/Esplora/EsploraTFTHorizon/EsploraTFTHorizon.ino
@@ -10,7 +10,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/EsploraTFTHorizon
+ http://www.arduino.cc/en/Tutorial/EsploraTFTHorizon
*/
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTPong/EsploraTFTPong.ino b/libraries/TFT/examples/Esplora/EsploraTFTPong/EsploraTFTPong.ino
index e6c793df7..11b1dffa1 100644
--- a/libraries/TFT/examples/Esplora/EsploraTFTPong/EsploraTFTPong.ino
+++ b/libraries/TFT/examples/Esplora/EsploraTFTPong/EsploraTFTPong.ino
@@ -13,7 +13,7 @@
Created by Tom Igoe December 2012
Modified 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/EsploraTFTPong
+ http://www.arduino.cc/en/Tutorial/EsploraTFTPong
*/
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino b/libraries/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino
index f3c529482..a5c70817c 100644
--- a/libraries/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino
+++ b/libraries/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino
@@ -13,7 +13,7 @@
Created 15 April 2013 by Scott Fitzgerald
- http://arduino.cc/en/Tutorial/EsploraTFTTemp
+ http://www.arduino.cc/en/Tutorial/EsploraTFTTemp
*/
diff --git a/libraries/TFT/extras/README.md b/libraries/TFT/extras/README.md
index 8489a20d4..6f41794fc 100644
--- a/libraries/TFT/extras/README.md
+++ b/libraries/TFT/extras/README.md
@@ -12,7 +12,7 @@ The TFT library relies on the SPI library for communication with the screen and
https://github.com/adafruit/Adafruit-GFX-Library
https://github.com/adafruit/Adafruit-ST7735-Library
-http://arduino.cc/en/Reference/SD
-http://arduino.cc/en/Reference/SPI
+http://www.arduino.cc/en/Reference/SD
+http://www.arduino.cc/en/Reference/SPI
-http://arduino.cc/en/Reference/TFTLibrary
\ No newline at end of file
+http://www.arduino.cc/en/Reference/TFTLibrary
\ No newline at end of file
diff --git a/libraries/TFT/library.properties b/libraries/TFT/library.properties
index a46758741..c40f8ee3a 100644
--- a/libraries/TFT/library.properties
+++ b/libraries/TFT/library.properties
@@ -1,9 +1,9 @@
name=TFT
-version=1.0.2
+version=1.0.4
author=Arduino, Adafruit
maintainer=Arduino
sentence=Allows drawing text, images, and shapes on the Arduino TFT graphical display. For all Arduino boards.
paragraph=This library is compatible with most of the TFT display based on the ST7735 chipset
category=Display
-url=http://arduino.cc/en/Reference/TFTLibrary
+url=http://www.arduino.cc/en/Reference/TFTLibrary
architectures=*
diff --git a/libraries/TFT/src/utility/Adafruit_ST7735.cpp b/libraries/TFT/src/utility/Adafruit_ST7735.cpp
index df91f7d27..1fdd37ef6 100644
--- a/libraries/TFT/src/utility/Adafruit_ST7735.cpp
+++ b/libraries/TFT/src/utility/Adafruit_ST7735.cpp
@@ -73,6 +73,9 @@ inline void Adafruit_ST7735::spiwrite(uint8_t c) {
void Adafruit_ST7735::writecommand(uint8_t c) {
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.beginTransaction(spisettings);
+#endif
*rsport &= ~rspinmask;
*csport &= ~cspinmask;
@@ -80,10 +83,16 @@ void Adafruit_ST7735::writecommand(uint8_t c) {
spiwrite(c);
*csport |= cspinmask;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.endTransaction();
+#endif
}
void Adafruit_ST7735::writedata(uint8_t c) {
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.beginTransaction(spisettings);
+#endif
*rsport |= rspinmask;
*csport &= ~cspinmask;
@@ -91,7 +100,10 @@ void Adafruit_ST7735::writedata(uint8_t c) {
spiwrite(c);
*csport |= cspinmask;
-}
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.endTransaction();
+#endif
+}
// Rather than a bazillion writecommand() and writedata() calls, screen
@@ -331,6 +343,9 @@ void Adafruit_ST7735::commonInit(const uint8_t *cmdList) {
if(hwSPI) { // Using hardware SPI
SPI.begin();
+#ifdef SPI_HAS_TRANSACTION
+ spisettings = SPISettings(4000000L, MSBFIRST, SPI_MODE0);
+#else
#if defined(ARDUINO_ARCH_SAM)
SPI.setClockDivider(24); // 4 MHz (half speed)
#else
@@ -338,6 +353,7 @@ void Adafruit_ST7735::commonInit(const uint8_t *cmdList) {
#endif
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
+#endif // SPI_HAS_TRANSACTION
} else {
pinMode(_sclk, OUTPUT);
pinMode(_sid , OUTPUT);
@@ -413,6 +429,9 @@ void Adafruit_ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1,
void Adafruit_ST7735::pushColor(uint16_t color) {
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.beginTransaction(spisettings);
+#endif
*rsport |= rspinmask;
*csport &= ~cspinmask;
@@ -421,6 +440,9 @@ void Adafruit_ST7735::pushColor(uint16_t color) {
spiwrite(color);
*csport |= cspinmask;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.endTransaction();
+#endif
}
void Adafruit_ST7735::drawPixel(int16_t x, int16_t y, uint16_t color) {
@@ -429,6 +451,9 @@ void Adafruit_ST7735::drawPixel(int16_t x, int16_t y, uint16_t color) {
setAddrWindow(x,y,x+1,y+1);
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.beginTransaction(spisettings);
+#endif
*rsport |= rspinmask;
*csport &= ~cspinmask;
@@ -438,6 +463,9 @@ void Adafruit_ST7735::drawPixel(int16_t x, int16_t y, uint16_t color) {
spiwrite(color);
*csport |= cspinmask;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.endTransaction();
+#endif
}
@@ -452,6 +480,9 @@ void Adafruit_ST7735::drawFastVLine(int16_t x, int16_t y, int16_t h,
if (tabcolor == INITR_BLACKTAB) color = swapcolor(color);
uint8_t hi = color >> 8, lo = color;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.beginTransaction(spisettings);
+#endif
*rsport |= rspinmask;
*csport &= ~cspinmask;
while (h--) {
@@ -459,6 +490,9 @@ void Adafruit_ST7735::drawFastVLine(int16_t x, int16_t y, int16_t h,
spiwrite(lo);
}
*csport |= cspinmask;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.endTransaction();
+#endif
}
@@ -473,6 +507,9 @@ void Adafruit_ST7735::drawFastHLine(int16_t x, int16_t y, int16_t w,
if (tabcolor == INITR_BLACKTAB) color = swapcolor(color);
uint8_t hi = color >> 8, lo = color;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.beginTransaction(spisettings);
+#endif
*rsport |= rspinmask;
*csport &= ~cspinmask;
while (w--) {
@@ -480,6 +517,9 @@ void Adafruit_ST7735::drawFastHLine(int16_t x, int16_t y, int16_t w,
spiwrite(lo);
}
*csport |= cspinmask;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.endTransaction();
+#endif
}
@@ -504,6 +544,9 @@ void Adafruit_ST7735::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
setAddrWindow(x, y, x+w-1, y+h-1);
uint8_t hi = color >> 8, lo = color;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.beginTransaction(spisettings);
+#endif
*rsport |= rspinmask;
*csport &= ~cspinmask;
for(y=h; y>0; y--) {
@@ -514,6 +557,9 @@ void Adafruit_ST7735::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
}
*csport |= cspinmask;
+#ifdef SPI_HAS_TRANSACTION
+ if (hwSPI) SPI.endTransaction();
+#endif
}
diff --git a/libraries/TFT/src/utility/Adafruit_ST7735.h b/libraries/TFT/src/utility/Adafruit_ST7735.h
index df52dd8a9..0233a93a2 100644
--- a/libraries/TFT/src/utility/Adafruit_ST7735.h
+++ b/libraries/TFT/src/utility/Adafruit_ST7735.h
@@ -26,6 +26,7 @@
#include "WProgram.h"
#endif
#include "Adafruit_GFX.h"
+#include
#include
// some flags for initR() :(
@@ -135,7 +136,10 @@ class Adafruit_ST7735 : public Adafruit_GFX {
//uint8_t spiread(void);
boolean hwSPI;
- #if defined(ARDUINO_ARCH_SAM)
+#ifdef SPI_HAS_TRANSACTION
+ SPISettings spisettings;
+#endif
+#if defined(ARDUINO_ARCH_SAM)
volatile uint32_t *dataport, *clkport, *csport, *rsport;
uint32_t _cs, _rs, _rst, _sid, _sclk,
datapinmask, clkpinmask, cspinmask, rspinmask,
diff --git a/libraries/Temboo/README.adoc b/libraries/Temboo/README.adoc
deleted file mode 100644
index ec74a12d4..000000000
--- a/libraries/Temboo/README.adoc
+++ /dev/null
@@ -1,19 +0,0 @@
-= Temboo Library for Arduino =
-
-This library allows an Arduino Yun to connect to the Temboo service.
-
-== License ==
-
-Copyright 2015, Temboo Inc.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-either express or implied. See the License for the specific
-language governing permissions and limitations under the License.
diff --git a/libraries/Temboo/extras/readme.txt b/libraries/Temboo/extras/readme.txt
deleted file mode 100644
index cb8b49718..000000000
--- a/libraries/Temboo/extras/readme.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-Temboo Library for Arduino
-
-Installation
-------------
-
-For installation instructions, please visit:
-
-http://temboo.com/arduino/others/library-installation
-
-Examples, Tutorials & More
---------------------------
-
-You can find lots of examples, tutorials and info about Device Coder (Temboo's tool for automatically generating internet-connected sketch code) at the link below:
-
-http://temboo.com/arduino/
-
-Compatibility
--------------
-
-This library has been tested with the following Arduino boards:
-
-* TRE
-* Yún
-* Due
-* Mega
-* Uno
-
-And the following internet shields:
-
-* Arduino Wifi Shield
-* Arduino Ethernet Shield
diff --git a/libraries/Temboo/keywords.txt b/libraries/Temboo/keywords.txt
deleted file mode 100644
index 40d670dd7..000000000
--- a/libraries/Temboo/keywords.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-#######################################
-# Syntax Coloring Map Temboo
-#######################################
-
-#######################################
-# Class (KEYWORD1)
-#######################################
-
-Temboo KEYWORD1
-
-#######################################
-# Datatypes (KEYWORD2)
-#######################################
-
-TembooChoreo KEYWORD2
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-begin KEYWORD2
-setAccountName KEYWORD2
-setAppKeyName KEYWORD2
-setAppKey KEYWORD2
-setChoreo KEYWORD2
-setCredential KEYWORD2
-setSavedInputs KEYWORD2
-addInput KEYWORD2
-addOutputFilter KEYWORD2
-setSettingsFileToWrite KEYWORD2
-setSettingsFileToRead KEYWORD2
diff --git a/libraries/Temboo/library.properties b/libraries/Temboo/library.properties
deleted file mode 100644
index 9b743a33a..000000000
--- a/libraries/Temboo/library.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-name=Temboo
-author=Temboo
-maintainer=Temboo
-sentence=This library enables calls to Temboo, a platform that connects Arduino boards to 100+ APIs, databases, code utilities and more.
-paragraph=Use this library to connect your Arduino board to Temboo, making it simple to interact with a vast array of web-based resources and services.
-category=Communication
-url=http://www.temboo.com/arduino
-architectures=*
-version=1.1.2
-core-dependencies=arduino (>=1.5.0)
diff --git a/libraries/Temboo/src/Temboo.cpp b/libraries/Temboo/src/Temboo.cpp
deleted file mode 100644
index f4eb85e7f..000000000
--- a/libraries/Temboo/src/Temboo.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-
-#if defined (ARDUINO_AVR_YUN) || defined (ARDUINO_AVR_TRE)
-
-///////////////////////////////////////////////////////
-// BEGIN ARDUINO YUN AND TRE SUPPORT
-///////////////////////////////////////////////////////
-
-#include
-
-void TembooChoreo::begin() {
- Process::begin("temboo");
-}
-
-void TembooChoreo::setAccountName(const String& accountName) {
- addParameter("-a" + accountName);
-}
-
-void TembooChoreo::setAppKeyName(const String& appKeyName) {
- addParameter("-u" + appKeyName);
-}
-
-void TembooChoreo::setAppKey(const String& appKey) {
- addParameter("-p" + appKey);
-}
-
-void TembooChoreo::setChoreo(const String& choreo) {
- addParameter("-c" + choreo);
-}
-
-void TembooChoreo::setCredential(const String& credentialName) {
- addParameter("-e" + credentialName);
-}
-
-void TembooChoreo::setSavedInputs(const String& savedInputsName) {
- addParameter("-e" + savedInputsName);
-}
-
-void TembooChoreo::setProfile(const String& profileName) {
- addParameter("-e" + profileName);
-}
-
-void TembooChoreo::addInput(const String& inputName, const String& inputValue) {
- addParameter("-i" + inputName + ":" + inputValue);
-}
-
-void TembooChoreo::addOutputFilter(const String& outputName, const String& filterPath, const String& variableName) {
- addParameter("-o" + outputName + ":" + filterPath + ":" + variableName);
-}
-
-void TembooChoreo::setSettingsFileToWrite(const String& filePath) {
- addParameter("-w" + filePath);
-}
-
-void TembooChoreo::setSettingsFileToRead(const String& filePath) {
- addParameter("-r" + filePath);
-}
-
-
-#else //ARDUINO_AVR_YUN
-
-///////////////////////////////////////////////////////
-// BEGIN ARDUINO NON-YUN SUPPORT
-///////////////////////////////////////////////////////
-
-#include
-#include
-#include
-#include
-#include "utility/TembooGlobal.h"
-#include "utility/TembooSession.h"
-
-static const char HTTP_CODE[] PROGMEM = "HTTP_CODE\x0A\x1F";
-static char HTTP_EOL[] = "\r\n";
-static char HTTP_EOH[] = "\r\n\r\n";
-
-TembooChoreo::TembooChoreo(Client& client) : m_client(client) {
- m_accountName = NULL;
- m_appKeyName = NULL;
- m_appKeyValue = NULL;
- m_path = NULL;
- m_nextChar = NULL;
- m_nextState = END;
-}
-
-void TembooChoreo::setAccountName(const String& accountName) {
- m_accountName = accountName.c_str();
-}
-
-
-void TembooChoreo::setAccountName(const char* accountName) {
- m_accountName = accountName;
-}
-
-
-void TembooChoreo::setAppKeyName(const String& appKeyName) {
- m_appKeyName = appKeyName.c_str();
-}
-
-
-void TembooChoreo::setAppKeyName(const char* appKeyName) {
- m_appKeyName = appKeyName;
-}
-
-
-void TembooChoreo::setAppKey(const String& appKeyValue) {
- m_appKeyValue = appKeyValue.c_str();
-}
-
-
-void TembooChoreo::setAppKey(const char* appKeyValue) {
- m_appKeyValue = appKeyValue;
-}
-
-
-void TembooChoreo::setChoreo(const String& path) {
- m_path = path.c_str();
-}
-
-
-void TembooChoreo::setChoreo(const char* path) {
- m_path = path;
-}
-
-
-void TembooChoreo::setSavedInputs(const String& savedInputsName) {
- m_preset.put(savedInputsName.c_str());
-}
-
-
-void TembooChoreo::setSavedInputs(const char* savedInputsName) {
- m_preset.put(savedInputsName);
-}
-
-
-void TembooChoreo::setCredential(const String& credentialName) {
- m_preset.put(credentialName.c_str());
-}
-
-
-void TembooChoreo::setCredential(const char* credentialName) {
- m_preset.put(credentialName);
-}
-
-void TembooChoreo::setProfile(const String& profileName) {
- m_preset.put(profileName.c_str());
-}
-
-
-void TembooChoreo::setProfile(const char* profileName) {
- m_preset.put(profileName);
-}
-
-
-void TembooChoreo::addInput(const String& inputName, const String& inputValue) {
- m_inputs.put(inputName.c_str(), inputValue.c_str());
-}
-
-
-void TembooChoreo::addInput(const char* inputName, const char* inputValue) {
- m_inputs.put(inputName, inputValue);
-}
-
-
-void TembooChoreo::addInput(const char* inputName, const String& inputValue) {
- m_inputs.put(inputName, inputValue.c_str());
-}
-
-
-void TembooChoreo::addInput(const String& inputName, const char* inputValue) {
- m_inputs.put(inputName.c_str(), inputValue);
-}
-
-
-void TembooChoreo::addOutputFilter(const char* outputName, const char* filterPath, const char* variableName) {
- m_outputs.put(outputName, filterPath, variableName);
-}
-
-
-void TembooChoreo::addOutputFilter(const String& outputName, const char* filterPath, const char* variableName) {
- m_outputs.put(outputName.c_str(), filterPath, variableName);
-}
-
-
-void TembooChoreo::addOutputFilter(const char* outputName, const String& filterPath, const char* variableName) {
- m_outputs.put(outputName, filterPath.c_str(), variableName);
-}
-
-
-void TembooChoreo::addOutputFilter(const String& outputName, const String& filterPath, const char* variableName) {
- m_outputs.put(outputName.c_str(), filterPath.c_str(), variableName);
-}
-
-
-void TembooChoreo::addOutputFilter(const char* outputName, const char* filterPath, const String& variableName) {
- m_outputs.put(outputName, filterPath, variableName.c_str());
-}
-
-
-void TembooChoreo::addOutputFilter(const String& outputName, const char* filterPath, const String& variableName) {
- m_outputs.put(outputName.c_str(), filterPath, variableName.c_str());
-}
-
-
-void TembooChoreo::addOutputFilter(const char* outputName, const String& filterPath, const String& variableName) {
- m_outputs.put(outputName, filterPath.c_str(), variableName.c_str());
-}
-
-
-void TembooChoreo::addOutputFilter(const String& outputName, const String& filterPath, const String& variableName) {
- m_outputs.put(outputName.c_str(), filterPath.c_str(), variableName.c_str());
-}
-
-
-int TembooChoreo::run() {
- return run(INADDR_NONE, 80, TEMBOO_CHOREO_DEFAULT_TIMEOUT_SECS);
-}
-
-int TembooChoreo::run(uint16_t timeoutSecs) {
- return run(INADDR_NONE, 80, timeoutSecs);
-}
-
-int TembooChoreo::run(IPAddress addr, uint16_t port, uint16_t timeoutSecs) {
-
- m_nextChar = NULL;
-
- if (m_accountName == NULL || *m_accountName == '\0') {
- return TEMBOO_ERROR_ACCOUNT_MISSING;
- }
-
- if (m_path == NULL || *m_path == '\0') {
- return TEMBOO_ERROR_CHOREO_MISSING;
- }
-
- if (m_appKeyName == NULL || *m_appKeyName == '\0') {
- return TEMBOO_ERROR_APPKEY_NAME_MISSING;
- }
-
- if (m_appKeyValue == NULL || *m_appKeyValue == '\0') {
- return TEMBOO_ERROR_APPKEY_MISSING;
- }
-
- TembooSession session(m_client, addr, port);
- uint16_t httpCode = 0;
-
- for (int i = 0; i < 2; i++) {
- unsigned long timeoutBeginSecs = session.getTime();
- if (0 != session.executeChoreo(m_accountName, m_appKeyName, m_appKeyValue, m_path, m_inputs, m_outputs, m_preset)) {
- httpCode = 0;
- break;
- }
-
- while(!m_client.available()) {
- if((session.getTime() - timeoutBeginSecs) >= timeoutSecs) {
- TEMBOO_TRACELN("Receive time out");
- m_client.stop();
- return TEMBOO_ERROR_STREAM_TIMEOUT;
- }
- if (!m_client.connected()) {
- TEMBOO_TRACELN("Disconnected");
- return TEMBOO_ERROR_HTTP_ERROR;
- }
- delay(10);
- }
- if (!m_client.findUntil("HTTP/1.", HTTP_EOL)) {
- TEMBOO_TRACELN("No HTTP");
- return TEMBOO_ERROR_HTTP_ERROR;
- }
- //Don't care if the next byte is a '1' or a '0'
- m_client.read();
-
- //Read the HTTP status code
- httpCode = (uint16_t)m_client.parseInt();
-
- // We expect HTTP response codes to be <= 599, but
- // we need to be prepared for anything.
- if (httpCode >= 600) {
- TEMBOO_TRACELN("Invalid HTTP");
- httpCode = 0;
- }
-
- // if we get an auth error AND there was an x-temboo-time header,
- // update the session timeOffset
- if ((httpCode == 401) && (i == 0)) {
- if (m_client.findUntil("x-temboo-time:", HTTP_EOH)) {
- TembooSession::setTime((unsigned long)m_client.parseInt());
- while(m_client.available()) {
- m_client.read();
- }
- m_client.stop();
- }
- } else {
- break;
- }
- }
-
- uint16toa(httpCode, m_httpCodeStr);
- strcat_P(m_httpCodeStr, PSTR("\x0A\x1E"));
- m_nextState = START;
- m_nextChar = HTTP_CODE;
-
- if (httpCode < 200 || httpCode >= 300) {
- return TEMBOO_ERROR_HTTP_ERROR;
- }
-
- if (!m_client.find(HTTP_EOH)) {
- return TEMBOO_ERROR_HTTP_ERROR;
- }
-
- return TEMBOO_ERROR_OK;
-}
-
-void TembooChoreo::close() {
- m_client.stop();
-}
-
-int TembooChoreo::available() {
- // If we're still sending the HTTP response code,
- // report at least one character available.
- if (m_nextChar != NULL) {
- return m_client.available() + 1;
- }
-
- // Otherwise, return however many characters the client has.
- return m_client.available();
-}
-
-
-int TembooChoreo::peek() {
- // If we're still sending the HTTP response code,
- // return the next character in that sequence.
- if (m_nextChar != NULL) {
- return (int)*m_nextChar;
- }
-
- // Otherwise, return whatever is in the client buffer.
- return m_client.peek();
-}
-
-
-int TembooChoreo::read() {
-
- int c = 0;
- switch(m_nextState) {
- case START:
- m_nextChar = HTTP_CODE;
- c = (int)pgm_read_byte(m_nextChar++);
- m_nextState = HTTP_CODE_TAG;
- break;
-
- case HTTP_CODE_TAG:
- c = (int)pgm_read_byte(m_nextChar++);
- if (pgm_read_byte(m_nextChar) == '\0') {
- m_nextState = HTTP_CODE_VALUE;
- m_nextChar = m_httpCodeStr;
- }
- break;
-
- case HTTP_CODE_VALUE:
- c = (int)(*m_nextChar++);
- if (*m_nextChar == '\0') {
- m_nextState = END;
- m_nextChar = NULL;
- }
- break;
-
- default:
- c = m_client.read();
- }
- return c;
-}
-
-
-size_t TembooChoreo::write(uint8_t data) {
- return m_client.write(data);
-}
-
-
-void TembooChoreo::flush() {
- m_nextChar = NULL;
- m_nextState = END;
- m_client.flush();
-}
-
-#endif //ARDUINO_AVR_YUN
diff --git a/libraries/Temboo/src/Temboo.h b/libraries/Temboo/src/Temboo.h
deleted file mode 100644
index 881fe484a..000000000
--- a/libraries/Temboo/src/Temboo.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef TEMBOO_H_
-#define TEMBOO_H_
-
-#include
-
-#if defined (ARDUINO_AVR_YUN) || defined (ARDUINO_AVR_TRE)
-///////////////////////////////////////////////////////
-// BEGIN ARDUINO YUN AND TRE SUPPORT
-///////////////////////////////////////////////////////
-
-#include
-
-class TembooChoreo : public Process {
-
- public:
- void begin();
- void setAccountName(const String& accountName);
- void setAppKeyName(const String& appKeyName);
- void setAppKey(const String& appKey);
- void setChoreo(const String& choreo);
- void setCredential(const String& credentialName);
- void setSavedInputs(const String& saveInputsName);
- void setProfile(const String& profileName);
- void addInput(const String& inputName, const String& inputValue);
- void addOutputFilter(const String& filterName, const String& filterPath, const String& variableName);
- void setSettingsFileToWrite(const String& filePath);
- void setSettingsFileToRead(const String& filePath);
-
-};
-
-#else //ARDUINO_AVR_YUN
-
-///////////////////////////////////////////////////////
-// BEGIN ARDUINO NON-YUN SUPPORT
-///////////////////////////////////////////////////////
-
-#include
-#include
-#include
-#include "utility/ChoreoInputSet.h"
-#include "utility/ChoreoOutputSet.h"
-#include "utility/ChoreoPreset.h"
-
-#define TEMBOO_ERROR_OK (0)
-#define TEMBOO_ERROR_ACCOUNT_MISSING (201)
-#define TEMBOO_ERROR_CHOREO_MISSING (203)
-#define TEMBOO_ERROR_APPKEY_NAME_MISSING (205)
-#define TEMBOO_ERROR_APPKEY_MISSING (207)
-#define TEMBOO_ERROR_HTTP_ERROR (223)
-#define TEMBOO_ERROR_STREAM_TIMEOUT (225)
-#define TEMBOO_CHOREO_DEFAULT_TIMEOUT_SECS (901) //15 minutes and 1 second
-
-class TembooChoreo : public Stream {
- public:
-
- // Constructor.
- // client - an instance of an Arduino Client, usually an EthernetClient
- // or a WiFiClient. Used to communicate with Temboo.
- TembooChoreo(Client& client);
-
- // Does nothing. Just for source compatibility with Yun code.
- void begin() {};
-
- // Sets the account name to use when communicating with Temboo.
- // (required)
- void setAccountName(const String& accountName);
- void setAccountName(const char* accountName);
-
- // Sets the application key name to use with choreo execution requests.
- // (required)
- void setAppKeyName(const String& appKeyName);
- void setAppKeyName(const char* appKeyName);
-
- // Sets the application key value to use with choreo execution requests
- // (required)
- void setAppKey(const String& appKey);
- void setAppKey(const char* appKey);
-
- // sets the name of the choreo to be executed.
- // (required)
- void setChoreo(const String& choreoPath);
- void setChoreo(const char* choreoPath);
-
- // sets the name of the saved inputs to use when executing the choreo
- // (optional)
- void setSavedInputs(const String& savedInputsName);
- void setSavedInputs(const char* savedInputsName);
-
- void setCredential(const String& credentialName);
- void setCredential(const char* credentialName);
-
- void setProfile(const String& profileName);
- void setProfile(const char* profileName);
-
- // sets an input to be used when executing a choreo.
- // (optional or required, depending on the choreo being executed.)
- void addInput(const String& inputName, const String& inputValue);
- void addInput(const char* inputName, const char* inputValue);
- void addInput(const char* inputName, const String& inputValue);
- void addInput(const String& inputName, const char* inputValue);
-
- // sets an output filter to be used to process the choreo output
- // (optional)
- void addOutputFilter(const char* filterName, const char* filterPath, const char* variableName);
- void addOutputFilter(const String& filterName, const char* filterPath, const char* variableName);
- void addOutputFilter(const char* filterName, const String& filterPath, const char* variableName);
- void addOutputFilter(const String& filterName, const String& filterPath, const char* variableName);
- void addOutputFilter(const char* filterName, const char* filterPath, const String& variableName);
- void addOutputFilter(const String& filterName, const char* filterPath, const String& variableName);
- void addOutputFilter(const char* filterName, const String& filterPath, const String& variableName);
- void addOutputFilter(const String& filterName, const String& filterPath, const String& variableName);
-
- // run the choreo using the current input info
- int run();
-
- // run the choreo on the Temboo server at the given IP address and port
- // (used only when instructed by Temboo customer support.)
- int run(uint16_t timeoutSecs);
- int run(IPAddress addr, uint16_t port, uint16_t timeoutSecs);
-
- void close();
-
- // Stream interface - see the Arduino library documentation.
- int available();
- int read();
- int peek();
- void flush();
-
- //Print interface - see the Arduino library documentation
- size_t write(uint8_t data);
-
-
- protected:
- ChoreoInputSet m_inputs;
- ChoreoOutputSet m_outputs;
- ChoreoPreset m_preset;
-
- const char* m_accountName;
- const char* m_appKeyValue;
- const char* m_appKeyName;
- const char* m_path;
- Client& m_client;
- char m_httpCodeStr[6];
- const char* m_nextChar;
- enum State {START, HTTP_CODE_TAG, HTTP_CODE_VALUE, END};
- State m_nextState;
-
-};
-
-#endif //ARDUINO_AVR_YUN
-
-#endif //TEMBOO_H_
diff --git a/libraries/Temboo/src/utility/BaseFormatter.cpp b/libraries/Temboo/src/utility/BaseFormatter.cpp
deleted file mode 100644
index 1e575e217..000000000
--- a/libraries/Temboo/src/utility/BaseFormatter.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include "BaseFormatter.h"
-
-char BaseFormatter::escape(char c) {
- char outChar = c;
- switch(c) {
- case '\\':
- case '"':
- outChar = '\\';
- m_escapedChar = c;
- break;
- case '\b':
- outChar = '\\';
- m_escapedChar = 'b';
- break;
- case '\f':
- outChar = '\\';
- m_escapedChar = 'f';
- break;
- case '\n':
- outChar = '\\';
- m_escapedChar = 'n';
- break;
- case '\r':
- outChar = '\\';
- m_escapedChar = 'r';
- break;
- case '\t':
- outChar = '\\';
- m_escapedChar = 't';
- break;
- default:
- m_escapedChar = '\0';
- }
- return outChar;
-}
-
-char BaseFormatter::finishEscape() {
- char c = m_escapedChar;
- m_escapedChar = '\0';
- return c;
-}
-
-char BaseFormatter::readTagChar(int nextState) {
- char c = pgm_read_byte(m_nextChar++);
- if (pgm_read_byte(m_nextChar) == '\0') {
- m_nextState = nextState;
- }
- return c;
-}
-
-char BaseFormatter::readValueChar(int nextState) {
- char c;
- if (isEscaping()) {
- c = finishEscape();
- if (*m_nextChar == '\0') {
- m_nextState = nextState;
- }
- } else {
- c = escape(*m_nextChar++);
- if (!isEscaping()) {
- if(*m_nextChar == '\0') {
- m_nextState = nextState;
- }
- }
- }
- return c;
-}
-
-char BaseFormatter::readStartTagChar(const char* tag, int nextState) {
- m_nextChar = tag;
- char c = pgm_read_byte(m_nextChar++);
- m_nextState = nextState;
- return c;
-}
diff --git a/libraries/Temboo/src/utility/BaseFormatter.h b/libraries/Temboo/src/utility/BaseFormatter.h
deleted file mode 100644
index 3d4443124..000000000
--- a/libraries/Temboo/src/utility/BaseFormatter.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef BASEFORMATTER_H_
-#define BASEFORMATTER_H_
-#include "TembooGlobal.h"
-
-class BaseFormatter {
- public:
- BaseFormatter() {m_escapedChar = '\0';}
-
- protected:
- const char* m_nextChar;
- int m_nextState;
- char m_escapedChar;
-
- char escape(char c);
- bool isEscaping() {return m_escapedChar != '\0';}
- char finishEscape();
-
- char readTagChar(int nextState);
- char readValueChar(int nextState);
- char readStartTagChar(const char* tag, int nextState);
-
-};
-
-#endif
diff --git a/libraries/Temboo/src/utility/ChoreoInput.cpp b/libraries/Temboo/src/utility/ChoreoInput.cpp
deleted file mode 100644
index faf921d89..000000000
--- a/libraries/Temboo/src/utility/ChoreoInput.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include
-#include "ChoreoInput.h"
-
-ChoreoInput::ChoreoInput(ChoreoInput* prev, const char* name, const char* value) {
- if (prev != NULL) {
- prev->m_next = this;
- }
- m_next = NULL;
- m_name = name;
- m_value = value;
-}
-
diff --git a/libraries/Temboo/src/utility/ChoreoInput.h b/libraries/Temboo/src/utility/ChoreoInput.h
deleted file mode 100644
index a23ca700c..000000000
--- a/libraries/Temboo/src/utility/ChoreoInput.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef CHOREOINPUT_H_
-#define CHOREOINPUT_H_
-#include "TembooGlobal.h"
-class ChoreoInput {
- public:
- ChoreoInput(ChoreoInput* prev, const char* name, const char* value);
- const char* getName() const {return m_name;}
- const char* getValue() const {return m_value;}
- void setValue(const char* value) {m_value = value;}
- ChoreoInput* getNext() const {return m_next;}
-
- private:
- ChoreoInput* m_next;
- const char* m_name;
- const char* m_value;
-};
-
-#endif
-
diff --git a/libraries/Temboo/src/utility/ChoreoInputFormatter.cpp b/libraries/Temboo/src/utility/ChoreoInputFormatter.cpp
deleted file mode 100644
index a54c55375..000000000
--- a/libraries/Temboo/src/utility/ChoreoInputFormatter.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include
-#include
-#include "ChoreoInputFormatter.h"
-#include "ChoreoInputSet.h"
-
-static const char TAG_INPUTS_START[] PROGMEM = "\"inputs\":{";
-
-ChoreoInputFormatter::ChoreoInputFormatter(const ChoreoInputSet* inputSet) {
- m_inputSet = inputSet;
- reset();
-}
-
-void ChoreoInputFormatter::reset() {
- m_currentInput = NULL;
- m_nextChar = NULL;
- if (m_inputSet == NULL || m_inputSet->isEmpty()) {
- m_nextState = END;
- } else {
- m_nextState = START;
- }
-}
-
-bool ChoreoInputFormatter::hasNext() {
- return m_nextState != END;
-}
-
-char ChoreoInputFormatter::next() {
- char c;
- switch(m_nextState) {
- case START:
- c = readStartTagChar(TAG_INPUTS_START, INPUTS_TAG);
- break;
-
- case INPUTS_TAG:
- c = readTagChar(NAME_START);
- if (m_nextState == NAME_START) {
- m_currentInput= m_inputSet->getFirstInput();
- }
- break;
-
- case NAME_START:
- c = '"';
- m_nextChar = m_currentInput->getName();
- if ((NULL == m_nextChar) || ('\0' == *m_nextChar)) {
- m_nextState = NAME_END;
- } else {
- m_nextState = NAME;
- }
- break;
-
- case NAME:
- c = readValueChar(NAME_END);
- break;
-
- case NAME_END:
- c = '"';
- m_nextState = NAME_VALUE_SEPARATOR;
- break;
-
- case NAME_VALUE_SEPARATOR:
- c = ':';
- m_nextState = VALUE_START;
- break;
-
- case VALUE_START:
- c = '"';
- m_nextChar = m_currentInput->getValue();
- if ((NULL == m_nextChar) || ('\0' == *m_nextChar)) {
- m_nextState = VALUE_END;
- } else {
- m_nextState = VALUE;
- }
- break;
-
- case VALUE:
- c = readValueChar(VALUE_END);
- break;
-
- case VALUE_END:
- c = '"';
- m_currentInput = m_currentInput->getNext();
- if (m_currentInput != NULL) {
- m_nextState = NEXT_INPUT;
- } else {
- m_nextState = INPUTS_END;
- }
- break;
- case NEXT_INPUT:
- c = ',';
- m_nextChar = m_currentInput->getName();
- m_nextState = NAME_START;
- break;
-
- case INPUTS_END:
- c = '}';
- m_nextState = END;
- break;
- case END:
- default:
- c = '\0';
- }
- return c;
-}
diff --git a/libraries/Temboo/src/utility/ChoreoInputFormatter.h b/libraries/Temboo/src/utility/ChoreoInputFormatter.h
deleted file mode 100644
index 8946c5d10..000000000
--- a/libraries/Temboo/src/utility/ChoreoInputFormatter.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef CHOREOINPUTFORMATTER_H_
-#define CHOREOINPUTFORMATTER_H_
-#include "TembooGlobal.h"
-#include "BaseFormatter.h"
-#include "ChoreoInputSet.h"
-
-class ChoreoInputFormatter : public BaseFormatter {
-
- public:
- ChoreoInputFormatter(const ChoreoInputSet* inputSet);
- bool hasNext();
- char next();
- void reset();
-
- protected:
- const ChoreoInputSet* m_inputSet;
- const ChoreoInput* m_currentInput;
-
-
- enum State {
- START,
- INPUTS_TAG,
- NAME_START,
- NAME,
- NAME_END,
- NAME_VALUE_SEPARATOR,
- VALUE_START,
- VALUE,
- VALUE_END,
- NEXT_INPUT,
- INPUTS_END,
- END
- };
-};
-
-#endif
diff --git a/libraries/Temboo/src/utility/ChoreoInputSet.cpp b/libraries/Temboo/src/utility/ChoreoInputSet.cpp
deleted file mode 100644
index 09a9f1aac..000000000
--- a/libraries/Temboo/src/utility/ChoreoInputSet.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include
-#include "ChoreoInputSet.h"
-
-ChoreoInputSet::ChoreoInputSet() {
- m_first = NULL;
-}
-
-ChoreoInputSet::~ChoreoInputSet() {
- ChoreoInput* i = m_first;
- ChoreoInput* next = NULL;
- while (i != NULL) {
- next = i->getNext();
- delete i;
- i = next;
- }
-}
-
-void ChoreoInputSet::put(const char* name, const char* value) {
-
- // Haven't set ANY inputs yet?
- // Just create a new one.
- if (m_first == NULL) {
- m_first = new ChoreoInput(NULL, name, value);
- } else {
- // Some inputs already set.
- // See if we already have this input.
- ChoreoInput* last = NULL;
- ChoreoInput* i = m_first;
- while(i != NULL) {
- if (strcmp(i->getName(), name) == 0) {
- // We already have an input with this name.
- // Just update the value.
- i->setValue(value);
- break;
- }
- last = i;
- i = i->getNext();
- }
-
- // We don't have an input with this name
- // So we need to create a new one.
- if (i == NULL) {
- new ChoreoInput(last, name, value);
- }
- }
-}
-
-const char* ChoreoInputSet::get(const char* name) const {
- ChoreoInput* i = m_first;
- while(i != NULL) {
- if (strcmp(i->getName(), name) == 0) {
- return i->getValue();
- }
- i = i->getNext();
- }
- return NULL;
-}
-
diff --git a/libraries/Temboo/src/utility/ChoreoInputSet.h b/libraries/Temboo/src/utility/ChoreoInputSet.h
deleted file mode 100644
index 123a38a23..000000000
--- a/libraries/Temboo/src/utility/ChoreoInputSet.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef CHOREOINPUTSET_H_
-#define CHOREOINPUTSET_H_
-#include
-#include "TembooGlobal.h"
-#include "ChoreoInput.h"
-
-class ChoreoInputSet {
-
- public:
- ChoreoInputSet();
- ~ChoreoInputSet();
- void put(const char* name, const char* value);
- const char* get(const char* name) const;
- bool isEmpty() const {return m_first == NULL;}
- const ChoreoInput* getFirstInput() const {return m_first;}
-
- protected:
- ChoreoInput* m_first;
-};
-
-#endif
diff --git a/libraries/Temboo/src/utility/ChoreoOutput.cpp b/libraries/Temboo/src/utility/ChoreoOutput.cpp
deleted file mode 100644
index 63cdc5fda..000000000
--- a/libraries/Temboo/src/utility/ChoreoOutput.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include
-#include "ChoreoOutput.h"
-
-
-ChoreoOutput::ChoreoOutput(ChoreoOutput* prev, const char* name, const char* path, const char* var) {
- if (prev != NULL) {
- prev->m_next = this;
- }
- m_next = NULL;
- m_name = name;
- m_path = path;
- m_var = var;
-}
-
-
diff --git a/libraries/Temboo/src/utility/ChoreoOutput.h b/libraries/Temboo/src/utility/ChoreoOutput.h
deleted file mode 100644
index 844e8b5fb..000000000
--- a/libraries/Temboo/src/utility/ChoreoOutput.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef CHOREOOUTPUT_H_
-#define CHOREOOUTPUT_H_
-#include "TembooGlobal.h"
-
-class ChoreoOutput {
- public:
- ChoreoOutput(ChoreoOutput* prev, const char* name, const char* path, const char* var);
- const char* getName() const {return m_name;}
- const char* getPath() const {return m_path;}
- const char* getVariable() const {return m_var;}
- void setPath(const char* path) {m_path = path;}
- void setVariable(const char* variable) {m_var = variable;}
- ChoreoOutput* getNext() const {return m_next;}
-
- private:
- ChoreoOutput* m_next;
- const char* m_name;
- const char* m_path;
- const char* m_var;
-};
-
-#endif
diff --git a/libraries/Temboo/src/utility/ChoreoOutputFormatter.cpp b/libraries/Temboo/src/utility/ChoreoOutputFormatter.cpp
deleted file mode 100644
index 53561ccd8..000000000
--- a/libraries/Temboo/src/utility/ChoreoOutputFormatter.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include
-#include
-#include "ChoreoOutputFormatter.h"
-#include "ChoreoOutputSet.h"
-
-static const char TAG_OUTPUTS_START[] PROGMEM = "\"outputs\":[";
-static const char TAG_NAME[] PROGMEM = "\"name\":";
-static const char TAG_PATH[] PROGMEM = "\"path\":";
-static const char TAG_VAR[] PROGMEM = "\"variable\":";
-
-
-ChoreoOutputFormatter::ChoreoOutputFormatter(const ChoreoOutputSet* outputSet) {
- m_outputSet = outputSet;
- reset();
-}
-
-void ChoreoOutputFormatter::reset() {
- m_currentOutput = NULL;
- m_nextChar = NULL;
- if (m_outputSet == NULL || m_outputSet->isEmpty()) {
- m_nextState = END;
- } else {
- m_nextState = START;
- }
-}
-
-bool ChoreoOutputFormatter::hasNext() {
- return m_nextState != END;
-}
-
-char ChoreoOutputFormatter::next() {
- char c = '\0';
- switch(m_nextState) {
- case START:
- c = readStartTagChar(TAG_OUTPUTS_START, OUTPUTS_TAG);
- break;
-
- case OUTPUTS_TAG:
- c = readTagChar(OUTPUT_START);
- if (m_nextState == OUTPUT_START) {
- m_currentOutput = m_outputSet->getFirstOutput();
- }
- break;
-
- case OUTPUT_START:
- c = '{';
- m_nextChar = TAG_NAME;
- m_nextState = NAME_TAG;
- break;
-
- case NAME_TAG:
- c = readTagChar(NAME_START);
- break;
-
- case NAME_START:
- c = '"';
- m_nextChar = m_currentOutput->getName();
- if ((NULL == m_nextChar) || ('\0' == *m_nextChar)) {
- m_nextState = NAME_END;
- } else {
- m_nextState = NAME;
- }
- break;
-
- case NAME:
- c = readValueChar(NAME_END);
- break;
-
- case NAME_END:
- c = '"';
- m_nextState = NAME_PATH_SEPARATOR;
- break;
-
- case NAME_PATH_SEPARATOR:
- c = ',';
- m_nextState = PATH_TAG;
- m_nextChar = TAG_PATH;
- break;
-
- case PATH_TAG:
- c = readTagChar(PATH_START);
- break;
-
- case PATH_START:
- c = '"';
- m_nextChar = m_currentOutput->getPath();
- if ((NULL == m_nextChar) || ('\0' == *m_nextChar)) {
- m_nextState = PATH_END;
- } else {
- m_nextState = PATH;
- }
- break;
-
- case PATH:
- c = readValueChar(PATH_END);
- break;
-
- case PATH_END:
- c = '"';
- m_nextState = PATH_VAR_SEPARATOR;
- break;
-
- case PATH_VAR_SEPARATOR:
- c = ',';
- m_nextState = VAR_TAG;
- m_nextChar = TAG_VAR;
- break;
-
- case VAR_TAG:
- c = readTagChar(VAR_START);
- break;
-
- case VAR_START:
- c = '"';
- m_nextChar = m_currentOutput->getVariable();
- if ((NULL == m_nextChar) || ('\0' == *m_nextChar)) {
- m_nextState = VAR_END;
- } else {
- m_nextState = VAR;
- }
- break;
-
- case VAR:
- c = readValueChar(VAR_END);
- break;
-
- case VAR_END:
- c = '"';
- m_nextState = OUTPUT_END;
- break;
-
- case OUTPUT_END:
- c = '}';
- m_currentOutput = m_currentOutput->getNext();
- if (m_currentOutput != NULL) {
- m_nextState = NEXT_OUTPUT;
- } else {
- m_nextState = OUTPUTS_END;
- }
- break;
-
- case NEXT_OUTPUT:
- c = ',';
- m_nextChar = m_currentOutput->getName();
- m_nextState = OUTPUT_START;
- break;
-
- case OUTPUTS_END:
- c = ']';
- m_nextState = END;
- break;
- case END:
- default:
- c = '\0';
- }
-
- return c;
-}
-
diff --git a/libraries/Temboo/src/utility/ChoreoOutputFormatter.h b/libraries/Temboo/src/utility/ChoreoOutputFormatter.h
deleted file mode 100644
index 52874a6ca..000000000
--- a/libraries/Temboo/src/utility/ChoreoOutputFormatter.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef CHOREOOUTPUTFORMATTER_H_
-#define CHOREOOUTPUTFORMATTER_H_
-#include "TembooGlobal.h"
-#include "BaseFormatter.h"
-#include "ChoreoOutputSet.h"
-
-class ChoreoOutputFormatter : public BaseFormatter {
-
- public:
- ChoreoOutputFormatter(const ChoreoOutputSet* outputSet);
- bool hasNext();
- char next();
- void reset();
-
- protected:
- const ChoreoOutputSet* m_outputSet;
- const ChoreoOutput* m_currentOutput;
-
- enum State {
- START,
- OUTPUTS_TAG,
- OUTPUT_START,
- NAME_TAG,
- NAME_START,
- NAME,
- NAME_END,
- NAME_PATH_SEPARATOR,
- PATH_TAG,
- PATH_START,
- PATH,
- PATH_END,
- PATH_VAR_SEPARATOR,
- VAR_TAG,
- VAR_START,
- VAR,
- VAR_END,
- OUTPUT_END,
- NEXT_OUTPUT,
- OUTPUTS_END,
- END
- };
-};
-
-#endif
diff --git a/libraries/Temboo/src/utility/ChoreoOutputSet.cpp b/libraries/Temboo/src/utility/ChoreoOutputSet.cpp
deleted file mode 100644
index 084fe625b..000000000
--- a/libraries/Temboo/src/utility/ChoreoOutputSet.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include
-#include
-#include "ChoreoOutputSet.h"
-
-
-ChoreoOutputSet::ChoreoOutputSet() {
- m_first = NULL;
-}
-
-ChoreoOutputSet::~ChoreoOutputSet() {
- ChoreoOutput* i = m_first;
- ChoreoOutput* next = NULL;
- while(i != NULL) {
- next = i->getNext();
- delete i;
- i = next;
- }
-}
-
-void ChoreoOutputSet::put(const char* name, const char* path, const char* variable) {
- if (m_first == NULL) {
- m_first = new ChoreoOutput(NULL, name, path, variable);
- } else {
- ChoreoOutput* last = NULL;
- ChoreoOutput* i = m_first;
- while(i != NULL) {
- if (strcmp(i->getName(), name) == 0) {
- i->setPath(path);
- i->setVariable(variable);
- break;
- }
- last = i;
- i = i->getNext();
- }
-
- if (i == NULL) {
- new ChoreoOutput(last, name, path, variable);
- }
- }
-}
-
-const ChoreoOutput* ChoreoOutputSet::get(const char* name) const {
- ChoreoOutput* i = m_first;
- while(i != NULL) {
- if (strcmp(i->getName(), name) == 0) {
- return i;
- }
- i = i->getNext();
- }
- return NULL;
-}
diff --git a/libraries/Temboo/src/utility/ChoreoOutputSet.h b/libraries/Temboo/src/utility/ChoreoOutputSet.h
deleted file mode 100644
index 2c0fc4b9c..000000000
--- a/libraries/Temboo/src/utility/ChoreoOutputSet.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef CHOREOOUTPUTSET_H_
-#define CHOREOOUTPUTSET_H_
-#include
-#include "TembooGlobal.h"
-#include "ChoreoOutput.h"
-
-class ChoreoOutputSet {
-
- public:
- ChoreoOutputSet();
- ~ChoreoOutputSet();
- void put(const char* name, const char* path, const char* variable);
- const ChoreoOutput* get(const char* name) const;
- bool isEmpty() const {return m_first == NULL;}
- const ChoreoOutput* getFirstOutput() const {return m_first;}
-
- protected:
- ChoreoOutput* m_first;
-};
-
-#endif
diff --git a/libraries/Temboo/src/utility/ChoreoPreset.cpp b/libraries/Temboo/src/utility/ChoreoPreset.cpp
deleted file mode 100644
index 61a785026..000000000
--- a/libraries/Temboo/src/utility/ChoreoPreset.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include "ChoreoPreset.h"
diff --git a/libraries/Temboo/src/utility/ChoreoPreset.h b/libraries/Temboo/src/utility/ChoreoPreset.h
deleted file mode 100644
index 2ba457b6d..000000000
--- a/libraries/Temboo/src/utility/ChoreoPreset.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#ifndef CHOREOPRESET_H_
-#define CHOREOPRESET_H_
-#include
-#include "TembooGlobal.h"
-
-class ChoreoPreset {
- public:
- ChoreoPreset() {m_name = NULL;}
- ChoreoPreset(const char* name) {put(name);}
- const char* getName() const {return m_name;}
- void put(const char* name) {m_name = name;}
- bool isEmpty() const {return m_name == NULL || *m_name == '\0';}
-
- private:
- const char* m_name;
-};
-
-#endif
diff --git a/libraries/Temboo/src/utility/ChoreoPresetFormatter.cpp b/libraries/Temboo/src/utility/ChoreoPresetFormatter.cpp
deleted file mode 100644
index f34d181a5..000000000
--- a/libraries/Temboo/src/utility/ChoreoPresetFormatter.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-###############################################################################
-#
-# Temboo Arduino library
-#
-# Copyright 2015, Temboo Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###############################################################################
-*/
-
-#include
-#include