diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 5f603378b..680545e6d 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -545,7 +545,7 @@ public class Base { newbieDir.mkdirs(); // Make an empty pde file - File newbieFile = new File(newbieDir, newbieName + ".pde"); + File newbieFile = new File(newbieDir, newbieName + ".ino"); new FileOutputStream(newbieFile); // create the file return newbieFile.getAbsolutePath(); } @@ -637,7 +637,8 @@ public class Base { public boolean accept(File dir, String name) { // TODO this doesn't seem to ever be used. AWESOME. //System.out.println("check filter on " + dir + " " + name); - return name.toLowerCase().endsWith(".pde"); + return name.toLowerCase().endsWith(".ino") + || name.toLowerCase().endsWith(".pde"); } }); @@ -1024,22 +1025,28 @@ public class Base { } - public void rebuildBurnBootloaderMenu(JMenu menu) { - //System.out.println("rebuilding burn bootloader menu"); + public void rebuildProgrammerMenu(JMenu menu) { + //System.out.println("rebuilding programmer menu"); menu.removeAll(); + ButtonGroup group = new ButtonGroup(); for (Target target : targetsTable.values()) { for (String programmer : target.getProgrammers().keySet()) { AbstractAction action = new AbstractAction( - "w/ " + target.getProgrammers().get(programmer).get("name")) { + target.getProgrammers().get(programmer).get("name")) { public void actionPerformed(ActionEvent actionevent) { - activeEditor.handleBurnBootloader((String) getValue("target"), - (String) getValue("programmer")); + Preferences.set("programmer", getValue("target") + ":" + + getValue("programmer")); } }; action.putValue("target", target.getName()); action.putValue("programmer", programmer); - JMenuItem item = new JMenuItem(action); + JMenuItem item = new JRadioButtonMenuItem(action); + if (Preferences.get("programmer").equals(target.getName() + ":" + + programmer)) { + item.setSelected(true); + } + group.add(item); menu.add(item); } } @@ -1099,7 +1106,10 @@ public class Base { File subfolder = new File(folder, list[i]); if (!subfolder.isDirectory()) continue; - File entry = new File(subfolder, list[i] + ".pde"); + File entry = new File(subfolder, list[i] + ".ino"); + if (!entry.exists() && (new File(subfolder, list[i] + ".pde")).exists()) { + entry = new File(subfolder, list[i] + ".pde"); + } // if a .pde file of the same prefix as the folder exists.. if (entry.exists()) { //String sanityCheck = sanitizedName(list[i]); diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 3d8bd405b..6de3c4882 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -46,6 +46,7 @@ import gnu.io.*; /** * Main editor panel for the Processing Development Environment. */ +@SuppressWarnings("serial") public class Editor extends JFrame implements RunnerListener { Base base; @@ -113,7 +114,7 @@ public class Editor extends JFrame implements RunnerListener { EditorLineStatus lineStatus; - JEditorPane editorPane; + //JEditorPane editorPane; JEditTextArea textarea; EditorListener listener; @@ -195,8 +196,10 @@ public class Editor extends JFrame implements RunnerListener { //PdeKeywords keywords = new PdeKeywords(); //sketchbook = new Sketchbook(this); - if (serialMonitor == null) + if (serialMonitor == null) { serialMonitor = new SerialMonitor(Preferences.get("serial.port")); + serialMonitor.setIconImage(getIconImage()); + } buildMenuBar(); @@ -538,7 +541,7 @@ public class Editor extends JFrame implements RunnerListener { }); fileMenu.add(saveAsMenuItem); - item = newJMenuItem("Upload to I/O Board", 'U'); + item = newJMenuItem("Upload", 'U'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleExport(false); @@ -546,13 +549,13 @@ public class Editor extends JFrame implements RunnerListener { }); fileMenu.add(item); -// item = newJMenuItemShift("Upload to I/O Board (verbose)", 'U'); -// item.addActionListener(new ActionListener() { -// public void actionPerformed(ActionEvent e) { -// handleExport(true); -// } -// }); -// fileMenu.add(item); + item = newJMenuItemShift("Upload Using Programmer", 'U'); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + handleExport(true); + } + }); + fileMenu.add(item); fileMenu.addSeparator(); @@ -618,13 +621,13 @@ public class Editor extends JFrame implements RunnerListener { // }); // sketchMenu.add(item); - item = new JMenuItem("Stop"); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - handleStop(); - } - }); - sketchMenu.add(item); +// item = new JMenuItem("Stop"); +// item.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// handleStop(); +// } +// }); +// sketchMenu.add(item); sketchMenu.addSeparator(); @@ -693,12 +696,20 @@ public class Editor extends JFrame implements RunnerListener { serialMenu = new JMenu("Serial Port"); populateSerialMenu(); menu.add(serialMenu); - + menu.addSeparator(); + + JMenu programmerMenu = new JMenu("Programmer"); + base.rebuildProgrammerMenu(programmerMenu); + menu.add(programmerMenu); - JMenu bootloaderMenu = new JMenu("Burn Bootloader"); - base.rebuildBurnBootloaderMenu(bootloaderMenu); - menu.add(bootloaderMenu); + item = new JMenuItem("Burn Bootloader"); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + handleBurnBootloader(); + } + }); + menu.add(item); menu.addMenuListener(new MenuListener() { public void menuCanceled(MenuEvent e) {} @@ -899,6 +910,7 @@ public class Editor extends JFrame implements RunnerListener { public void actionPerformed(ActionEvent e) { selectSerialPort(((JCheckBoxMenuItem)e.getSource()).getText()); + base.onBoardOrPortChange(); } /* @@ -989,8 +1001,8 @@ public class Editor extends JFrame implements RunnerListener { //serialMenu.addSeparator(); //serialMenu.add(item); } - - + + protected 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. @@ -1810,7 +1822,7 @@ public class Editor extends JFrame implements RunnerListener { internalCloseRunner(); running = true; toolbar.activate(EditorToolbar.RUN); - statusNotice("Compiling..."); + status.progress("Compiling sketch..."); // do this to advance/clear the terminal window / dos prompt / etc for (int i = 0; i < 10; i++) System.out.println(); @@ -1830,12 +1842,14 @@ public class Editor extends JFrame implements RunnerListener { public void run() { try { sketch.prepare(); - String appletClassName = sketch.build(false); + sketch.build(false); statusNotice("Done compiling."); } catch (Exception e) { + status.unprogress(); statusError(e); } + status.unprogress(); toolbar.deactivate(EditorToolbar.RUN); } } @@ -1845,12 +1859,14 @@ public class Editor extends JFrame implements RunnerListener { public void run() { try { sketch.prepare(); - String appletClassName = sketch.build(true); + sketch.build(true); statusNotice("Done compiling."); } catch (Exception e) { + status.unprogress(); statusError(e); } + status.unprogress(); toolbar.deactivate(EditorToolbar.RUN); } } @@ -1887,12 +1903,12 @@ public class Editor extends JFrame implements RunnerListener { * Implements Sketch → Stop, or pressing Stop on the toolbar. */ public void handleStop() { // called by menu or buttons - toolbar.activate(EditorToolbar.STOP); +// toolbar.activate(EditorToolbar.STOP); internalCloseRunner(); toolbar.deactivate(EditorToolbar.RUN); - toolbar.deactivate(EditorToolbar.STOP); +// toolbar.deactivate(EditorToolbar.STOP); // focus the PDE again after quitting presentation mode [toxi 030903] toFront(); @@ -2035,33 +2051,35 @@ public class Editor extends JFrame implements RunnerListener { // check to make sure that this .pde file is // in a folder of the same name File file = new File(path); - File parentFile = new File(file.getParent()); - String parentName = parentFile.getName(); + String fileName = file.getName(); + File parent = file.getParentFile(); + String parentName = parent.getName(); String pdeName = parentName + ".pde"; - File altFile = new File(file.getParent(), pdeName); - - if (pdeName.equals(file.getName())) { + File altPdeFile = new File(parent, pdeName); + String inoName = parentName + ".ino"; + File altInoFile = new File(parent, pdeName); + + if (pdeName.equals(fileName) || inoName.equals(fileName)) { // no beef with this guy - } else if (altFile.exists()) { - // user selected a .java from the same sketch, - // but open the .pde instead - path = altFile.getAbsolutePath(); - //System.out.println("found alt file in same folder"); - - } else if (!path.endsWith(".pde")) { + } else if (altPdeFile.exists()) { + // user selected a .java from the same sketch, but open the .pde instead + path = altPdeFile.getAbsolutePath(); + } else if (altInoFile.exists()) { + path = altInoFile.getAbsolutePath(); + } else if (!path.endsWith(".ino") && !path.endsWith(".pde")) { Base.showWarning("Bad file selected", "Processing can only open its own sketches\n" + - "and other files ending in .pde", null); + "and other files ending in .ino or .pde", null); return false; } else { String properParent = - file.getName().substring(0, file.getName().length() - 4); + fileName.substring(0, fileName.length() - 4); Object[] options = { "OK", "Cancel" }; String prompt = - "The file \"" + file.getName() + "\" needs to be inside\n" + + "The file \"" + fileName + "\" needs to be inside\n" + "a sketch folder named \"" + properParent + "\".\n" + "Create this folder, move the file, and continue?"; @@ -2156,7 +2174,7 @@ public class Editor extends JFrame implements RunnerListener { // need to get the name, user might also cancel here } else if (immediately) { - handleSave2(); + return handleSave2(); } else { SwingUtilities.invokeLater(new Runnable() { @@ -2169,15 +2187,16 @@ public class Editor extends JFrame implements RunnerListener { } - protected void handleSave2() { + protected boolean handleSave2() { toolbar.activate(EditorToolbar.SAVE); statusNotice("Saving..."); + boolean saved = false; try { - if (sketch.save()) { + saved = sketch.save(); + if (saved) statusNotice("Done Saving."); - } else { + 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 @@ -2196,6 +2215,7 @@ public class Editor extends JFrame implements RunnerListener { } //toolbar.clear(); toolbar.deactivate(EditorToolbar.SAVE); + return saved; } @@ -2252,6 +2272,7 @@ public class Editor extends JFrame implements RunnerListener { 0); if (result == null) return false; selectSerialPort(result); + base.onBoardOrPortChange(); return true; } @@ -2271,13 +2292,13 @@ public class Editor extends JFrame implements RunnerListener { * Made synchronized to (hopefully) avoid problems of people * hitting export twice, quickly, and horking things up. */ - synchronized public void handleExport(final boolean verbose) { + synchronized public void handleExport(final boolean usingProgrammer) { //if (!handleExportCheckModified()) return; toolbar.activate(EditorToolbar.EXPORT); console.clear(); - statusNotice("Uploading to I/O Board..."); + status.progress("Uploading to I/O Board..."); - new Thread(verbose ? exportAppHandler : exportHandler).start(); + new Thread(usingProgrammer ? exportAppHandler : exportHandler).start(); } // DAM: in Arduino, this is upload @@ -2304,10 +2325,12 @@ public class Editor extends JFrame implements RunnerListener { } catch (RunnerException e) { //statusError("Error during upload."); //e.printStackTrace(); + status.unprogress(); statusError(e); } catch (Exception e) { e.printStackTrace(); } + status.unprogress(); uploading = false; //toolbar.clear(); toolbar.deactivate(EditorToolbar.EXPORT); @@ -2338,10 +2361,12 @@ public class Editor extends JFrame implements RunnerListener { } catch (RunnerException e) { //statusError("Error during upload."); //e.printStackTrace(); + status.unprogress(); statusError(e); } catch (Exception e) { e.printStackTrace(); } + status.unprogress(); uploading = false; //toolbar.clear(); toolbar.deactivate(EditorToolbar.EXPORT); @@ -2395,14 +2420,14 @@ public class Editor extends JFrame implements RunnerListener { } - protected void handleBurnBootloader(final String target, final String programmer) { + protected void handleBurnBootloader() { console.clear(); statusNotice("Burning bootloader to I/O Board (this may take a minute)..."); SwingUtilities.invokeLater(new Runnable() { public void run() { try { Uploader uploader = new AvrdudeUploader(); - if (uploader.burnBootloader(target, programmer)) { + if (uploader.burnBootloader()) { statusNotice("Done burning bootloader."); } else { statusError("Error while burning bootloader."); @@ -2556,30 +2581,49 @@ public class Editor extends JFrame implements RunnerListener { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + protected void onBoardOrPortChange() { + Map boardPreferences = Base.getBoardPreferences(); + lineStatus.setBoardName(boardPreferences.get("name")); + lineStatus.setSerialPort(Preferences.get("serial.port")); + lineStatus.repaint(); + } + /** * Returns the edit popup menu. */ class TextAreaPopup extends JPopupMenu { - //String currentDir = System.getProperty("user.dir"); - String referenceFile = null; + //private String currentDir = System.getProperty("user.dir"); + private String referenceFile = null; - JMenuItem cutItem; - JMenuItem copyItem; - JMenuItem discourseItem; - JMenuItem referenceItem; + private JMenuItem cutItem; + private JMenuItem copyItem; + private JMenuItem discourseItem; + private JMenuItem referenceItem; + private JMenuItem openURLItem; + private JSeparator openURLItemSeparator; + private String clickedURL; public TextAreaPopup() { - JMenuItem item; - + openURLItem = new JMenuItem("Open URL"); + openURLItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Base.openURL(clickedURL); + } + }); + add(openURLItem); + + openURLItemSeparator = new JSeparator(); + add(openURLItemSeparator); + cutItem = new JMenuItem("Cut"); cutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleCut(); } }); - this.add(cutItem); + add(cutItem); copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @@ -2587,7 +2631,7 @@ public class Editor extends JFrame implements RunnerListener { handleCopy(); } }); - this.add(copyItem); + add(copyItem); discourseItem = new JMenuItem("Copy for Forum"); discourseItem.addActionListener(new ActionListener() { @@ -2595,7 +2639,7 @@ public class Editor extends JFrame implements RunnerListener { handleDiscourseCopy(); } }); - this.add(discourseItem); + add(discourseItem); discourseItem = new JMenuItem("Copy as HTML"); discourseItem.addActionListener(new ActionListener() { @@ -2603,15 +2647,15 @@ public class Editor extends JFrame implements RunnerListener { handleHTMLCopy(); } }); - this.add(discourseItem); + add(discourseItem); - item = new JMenuItem("Paste"); + JMenuItem item = new JMenuItem("Paste"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handlePaste(); } }); - this.add(item); + add(item); item = new JMenuItem("Select All"); item.addActionListener(new ActionListener() { @@ -2619,9 +2663,9 @@ public class Editor extends JFrame implements RunnerListener { handleSelectAll(); } }); - this.add(item); + add(item); - this.addSeparator(); + addSeparator(); item = new JMenuItem("Comment/Uncomment"); item.addActionListener(new ActionListener() { @@ -2629,7 +2673,7 @@ public class Editor extends JFrame implements RunnerListener { handleCommentUncomment(); } }); - this.add(item); + add(item); item = new JMenuItem("Increase Indent"); item.addActionListener(new ActionListener() { @@ -2637,7 +2681,7 @@ public class Editor extends JFrame implements RunnerListener { handleIndentOutdent(true); } }); - this.add(item); + add(item); item = new JMenuItem("Decrease Indent"); item.addActionListener(new ActionListener() { @@ -2645,9 +2689,9 @@ public class Editor extends JFrame implements RunnerListener { handleIndentOutdent(false); } }); - this.add(item); + add(item); - this.addSeparator(); + addSeparator(); referenceItem = new JMenuItem("Find in Reference"); referenceItem.addActionListener(new ActionListener() { @@ -2655,11 +2699,23 @@ public class Editor extends JFrame implements RunnerListener { handleFindReference(); } }); - this.add(referenceItem); + add(referenceItem); } // if no text is selected, disable copy and cut menu items public void show(Component component, int x, int y) { + int lineNo = textarea.getLineOfOffset(textarea.xyToOffset(x, y)); + int offset = textarea.xToOffset(lineNo, x); + String line = textarea.getLineText(lineNo); + clickedURL = textarea.checkClickedURL(line, offset); + if (clickedURL != null) { + openURLItem.setVisible(true); + openURLItemSeparator.setVisible(true); + } else { + openURLItem.setVisible(false); + openURLItemSeparator.setVisible(false); + } + if (textarea.isSelectionActive()) { cutItem.setEnabled(true); copyItem.setEnabled(true); diff --git a/app/src/processing/app/EditorToolbar.java b/app/src/processing/app/EditorToolbar.java index 9ddc48576..6b04aa2d9 100644 --- a/app/src/processing/app/EditorToolbar.java +++ b/app/src/processing/app/EditorToolbar.java @@ -37,12 +37,12 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key /** Rollover titles for each button. */ static final String title[] = { - "Verify", "Stop", "New", "Open", "Save", "Upload", "Serial Monitor" + "Verify", "Upload", "New", "Open", "Save", "Serial Monitor" }; /** Titles for each button when the shift key is pressed. */ static final String titleShift[] = { - "Verify (w/ Verbose Output)", "Stop", "New Editor Window", "Open in Another Window", "Save", "Upload (w/ Verbose Output)", "Serial Monitor" + "Verify", "Upload Using Programmer", "New Editor Window", "Open in Another Window", "Save", "Serial Monitor" }; static final int BUTTON_COUNT = title.length; @@ -57,14 +57,13 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key static final int RUN = 0; - static final int STOP = 1; + static final int EXPORT = 1; static final int NEW = 2; static final int OPEN = 3; static final int SAVE = 4; - static final int EXPORT = 5; - static final int SERIAL = 6; + static final int SERIAL = 5; static final int INACTIVE = 0; static final int ROLLOVER = 1; @@ -105,11 +104,10 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key //which[buttonCount++] = NOTHING; which[buttonCount++] = RUN; - which[buttonCount++] = STOP; + which[buttonCount++] = EXPORT; which[buttonCount++] = NEW; which[buttonCount++] = OPEN; which[buttonCount++] = SAVE; - which[buttonCount++] = EXPORT; which[buttonCount++] = SERIAL; currentRollover = -1; @@ -322,13 +320,13 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key switch (sel) { case RUN: - editor.handleRun(e.isShiftDown()); - break; - - case STOP: - editor.handleStop(); + editor.handleRun(false); break; +// case STOP: +// editor.handleStop(); +// break; +// case OPEN: popup = menu.getPopupMenu(); popup.show(EditorToolbar.this, x, y); diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index f05d7c57b..4cee5ad8e 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -113,6 +113,8 @@ public class Preferences { JTextField sketchbookLocationField; JCheckBox exportSeparateBox; + JCheckBox verboseCompilationBox; + JCheckBox verboseUploadBox; JCheckBox deletePreviousBox; JCheckBox externalEditorBox; JCheckBox memoryOverrideBox; @@ -280,6 +282,21 @@ public class Preferences { top += d.height + GUI_BETWEEN; + // Show verbose output during: [ ] compilation [ ] upload + + box = Box.createHorizontalBox(); + label = new JLabel("Show verbose output during: "); + box.add(label); + verboseCompilationBox = new JCheckBox("compilation "); + box.add(verboseCompilationBox); + verboseUploadBox = new JCheckBox("upload"); + box.add(verboseUploadBox); + pain.add(box); + d = box.getPreferredSize(); + box.setBounds(left, top, d.width, d.height); + top += d.height + GUI_BETWEEN; + + // [ ] Delete previous applet or application folder on export deletePreviousBox = @@ -470,6 +487,8 @@ public class Preferences { */ protected void applyFrame() { // put each of the settings into the table + setBoolean("build.verbose", verboseCompilationBox.isSelected()); + setBoolean("upload.verbose", verboseUploadBox.isSelected()); setBoolean("export.delete_target_folder", deletePreviousBox.isSelected()); @@ -527,6 +546,8 @@ public class Preferences { this.editor = editor; // set all settings entry boxes to their actual status + verboseCompilationBox.setSelected(getBoolean("build.verbose")); + verboseUploadBox.setSelected(getBoolean("upload.verbose")); deletePreviousBox. setSelected(getBoolean("export.delete_target_folder")); diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 801067c5e..4a90795de 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -36,6 +36,7 @@ import java.awt.event.*; import java.beans.*; import java.io.*; import java.util.*; +import java.util.List; import java.util.zip.*; import javax.swing.*; @@ -261,7 +262,6 @@ public class Sketch { } } - boolean renamingCode; /** @@ -315,7 +315,7 @@ public class Sketch { renamingCode = true; String prompt = (currentIndex == 0) ? "New name for sketch:" : "New name for file:"; - String oldName = (current.isExtension("pde")) ? + String oldName = (current.isExtension("ino")) ? current.getPrettyName() : current.getFileName(); editor.status.edit(prompt, oldName); } @@ -495,7 +495,7 @@ public class Sketch { } // if successful, set base properties for the sketch - File newMainFile = new File(newFolder, newName + ".pde"); + File newMainFile = new File(newFolder, newName + ".ino"); String newMainFilePath = newMainFile.getAbsolutePath(); // having saved everything and renamed the folder and the main .pde, @@ -707,15 +707,68 @@ public class Sketch { "need to re-save this sketch to another location."); // if the user cancels, give up on the save() if (!saveAs()) return false; + } else { + // rename .pde files to .ino + File mainFile = new File(getMainFilePath()); + File mainFolder = mainFile.getParentFile(); + File[] pdeFiles = mainFolder.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.toLowerCase().endsWith(".pde"); + } + }); + + if (pdeFiles != null && pdeFiles.length > 0) { + if (Preferences.get("editor.update_extension") == null) { + Object[] options = { "OK", "Cancel" }; + int result = JOptionPane.showOptionDialog(editor, + "In Arduino 1.0, the default file extension has changed\n" + + "from .pde to .ino. New sketches (including those created\n" + + "by \"Save-As\" will use the new extension. The extension\n" + + "of existing sketches will be updated on save, but you can\n" + + "disable this in the Preferences dialog.\n" + + "\n" + + "Save sketch and update its extension?", + ".pde -> .ino", + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + options, + options[0]); + + if (result != JOptionPane.OK_OPTION) return false; // save cancelled + + Preferences.setBoolean("editor.update_extension", true); + } + + if (Preferences.getBoolean("editor.update_extension")) { + // Do rename of all .pde files to new .ino extension + for (File pdeFile : pdeFiles) + renameCodeToInoExtension(pdeFile); + } + } } for (int i = 0; i < codeCount; i++) { - if (code[i].isModified()) code[i].save(); + if (code[i].isModified()) + code[i].save(); } calcModified(); return true; } + + protected boolean renameCodeToInoExtension(File pdeFile) { + for (SketchCode c : code) { + if (!c.getFile().equals(pdeFile)) + continue; + + String pdeName = pdeFile.getPath(); + pdeName = pdeName.substring(0, pdeName.length() - 4) + ".ino"; + return c.renameTo(new File(pdeName), "ino"); + } + return false; + } + /** * Handles 'Save As' for a sketch. @@ -860,7 +913,7 @@ public class Sketch { } // save the main tab with its new name - File newFile = new File(newFolder, newName + ".pde"); + File newFile = new File(newFolder, newName + ".ino"); code[0].saveAs(newFile); editor.handleOpenUnchecked(newFile.getPath(), @@ -1261,7 +1314,7 @@ public class Sketch { StringBuffer bigCode = new StringBuffer(); int bigCount = 0; for (SketchCode sc : code) { - if (sc.isExtension("pde")) { + if (sc.isExtension("ino") || sc.isExtension("pde")) { sc.setPreprocOffset(bigCount); bigCode.append(sc.getProgram()); bigCode.append('\n'); @@ -1357,7 +1410,7 @@ public class Sketch { } // sc.setPreprocName(filename); - } else if (sc.isExtension("pde")) { + } else if (sc.isExtension("ino") || sc.isExtension("pde")) { // The compiler and runner will need this to have a proper offset sc.addPreprocOffset(headerOffset); } @@ -1386,7 +1439,7 @@ public class Sketch { // SketchCode errorCode = null; // if (filename.equals(appletJavaFile)) { // for (SketchCode code : getCode()) { -// if (code.isExtension("pde")) { +// if (code.isExtension("ino")) { // if (line >= code.getPreprocOffset()) { // errorCode = code; // } @@ -1507,6 +1560,7 @@ public class Sketch { throws RunnerException { // run the preprocessor + editor.status.progressUpdate(20); String primaryClassName = preprocess(buildPath); // compile the program. errors will happen as a RunnerException @@ -1520,15 +1574,15 @@ public class Sketch { } - protected boolean exportApplet(boolean verbose) throws Exception { - return exportApplet(tempBuildFolder.getAbsolutePath(), verbose); + protected boolean exportApplet(boolean usingProgrammer) throws Exception { + return exportApplet(tempBuildFolder.getAbsolutePath(), usingProgrammer); } /** * Handle export to applet. */ - public boolean exportApplet(String appletPath, boolean verbose) + public boolean exportApplet(String appletPath, boolean usingProgrammer) throws RunnerException, IOException, SerialException { // Make sure the user didn't hide the sketch folder @@ -1552,6 +1606,7 @@ public class Sketch { appletFolder.mkdirs(); // build the sketch + editor.status.progressNotice("Compiling sketch..."); String foundName = build(appletFolder.getPath(), false); // (already reported) error during export, exit this function if (foundName == null) return false; @@ -1565,12 +1620,18 @@ public class Sketch { // return false; // } - upload(appletFolder.getPath(), foundName, verbose); - + editor.status.progressNotice("Uploading..."); + upload(appletFolder.getPath(), foundName, usingProgrammer); + editor.status.progressUpdate(100); return true; } + + public void setCompilingProgress(int percent) { + editor.status.progressUpdate(percent); + } + protected void size(String buildPath, String suggestedClassName) throws RunnerException { long size = 0; @@ -1592,7 +1653,7 @@ public class Sketch { } - protected String upload(String buildPath, String suggestedClassName, boolean verbose) + protected String upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws RunnerException, SerialException { Uploader uploader; @@ -1602,7 +1663,7 @@ public class Sketch { uploader = new AvrdudeUploader(); boolean success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, - verbose); + usingProgrammer); return success ? suggestedClassName : null; } @@ -1754,7 +1815,7 @@ public class Sketch { * For Processing, this is true for .pde files. (Broken out for subclasses.) */ public boolean hideExtension(String what) { - return what.equals(getDefaultExtension()); + return getHiddenExtensions().contains(what); } @@ -1791,15 +1852,20 @@ public class Sketch { * Returns the default extension for this editor setup. */ public String getDefaultExtension() { - return "pde"; + return "ino"; } + static private List hiddenExtensions = Arrays.asList("ino", "pde"); + public List getHiddenExtensions() { + return hiddenExtensions; + } + /** * Returns a String[] array of proper extensions. */ public String[] getExtensions() { - return new String[] { "pde", "c", "cpp", "h" }; + return new String[] { "ino", "pde", "c", "cpp", "h" }; } diff --git a/app/src/processing/app/debug/AvrdudeUploader.java b/app/src/processing/app/debug/AvrdudeUploader.java index 4178a0bb3..d5db258ad 100755 --- a/app/src/processing/app/debug/AvrdudeUploader.java +++ b/app/src/processing/app/debug/AvrdudeUploader.java @@ -42,33 +42,28 @@ public class AvrdudeUploader extends Uploader { public AvrdudeUploader() { } - // XXX: add support for uploading sketches using a programmer - public boolean uploadUsingPreferences(String buildPath, String className, boolean verbose) + public boolean uploadUsingPreferences(String buildPath, String className, boolean usingProgrammer) throws RunnerException, SerialException { this.verbose = verbose; Map boardPreferences = Base.getBoardPreferences(); - String uploadUsing = boardPreferences.get("upload.using"); - if (uploadUsing == null) { - // fall back on global preference - uploadUsing = Preferences.get("upload.using"); - } - if (uploadUsing.equals("bootloader")) { - return uploadViaBootloader(buildPath, className); - } else { - Target t; - if (uploadUsing.indexOf(':') == -1) { - t = Base.getTarget(); // the current target (associated with the board) - } else { - String targetName = uploadUsing.substring(0, uploadUsing.indexOf(':')); - t = Base.targetsTable.get(targetName); - uploadUsing = uploadUsing.substring(uploadUsing.indexOf(':') + 1); + // if no protocol is specified for this board, assume it lacks a + // bootloader and upload using the selected programmer. + if (usingProgrammer || boardPreferences.get("upload.protocol") == null) { + String programmer = Preferences.get("programmer"); + Target target = Base.getTarget(); + + if (programmer.indexOf(":") != -1) { + target = Base.targetsTable.get(programmer.substring(0, programmer.indexOf(":"))); + programmer = programmer.substring(programmer.indexOf(":") + 1); } - - Collection params = getProgrammerCommands(t, uploadUsing); + + Collection params = getProgrammerCommands(target, programmer); params.add("-Uflash:w:" + buildPath + File.separator + className + ".hex:i"); return avrdude(params); } + + return uploadViaBootloader(buildPath, className); } private boolean uploadViaBootloader(String buildPath, String className) @@ -96,8 +91,14 @@ public class AvrdudeUploader extends Uploader { return avrdude(commandDownloader); } - public boolean burnBootloader(String targetName, String programmer) throws RunnerException { - return burnBootloader(getProgrammerCommands(Base.targetsTable.get(targetName), programmer)); + public boolean burnBootloader() throws RunnerException { + String programmer = Preferences.get("programmer"); + Target target = Base.getTarget(); + if (programmer.indexOf(":") != -1) { + target = Base.targetsTable.get(programmer.substring(0, programmer.indexOf(":"))); + programmer = programmer.substring(programmer.indexOf(":") + 1); + } + return burnBootloader(getProgrammerCommands(target, programmer)); } private Collection getProgrammerCommands(Target target, String programmer) { diff --git a/app/src/processing/app/debug/Uploader.java b/app/src/processing/app/debug/Uploader.java index 573502030..71739f129 100755 --- a/app/src/processing/app/debug/Uploader.java +++ b/app/src/processing/app/debug/Uploader.java @@ -64,10 +64,10 @@ public abstract class Uploader implements MessageConsumer { public Uploader() { } - public abstract boolean uploadUsingPreferences(String buildPath, String className, boolean verbose) + public abstract boolean uploadUsingPreferences(String buildPath, String className, boolean usingProgrammer) throws RunnerException, SerialException; - public abstract boolean burnBootloader(String target, String programmer) throws RunnerException; + public abstract boolean burnBootloader() throws RunnerException; protected void flushSerialBuffer() throws RunnerException, SerialException { // Cleanup the serial buffer diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java index 63e76145a..5afe4db13 100644 --- a/app/src/processing/app/windows/Platform.java +++ b/app/src/processing/app/windows/Platform.java @@ -44,8 +44,8 @@ public class Platform extends processing.app.Platform { static final String openCommand = System.getProperty("user.dir").replace('/', '\\') + - "\\processing.exe \"%1\""; - static final String DOC = "Processing.Document"; + "\\arduino.exe \"%1\""; + static final String DOC = "Arduino.Document"; public void init(Base base) { super.init(base); @@ -86,13 +86,13 @@ public class Platform extends processing.app.Platform { */ protected void setAssociations() throws UnsupportedEncodingException { if (Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT, - "", ".pde") && + "", ".ino") && Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT, - ".pde", "", DOC) && + ".ino", "", DOC) && Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT, "", DOC) && Registry.setStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT, DOC, "", - "Processing Source Code") && + "Arduino Source Code") && Registry.createKey(REGISTRY_ROOT_KEY.CLASSES_ROOT, DOC, "shell") && diff --git a/build/macosx/template.app/Contents/Info.plist b/build/macosx/template.app/Contents/Info.plist index e19bedb98..6fe5351f4 100755 --- a/build/macosx/template.app/Contents/Info.plist +++ b/build/macosx/template.app/Contents/Info.plist @@ -35,13 +35,15 @@ CFBundleTypeExtensions - pde - java + ino + c + cpp + h CFBundleTypeIconFile pde.icns CFBundleTypeName - Processing Source File + Arduino Source File CFBundleTypeMIMETypes text/plain diff --git a/build/macosx/template.app/Contents/Resources/pde.icns b/build/macosx/template.app/Contents/Resources/pde.icns index 214b19877..d3862982c 100644 Binary files a/build/macosx/template.app/Contents/Resources/pde.icns and b/build/macosx/template.app/Contents/Resources/pde.icns differ diff --git a/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde b/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde deleted file mode 100644 index e3565152a..000000000 --- a/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde +++ /dev/null @@ -1,1197 +0,0 @@ -/* - Serial Call and Response - Language: Wiring/Arduino - - This program sends an ASCII A (byte of value 65) on startup - and repeats that until it gets some data in. - Then it waits for a byte in the serial port, and - sends three sensor values whenever it gets a byte in. - - Thanks to Greg Shakar and Scott Fitzgerald for the improvements - - The circuit: - * potentiometers attached to analog inputs 0 and 1 - * pushbutton attached to digital I/O 2 - - Created 26 Sept. 2005 - by Tom Igoe - Modified 4 Sep 2010 - by Tom Igoe and Scott Fitzgerald - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/SerialCallResponse - - */ - -int firstSensor = 0; // first analog sensor -int secondSensor = 0; // second analog sensor -int thirdSensor = 0; // digital sensor -int inByte = 0; // incoming serial byte - -void setup() -{ - // start serial port at 9600 bps: - Serial.begin(9600); - pinMode(2, INPUT); // digital sensor is on digital pin 2 - establishContact(); // send a byte to establish contact until receiver responds -} - -void loop() -{ - // if we get a valid byte, read analog ins: - if (Serial.available() > 0) { - // get incoming byte: - inByte = Serial.read(); - // read first analog input, divide by 4 to make the range 0-255: - firstSensor = analogRead(A0)/4; - // delay 10ms to let the ADC recover: - delay(10); - // read second analog input, divide by 4 to make the range 0-255: - secondSensor = analogRead(1)/4; - // read switch, map it to 0 or 255L - thirdSensor = map(digitalRead(2), 0, 1, 0, 255); - // send sensor values: - Serial.write(firstSensor); - Serial.write(secondSensor); - Serial.write(thirdSensor); - } -} - -void establishContact() { - while (Serial.available() <= 0) { - Serial.print('A'); // send a capital A - delay(300); - } -} - -/* -Processing sketch to run with this example: - -// This example code is in the public domain. - -import processing.serial.*; - -int bgcolor; // Background color -int fgcolor; // Fill color -Serial myPort; // The serial port -int[] serialInArray = new int[3]; // Where we'll put what we receive -int serialCount = 0; // A count of how many bytes we receive -int xpos, ypos; // Starting position of the ball -boolean firstContact = false; // Whether we've heard from the microcontroller - -void setup() { - size(256, 256); // Stage size - noStroke(); // No border on the next thing drawn - - // Set the starting position of the ball (middle of the stage) - xpos = width/2; - ypos = height/2; - - // Print a list of the serial ports, for debugging purposes: - println(Serial.list()); - - // I know that the first port in the serial list on my mac - // is always my FTDI adaptor, so I open Serial.list()[0]. - // On Windows machines, this generally opens COM1. - // Open whatever port is the one you're using. - String portName = Serial.list()[0]; - myPort = new Serial(this, portName, 9600); -} - -void draw() { - background(bgcolor); - fill(fgcolor); - // Draw the shape - ellipse(xpos, ypos, 20, 20); -} - -void serialEvent(Serial myPort) { - // read a byte from the serial port: - int inByte = myPort.read(); - // if this is the first byte received, and it's an A, - // clear the serial buffer and note that you've - // had first contact from the microcontroller. - // Otherwise, add the incoming byte to the array: - if (firstContact == false) { - if (inByte == 'A') { - myPort.clear(); // clear the serial port buffer - firstContact = true; // you've had first contact from the microcontroller - myPort.write('A'); // ask for more - } - } - else { - // Add the latest byte from the serial port to array: - serialInArray[serialCount] = inByte; - serialCount++; - - // If we have 3 bytes: - if (serialCount > 2 ) { - xpos = serialInArray[0]; - ypos = serialInArray[1]; - fgcolor = serialInArray[2]; - - // print the values (for debugging purposes only): - println(xpos + "\t" + ypos + "\t" + fgcolor); - - // Send a capital A to request new sensor readings: - myPort.write('A'); - // Reset serialCount: - serialCount = 0; - } - } -} -*/ - -/* -Max/MSP version 5 patch to run with this example: - -{ - "boxes" : [ { - "box" : { - "maxclass" : "message", - "text" : "65", - "patching_rect" : [ 339.0, 466.0, 32.5, 18.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-9", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "sel 1", - "patching_rect" : [ 339.0, 437.0, 36.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "bang", "" ], - "id" : "obj-6", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "Serial Call-Response \n\nSends a byte out the serial port, and reads 3 bytes in. Sets foregound color, xpos, and ypos of a circle using the values returned from the serial port. \n\nNote: This patch assumes that the device on the other end of the serial port is going to send a single byte of value 65 (ASCII A) on startup. The sketch waits for that byte, then sends an ASCII A whenever it wants more data. \n\ncreated 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe", - "linecount" : 11, - "patching_rect" : [ 404.0, 52.0, 464.0, 158.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-5", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "trigger (or [t]) forces right-left conventions. All the drawing and processing will happen before Max requests new values. When this trigger fires, it sends an ASCII A to ask Arduino for new values.", - "linecount" : 3, - "patching_rect" : [ 239.0, 505.0, 425.0, 48.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-65", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "reinitializes the gates when turned on and off", - "linecount" : 2, - "patching_rect" : [ 170.0, 370.0, 135.0, 34.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-64", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "checks for the ascii value of \"A\" to begin cominucation. After initial communication is made, this block shuts down.", - "linecount" : 3, - "patching_rect" : [ 460.0, 355.0, 233.0, 48.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-63", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "p \"draw the circle\"", - "patching_rect" : [ 217.0, 645.0, 269.0, 19.0 ], - "numoutlets" : 1, - "fontsize" : 10.0, - "outlettype" : [ "" ], - "id" : "obj-62", - "fontname" : "Verdana", - "numinlets" : 3, - "patcher" : { - "fileversion" : 1, - "rect" : [ 54.0, 94.0, 640.0, 480.0 ], - "bglocked" : 0, - "defrect" : [ 54.0, 94.0, 640.0, 480.0 ], - "openrect" : [ 0.0, 0.0, 0.0, 0.0 ], - "openinpresentation" : 0, - "default_fontsize" : 10.0, - "default_fontface" : 0, - "default_fontname" : "Verdana", - "gridonopen" : 0, - "gridsize" : [ 25.0, 25.0 ], - "gridsnaponopen" : 0, - "toolbarvisible" : 1, - "boxanimatetime" : 200, - "imprint" : 0, - "boxes" : [ { - "box" : { - "maxclass" : "message", - "text" : "frgb 255 255 255", - "patching_rect" : [ 375.0, 150.0, 98.0, 18.0 ], - "numoutlets" : 1, - "fontsize" : 11.595187, - "outlettype" : [ "" ], - "id" : "obj-47", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "message", - "text" : "frgb 0 0 0", - "patching_rect" : [ 275.0, 125.0, 59.0, 18.0 ], - "numoutlets" : 1, - "fontsize" : 11.595187, - "outlettype" : [ "" ], - "id" : "obj-46", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "sel 255 0", - "patching_rect" : [ 300.0, 100.0, 66.0, 21.0 ], - "numoutlets" : 3, - "fontsize" : 12.0, - "outlettype" : [ "bang", "bang", "" ], - "id" : "obj-45", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "pack 0 0 0 0", - "patching_rect" : [ 50.0, 125.0, 180.0, 21.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-43", - "fontname" : "Verdana", - "numinlets" : 4 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "+ 10", - "patching_rect" : [ 200.0, 100.0, 40.0, 21.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-42", - "fontname" : "Verdana", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "+ 10", - "patching_rect" : [ 75.0, 100.0, 40.0, 21.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-41", - "fontname" : "Verdana", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "message", - "text" : "clear, paintoval $1 $2 $3 $4", - "patching_rect" : [ 50.0, 150.0, 152.0, 18.0 ], - "numoutlets" : 1, - "fontsize" : 11.595187, - "outlettype" : [ "" ], - "id" : "obj-40", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "inlet", - "patching_rect" : [ 57.5, 40.0, 25.0, 25.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-58", - "numinlets" : 0, - "comment" : "" - } - - } -, { - "box" : { - "maxclass" : "inlet", - "patching_rect" : [ 120.0, 40.0, 25.0, 25.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-59", - "numinlets" : 0, - "comment" : "" - } - - } -, { - "box" : { - "maxclass" : "inlet", - "patching_rect" : [ 300.0, 40.0, 25.0, 25.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-60", - "numinlets" : 0, - "comment" : "" - } - - } -, { - "box" : { - "maxclass" : "outlet", - "patching_rect" : [ 228.333344, 228.0, 25.0, 25.0 ], - "numoutlets" : 0, - "id" : "obj-61", - "numinlets" : 1, - "comment" : "" - } - - } - ], - "lines" : [ { - "patchline" : { - "source" : [ "obj-47", 0 ], - "destination" : [ "obj-61", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-46", 0 ], - "destination" : [ "obj-61", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-40", 0 ], - "destination" : [ "obj-61", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-60", 0 ], - "destination" : [ "obj-45", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-59", 0 ], - "destination" : [ "obj-42", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-59", 0 ], - "destination" : [ "obj-43", 1 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-58", 0 ], - "destination" : [ "obj-41", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-58", 0 ], - "destination" : [ "obj-43", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-42", 0 ], - "destination" : [ "obj-43", 3 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-41", 0 ], - "destination" : [ "obj-43", 2 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-45", 1 ], - "destination" : [ "obj-47", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-45", 0 ], - "destination" : [ "obj-46", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-43", 0 ], - "destination" : [ "obj-40", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - ] - } -, - "saved_object_attributes" : { - "fontface" : 0, - "fontsize" : 10.0, - "default_fontface" : 0, - "default_fontname" : "Verdana", - "default_fontsize" : 10.0, - "fontname" : "Verdana", - "globalpatchername" : "" - } - - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "0", - "patching_rect" : [ 310.0, 378.0, 32.5, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-57", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "!- 1", - "patching_rect" : [ 385.0, 436.0, 32.5, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-55", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "gate 1 1", - "patching_rect" : [ 385.0, 355.0, 54.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-54", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 385.0, 405.0, 20.0, 20.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-53", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "gate 1 0", - "patching_rect" : [ 194.0, 455.0, 54.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-50", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "sel 65", - "patching_rect" : [ 385.0, 380.0, 43.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "bang", "" ], - "id" : "obj-48", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "lcd", - "patching_rect" : [ 217.0, 695.0, 256.0, 256.0 ], - "numoutlets" : 4, - "outlettype" : [ "list", "list", "int", "" ], - "id" : "obj-39", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "t 65 l", - "patching_rect" : [ 194.0, 504.0, 42.0, 21.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "int", "" ], - "id" : "obj-35", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "val3", - "patching_rect" : [ 535.0, 604.0, 37.0, 21.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-1", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 467.0, 604.0, 56.0, 21.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "int", "bang" ], - "id" : "obj-3", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "val2", - "patching_rect" : [ 410.0, 605.0, 37.0, 21.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-18", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "val1", - "patching_rect" : [ 282.0, 605.0, 37.0, 21.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-20", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 342.0, 605.0, 56.0, 21.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "int", "bang" ], - "id" : "obj-22", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 217.0, 605.0, 55.0, 21.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "int", "bang" ], - "id" : "obj-23", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "unpack 0 0 0", - "patching_rect" : [ 217.0, 570.0, 269.0, 21.0 ], - "numoutlets" : 3, - "fontsize" : 12.0, - "outlettype" : [ "int", "int", "int" ], - "id" : "obj-29", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "zl group 3", - "patching_rect" : [ 194.0, 480.0, 71.0, 21.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "", "" ], - "id" : "obj-31", - "fontname" : "Verdana", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "select 0 1", - "patching_rect" : [ 312.0, 200.0, 62.0, 20.0 ], - "numoutlets" : 3, - "fontsize" : 12.0, - "outlettype" : [ "bang", "bang", "" ], - "id" : "obj-30", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "click here to close the serial port", - "patching_rect" : [ 360.0, 291.0, 206.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-26", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "click here to open the serial port", - "patching_rect" : [ 385.0, 265.0, 206.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-27", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "message", - "text" : "close", - "patching_rect" : [ 312.0, 291.0, 39.0, 18.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-21", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "message", - "text" : "port a", - "patching_rect" : [ 334.0, 265.0, 41.0, 18.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-19", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "Click here to get a list of serial ports", - "patching_rect" : [ 405.0, 239.0, 207.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-2", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 229.0, 155.0, 22.0, 22.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-11", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "qmetro 10", - "patching_rect" : [ 229.0, 200.0, 65.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "bang" ], - "id" : "obj-12", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "message", - "text" : "print", - "patching_rect" : [ 354.0, 239.0, 36.0, 18.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-13", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "serial a 9600", - "patching_rect" : [ 229.0, 315.0, 84.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "int", "" ], - "id" : "obj-14", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "Read serial input buffer every 10 milliseconds", - "linecount" : 2, - "patching_rect" : [ 13.0, 192.0, 210.0, 34.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-15", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "Click to start", - "patching_rect" : [ 256.0, 163.0, 117.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-17", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - ], - "lines" : [ { - "patchline" : { - "source" : [ "obj-12", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-11", 0 ], - "destination" : [ "obj-12", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-13", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 363.5, 260.5, 238.5, 260.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-19", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 343.5, 288.5, 238.5, 288.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-21", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 321.5, 311.5, 238.5, 311.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-30", 0 ], - "destination" : [ "obj-21", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-30", 1 ], - "destination" : [ "obj-19", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-11", 0 ], - "destination" : [ "obj-30", 0 ], - "hidden" : 0, - "midpoints" : [ 238.5, 191.0, 321.5, 191.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-29", 2 ], - "destination" : [ "obj-3", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-29", 0 ], - "destination" : [ "obj-23", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-29", 1 ], - "destination" : [ "obj-22", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-14", 0 ], - "destination" : [ "obj-50", 1 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-50", 0 ], - "destination" : [ "obj-31", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-48", 0 ], - "destination" : [ "obj-53", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-53", 0 ], - "destination" : [ "obj-50", 0 ], - "hidden" : 0, - "midpoints" : [ 394.5, 426.0, 203.5, 426.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-14", 0 ], - "destination" : [ "obj-54", 1 ], - "hidden" : 0, - "midpoints" : [ 238.5, 342.0, 429.5, 342.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-54", 0 ], - "destination" : [ "obj-48", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-62", 0 ], - "destination" : [ "obj-39", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-3", 0 ], - "destination" : [ "obj-62", 2 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-22", 0 ], - "destination" : [ "obj-62", 1 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-23", 0 ], - "destination" : [ "obj-62", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-53", 0 ], - "destination" : [ "obj-55", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-55", 0 ], - "destination" : [ "obj-54", 0 ], - "hidden" : 0, - "midpoints" : [ 394.5, 459.0, 453.0, 459.0, 453.0, 351.0, 394.5, 351.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-30", 0 ], - "destination" : [ "obj-57", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-57", 0 ], - "destination" : [ "obj-53", 0 ], - "hidden" : 0, - "midpoints" : [ 319.5, 401.0, 394.5, 401.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-35", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 203.5, 542.0, 167.0, 542.0, 167.0, 300.0, 238.5, 300.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-35", 1 ], - "destination" : [ "obj-29", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-31", 0 ], - "destination" : [ "obj-35", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-6", 0 ], - "destination" : [ "obj-9", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-53", 0 ], - "destination" : [ "obj-6", 0 ], - "hidden" : 0, - "midpoints" : [ 394.5, 431.5, 348.5, 431.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-9", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - ] -} - - -*/ diff --git a/build/shared/lib/about.jpg b/build/shared/lib/about.jpg old mode 100755 new mode 100644 index 90afdb08b..0b168bba1 Binary files a/build/shared/lib/about.jpg and b/build/shared/lib/about.jpg differ diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index 63f63acde..bca71bfd9 100755 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -240,6 +240,8 @@ run.present.exclusive.macosx = true board = uno target = arduino +programmer = arduino:avrispmkii + upload.using = bootloader serial.port=COM1 diff --git a/build/shared/lib/theme/buttons.gif b/build/shared/lib/theme/buttons.gif index 7cc33ceaf..4de0905d2 100644 Binary files a/build/shared/lib/theme/buttons.gif and b/build/shared/lib/theme/buttons.gif differ diff --git a/build/shared/lib/theme/resize.gif b/build/shared/lib/theme/resize.gif index 59d21d909..ed31c0ad8 100644 Binary files a/build/shared/lib/theme/resize.gif and b/build/shared/lib/theme/resize.gif differ diff --git a/build/shared/lib/theme/tab-sel-left.gif b/build/shared/lib/theme/tab-sel-left.gif index 1fbefecde..252ebcc6d 100644 Binary files a/build/shared/lib/theme/tab-sel-left.gif and b/build/shared/lib/theme/tab-sel-left.gif differ diff --git a/build/shared/lib/theme/tab-sel-menu.gif b/build/shared/lib/theme/tab-sel-menu.gif index eabde568a..3b213f4a7 100644 Binary files a/build/shared/lib/theme/tab-sel-menu.gif and b/build/shared/lib/theme/tab-sel-menu.gif differ diff --git a/build/shared/lib/theme/tab-sel-mid.gif b/build/shared/lib/theme/tab-sel-mid.gif index e6df08890..4bd19a0c3 100644 Binary files a/build/shared/lib/theme/tab-sel-mid.gif and b/build/shared/lib/theme/tab-sel-mid.gif differ diff --git a/build/shared/lib/theme/tab-sel-right.gif b/build/shared/lib/theme/tab-sel-right.gif index be24960a7..4ceb3ed80 100644 Binary files a/build/shared/lib/theme/tab-sel-right.gif and b/build/shared/lib/theme/tab-sel-right.gif differ diff --git a/build/shared/lib/theme/tab-unsel-left.gif b/build/shared/lib/theme/tab-unsel-left.gif index 6ed8391d2..cdc98861f 100644 Binary files a/build/shared/lib/theme/tab-unsel-left.gif and b/build/shared/lib/theme/tab-unsel-left.gif differ diff --git a/build/shared/lib/theme/tab-unsel-menu.gif b/build/shared/lib/theme/tab-unsel-menu.gif index 1587067ae..3c9177118 100644 Binary files a/build/shared/lib/theme/tab-unsel-menu.gif and b/build/shared/lib/theme/tab-unsel-menu.gif differ diff --git a/build/shared/lib/theme/tab-unsel-mid.gif b/build/shared/lib/theme/tab-unsel-mid.gif index f1adaa675..c538ad2fe 100644 Binary files a/build/shared/lib/theme/tab-unsel-mid.gif and b/build/shared/lib/theme/tab-unsel-mid.gif differ diff --git a/build/shared/lib/theme/tab-unsel-right.gif b/build/shared/lib/theme/tab-unsel-right.gif index 1086fb309..3150eb5ea 100644 Binary files a/build/shared/lib/theme/tab-unsel-right.gif and b/build/shared/lib/theme/tab-unsel-right.gif differ diff --git a/build/shared/lib/theme/theme.txt b/build/shared/lib/theme/theme.txt index d3404179c..98a8ef7a5 100644 --- a/build/shared/lib/theme/theme.txt +++ b/build/shared/lib/theme/theme.txt @@ -1,35 +1,35 @@ # GUI - STATUS -status.notice.fgcolor = #000000 -status.notice.bgcolor = #54919e -status.error.fgcolor = #ffffff -status.error.bgcolor = #662000 +status.notice.fgcolor = #002325 +status.notice.bgcolor = #17A1A5 +status.error.fgcolor = #FFFFFF +status.error.bgcolor = #E34C00 status.edit.fgcolor = #000000 -status.edit.bgcolor = #cc9900 +status.edit.bgcolor = #F1B500 status.font = SansSerif,plain,12 # GUI - TABS # settings for the tabs at the top # (tab images are stored in the lib/theme folder) -header.bgcolor = #216886 -header.text.selected.color = #1a1a00 -header.text.unselected.color = #ffffff +header.bgcolor = #17A1A5 +header.text.selected.color = #005B5B +header.text.unselected.color = #007e82 header.text.font = SansSerif,plain,12 # GUI - CONSOLE console.font = Monospaced,plain,11 console.font.macosx = Monaco,plain,10 console.color = #000000 -console.output.color = #cccccc -console.error.color = #ff3000 +console.output.color = #eeeeee +console.error.color = #E34C00 # GUI - BUTTONS -buttons.bgcolor = #044f6f +buttons.bgcolor = #006468 buttons.status.font = SansSerif,plain,12 buttons.status.color = #ffffff -# GUI - LINESTATUS +# GUI - LINESTATUS linestatus.color = #ffffff -linestatus.bgcolor = #044f6f +linestatus.bgcolor = #006468 # EDITOR - DETAILS @@ -83,6 +83,9 @@ editor.literal1.style = #006699,plain # p5 built in variables: e.g. mouseX, width, pixels editor.literal2.style = #006699,plain +# http://arduino.cc/ +editor.url.style = #0000ff,underlined + # e.g. + - = / editor.operator.style = #000000,plain diff --git a/build/windows/launcher/about.bmp b/build/windows/launcher/about.bmp index c8eceac06..19b6904b8 100755 Binary files a/build/windows/launcher/about.bmp and b/build/windows/launcher/about.bmp differ diff --git a/hardware/arduino/boards.txt b/hardware/arduino/boards.txt index aa5c70dc9..bb3679685 100644 --- a/hardware/arduino/boards.txt +++ b/hardware/arduino/boards.txt @@ -10,7 +10,7 @@ uno.bootloader.extended_fuses=0x05 uno.bootloader.path=optiboot uno.bootloader.file=optiboot_atmega328.hex uno.bootloader.unlock_bits=0x3F -uno.bootloader.lock_bits=0x2F +uno.bootloader.lock_bits=0x0F uno.build.mcu=atmega328p uno.build.f_cpu=16000000L uno.build.core=arduino diff --git a/hardware/arduino/bootloaders/stk500v2/stk500boot.c b/hardware/arduino/bootloaders/stk500v2/stk500boot.c index 3d5b09582..13dec8951 100755 --- a/hardware/arduino/bootloaders/stk500v2/stk500boot.c +++ b/hardware/arduino/bootloaders/stk500v2/stk500boot.c @@ -95,8 +95,7 @@ LICENSE: #include "command.h" -//#if defined(_MEGA_BOARD_) || defined(_BOARD_AMBER128_) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) -#if 0 +#if defined(_MEGA_BOARD_) || defined(_BOARD_AMBER128_) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) #define ENABLE_MONITOR static void RunMonitor(void); #endif diff --git a/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex b/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex index ace9cb1f7..4f366997c 100644 --- a/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex +++ b/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex @@ -1,141 +1,513 @@ :020000023000CC -:10E000000D9472F00D9493F00D9493F00D9493F0A1 -:10E010000D9493F00D9493F00D9493F00D9493F070 -:10E020000D9493F00D9493F00D9493F00D9493F060 -:10E030000D9493F00D9493F00D9493F00D9493F050 -:10E040000D9493F00D9493F00D9493F00D9493F040 -:10E050000D9493F00D9493F00D9493F00D9493F030 -:10E060000D9493F00D9493F00D9493F00D9493F020 -:10E070000D9493F00D9493F00D9493F00D9493F010 -:10E080000D9493F00D9493F00D9493F00D9493F000 -:10E090000D9493F00D9493F00D9493F00D9493F0F0 -:10E0A0000D9493F00D9493F00D9493F00D9493F0E0 -:10E0B0000D9493F00D9493F00D9493F00D9493F0D0 -:10E0C0000D9493F00D9493F00D9493F00D9493F0C0 -:10E0D0000D9493F00D9493F00D9493F00D9493F0B0 -:10E0E0000D9493F011241FBECFEFD1E2DEBFCDBF60 -:10E0F00001E00CBF12E0A0E0B2E0E0EAF8EE03E0DD -:10E100000BBF02C007900D92A030B107D9F70F9452 -:10E11000A3F00D944EF401E20EBF0FEF0DBF1124DA -:10E120001FBE0D94A3F00D9400F020E030E040ED10 -:10E1300057E005C0FA013197F1F72F5F3F4F2817DD -:10E140003907C0F308952F923F924F925F926F92DA -:10E150007F928F929F92AF92BF92CF92DF92EF9277 -:10E16000FF920F931F93DF93CF93CDB7DEB7C852C3 -:10E17000D1400FB6F894DEBF0FBECDBF279A2F9ABD -:10E180008091C00082608093C00080E18093C400D1 -:10E1900088E18093C1000000EE24FF248701E4E0C1 -:10E1A000AE2EB12CCC24DD2424C0C5010197F1F79B -:10E1B0000894E11CF11C011D111D21E2E2162EE460 -:10E1C000F20620E0020720E0120718F071E0C72EE7 -:10E1D000D12CC801B70128E53BE140E050E00F94A5 -:10E1E0002CF4611571058105910519F485B18058EC -:10E1F00085B98091C00087FD03C0C114D104A9F284 -:10E20000A6014F5F5F4FC25EDE4F59834883CE51F8 -:10E21000D140C25EDE4F68817981CE51D1406130FC -:10E22000710509F0FCC222243324A0E0C05EDE4F59 -:10E230001882C052D1408824992454014424552482 -:10E240003201ABBEF40187919691C95DDE4F99838F -:10E250008883C752D140DFC2C25EDE4FE881F981B8 -:10E26000CE51D140319709F53091C600C25EDE4FE4 -:10E2700019821882CE51D14022C04F5F5F4F6F4F3D -:10E280007F4F4130F2E15F07FAE76F07F0E07F0769 -:10E2900080F0C95DDE4F28813981C752D1402F5FA0 -:10E2A0003F4F19F0EE27FF27099440E050E060E06F -:10E2B00070E08091C00087FFE0CF3091C6009330BE -:10E2C00061F1943028F4913089F0923008F508C05B -:10E2D000953091F1953040F1963009F043C03EC041 -:10E2E0003B3109F0B9CF91E0ABE1B6CF313041F02D -:10E2F000C05EDE4F5881C052D140351709F0AAC226 -:10E30000A327C05EDE4F3883C052D14092E0A4CF35 -:10E31000132F00E0A32793E09FCF832F90E0082BDB -:10E32000192BA32794E098CF3E3009F093C2A3277E -:10E3300095E02224332490CFE1E0F0E0EC0FFD1FC4 -:10E34000E20DF31D30830894211C311CA3272016F5 -:10E35000310609F081CF810196E07ECF3A1709F0AE -:10E3600079C203C0973009F077CF8981833109F4EE -:10E37000F4C08431C0F4863009F4C2C0873048F458 -:10E38000823069F1833009F45BC0813009F0C4C187 -:10E3900041C0813109F465C0823108F0ACC08031E0 -:10E3A00009F0BAC11CC0883109F474C0893150F435 -:10E3B000853109F4D2C0853108F443C1863109F0B2 -:10E3C000ABC13FC18A3109F45CC08A3108F482C014 -:10E3D0008B3109F44BC08D3109F09EC102C090E031 -:10E3E00041C08D81803311F090E00AC08F81882375 -:10E3F00011F49EE105C0813011F091E001C098E96F -:10E400001A821B828D818C831D829E831F8247E02E -:10E4100050E086C11A8288E08B8381E48C8386E594 -:10E420008D8382E58E8389E48F8383E5888780E509 -:10E4300089878FE58A8782E38B874BE050E070C144 -:10E440008A81813941F0823941F0803911F48FE0BD -:10E4500005C080E003C082E001C08AE01A828B839D -:10E4600047C091E01A8242E050E05BC18D81882371 -:10E4700011F48EE129C0813011F081E025C088E9D6 -:10E4800023C01A82E1E0F0E069E060935700E49174 -:10E49000EB831CC08B81803589F48C81883039F402 -:10E4A00029E0E2E0F0E02093570084910DC029E0DC -:10E4B000E0E0F0E020935700849106C0E3E0F0E054 -:10E4C00039E03093570084911A828B831C8244E098 -:10E4D00050E026C18D81836C49E0E1E0F0E0082E38 -:10E4E00040935700E89507B600FCFDCF1A821B82C7 -:10E4F00043E050E015C11A824424552432010EC174 -:10E500008A8190E0A0E0B0E0B82EAA249924882463 -:10E510008B8190E0A0E0B0E0DC0199278827882A71 -:10E52000992AAA2ABB2A8D8190E0A0E0B0E0882A2F -:10E53000992AAA2ABB2A8C8190E0A0E0B0E0BA2FE9 -:10E54000A92F982F8827882A992AAA2ABB2A880CBB -:10E55000991CAA1CBB1C1A82E1C09A813B818331A1 -:10E5600019F0B501A40169C050E0451650EC5506FC -:10E5700053E0650650E0750690F463E0F2016092A6 -:10E580005B0060935700E89507B600FCFDCF40E0C4 -:10E5900051E060E070E0440E551E661E771ECE5DB1 -:10E5A000DE4F9883C252D140CF5DDE4F1882C152F8 -:10E5B000D140032F10E0CF5DDE4F68817981C152D9 -:10E5C000D140062B172BB501A401DE011B968C91BF -:10E5D00011962C9111971296CC5DDE4F2883C45270 -:10E5E000D140CD5DDE4F1882C352D14090E0CD5D69 -:10E5F000DE4FE881F981C352D1408E2B9F2B21E061 -:10E600000C01FA0160935B0020935700E8951124F8 -:10E610004E5F5F4F6F4F7F4F02501040C1F635E0A5 -:10E62000F401A0925B0030935700E89507B600FC18 -:10E63000FDCF81E180935700E8951A824A015B0182 -:10E640006DC09A81CA5DDE4F9883C652D140CB5DC2 -:10E65000DE4F1882C552D1408B81C82EDD24CB5DA0 -:10E66000DE4FA881B981C552D140CA2ADB2A1A825D -:10E6700089818431E9F4A60123E0E22EF12CEC0E2D -:10E68000FD1EABBEF40187919691F70180839183C3 -:10E6900022E030E0E20EF31E62E070E080E090E005 -:10E6A000860E971EA81EB91E4250504051F72EC02C -:10E6B000B501A40193E0E92EF12CEC0EFD1E0894A7 -:10E6C000C108D108860120E030E00894C11CD11CAB -:10E6D0000F5F1F4F2F4F3F4F080D191D2A1D3B1D68 -:10E6E00041BDBB27A72F962F852F82BD4F5F5F4F60 -:10E6F0006F4F7F4FF89A80B5D7018D937D014017FA -:10E7000051076207730761F74A015B01A6014D5F7C -:10E710005F4FF701108204C0F0ECFA8342E050E052 -:10E7200090E02BE12093C6008091C00086FFFCCFD3 -:10E730008091C00080648093C000C05EDE4F38814D -:10E74000C052D1403093C6008091C00086FFFCCFFC -:10E750008091C00080648093C000652F5093C600F4 -:10E760008091C00086FFFCCF8091C00080648093C0 -:10E77000C000342F4093C6008091C00086FFFCCFBC -:10E780008091C00080648093C0008EE08093C600BA -:10E790008091C00086FFFCCF8091C0008064809390 -:10E7A000C000A5E1C05EDE4F7881C052D140A727EE -:10E7B000A327A627FE01319610C030813093C600F2 -:10E7C0008091C00086FFFCCF31968091C0008064AC -:10E7D0008093C000A327415050404115510569F76F -:10E7E000A093C6008091C00086FFFCCF8091C0003E -:10E7F00080648093C00085B1805885B9992379F4ED -:10E80000C05EDE4F8881C052D1408F5FC05EDE4F58 -:10E810008883C052D14090E000E010E01DCD2798E1 -:10E820002F9880E090E020ED37E0F9013197F1F783 -:10E83000019684369105C9F700008091C0008D7F54 -:10E840008093C00081E180935700E895EE27FF2771 -:10E850000994FFCF90E000CDA1E21A2EAA1BBB1BAA -:10E86000FD010DC0AA1FBB1FEE1FFF1FA217B3079C -:10E87000E407F50720F0A21BB30BE40BF50B661FB2 -:10E88000771F881F991F1A9469F760957095809576 -:10E8900090959B01AC01BD01CF010895F894FFCF85 +:10E000000D94F6F20D941FF30D941FF30D941FF36E +:10E010000D941FF30D941FF30D941FF30D941FF334 +:10E020000D941FF30D941FF30D941FF30D941FF324 +:10E030000D941FF30D941FF30D941FF30D941FF314 +:10E040000D941FF30D941FF30D941FF30D941FF304 +:10E050000D941FF30D941FF30D941FF30D941FF3F4 +:10E060000D941FF30D941FF30D941FF30D941FF3E4 +:10E070000D941FF30D941FF30D941FF30D941FF3D4 +:10E080000D941FF30D941FF30D941FF30D941FF3C4 +:10E090000D941FF30D941FF30D941FF30D941FF3B4 +:10E0A0000D941FF30D941FF30D941FF30D941FF3A4 +:10E0B0000D941FF30D941FF30D941FF30D941FF394 +:10E0C0000D941FF30D941FF30D941FF30D941FF384 +:10E0D0000D941FF30D941FF30D941FF30D941FF374 +:10E0E0000D941FF341546D65676132353630004140 +:10E0F000726475696E6F206578706C6F72657220DE +:10E1000073746B3530305632206279204D4C530099 +:10E11000426F6F746C6F616465723E004875683F52 +:10E1200000436F6D70696C6564206F6E20203D2028 +:10E1300000435055205479706520202020203D2038 +:10E14000005F5F4156525F415243485F5F203D2070 +:10E1500000415652204C69624320566572203D2092 +:10E16000004743432056657273696F6E20203D203F +:10E1700000435055207369676E61747572653D2068 +:10E18000004C6F77206675736520202020203D208D +:10E1900000486967682066757365202020203D204F +:10E1A00000457874206675736520202020203D206E +:10E1B000004C6F636B2066757365202020203D2026 +:10E1C00000536570202039203230313000312E3636 +:10E1D0002E3700342E332E33005623202020414486 +:10E1E00044522020206F7020636F6465202020201F +:10E1F00020696E737472756374696F6E20616464F4 +:10E2000072202020496E74657272757074006E6F92 +:10E2100020766563746F7200726A6D702020006AE8 +:10E220006D7020005768617420706F72743A0050EE +:10E230006F7274206E6F7420737570706F72746576 +:10E2400064004D7573742062652061206C65747480 +:10E2500065720020005772697474696E67204545C5 +:10E260000052656164696E6720454500656570729E +:10E270006F6D206572726F7220636F756E743D00F2 +:10E28000504F525400303D5A65726F206164647281 +:10E290006573732063747273003F3D435055207360 +:10E2A0007461747300403D454550524F4D20746574 +:10E2B000737400423D426C696E6B204C45440045CE +:10E2C0003D44756D7020454550524F4D00463D44CC +:10E2D000756D7020464C41534800483D48656C7050 +:10E2E000004C3D4C69737420492F4F20506F72745D +:10E2F0007300513D517569742026206A756D702038 +:10E30000746F20757365722070676D00523D44759F +:10E310006D702052414D00563D73686F7720696ED5 +:10E320007465727275707420566563746F727300D1 +:10E33000593D506F727420626C696E6B002A0052F6 +:10E340004553455400494E543000494E543100491C +:10E350004E543200494E543300494E543400494E15 +:10E36000543500494E543600494E54370050434905 +:10E370004E5430005043494E5431005043494E549E +:10E3800032005744540054494D45523020434F4DBC +:10E3900050410054494D45523020434F4D504200AA +:10E3A00054494D455230204F56460054494D455230 +:10E3B0003120434150540054494D45523120434F80 +:10E3C0004D50410054494D45523120434F4D50422C +:10E3D0000054494D45523120434F4D50430054495C +:10E3E0004D455231204F56460054494D455232203A +:10E3F000434F4D50410054494D45523220434F4DFB +:10E4000050420054494D455232204F56460054491F +:10E410004D45523320434150540054494D455233E9 +:10E4200020434F4D50410054494D45523320434FF6 +:10E430004D50420054494D45523320434F4D5043B7 +:10E440000054494D455233204F56460054494D45DE +:10E45000523420434150540054494D4552342043D6 +:10E460004F4D50410054494D45523420434F4D507B +:10E47000420054494D45523420434F4D50430054BF +:10E48000494D455234204F56460054494D4552356A +:10E4900020434150540054494D45523520434F4D7F +:10E4A00050410054494D45523520434F4D50420094 +:10E4B00054494D45523520434F4D50430054494D2A +:10E4C000455235204F564600555341525430205244 +:10E4D000580055534152543020554452450055532D +:10E4E0004152543020545800555341525431205217 +:10E4F000580055534152543120554452450055530C +:10E5000041525431205458005553415254322052F4 +:10E5100058005553415254322055445245005553EA +:10E5200041525432205458005553415254332052D2 +:10E5300058005553415254332055445245005553C9 +:10E5400041525433205458005350492053544300EF +:10E5500041444300414E414C4F4720434F4D5000F2 +:10E560004545205245414459005457490053504DA8 +:10E57000205245414459002A003FE345E34AE34F16 +:10E58000E354E359E35EE363E368E36DE374E37B41 +:10E59000E382E3E9E3F6E303E4ABE3B7E3C4E3D107 +:10E5A000E3DEE386E393E3A0E348E5C8E4D2E4DEF8 +:10E5B000E454E550E560E50EE41AE427E434E44170 +:10E5C000E4E8E4F2E4FEE469E56DE54CE458E46572 +:10E5D000E472E47FE48AE496E4A3E4B0E4BDE408F2 +:10E5E000E512E51EE528E532E53EE50011241FBEF3 +:10E5F000CFEFD1E2DEBFCDBF01E00CBF12E0A0E063 +:10E60000B2E0EAEDFFEF03E00BBF02C007900D920E +:10E61000A030B107D9F712E0A0E0B2E001C01D922E +:10E62000AC30B107E1F70F94FBF40D94EBFF01E27E +:10E630000EBF0FEF0DBF11241FBE0D94FBF40D9400 +:10E6400000F020E030E040ED57E005C0FA013197DE +:10E65000F1F72F5F3F4F28173907C0F308959C014A +:10E66000442737FD4095542FDA01C901860F911DCB +:10E67000A11DB11DABBFFC018791882369F0809378 +:10E68000C6008091C00086FFFCCF8091C0008064EE +:10E690008093C0006F5FE8CF08958DE08093C6003F +:10E6A0008091C00086FFFCCF8091C0008064809381 +:10E6B000C0008AE08093C6008091C00086FFFCCF36 +:10E6C0008091C00080648093C00008950F942FF360 +:10E6D0000F944DF30895FC019081992359F0909384 +:10E6E000C6008091C00086FFFCCF8091C00080648E +:10E6F0008093C0003196992379F70895282F982F99 +:10E7000092959F70892F805D8A3308F0895F80938E +:10E71000C6008091C00086FFFCCF8091C00080645D +:10E720008093C000822F8F70982F905D9A3308F0ED +:10E73000995F9093C6008091C00086FFFCCF8091C6 +:10E74000C00080648093C00008959C01FB01853661 +:10E7500091051CF46330710594F0C90164E670E022 +:10E760000F948CFF605D7F4F6093C6008091C00066 +:10E7700086FFFCCF8091C00080648093C0002B3066 +:10E78000310514F43297B4F0C90164E670E00F94D7 +:10E790008CFF6AE070E00F948CFF605D7F4F6093A8 +:10E7A000C6008091C00086FFFCCF8091C0008064CD +:10E7B0008093C000C9016AE070E00F948CFFC0969E +:10E7C0008093C6008091C00086FFFCCF8091C0007E +:10E7D00080648093C0000895282F277020642093C0 +:10E7E0007C0020917B0086958695869590E08170CF +:10E7F000907033E0880F991F3A95E1F7277F282B17 +:10E8000020937B0080917A00806480937A008091CD +:10E810007A0086FDFCCF2091780040917900942FFA +:10E8200080E030E0282B392BC90108951F93182F61 +:10E8300080E892EE60E00F942FF31093C600809171 +:10E84000C00086FFFCCF8091C00080648093C00030 +:10E850000F944DF31F9108952F923F924F925F9224 +:10E860006F927F928F929F92AF92BF92CF92DF92E0 +:10E87000EF92FF920F931F93DF93CF93CDB7DEB745 +:10E8800062970FB6F894DEBF0FBECDBF382E622E52 +:10E89000CA01DB015C016D01772460E2262E2E01A6 +:10E8A0000894411C511C8BC081E0A81680E0B8067A +:10E8B00081E0C80680E0D80628F0C601AA27BB2759 +:10E8C0000F947EF3BB27AD2D9C2D8B2D0F947EF3E3 +:10E8D0008A2D0F947EF32092C6008091C00086FF9F +:10E8E000FCCF8091C00080648093C0009DE2909333 +:10E8F000C6008091C00086FFFCCF8091C00080647C +:10E900008093C0002092C6008091C00086FFFCCF9B +:10E910008091C00080648093C000198286017501D7 +:10E9200088249924A1E03A1651F03A1620F0B2E07A +:10E930003B1661F409C00BBFF701779007C0C70110 +:10E940000F94D5FF782E02C0F7017080872D0F94A9 +:10E950007EF32092C6008091C00086FFFCCF80919C +:10E96000C00080648093C000872D8052F401EF7056 +:10E97000F0708F3520F4E40DF51D708204C0E40DB5 +:10E98000F51D8EE280830894E11CF11C011D111D10 +:10E990000894811C911C90E18916910409F0C2CF62 +:10E9A00080E190E0A0E0B0E0A80EB91ECA1EDB1E18 +:10E9B000198AC2010F946BF30F944DF36A94662089 +:10E9C00009F072CF62960FB6F894DEBF0FBECDBFCE +:10E9D000CF91DF911F910F91FF90EF90DF90CF903B +:10E9E000BF90AF909F908F907F906F905F904F906F +:10E9F0003F902F9008952F923F924F925F926F9287 +:10EA00007F928F929F92AF92BF92CF92DF92EF92BE +:10EA1000FF920F931F93DF93CF93CDB7DEB7CD5304 +:10EA2000D1400FB6F894DEBF0FBECDBF279A2F9A04 +:10EA30008091C00082608093C00080E18093C40018 +:10EA400088E18093C1000000EE24FF248701B4E038 +:10EA5000AB2EB12CCC24DD2424C0C5010197F1F7E5 +:10EA60000894E11CF11C011D111D21E2E2162EE4A7 +:10EA7000F20620E0020720E0120718F0A1E0CA2EFB +:10EA8000D12CC801B70128E53BE140E050E00F94EC +:10EA90009FFF611571058105910519F485B18058B5 +:10EAA00085B98091C00087FD03C0C114D104A9F2CB +:10EAB000A6014F5F5F4FC25EDE4F59834883CE5140 +:10EAC000D140C25EDE4F68817981CE51D140613044 +:10EAD000710511F00D946EFFC05DDE4F1982188232 +:10EAE000C053D14060E0C15DDE4F1882CF52D140AB +:10EAF000AA24BB24C05EDE4F188219821A821B82B0 +:10EB0000C052D140CE5CDE4F188219821A821B821D +:10EB1000C253D14080E090E0A0E0B0E0ABBFFC0188 +:10EB2000A791B691C45CDE4FB983A883CC53D14082 +:10EB30000D9469FFC25EDE4FE881F981CE51D1406C +:10EB4000319709F52091C600C25EDE4F1982188206 +:10EB5000CE51D14022C02F5F3F4F4F4F5F4F2130EA +:10EB6000F2E13F07FAE74F07F0E05F0780F0C45C8F +:10EB7000DE4F08811981CC53D1400F5F1F4F19F030 +:10EB8000EE27FF27099420E030E040E050E080913C +:10EB9000C00087FFE0CF2091C600213209F094C663 +:10EBA0000894A11CB11C33E0A316B10409F08EC671 +:10EBB00000E010E018C041E24093C6008091C00020 +:10EBC00086FFFCCF8091C00080648093C0002F5FDF +:10EBD0003F4F2931310579F70F944DF30F5F1F4FE8 +:10EBE0000530110519F020E030E0E5CF1092080261 +:10EBF0001092090210920A0210920B021092040263 +:10EC00001092050210920602109207021092000262 +:10EC10001092010210920202109203028FEE90EE07 +:10EC200060E00F9466F380E191EE60E00F942FF3C3 +:10EC30008091C00087FFFCCF9091C600903608F00D +:10EC40009F759032B8F09093C6008091C00086FF07 +:10EC5000FCCF8091C00080648093C00080E28093EC +:10EC6000C6008091C00086FFFCCF8091C000806408 +:10EC70008093C000983409F4DBC19934B8F492341D +:10EC800009F45DC1933458F4903319F1903308F4CA +:10EC900018C69F33A1F1903409F013C6BDC0953456 +:10ECA00009F474C1963409F00CC69CC1923509F47C +:10ECB0002FC2933538F49C3409F4F9C1913509F029 +:10ECC00000C61CC2963509F449C2993509F0F9C548 +:10ECD0009CC485E892EE62E00F9466F31092040201 +:10ECE000109205021092060210920702109208027A +:10ECF0001092090210920A0210920B0217C189E9C0 +:10ED000092EE62E00F9466F38FEE90EE60E00F9467 +:10ED100066F381E291EE60E00F942FF381EC91EEC7 +:10ED200060E00F9466F381E391EE60E00F942FF3BF +:10ED300084EE90EE60E00F9466F381E491EE60E083 +:10ED40000F942FF386E090E061E070E00F94A5F35C +:10ED50000F944DF381E691EE60E00F942FF383ED75 +:10ED600091EE60E00F9466F381E591EE60E00F9420 +:10ED70002FF38DEC91EE60E00F9466F381E791EE56 +:10ED800060E00F942FF38EE10F947EF388E90F94E7 +:10ED90007EF381E00F947EF30F944DF381E891EEC2 +:10EDA00060E00F942FF319E0E0E0F0E010935700DB +:10EDB000E4918E2F0F947EF30F944DF381E991EE41 +:10EDC00060E00F942FF3E3E0F0E010935700E4913C +:10EDD0008E2F0F947EF30F944DF381EA91EE60E055 +:10EDE0000F942FF3E2E0F0E010935700E4918E2FA0 +:10EDF0000F947EF30F944DF381EB91EE60E00F944E +:10EE00002FF3E1E0F0E0109357001491812F0F945D +:10EE10007EF30F944DF307CF85EA92EE62E00F94F4 +:10EE200066F385E592EE60E00F9466F30F944DF380 +:10EE300000E010E019C0C8016F2D0F94DDFFFF2026 +:10EE400031F483E592EE60E00F942FF30BC0F09263 +:10EE5000C6008091C00086FFFCCF8091C000806416 +:10EE60008093C0000F5F1F4FC80181519F41AA27A7 +:10EE700097FDA095BA2FABBFFC01F7905AE2F516AB +:10EE800021F062E000301607B1F60F944DF30F94B5 +:10EE90004DF381E692EE60E00F9466F30F944DF32C +:10EEA000CC24DD2400E010E01EC0C8010F94D5FF83 +:10EEB000F82E882331F483E592EE60E00F942FF36F +:10EEC0000BC08093C6008091C00086FFFCCF80916C +:10EED000C00080648093C000FE1419F00894C11C27 +:10EEE000D11C0F5F1F4FC80181519F41AA2797FD79 +:10EEF000A095BA2FABBFFC01E7907AE2E71621F0AC +:10EF000082E00030180789F60F944DF30F944DF30B +:10EF10008CE692EE60E00F942FF3C60161E070E0A2 +:10EF20000F94A5F30F944DF30F944DF3109200023C +:10EF300010920102109202021092030274CE83EB2F +:10EF400092EE62E00F9466F3279A2F9A16C02F98DC +:10EF500080E090E0E0EDF7E03197F1F7019684363C +:10EF60009105C1F72F9A80E090E0E0EDF7E031974E +:10EF7000F1F7019684369105C1F78091C00087FFB3 +:10EF8000E6CF8091C00087FFFCCF95C48FEB92EE57 +:10EF900062E00F9466F3409100025091010260918B +:10EFA00002027091030281E020E10F942CF4809121 +:10EFB000000290910102A0910202B09103028050E0 +:10EFC0009F4FAF4FBF4F8093000290930102A093D9 +:10EFD0000202B093030280509041A040B04008F478 +:10EFE00022CEA4CF8DEC92EE62E00F9466F34091B6 +:10EFF000040250910502609106027091070280E0C0 +:10F0000020E10F942CF48091040290910502A091CC +:10F010000602B091070280509F4FAF4FBF4F8093C1 +:10F02000040290930502A0930602B0930702FBCD61 +:10F030008AED92EE62E00F9466F385E892EE60E06E +:10F040000F9466F389E992EE60E00F9466F385EA27 +:10F0500092EE60E00F9466F383EB92EE60E00F9423 +:10F0600066F38FEB92EE60E00F9466F38DEC92EE18 +:10F0700060E00F9466F38AED92EE60E00F9466F321 +:10F0800081EE92EE60E00F9466F382EF92EE60E024 +:10F090000F9466F38CE093EE60E00F9466F387E1E3 +:10F0A00093EE60E00F9466F380E393EEB9CD81EECA +:10F0B00092EE62E00F9466F381E40F9416F482E41A +:10F0C0000F9416F483E40F9416F484E40F9416F46A +:10F0D00085E40F9416F486E40F9416F487E40F94F5 +:10F0E00016F488E40F9416F48AE40F9416F48BE473 +:10F0F0000F9416F48CE40F9416F495CD82EF92EEF3 +:10F1000062E00F9466F399249394AA24BB2445C427 +:10F110008CE093EE62E00F9466F340910802509108 +:10F12000090260910A0270910B0282E020E10F94C3 +:10F130002CF48091080290910902A0910A02B091EA +:10F140000B0280509F4FAF4FBF4F809308029093A8 +:10F150000902A0930A02B0930B0265CD87E193EEFA +:10F1600062E00F9466F384EE90EE60E00F9466F335 +:10F1700089ED91EE60E00F9466F309E715EECC5D42 +:10F18000DE4F19830883C452D1406624772443019B +:10F19000CA5DDE4F19821882C652D140A401930184 +:10F1A0005695479537952795C85DDE4F2883398357 +:10F1B0004A835B83C852D140CA5DDE4F4881598182 +:10F1C000C652D1404F5F5F4FCA5DDE4F59834883BF +:10F1D000C652D140CA0162E070E00F94A5F350E23C +:10F1E0005093C6008091C00086FFFCCF8091C00084 +:10F1F00080648093C0006DE26093C6008091C0007F +:10F2000086FFFCCF8091C00080648093C00070E2D4 +:10F210007093C6008091C00086FFFCCF8091C00033 +:10F2200080648093C000C85DDE4FE880F9800A8169 +:10F230001B81C852D140BB27A12F902F8F2D0F9437 +:10F240007EF3C85DDE4F8881C852D1400F947EF3B3 +:10F2500070E2F72EF092C6008091C00086FFFCCFCE +:10F260008091C00080648093C0000DE30093C600CD +:10F270008091C00086FFFCCF8091C00080648093A5 +:10F28000C00010E21093C6008091C00086FFFCCF42 +:10F290008091C00080648093C0008BBEF3012791F1 +:10F2A000C45DDE4F2883CC52D140A22EBB24CC2497 +:10F2B000DD240894611C711C811C911C8BBEF30120 +:10F2C0008791282E332444245524142D032DF22C09 +:10F2D000EE24EA0CFB1C0C1D1D1D0894611C711C06 +:10F2E000811C911C8BBEF3013791C35DDE4F3883C7 +:10F2F000CD52D1400894611C711C811C911C8BBEA5 +:10F30000F3014791C25DDE4F4883CE52D1402DEFCD +:10F310003FEF4FEF5FEF620E731E841E951E0F943A +:10F320007EF330E23093C6008091C00086FFFCCFB0 +:10F330008091C00080648093C000C45DDE4F8881EE +:10F34000CC52D1400F947EF340E24093C6008091AE +:10F35000C00086FFFCCF8091C00080648093C00015 +:10F36000C25DDE4F8881CE52D1400F947EF350E2D1 +:10F370005093C6008091C00086FFFCCF8091C000F2 +:10F3800080648093C000C35DDE4F8881CD52D14040 +:10F390000F947EF360E26093C6008091C00086FF08 +:10F3A000FCCF8091C00080648093C0007FEFE7169F +:10F3B0007FEFF70670E0070770E0170731F48EE083 +:10F3C00092EE60E00F942FF3DFC0D801C701807088 +:10F3D000907CA070B0708050904CA040B040D1F5AF +:10F3E0002FEF3FE340E050E0E222F3220423152315 +:10F3F000C85DDE4FA880B980CA80DB80C852D1408A +:10F40000AE0CBF1CC01ED11EAA0CBB1CCC1CDD1C2C +:10F4100088E192EE60E00F942FF3BB27A12F902F8D +:10F420008F2D0F947EF38E2D0F947EF330E2309368 +:10F43000C6008091C00086FFFCCF8091C000806430 +:10F440008093C0004EE34093C6008091C00086FFC9 +:10F45000FCCF87C06EE07EEF80E090E0E622F722EE +:10F46000082319237CE0E71674E9F70670E0070724 +:10F4700070E0170709F088C0C25DDE4F8881CE5268 +:10F48000D140E82EFF2400E010E0102F0F2DFE2CBD +:10F49000EE24C35DDE4F9881CD52D140E90EF11CC0 +:10F4A000011D111DD601C50181709070A070B07052 +:10F4B000DC0199278827E80EF91E0A1F1B1F20EF81 +:10F4C00030E040E050E0A222B322C422D522F1E194 +:10F4D000AA0CBB1CCC1CDD1CFA95D1F7EA0CFB1C5A +:10F4E0000C1D1D1D41E050E060E070E0242235223B +:10F4F00046225722E5E1220C331C441C551CEA9598 +:10F50000D1F7E20CF31C041D151D57016801AA0C6C +:10F51000BB1CCC1CDD1C8FE192EE60E00F942FF33E +:10F52000C801AA27BB270F947EF3BB27A12F902FDA +:10F530008F2D0F947EF38E2D0F947EF350E2509317 +:10F54000C6008091C00086FFFCCF8091C00080641F +:10F550008093C0006EE36093C6008091C00086FF78 +:10F56000FCCF8091C00080648093C000C601AA27B0 +:10F57000BB270F947EF3BB27AD2D9C2D8B2D0F94B5 +:10F580007EF38A2D0F947EF370E27093C600809113 +:10F59000C00086FFFCCF8091C00080648093C000D3 +:10F5A000CC5DDE4FE881F981C452D140CF01AA275A +:10F5B00097FDA095BA2FABBFFC018791969160E0B3 +:10F5C0000F942FF30F944DF3CC5DDE4F088119811A +:10F5D000C452D1400E5F1F4FCC5DDE4F19830883AC +:10F5E000C452D140CA5DDE4F28813981C652D14014 +:10F5F0002933310509F417CB44E050E060E070E0B6 +:10F60000640E751E861E971EC9CD80E393EE62E0E0 +:10F610000F9466F384E292EE60E00F942FF38091F2 +:10F62000C00087FFFCCF1091C6001F751093C60065 +:10F630008091C00086FFFCCF8091C00080648093E1 +:10F64000C0000F944DF3812F81548A3108F036C1E8 +:10F65000163409F495C0173490F4133409F44EC0ED +:10F66000143430F41134F1F0123409F01DC130C0FB +:10F67000143409F459C0153409F016C16BC01A349A +:10F6800009F4C4C01B3438F4173409F48FC018349B +:10F6900009F00AC1A1C01B3409F4D2C01C3409F01E +:10F6A00003C1E8C08FEF81B90DC082B1809582B9E6 +:10F6B00080E090E0E0EDF7E03197F1F70196883CCB +:10F6C0009105C1F78091C00087FFEFCF12B8EFC05E +:10F6D0008FEF84B90DC085B1809585B980E090E049 +:10F6E000E0EDF7E03197F1F70196883C9105C1F71D +:10F6F0008091C00087FFEFCF15B8D9C08FEF87B9D1 +:10F700000DC088B1809588B980E090E0E0EDF7E029 +:10F710003197F1F70196883C9105C1F78091C000BF +:10F7200087FFEFCF18B8C3C08FEF8AB90DC08BB178 +:10F7300080958BB980E090E0E0EDF7E03197F1F74C +:10F740000196883C9105C1F78091C00087FFEFCFFB +:10F750001BB8ADC08FEF8DB90DC08EB180958EB93D +:10F7600080E090E0E0EDF7E03197F1F70196883C1A +:10F770009105C1F78091C00087FFEFCF1EB897C0F9 +:10F780008FEF80BB0DC081B3809581BB80E090E09E +:10F79000E0EDF7E03197F1F70196883C9105C1F76C +:10F7A0008091C00087FFEFCF11BA81C08FEF83BB7C +:10F7B0000DC084B3809584BB80E090E0E0EDF7E07D +:10F7C0003197F1F70196883C9105C1F78091C0000F +:10F7D00087FFEFCF14BA6BC08FEF809301010FC08A +:10F7E0008091020180958093020180E090E0E0ED3D +:10F7F000F7E03197F1F70196883C9105C1F78091C8 +:10F80000C00087FFEDCF1092020151C08FEF8093AF +:10F8100004010FC08091050180958093050180E06F +:10F8200090E0E0EDF7E03197F1F70196883C910523 +:10F83000C1F78091C00087FFEDCF1092050137C05E +:10F840008FEF809307010FC080910801809580930E +:10F85000080180E090E0E0EDF7E03197F1F70196E4 +:10F86000883C9105C1F78091C00087FFEDCF1092D1 +:10F8700008011DC08FEF80930A010FC080910B011A +:10F88000809580930B0180E090E0E0EDF7E0319708 +:10F89000F1F70196883C9105C1F78091C00087FF80 +:10F8A000EDCF10920B0103C08FE292EEB9C98091A7 +:10F8B000C00087FFFCCF8091C600B5C982E492EEFC +:10F8C000AFC98CE191EEACC9AA24BB24933061F19D +:10F8D000943028F4913089F0923008F508C09530C2 +:10F8E000B1F1953040F1963009F053C04EC02B3144 +:10F8F00009F020C991E06BE11DC9213041F0C15DE3 +:10F90000DE4F5881CF52D140251709F002C362273C +:10F91000C15DDE4F2883CF52D14092E00BC9B22F98 +:10F92000A0E0622793E006C9822F90E0A82BB92BB4 +:10F93000622794E0FFC82E3009F0EBC2622795E001 +:10F94000C05DDE4F19821882C053D140F3C8E1E098 +:10F95000F0E0EC0FFD1FC05DDE4FE880F980C05382 +:10F96000D140EE0DFF1D208387010F5F1F4FC05D4B +:10F97000DE4F19830883C053D14062270A171B0743 +:10F9800009F0D8C8D80196E0D5C8261709F0C1C239 +:10F9900003C0973009F0CEC899248981833109F4D6 +:10F9A000FCC08431C8F4863009F4C2C0873050F4FA +:10F9B000823009F4F0C0833009F458C0813009F076 +:10F9C0000AC23EC0813109F462C0823108F0A6C08B +:10F9D000803109F000C2DFC0883109F472C089317A +:10F9E00050F4853109F4D9C0853108F477C18631E6 +:10F9F00009F0F1C173C18A3109F457C08A3108F4A2 +:10FA00007CC08B3109F446C08D3109F0E4C18D8191 +:10FA1000803311F090E00AC08F81882311F49EE1B9 +:10FA200005C0813011F091E001C098E91A821B8273 +:10FA30008D818C831D829E831F8227E030E0CFC1A1 +:10FA40001A8288E08B8381E48C8386E58D8382E54E +:10FA50008E8389E48F8383E5888780E589878FE5B6 +:10FA60008A8782E38B872BE030E0B9C18A818139B4 +:10FA700041F0823941F0803911F48FE005C080E017 +:10FA800003C082E001C08AE01A828B8344C09924BB +:10FA9000939481C08D81882311F48EE12CC0813034 +:10FAA00011F081E028C088E926C01A82E1E0F0E088 +:10FAB00089E08093570084918B831C8224E030E09E +:10FAC0008EC18B81803589F48C81883039F4E2E0F5 +:10FAD000F0E089E08093570084910DC0E0E0F0E011 +:10FAE00089E080935700849106C0E3E0F0E089E06C +:10FAF0008093570084911A82DFCF8D81836C99E0C7 +:10FB0000E1E0F0E0082E90935700E89507B600FC7E +:10FB1000FDCF1A821B8223E030E061C11A82CE5CE5 +:10FB2000DE4F188219821A821B82C253D14055C1FE +:10FB30008A8190E0A0E0B0E0582F442733272227A5 +:10FB40008B8190E0A0E0B0E0DC0199278827282B8A +:10FB5000392B4A2B5B2B8D8190E0A0E0B0E0282B65 +:10FB6000392B4A2B5B2B8C8190E0A0E0B0E0BA2FC0 +:10FB7000A92F982F8827282B392B4A2B5B2B220F54 +:10FB8000331F441F551FC05EDE4F288339834A83CD +:10FB90005B83C052D1401A8220C19A812B8183316C +:10FBA00049F0C05EDE4F488159816A817B81C05235 +:10FBB000D1408AC0CE5CDE4F488159816A817B8109 +:10FBC000C253D140403080EC580783E0680780E0A2 +:10FBD0007807F0F483E0FA0160935B0080935700AC +:10FBE000E89507B600FCFDCFCE5CDE4F4881598119 +:10FBF0006A817B81C253D14040505F4F6F4F7F4F2E +:10FC0000CE5CDE4F488359836A837B83C253D140E5 +:10FC1000C95CDE4F9883C753D140CA5CDE4F18825F +:10FC2000C653D140022F10E0CA5CDE4F6881798153 +:10FC3000C653D140062B172BC05EDE4F4881598139 +:10FC40006A817B81C052D140DE011B9631E08C91EC +:10FC500011962C9111971296C75CDE4F2883C953D9 +:10FC6000D140C85CDE4F1882C853D14090E0C85CD8 +:10FC7000DE4FE881F981C853D1408E2B9F2B0C01B8 +:10FC8000FA0160935B0030935700E89511244E5FB2 +:10FC90005F4F6F4F7F4F02501040C9F685E0C05E46 +:10FCA000DE4FE880F9800A811B81C052D140F70104 +:10FCB00000935B0080935700E89507B600FCFDCFEA +:10FCC00081E180935700E8951A82C05EDE4F488339 +:10FCD00059836A837B83C052D1407FC0FA80C55C60 +:10FCE000DE4FF882CB53D140C65CDE4F1882CA5338 +:10FCF000D1408B81C82EDD24C65CDE4F088119817E +:10FD0000CA53D140C02AD12A1A828981BE016D5FAF +:10FD10007F4F843121F59601C05EDE4FE880F98087 +:10FD20000A811B81C052D1400BBFF7018791969188 +:10FD3000DB018C9311969C936E5F7F4FD801C701B6 +:10FD40000296A11DB11DC05EDE4F88839983AA83F0 +:10FD5000BB83C052D14022503040F1F636C0C05E65 +:10FD6000DE4F288139814A815B81C052D14008949D +:10FD7000C108D108760100E010E00894C11CD11C34 +:10FD80000894E11CF11C011D111DE20EF31E041F5D +:10FD9000151F21BDBB27A52F942F832F82BD2F5F59 +:10FDA0003F4F4F4F5F4FF89A80B5DB018D93BD01F8 +:10FDB0002E153F054007510761F7C05EDE4F2883CF +:10FDC00039834A835B83C052D14096012D5F3F4FF8 +:10FDD000FB01108204C080EC8A8322E030E08BE1DA +:10FDE0008093C6008091C00086FFFCCF8091C00048 +:10FDF00080648093C000C15DDE4FF881CF52D14056 +:10FE0000F093C6008091C00086FFFCCF8091C000B7 +:10FE100080648093C000432F3093C6008091C0005F +:10FE200086FFFCCF8091C00080648093C000922F39 +:10FE30002093C6008091C00086FFFCCF8091C00057 +:10FE400080648093C0008EE08093C6008091C000E3 +:10FE500086FFFCCF8091C00080648093C00065E184 +:10FE6000C15DDE4FE880CF52D1406E2569276427FF +:10FE7000FE01319610C090819093C6008091C00021 +:10FE800086FFFCCF31968091C00080648093C000D3 +:10FE90006927215030402115310569F76093C6006C +:10FEA0008091C00086FFFCCF8091C0008064809369 +:10FEB000C00085B1805885B9992081F4C15DDE4FBD +:10FEC0000881CF52D1400F5FC15DDE4F0883CF5212 +:10FED000D14090E0A0E0B0E00D949AF527982F98DB +:10FEE00080E090E020ED37E0F9013197F1F70196DD +:10FEF00084369105C9F700008091C0008D7F809302 +:10FF0000C00081E180935700E895EE27FF27099410 +:10FF1000FFCF90E00D949AF597FB092E07260AD0A3 +:10FF200077FD04D02ED006D000201AF4709561958C +:10FF30007F4F0895F6F7909581959F4F0895A1E220 +:10FF40001A2EAA1BBB1BFD010DC0AA1FBB1FEE1F53 +:10FF5000FF1FA217B307E407F50720F0A21BB30B9E +:10FF6000E40BF50B661F771F881F991F1A9469F71A +:10FF700060957095809590959B01AC01BD01CF0176 +:10FF80000895AA1BBB1B51E107C0AA1FBB1FA617E0 +:10FF9000B70710F0A61BB70B881F991F5A95A9F732 +:10FFA00080959095BC01CD010895F999FECF92BD41 +:10FFB00081BDF89A992780B50895262FF999FECF2B +:10FFC0001FBA92BD81BD20BD0FB6F894FA9AF99A76 +:0AFFD0000FBE01960895F894FFCFCC :040000033000E000E9 :00000001FF diff --git a/hardware/arduino/cores/arduino/HardwareSerial.h b/hardware/arduino/cores/arduino/HardwareSerial.h index 9dc67c4c9..176abe1e2 100644 --- a/hardware/arduino/cores/arduino/HardwareSerial.h +++ b/hardware/arduino/cores/arduino/HardwareSerial.h @@ -32,6 +32,7 @@ class HardwareSerial : public Stream { private: ring_buffer *_rx_buffer; + ring_buffer *_tx_buffer; volatile uint8_t *_ubrrh; volatile uint8_t *_ubrrl; volatile uint8_t *_ucsra; @@ -40,28 +41,29 @@ class HardwareSerial : public Stream uint8_t _rxen; uint8_t _txen; uint8_t _rxcie; - uint8_t _udre; + uint8_t _udrie; uint8_t _u2x; public: - HardwareSerial(ring_buffer *rx_buffer, + HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, volatile uint8_t *ucsra, volatile uint8_t *ucsrb, volatile uint8_t *udr, - uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x); + uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x); void begin(unsigned long); void end(); virtual int available(void); virtual int peek(void); virtual int read(void); virtual void flush(void); - virtual void write(uint8_t); + virtual size_t write(uint8_t); using Print::write; // pull in write(str) and write(buf, size) from Print }; #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; #elif defined(USBCON) - #include "usb_api.h" + #include "USBAPI.h" +// extern HardwareSerial Serial_; #endif #if defined(UBRR1H) extern HardwareSerial Serial1; @@ -73,4 +75,6 @@ class HardwareSerial : public Stream extern HardwareSerial Serial3; #endif +extern void serialEventRun(void) __attribute__((weak)); + #endif diff --git a/hardware/arduino/cores/arduino/Print.cpp b/hardware/arduino/cores/arduino/Print.cpp index fd689423a..ff9b15459 100755 --- a/hardware/arduino/cores/arduino/Print.cpp +++ b/hardware/arduino/cores/arduino/Print.cpp @@ -23,173 +23,213 @@ #include #include #include -#include "wiring.h" +#include "Arduino.h" #include "Print.h" // Public Methods ////////////////////////////////////////////////////////////// /* default implementation: may be overridden */ -void Print::write(const char *str) +size_t Print::write(const uint8_t *buffer, size_t size) { - while (*str) - write(*str++); -} - -/* default implementation: may be overridden */ -void Print::write(const uint8_t *buffer, size_t size) -{ - while (size--) - write(*buffer++); -} - -void Print::print(const String &s) -{ - for (unsigned int i = 0; i < s.length(); i++) { - write(s[i]); + size_t n = 0; + while (size--) { + n += write(*buffer++); } + return n; } -void Print::print(const char str[]) +size_t Print::print(const __FlashStringHelper *ifsh) { - write(str); + const prog_char *p = (const prog_char *)ifsh; + size_t n = 0; + while (1) { + unsigned char c = pgm_read_byte(p++); + if (c == 0) break; + n += write(c); + } + return n; } -void Print::print(char c, int base) +size_t Print::print(const String &s) { - print((long) c, base); + size_t n = 0; + for (uint16_t i = 0; i < s.length(); i++) { + n += write(s[i]); + } + return n; } -void Print::print(unsigned char b, int base) +size_t Print::print(const char str[]) { - print((unsigned long) b, base); + return write(str); } -void Print::print(int n, int base) +size_t Print::print(char c) { - print((long) n, base); + return write(c); } -void Print::print(unsigned int n, int base) +size_t Print::print(unsigned char b, int base) { - print((unsigned long) n, base); + return print((unsigned long) b, base); } -void Print::print(long n, int base) +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) { if (base == 0) { - write(n); + return write(n); } else if (base == 10) { if (n < 0) { - print('-'); + int t = print('-'); n = -n; + return printNumber(n, 10) + t; } - printNumber(n, 10); + return printNumber(n, 10); } else { - printNumber(n, base); + return printNumber(n, base); } } -void Print::print(unsigned long n, int base) +size_t Print::print(unsigned long n, int base) { - if (base == 0) write(n); - else printNumber(n, base); + if (base == 0) return write(n); + else return printNumber(n, base); } -void Print::print(double n, int digits) +size_t Print::print(double n, int digits) { - printFloat(n, digits); + return printFloat(n, digits); } -void Print::println(void) +size_t Print::println(const __FlashStringHelper *ifsh) { - print('\r'); - print('\n'); + size_t n = print(ifsh); + n += println(); + return n; } -void Print::println(const String &s) +size_t Print::print(const Printable& x) { - print(s); - println(); + return x.printTo(*this); } -void Print::println(const char c[]) +size_t Print::println(void) { - print(c); - println(); + size_t n = print('\r'); + n += print('\n'); + return n; } -void Print::println(char c, int base) +size_t Print::println(const String &s) { - print(c, base); - println(); + size_t n = print(s); + n += println(); + return n; } -void Print::println(unsigned char b, int base) +size_t Print::println(const char c[]) { - print(b, base); - println(); + size_t n = print(c); + n += println(); + return n; } -void Print::println(int n, int base) +size_t Print::println(char c) { - print(n, base); - println(); + size_t n = print(c); + n += println(); + return n; } -void Print::println(unsigned int n, int base) +size_t Print::println(unsigned char b, int base) { - print(n, base); - println(); + size_t n = print(b, base); + n += println(); + return n; } -void Print::println(long n, int base) +size_t Print::println(int num, int base) { - print(n, base); - println(); + size_t n = print(num, base); + n += println(); + return n; } -void Print::println(unsigned long n, int base) +size_t Print::println(unsigned int num, int base) { - print(n, base); - println(); + size_t n = print(num, base); + n += println(); + return n; } -void Print::println(double n, int digits) +size_t Print::println(long num, int base) { - print(n, digits); - println(); + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; } // Private Methods ///////////////////////////////////////////////////////////// -void Print::printNumber(unsigned long n, uint8_t base) -{ - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. - unsigned long i = 0; +size_t Print::printNumber(unsigned long n, uint8_t base) { + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; - if (n == 0) { - print('0'); - return; - } + *str = '\0'; - while (n > 0) { - buf[i++] = n % base; + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + unsigned long m = n; n /= base; - } + char c = m - base * n; + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); - for (; i > 0; i--) - print((char) (buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10)); + return write(str); } -void Print::printFloat(double number, uint8_t digits) +size_t Print::printFloat(double number, uint8_t digits) { + size_t n = 0; + // Handle negative numbers if (number < 0.0) { - print('-'); + n += print('-'); number = -number; } @@ -203,18 +243,21 @@ void Print::printFloat(double number, uint8_t digits) // Extract the integer part of the number and print it unsigned long int_part = (unsigned long)number; double remainder = number - (double)int_part; - print(int_part); + n += print(int_part); // Print the decimal point, but only if there are digits beyond - if (digits > 0) - print("."); + if (digits > 0) { + n += print("."); + } // Extract digits from the remainder one at a time while (digits-- > 0) { remainder *= 10.0; int toPrint = int(remainder); - print(toPrint); + n += print(toPrint); remainder -= toPrint; } + + return n; } diff --git a/hardware/arduino/cores/arduino/WString.h b/hardware/arduino/cores/arduino/WString.h index 56faf9a48..d76d2a33d 100644 --- a/hardware/arduino/cores/arduino/WString.h +++ b/hardware/arduino/cores/arduino/WString.h @@ -1,6 +1,8 @@ /* WString.h - String library for Wiring & Arduino + ...mostly rewritten by Paul Stoffregen... Copyright (c) 2009-10 Hernando Barragan. All right reserved. + Copyright 2011, Paul Stoffregen, paul@pjrc.com This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -17,96 +19,187 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef String_h -#define String_h +#ifndef String_class_h +#define String_class_h +#ifdef __cplusplus -//#include "WProgram.h" #include #include #include +#include +// When compiling programs with this class, the following gcc parameters +// dramatically increase performance and memory (RAM) efficiency, typically +// with little or no increase in code size. +// -felide-constructors +// -std=c++0x + +class __FlashStringHelper; +#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal))) + +// An inherited class for holding the result of a concatenation. These +// result objects are assumed to be writable by subsequent concatenations. +class StringSumHelper; + +// The string class class String { - public: - // constructors - String( const char *value = "" ); - String( const String &value ); - String( const char ); - String( const unsigned char ); - String( const int, const int base=10); - String( const unsigned int, const int base=10 ); - String( const long, const int base=10 ); - String( const unsigned long, const int base=10 ); - ~String() { free(_buffer); _length = _capacity = 0;} //added _length = _capacity = 0; + // use a function pointer to allow for "if (s)" without the + // complications of an operator bool(). for more information, see: + // http://www.artima.com/cppsource/safebool.html + typedef void (String::*StringIfHelperType)() const; + void StringIfHelper() const {} - // operators - const String & operator = ( const String &rhs ); - const String & operator +=( const String &rhs ); - //const String & operator +=( const char ); - int operator ==( const String &rhs ) const; - int operator !=( const String &rhs ) const; - int operator < ( const String &rhs ) const; - int operator > ( const String &rhs ) const; - int operator <=( const String &rhs ) const; - int operator >=( const String &rhs ) const; - char operator []( unsigned int index ) const; - char& operator []( unsigned int index ); - //operator const char *() const { return _buffer; } - - // general methods - char charAt( unsigned int index ) const; - int compareTo( const String &anotherString ) const; - unsigned char endsWith( const String &suffix ) const; - unsigned char equals( const String &anObject ) const; - unsigned char equalsIgnoreCase( const String &anotherString ) const; - int indexOf( char ch ) const; - int indexOf( char ch, unsigned int fromIndex ) const; - int indexOf( const String &str ) const; - int indexOf( const String &str, unsigned int fromIndex ) const; - int lastIndexOf( char ch ) const; - int lastIndexOf( char ch, unsigned int fromIndex ) const; - int lastIndexOf( const String &str ) const; - int lastIndexOf( const String &str, unsigned int fromIndex ) const; - unsigned int length( ) const { return _length; } - void setCharAt(unsigned int index, const char ch); - unsigned char startsWith( const String &prefix ) const; - unsigned char startsWith( const String &prefix, unsigned int toffset ) const; - String substring( unsigned int beginIndex ) const; - String substring( unsigned int beginIndex, unsigned int endIndex ) const; - String toLowerCase( ) const; - String toUpperCase( ) const; - String trim( ) const; - void getBytes(unsigned char *buf, unsigned int bufsize); - void toCharArray(char *buf, unsigned int bufsize); - long toInt( ); - const String& concat( const String &str ); - String replace( char oldChar, char newChar ); - String replace( const String& match, const String& replace ); - friend String operator + ( String lhs, const String &rhs ); +public: + // constructors + // creates a copy of the initial value. + // if the initial value is null or invalid, or if memory allocation + // fails, the string will be marked as invalid (i.e. "if (s)" will + // be false). + String(const char *cstr = ""); + String(const String &str); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + String(String &&rval); + String(StringSumHelper &&rval); + #endif + explicit String(char c); + explicit String(unsigned char, unsigned char base=10); + explicit String(int, unsigned char base=10); + explicit String(unsigned int, unsigned char base=10); + explicit String(long, unsigned char base=10); + explicit String(unsigned long, unsigned char base=10); + ~String(void); - protected: - char *_buffer; // the actual char array - unsigned int _capacity; // the array length minus one (for the '\0') - unsigned int _length; // the String length (not counting the '\0') + // memory management + // return true on success, false on failure (in which case, the string + // is left unchanged). reserve(0), if successful, will validate an + // invalid string (i.e., "if (s)" will be true afterwards) + unsigned char reserve(unsigned int size); + inline unsigned int length(void) const {return len;} - void getBuffer(unsigned int maxStrLen); + // creates a copy of the assigned value. if the value is null or + // invalid, or if the memory allocation fails, the string will be + // marked as invalid ("if (s)" will be false). + String & operator = (const String &rhs); + String & operator = (const char *cstr); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + String & operator = (String &&rval); + String & operator = (StringSumHelper &&rval); + #endif - private: + // concatenate (works w/ built-in types) + + // returns true on success, false on failure (in which case, the string + // is left unchanged). if the argument is null or invalid, the + // concatenation is considered unsucessful. + unsigned char concat(const String &str); + unsigned char concat(const char *cstr); + unsigned char concat(char c); + unsigned char concat(unsigned char c); + unsigned char concat(int num); + unsigned char concat(unsigned int num); + unsigned char concat(long num); + unsigned char concat(unsigned long num); + + // if there's not enough memory for the concatenated value, the string + // will be left unchanged (but this isn't signalled in any way) + String & operator += (const String &rhs) {concat(rhs); return (*this);} + String & operator += (const char *cstr) {concat(cstr); return (*this);} + String & operator += (char c) {concat(c); return (*this);} + String & operator += (unsigned char num) {concat(num); return (*this);} + String & operator += (int num) {concat(num); return (*this);} + String & operator += (unsigned int num) {concat(num); return (*this);} + String & operator += (long num) {concat(num); return (*this);} + String & operator += (unsigned long num) {concat(num); return (*this);} + friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); + friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr); + friend StringSumHelper & operator + (const StringSumHelper &lhs, char c); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, int num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, long num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num); + + // comparison (only works w/ Strings and "strings") + operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; } + int compareTo(const String &s) const; + unsigned char equals(const String &s) const; + unsigned char equals(const char *cstr) const; + unsigned char operator == (const String &rhs) const {return equals(rhs);} + unsigned char operator == (const char *cstr) const {return equals(cstr);} + unsigned char operator != (const String &rhs) const {return !equals(rhs);} + unsigned char operator != (const char *cstr) const {return !equals(cstr);} + unsigned char operator < (const String &rhs) const; + unsigned char operator > (const String &rhs) const; + unsigned char operator <= (const String &rhs) const; + unsigned char operator >= (const String &rhs) const; + unsigned char equalsIgnoreCase(const String &s) const; + unsigned char startsWith( const String &prefix) const; + unsigned char startsWith(const String &prefix, unsigned int offset) const; + unsigned char endsWith(const String &suffix) const; + + // character acccess + char charAt(unsigned int index) const; + void setCharAt(unsigned int index, char c); + char operator [] (unsigned int index) const; + char& operator [] (unsigned int index); + void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const; + void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const + {getBytes((unsigned char *)buf, bufsize, index);} + + // search + int indexOf( char ch ) const; + int indexOf( char ch, unsigned int fromIndex ) const; + int indexOf( const String &str ) const; + int indexOf( const String &str, unsigned int fromIndex ) const; + int lastIndexOf( char ch ) const; + int lastIndexOf( char ch, unsigned int fromIndex ) const; + int lastIndexOf( const String &str ) const; + int lastIndexOf( const String &str, unsigned int fromIndex ) const; + String substring( unsigned int beginIndex ) const; + String substring( unsigned int beginIndex, unsigned int endIndex ) const; + + // modification + void replace(char find, char replace); + void replace(const String& find, const String& replace); + void toLowerCase(void); + void toUpperCase(void); + void trim(void); + + // parsing/conversion + long toInt(void) const; + +protected: + char *buffer; // the actual char array + unsigned int capacity; // the array length minus one (for the '\0') + unsigned int len; // the String length (not counting the '\0') + unsigned char flags; // unused, for future features +protected: + void init(void); + void invalidate(void); + unsigned char changeBuffer(unsigned int maxStrLen); + unsigned char concat(const char *cstr, unsigned int length); + + // copy and move + String & copy(const char *cstr, unsigned int length); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + void move(String &rhs); + #endif }; -// allocate buffer space -inline void String::getBuffer(unsigned int maxStrLen) +class StringSumHelper : public String { - _capacity = maxStrLen; - _buffer = (char *) malloc(_capacity + 1); - if (_buffer == NULL) _length = _capacity = 0; -} +public: + StringSumHelper(const String &s) : String(s) {} + StringSumHelper(const char *p) : String(p) {} + StringSumHelper(char c) : String(c) {} + StringSumHelper(unsigned char num) : String(num) {} + StringSumHelper(int num) : String(num) {} + StringSumHelper(unsigned int num) : String(num) {} + StringSumHelper(long num) : String(num) {} + StringSumHelper(unsigned long num) : String(num) {} +}; -inline String operator+( String lhs, const String &rhs ) -{ - return lhs += rhs; -} - - -#endif +#endif // __cplusplus +#endif // String_class_h diff --git a/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino b/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino index 8f405e7af..a169443b5 100644 --- a/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino +++ b/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino @@ -41,6 +41,13 @@ const int postingInterval = 10000; //delay between updates to Pachube.com void setup() { // start serial port: Serial.begin(9600); + // start the Ethernet connection: + if (Ethernet.begin(mac) == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // no point in carrying on, so do nothing forevermore: + for(;;) + ; + } // give the ethernet module time to boot up: delay(1000); // start the Ethernet connection: diff --git a/libraries/Firmata/examples/EchoString/EchoString.ino b/libraries/Firmata/examples/EchoString/EchoString.ino index e5c4e6fe5..5079697a5 100644 --- a/libraries/Firmata/examples/EchoString/EchoString.ino +++ b/libraries/Firmata/examples/EchoString/EchoString.ino @@ -1,3 +1,14 @@ +/* + * 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. @@ -14,12 +25,7 @@ void stringCallback(char *myString) void sysexCallback(byte command, byte argc, byte*argv) { - Serial.write(START_SYSEX); - Serial.write(command); - for(byte i=0; i Arduino!" and a little dancing man - to the LCD. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K potentiometer: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - * 10K poterntiometer on pin A0 - - created21 Mar 2011 - by Tom Igoe - Based on Adafruit's example at - https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde - - This example code is in the public domain. - http://www.arduino.cc/en/Tutorial/LiquidCrystal - - Also useful: - http://icontexto.com/charactercreator/ - - */ - -// include the library code: -#include - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -// make some custom characters: -byte heart[8] = { - 0b00000, - 0b01010, - 0b11111, - 0b11111, - 0b11111, - 0b01110, - 0b00100, - 0b00000 -}; - -byte smiley[8] = { - 0b00000, - 0b00000, - 0b01010, - 0b00000, - 0b00000, - 0b10001, - 0b01110, - 0b00000 -}; - -byte frownie[8] = { - 0b00000, - 0b00000, - 0b01010, - 0b00000, - 0b00000, - 0b00000, - 0b01110, - 0b10001 -}; - -byte armsDown[8] = { - 0b00100, - 0b01010, - 0b00100, - 0b00100, - 0b01110, - 0b10101, - 0b00100, - 0b01010 -}; - -byte armsUp[8] = { - 0b00100, - 0b01010, - 0b00100, - 0b10101, - 0b01110, - 0b00100, - 0b00100, - 0b01010 -}; -void setup() { - // create a new character - lcd.createChar(0, heart); - // create a new character - lcd.createChar(1, smiley); - // create a new character - lcd.createChar(2, frownie); - // create a new character - lcd.createChar(3, armsDown); - // create a new character - lcd.createChar(4, armsUp); - - // set up the lcd's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the lcd. - lcd.print("I "); - lcd.write(0); - lcd.print(" Arduino! "); - lcd.write(1); - -} - -void loop() { - // read the potentiometer on A0: - int sensorReading = analogRead(A0); - // map the result to 200 - 1000: - int delayTime = map(sensorReading, 0, 1023, 200, 1000); - // set the cursor to the bottom row, 5th position: - lcd.setCursor(4, 1); - // draw the little man, arms down: - lcd.write(3); - delay(delayTime); - lcd.setCursor(4, 1); - // draw him arms up: - lcd.write(4); - delay(delayTime); -} - - - diff --git a/libraries/SD/File.cpp b/libraries/SD/File.cpp index b93466ec1..88d9e9ac9 100644 --- a/libraries/SD/File.cpp +++ b/libraries/SD/File.cpp @@ -14,52 +14,137 @@ #include -void File::write(uint8_t val) { - SD.file.write(val); +/* for debugging file open/close leaks + uint8_t nfilecount=0; +*/ + +File::File(SdFile f, const char *n) { + // oh man you are kidding me, new() doesnt exist? Ok we do it by hand! + _file = (SdFile *)malloc(sizeof(SdFile)); + if (_file) { + memcpy(_file, &f, sizeof(SdFile)); + + strncpy(_name, n, 12); + _name[12] = 0; + + /* for debugging file open/close leaks + nfilecount++; + Serial.print("Created \""); + Serial.print(n); + Serial.print("\": "); + Serial.println(nfilecount, DEC); + */ + } } -void File::write(const char *str) { - SD.file.write(str); +File::File(void) { + _file = 0; + _name[0] = 0; + //Serial.print("Created empty file object"); } -void File::write(const uint8_t *buf, size_t size) { - SD.file.write(buf, size); +File::~File(void) { + // Serial.print("Deleted file object"); +} + +// returns a pointer to the file name +char *File::name(void) { + return _name; +} + +// a directory is a special type of file +boolean File::isDirectory(void) { + return (_file && _file->isDir()); +} + + +size_t File::write(uint8_t val) { + return write(&val, 1); +} + +size_t File::write(const uint8_t *buf, size_t size) { + size_t t; + if (!_file) { + setWriteError(); + return 0; + } + _file->clearWriteError(); + t = _file->write(buf, size); + if (_file->getWriteError()) { + setWriteError(); + return 0; + } + return t; } int File::peek() { - int c = SD.file.read(); - if (c != -1) SD.file.seekCur(-1); + if (! _file) + return 0; + + int c = _file->read(); + if (c != -1) _file->seekCur(-1); return c; } int File::read() { - return SD.file.read(); + if (_file) + return _file->read(); + return -1; +} + +// buffered read for more efficient, high speed reading +int File::read(void *buf, uint16_t nbyte) { + if (_file) + return _file->read(buf, nbyte); + return 0; } int File::available() { - return size() - position(); + if (! _file) return 0; + + uint32_t n = size() - position(); + + return n > 0X7FFF ? 0X7FFF : n; } void File::flush() { - SD.file.sync(); + if (_file) + _file->sync(); } boolean File::seek(uint32_t pos) { - return SD.file.seekSet(pos); + if (! _file) return false; + + return _file->seekSet(pos); } uint32_t File::position() { - return SD.file.curPosition(); + if (! _file) return -1; + return _file->curPosition(); } uint32_t File::size() { - return SD.file.fileSize(); + if (! _file) return 0; + return _file->fileSize(); } void File::close() { - SD.file.close(); + if (_file) { + _file->close(); + free(_file); + _file = 0; + + /* for debugging file open/close leaks + nfilecount--; + Serial.print("Deleted "); + Serial.println(nfilecount, DEC); + */ + } } File::operator bool() { - return SD.file.isOpen(); + if (_file) + return _file->isOpen(); + return false; } + diff --git a/libraries/SD/examples/CardInfo/CardInfo.pde b/libraries/SD/examples/CardInfo/CardInfo.pde deleted file mode 100644 index 7abfd33e4..000000000 --- a/libraries/SD/examples/CardInfo/CardInfo.pde +++ /dev/null @@ -1,111 +0,0 @@ -/* - SD card test - - This example shows how use the utility libraries on which the' - SD library is based in order to get info about your SD card. - Very useful for testing a card when you're not sure whether its working or not. - - The circuit: - * SD card attached to SPI bus as follows: - ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila - ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila - ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila - ** CS - depends on your SD card shield or module. - Pin 4 used here for consistency with other Arduino examples - - - created 28 Mar 2011 - by Limor Fried - modified 16 Mar 2011 - by Tom Igoe - */ - // include the SD library: -#include - -// set up variables using the SD utility library functions: -Sd2Card card; -SdVolume volume; -SdFile root; - -// change this to match your SD shield or module; -// Arduino Ethernet shield: pin 4 -// Adafruit SD shields and modules: pin 10 -// Sparkfun SD shield: pin 8 -const int chipSelect = 4; - -void setup() -{ - Serial.begin(9600); - Serial.print("\nInitializing SD card..."); - // On the Ethernet Shield, CS is pin 4. It's set as an output by default. - // Note that even if it's not used as the CS pin, the hardware SS pin - // (10 on most Arduino boards, 53 on the Mega) must be left as an output - // or the SD library functions will not work. - pinMode(10, OUTPUT); // change this to 53 on a mega - - - // we'll use the initialization code from the utility libraries - // since we're just testing if the card is working! - if (!card.init(SPI_HALF_SPEED, chipSelect)) { - Serial.println("initialization failed. Things to check:"); - Serial.println("* is a card is inserted?"); - Serial.println("* Is your wiring correct?"); - Serial.println("* did you change the chipSelect pin to match your shield or module?"); - return; - } else { - Serial.println("Wiring is correct and a card is present."); - } - - // print the type of card - Serial.print("\nCard type: "); - switch(card.type()) { - case SD_CARD_TYPE_SD1: - Serial.println("SD1"); - break; - case SD_CARD_TYPE_SD2: - Serial.println("SD2"); - break; - case SD_CARD_TYPE_SDHC: - Serial.println("SDHC"); - break; - default: - Serial.println("Unknown"); - } - - // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32 - if (!volume.init(card)) { - Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card"); - return; - } - - - // print the type and size of the first FAT-type volume - long volumesize; - Serial.print("\nVolume type is FAT"); - Serial.println(volume.fatType(), DEC); - Serial.println(); - - volumesize = volume.blocksPerCluster(); // clusters are collections of blocks - volumesize *= volume.clusterCount(); // we'll have a lot of clusters - volumesize *= 512; // SD card blocks are always 512 bytes - Serial.print("Volume size (bytes): "); - Serial.println(volumesize); - Serial.print("Volume size (Kbytes): "); - volumesize /= 1024; - Serial.println(volumesize); - Serial.print("Volume size (Mbytes): "); - volumesize /= 1024; - Serial.println(volumesize); - - - Serial.println("\nFiles found on the card (name, date and size in bytes): "); - root.openRoot(volume); - - // list all files in the card with date and size - root.ls(LS_R | LS_DATE | LS_SIZE); -} - - -void loop(void) { - -} diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp index 6df04d2f7..c15bdda0d 100755 --- a/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/libraries/SoftwareSerial/SoftwareSerial.cpp @@ -1,227 +1,515 @@ -/* - SoftwareSerial.cpp - Software serial library - Copyright (c) 2006 David A. Mellis. 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 -*/ - -/****************************************************************************** - * Includes - ******************************************************************************/ - -#include "WConstants.h" -#include "SoftwareSerial.h" - -/****************************************************************************** - * Definitions - ******************************************************************************/ - -/****************************************************************************** - * Constructors - ******************************************************************************/ - -SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin) -{ - _receivePin = receivePin; - _transmitPin = transmitPin; - _baudRate = 0; -} - -/****************************************************************************** - * User API - ******************************************************************************/ - -void SoftwareSerial::begin(long speed) -{ - _baudRate = speed; - _bitPeriod = 1000000 / _baudRate; - - digitalWrite(_transmitPin, HIGH); - delayMicroseconds( _bitPeriod); // if we were low this establishes the end -} - -int SoftwareSerial::read() -{ - int val = 0; - int bitDelay = _bitPeriod - clockCyclesToMicroseconds(50); - - // one byte of serial data (LSB first) - // ...--\ /--\/--\/--\/--\/--\/--\/--\/--\/--... - // \--/\--/\--/\--/\--/\--/\--/\--/\--/ - // start 0 1 2 3 4 5 6 7 stop - - while (digitalRead(_receivePin)); - - // confirm that this is a real start bit, not line noise - if (digitalRead(_receivePin) == LOW) { - // frame start indicated by a falling edge and low start bit - // jump to the middle of the low start bit - delayMicroseconds(bitDelay / 2 - clockCyclesToMicroseconds(50)); - - // offset of the bit in the byte: from 0 (LSB) to 7 (MSB) - for (int offset = 0; offset < 8; offset++) { - // jump to middle of next bit - delayMicroseconds(bitDelay); - - // read bit - val |= digitalRead(_receivePin) << offset; - } - - delayMicroseconds(_bitPeriod); - - return val; - } - - return -1; -} - -void SoftwareSerial::print(uint8_t b) -{ - if (_baudRate == 0) - return; - - int bitDelay = _bitPeriod - clockCyclesToMicroseconds(50); // a digitalWrite is about 50 cycles - byte mask; - - digitalWrite(_transmitPin, LOW); - delayMicroseconds(bitDelay); - - for (mask = 0x01; mask; mask <<= 1) { - if (b & mask){ // choose bit - digitalWrite(_transmitPin,HIGH); // send 1 - } - else{ - digitalWrite(_transmitPin,LOW); // send 1 - } - delayMicroseconds(bitDelay); - } - - digitalWrite(_transmitPin, HIGH); - delayMicroseconds(bitDelay); -} - -void SoftwareSerial::print(const char *s) -{ - while (*s) - print(*s++); -} - -void SoftwareSerial::print(char c) -{ - print((uint8_t) c); -} - -void SoftwareSerial::print(int n) -{ - print((long) n); -} - -void SoftwareSerial::print(unsigned int n) -{ - print((unsigned long) n); -} - -void SoftwareSerial::print(long n) -{ - if (n < 0) { - print('-'); - n = -n; - } - printNumber(n, 10); -} - -void SoftwareSerial::print(unsigned long n) -{ - printNumber(n, 10); -} - -void SoftwareSerial::print(long n, int base) -{ - if (base == 0) - print((char) n); - else if (base == 10) - print(n); - else - printNumber(n, base); -} - -void SoftwareSerial::println(void) -{ - print('\r'); - print('\n'); -} - -void SoftwareSerial::println(char c) -{ - print(c); - println(); -} - -void SoftwareSerial::println(const char c[]) -{ - print(c); - println(); -} - -void SoftwareSerial::println(uint8_t b) -{ - print(b); - println(); -} - -void SoftwareSerial::println(int n) -{ - print(n); - println(); -} - -void SoftwareSerial::println(long n) -{ - print(n); - println(); -} - -void SoftwareSerial::println(unsigned long n) -{ - print(n); - println(); -} - -void SoftwareSerial::println(long n, int base) -{ - print(n, base); - println(); -} - -// Private Methods ///////////////////////////////////////////////////////////// - -void SoftwareSerial::printNumber(unsigned long n, uint8_t base) -{ - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. - unsigned long i = 0; - - if (n == 0) { - print('0'); - return; - } - - while (n > 0) { - buf[i++] = n % base; - n /= base; - } - - for (; i > 0; i--) - print((char) (buf[i - 1] < 10 ? '0' + buf[i - 1] : 'A' + buf[i - 1] - 10)); -} +/* +SoftwareSerial.cpp (formerly NewSoftSerial.cpp) - +Multi-instance software serial library for Arduino/Wiring +-- Interrupt-driven receive and other improvements by ladyada + (http://ladyada.net) +-- Tuning, circular buffer, derivation from class Print/Stream, + multi-instance support, porting to 8MHz processors, + various optimizations, PROGMEM delay tables, inverse logic and + direct port writing by Mikal Hart (http://www.arduiniana.org) +-- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) +-- 20MHz processor support by Garrett Mace (http://www.macetech.com) +-- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) + +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 latest version of this library can always be found at +http://arduiniana.org. +*/ + +// When set, _DEBUG co-opts pins 11 and 13 for debugging with an +// oscilloscope or logic analyzer. Beware: it also slightly modifies +// the bit times, so don't rely on it too much at high baud rates +#define _DEBUG 0 +#define _DEBUG_PIN1 11 +#define _DEBUG_PIN2 13 +// +// Includes +// +#include +#include +#include "Arduino.h" +#include "SoftwareSerial.h" +// +// Lookup table +// +typedef struct _DELAY_TABLE +{ + long baud; + unsigned short rx_delay_centering; + unsigned short rx_delay_intrabit; + unsigned short rx_delay_stopbit; + unsigned short tx_delay; +} DELAY_TABLE; + +#if F_CPU == 16000000 + +static const DELAY_TABLE PROGMEM table[] = +{ + // baud rxcenter rxintra rxstop tx + { 115200, 1, 17, 17, 12, }, + { 57600, 10, 37, 37, 33, }, + { 38400, 25, 57, 57, 54, }, + { 31250, 31, 70, 70, 68, }, + { 28800, 34, 77, 77, 74, }, + { 19200, 54, 117, 117, 114, }, + { 14400, 74, 156, 156, 153, }, + { 9600, 114, 236, 236, 233, }, + { 4800, 233, 474, 474, 471, }, + { 2400, 471, 950, 950, 947, }, + { 1200, 947, 1902, 1902, 1899, }, + { 300, 3804, 7617, 7617, 7614, }, +}; + +const int XMIT_START_ADJUSTMENT = 5; + +#elif F_CPU == 8000000 + +static const DELAY_TABLE table[] PROGMEM = +{ + // baud rxcenter rxintra rxstop tx + { 115200, 1, 5, 5, 3, }, + { 57600, 1, 15, 15, 13, }, + { 38400, 2, 25, 26, 23, }, + { 31250, 7, 32, 33, 29, }, + { 28800, 11, 35, 35, 32, }, + { 19200, 20, 55, 55, 52, }, + { 14400, 30, 75, 75, 72, }, + { 9600, 50, 114, 114, 112, }, + { 4800, 110, 233, 233, 230, }, + { 2400, 229, 472, 472, 469, }, + { 1200, 467, 948, 948, 945, }, + { 300, 1895, 3805, 3805, 3802, }, +}; + +const int XMIT_START_ADJUSTMENT = 4; + +#elif F_CPU == 20000000 + +// 20MHz support courtesy of the good people at macegr.com. +// Thanks, Garrett! + +static const DELAY_TABLE PROGMEM table[] = +{ + // baud rxcenter rxintra rxstop tx + { 115200, 3, 21, 21, 18, }, + { 57600, 20, 43, 43, 41, }, + { 38400, 37, 73, 73, 70, }, + { 31250, 45, 89, 89, 88, }, + { 28800, 46, 98, 98, 95, }, + { 19200, 71, 148, 148, 145, }, + { 14400, 96, 197, 197, 194, }, + { 9600, 146, 297, 297, 294, }, + { 4800, 296, 595, 595, 592, }, + { 2400, 592, 1189, 1189, 1186, }, + { 1200, 1187, 2379, 2379, 2376, }, + { 300, 4759, 9523, 9523, 9520, }, +}; + +const int XMIT_START_ADJUSTMENT = 6; + +#else + +#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors + +#endif + +// +// Statics +// +SoftwareSerial *SoftwareSerial::active_object = 0; +char SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF]; +volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0; +volatile uint8_t SoftwareSerial::_receive_buffer_head = 0; + +// +// Debugging +// +// This function generates a brief pulse +// for debugging or measuring on an oscilloscope. +inline void DebugPulse(uint8_t pin, uint8_t count) +{ +#if _DEBUG + volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin)); + + uint8_t val = *pport; + while (count--) + { + *pport = val | digitalPinToBitMask(pin); + *pport = val; + } +#endif +} + +// +// Private methods +// + +/* static */ +inline void SoftwareSerial::tunedDelay(uint16_t delay) { + uint8_t tmp=0; + + asm volatile("sbiw %0, 0x01 \n\t" + "ldi %1, 0xFF \n\t" + "cpi %A0, 0xFF \n\t" + "cpc %B0, %1 \n\t" + "brne .-10 \n\t" + : "+r" (delay), "+a" (tmp) + : "0" (delay) + ); +} + +// This function sets the current object as the "listening" +// one and returns true if it replaces another +bool SoftwareSerial::listen() +{ + if (active_object != this) + { + _buffer_overflow = false; + uint8_t oldSREG = SREG; + cli(); + _receive_buffer_head = _receive_buffer_tail = 0; + active_object = this; + SREG = oldSREG; + return true; + } + + return false; +} + +// +// The receive routine called by the interrupt handler +// +void SoftwareSerial::recv() +{ + +#if GCC_VERSION < 40302 +// Work-around for avr-gcc 4.3.0 OSX version bug +// Preserve the registers that the compiler misses +// (courtesy of Arduino forum user *etracer*) + asm volatile( + "push r18 \n\t" + "push r19 \n\t" + "push r20 \n\t" + "push r21 \n\t" + "push r22 \n\t" + "push r23 \n\t" + "push r26 \n\t" + "push r27 \n\t" + ::); +#endif + + uint8_t d = 0; + + // If RX line is high, then we don't see any start bit + // so interrupt is probably not for us + if (_inverse_logic ? rx_pin_read() : !rx_pin_read()) + { + // Wait approximately 1/2 of a bit width to "center" the sample + tunedDelay(_rx_delay_centering); + DebugPulse(_DEBUG_PIN2, 1); + + // Read each of the 8 bits + for (uint8_t i=0x1; i; i <<= 1) + { + tunedDelay(_rx_delay_intrabit); + DebugPulse(_DEBUG_PIN2, 1); + uint8_t noti = ~i; + if (rx_pin_read()) + d |= i; + else // else clause added to ensure function timing is ~balanced + d &= noti; + } + + // skip the stop bit + tunedDelay(_rx_delay_stopbit); + DebugPulse(_DEBUG_PIN2, 1); + + if (_inverse_logic) + d = ~d; + + // if buffer full, set the overflow flag and return + if ((_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF != _receive_buffer_head) + { + // save new data in buffer: tail points to where byte goes + _receive_buffer[_receive_buffer_tail] = d; // save new byte + _receive_buffer_tail = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF; + } + else + { +#if _DEBUG // for scope: pulse pin as overflow indictator + DebugPulse(_DEBUG_PIN1, 1); +#endif + _buffer_overflow = true; + } + } + +#if GCC_VERSION < 40302 +// Work-around for avr-gcc 4.3.0 OSX version bug +// Restore the registers that the compiler misses + asm volatile( + "pop r27 \n\t" + "pop r26 \n\t" + "pop r23 \n\t" + "pop r22 \n\t" + "pop r21 \n\t" + "pop r20 \n\t" + "pop r19 \n\t" + "pop r18 \n\t" + ::); +#endif +} + +void SoftwareSerial::tx_pin_write(uint8_t pin_state) +{ + if (pin_state == LOW) + *_transmitPortRegister &= ~_transmitBitMask; + else + *_transmitPortRegister |= _transmitBitMask; +} + +uint8_t SoftwareSerial::rx_pin_read() +{ + return *_receivePortRegister & _receiveBitMask; +} + +// +// Interrupt handling +// + +/* static */ +inline void SoftwareSerial::handle_interrupt() +{ + if (active_object) + { + active_object->recv(); + } +} + +#if defined(PCINT0_vect) +ISR(PCINT0_vect) +{ + SoftwareSerial::handle_interrupt(); +} +#endif + +#if defined(PCINT1_vect) +ISR(PCINT1_vect) +{ + SoftwareSerial::handle_interrupt(); +} +#endif + +#if defined(PCINT2_vect) +ISR(PCINT2_vect) +{ + SoftwareSerial::handle_interrupt(); +} +#endif + +#if defined(PCINT3_vect) +ISR(PCINT3_vect) +{ + SoftwareSerial::handle_interrupt(); +} +#endif + +// +// Constructor +// +SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) : + _rx_delay_centering(0), + _rx_delay_intrabit(0), + _rx_delay_stopbit(0), + _tx_delay(0), + _buffer_overflow(false), + _inverse_logic(inverse_logic) +{ + setTX(transmitPin); + setRX(receivePin); +} + +// +// Destructor +// +SoftwareSerial::~SoftwareSerial() +{ + end(); +} + +void SoftwareSerial::setTX(uint8_t tx) +{ + pinMode(tx, OUTPUT); + digitalWrite(tx, HIGH); + _transmitBitMask = digitalPinToBitMask(tx); + uint8_t port = digitalPinToPort(tx); + _transmitPortRegister = portOutputRegister(port); +} + +void SoftwareSerial::setRX(uint8_t rx) +{ + pinMode(rx, INPUT); + if (!_inverse_logic) + digitalWrite(rx, HIGH); // pullup for normal logic! + _receivePin = rx; + _receiveBitMask = digitalPinToBitMask(rx); + uint8_t port = digitalPinToPort(rx); + _receivePortRegister = portInputRegister(port); +} + +// +// Public methods +// + +void SoftwareSerial::begin(long speed) +{ + _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; + + for (unsigned i=0; i - -class SoftwareSerial -{ - private: - uint8_t _receivePin; - uint8_t _transmitPin; - long _baudRate; - int _bitPeriod; - void printNumber(unsigned long, uint8_t); - public: - SoftwareSerial(uint8_t, uint8_t); - void begin(long); - int read(); - void print(char); - void print(const char[]); - void print(uint8_t); - void print(int); - void print(unsigned int); - void print(long); - void print(unsigned long); - void print(long, int); - void println(void); - void println(char); - void println(const char[]); - void println(uint8_t); - void println(int); - void println(long); - void println(unsigned long); - void println(long, int); -}; - -#endif - +/* +SoftwareSerial.h (formerly NewSoftSerial.h) - +Multi-instance software serial library for Arduino/Wiring +-- Interrupt-driven receive and other improvements by ladyada + (http://ladyada.net) +-- Tuning, circular buffer, derivation from class Print/Stream, + multi-instance support, porting to 8MHz processors, + various optimizations, PROGMEM delay tables, inverse logic and + direct port writing by Mikal Hart (http://www.arduiniana.org) +-- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) +-- 20MHz processor support by Garrett Mace (http://www.macetech.com) +-- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) + +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 latest version of this library can always be found at +http://arduiniana.org. +*/ + +#ifndef SoftwareSerial_h +#define SoftwareSerial_h + +#include +#include + +/****************************************************************************** +* Definitions +******************************************************************************/ + +#define _SS_MAX_RX_BUFF 64 // RX buffer size +#ifndef GCC_VERSION +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#endif + +class SoftwareSerial : public Stream +{ +private: + // per object data + uint8_t _receivePin; + uint8_t _receiveBitMask; + volatile uint8_t *_receivePortRegister; + uint8_t _transmitBitMask; + volatile uint8_t *_transmitPortRegister; + + uint16_t _rx_delay_centering; + uint16_t _rx_delay_intrabit; + uint16_t _rx_delay_stopbit; + uint16_t _tx_delay; + + uint16_t _buffer_overflow:1; + uint16_t _inverse_logic:1; + + // static data + static char _receive_buffer[_SS_MAX_RX_BUFF]; + static volatile uint8_t _receive_buffer_tail; + static volatile uint8_t _receive_buffer_head; + static SoftwareSerial *active_object; + + // private methods + void recv(); + uint8_t rx_pin_read(); + void tx_pin_write(uint8_t pin_state); + void setTX(uint8_t transmitPin); + void setRX(uint8_t receivePin); + + // private static method for timing + static inline void tunedDelay(uint16_t delay); + +public: + // public methods + SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false); + ~SoftwareSerial(); + void begin(long speed); + bool listen(); + void end(); + bool isListening() { return this == active_object; } + bool overflow() { bool ret = _buffer_overflow; _buffer_overflow = false; return ret; } + int peek(); + + virtual size_t write(uint8_t byte); + virtual int read(); + virtual int available(); + virtual void flush(); + + using Print::write; + + // public only for easy access by interrupt handlers + static inline void handle_interrupt(); +}; + +// Arduino 0012 workaround +#undef int +#undef char +#undef long +#undef byte +#undef float +#undef abs +#undef round + +#endif diff --git a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino new file mode 100644 index 000000000..1f535bdef --- /dev/null +++ b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino @@ -0,0 +1,21 @@ +#include + +SoftwareSerial mySerial(2, 3); + +void setup() +{ + Serial.begin(57600); + Serial.println("Goodnight moon!"); + + // set the data rate for the SoftwareSerial port + mySerial.begin(4800); + mySerial.println("Hello, world?"); +} + +void loop() // run over and over +{ + if (mySerial.available()) + Serial.write(mySerial.read()); + if (Serial.available()) + mySerial.write(Serial.read()); +} diff --git a/libraries/SoftwareSerial/keywords.txt b/libraries/SoftwareSerial/keywords.txt old mode 100644 new mode 100755 index de5a74c77..90d4c152d --- a/libraries/SoftwareSerial/keywords.txt +++ b/libraries/SoftwareSerial/keywords.txt @@ -1,17 +1,26 @@ ####################################### -# Syntax Coloring Map For Ultrasound +# Syntax Coloring Map for NewSoftSerial ####################################### ####################################### # Datatypes (KEYWORD1) ####################################### -SoftwareSerial KEYWORD1 +NewSoftSerial KEYWORD1 ####################################### # Methods and Functions (KEYWORD2) ####################################### +begin KEYWORD2 +end KEYWORD2 +read KEYWORD2 +available KEYWORD2 +isListening KEYWORD2 +overflow KEYWORD2 +flush KEYWORD2 +listen KEYWORD2 + ####################################### # Constants (LITERAL1) #######################################