diff --git a/.classpath b/.classpath index 71e8cc144..5f528e603 100644 --- a/.classpath +++ b/.classpath @@ -2,9 +2,11 @@ - - - - + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index ef277e5a2..a4e4441e5 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,10 +1,15 @@ -#Thu Jan 10 10:50:38 PST 2008 +#Tue Aug 16 19:08:40 CEST 2011 eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 0dba54f30..2e3d7b346 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -41,9 +41,9 @@ import processing.core.*; * files and images, etc) that comes from that. */ public class Base { - public static final int REVISION = 22; + public static final int REVISION = 100; /** This might be replaced by main() if there's a lib/version.txt file. */ - static String VERSION_NAME = "0022"; + static String VERSION_NAME = "0100"; /** Set true if this a proper release rather than a numbered revision. */ static public boolean RELEASE = false; @@ -349,6 +349,10 @@ public class Base { int opened = 0; for (int i = 0; i < count; i++) { String path = Preferences.get("last.sketch" + i + ".path"); + // don't automatically rename sketches that were left open from a + // pre-1.0 version of Arduino (wait for the user to explicitly open + // the sketch before renaming it). + if (path.toLowerCase().endsWith(".pde")) continue; int[] location; if (windowPositionValid) { String locationStr = Preferences.get("last.sketch" + i + ".location"); @@ -545,7 +549,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 +641,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"); } }); @@ -988,6 +993,13 @@ public class Base { } + public void onBoardOrPortChange() { + for (Editor editor : editors) { + editor.onBoardOrPortChange(); + } + } + + public void rebuildBoardsMenu(JMenu menu) { //System.out.println("rebuilding boards menu"); menu.removeAll(); @@ -1000,6 +1012,7 @@ public class Base { //System.out.println("Switching to " + target + ":" + board); Preferences.set("target", (String) getValue("target")); Preferences.set("board", (String) getValue("board")); + onBoardOrPortChange(); } }; action.putValue("target", target.getName()); @@ -1016,22 +1029,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); } } @@ -1091,7 +1110,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..dd6ad5614 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(); @@ -2032,14 +2048,65 @@ public class Editor extends JFrame implements RunnerListener { * modifications (if any) to the previous sketch need to be saved. */ protected boolean handleOpenInternal(String path) { + // rename .pde files to .ino + File[] oldFiles = (new File(path)).getParentFile().listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + return (name.toLowerCase().endsWith(".pde")); + } + }); + + if (oldFiles != null && oldFiles.length > 0) { + if (!Preferences.getBoolean("editor.update_extension")) { + Object[] options = { "OK", "Cancel" }; + String prompt = + "In Arduino 1.0, the file extension for sketches changed\n" + + "from \".pde\" to \".ino\". This version of the software only\n" + + "supports the new extension. Rename the files in this sketch\n" + + "(and future sketches) and continue?"; + + int result = JOptionPane.showOptionDialog(this, + prompt, + "New extension", + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + options, + options[0]); + if (result != JOptionPane.YES_OPTION) { + return false; + } + + Preferences.setBoolean("editor.update_extension", true); + } + + for (int i = 0; i < oldFiles.length; i++) { + String oldPath = oldFiles[i].getPath(); + File newFile = new File(oldPath.substring(0, oldPath.length() - 4) + ".ino"); + try { + Base.copyFile(oldFiles[i], newFile); + } catch (IOException e) { + Base.showWarning("Error", "Could not copy to a proper location.", e); + return false; + } + + // remove the original file, so user doesn't get confused + oldFiles[i].delete(); + + // update with the new path + if (oldFiles[i].compareTo(new File(path)) == 0) { + path = newFile.getAbsolutePath(); + } + } + } + // 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 pdeName = parentName + ".pde"; + String pdeName = parentName + ".ino"; File altFile = new File(file.getParent(), pdeName); - + if (pdeName.equals(file.getName())) { // no beef with this guy @@ -2049,10 +2116,10 @@ public class Editor extends JFrame implements RunnerListener { path = altFile.getAbsolutePath(); //System.out.println("found alt file in same folder"); - } else if (!path.endsWith(".pde")) { + } else if (!path.endsWith(".ino")) { 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", null); return false; } else { @@ -2252,6 +2319,7 @@ public class Editor extends JFrame implements RunnerListener { 0); if (result == null) return false; selectSerialPort(result); + base.onBoardOrPortChange(); return true; } @@ -2271,13 +2339,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 +2372,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 +2408,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 +2467,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 +2628,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 +2678,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 +2686,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 +2694,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 +2710,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 +2720,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 +2728,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 +2736,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 +2746,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/EditorLineStatus.java b/app/src/processing/app/EditorLineStatus.java index f28175ff0..2fcb8c917 100644 --- a/app/src/processing/app/EditorLineStatus.java +++ b/app/src/processing/app/EditorLineStatus.java @@ -25,6 +25,9 @@ package processing.app; import processing.app.syntax.*; import java.awt.*; +import java.awt.geom.Rectangle2D; +import java.util.Map; + import javax.swing.*; @@ -39,10 +42,14 @@ public class EditorLineStatus extends JComponent { Color foreground; Color background; + Color messageForeground; + Font font; int high; String text = ""; + String name = ""; + String serialport = ""; public EditorLineStatus(JEditTextArea textarea) { @@ -87,6 +94,11 @@ public class EditorLineStatus extends JComponent { public void paintComponent(Graphics g) { + if (name=="" && serialport=="") { + Map boardPreferences = Base.getBoardPreferences(); + setBoardName(boardPreferences.get("name")); + setSerialPort(Preferences.get("serial.port")); + } g.setColor(background); Dimension size = getSize(); g.fillRect(0, 0, size.width, size.height); @@ -96,11 +108,20 @@ public class EditorLineStatus extends JComponent { int baseline = (high + g.getFontMetrics().getAscent()) / 2; g.drawString(text, 6, baseline); + g.setColor(messageForeground); + String tmp = name + " on " + serialport; + + Rectangle2D bounds = g.getFontMetrics().getStringBounds(tmp, null); + + g.drawString(tmp, size.width - (int) bounds.getWidth() -20 , baseline); + if (Base.isMacOS()) { g.drawImage(resize, size.width - 20, 0, this); } } + public void setBoardName(String name) { this.name = name; } + public void setSerialPort(String serialport) { this.serialport = serialport; } public Dimension getPreferredSize() { return new Dimension(300, high); diff --git a/app/src/processing/app/EditorStatus.java b/app/src/processing/app/EditorStatus.java index a7035ab7c..a335b9230 100644 --- a/app/src/processing/app/EditorStatus.java +++ b/app/src/processing/app/EditorStatus.java @@ -40,6 +40,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { //static final int PROMPT = 2; //static final int EDIT = 3; static final int EDIT = 2; + static final int PROGRESS = 5; static final int YES = 1; static final int NO = 2; @@ -66,6 +67,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { JButton cancelButton; JButton okButton; JTextField editField; + JProgressBar progressBar; //Thread promptThread; int response; @@ -76,16 +78,22 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { empty(); if (bgcolor == null) { - bgcolor = new Color[3]; //4]; + bgcolor = new Color[6]; bgcolor[0] = Theme.getColor("status.notice.bgcolor"); bgcolor[1] = Theme.getColor("status.error.bgcolor"); bgcolor[2] = Theme.getColor("status.edit.bgcolor"); + bgcolor[3] = null; + bgcolor[4] = null; + bgcolor[5] = Theme.getColor("status.notice.bgcolor"); - fgcolor = new Color[3]; //4]; + fgcolor = new Color[6]; fgcolor[0] = Theme.getColor("status.notice.fgcolor"); fgcolor[1] = Theme.getColor("status.error.fgcolor"); fgcolor[2] = Theme.getColor("status.edit.fgcolor"); - } + fgcolor[3] = null; + fgcolor[4] = null; + fgcolor[5] = Theme.getColor("status.notice.fgcolor"); +} } @@ -163,6 +171,54 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { empty(); } + public void progress(String message) + { + mode = PROGRESS; + this.message = message; + progressBar.setIndeterminate(false); + progressBar.setVisible(true); + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + repaint(); + } + + + public void progressIndeterminate(String message) + { + mode = PROGRESS; + this.message = message; + progressBar.setIndeterminate(true); + progressBar.setValue(50); + progressBar.setVisible(true); + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + repaint(); + } + + + public void progressNotice(String message) { + //mode = NOTICE; + this.message = message; + //update(); + repaint(); + } + + + public void unprogress() + { + if (Preferences.getBoolean("editor.beep.compile")) { + Toolkit.getDefaultToolkit().beep(); + } + progressBar.setVisible(false); + progressBar.setValue(0); + setCursor(null); + //empty(); + } + + + public void progressUpdate(int value) + { + progressBar.setValue(value); + repaint(); + } /* public void update() { @@ -369,6 +425,19 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { }); add(editField); editField.setVisible(false); + + progressBar = new JProgressBar(JScrollBar.HORIZONTAL); + progressBar.setIndeterminate(false); + if (Base.isMacOS()) { + //progressBar.setBackground(bgcolor[PROGRESS]); + //progressBar.putClientProperty("JProgressBar.style", "circular"); + } + progressBar.setValue(0); + progressBar.setBorderPainted(true); + //progressBar.setStringPainted(true); + add(progressBar); + progressBar.setVisible(false); + } } @@ -385,11 +454,13 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { //noButton.setLocation(noLeft, top); cancelButton.setLocation(cancelLeft, top); okButton.setLocation(noLeft, top); + progressBar.setLocation(noLeft, top); //yesButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); //noButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); okButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); + progressBar.setSize(2*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT); // edit field height is awkward, and very different between mac and pc, // so use at least the preferred height for now. @@ -398,6 +469,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ { int editTop = (1 + sizeH - editHeight) / 2; // add 1 for ceil editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop, editWidth, editHeight); + progressBar.setBounds(noLeft, editTop, editWidth, editHeight); } diff --git a/app/src/processing/app/EditorToolbar.java b/app/src/processing/app/EditorToolbar.java index 74ef71f94..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; @@ -172,6 +170,10 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key x2[i] = x1[i] + BUTTON_WIDTH; offsetX = x2[i]; } + + // Serial button must be on the right + x1[SERIAL] = width - BUTTON_WIDTH - 14; + x2[SERIAL] = width - 14; } Graphics g = offscreen.getGraphics(); g.setColor(bgcolor); //getBackground()); @@ -196,9 +198,15 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key g2.drawString(status, statusX, statusY); */ if (currentRollover != -1) { - int statusY = (BUTTON_HEIGHT + g.getFontMetrics().getAscent()) / 2; + int statusY = (BUTTON_HEIGHT + g.getFontMetrics().getAscent()) / 2; String status = shiftPressed ? titleShift[currentRollover] : title[currentRollover]; - g.drawString(status, buttonCount * BUTTON_WIDTH + 3 * BUTTON_GAP, statusY); + if (currentRollover != SERIAL) + g.drawString(status, (buttonCount-1) * BUTTON_WIDTH + 3 * BUTTON_GAP, statusY); + else { + int statusX = x1[SERIAL] - BUTTON_GAP; + statusX -= g.getFontMetrics().stringWidth(status); + g.drawString(status, statusX, statusY); + } } screen.drawImage(offscreen, 0, 0, null); @@ -312,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 ffc63f7ae..315620033 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; @@ -279,6 +281,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 = @@ -461,6 +478,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()); @@ -516,6 +535,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")); @@ -751,8 +772,9 @@ public class Preferences { s = st.nextToken(); boolean bold = (s.indexOf("bold") != -1); boolean italic = (s.indexOf("italic") != -1); + boolean underlined = (s.indexOf("underlined") != -1); //System.out.println(what + " = " + str + " " + bold + " " + italic); - return new SyntaxStyle(color, italic, bold); + return new SyntaxStyle(color, italic, bold, underlined); } } diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 801067c5e..93b8e40dc 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -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, @@ -860,7 +860,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 +1261,7 @@ public class Sketch { StringBuffer bigCode = new StringBuffer(); int bigCount = 0; for (SketchCode sc : code) { - if (sc.isExtension("pde")) { + if (sc.isExtension("ino")) { sc.setPreprocOffset(bigCount); bigCode.append(sc.getProgram()); bigCode.append('\n'); @@ -1357,7 +1357,7 @@ public class Sketch { } // sc.setPreprocName(filename); - } else if (sc.isExtension("pde")) { + } else if (sc.isExtension("ino")) { // The compiler and runner will need this to have a proper offset sc.addPreprocOffset(headerOffset); } @@ -1386,7 +1386,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 +1507,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 +1521,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 +1553,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 +1567,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 +1600,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 +1610,7 @@ public class Sketch { uploader = new AvrdudeUploader(); boolean success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, - verbose); + usingProgrammer); return success ? suggestedClassName : null; } @@ -1791,7 +1799,7 @@ public class Sketch { * Returns the default extension for this editor setup. */ public String getDefaultExtension() { - return "pde"; + return "ino"; } @@ -1799,7 +1807,7 @@ public class Sketch { * Returns a String[] array of proper extensions. */ public String[] getExtensions() { - return new String[] { "pde", "c", "cpp", "h" }; + return new String[] { "ino", "c", "cpp", "h" }; } diff --git a/app/src/processing/app/Theme.java b/app/src/processing/app/Theme.java index 8b68f4f45..373b56835 100644 --- a/app/src/processing/app/Theme.java +++ b/app/src/processing/app/Theme.java @@ -196,7 +196,8 @@ public class Theme { s = st.nextToken(); boolean bold = (s.indexOf("bold") != -1); boolean italic = (s.indexOf("italic") != -1); + boolean underlined = (s.indexOf("underlined") != -1); - return new SyntaxStyle(color, italic, bold); + return new SyntaxStyle(color, italic, bold, underlined); } } \ No newline at end of file diff --git a/app/src/processing/app/debug/AvrdudeUploader.java b/app/src/processing/app/debug/AvrdudeUploader.java index 97ef91a20..a30f56614 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/Compiler.java b/app/src/processing/app/debug/Compiler.java index f2fa5e26d..559df3a61 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -86,23 +86,42 @@ public class Compiler implements MessageConsumer { corePath = coreFolder.getAbsolutePath(); } else { Target t = Base.targetsTable.get(core.substring(0, core.indexOf(':'))); - File coresFolder = new File(t.getFolder(), "cores"); - File coreFolder = new File(coresFolder, core.substring(core.indexOf(':') + 1)); + File coreFolder = new File(t.getFolder(), "cores"); + coreFolder = new File(coreFolder, core.substring(core.indexOf(':') + 1)); corePath = coreFolder.getAbsolutePath(); } + String variant = boardPreferences.get("build.variant"); + String variantPath = null; + + if (variant != null) { + if (variant.indexOf(':') == -1) { + Target t = Base.getTarget(); + File variantFolder = new File(new File(t.getFolder(), "variants"), variant); + variantPath = variantFolder.getAbsolutePath(); + } else { + Target t = Base.targetsTable.get(variant.substring(0, variant.indexOf(':'))); + File variantFolder = new File(t.getFolder(), "variants"); + variantFolder = new File(variantFolder, variant.substring(variant.indexOf(':') + 1)); + variantPath = variantFolder.getAbsolutePath(); + } + } + List objectFiles = new ArrayList(); // 0. include paths for core + all libraries + sketch.setCompilingProgress(20); List includePaths = new ArrayList(); includePaths.add(corePath); + if (variantPath != null) includePaths.add(variantPath); for (File file : sketch.getImportedLibraries()) { includePaths.add(file.getPath()); } // 1. compile the sketch (already in the buildPath) + sketch.setCompilingProgress(30); objectFiles.addAll( compileFiles(avrBasePath, buildPath, includePaths, findFilesInPath(buildPath, "S", false), @@ -112,6 +131,7 @@ public class Compiler implements MessageConsumer { // 2. compile the libraries, outputting .o files to: // + sketch.setCompilingProgress(40); for (File libraryFolder : sketch.getImportedLibraries()) { File outputFolder = new File(buildPath, libraryFolder.getName()); File utilityFolder = new File(libraryFolder, "utility"); @@ -139,8 +159,10 @@ public class Compiler implements MessageConsumer { // 3. compile the core, outputting .o files to and then // collecting them into the core.a library file. + sketch.setCompilingProgress(50); includePaths.clear(); includePaths.add(corePath); // include path for core only + if (variantPath != null) includePaths.add(variantPath); List coreObjectFiles = compileFiles(avrBasePath, buildPath, includePaths, findFilesInPath(corePath, "S", true), @@ -162,6 +184,7 @@ public class Compiler implements MessageConsumer { // 4. link it all together into the .elf file + sketch.setCompilingProgress(60); List baseCommandLinker = new ArrayList(Arrays.asList(new String[] { avrBasePath + "avr-gcc", "-Os", @@ -190,6 +213,7 @@ public class Compiler implements MessageConsumer { List commandObjcopy; // 5. extract EEPROM data (from EEMEM directive) to .eep file. + sketch.setCompilingProgress(70); commandObjcopy = new ArrayList(baseCommandObjcopy); commandObjcopy.add(2, "ihex"); commandObjcopy.set(3, "-j"); @@ -203,6 +227,7 @@ public class Compiler implements MessageConsumer { execAsynchronously(commandObjcopy); // 6. build the .hex file + sketch.setCompilingProgress(80); commandObjcopy = new ArrayList(baseCommandObjcopy); commandObjcopy.add(2, "ihex"); commandObjcopy.add(".eeprom"); // remove eeprom data @@ -210,6 +235,8 @@ public class Compiler implements MessageConsumer { commandObjcopy.add(buildPath + File.separator + primaryClassName + ".hex"); execAsynchronously(commandObjcopy); + sketch.setCompilingProgress(90); + return true; } @@ -367,7 +394,13 @@ public class Compiler implements MessageConsumer { e = new RunnerException("Please import the SPI library from the Sketch > Import Library menu."); s += "\nAs of Arduino 0019, the Ethernet library depends on the SPI library." + "\nYou appear to be using it or another library that depends on the SPI library."; - } + } + + if (pieces[3].trim().equals("'BYTE' was not declared in this scope")) { + e = new RunnerException("The 'BYTE' keyword is no longer supported."); + s += "\nAs of Arduino 1.0, the 'BYTE' keyword is no longer supported." + + "\nPlease use Serial.write() instead."; + } if (exception == null && e != null) { exception = e; diff --git a/app/src/processing/app/debug/Uploader.java b/app/src/processing/app/debug/Uploader.java index 16e3d33d8..03d8f2f30 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/preproc/PdePreprocessor.java b/app/src/processing/app/preproc/PdePreprocessor.java index 2deaa15aa..2b4f03e85 100644 --- a/app/src/processing/app/preproc/PdePreprocessor.java +++ b/app/src/processing/app/preproc/PdePreprocessor.java @@ -46,7 +46,7 @@ public class PdePreprocessor { public int prototypeCount = 0; // stores number of included library headers written - // we always write one header: WProgram.h + // we always write one header: Arduino.h public int headerCount = 1; // the prototypes that are generated by the preprocessor @@ -199,7 +199,7 @@ public class PdePreprocessor { int prototypeInsertionPoint = firstStatement(program); out.print(program.substring(0, prototypeInsertionPoint)); - out.print("#include \"WProgram.h\"\n"); + out.print("#include \"Arduino.h\"\n"); // print user defined prototypes for (int i = 0; i < prototypes.size(); i++) { diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index d5c01c48a..3c1548fbd 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -2045,6 +2045,17 @@ public class JEditTextArea extends JComponent } } + public String checkClickedURL(String line, int offset) { + String[] parse = SyntaxUtilities.parseCommentUrls(line); + if (parse==null) + return null; + int start = parse[0].length(); + int stop = start + parse[1].length(); + if (offsetstop) + return null; + return parse[1]; + } + class MouseHandler extends MouseAdapter { public void mousePressed(MouseEvent evt) @@ -2095,6 +2106,13 @@ public class JEditTextArea extends JComponent private void doSingleClick(MouseEvent evt, int line, int offset, int dot) { + // Check for click on urls + String clickedURL = checkClickedURL(getLineText(line), offset); + if (clickedURL != null) { + Base.openURL(clickedURL); + return; + } + if ((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) { rectSelect = (evt.getModifiers() & InputEvent.CTRL_MASK) != 0; select(getMarkPosition(),dot); diff --git a/app/src/processing/app/syntax/PdeTextAreaDefaults.java b/app/src/processing/app/syntax/PdeTextAreaDefaults.java index b715255be..382c69aaf 100644 --- a/app/src/processing/app/syntax/PdeTextAreaDefaults.java +++ b/app/src/processing/app/syntax/PdeTextAreaDefaults.java @@ -169,6 +169,9 @@ public class PdeTextAreaDefaults extends TextAreaDefaults { // ?? styles[Token.LABEL] = Theme.getStyle("label"); + // http://arduino.cc/ + styles[Token.URL] = Theme.getStyle("url"); + // + - = / styles[Token.OPERATOR] = Theme.getStyle("operator"); diff --git a/app/src/processing/app/syntax/SyntaxStyle.java b/app/src/processing/app/syntax/SyntaxStyle.java index 56323c3cc..ac3dd797d 100644 --- a/app/src/processing/app/syntax/SyntaxStyle.java +++ b/app/src/processing/app/syntax/SyntaxStyle.java @@ -10,6 +10,10 @@ package processing.app.syntax; import java.awt.*; +import java.awt.font.TextAttribute; +import java.util.Hashtable; +import java.util.Map; + import javax.swing.JComponent; @@ -27,11 +31,12 @@ public class SyntaxStyle * @param italic True if the text should be italics * @param bold True if the text should be bold */ - public SyntaxStyle(Color color, boolean italic, boolean bold) + public SyntaxStyle(Color color, boolean italic, boolean bold, boolean underlined) { this.color = color; this.italic = italic; this.bold = bold; + this.underlined = underlined; } /** @@ -47,7 +52,7 @@ public class SyntaxStyle */ public boolean isPlain() { - return !(bold || italic); + return !(bold || italic || underlined); } /** @@ -67,7 +72,14 @@ public class SyntaxStyle } /** - * Returns the specified font, but with the style's bold and + * @return true if underline is enabled for this style. + */ + public boolean isUnderlined() { + return underlined; + } + + /** + * Returns the specified font, but with the style's bold, underline and * italic flags applied. */ public Font getStyledFont(Font font) @@ -78,10 +90,16 @@ public class SyntaxStyle if(font.equals(lastFont)) return lastStyledFont; lastFont = font; + lastStyledFont = new Font(font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize()); + if (underlined) { + Map attr = new Hashtable(); + attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); + lastStyledFont = lastStyledFont.deriveFont(attr); + } return lastStyledFont; } @@ -100,6 +118,11 @@ public class SyntaxStyle (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize()); + if (underlined) { + Map attr = new Hashtable(); + attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); + lastStyledFont = lastStyledFont.deriveFont(attr); + } //fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(lastStyledFont); fontMetrics = comp.getFontMetrics(lastStyledFont); return fontMetrics; @@ -125,13 +148,16 @@ public class SyntaxStyle { return getClass().getName() + "[color=" + color + (italic ? ",italic" : "") + - (bold ? ",bold" : "") + "]"; + (bold ? ",bold" : "") + + (underlined ? ",underlined" : "") + + "]"; } // private members private Color color; private boolean italic; private boolean bold; + private boolean underlined; private Font lastFont; private Font lastStyledFont; private FontMetrics fontMetrics; diff --git a/app/src/processing/app/syntax/SyntaxUtilities.java b/app/src/processing/app/syntax/SyntaxUtilities.java index 5225d0b73..1e3c6c900 100644 --- a/app/src/processing/app/syntax/SyntaxUtilities.java +++ b/app/src/processing/app/syntax/SyntaxUtilities.java @@ -11,6 +11,8 @@ package processing.app.syntax; import javax.swing.text.*; import java.awt.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** @@ -93,16 +95,17 @@ public class SyntaxUtilities { SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT]; - styles[Token.COMMENT1] = new SyntaxStyle(Color.black,true,false); - styles[Token.COMMENT2] = new SyntaxStyle(new Color(0x990033),true,false); - styles[Token.KEYWORD1] = new SyntaxStyle(Color.black,false,true); - styles[Token.KEYWORD2] = new SyntaxStyle(Color.magenta,false,false); - styles[Token.KEYWORD3] = new SyntaxStyle(new Color(0x009600),false,false); - styles[Token.LITERAL1] = new SyntaxStyle(new Color(0x650099),false,false); - styles[Token.LITERAL2] = new SyntaxStyle(new Color(0x650099),false,true); - styles[Token.LABEL] = new SyntaxStyle(new Color(0x990033),false,true); - styles[Token.OPERATOR] = new SyntaxStyle(Color.black,false,true); - styles[Token.INVALID] = new SyntaxStyle(Color.red,false,true); + styles[Token.COMMENT1] = new SyntaxStyle(Color.black,true,false,false); + styles[Token.COMMENT2] = new SyntaxStyle(new Color(0x990033),true,false,false); + styles[Token.KEYWORD1] = new SyntaxStyle(Color.black,false,true,false); + styles[Token.KEYWORD2] = new SyntaxStyle(Color.magenta,false,false,false); + styles[Token.KEYWORD3] = new SyntaxStyle(new Color(0x009600),false,false,false); + styles[Token.LITERAL1] = new SyntaxStyle(new Color(0x650099),false,false,false); + styles[Token.LITERAL2] = new SyntaxStyle(new Color(0x650099),false,true,false); + styles[Token.LABEL] = new SyntaxStyle(new Color(0x990033),false,true,false); + styles[Token.OPERATOR] = new SyntaxStyle(Color.black,false,true,false); + styles[Token.URL] = new SyntaxStyle(Color.blue,true,false,false); + styles[Token.INVALID] = new SyntaxStyle(Color.red,false,true,false); return styles; } @@ -148,7 +151,10 @@ public class SyntaxUtilities styles[id].setGraphicsFlags(gfx,defaultFont); line.count = length; - x = Utilities.drawTabbedText(line,x,y,gfx,expander,0); + if (id == Token.COMMENT1 || id == Token.COMMENT2) + x = drawTabbedCommentsText(line, x, y, gfx, expander, styles, styles[id]); + else + x = Utilities.drawTabbedText(line, x, y, gfx, expander, 0); line.offset += length; offset += length; @@ -158,6 +164,66 @@ public class SyntaxUtilities return x; } + /** + * Parse comments and identify "@schematics <something>" pattern. + * + * @param line + * A string to parse + * @return null if the pattern is not found, otherwise an array of + * String is returned: the elements with index 0, 1 and 2 are + * respectively the preamble, the <something> stuff, and + * the remaining part of the string. + */ + public static String[] parseCommentUrls(String line) { + Matcher m = urlPattern.matcher(line.toString()); + if (!m.find()) + return null; + + String res[] = new String[3]; + res[0] = line.substring(0, m.start(1)); + res[1] = line.substring(m.start(1), m.end(1)); + res[2] = line.substring(m.end(1)); + // System.out.println("0 =>"+res[0]+"<\n1 =>"+res[1]+"< \n2 =>"+res[2]+"<"); + return res; + } + + static private Pattern urlPattern = Pattern.compile( + "((?:https?|ftp)://" + // ( Protocol + "(?:(?:[\\w_\\-]+:)?[\\w_\\-]+@)?" + // Username and password + "(?:[\\w_\\-]+\\.)+[\\w_\\-]+" + // Domain name + "(?::[0-9]{1,5})?" + // Port + "(?:/[\\w_\\-./?%&=+]*)?)" + // Path ) + "(?:\\s|$)"); // whitespace or EOL + + public static Segment stringToSegment(String v) { + return new Segment(v.toCharArray(), 0, v.length()); + } + + private static int drawTabbedCommentsText(Segment line, int x, int y, + Graphics gfx, TabExpander expander, SyntaxStyle[] styles, + SyntaxStyle commentStyle) { + + String parse[] = parseCommentUrls(line.toString()); + if (parse == null) + // Revert to plain writing. + return Utilities.drawTabbedText(line, x, y, gfx, expander, 0); + Segment pre = stringToSegment(parse[0]); + Segment tag = stringToSegment(parse[1]); + Segment post = stringToSegment(parse[2]); + + if (pre.count>0) + x = Utilities.drawTabbedText(pre, x, y, gfx, expander, 0); + + Font f = gfx.getFont(); + styles[Token.URL].setGraphicsFlags(gfx, f); + x = Utilities.drawTabbedText(tag, x, y, gfx, expander, 0); + + commentStyle.setGraphicsFlags(gfx, f); + if (post.count>0) + x = Utilities.drawTabbedText(post, x, y, gfx, expander, 0); + return x; + } + // private members private SyntaxUtilities() {} } diff --git a/app/src/processing/app/syntax/Token.java b/app/src/processing/app/syntax/Token.java index a0f73bebf..06dc26323 100644 --- a/app/src/processing/app/syntax/Token.java +++ b/app/src/processing/app/syntax/Token.java @@ -83,17 +83,22 @@ public class Token */ public static final byte OPERATOR = 9; + /** + * URL token id. + */ + public static final byte URL = 10; + /** * Invalid token id. This can be used to mark invalid * or incomplete tokens, so the user can easily spot * syntax errors. */ - public static final byte INVALID = 10; + public static final byte INVALID = 11; /** * The total number of defined token ids. */ - public static final byte ID_COUNT = 11; + public static final byte ID_COUNT = 12; /** * The first id that can be used for internal state 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/build.xml b/build/build.xml index 1e5f0259b..d6e00e2bd 100644 --- a/build/build.xml +++ b/build/build.xml @@ -1,17 +1,23 @@ + + + + + value="linux"> + @@ -317,13 +323,23 @@ + + + + + + description="Run Linux (32-bit) version"> - + + + + diff --git a/build/linux/dist/lib/librxtxSerial64.so b/build/linux/dist/lib/librxtxSerial64.so new file mode 100755 index 000000000..853b87a22 Binary files /dev/null and b/build/linux/dist/lib/librxtxSerial64.so differ diff --git a/build/linux/dist/tools/avrdude64 b/build/linux/dist/tools/avrdude64 new file mode 100755 index 000000000..f13912adc Binary files /dev/null and b/build/linux/dist/tools/avrdude64 differ diff --git a/build/macosx/template.app/Contents/Info.plist b/build/macosx/template.app/Contents/Info.plist index f9dc41c24..2233d7278 100755 --- a/build/macosx/template.app/Contents/Info.plist +++ b/build/macosx/template.app/Contents/Info.plist @@ -7,11 +7,11 @@ CFBundleGetInfoString - 0022 + 1.0-beta2 CFBundleVersion - 0022 + 0100 CFBundleShortVersionString - 0022 + 1.0-beta2 CFBundleAllowMixedLocalizations @@ -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/macosx/template.dmg.gz b/build/macosx/template.dmg.gz index 97aeb21d4..70405c676 100644 Binary files a/build/macosx/template.dmg.gz and b/build/macosx/template.dmg.gz differ diff --git a/build/shared/examples/4.Communication/ASCIITable/ASCIITable.pde b/build/shared/examples/4.Communication/ASCIITable/ASCIITable.pde index 3678836b3..c92b0d023 100644 --- a/build/shared/examples/4.Communication/ASCIITable/ASCIITable.pde +++ b/build/shared/examples/4.Communication/ASCIITable/ASCIITable.pde @@ -38,7 +38,7 @@ void loop() // prints value unaltered, i.e. the raw binary version of the // byte. The serial monitor interprets all bytes as // ASCII, so 33, the first number, will show up as '!' - Serial.print(thisByte, BYTE); + Serial.write(thisByte); Serial.print(", dec: "); // prints value as string as an ASCII-encoded decimal (base 10). diff --git a/build/shared/examples/4.Communication/Dimmer/Dimmer.pde b/build/shared/examples/4.Communication/Dimmer/Dimmer.pde index 3eb92b049..2985ddaee 100644 --- a/build/shared/examples/4.Communication/Dimmer/Dimmer.pde +++ b/build/shared/examples/4.Communication/Dimmer/Dimmer.pde @@ -84,281 +84,29 @@ void loop() { /* Max/MSP v5 patch for this example - { - "boxes" : [ { - "box" : { - "maxclass" : "comment", - "text" : "Dimmer\n\nThis patch sends a binary number from 0 to 255 out the serial port to an Arduino connected to the port. It dims an LED attached to the Arduino.\n\ncreated 2006\nby David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe", - "linecount" : 10, - "patching_rect" : [ 209.0, 55.0, 344.0, 144.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-32", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "change the slider to alter the brightness of the LED", - "linecount" : 3, - "patching_rect" : [ 90.0, 235.0, 117.0, 48.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-7", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 215.0, 385.0, 50.0, 19.0 ], - "numoutlets" : 2, - "fontsize" : 10.0, - "outlettype" : [ "int", "bang" ], - "id" : "obj-6", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "slider", - "patching_rect" : [ 215.0, 235.0, 20.0, 140.0 ], - "numoutlets" : 1, - "outlettype" : [ "" ], - "bgcolor" : [ 0.94902, 0.94902, 0.94902, 0.0 ], - "id" : "obj-1", - "size" : 256.0, - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "select 0 1", - "patching_rect" : [ 342.0, 305.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" : [ 390.0, 396.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" : [ 415.0, 370.0, 206.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-27", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "message", - "text" : "close", - "patching_rect" : [ 342.0, 396.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" : [ 364.0, 370.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" : [ 435.0, 344.0, 207.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-2", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 342.0, 268.0, 15.0, 15.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-11", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "message", - "text" : "print", - "patching_rect" : [ 384.0, 344.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" : [ 259.0, 420.0, 84.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "int", "" ], - "id" : "obj-14", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Click to start", - "patching_rect" : [ 369.0, 268.0, 117.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-17", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "panel", - "patching_rect" : [ 215.0, 235.0, 21.0, 139.0 ], - "numoutlets" : 0, - "mode" : 1, - "grad1" : [ 1.0, 1.0, 1.0, 1.0 ], - "id" : "obj-8", - "grad2" : [ 0.509804, 0.509804, 0.509804, 1.0 ], - "numinlets" : 1, - "angle" : 270.0 - } - - } - ], - "lines" : [ { - "patchline" : { - "source" : [ "obj-11", 0 ], - "destination" : [ "obj-30", 0 ], - "hidden" : 0, - "midpoints" : [ 351.0, 296.0, 351.5, 296.0 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-30", 1 ], - "destination" : [ "obj-19", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-30", 0 ], - "destination" : [ "obj-21", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-21", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 351.5, 416.5, 268.5, 416.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-19", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 373.5, 393.5, 268.5, 393.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-13", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 393.5, 365.5, 268.5, 365.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-1", 0 ], - "destination" : [ "obj-6", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-6", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 224.5, 411.5, 268.5, 411.5 ] - } - - } - ] - } +----------begin_max5_patcher---------- +1008.3ocuXszaiaCD9r8uhA5rqAeHIa0aAMaAVf1S6hdoYQAsDiL6JQZHQ2M +YWr+2KeX4vjnjXKKkKhhiGQ9MeyCNz+X9rnMp63sQvuB+MLa1OlOalSjUvrC +ymEUytKuh05TKJWUWyk5nE9eSyuS6jesvHu4F4MxOuUzB6X57sPKWVzBLXiP +xZtGj6q2vafaaT0.BzJfjj.p8ZPukazsQvpfcpFs8mXR3plh8BoBxURIOWyK +rxspZ0YI.eTCEh5Vqp+wGtFXZMKe6CZc3yWZwTdCmYW.BBkdiby8v0r+ST.W +sD9SdUkn8FYspPbqvnBNFtZWiUyLmleJWo0vuKzeuj2vpJLaWA7YiE7wREui +FpDFDp1KcbAFcP5sJoVxp4NB5Jq40ougIDxJt1wo3GDZHiNocKhiIExx+owv +AdOEAksDs.RRrOoww1Arc.9RvN2J9tamwjkcqknvAE0l+8WnjHqreNet8whK +z6mukIK4d+Xknv3jstvJs8EirMMhxsZIusET25jXbX8xczIl5xPVxhPcTGFu +xNDu9rXtUCg37g9Q8Yc+EuofIYmg8QdkPCrOnXsaHwYs3rWx9PGsO+pqueG2 +uNQBqWFh1X7qQG+3.VHcHrfO1nyR2TlqpTM9MDsLKNCQVz6KO.+Sfc5j1Ykj +jzkn2jwNDRP7LVb3d9LtoWBAOnvB92Le6yRmZ4UF7YpQhiFi7A5Ka8zXhKdA +4r9TRGG7V4COiSbAJKdXrWNhhF0hNUh7uBa4Mba0l7JUK+omjDMwkSn95Izr +TOwkdp7W.oPRmNRQsiKeu4j3CkfVgt.NYPEYqMGvvJ48vIlPiyzrIuZskWIS +xGJPcmPiWOfLodybH3wjPbMYwlbFIMNHPHFOtLBNaLSa9sGk1TxMzCX5KTa6 +WIH2ocxSdngM0QPqFRxyPHFsprrhGc9Gy9xoBjz0NWdR2yW9DUa2F85jG2v9 +FgTO4Q8qiC7fzzQNpmNpsY3BrYPVJBMJQ1uVmoItRhw9NrVGO3NMNzYZ+zS7 +3WTvTOnUydG5kHMKLqAOjTe7fN2bGSxOZDkMrBrGQ9J1gONBEy0k4gVo8qHc +cxmfxVihWz6a3yqY9NazzUYkua9UnynadOtogW.JfsVGRVNEbWF8I+eHtcwJ ++wLXqZeSdWLo+FQF6731Tva0BISKTx.cLwmgJsUTTvkg1YsnXmxDge.CDR7x +D6YmX6fMznaF7kdczmJXwm.XSOOrdoHhNA7GMiZYLZZR.+4lconMaJP6JOZ8 +ftCs1YWHZI3o.sIXezX5ihMSuXzZtk3ai1mXRSczoCS32hAydeyXNEu5SHyS +xqZqbd3ZLdera1iPqYxOm++v7SUSz +-----------end_max5_patcher----------- */ diff --git a/build/shared/examples/4.Communication/Graph/Graph.pde b/build/shared/examples/4.Communication/Graph/Graph.pde index c1e39ac3f..03e868b9b 100644 --- a/build/shared/examples/4.Communication/Graph/Graph.pde +++ b/build/shared/examples/4.Communication/Graph/Graph.pde @@ -107,473 +107,43 @@ void loop() { */ /* Max/MSP v5 patch for this example - { - "boxes" : [ { - "box" : { - "maxclass" : "comment", - "text" : "Graph\n\nThis patch takes a string, containing ASCII formatted number from 0 to 1023, with a carriage return and linefeed at the end. It converts the string to an integer and graphs it.\n\ncreated 2006\nby David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe", - "linecount" : 10, - "patching_rect" : [ 479.0, 6.0, 344.0, 144.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-32", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "select 0 1", - "patching_rect" : [ 327.0, 80.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" : [ 412.0, 231.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" : [ 412.0, 205.0, 206.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-27", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "message", - "text" : "close", - "patching_rect" : [ 327.0, 231.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" : [ 349.0, 205.0, 41.0, 18.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-19", - "fontname" : "Arial", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "multislider", - "candicane7" : [ 0.878431, 0.243137, 0.145098, 1.0 ], - "patching_rect" : [ 302.0, 450.0, 246.0, 167.0 ], - "contdata" : 1, - "numoutlets" : 2, - "peakcolor" : [ 0.498039, 0.498039, 0.498039, 1.0 ], - "slidercolor" : [ 0.066667, 0.058824, 0.776471, 1.0 ], - "candicane8" : [ 0.027451, 0.447059, 0.501961, 1.0 ], - "outlettype" : [ "", "" ], - "setminmax" : [ 0.0, 1023.0 ], - "settype" : 0, - "candicane6" : [ 0.733333, 0.035294, 0.788235, 1.0 ], - "setstyle" : 3, - "bgcolor" : [ 0.231373, 0.713726, 1.0, 1.0 ], - "id" : "obj-1", - "candicane4" : [ 0.439216, 0.619608, 0.070588, 1.0 ], - "candicane5" : [ 0.584314, 0.827451, 0.431373, 1.0 ], - "candicane2" : [ 0.145098, 0.203922, 0.356863, 1.0 ], - "candicane3" : [ 0.290196, 0.411765, 0.713726, 1.0 ], - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Click here to get a list of serial ports", - "patching_rect" : [ 412.0, 179.0, 207.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-2", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Here's the number from Arduino's analog input", - "linecount" : 2, - "patching_rect" : [ 153.0, 409.0, 138.0, 34.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-3", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Convert ASCII to symbol", - "patching_rect" : [ 379.0, 378.0, 147.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-4", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Convert integer to ASCII", - "patching_rect" : [ 379.0, 355.0, 147.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-5", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 302.0, 414.0, 37.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "int", "bang" ], - "bgcolor" : [ 0.866667, 0.866667, 0.866667, 1.0 ], - "id" : "obj-6", - "triscale" : 0.9, - "fontname" : "Arial", - "htextcolor" : [ 0.870588, 0.870588, 0.870588, 1.0 ], - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "fromsymbol", - "patching_rect" : [ 302.0, 378.0, 74.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-7", - "fontname" : "Arial", - "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "itoa", - "patching_rect" : [ 302.0, 355.0, 46.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-8", - "fontname" : "Arial", - "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], - "numinlets" : 3 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "zl group 4", - "patching_rect" : [ 302.0, 332.0, 64.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "", "" ], - "id" : "obj-9", - "fontname" : "Arial", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "select 10 13", - "patching_rect" : [ 244.0, 281.0, 77.0, 20.0 ], - "numoutlets" : 3, - "fontsize" : 12.0, - "outlettype" : [ "bang", "bang", "" ], - "id" : "obj-10", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 244.0, 43.0, 15.0, 15.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-11", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "qmetro 10", - "patching_rect" : [ 244.0, 80.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" : [ 369.0, 179.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" : [ 244.0, 255.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" : [ 53.0, 72.0, 185.0, 34.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-15", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "If you get newline (ASCII 10), send the list. If you get return (ASCII 13) do nothing. Any other value, add to the list", - "linecount" : 3, - "patching_rect" : [ 332.0, 269.0, 320.0, 48.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-16", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Click to open/close serial port and start/stop patch", - "linecount" : 2, - "patching_rect" : [ 271.0, 32.0, 199.0, 34.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-17", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - ], - "lines" : [ { - "patchline" : { - "source" : [ "obj-6", 0 ], - "destination" : [ "obj-1", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-7", 0 ], - "destination" : [ "obj-6", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-8", 0 ], - "destination" : [ "obj-7", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-9", 0 ], - "destination" : [ "obj-8", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-10", 0 ], - "destination" : [ "obj-9", 0 ], - "hidden" : 0, - "midpoints" : [ 253.5, 308.0, 311.5, 308.0 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-10", 2 ], - "destination" : [ "obj-9", 0 ], - "hidden" : 0, - "midpoints" : [ 311.5, 320.0, 311.5, 320.0 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-14", 0 ], - "destination" : [ "obj-10", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "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" : [ 378.5, 200.5, 253.5, 200.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-19", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 358.5, 228.5, 253.5, 228.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-21", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 336.5, 251.5, 253.5, 251.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" : [ 253.0, 71.0, 336.5, 71.0 ] - } - - } - ] - } - + ----------begin_max5_patcher---------- +1591.3oc0YszbaaCD9r7uBL5RalQUAO3CvdyS5zVenWZxs5NcfHgjPCIfJIT +RTxj+6AOHkoTDooroUs0AQPR73a+1cwtK3WtZxzEpOwqlB9YveAlL4KWMYh6 +Q1GLo99ISKXeJMmU451zTUQAWpmNy+NM+SZ2y+sR1l02JuU9t0hJvFlNcMPy +dOuBv.U5Rgb0LPpRpYBooM3529latArTUVvzZdFPtsXAuDrrTU.f.sBffXxL +vGE50lIHkUVJXq3fRtdaoDvjYfbgjujaFJSCzq4.tLaN.bi1tJefWpqbO0uz +1IjIABoluxrJ1guxh2JfPO2B5zRNyBCLDFcqbwNvuv9fHCb8bvevyyEU2JKT +YhkBSWPAfq2TZ6YhqmuMUo0feUn+rYpY4YtY+cFw3lUJdCMYAapZqzwUHX8S +crjAd+SIOU6UBAwIygy.Q1+HAA1KH6EveWOFQlitUK92ehfal9kFhUxJ3tWc +sgpxadigWExbt1o7Ps5dk3yttivyg20W0VcSmg1G90qtx92rAZbH4ez.ruy1 +nhmaDPidE07J+5n2sg6E6oKXxUSmc20o6E3SPRDbrkXnPGUYE.i5nCNB9TxQ +jG.G0kCTZtH88f07Rt0ZMMWUw8VvbKVAaTk6GyoraPdZff7rQTejBN54lgyv +HE0Ft7AvIvvgvIwO23jBdUkYOuSvIFSiNcjFhiSsUBwsUCh1AgfNSBAeNDBZ +DIDqY.f8.YjfjV1HAn9XDTxyNFYatVTkKx3kcK9GraZpI5jv7GOx+Z37Xh82 +LSKHIDmDXaESoXRngIZQDKVkpxUkMCyXCQhcCK1z.G457gi3TzMz4RFD515F +G3bIQQwcP3SOF0zlkGhiCBQ1kOHHFFlXaEBQIQnCwv9QF1LxPZ.A4jR5cyQs +vbvHMJsLll01We+rE2LazX6zYmCraRrsPFwKg1ANBZFY.IAihr8Ox.aH0oAL +hB8nQVw0FSJiZeunOykbT6t3r.NP8.iL+bnwNiXuVMNJH9H9YCm89CFXPBER +bz422p8.O4dg6kRxdyjDqRwMIHTbT3QFLskxJ8tbmQK4tm0XGeZWF7wKKtYY +aTAF.XPNFaaQBinQMJ4QLF0aNHF0JtYuHSxoUZfZY6.UU2ejJTb8lQw8Fo5k +Rv6e2PI+fOM71o2ecY1VgTYdCSxxUqLokuYq9jYJi6lxPgD2NIPePLB0mwbG +YA9Rgxdiu1k5xiLlSU6JVnx6wzg3sYHwTesB8Z5D7RiGZpXyvDNJY.DQX3.H +hvmcUN4bP1yCkhpTle2P37jtBsKrLWcMScEmltOPv22ZfAqQAdKr9HzATQwZ +q18PrUGt6Tst2XMCRUfGuhXs6ccn23YloomMqcTiC5iMGPsHsHRWhWFlaenV +XcqwgCQiGGJzptyS2ZMODBz6fGza0bzmXBj7+DA94bvpR01MffAlueO7HwcI +pWCwmzJdvi9ILgflLAFmyXB6O7ML0YbD26lenmcGxjVsZUN+A6pUK7AtTrPg +M+eRYG0qD9j4I7eEbco8Xh6WcO.or9XDC6UCiewbXHkh6xm5LiPEkzpJDRTu +mEB44Fgz4NCtJvX.SM1vo2SlTCZGAe7GZu6ahdRyzFOhYZ+mbVVSYptBw.K1 +tboIkatIA7c1cTKD1u.honLYV04VkluHsXe0szv9pQCE9Ro3jaVB1o15pz2X +zYoBvO5KXCAe0LCYJybE8ZODf4fV8t9qW0zYxq.YJfTosj1bv0xc.SaC0+AV +9V9L.KKyV3SyTcRtmzi6rO.O16USvts4B5xe9EymDvebK0eMfW6+NIsNlE2m +eqRyJ0utRq13+RjmqYKN1e.4d61jjdsauXe3.2p6jgi9hsNIv97CoyJ01xzl +c3ZhUCtSHx3UZgjoEJYqNY+hYs5zZQVFW19L3JDYaTlMLqAAt1G2yXlnFg9a +53L1FJVcv.cOX0dh7mCVGCLce7GFcQwDdH5Ta3nyAS0pQbHxegr+tGIZORgM +RnMj5vGl1Fs16drnk7Tf1XOLgv1n0d2iEsCxR.eQsNOZ4FGF7whofgfI3kES +1kCeOX5L2rifbdu0A9ae2X.V33B1Z+.Bj1FrP5iFrCYCG5EUWSG.hhunHJd. +HJ5hhnng3h9HPj4lud02.1bxGw. +-----------end_max5_patcher----------- + */ diff --git a/build/shared/examples/4.Communication/MIDI/Midi.pde b/build/shared/examples/4.Communication/MIDI/Midi.pde index 7a25c852c..cdeaeea11 100644 --- a/build/shared/examples/4.Communication/MIDI/Midi.pde +++ b/build/shared/examples/4.Communication/MIDI/Midi.pde @@ -29,7 +29,7 @@ void setup() { void loop() { // play notes from F#-0 (0x1E) to F#-5 (0x5A): - for (intnote = 0x1E; note < 0x5A; note ++) { + for (int note = 0x1E; note < 0x5A; note ++) { //Note on channel 1 (0x90), some note value (note), middle velocity (0x45): noteOn(0x90, note, 0x45); delay(100); @@ -42,8 +42,8 @@ void loop() { // plays a MIDI note. Doesn't check to see that // cmd is greater than 127, or that data values are less than 127: void noteOn(int cmd, int pitch, int velocity) { - Serial.print(cmd, BYTE); - Serial.print(pitch, BYTE); - Serial.print(velocity, BYTE); + Serial.write(cmd); + Serial.write(pitch); + Serial.write(velocity); } diff --git a/build/shared/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde b/build/shared/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde index 788bc908e..684e305bb 100644 --- a/build/shared/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde +++ b/build/shared/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde @@ -28,6 +28,6 @@ void loop() { // read from port 1, send to port 0: if (Serial1.available()) { int inByte = Serial1.read(); - Serial.print(inByte, BYTE); + Serial.write(inByte); } } diff --git a/build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde b/build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde index f7371c95c..8c1f780d3 100644 --- a/build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde +++ b/build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde @@ -123,589 +123,48 @@ void loop() { */ /* -{ - "boxes" : [ { - "box" : { - "maxclass" : "comment", - "text" : "Physical Pixel\n\nThis patch sends an ASCII H or an ASCII L out the serial port to turn on an LED attached to an Arduino board. It can also send alternating H and L characters once every second to make the LED blink.\n\ncreated 2006\nby David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe", - "linecount" : 11, - "patching_rect" : [ 14.0, 35.0, 354.0, 158.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-1", - "fontname" : "Arial", - "numinlets" : 1 - } +Max/MSP version 5 patch to run with this example: + +----------begin_max5_patcher---------- +1672.3oc2ZszaaiCD9ryuBBebQVCQRYao8xhf1cQCPVfBzh8RRQ.sDsM2HSZ +HQmlzh9eu7gjsjsEk7y0oWjiHoHm4aluYHGlueUmtiDuPy5B9Cv8fNc99Uc5 +XZR2Pm726zcF4knDRlYXciDylQ4xtWa6SReQZZ+iSeMiEQR.ej8BM4A9C7OO +kkAlSjQSAYTdbFfvA27o2c6sfO.Doqd6NfXgDHmRUCKkolg4hT06BfbQJGH3 +5Qd2e8d.QJIQSow5tzebZ7BFW.FIHow8.2JAQpVIIYByxo9KIMkSjL9D0BRT +sbGHZJIkDoZOSMuQT.8YZ5qpgGI3locF4IpQRzq2nDF+odZMIJkRjpEF44M3 +A9nWAum7LKFbSOv+PSRXYOvmIhYiYpg.8A2LOUOxPyH+TjPJA+MS9sIzTRRr +QP9rXF31IBZAHpVHkHrfaPRHLuUCzoj9GSoQRqIB52y6Z.tu8o4EX+fddfuj ++MrXiwPL5+9cXwrOVvkbxLpomazHbQO7EyX7DpzXYgkFdF6algCQpkX4XUlo +hA6oa7GWck9w0Gnmy6RXQOoQeCfWwlzsdnHLTq8n9PCHLv7Cxa6PAN3RCKjh +ISRVZ+sSl704Tqt0kocE9R8J+P+RJOZ4ysp6gN0vppBbOTEN8qp0YCq5bq47 +PUwfA5e766z7NbGMuncw7VgNRSyQhbnPMGrDsGaFSvKM5NcWoIVdZn44.eOi +9DTRUT.7jDQzSTiF4UzXLc7tLGh4T9pwaFQkGUGIiOOkpBSJUwGsBd40krHQ +9XEvwq2V6eLIhV6GuzP7uzzXBmzsXPSRYwBtVLp7s5lKVv6UN2VW7xRtYDbx +7s7wRgHYDI8YVFaTBshkP49R3rYpH3RlUhTQmK5jMadJyF3cYaTNQMGSyhRE +IIUlJaOOukdhoOyhnekEKmZlqU3UkLrk7bpPrpztKBVUR1uorLddk6xIOqNt +lBOroRrNVFJGLrDxudpET4kzkstNp2lzuUHVMgk5TDZx9GWumnoQTbhXsEtF +tzCcM+z0QKXsngCUtTOEIN0SX2iHTTIIz968.Kf.uhfzUCUuAd3UKd.OKt.N +HTynxTQyjpQD9jlwEXeKQxfHCBahUge6RprSa2V4m3aYOMyaP6gah2Yf1zbD +jVwZVGFZHHxINFxpjr5CiTS9JiZn6e6nTlXQZTAFj6QCppQwzL0AxVtoi6WE +QXsANkEGWMEuwNvhmKTnat7A9RqLq6pXuEwY6xM5xRraoTiurj51J1vKLzFs +CvM7HI14Mpje6YRxHOSieTsJpvJORjxT1nERK6s7YTN7sr6rylNwf5zMiHI4 +meZ4rTYt2PpVettZERbjJ6PjfqN2loPSrUcusH01CegsGEE5467rnCdqT1ES +QxtCvFq.cvGz+BaAHXKzRSfP+2Jf.KCvj5ZLJRAhwi+SWHvPyN3vXiaPn6JR +3eoA.0TkFhTvpsDMIrL20nAkCI4EoYfSHAuiPBdmJRyd.IynYYjIzMvjOTKf +3DLvnvRLDLpWeEOYXMfAZqfQ0.qsnlUdmA33t8CNJ7MZEb.u7fiZHLYzDkJp +R7CqEVLGN75U+1JXxFUY.xEEBcRCqhOEkz2bENEWnh4pbh0wY25EefbD6EmW +UA6Ip8wFLyuFXx+Wrp8m6iff1B86W7bqJO9+mx8er4E3.abCLrYdA16sBuHx +vKT6BlpIGQIhL55W7oicf3ayv3ixQCm4aQuY1HZUPQWY+cASx2WZ3f1fICuz +vj5R5ZbM1y8gXYN4dIXaYGq4NhQvS5MmcDADy+S.j8CQ78vk7Q7gtPDX3kFh +3NGaAsYBUAO.8N1U4WKycxbQdrWxJdXd10gNIO+hkUMmm.CZwknu7JbNUYUq +0sOsTsI1QudDtjw0t+xZ85wWZd80tMCiiMADNX4UzrcSeK23su87IANqmA7j +tiRzoXi2YRh67ldAk79gPmTe3YKuoY0qdEDV3X8xylCJMTN45JIakB7uY8XW +uVr3PO8wWwEoTW8lsfraX7ZqzZDDXCRqNkztHsGCYpIDDAOqxDpMVUMKcOrp +942acPvx2NPocMC1wQZ8glRn3myTykVaEUNLoEeJjVaAevA4EAZnsNgkeyO+ +3rEZB7f0DTazDcQTNmdt8aACGi1QOWnMmd+.6YjMHH19OB5gKsMF877x8wsJ +hN97JSnSfLUXGUoj6ujWXd6Pk1SAC+Pkogm.tZ.1lX1qL.pe6PE11DPeMMZ2 +.P0K+3peBt3NskC +-----------end_max5_patcher----------- - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Click to blink every second", - "patching_rect" : [ 99.0, 251.0, 161.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-38", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 74.0, 251.0, 21.0, 21.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-39", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "p blink", - "patching_rect" : [ 74.0, 286.0, 45.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-37", - "fontname" : "Arial", - "numinlets" : 2, - "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" : "newobj", - "text" : "* 1000", - "patching_rect" : [ 200.0, 150.0, 46.0, 19.0 ], - "numoutlets" : 1, - "fontsize" : 10.0, - "outlettype" : [ "int" ], - "id" : "obj-12", - "fontname" : "Verdana", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "inlet", - "patching_rect" : [ 200.0, 75.0, 25.0, 25.0 ], - "numoutlets" : 1, - "outlettype" : [ "" ], - "id" : "obj-11", - "numinlets" : 0, - "comment" : "" - } - - } - , { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 125.0, 250.0, 20.0, 20.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-10", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "metro 1000", - "patching_rect" : [ 115.0, 190.0, 69.0, 19.0 ], - "numoutlets" : 1, - "fontsize" : 10.0, - "outlettype" : [ "bang" ], - "id" : "obj-3", - "fontname" : "Verdana", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "outlet", - "patching_rect" : [ 125.0, 400.0, 25.0, 25.0 ], - "numoutlets" : 0, - "id" : "obj-2", - "numinlets" : 1, - "comment" : "" - } - - } - , { - "box" : { - "maxclass" : "inlet", - "patching_rect" : [ 100.0, 25.0, 25.0, 25.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-1", - "numinlets" : 0, - "comment" : "" - } - - } - ], - "lines" : [ { - "patchline" : { - "source" : [ "obj-12", 0 ], - "destination" : [ "obj-3", 1 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-11", 0 ], - "destination" : [ "obj-12", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-1", 0 ], - "destination" : [ "obj-3", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-10", 0 ], - "destination" : [ "obj-2", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-3", 0 ], - "destination" : [ "obj-10", 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" : "comment", - "text" : "convert to int", - "patching_rect" : [ 154.0, 386.0, 104.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-36", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "send L if 0, H if 1", - "patching_rect" : [ 154.0, 361.0, 104.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-35", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "is it on or off?", - "patching_rect" : [ 179.0, 336.0, 95.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-34", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "atoi", - "patching_rect" : [ 279.0, 386.0, 46.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "list" ], - "id" : "obj-33", - "fontname" : "Arial", - "numinlets" : 3 - } - - } - , { - "box" : { - "maxclass" : "message", - "text" : "H", - "patching_rect" : [ 329.0, 361.0, 32.5, 17.0 ], - "numoutlets" : 1, - "fontsize" : 10.0, - "outlettype" : [ "" ], - "id" : "obj-32", - "fontname" : "Verdana", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "message", - "text" : "L", - "patching_rect" : [ 279.0, 361.0, 32.5, 17.0 ], - "numoutlets" : 1, - "fontsize" : 10.0, - "outlettype" : [ "" ], - "id" : "obj-31", - "fontname" : "Verdana", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "select 0 1", - "patching_rect" : [ 279.0, 336.0, 62.0, 20.0 ], - "numoutlets" : 3, - "fontsize" : 12.0, - "outlettype" : [ "bang", "bang", "" ], - "id" : "obj-25", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Click to turn the LED on and off", - "linecount" : 2, - "patching_rect" : [ 130.0, 205.0, 143.0, 34.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-24", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 279.0, 211.0, 24.0, 24.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-23", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "select 0 1", - "patching_rect" : [ 381.0, 331.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" : [ 429.0, 422.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" : [ 454.0, 396.0, 206.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-27", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "message", - "text" : "close", - "patching_rect" : [ 381.0, 422.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" : [ 403.0, 396.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" : [ 474.0, 370.0, 207.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-2", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 381.0, 181.0, 21.0, 21.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-11", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "message", - "text" : "print", - "patching_rect" : [ 423.0, 370.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" : [ 279.0, 461.0, 84.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "int", "" ], - "id" : "obj-14", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Click to start", - "patching_rect" : [ 408.0, 181.0, 117.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-17", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - ], - "lines" : [ { - "patchline" : { - "source" : [ "obj-39", 0 ], - "destination" : [ "obj-37", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-37", 0 ], - "destination" : [ "obj-25", 0 ], - "hidden" : 0, - "midpoints" : [ 83.5, 320.5, 288.5, 320.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-33", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-32", 0 ], - "destination" : [ "obj-33", 0 ], - "hidden" : 0, - "midpoints" : [ 338.5, 381.5, 288.5, 381.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-31", 0 ], - "destination" : [ "obj-33", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-25", 0 ], - "destination" : [ "obj-31", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-25", 1 ], - "destination" : [ "obj-32", 0 ], - "hidden" : 0, - "midpoints" : [ 310.0, 358.0, 338.5, 358.0 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-23", 0 ], - "destination" : [ "obj-25", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-13", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 432.5, 389.0, 367.0, 389.0, 367.0, 411.0, 288.5, 411.0 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-19", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 412.5, 417.0, 288.5, 417.0 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-21", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 390.5, 450.0, 288.5, 450.0 ] - } - - } - , { - "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" : [ 390.5, 322.0, 390.5, 322.0 ] - } - - } - ] - } */ diff --git a/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde b/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde index 6f56d9891..3a6e01300 100644 --- a/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde +++ b/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde @@ -52,15 +52,15 @@ void loop() // read switch, map it to 0 or 255L thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: - Serial.print(firstSensor, BYTE); - Serial.print(secondSensor, BYTE); - Serial.print(thirdSensor, BYTE); + Serial.write(firstSensor); + Serial.write(secondSensor); + Serial.write(thirdSensor); } } void establishContact() { while (Serial.available() <= 0) { - Serial.print('A', BYTE); // send a capital A + Serial.print('A'); // send a capital A delay(300); } } @@ -146,1052 +146,66 @@ void serialEvent(Serial myPort) { /* 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" : [ ] - } - - } - ] -} +----------begin_max5_patcher---------- +2569.3oc2as0jiZqD9YO+Jzw09PRc75BIAX671TaUop8gy4gLoNmG1YqsjAY +rxhAGPLW1T4+dZIAd.aCFeiEuYqXFABQqu9qa0Rp0ec2fgyiegmND8KnOgFL +3utav.8sT2XPd4ACWwdwKjkpq1vU7zTV.e3Hyyj7Wj5665Tbq3LYHWJecM2z +tCGh9b9iVyjdKEQAeIg6IMOkRmM1ZDx10UcgRF6LBgmN1Zy6H70se77+38yJ +9DKhijQrU5Ovv6SDrvhmDksRDAedsvRJU8Tw2zUGSfuyl5ZjUckwpa922cm5 +mQsDLh3OCx0NXQJODgqENlyhBFNpkvBchFVzfCwZ+vh60DVHm.r3EuZEORtC +t7.WISnOvBCe+uwSWGGkxQnGidL5AdjeJhgl+pjifuNRtjiRMUecbhbDhE4i +R3LnVTcsRQhnwHzCfXhVDmvChyfZ3EGFmLB8x53Tyq7J7Wn3EPS6IR7B4nrT +.n0M+SrvLnYR3xrjHtOZQR7ps+tiMh2+MVx+EzuuTjhz5JDzSy.KAn5Lir5y +eR3AhdjtTL7SBB5SpO8VMIBZjfXsPDC2GpCCojIP1L89EFIC45f9o6e3Ce7i +n6+YUCmJYIxr0iA4.ZvuxUxwyLgo+ajDUCLR8AizsLfnQn7l.8LbW9SfXIjv +qAZdzJ.1P9LIartS5AvqDvArM590I.ayZ1iQyeE8fWrTh9Ug7aA7DVnuFW+c +.q9XP7F+.ghHtGnBzJZLtdhsskshK6PLV85BXmZL3cNRlM9XX1VWPlsLQD.n +C5m.Mwmje9mUpDOE4RDrT99P9BIPMidBdUAP5AV08ggFdSB6YEWPgoqShg2Q +yOeV.OeIa8ZPSNmq32n+C6Efq9m.kETcfimb96Xz+WotkJtYgTrPjvA9Onn2 +gE.bNV5WQ2m3mIhh0LmRs0d0lz5UlDiWJGKGs1jXtTixz8lQalvEQBIHVvGM +UqlBXJONOqQZi2BvfjosuWrWPiTOngmXo8oatfoZPiZWCnYeq.ZdK4desvWD +GXYdBQtmLvk1iCu+wgJ12bdfHBLF.QNyioLGTVCKjJGSFPW8vUYQBySUtKWw +70t0f+bdXr2WQoKy.i.+3miNZJqsqA8czvNgRajxR6aneMQbrF.XkqDMzaFo +6wgmV.YDrNjCWaC.4psvwypAfH6Ef9e7DeVDauPDcePjUcAkUVN4I4.SNx.s +gHTMjVJvSJU6ACeq23nGfYlsoKYYT1khiBv6.Ekhq6SVE2zmu3XZiXvO8a0W +WiJ+Tslhn0f+YvFRSv296xxBkeY+fS0muf4wq8kqQULXXPhvONRIFUdW0sK9 +f.Gvn6cJK45ZDwVumWVFGGNmk7jHULOjWQS.rYVjXE39TJLRDDWQwCEqVmHL +VratGOhAswxTuj3vvJMk4IOsmmXB95YgubotsdCupL8lRLmJ1YUteiS2opQ2 +hjf4.H4T7+kqT81b0Fw+DGSrPZRyro5Bk7Kssom8jxeuZ8OUa3+6ZDhG6LyA +OcR0Wb6oHMnvok4OFcs.VK0+NOHkjCoF5ryrCBot2zPZkwF1cFoJVZy.ZwLS +2YFp0xYsLwvXtXlBOA2..6TK.ukep5FYsgQW2C5R6FzcMChIw5RvXMF+4DV7 +TqCBnzSFPsOE.sinq+afR0HPpG03PV+UHm1GFKImLVR9QGKycj1ZnDe6BkMM +vDDVMKYDZMCvrXXtMn2gQuifdGE8N6KhgewExAGpx5ldnJs7b1rRmIpUKNmN +taHqauXRSqETZfYU5IEy7U0fC6cfAlT137vnwrenQCp0QgFtV8Tzv74FdfQ5 +HSGSg+y1dj9uaWWF2pXs1ZIKNht7aScTs1L0LKLcuQ878iEowYIdE58h.dPU +6S97ToHZybo+zaNH2phKE99Um4pFtE9qiAJUt.h9bqzdGsb6zV41s+I231H2 +S5WxMts3shPQ5OxM4XjaZuQtUCt1d415FTtw8K4d1wf23aP4lzqvaWq1J2N8 +K+fsUtc6W768LL3sgbO46gbmeSnCX1tjT1Sb+u.eFHDwuvjxDw7LoIDrxaex +4uaBM9vCsYFAgwyYg4asylVoRauiTscac2aHwkYmzrpcWyJOsi8NkCb995N8 +sLYptT1wYxMRpL8udeCYxzAQjolDBf51BDw4FAQToB.LfJ9DS2MCjju8ylcV +rVHwtuAIx3ffP9YyGLoKhY8JpsySabC1u1pWqSS8hM6RrcqTuV2PoyXCo2Y6 +xmwbduYKMroMAL1S6aIzXnmesc+PQpT08KtpLBF0xbrXV9pz3t4x9vC5rivT +v9xo2kpTPLrQq8Qsydvwjze1js23fJcSmiNWRveuxj0mXga7OsuEl1jTWtlt +sIGdqqaiut85SJIixVMmmbHEu1tuIkus6jRnfiaiJ+aJcOoAcusILPWyfbGP +2Os+o7anaianaSlRZc2lX8CKmmZWFFZlySH8OR+EBFJFfKGFbZDF5g190LhX +Vzao5wgvnRWZAR4XxF37zsrVnZ10EpnWNn5agnfj3r0HZ8QR2xnGrMAMNA23 +.HG+3njuSrHHdZnKBbnCeFgZWr0XSbU4YgEooXqoVWyLZldIym7PAXpsjmvU +oMtWXbJe6iRSCCGQMo4MYlgzX03Anh3dyjj8U.EUh3dLXxz7T51oMXxj9FlT +2IOTSMNwUiI2xwvRn6jfnU.Dbea550AH5SYF6TONl1k3H13lPDbu67XVmYyG +pX1DvA3Aolut5joTx1Isov5yWzJCIgXMoQim9lsyYtvcDhwzHOPNRwu6kUf+ +9rvc+4JtLI9sjcrlAUaQ2rXfTmlTwXxMi6.8Yr3z7FjuBlFRuYY7q0a.8lY4 +L0F7LzLWKqyZ0sx4KTrloLswU6EeUOHeWx02323L+Buhhn0YRz7rEKTmm4m3 +IuBFXnUhPv6I2KNxO8nO8iTy4IKeo.sZ5vOhuYNwnlAXTGna0gztokIwrj.X +WCLfabXDbmECl9qWMO8Lvw16+cNnry9dWIsNpYKuUl.kpzNa2892p6czPsUj +bnsPlbONQhByHUkxwTr5B0d5lRmov51BYcVmBeTbKDIpS2JSUxFwZjIxrtWl +tzTehEUwrbLqlH1rP5UKkmgyDplCpKctFLSZQOYKqpCawfmYRR+7oXYuoz4h +6VsQZmzstbZCWvw9z74XN+h1NlSrdkRTmxnqtTW37zoas9IsxgNoakIRakIb +24QpshDoyDI21.Szt0w8V1g0jNmS6TYBa2VGHGAcpXHByvG1jYaJ0INIrNM2 +cj7kmjtozYJsaoJuLCuctHXaFDaqHw5GbPqN0klNltCF3WG65uMy4gP6dYhb +H9T2RmZ07HNRmD4tzv4KbOAuozkHpxCQzvc7LLZiSBR25jffuBy5IWORw5KE +CagO+YWiuFKOA0VOzDY5zRRqtz4Jszqgz5ZjVWqxRqpTWXei6VWyXx0d4nfB ++8c+C81VE7B +-----------end_max5_patcher----------- */ diff --git a/build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde b/build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde index 3caf3f713..76a6ffe2b 100644 --- a/build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde +++ b/build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde @@ -142,1131 +142,70 @@ void serialEvent(Serial myPort) { */ /* -{ - "boxes" : [ { - "box" : { - "maxclass" : "newobj", - "text" : "fromsymbol", - "patching_rect" : [ 265.0, 585.0, 74.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-7", - "fontname" : "Arial", - "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "itoa", - "patching_rect" : [ 265.0, 562.0, 46.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-8", - "fontname" : "Arial", - "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], - "numinlets" : 3 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "zl group", - "patching_rect" : [ 265.0, 539.0, 53.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "", "" ], - "id" : "obj-4", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "select 10 13", - "patching_rect" : [ 209.0, 501.0, 75.0, 20.0 ], - "numoutlets" : 3, - "fontsize" : 12.0, - "outlettype" : [ "bang", "bang", "" ], - "id" : "obj-10", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "message", - "text" : "65", - "patching_rect" : [ 354.0, 481.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" : [ 354.0, 452.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 ASCII \n\nSends a byte out the serial port, and reads 3 ASCII enoded, comma separated in, truncated by a linefeed. It then 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" : 12, - "patching_rect" : [ 401.0, 67.0, 540.0, 172.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" : [ 254.0, 625.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" : [ 185.0, 385.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 newline to begin communication. After initial communication is made, this block shuts down.", - "linecount" : 3, - "patching_rect" : [ 475.0, 370.0, 252.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" : [ 232.0, 765.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-43", 0 ], - "destination" : [ "obj-40", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-45", 0 ], - "destination" : [ "obj-46", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-45", 1 ], - "destination" : [ "obj-47", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-41", 0 ], - "destination" : [ "obj-43", 2 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-42", 0 ], - "destination" : [ "obj-43", 3 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-58", 0 ], - "destination" : [ "obj-43", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-58", 0 ], - "destination" : [ "obj-41", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-59", 0 ], - "destination" : [ "obj-43", 1 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-59", 0 ], - "destination" : [ "obj-42", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-60", 0 ], - "destination" : [ "obj-45", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-40", 0 ], - "destination" : [ "obj-61", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-46", 0 ], - "destination" : [ "obj-61", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-47", 0 ], - "destination" : [ "obj-61", 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" : [ 325.0, 393.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" : [ 400.0, 451.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" : [ 400.0, 370.0, 54.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-54", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 400.0, 420.0, 20.0, 20.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-53", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "gate 1 0", - "patching_rect" : [ 209.0, 470.0, 54.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-50", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "sel 10", - "patching_rect" : [ 400.0, 393.0, 43.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "bang", "" ], - "id" : "obj-48", - "fontname" : "Arial", - "numinlets" : 2 - } - - } -, { - "box" : { - "maxclass" : "lcd", - "patching_rect" : [ 232.0, 815.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" : [ 209.0, 624.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" : [ 553.0, 725.0, 37.0, 21.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-1", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 482.0, 725.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" : [ 425.0, 725.0, 37.0, 21.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-18", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "comment", - "text" : "val1", - "patching_rect" : [ 297.0, 725.0, 37.0, 21.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-20", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 357.0, 725.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" : [ 232.0, 725.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 0 0", - "patching_rect" : [ 232.0, 690.0, 269.0, 21.0 ], - "numoutlets" : 5, - "fontsize" : 12.0, - "outlettype" : [ "int", "int", "int", "int", "int" ], - "id" : "obj-29", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "select 0 1", - "patching_rect" : [ 327.0, 215.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" : [ 375.0, 306.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" : [ 400.0, 280.0, 206.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-27", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "message", - "text" : "close", - "patching_rect" : [ 327.0, 306.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" : [ 349.0, 280.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" : [ 420.0, 254.0, 207.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-2", - "fontname" : "Arial", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 244.0, 170.0, 22.0, 22.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-11", - "numinlets" : 1 - } - - } -, { - "box" : { - "maxclass" : "newobj", - "text" : "qmetro 10", - "patching_rect" : [ 244.0, 215.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" : [ 369.0, 254.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" : [ 244.0, 330.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" : [ 28.0, 207.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" : [ 271.0, 178.0, 117.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-17", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - ], - "lines" : [ { - "patchline" : { - "source" : [ "obj-54", 0 ], - "destination" : [ "obj-48", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-48", 0 ], - "destination" : [ "obj-53", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-9", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-53", 0 ], - "destination" : [ "obj-6", 0 ], - "hidden" : 0, - "midpoints" : [ 409.5, 446.5, 363.5, 446.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-6", 0 ], - "destination" : [ "obj-9", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-35", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 218.5, 656.0, 182.0, 656.0, 182.0, 315.0, 253.5, 315.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-57", 0 ], - "destination" : [ "obj-53", 0 ], - "hidden" : 0, - "midpoints" : [ 334.5, 416.0, 409.5, 416.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-30", 0 ], - "destination" : [ "obj-57", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-55", 0 ], - "destination" : [ "obj-54", 0 ], - "hidden" : 0, - "midpoints" : [ 409.5, 474.0, 468.0, 474.0, 468.0, 366.0, 409.5, 366.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-53", 0 ], - "destination" : [ "obj-55", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-23", 0 ], - "destination" : [ "obj-62", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-22", 0 ], - "destination" : [ "obj-62", 1 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-3", 0 ], - "destination" : [ "obj-62", 2 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-62", 0 ], - "destination" : [ "obj-39", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-14", 0 ], - "destination" : [ "obj-54", 1 ], - "hidden" : 0, - "midpoints" : [ 253.5, 357.0, 444.5, 357.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-53", 0 ], - "destination" : [ "obj-50", 0 ], - "hidden" : 0, - "midpoints" : [ 409.5, 441.0, 218.5, 441.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-14", 0 ], - "destination" : [ "obj-50", 1 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-11", 0 ], - "destination" : [ "obj-30", 0 ], - "hidden" : 0, - "midpoints" : [ 253.5, 206.0, 336.5, 206.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-30", 1 ], - "destination" : [ "obj-19", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-30", 0 ], - "destination" : [ "obj-21", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-21", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 336.5, 326.5, 253.5, 326.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-19", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 358.5, 303.5, 253.5, 303.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-13", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 378.5, 275.5, 253.5, 275.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-11", 0 ], - "destination" : [ "obj-12", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-12", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-10", 2 ], - "destination" : [ "obj-4", 0 ], - "hidden" : 0, - "midpoints" : [ 274.5, 542.0, 274.5, 542.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-10", 0 ], - "destination" : [ "obj-4", 0 ], - "hidden" : 0, - "midpoints" : [ 218.5, 529.5, 274.5, 529.5 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-4", 0 ], - "destination" : [ "obj-8", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-8", 0 ], - "destination" : [ "obj-7", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-7", 0 ], - "destination" : [ "obj-35", 0 ], - "hidden" : 0, - "midpoints" : [ 274.5, 614.0, 218.5, 614.0 ] - } - - } -, { - "patchline" : { - "source" : [ "obj-50", 0 ], - "destination" : [ "obj-10", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-29", 0 ], - "destination" : [ "obj-23", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-35", 1 ], - "destination" : [ "obj-29", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-29", 4 ], - "destination" : [ "obj-3", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-29", 2 ], - "destination" : [ "obj-22", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - ] -} +Max/MSP version 5 patch to run with this example: + +----------begin_max5_patcher---------- +2726.3oc2bkziaiiE9bU+J3XjCciwo.WzZeqPCL.4vLG5zXlCIAAzRz1bhrj +aI5pRkF8+89QRIWR1VxxqQNoPrL0B0G+dK7QxG8ed+cilj8UQwHzuf9.5t69 +y6u6Nyozm3txx2MZA+qQI7BysMJU7b1j++nw1KoDeUYN8z7rEEurXRVR0kxV +oRDJ0KKE1pezHzmJuzRtJZtLc1myEQJ6UodtOfGibCLG7czeRwOfW+LxXy6A +d2u0u5ULMKUkxWXdAidLWxW+xixRxxs0LQWU3GBBwjPO82vkeiTq1SWsPlBv +0zFI0p9B42LUOgBUy56011r2r9j+082q+X7owgRUFuU1Slp5EA5oAJxwqKBL +3BSfruSD32RPyxyVsrcUvw8TMjEZOzEK5reVrAqPODVgd9XkBQBz9PDLhvZk +YlvSmoYmpicyRXK8fMpF9tcwRD7ARSGj0G6HnoEhhB9LwV7jm6w45h4Z7V4D +XXCF8AWvzHX2rQ3kTmgbV0YPj8przKZw03Ph0oCIugloTT1hEBvi6l7x6EZL +g9UdRxa+MQwxrzBA5w2+qu6cnOl9wz2KRiKPbzjWTBD.AjZt.UXelkY4pwHd +ZLJWvg6hU9bhzrXQ7Xj9UxgadIOmqDwHjLcLRkuJMxTbxKP8lHSESEh3GPuy +T2ov8qJPSyxEyxVAUsws8XzWWlUXeWu.eCkMEd1HYdTh.sp.DSFb8DOYkn.P +iZUdJ7FzcguIfe.YZW+mLk3WP+9bYAxHoQ.OsBrifamaajwhmjQPaN0TJC9H +GZYw5W8FUIBpjYYFPjAmGtGnUCEArYosoVjg7bQ+jkhd7m0UbghmqVs7A.GP +E9EgFGOyk11uEI5JXbEwXDEokr7inmgyJdBfkTAOFn2fV.zFJlq3OXZjQfbQ +yzDGziKyAcUb3GSAZ+8QYJE5eIUealHmmDa30eG3p2MKasWDsjIBDAJqpX6l +ENVmld9FOnNX8AhOc21EtWRem3yncgJWNCXGzOARhOn9zOqEIQZkK4r4p2lH +lp.UyzmfGUBlLfV0iIIV8lb9yZcAMmtLOCdFi94yR35y4KWBRxIBs9M5ey+J +nq9GfJKH5.2Vk5uOf9eZwsRqaVghoxbAn+CB5szB.cNdwWPOlGuRllYzbpUW +6TZx5niPqONOpoKPmxCs3626lQZlKjoRE.K3kVXDSy.KiBiIDpzaAXPxM12S +2Io0gE.wFiOydfvrkbZgzbtUHsn4hnuT4KR.ZYQRYomLvkFnjo4Gs92DwLYp +wc+pTI3bGrHzFDSUZeSVdu4U0dLWviMd1fuNIIK5Knh4q.6f3rmSOXsVGaDa +LeiyGZU3KsH.XCMAPKgrrD8wQZuIF121Y2GGcjCFkYhYw2NX.pmIZWRXKDDc +mDz+UjGyS4i583ivsEUWcbJxKIlRlApCYhtWsBPOo1ce2nWaMV4an0SksCGm +fZAhA78LsJkvzlvUmLVL8PpiLvU8q2O1NlwZez7NkoKAWzfYjQAey2KeUh5y +6lbZd8o7HQqObKhh6FMKWFmkpgQimUe5pWn10t03nNxM2QJe4NdXUVVxDd9S +xB4jDQCIAnMySkK.OnJoEQPnEUWTtXYtzZwt9bhTNTGyKhxyRRZTU1q7zNth +M9qmkwp4l55U9pwL7TSyogcViy243k1bZelMAHI2p+W+lZ2lq0gLXcLQbMJM +gAlB07Ks0Hv8q+9Z0+TqieXaiPxCtgtj.+lO3liw5tJmV1uL9RQrX8emFkRK +oTq5ra3doTuaZJsQeCaOjVsVZ2DZqyCRq5rXaH71Cd1g4R5ffcakf2vOUa8r +1QuqsMCIWd1cIGhIAeNzXsF+kJrj.7dIT1QSnNGCgdkTW+mHR2DY8IDt8Ipq +txoy94R5Qykzez4xRGo8lJI2tTYWcLAgUyyGiVxANKCFdC5MDzann2vPuw4r +X3Wcft2tpv2zcUYvyIqU55qmt4R0wsCYcy4SJnURoCMqZWoZvu5JbzfiLHz5 +Fm6mMB+glMX3ChM7vCT1v95Fsmd5nAOvf+43L17890jI8JVqMlxhCnI+5PG0 +yMSKiByzZzWe2bQQ1p7nJ4d0ndPMaSwhBkLc8Xo+vqMuMtw4x33lib0P2x3k +YfJUI.QepWRuCF2d2n3Feahau9ha8PRFP3V6Vte3ldihaXDKHxvA2A8E2CK8 +69ia1vxeB8PvMa3faxgfa5vA2taYt0Bt8GV5It8ku8FV3l0WbiOi3t7jPCvt +bIE7mDweFdMPHhelqT4xIqT1Pvpu7Im9pIz4E22hYLKIaBOobocVWKMp6sP0 +l008uxDmmURCezIgHyFyMKj8ZpP0VN+35eijKT+i21QpPsOFwobPXtjdvHt2 +HLhNa..Opjia0UKojxke1syT800YnQIprYyRDmr9fclJd8yc13Yct.6WZwK9 +HW7baxg5zKwK9VJeHwmVBQVo2acN5zctEGLzxHxjn3Va9IxBkt4WcTaDLte4 +XQ.obVZ7VeXW7AK7.LEbNexckNKDS5zZumIKsG0llMzMW3fFMS2CNWRHeuRE +1m3Iq8OsqIl1l779kQD32UylbYa0GURFsZwDQ99D7F69Ns4Cn0XAWuNE92Tx +dZGx9xDgrex9fgmvuilMoilMMzu2MaJ9GVcdlqeu04ozgmR+YhFpRhvRZvsS +ZX.Z62ROhqRqmpGH793oVOzCtyKDWKALak7Burjm6YeqXg6wdqoe6wFZoSFW +aHFcERIavsQrZMSpSjfF1bQtIcoiRxJDatIR5vKbYRDxvk63nN23QTualzKu +Aony+zCfSJG5AsLap1Cm3Oz3j11wdFUiibS6YsbJ0RXakWjMHDxPaTpsQHl8 +WE+HYDmvZ5HNjtXDxfaeL1lYyu1vrYlPY1EcEJ8dxnlsSQmQyVeeRPw9cZ7L +zrcNw4qh53X2gZVNfV84N0JHeelup+XgPkms24moGMypNR6dGMSuYbGX1ZAG +m2fxXtrJ81cuaqdCX2LyhmwfmiB8v3SaRcr5KLlwrHnyI4jbQ2Bamyg0+aBd +bkWQY5xUJzjUSmp2IuOIxeQ+KHvBYB38TDkkFWbn66uxrxpz+IA2019ibyrW +Iscvn2Jy5smbWyNfusKUe61ZgzY2HjqVLXl2dyzSyRGatrukjxVK2qd3WutZ ++srTuzF47v1Ky6tWh2sDQGDlb1ClXWUHwZjEBsQSgWeZBuOLcc4IWbOvDAeU +wjeOfDy8vfD02QuVvdjx.OBVW5DAaPO.q+Uk9b5AhBtpHhzGkLmCTfZEgtzP +yZ7aEulRmCvROyfsDdkKGUsRmJXo8w7045JsI8ASW2dnHrK.Ow7Cr5dtlCtr +0kNUzFdIPqqAsLLqFZMkN0t0HWBzBiARiOpWczpKcpAFzGeQazjt3Aqf6QvJ +jvgmUL6.CLnxFobZ.sxXSoSEs8oSO2lz7EOzJVewzAvfNXS+cN1ILrrSPSoq +BC5bXLXkcqcIJcbbVW5DQqWe52iccsX5i31fa50aDGz9hoqmYAs27DdfYp5d +cwjaeMHOB2G1ewWc7Br4NX8RL6OpBk2ooz0nKW2q6fjb6yfLcYGZPKFGbNj5 +Lnoz4X1LN2gXUMHX2xYa1lC.MJwpRWPqabh6o63tGMjvgmsu2Q1KsMHVO15R +mHXCGdC2yI3BXIcpxz9DLiyoLIHPg+59+Fv1JXFJ +-----------end_max5_patcher----------- */ diff --git a/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino b/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino new file mode 100644 index 000000000..458c43dad --- /dev/null +++ b/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino @@ -0,0 +1,57 @@ +/* + Serial Event example + + When new serial data arrives, this sketch adds it to a String. + When a newline is received, the loop prints the string and + clears it. + + A good test for this is to try it with a GPS receiver + that sends out NMEA 0183 sentences. + + Created 9 May 2011 + by Tom Igoe + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/SerialEvent + + */ + +String inputString = ""; // a string to hold incoming data +boolean stringComplete = false; // whether the string is complete + +void setup() { + // initialize serial: + Serial.begin(9600); + // reserve 200 bytes for the inputString: + inputString.reserve(200); +} + +void loop() { + // print the string when a newline arrives: + if (stringComplete) { + Serial.println(inputString); + // clear the string: + inputString = ""; + stringComplete = false; + } +} + +/* + SerialEvent occurs whenever a new byte comes in the + hardware serial RX. Don't do complex things here, as the + processor halts the regular program to run this routine: + */ +void serialEvent() { + // get the new byte: + char inChar = (char)Serial.read(); + // add it to the inputString: + inputString += inChar; + // if the incoming character is a newline, set a flag + // so the main loop can do something about it: + if (inChar == '\n') { + stringComplete = true; + } +} + + diff --git a/build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde b/build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde index 5e8c4012a..e931262a9 100644 --- a/build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde +++ b/build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde @@ -88,612 +88,43 @@ void loop() */ /* Max/MSP patch for this example - { - "boxes" : [ { - "box" : { - "maxclass" : "newobj", - "text" : "/ 4", - "patching_rect" : [ 448.0, 502.0, 32.5, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-25", - "fontname" : "Arial", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "/ 4", - "patching_rect" : [ 398.0, 502.0, 32.5, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-24", - "fontname" : "Arial", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "/ 4", - "patching_rect" : [ 348.0, 502.0, 32.5, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-23", - "fontname" : "Arial", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Virtual color mixer\n\nThis patch takes a string, containing three comma-separated ASCII formatted numbers from 0 to 1023, with a carriage return and linefeed at the end. It converts the string to three integers and uses them to set the background color.\n\n created 2 Dec 2006\n by David A. Mellis\nmodified 14 Apr 2009\nby Scott Fitzgerald and Tom Igoe", - "linecount" : 11, - "patching_rect" : [ 524.0, 51.0, 398.0, 158.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-32", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "select 0 1", - "patching_rect" : [ 372.0, 125.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" : [ 457.0, 276.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" : [ 457.0, 250.0, 206.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-27", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "message", - "text" : "close", - "patching_rect" : [ 372.0, 276.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" : [ 394.0, 250.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" : [ 457.0, 224.0, 207.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-2", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Convert ASCII to symbol", - "patching_rect" : [ 424.0, 423.0, 147.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-4", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Convert integer to ASCII", - "patching_rect" : [ 424.0, 400.0, 147.0, 20.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-5", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "fromsymbol", - "patching_rect" : [ 347.0, 423.0, 74.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "" ], - "id" : "obj-7", - "fontname" : "Arial", - "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "itoa", - "patching_rect" : [ 347.0, 400.0, 46.0, 20.0 ], - "numoutlets" : 1, - "fontsize" : 12.0, - "outlettype" : [ "int" ], - "id" : "obj-8", - "fontname" : "Arial", - "color" : [ 1.0, 0.890196, 0.090196, 1.0 ], - "numinlets" : 3 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "zl group", - "patching_rect" : [ 347.0, 377.0, 53.0, 20.0 ], - "numoutlets" : 2, - "fontsize" : 12.0, - "outlettype" : [ "", "" ], - "id" : "obj-9", - "fontname" : "Arial", - "numinlets" : 2 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "select 10 13", - "patching_rect" : [ 289.0, 326.0, 77.0, 20.0 ], - "numoutlets" : 3, - "fontsize" : 12.0, - "outlettype" : [ "bang", "bang", "" ], - "id" : "obj-10", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "toggle", - "patching_rect" : [ 289.0, 88.0, 15.0, 15.0 ], - "numoutlets" : 1, - "outlettype" : [ "int" ], - "id" : "obj-11", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "qmetro 10", - "patching_rect" : [ 289.0, 125.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" : [ 414.0, 224.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" : [ 289.0, 300.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" : [ 98.0, 117.0, 185.0, 34.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-15", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "If you get newline (ASCII 10), send the list. If you get return (ASCII 13) do nothing. Any other value, add to the list", - "linecount" : 3, - "patching_rect" : [ 377.0, 314.0, 320.0, 48.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-16", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Click to open/close serial port and start/stop patch", - "linecount" : 2, - "patching_rect" : [ 316.0, 77.0, 199.0, 34.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-17", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "bgcolor 0 0 0", - "patching_rect" : [ 348.0, 585.0, 169.0, 19.0 ], - "numoutlets" : 0, - "fontsize" : 10.0, - "id" : "obj-6", - "fontname" : "Verdana", - "numinlets" : 4 - } - - } - , { - "box" : { - "maxclass" : "newobj", - "text" : "unpack 0 0 0 0 0", - "patching_rect" : [ 347.0, 470.0, 119.0, 19.0 ], - "numoutlets" : 5, - "fontsize" : 10.0, - "outlettype" : [ "int", "int", "int", "int", "int" ], - "id" : "obj-20", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 448.0, 535.0, 50.0, 19.0 ], - "numoutlets" : 2, - "fontsize" : 10.0, - "outlettype" : [ "int", "bang" ], - "id" : "obj-18", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 398.0, 535.0, 50.0, 19.0 ], - "numoutlets" : 2, - "fontsize" : 10.0, - "outlettype" : [ "int", "bang" ], - "id" : "obj-1", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "number", - "patching_rect" : [ 348.0, 535.0, 50.0, 19.0 ], - "numoutlets" : 2, - "fontsize" : 10.0, - "outlettype" : [ "int", "bang" ], - "id" : "obj-22", - "fontname" : "Verdana", - "numinlets" : 1 - } - - } - , { - "box" : { - "maxclass" : "comment", - "text" : "Here's the numbers from Arduino's analog input", - "linecount" : 3, - "patching_rect" : [ 198.0, 484.0, 138.0, 48.0 ], - "numoutlets" : 0, - "fontsize" : 12.0, - "id" : "obj-3", - "fontname" : "Arial", - "numinlets" : 1 - } - - } - ], - "lines" : [ { - "patchline" : { - "source" : [ "obj-18", 0 ], - "destination" : [ "obj-6", 2 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-1", 0 ], - "destination" : [ "obj-6", 1 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-22", 0 ], - "destination" : [ "obj-6", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-25", 0 ], - "destination" : [ "obj-18", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-20", 4 ], - "destination" : [ "obj-25", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-20", 2 ], - "destination" : [ "obj-24", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-24", 0 ], - "destination" : [ "obj-1", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-23", 0 ], - "destination" : [ "obj-22", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-20", 0 ], - "destination" : [ "obj-23", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-8", 0 ], - "destination" : [ "obj-7", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-14", 0 ], - "destination" : [ "obj-10", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "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" : [ 423.5, 245.5, 298.5, 245.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-19", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 403.5, 273.5, 298.5, 273.5 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-21", 0 ], - "destination" : [ "obj-14", 0 ], - "hidden" : 0, - "midpoints" : [ 381.5, 296.5, 298.5, 296.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" : [ 298.0, 116.0, 381.5, 116.0 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-7", 0 ], - "destination" : [ "obj-20", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-9", 0 ], - "destination" : [ "obj-8", 0 ], - "hidden" : 0, - "midpoints" : [ ] - } - - } - , { - "patchline" : { - "source" : [ "obj-10", 0 ], - "destination" : [ "obj-9", 0 ], - "hidden" : 0, - "midpoints" : [ 298.5, 353.0, 356.5, 353.0 ] - } - - } - , { - "patchline" : { - "source" : [ "obj-10", 2 ], - "destination" : [ "obj-9", 0 ], - "hidden" : 0, - "midpoints" : [ 356.5, 365.0, 356.5, 365.0 ] - } - - } - ] - } + + ----------begin_max5_patcher---------- +1512.3oc4Z00aaaCE8YmeED9ktB35xOjrj1aAsXX4g8xZQeYoXfVh1gqRjdT +TsIsn+2K+PJUovVVJ1VMdCAvxThV7bO7b48dIyWtXxzkxaYkSA+J3u.Sl7kK +lLwcK6MlT2dxzB5so4zRW2lJXeRt7elNy+HM6Vs61uDDzbOYkNmo02sg4euS +4BSede8S2P0o2vEq+aEKU66PPP7b3LPHDauPvyCmAvv4v6+M7L2XXF2WfCaF +lURgVPKbCxzKUbZdySDUEbgABN.ia08R9mccGYGn66qGutNir27qWbg8iY+7 +HDRx.Hjf+OPHCQgPdpQHoxhBlwB+QF4cbkthlCRk4REnfeKScs3ZwaugWBbj +.PS+.qDPAkZkgPlY5oPS4By2A5aTLFv9pounjsgpnZVF3x27pqtBrRpJnZaa +C3WxTkfUJYA.BzR.BhIy.ehquw7dSoJCsrlATLckR.nhLPNWvVwL+Vp1LHL. +SjMG.tRaG7OxT5R2c8Hx9B8.wLCxVaGI6qnpj45Ug84kL+6YIM8CqUxJyycF +7bqsBRULGvwfWyRMyovElat7NvqoejaLm4f+fkmyKuVTHy3q3ldhB.WtQY6Z +x0BSOeSpTqA+FW+Yy3SyybH3sFy8p0RVCmaMpTyX6HdDZ2JsPbfSogbBMueH +JLd6RMBdfRMzPjZvimuWIK2XgFA.ZmtfKoh0Sm88qc6OF4bDQ3P6kEtF6xej +.OkjD4H5OllyS+.3FlhY0so4xRlWqyrXErQpt+2rsnXgQNZHZgmMVzEofW7T +S4zORQtgIdDbRHrObRzSMNofUVZVcbKbhQZrSOo934TqRHIN2ncr7BF8TKR1 +tHDqL.PejLRRPKMR.pKFAkbtDa+UOvsYsIFH0DYsTCjqZ66T1CmGeDILLpSm +myk0SdkOKh5LUr4GbWwRYdW7fm.BvDmzHnSdH3biGpSbxxDNJoGDAD1ChH7L +I0DaloOTBLvkO7zPs5HJnKNoGAXbol5eytUhfyiSfnjE1uAq+Fp0a+wygGwR +q3ZI8.psJpkpJnyPzwmXBj7Sh.+bNvVZxlcKAm0OYHIxcIjzEKdRChgO5UMf +LkMPNN0MfiS7Ev6TYQct.F5IWcCZ4504rGsiVswGWWSYyma01QcZgmL+f+sf +oU18Hn6o6dXkMkFF14TL9rIAWE+6wvGV.p.TPqz3HK5L+VxYxl4UmBKEjr.B +6zinuKI3C+D2Y7azIM6N7QL6t+jQyZxymK1ToAKqVsxjlGyjz2c1kTK3180h +kJEYkacWpv6lyp2VJTjWK47wHA6fyBOWxH9pUf6jUtZkLpNKW.9EeUBH3ymY +XSQlaqGrkQMGzp20adYSmIOGjIABo1xZyAWJtCX9tg6+HMuhMCPyx76ao+Us +UxmzUE79H8d2ZB1m1ztbnOa1mGeAq0awyK8a9UqBUc6pZolpzurTK232e5gp +aInVw8QIIcpaiNSJfY4Z+92Cs+Mc+mgg2cEsvGlLY6V+1kMuioxnB5VM+fsY +9vSu4WI1PMBGXye6KXvNuzmZTh7U9h5j6vvASdngPdgOFxycNL6ia1axUMmT +JIzebXcQCn3SKMf+4QCMmOZung+6xBCPLfwO8ngcEI52YJ1y7mx3CN9xKUYU +bg7Y1yXjlKW6SrZnguQdsSfOSSDItqv2jwJFjavc1vO7OigyBr2+gDYorRk1 +HXZpVFfu2FxXkZtfp4RQqNkX5y2sya3YYL2iavWAOaizH+pw.Ibg8f1I9h3Z +2B79sNeOHvBOtfEalWsvyu0KMf015.AaROvZ7vv5AhnndfHLbTgjcCK1KlHv +gOk5B26OqrXjcJ005.QqCHn8fVTxnxfj93SfQiJlv8YV0VT9fVUwOOhSV3uD +eeqCUClbBPa.j3vWDoMZssNTzRNEnE6gYPXazZaMF921syaLWyAeBXvCESA8 +ASi6Zyw8.RQi65J8ZsNx3ho93OhGWENtWpowepae4YhCFeLErOLENtXJrOSc +iadi39rf4hwc8xdhHz3gn3dBI7iDRlFe8huAfIZhq +-----------end_max5_patcher----------- + */ 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/keywords.txt b/build/shared/lib/keywords.txt index ad53668b2..730de4e75 100644 --- a/build/shared/lib/keywords.txt +++ b/build/shared/lib/keywords.txt @@ -8,7 +8,6 @@ DEC LITERAL1 Serial_Print BIN LITERAL1 Serial_Print HEX LITERAL1 Serial_Print OCT LITERAL1 Serial_Print -BYTE LITERAL1 Serial_Print PI LITERAL1 HALF_PI LITERAL1 TWO_PI LITERAL1 @@ -173,6 +172,13 @@ print KEYWORD2 Serial_Print println KEYWORD2 Serial_Println available KEYWORD2 Serial_Available flush KEYWORD2 Serial_Flush +setTimeout KEYWORD2 +find KEYWORD2 +findUntil KEYWORD2 +parseInt KEYWORD2 +parseFloat KEYWORD2 +readBytes KEYWORD2 +readBytesUntil KEYWORD2 setup KEYWORD3 Setup loop KEYWORD3 Loop 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..d8f5b7aa4 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 -linestatus.color = #ffffff -linestatus.bgcolor = #044f6f +# GUI - LINESTATUS +linestatus.color = #17A1A5 +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/dist/drivers/FTDI USB Drivers/Application Notes.url b/build/windows/dist/drivers/FTDI USB Drivers/Application Notes.url deleted file mode 100755 index 6ad7c91df..000000000 --- a/build/windows/dist/drivers/FTDI USB Drivers/Application Notes.url +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] -BASEURL=http://www.ftdichip.com/Documents/AppNotes.htm -[InternetShortcut] -URL=http://www.ftdichip.com/Documents/AppNotes.htm -Modified=C055946F4AF7C5011F -IconFile=C:\WINNT\system32\url.dll -IconIndex=0 diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTBUSUI.dll b/build/windows/dist/drivers/FTDI USB Drivers/FTBUSUI.dll deleted file mode 100755 index 2bc666345..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/FTBUSUI.dll and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.H b/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.H deleted file mode 100755 index 2507326c5..000000000 --- a/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.H +++ /dev/null @@ -1,875 +0,0 @@ -/*++ - -Copyright (c) 2001-2005 Future Technology Devices International Ltd. - -Module Name: - - ftd2xx.h - -Abstract: - - Native USB device driver for FTDI FT8U232/245 - FTD2XX library definitions - -Environment: - - kernel & user mode - -Revision History: - - 13/03/01 awm Created. - 13/01/03 awm Added device information support. - 19/03/03 awm Added FT_W32_CancelIo. - 12/06/03 awm Added FT_StopInTask and FT_RestartInTask. - 18/09/03 awm Added FT_SetResetPipeRetryCount. - 10/10/03 awm Added FT_ResetPort. - 23/01/04 awm Added support for open-by-location. - 16/03/04 awm Added support for FT2232C. - 23/09/04 awm Added support for FT232R. - 20/10/04 awm Added FT_CyclePort. - 18/01/05 awm Added FT_DEVICE_LIST_INFO_NODE type. - 11/02/05 awm Added LocId to FT_DEVICE_LIST_INFO_NODE. - 25/08/05 awm Added FT_SetDeadmanTimeout. - 02/12/05 awm Removed obsolete references. - 05/12/05 awm Added FT_GetVersion, FT_GetVersionEx. - - ---*/ - - -#ifndef FTD2XX_H -#define FTD2XX_H - -// The following ifdef block is the standard way of creating macros -// which make exporting from a DLL simpler. All files within this DLL -// are compiled with the FTD2XX_EXPORTS symbol defined on the command line. -// This symbol should not be defined on any project that uses this DLL. -// This way any other project whose source files include this file see -// FTD2XX_API functions as being imported from a DLL, whereas this DLL -// sees symbols defined with this macro as being exported. - -#ifdef FTD2XX_EXPORTS -#define FTD2XX_API __declspec(dllexport) -#else -#define FTD2XX_API __declspec(dllimport) -#endif - - -typedef PVOID FT_HANDLE; -typedef ULONG FT_STATUS; - -// -// Device status -// -enum { - FT_OK, - FT_INVALID_HANDLE, - FT_DEVICE_NOT_FOUND, - FT_DEVICE_NOT_OPENED, - FT_IO_ERROR, - FT_INSUFFICIENT_RESOURCES, - FT_INVALID_PARAMETER, - FT_INVALID_BAUD_RATE, - - FT_DEVICE_NOT_OPENED_FOR_ERASE, - FT_DEVICE_NOT_OPENED_FOR_WRITE, - FT_FAILED_TO_WRITE_DEVICE, - FT_EEPROM_READ_FAILED, - FT_EEPROM_WRITE_FAILED, - FT_EEPROM_ERASE_FAILED, - FT_EEPROM_NOT_PRESENT, - FT_EEPROM_NOT_PROGRAMMED, - FT_INVALID_ARGS, - FT_NOT_SUPPORTED, - FT_OTHER_ERROR -}; - - -#define FT_SUCCESS(status) ((status) == FT_OK) - -// -// FT_OpenEx Flags -// - -#define FT_OPEN_BY_SERIAL_NUMBER 1 -#define FT_OPEN_BY_DESCRIPTION 2 -#define FT_OPEN_BY_LOCATION 4 - -// -// FT_ListDevices Flags (used in conjunction with FT_OpenEx Flags -// - -#define FT_LIST_NUMBER_ONLY 0x80000000 -#define FT_LIST_BY_INDEX 0x40000000 -#define FT_LIST_ALL 0x20000000 - -#define FT_LIST_MASK (FT_LIST_NUMBER_ONLY|FT_LIST_BY_INDEX|FT_LIST_ALL) - -// -// Baud Rates -// - -#define FT_BAUD_300 300 -#define FT_BAUD_600 600 -#define FT_BAUD_1200 1200 -#define FT_BAUD_2400 2400 -#define FT_BAUD_4800 4800 -#define FT_BAUD_9600 9600 -#define FT_BAUD_14400 14400 -#define FT_BAUD_19200 19200 -#define FT_BAUD_38400 38400 -#define FT_BAUD_57600 57600 -#define FT_BAUD_115200 115200 -#define FT_BAUD_230400 230400 -#define FT_BAUD_460800 460800 -#define FT_BAUD_921600 921600 - -// -// Word Lengths -// - -#define FT_BITS_8 (UCHAR) 8 -#define FT_BITS_7 (UCHAR) 7 -#define FT_BITS_6 (UCHAR) 6 -#define FT_BITS_5 (UCHAR) 5 - -// -// Stop Bits -// - -#define FT_STOP_BITS_1 (UCHAR) 0 -#define FT_STOP_BITS_1_5 (UCHAR) 1 -#define FT_STOP_BITS_2 (UCHAR) 2 - -// -// Parity -// - -#define FT_PARITY_NONE (UCHAR) 0 -#define FT_PARITY_ODD (UCHAR) 1 -#define FT_PARITY_EVEN (UCHAR) 2 -#define FT_PARITY_MARK (UCHAR) 3 -#define FT_PARITY_SPACE (UCHAR) 4 - -// -// Flow Control -// - -#define FT_FLOW_NONE 0x0000 -#define FT_FLOW_RTS_CTS 0x0100 -#define FT_FLOW_DTR_DSR 0x0200 -#define FT_FLOW_XON_XOFF 0x0400 - -// -// Purge rx and tx buffers -// -#define FT_PURGE_RX 1 -#define FT_PURGE_TX 2 - -// -// Events -// - -typedef void (*PFT_EVENT_HANDLER)(DWORD,DWORD); - -#define FT_EVENT_RXCHAR 1 -#define FT_EVENT_MODEM_STATUS 2 - -// -// Timeouts -// - -#define FT_DEFAULT_RX_TIMEOUT 300 -#define FT_DEFAULT_TX_TIMEOUT 300 - -// -// Device types -// - -typedef ULONG FT_DEVICE; - -enum { - FT_DEVICE_BM, - FT_DEVICE_AM, - FT_DEVICE_100AX, - FT_DEVICE_UNKNOWN, - FT_DEVICE_2232C, - FT_DEVICE_232R -}; - - -#ifdef __cplusplus -extern "C" { -#endif - - -FTD2XX_API -FT_STATUS WINAPI FT_Open( - int deviceNumber, - FT_HANDLE *pHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_OpenEx( - PVOID pArg1, - DWORD Flags, - FT_HANDLE *pHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_ListDevices( - PVOID pArg1, - PVOID pArg2, - DWORD Flags - ); - -FTD2XX_API -FT_STATUS WINAPI FT_Close( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_Read( - FT_HANDLE ftHandle, - LPVOID lpBuffer, - DWORD nBufferSize, - LPDWORD lpBytesReturned - ); - -FTD2XX_API -FT_STATUS WINAPI FT_Write( - FT_HANDLE ftHandle, - LPVOID lpBuffer, - DWORD nBufferSize, - LPDWORD lpBytesWritten - ); - -FTD2XX_API -FT_STATUS WINAPI FT_IoCtl( - FT_HANDLE ftHandle, - DWORD dwIoControlCode, - LPVOID lpInBuf, - DWORD nInBufSize, - LPVOID lpOutBuf, - DWORD nOutBufSize, - LPDWORD lpBytesReturned, - LPOVERLAPPED lpOverlapped - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetBaudRate( - FT_HANDLE ftHandle, - ULONG BaudRate - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetDivisor( - FT_HANDLE ftHandle, - USHORT Divisor - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetDataCharacteristics( - FT_HANDLE ftHandle, - UCHAR WordLength, - UCHAR StopBits, - UCHAR Parity - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetFlowControl( - FT_HANDLE ftHandle, - USHORT FlowControl, - UCHAR XonChar, - UCHAR XoffChar - ); - -FTD2XX_API -FT_STATUS WINAPI FT_ResetDevice( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetDtr( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_ClrDtr( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetRts( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_ClrRts( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetModemStatus( - FT_HANDLE ftHandle, - ULONG *pModemStatus - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetChars( - FT_HANDLE ftHandle, - UCHAR EventChar, - UCHAR EventCharEnabled, - UCHAR ErrorChar, - UCHAR ErrorCharEnabled - ); - -FTD2XX_API -FT_STATUS WINAPI FT_Purge( - FT_HANDLE ftHandle, - ULONG Mask - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetTimeouts( - FT_HANDLE ftHandle, - ULONG ReadTimeout, - ULONG WriteTimeout - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetQueueStatus( - FT_HANDLE ftHandle, - DWORD *dwRxBytes - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetEventNotification( - FT_HANDLE ftHandle, - DWORD Mask, - PVOID Param - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetStatus( - FT_HANDLE ftHandle, - DWORD *dwRxBytes, - DWORD *dwTxBytes, - DWORD *dwEventDWord - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetBreakOn( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetBreakOff( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetWaitMask( - FT_HANDLE ftHandle, - DWORD Mask - ); - -FTD2XX_API -FT_STATUS WINAPI FT_WaitOnMask( - FT_HANDLE ftHandle, - DWORD *Mask - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetEventStatus( - FT_HANDLE ftHandle, - DWORD *dwEventDWord - ); - -FTD2XX_API -FT_STATUS WINAPI FT_ReadEE( - FT_HANDLE ftHandle, - DWORD dwWordOffset, - LPWORD lpwValue - ); - -FTD2XX_API -FT_STATUS WINAPI FT_WriteEE( - FT_HANDLE ftHandle, - DWORD dwWordOffset, - WORD wValue - ); - -FTD2XX_API -FT_STATUS WINAPI FT_EraseEE( - FT_HANDLE ftHandle - ); - -// -// structure to hold program data for FT_Program function -// -typedef struct ft_program_data { - - DWORD Signature1; // Header - must be 0x00000000 - DWORD Signature2; // Header - must be 0xffffffff - DWORD Version; // Header - FT_PROGRAM_DATA version - // 0 = original - // 1 = FT2232C extensions - // 2 = FT232R extensions - - WORD VendorId; // 0x0403 - WORD ProductId; // 0x6001 - char *Manufacturer; // "FTDI" - char *ManufacturerId; // "FT" - char *Description; // "USB HS Serial Converter" - char *SerialNumber; // "FT000001" if fixed, or NULL - WORD MaxPower; // 0 < MaxPower <= 500 - WORD PnP; // 0 = disabled, 1 = enabled - WORD SelfPowered; // 0 = bus powered, 1 = self powered - WORD RemoteWakeup; // 0 = not capable, 1 = capable - // - // Rev4 extensions - // - UCHAR Rev4; // non-zero if Rev4 chip, zero otherwise - UCHAR IsoIn; // non-zero if in endpoint is isochronous - UCHAR IsoOut; // non-zero if out endpoint is isochronous - UCHAR PullDownEnable; // non-zero if pull down enabled - UCHAR SerNumEnable; // non-zero if serial number to be used - UCHAR USBVersionEnable; // non-zero if chip uses USBVersion - WORD USBVersion; // BCD (0x0200 => USB2) - // - // FT2232C extensions - // - UCHAR Rev5; // non-zero if Rev5 chip, zero otherwise - UCHAR IsoInA; // non-zero if in endpoint is isochronous - UCHAR IsoInB; // non-zero if in endpoint is isochronous - UCHAR IsoOutA; // non-zero if out endpoint is isochronous - UCHAR IsoOutB; // non-zero if out endpoint is isochronous - UCHAR PullDownEnable5; // non-zero if pull down enabled - UCHAR SerNumEnable5; // non-zero if serial number to be used - UCHAR USBVersionEnable5; // non-zero if chip uses USBVersion - WORD USBVersion5; // BCD (0x0200 => USB2) - UCHAR AIsHighCurrent; // non-zero if interface is high current - UCHAR BIsHighCurrent; // non-zero if interface is high current - UCHAR IFAIsFifo; // non-zero if interface is 245 FIFO - UCHAR IFAIsFifoTar; // non-zero if interface is 245 FIFO CPU target - UCHAR IFAIsFastSer; // non-zero if interface is Fast serial - UCHAR AIsVCP; // non-zero if interface is to use VCP drivers - UCHAR IFBIsFifo; // non-zero if interface is 245 FIFO - UCHAR IFBIsFifoTar; // non-zero if interface is 245 FIFO CPU target - UCHAR IFBIsFastSer; // non-zero if interface is Fast serial - UCHAR BIsVCP; // non-zero if interface is to use VCP drivers - // - // FT232R extensions - // - UCHAR UseExtOsc; // Use External Oscillator - UCHAR HighDriveIOs; // High Drive I/Os - UCHAR EndpointSize; // Endpoint size - - UCHAR PullDownEnableR; // non-zero if pull down enabled - UCHAR SerNumEnableR; // non-zero if serial number to be used - - UCHAR InvertTXD; // non-zero if invert TXD - UCHAR InvertRXD; // non-zero if invert RXD - UCHAR InvertRTS; // non-zero if invert RTS - UCHAR InvertCTS; // non-zero if invert CTS - UCHAR InvertDTR; // non-zero if invert DTR - UCHAR InvertDSR; // non-zero if invert DSR - UCHAR InvertDCD; // non-zero if invert DCD - UCHAR InvertRI; // non-zero if invert RI - - UCHAR Cbus0; // Cbus Mux control - UCHAR Cbus1; // Cbus Mux control - UCHAR Cbus2; // Cbus Mux control - UCHAR Cbus3; // Cbus Mux control - UCHAR Cbus4; // Cbus Mux control - - UCHAR RIsVCP; // non-zero if using VCP drivers - -} FT_PROGRAM_DATA, *PFT_PROGRAM_DATA; - -FTD2XX_API -FT_STATUS WINAPI FT_EE_Program( - FT_HANDLE ftHandle, - PFT_PROGRAM_DATA pData - ); - -FTD2XX_API -FT_STATUS WINAPI FT_EE_ProgramEx( - FT_HANDLE ftHandle, - PFT_PROGRAM_DATA pData, - char *Manufacturer, - char *ManufacturerId, - char *Description, - char *SerialNumber - ); - -FTD2XX_API -FT_STATUS WINAPI FT_EE_Read( - FT_HANDLE ftHandle, - PFT_PROGRAM_DATA pData - ); - -FTD2XX_API -FT_STATUS WINAPI FT_EE_ReadEx( - FT_HANDLE ftHandle, - PFT_PROGRAM_DATA pData, - char *Manufacturer, - char *ManufacturerId, - char *Description, - char *SerialNumber - ); - -FTD2XX_API -FT_STATUS WINAPI FT_EE_UASize( - FT_HANDLE ftHandle, - LPDWORD lpdwSize - ); - -FTD2XX_API -FT_STATUS WINAPI FT_EE_UAWrite( - FT_HANDLE ftHandle, - PUCHAR pucData, - DWORD dwDataLen - ); - -FTD2XX_API -FT_STATUS WINAPI FT_EE_UARead( - FT_HANDLE ftHandle, - PUCHAR pucData, - DWORD dwDataLen, - LPDWORD lpdwBytesRead - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetLatencyTimer( - FT_HANDLE ftHandle, - UCHAR ucLatency - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetLatencyTimer( - FT_HANDLE ftHandle, - PUCHAR pucLatency - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetBitMode( - FT_HANDLE ftHandle, - UCHAR ucMask, - UCHAR ucEnable - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetBitMode( - FT_HANDLE ftHandle, - PUCHAR pucMode - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetUSBParameters( - FT_HANDLE ftHandle, - ULONG ulInTransferSize, - ULONG ulOutTransferSize - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetDeadmanTimeout( - FT_HANDLE ftHandle, - ULONG ulDeadmanTimeout - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetDeviceInfo( - FT_HANDLE ftHandle, - FT_DEVICE *lpftDevice, - LPDWORD lpdwID, - PCHAR SerialNumber, - PCHAR Description, - LPVOID Dummy - ); - -FTD2XX_API -FT_STATUS WINAPI FT_StopInTask( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_RestartInTask( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_SetResetPipeRetryCount( - FT_HANDLE ftHandle, - DWORD dwCount - ); - -FTD2XX_API -FT_STATUS WINAPI FT_ResetPort( - FT_HANDLE ftHandle - ); - -FTD2XX_API -FT_STATUS WINAPI FT_CyclePort( - FT_HANDLE ftHandle - ); - - -// -// Win32-type functions -// - -FTD2XX_API -FT_HANDLE WINAPI FT_W32_CreateFile( - LPCSTR lpszName, - DWORD dwAccess, - DWORD dwShareMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - DWORD dwCreate, - DWORD dwAttrsAndFlags, - HANDLE hTemplate - ); - -FTD2XX_API -BOOL WINAPI FT_W32_CloseHandle( - FT_HANDLE ftHandle - ); - -FTD2XX_API -BOOL WINAPI FT_W32_ReadFile( - FT_HANDLE ftHandle, - LPVOID lpBuffer, - DWORD nBufferSize, - LPDWORD lpBytesReturned, - LPOVERLAPPED lpOverlapped - ); - -FTD2XX_API -BOOL WINAPI FT_W32_WriteFile( - FT_HANDLE ftHandle, - LPVOID lpBuffer, - DWORD nBufferSize, - LPDWORD lpBytesWritten, - LPOVERLAPPED lpOverlapped - ); - -FTD2XX_API -DWORD WINAPI FT_W32_GetLastError( - FT_HANDLE ftHandle - ); - -FTD2XX_API -BOOL WINAPI FT_W32_GetOverlappedResult( - FT_HANDLE ftHandle, - LPOVERLAPPED lpOverlapped, - LPDWORD lpdwBytesTransferred, - BOOL bWait - ); - -FTD2XX_API -BOOL WINAPI FT_W32_CancelIo( - FT_HANDLE ftHandle - ); - - -// -// Win32 COMM API type functions -// -typedef struct _FTCOMSTAT { - DWORD fCtsHold : 1; - DWORD fDsrHold : 1; - DWORD fRlsdHold : 1; - DWORD fXoffHold : 1; - DWORD fXoffSent : 1; - DWORD fEof : 1; - DWORD fTxim : 1; - DWORD fReserved : 25; - DWORD cbInQue; - DWORD cbOutQue; -} FTCOMSTAT, *LPFTCOMSTAT; - -typedef struct _FTDCB { - DWORD DCBlength; /* sizeof(FTDCB) */ - DWORD BaudRate; /* Baudrate at which running */ - DWORD fBinary: 1; /* Binary Mode (skip EOF check) */ - DWORD fParity: 1; /* Enable parity checking */ - DWORD fOutxCtsFlow:1; /* CTS handshaking on output */ - DWORD fOutxDsrFlow:1; /* DSR handshaking on output */ - DWORD fDtrControl:2; /* DTR Flow control */ - DWORD fDsrSensitivity:1; /* DSR Sensitivity */ - DWORD fTXContinueOnXoff: 1; /* Continue TX when Xoff sent */ - DWORD fOutX: 1; /* Enable output X-ON/X-OFF */ - DWORD fInX: 1; /* Enable input X-ON/X-OFF */ - DWORD fErrorChar: 1; /* Enable Err Replacement */ - DWORD fNull: 1; /* Enable Null stripping */ - DWORD fRtsControl:2; /* Rts Flow control */ - DWORD fAbortOnError:1; /* Abort all reads and writes on Error */ - DWORD fDummy2:17; /* Reserved */ - WORD wReserved; /* Not currently used */ - WORD XonLim; /* Transmit X-ON threshold */ - WORD XoffLim; /* Transmit X-OFF threshold */ - BYTE ByteSize; /* Number of bits/byte, 4-8 */ - BYTE Parity; /* 0-4=None,Odd,Even,Mark,Space */ - BYTE StopBits; /* 0,1,2 = 1, 1.5, 2 */ - char XonChar; /* Tx and Rx X-ON character */ - char XoffChar; /* Tx and Rx X-OFF character */ - char ErrorChar; /* Error replacement char */ - char EofChar; /* End of Input character */ - char EvtChar; /* Received Event character */ - WORD wReserved1; /* Fill for now. */ -} FTDCB, *LPFTDCB; - -typedef struct _FTTIMEOUTS { - DWORD ReadIntervalTimeout; /* Maximum time between read chars. */ - DWORD ReadTotalTimeoutMultiplier; /* Multiplier of characters. */ - DWORD ReadTotalTimeoutConstant; /* Constant in milliseconds. */ - DWORD WriteTotalTimeoutMultiplier; /* Multiplier of characters. */ - DWORD WriteTotalTimeoutConstant; /* Constant in milliseconds. */ -} FTTIMEOUTS,*LPFTTIMEOUTS; - - -FTD2XX_API -BOOL WINAPI FT_W32_ClearCommBreak( - FT_HANDLE ftHandle - ); - -FTD2XX_API -BOOL WINAPI FT_W32_ClearCommError( - FT_HANDLE ftHandle, - LPDWORD lpdwErrors, - LPFTCOMSTAT lpftComstat - ); - -FTD2XX_API -BOOL WINAPI FT_W32_EscapeCommFunction( - FT_HANDLE ftHandle, - DWORD dwFunc - ); - -FTD2XX_API -BOOL WINAPI FT_W32_GetCommModemStatus( - FT_HANDLE ftHandle, - LPDWORD lpdwModemStatus - ); - -FTD2XX_API -BOOL WINAPI FT_W32_GetCommState( - FT_HANDLE ftHandle, - LPFTDCB lpftDcb - ); - -FTD2XX_API -BOOL WINAPI FT_W32_GetCommTimeouts( - FT_HANDLE ftHandle, - FTTIMEOUTS *pTimeouts - ); - -FTD2XX_API -BOOL WINAPI FT_W32_PurgeComm( - FT_HANDLE ftHandle, - DWORD dwMask - ); - -FTD2XX_API -BOOL WINAPI FT_W32_SetCommBreak( - FT_HANDLE ftHandle - ); - -FTD2XX_API -BOOL WINAPI FT_W32_SetCommMask( - FT_HANDLE ftHandle, - ULONG ulEventMask - ); - -FTD2XX_API -BOOL WINAPI FT_W32_SetCommState( - FT_HANDLE ftHandle, - LPFTDCB lpftDcb - ); - -FTD2XX_API -BOOL WINAPI FT_W32_SetCommTimeouts( - FT_HANDLE ftHandle, - FTTIMEOUTS *pTimeouts - ); - -FTD2XX_API -BOOL WINAPI FT_W32_SetupComm( - FT_HANDLE ftHandle, - DWORD dwReadBufferSize, - DWORD dwWriteBufferSize - ); - -FTD2XX_API -BOOL WINAPI FT_W32_WaitCommEvent( - FT_HANDLE ftHandle, - PULONG pulEvent, - LPOVERLAPPED lpOverlapped - ); - - -// -// Device information -// - -typedef struct _ft_device_list_info_node { - ULONG Flags; - ULONG Type; - ULONG ID; - DWORD LocId; - char SerialNumber[16]; - char Description[64]; - FT_HANDLE ftHandle; -} FT_DEVICE_LIST_INFO_NODE; - - -FTD2XX_API -FT_STATUS WINAPI FT_CreateDeviceInfoList( - LPDWORD lpdwNumDevs - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetDeviceInfoList( - FT_DEVICE_LIST_INFO_NODE *pDest, - LPDWORD lpdwNumDevs - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetDeviceInfoDetail( - DWORD dwIndex, - LPDWORD lpdwFlags, - LPDWORD lpdwType, - LPDWORD lpdwID, - LPDWORD lpdwLocId, - LPVOID lpSerialNumber, - LPVOID lpDescription, - FT_HANDLE *pftHandle - ); - - -// -// Version information -// - -FTD2XX_API -FT_STATUS WINAPI FT_GetDriverVersion( - FT_HANDLE ftHandle, - LPDWORD lpdwVersion - ); - -FTD2XX_API -FT_STATUS WINAPI FT_GetLibraryVersion( - LPDWORD lpdwVersion - ); - - - - -#ifdef __cplusplus -} -#endif - - -#endif /* FTD2XX_H */ - diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.dll b/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.dll deleted file mode 100755 index b2b9f0fe2..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.dll and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.lib b/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.lib deleted file mode 100755 index 07451b4f1..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/FTD2XX.lib and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTDIBUS.INF b/build/windows/dist/drivers/FTDI USB Drivers/FTDIBUS.INF deleted file mode 100755 index 8b5b308d1..000000000 --- a/build/windows/dist/drivers/FTDI USB Drivers/FTDIBUS.INF +++ /dev/null @@ -1,88 +0,0 @@ -; FTDIBUS.INF -; Copyright (c) 2000-2006 FTDI Ltd. -; -; USB serial converter driver installation for Windows 2000 and XP. -; - -[Version] -Signature="$Windows NT$" -DriverPackageType=PlugAndPlay -DriverPackageDisplayName=%DESC% -Class=USB -ClassGUID={36fc9e60-c465-11cf-8056-444553540000} -Provider=%FTDI% -CatalogFile=ftdibus.cat -DriverVer=05/19/2006,2.00.00 - -[SourceDisksNames] -1=%DriversDisk%,,, - -[SourceDisksFiles] -ftdibus.sys = 1 -ftdiunin.exe = 1 -ftdiun2k.ini = 1 -ftbusui.dll = 1 -ftd2xx.dll = 1 - -[DestinationDirs] -FtdiBus.NT.Copy = 10,system32\drivers -FtdiBus.NT.Copy2 = 10,system32 - -[Manufacturer] -%Ftdi%=FtdiHw - -[FtdiHw] -%USB\VID_0403&PID_6001.DeviceDesc%=FtdiBus,USB\VID_0403&PID_6001 -%USB\VID_0403&PID_6010&MI_00.DeviceDesc%=FtdiBus,USB\VID_0403&PID_6010&MI_00 -%USB\VID_0403&PID_6010&MI_01.DeviceDesc%=FtdiBus,USB\VID_0403&PID_6010&MI_01 - -[ControlFlags] -ExcludeFromSelect=* - -[FtdiBus.NT] -CopyFiles=FtdiBus.NT.Copy,FtdiBus.NT.Copy2 -AddReg=FtdiBus.NT.AddReg,FtdiBusUnInst.NT.Reg - -[FtdiBus.NT.Services] -AddService = FTDIBUS, 0x00000002, FtdiBus.NT.AddService - -[FtdiBus.NT.AddService] -DisplayName = %SvcDesc% -ServiceType = 1 ; SERVICE_KERNEL_DRIVER -StartType = 3 ; SERVICE_DEMAND_START -ErrorControl = 1 ; SERVICE_ERROR_NORMAL -ServiceBinary = %10%\system32\drivers\ftdibus.sys -LoadOrderGroup = Base - -[FtdiBus.NT.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,ftdibus.sys -HKR,,EnumPropPages32,,"ftbusui.dll,FTBUSUIPropPageProvider" - -[FtdiBus.NT.Copy] -ftdibus.sys - -[FtdiBus.NT.Copy2] -ftdiunin.exe -ftdiun2k.ini -ftbusui.dll -ftd2xx.dll - -[FtdiBusUnInst.NT.Reg] -HKLM,%WINUN%,"FTDICOMM" -HKLM,%WINUN%\FTDICOMM , "UninstallString",,"%11%\ftdiunin.exe %11%\ftdiun2k.ini" -HKLM,%WINUN%\FTDICOMM , "DisplayName",,"FTDI USB Serial Converter Drivers" -HKLM,%WINUN%\FTDICOMM , "URLInfoAbout",,"http://www.ftdichip.com" -HKLM,%WINUN%\FTDICOMM , "Publisher",,"FTDI Ltd" -HKLM,%WINUN%\FTDICOMM , "DisplayVersion",,"2.00.00" - -[Strings] -Ftdi="FTDI" -DESC="CDM Driver Package" -DriversDisk="FTDI USB Drivers Disk" -USB\VID_0403&PID_6001.DeviceDesc="USB Serial Converter" -USB\VID_0403&PID_6010&MI_00.DeviceDesc="USB Serial Converter A" -USB\VID_0403&PID_6010&MI_01.DeviceDesc="USB Serial Converter B" -WINUN="Software\Microsoft\Windows\CurrentVersion\Uninstall" -SvcDesc="USB Serial Converter Driver" -ClassName="USB" diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTDIBUS.sys b/build/windows/dist/drivers/FTDI USB Drivers/FTDIBUS.sys deleted file mode 100755 index 1f091c86e..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/FTDIBUS.sys and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTDIPORT.INF b/build/windows/dist/drivers/FTDI USB Drivers/FTDIPORT.INF deleted file mode 100755 index fc5259004..000000000 --- a/build/windows/dist/drivers/FTDI USB Drivers/FTDIPORT.INF +++ /dev/null @@ -1,127 +0,0 @@ -; FTDIPORT.INF -; Copyright (c) 2000-2006 FTDI Ltd. -; -; USB serial port driver installation for Windows 2000 and XP. -; - -[Version] -Signature="$Windows NT$" -DriverPackageType=PlugAndPlay -DriverPackageDisplayName=%DESC% -Class=Ports -ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318} -Provider=%FTDI% -CatalogFile=ftdiport.cat -DriverVer=05/19/2006,2.00.00 - -[SourceDisksNames] -1=%DriversDisk%,,, - -[SourceDisksFiles] -ftser2k.sys=1 -ftserui2.dll=1 -FTLang.Dll = 1 -ftcserco.dll = 1 - -[DestinationDirs] -FtdiPort.NT.Copy=10,system32\drivers -FtdiPort.NT.CopyUI=10,system32 -FtdiPort2232.NT.CopyCoInst=10,system32 - -[ControlFlags] -ExcludeFromSelect=* - -[Manufacturer] -%FTDI%=FtdiHw - -[FtdiHw] -%VID_0403&PID_6001.DeviceDesc%=FtdiPort232,FTDIBUS\COMPORT&VID_0403&PID_6001 -%VID_0403&PID_6010.DeviceDesc%=FtdiPort2232,FTDIBUS\COMPORT&VID_0403&PID_6010 - -[FtdiPort.NT.AddService] -DisplayName = %SvcDesc% -ServiceType = 1 ; SERVICE_KERNEL_DRIVER -StartType = 3 ; SERVICE_DEMAND_START -ErrorControl = 1 ; SERVICE_ERROR_NORMAL -ServiceBinary = %10%\system32\drivers\ftser2k.sys -LoadOrderGroup = Base - -; -------------- Serenum Driver install section -[SerEnum_AddService] -DisplayName = %SerEnum.SvcDesc% -ServiceType = 1 ; SERVICE_KERNEL_DRIVER -StartType = 3 ; SERVICE_DEMAND_START -ErrorControl = 1 ; SERVICE_ERROR_NORMAL -ServiceBinary = %12%\serenum.sys -LoadOrderGroup = PNP Filter - -[FtdiPort.NT.AddReg] -HKR,,EnumPropPages32,,"ftserui2.dll,SerialPortPropPageProvider" - -[FtdiPort.NT.Copy] -ftser2k.sys -;serenum.sys - -[FtdiPort.NT.CopyUI] -ftserui2.dll -FTLang.dll - -[FtdiPort232.NT] -CopyFiles=FtdiPort.NT.Copy,FtdiPort.NT.CopyUI -AddReg=FtdiPort.NT.AddReg - -[FtdiPort232.NT.HW] -AddReg=FtdiPort232.NT.HW.AddReg - -[FtdiPort232.NT.Services] -AddService = FTSER2K, 0x00000002, FtdiPort.NT.AddService -AddService = Serenum,,SerEnum_AddService -DelService = FTSERIAL - -[FtdiPort232.NT.HW.AddReg] -HKR,,"UpperFilters",0x00010000,"serenum" -;HKR,,"ConfigData",1,01,00,3F,3F,10,27,88,13,C4,09,E2,04,71,02,38,41,9c,80,4E,C0,34,00,1A,00,0D,00,06,40,03,80,00,00,d0,80 -HKR,,"ConfigData",1,11,00,3F,3F,10,27,00,00,88,13,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,4E,C0,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00 -HKR,,"MinReadTimeout",0x00010001,0 -HKR,,"MinWriteTimeout",0x00010001,0 -HKR,,"LatencyTimer",0x00010001,16 - -; ------- -; FT2232C -; ------- - -[FtdiPort2232.NT] -CopyFiles=FtdiPort.NT.Copy,FtdiPort.NT.CopyUI -AddReg=FtdiPort.NT.AddReg - -[FtdiPort2232.NT.HW] -AddReg=FtdiPort232.NT.HW.AddReg - -[FtdiPort2232.NT.CoInstallers] -AddReg=FtdiPort2232.NT.CoInstallers.AddReg -CopyFiles=FtdiPort2232.NT.CopyCoInst - -[FtdiPort2232.NT.Services] -AddService = FTSER2K, 0x00000002, FtdiPort.NT.AddService -AddService = Serenum,,SerEnum_AddService -DelService = FTSERIAL - -[FtdiPort2232.NT.CoInstallers.AddReg] -HKR,,CoInstallers32,0x00010000,"ftcserco.Dll,FTCSERCoInstaller" - -[FtdiPort2232.NT.CopyCoInst] -ftcserco.dll - -;---------------------------------------------------------------; - -[Strings] -FTDI="FTDI" -DESC="CDM Driver Package" -DriversDisk="FTDI USB Drivers Disk" -PortsClassName = "Ports (COM & LPT)" -VID_0403&PID_6001.DeviceDesc="USB Serial Port" -VID_0403&PID_6010.DeviceDesc="USB Serial Port" -SvcDesc="USB Serial Port Driver" -SerEnum.SvcDesc="Serenum Filter Driver" - - diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTDIUN2K.INI b/build/windows/dist/drivers/FTDI USB Drivers/FTDIUN2K.INI deleted file mode 100755 index 15162f92a..000000000 --- a/build/windows/dist/drivers/FTDI USB Drivers/FTDIUN2K.INI +++ /dev/null @@ -1,6 +0,0 @@ -[Uninstall] -Device=VID_0403&PID_6001,VID_0403&PID_6010 -Converter=FTDIBUS -Serial=FTSER2K -InfFiles=FTDIBUS,FTDIPORT -Key=FTDICOMM diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTDIUNIN.exe b/build/windows/dist/drivers/FTDI USB Drivers/FTDIUNIN.exe deleted file mode 100755 index 4cee7519c..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/FTDIUNIN.exe and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/FTLang.dll b/build/windows/dist/drivers/FTDI USB Drivers/FTLang.dll deleted file mode 100755 index a64d28715..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/FTLang.dll and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/Installation Guides.url b/build/windows/dist/drivers/FTDI USB Drivers/Installation Guides.url deleted file mode 100755 index b885746ce..000000000 --- a/build/windows/dist/drivers/FTDI USB Drivers/Installation Guides.url +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] -BASEURL=http://www.ftdichip.com/Documents/InstallGuides.htm -[InternetShortcut] -URL=http://www.ftdichip.com/Documents/InstallGuides.htm -Modified=606147754AF7C50184 -IconFile=C:\WINNT\system32\url.dll -IconIndex=0 diff --git a/build/windows/dist/drivers/FTDI USB Drivers/LogoVerificationReport.pdf b/build/windows/dist/drivers/FTDI USB Drivers/LogoVerificationReport.pdf new file mode 100644 index 000000000..c20940a60 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/LogoVerificationReport.pdf differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/Static/amd64/ftd2xx.lib b/build/windows/dist/drivers/FTDI USB Drivers/Static/amd64/ftd2xx.lib new file mode 100644 index 000000000..d7a7b14f4 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/Static/amd64/ftd2xx.lib differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/Static/i386/ftd2xx.lib b/build/windows/dist/drivers/FTDI USB Drivers/Static/i386/ftd2xx.lib new file mode 100644 index 000000000..454de03e9 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/Static/i386/ftd2xx.lib differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftbusui.dll b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftbusui.dll new file mode 100644 index 000000000..ce8362eac Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftbusui.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftcserco.dll b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftcserco.dll new file mode 100644 index 000000000..18c231ba9 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftcserco.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftd2xx.lib b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftd2xx.lib new file mode 100644 index 000000000..96b42848a Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftd2xx.lib differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftd2xx64.dll b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftd2xx64.dll new file mode 100644 index 000000000..2c2602c1d Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftd2xx64.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftdibus.sys b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftdibus.sys new file mode 100644 index 000000000..1aa826c30 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftdibus.sys differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftlang.dll b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftlang.dll new file mode 100644 index 000000000..45be20f7f Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftlang.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftser2k.sys b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftser2k.sys new file mode 100644 index 000000000..d8bcf2fb7 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftser2k.sys differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftserui2.dll b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftserui2.dll new file mode 100644 index 000000000..d5a727a23 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/amd64/ftserui2.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/ftcserco.dll b/build/windows/dist/drivers/FTDI USB Drivers/ftcserco.dll deleted file mode 100755 index 9c493d3e5..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/ftcserco.dll and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/ftd2xx.h b/build/windows/dist/drivers/FTDI USB Drivers/ftd2xx.h new file mode 100644 index 000000000..65701b548 --- /dev/null +++ b/build/windows/dist/drivers/FTDI USB Drivers/ftd2xx.h @@ -0,0 +1,1067 @@ +/*++ + +Copyright © 2001-2011 Future Technology Devices International Limited + +THIS SOFTWARE IS PROVIDED BY FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +FTDI DRIVERS MAY BE USED ONLY IN CONJUNCTION WITH PRODUCTS BASED ON FTDI PARTS. + +FTDI DRIVERS MAY BE DISTRIBUTED IN ANY FORM AS LONG AS LICENSE INFORMATION IS NOT MODIFIED. + +IF A CUSTOM VENDOR ID AND/OR PRODUCT ID OR DESCRIPTION STRING ARE USED, IT IS THE +RESPONSIBILITY OF THE PRODUCT MANUFACTURER TO MAINTAIN ANY CHANGES AND SUBSEQUENT WHQL +RE-CERTIFICATION AS A RESULT OF MAKING THESE CHANGES. + + +Module Name: + +ftd2xx.h + +Abstract: + +Native USB device driver for FTDI FT232x, FT245x, FT2232x and FT4232x devices +FTD2XX library definitions + +Environment: + +kernel & user mode + + +--*/ + + +#ifndef FTD2XX_H +#define FTD2XX_H + +// The following ifdef block is the standard way of creating macros +// which make exporting from a DLL simpler. All files within this DLL +// are compiled with the FTD2XX_EXPORTS symbol defined on the command line. +// This symbol should not be defined on any project that uses this DLL. +// This way any other project whose source files include this file see +// FTD2XX_API functions as being imported from a DLL, whereas this DLL +// sees symbols defined with this macro as being exported. + +#ifdef FTD2XX_EXPORTS +#define FTD2XX_API __declspec(dllexport) +#else +#define FTD2XX_API __declspec(dllimport) +#endif + + +typedef PVOID FT_HANDLE; +typedef ULONG FT_STATUS; + +// +// Device status +// +enum { + FT_OK, + FT_INVALID_HANDLE, + FT_DEVICE_NOT_FOUND, + FT_DEVICE_NOT_OPENED, + FT_IO_ERROR, + FT_INSUFFICIENT_RESOURCES, + FT_INVALID_PARAMETER, + FT_INVALID_BAUD_RATE, + + FT_DEVICE_NOT_OPENED_FOR_ERASE, + FT_DEVICE_NOT_OPENED_FOR_WRITE, + FT_FAILED_TO_WRITE_DEVICE, + FT_EEPROM_READ_FAILED, + FT_EEPROM_WRITE_FAILED, + FT_EEPROM_ERASE_FAILED, + FT_EEPROM_NOT_PRESENT, + FT_EEPROM_NOT_PROGRAMMED, + FT_INVALID_ARGS, + FT_NOT_SUPPORTED, + FT_OTHER_ERROR, + FT_DEVICE_LIST_NOT_READY, +}; + + +#define FT_SUCCESS(status) ((status) == FT_OK) + +// +// FT_OpenEx Flags +// + +#define FT_OPEN_BY_SERIAL_NUMBER 1 +#define FT_OPEN_BY_DESCRIPTION 2 +#define FT_OPEN_BY_LOCATION 4 + +// +// FT_ListDevices Flags (used in conjunction with FT_OpenEx Flags +// + +#define FT_LIST_NUMBER_ONLY 0x80000000 +#define FT_LIST_BY_INDEX 0x40000000 +#define FT_LIST_ALL 0x20000000 + +#define FT_LIST_MASK (FT_LIST_NUMBER_ONLY|FT_LIST_BY_INDEX|FT_LIST_ALL) + +// +// Baud Rates +// + +#define FT_BAUD_300 300 +#define FT_BAUD_600 600 +#define FT_BAUD_1200 1200 +#define FT_BAUD_2400 2400 +#define FT_BAUD_4800 4800 +#define FT_BAUD_9600 9600 +#define FT_BAUD_14400 14400 +#define FT_BAUD_19200 19200 +#define FT_BAUD_38400 38400 +#define FT_BAUD_57600 57600 +#define FT_BAUD_115200 115200 +#define FT_BAUD_230400 230400 +#define FT_BAUD_460800 460800 +#define FT_BAUD_921600 921600 + +// +// Word Lengths +// + +#define FT_BITS_8 (UCHAR) 8 +#define FT_BITS_7 (UCHAR) 7 + +// +// Stop Bits +// + +#define FT_STOP_BITS_1 (UCHAR) 0 +#define FT_STOP_BITS_2 (UCHAR) 2 + +// +// Parity +// + +#define FT_PARITY_NONE (UCHAR) 0 +#define FT_PARITY_ODD (UCHAR) 1 +#define FT_PARITY_EVEN (UCHAR) 2 +#define FT_PARITY_MARK (UCHAR) 3 +#define FT_PARITY_SPACE (UCHAR) 4 + +// +// Flow Control +// + +#define FT_FLOW_NONE 0x0000 +#define FT_FLOW_RTS_CTS 0x0100 +#define FT_FLOW_DTR_DSR 0x0200 +#define FT_FLOW_XON_XOFF 0x0400 + +// +// Purge rx and tx buffers +// +#define FT_PURGE_RX 1 +#define FT_PURGE_TX 2 + +// +// Events +// + +typedef void (*PFT_EVENT_HANDLER)(DWORD,DWORD); + +#define FT_EVENT_RXCHAR 1 +#define FT_EVENT_MODEM_STATUS 2 +#define FT_EVENT_LINE_STATUS 4 + +// +// Timeouts +// + +#define FT_DEFAULT_RX_TIMEOUT 300 +#define FT_DEFAULT_TX_TIMEOUT 300 + +// +// Device types +// + +typedef ULONG FT_DEVICE; + +enum { + FT_DEVICE_BM, + FT_DEVICE_AM, + FT_DEVICE_100AX, + FT_DEVICE_UNKNOWN, + FT_DEVICE_2232C, + FT_DEVICE_232R, + FT_DEVICE_2232H, + FT_DEVICE_4232H, + FT_DEVICE_232H +}; + +// +// Bit Modes +// + +#define FT_BITMODE_RESET 0x00 +#define FT_BITMODE_ASYNC_BITBANG 0x01 +#define FT_BITMODE_MPSSE 0x02 +#define FT_BITMODE_SYNC_BITBANG 0x04 +#define FT_BITMODE_MCU_HOST 0x08 +#define FT_BITMODE_FAST_SERIAL 0x10 +#define FT_BITMODE_CBUS_BITBANG 0x20 +#define FT_BITMODE_SYNC_FIFO 0x40 + +// +// FT232R CBUS Options EEPROM values +// + +#define FT_232R_CBUS_TXDEN 0x00 // Tx Data Enable +#define FT_232R_CBUS_PWRON 0x01 // Power On +#define FT_232R_CBUS_RXLED 0x02 // Rx LED +#define FT_232R_CBUS_TXLED 0x03 // Tx LED +#define FT_232R_CBUS_TXRXLED 0x04 // Tx and Rx LED +#define FT_232R_CBUS_SLEEP 0x05 // Sleep +#define FT_232R_CBUS_CLK48 0x06 // 48MHz clock +#define FT_232R_CBUS_CLK24 0x07 // 24MHz clock +#define FT_232R_CBUS_CLK12 0x08 // 12MHz clock +#define FT_232R_CBUS_CLK6 0x09 // 6MHz clock +#define FT_232R_CBUS_IOMODE 0x0A // IO Mode for CBUS bit-bang +#define FT_232R_CBUS_BITBANG_WR 0x0B // Bit-bang write strobe +#define FT_232R_CBUS_BITBANG_RD 0x0C // Bit-bang read strobe + +// +// FT232H CBUS Options EEPROM values +// + +#define FT_232H_CBUS_TRISTATE 0x00 // Tristate +#define FT_232H_CBUS_RXLED 0x01 // Rx LED +#define FT_232H_CBUS_TXLED 0x02 // Tx LED +#define FT_232H_CBUS_TXRXLED 0x03 // Tx and Rx LED +#define FT_232H_CBUS_PWREN 0x04 // Power Enable +#define FT_232H_CBUS_SLEEP 0x05 // Sleep +#define FT_232H_CBUS_DRIVE_0 0x06 // Drive pin to logic 0 +#define FT_232H_CBUS_DRIVE_1 0x07 // Drive pin to logic 1 +#define FT_232H_CBUS_IOMODE 0x08 // IO Mode for CBUS bit-bang +#define FT_232H_CBUS_TXDEN 0x09 // Tx Data Enable +#define FT_232H_CBUS_CLK30 0x0A // 30MHz clock +#define FT_232H_CBUS_CLK15 0x0B // 15MHz clock +#define FT_232H_CBUS_CLK7_5 0x0C // 7.5MHz clock + + +#ifdef __cplusplus +extern "C" { +#endif + + + FTD2XX_API + FT_STATUS WINAPI FT_Open( + int deviceNumber, + FT_HANDLE *pHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_OpenEx( + PVOID pArg1, + DWORD Flags, + FT_HANDLE *pHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_ListDevices( + PVOID pArg1, + PVOID pArg2, + DWORD Flags + ); + + FTD2XX_API + FT_STATUS WINAPI FT_Close( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_Read( + FT_HANDLE ftHandle, + LPVOID lpBuffer, + DWORD dwBytesToRead, + LPDWORD lpBytesReturned + ); + + FTD2XX_API + FT_STATUS WINAPI FT_Write( + FT_HANDLE ftHandle, + LPVOID lpBuffer, + DWORD dwBytesToWrite, + LPDWORD lpBytesWritten + ); + + FTD2XX_API + FT_STATUS WINAPI FT_IoCtl( + FT_HANDLE ftHandle, + DWORD dwIoControlCode, + LPVOID lpInBuf, + DWORD nInBufSize, + LPVOID lpOutBuf, + DWORD nOutBufSize, + LPDWORD lpBytesReturned, + LPOVERLAPPED lpOverlapped + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetBaudRate( + FT_HANDLE ftHandle, + ULONG BaudRate + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetDivisor( + FT_HANDLE ftHandle, + USHORT Divisor + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetDataCharacteristics( + FT_HANDLE ftHandle, + UCHAR WordLength, + UCHAR StopBits, + UCHAR Parity + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetFlowControl( + FT_HANDLE ftHandle, + USHORT FlowControl, + UCHAR XonChar, + UCHAR XoffChar + ); + + FTD2XX_API + FT_STATUS WINAPI FT_ResetDevice( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetDtr( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_ClrDtr( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetRts( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_ClrRts( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetModemStatus( + FT_HANDLE ftHandle, + ULONG *pModemStatus + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetChars( + FT_HANDLE ftHandle, + UCHAR EventChar, + UCHAR EventCharEnabled, + UCHAR ErrorChar, + UCHAR ErrorCharEnabled + ); + + FTD2XX_API + FT_STATUS WINAPI FT_Purge( + FT_HANDLE ftHandle, + ULONG Mask + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetTimeouts( + FT_HANDLE ftHandle, + ULONG ReadTimeout, + ULONG WriteTimeout + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetQueueStatus( + FT_HANDLE ftHandle, + DWORD *dwRxBytes + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetEventNotification( + FT_HANDLE ftHandle, + DWORD Mask, + PVOID Param + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetStatus( + FT_HANDLE ftHandle, + DWORD *dwRxBytes, + DWORD *dwTxBytes, + DWORD *dwEventDWord + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetBreakOn( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetBreakOff( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetWaitMask( + FT_HANDLE ftHandle, + DWORD Mask + ); + + FTD2XX_API + FT_STATUS WINAPI FT_WaitOnMask( + FT_HANDLE ftHandle, + DWORD *Mask + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetEventStatus( + FT_HANDLE ftHandle, + DWORD *dwEventDWord + ); + + FTD2XX_API + FT_STATUS WINAPI FT_ReadEE( + FT_HANDLE ftHandle, + DWORD dwWordOffset, + LPWORD lpwValue + ); + + FTD2XX_API + FT_STATUS WINAPI FT_WriteEE( + FT_HANDLE ftHandle, + DWORD dwWordOffset, + WORD wValue + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EraseEE( + FT_HANDLE ftHandle + ); + + // + // structure to hold program data for FT_Program function + // + typedef struct ft_program_data { + + DWORD Signature1; // Header - must be 0x00000000 + DWORD Signature2; // Header - must be 0xffffffff + DWORD Version; // Header - FT_PROGRAM_DATA version + // 0 = original + // 1 = FT2232C extensions + // 2 = FT232R extensions + // 3 = FT2232H extensions + // 4 = FT4232H extensions + // 5 = FT232H extensions + + WORD VendorId; // 0x0403 + WORD ProductId; // 0x6001 + char *Manufacturer; // "FTDI" + char *ManufacturerId; // "FT" + char *Description; // "USB HS Serial Converter" + char *SerialNumber; // "FT000001" if fixed, or NULL + WORD MaxPower; // 0 < MaxPower <= 500 + WORD PnP; // 0 = disabled, 1 = enabled + WORD SelfPowered; // 0 = bus powered, 1 = self powered + WORD RemoteWakeup; // 0 = not capable, 1 = capable + // + // Rev4 (FT232B) extensions + // + UCHAR Rev4; // non-zero if Rev4 chip, zero otherwise + UCHAR IsoIn; // non-zero if in endpoint is isochronous + UCHAR IsoOut; // non-zero if out endpoint is isochronous + UCHAR PullDownEnable; // non-zero if pull down enabled + UCHAR SerNumEnable; // non-zero if serial number to be used + UCHAR USBVersionEnable; // non-zero if chip uses USBVersion + WORD USBVersion; // BCD (0x0200 => USB2) + // + // Rev 5 (FT2232) extensions + // + UCHAR Rev5; // non-zero if Rev5 chip, zero otherwise + UCHAR IsoInA; // non-zero if in endpoint is isochronous + UCHAR IsoInB; // non-zero if in endpoint is isochronous + UCHAR IsoOutA; // non-zero if out endpoint is isochronous + UCHAR IsoOutB; // non-zero if out endpoint is isochronous + UCHAR PullDownEnable5; // non-zero if pull down enabled + UCHAR SerNumEnable5; // non-zero if serial number to be used + UCHAR USBVersionEnable5; // non-zero if chip uses USBVersion + WORD USBVersion5; // BCD (0x0200 => USB2) + UCHAR AIsHighCurrent; // non-zero if interface is high current + UCHAR BIsHighCurrent; // non-zero if interface is high current + UCHAR IFAIsFifo; // non-zero if interface is 245 FIFO + UCHAR IFAIsFifoTar; // non-zero if interface is 245 FIFO CPU target + UCHAR IFAIsFastSer; // non-zero if interface is Fast serial + UCHAR AIsVCP; // non-zero if interface is to use VCP drivers + UCHAR IFBIsFifo; // non-zero if interface is 245 FIFO + UCHAR IFBIsFifoTar; // non-zero if interface is 245 FIFO CPU target + UCHAR IFBIsFastSer; // non-zero if interface is Fast serial + UCHAR BIsVCP; // non-zero if interface is to use VCP drivers + // + // Rev 6 (FT232R) extensions + // + UCHAR UseExtOsc; // Use External Oscillator + UCHAR HighDriveIOs; // High Drive I/Os + UCHAR EndpointSize; // Endpoint size + UCHAR PullDownEnableR; // non-zero if pull down enabled + UCHAR SerNumEnableR; // non-zero if serial number to be used + UCHAR InvertTXD; // non-zero if invert TXD + UCHAR InvertRXD; // non-zero if invert RXD + UCHAR InvertRTS; // non-zero if invert RTS + UCHAR InvertCTS; // non-zero if invert CTS + UCHAR InvertDTR; // non-zero if invert DTR + UCHAR InvertDSR; // non-zero if invert DSR + UCHAR InvertDCD; // non-zero if invert DCD + UCHAR InvertRI; // non-zero if invert RI + UCHAR Cbus0; // Cbus Mux control + UCHAR Cbus1; // Cbus Mux control + UCHAR Cbus2; // Cbus Mux control + UCHAR Cbus3; // Cbus Mux control + UCHAR Cbus4; // Cbus Mux control + UCHAR RIsD2XX; // non-zero if using D2XX driver + // + // Rev 7 (FT2232H) Extensions + // + UCHAR PullDownEnable7; // non-zero if pull down enabled + UCHAR SerNumEnable7; // non-zero if serial number to be used + UCHAR ALSlowSlew; // non-zero if AL pins have slow slew + UCHAR ALSchmittInput; // non-zero if AL pins are Schmitt input + UCHAR ALDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR AHSlowSlew; // non-zero if AH pins have slow slew + UCHAR AHSchmittInput; // non-zero if AH pins are Schmitt input + UCHAR AHDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR BLSlowSlew; // non-zero if BL pins have slow slew + UCHAR BLSchmittInput; // non-zero if BL pins are Schmitt input + UCHAR BLDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR BHSlowSlew; // non-zero if BH pins have slow slew + UCHAR BHSchmittInput; // non-zero if BH pins are Schmitt input + UCHAR BHDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR IFAIsFifo7; // non-zero if interface is 245 FIFO + UCHAR IFAIsFifoTar7; // non-zero if interface is 245 FIFO CPU target + UCHAR IFAIsFastSer7; // non-zero if interface is Fast serial + UCHAR AIsVCP7; // non-zero if interface is to use VCP drivers + UCHAR IFBIsFifo7; // non-zero if interface is 245 FIFO + UCHAR IFBIsFifoTar7; // non-zero if interface is 245 FIFO CPU target + UCHAR IFBIsFastSer7; // non-zero if interface is Fast serial + UCHAR BIsVCP7; // non-zero if interface is to use VCP drivers + UCHAR PowerSaveEnable; // non-zero if using BCBUS7 to save power for self-powered designs + // + // Rev 8 (FT4232H) Extensions + // + UCHAR PullDownEnable8; // non-zero if pull down enabled + UCHAR SerNumEnable8; // non-zero if serial number to be used + UCHAR ASlowSlew; // non-zero if AL pins have slow slew + UCHAR ASchmittInput; // non-zero if AL pins are Schmitt input + UCHAR ADriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR BSlowSlew; // non-zero if AH pins have slow slew + UCHAR BSchmittInput; // non-zero if AH pins are Schmitt input + UCHAR BDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR CSlowSlew; // non-zero if BL pins have slow slew + UCHAR CSchmittInput; // non-zero if BL pins are Schmitt input + UCHAR CDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR DSlowSlew; // non-zero if BH pins have slow slew + UCHAR DSchmittInput; // non-zero if BH pins are Schmitt input + UCHAR DDriveCurrent; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR ARIIsTXDEN; // non-zero if port A uses RI as RS485 TXDEN + UCHAR BRIIsTXDEN; // non-zero if port B uses RI as RS485 TXDEN + UCHAR CRIIsTXDEN; // non-zero if port C uses RI as RS485 TXDEN + UCHAR DRIIsTXDEN; // non-zero if port D uses RI as RS485 TXDEN + UCHAR AIsVCP8; // non-zero if interface is to use VCP drivers + UCHAR BIsVCP8; // non-zero if interface is to use VCP drivers + UCHAR CIsVCP8; // non-zero if interface is to use VCP drivers + UCHAR DIsVCP8; // non-zero if interface is to use VCP drivers + // + // Rev 9 (FT232H) Extensions + // + UCHAR PullDownEnableH; // non-zero if pull down enabled + UCHAR SerNumEnableH; // non-zero if serial number to be used + UCHAR ACSlowSlewH; // non-zero if AC pins have slow slew + UCHAR ACSchmittInputH; // non-zero if AC pins are Schmitt input + UCHAR ACDriveCurrentH; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR ADSlowSlewH; // non-zero if AD pins have slow slew + UCHAR ADSchmittInputH; // non-zero if AD pins are Schmitt input + UCHAR ADDriveCurrentH; // valid values are 4mA, 8mA, 12mA, 16mA + UCHAR Cbus0H; // Cbus Mux control + UCHAR Cbus1H; // Cbus Mux control + UCHAR Cbus2H; // Cbus Mux control + UCHAR Cbus3H; // Cbus Mux control + UCHAR Cbus4H; // Cbus Mux control + UCHAR Cbus5H; // Cbus Mux control + UCHAR Cbus6H; // Cbus Mux control + UCHAR Cbus7H; // Cbus Mux control + UCHAR Cbus8H; // Cbus Mux control + UCHAR Cbus9H; // Cbus Mux control + UCHAR IsFifoH; // non-zero if interface is 245 FIFO + UCHAR IsFifoTarH; // non-zero if interface is 245 FIFO CPU target + UCHAR IsFastSerH; // non-zero if interface is Fast serial + UCHAR IsFT1248H; // non-zero if interface is FT1248 + UCHAR FT1248CpolH; // FT1248 clock polarity - clock idle high (1) or clock idle low (0) + UCHAR FT1248LsbH; // FT1248 data is LSB (1) or MSB (0) + UCHAR FT1248FlowControlH; // FT1248 flow control enable + UCHAR IsVCPH; // non-zero if interface is to use VCP drivers + UCHAR PowerSaveEnableH; // non-zero if using ACBUS7 to save power for self-powered designs + + } FT_PROGRAM_DATA, *PFT_PROGRAM_DATA; + + FTD2XX_API + FT_STATUS WINAPI FT_EE_Program( + FT_HANDLE ftHandle, + PFT_PROGRAM_DATA pData + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EE_ProgramEx( + FT_HANDLE ftHandle, + PFT_PROGRAM_DATA pData, + char *Manufacturer, + char *ManufacturerId, + char *Description, + char *SerialNumber + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EE_Read( + FT_HANDLE ftHandle, + PFT_PROGRAM_DATA pData + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EE_ReadEx( + FT_HANDLE ftHandle, + PFT_PROGRAM_DATA pData, + char *Manufacturer, + char *ManufacturerId, + char *Description, + char *SerialNumber + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EE_UASize( + FT_HANDLE ftHandle, + LPDWORD lpdwSize + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EE_UAWrite( + FT_HANDLE ftHandle, + PUCHAR pucData, + DWORD dwDataLen + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EE_UARead( + FT_HANDLE ftHandle, + PUCHAR pucData, + DWORD dwDataLen, + LPDWORD lpdwBytesRead + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetLatencyTimer( + FT_HANDLE ftHandle, + UCHAR ucLatency + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetLatencyTimer( + FT_HANDLE ftHandle, + PUCHAR pucLatency + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetBitMode( + FT_HANDLE ftHandle, + UCHAR ucMask, + UCHAR ucEnable + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetBitMode( + FT_HANDLE ftHandle, + PUCHAR pucMode + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetUSBParameters( + FT_HANDLE ftHandle, + ULONG ulInTransferSize, + ULONG ulOutTransferSize + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetDeadmanTimeout( + FT_HANDLE ftHandle, + ULONG ulDeadmanTimeout + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetDeviceInfo( + FT_HANDLE ftHandle, + FT_DEVICE *lpftDevice, + LPDWORD lpdwID, + PCHAR SerialNumber, + PCHAR Description, + LPVOID Dummy + ); + + FTD2XX_API + FT_STATUS WINAPI FT_StopInTask( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_RestartInTask( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_SetResetPipeRetryCount( + FT_HANDLE ftHandle, + DWORD dwCount + ); + + FTD2XX_API + FT_STATUS WINAPI FT_ResetPort( + FT_HANDLE ftHandle + ); + + FTD2XX_API + FT_STATUS WINAPI FT_CyclePort( + FT_HANDLE ftHandle + ); + + + // + // Win32-type functions + // + + FTD2XX_API + FT_HANDLE WINAPI FT_W32_CreateFile( + LPCTSTR lpszName, + DWORD dwAccess, + DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreate, + DWORD dwAttrsAndFlags, + HANDLE hTemplate + ); + + FTD2XX_API + BOOL WINAPI FT_W32_CloseHandle( + FT_HANDLE ftHandle + ); + + FTD2XX_API + BOOL WINAPI FT_W32_ReadFile( + FT_HANDLE ftHandle, + LPVOID lpBuffer, + DWORD nBufferSize, + LPDWORD lpBytesReturned, + LPOVERLAPPED lpOverlapped + ); + + FTD2XX_API + BOOL WINAPI FT_W32_WriteFile( + FT_HANDLE ftHandle, + LPVOID lpBuffer, + DWORD nBufferSize, + LPDWORD lpBytesWritten, + LPOVERLAPPED lpOverlapped + ); + + FTD2XX_API + DWORD WINAPI FT_W32_GetLastError( + FT_HANDLE ftHandle + ); + + FTD2XX_API + BOOL WINAPI FT_W32_GetOverlappedResult( + FT_HANDLE ftHandle, + LPOVERLAPPED lpOverlapped, + LPDWORD lpdwBytesTransferred, + BOOL bWait + ); + + FTD2XX_API + BOOL WINAPI FT_W32_CancelIo( + FT_HANDLE ftHandle + ); + + + // + // Win32 COMM API type functions + // + typedef struct _FTCOMSTAT { + DWORD fCtsHold : 1; + DWORD fDsrHold : 1; + DWORD fRlsdHold : 1; + DWORD fXoffHold : 1; + DWORD fXoffSent : 1; + DWORD fEof : 1; + DWORD fTxim : 1; + DWORD fReserved : 25; + DWORD cbInQue; + DWORD cbOutQue; + } FTCOMSTAT, *LPFTCOMSTAT; + + typedef struct _FTDCB { + DWORD DCBlength; /* sizeof(FTDCB) */ + DWORD BaudRate; /* Baudrate at which running */ + DWORD fBinary: 1; /* Binary Mode (skip EOF check) */ + DWORD fParity: 1; /* Enable parity checking */ + DWORD fOutxCtsFlow:1; /* CTS handshaking on output */ + DWORD fOutxDsrFlow:1; /* DSR handshaking on output */ + DWORD fDtrControl:2; /* DTR Flow control */ + DWORD fDsrSensitivity:1; /* DSR Sensitivity */ + DWORD fTXContinueOnXoff: 1; /* Continue TX when Xoff sent */ + DWORD fOutX: 1; /* Enable output X-ON/X-OFF */ + DWORD fInX: 1; /* Enable input X-ON/X-OFF */ + DWORD fErrorChar: 1; /* Enable Err Replacement */ + DWORD fNull: 1; /* Enable Null stripping */ + DWORD fRtsControl:2; /* Rts Flow control */ + DWORD fAbortOnError:1; /* Abort all reads and writes on Error */ + DWORD fDummy2:17; /* Reserved */ + WORD wReserved; /* Not currently used */ + WORD XonLim; /* Transmit X-ON threshold */ + WORD XoffLim; /* Transmit X-OFF threshold */ + BYTE ByteSize; /* Number of bits/byte, 4-8 */ + BYTE Parity; /* 0-4=None,Odd,Even,Mark,Space */ + BYTE StopBits; /* 0,1,2 = 1, 1.5, 2 */ + char XonChar; /* Tx and Rx X-ON character */ + char XoffChar; /* Tx and Rx X-OFF character */ + char ErrorChar; /* Error replacement char */ + char EofChar; /* End of Input character */ + char EvtChar; /* Received Event character */ + WORD wReserved1; /* Fill for now. */ + } FTDCB, *LPFTDCB; + + typedef struct _FTTIMEOUTS { + DWORD ReadIntervalTimeout; /* Maximum time between read chars. */ + DWORD ReadTotalTimeoutMultiplier; /* Multiplier of characters. */ + DWORD ReadTotalTimeoutConstant; /* Constant in milliseconds. */ + DWORD WriteTotalTimeoutMultiplier; /* Multiplier of characters. */ + DWORD WriteTotalTimeoutConstant; /* Constant in milliseconds. */ + } FTTIMEOUTS,*LPFTTIMEOUTS; + + + FTD2XX_API + BOOL WINAPI FT_W32_ClearCommBreak( + FT_HANDLE ftHandle + ); + + FTD2XX_API + BOOL WINAPI FT_W32_ClearCommError( + FT_HANDLE ftHandle, + LPDWORD lpdwErrors, + LPFTCOMSTAT lpftComstat + ); + + FTD2XX_API + BOOL WINAPI FT_W32_EscapeCommFunction( + FT_HANDLE ftHandle, + DWORD dwFunc + ); + + FTD2XX_API + BOOL WINAPI FT_W32_GetCommModemStatus( + FT_HANDLE ftHandle, + LPDWORD lpdwModemStatus + ); + + FTD2XX_API + BOOL WINAPI FT_W32_GetCommState( + FT_HANDLE ftHandle, + LPFTDCB lpftDcb + ); + + FTD2XX_API + BOOL WINAPI FT_W32_GetCommTimeouts( + FT_HANDLE ftHandle, + FTTIMEOUTS *pTimeouts + ); + + FTD2XX_API + BOOL WINAPI FT_W32_PurgeComm( + FT_HANDLE ftHandle, + DWORD dwMask + ); + + FTD2XX_API + BOOL WINAPI FT_W32_SetCommBreak( + FT_HANDLE ftHandle + ); + + FTD2XX_API + BOOL WINAPI FT_W32_SetCommMask( + FT_HANDLE ftHandle, + ULONG ulEventMask + ); + + FTD2XX_API + BOOL WINAPI FT_W32_GetCommMask( + FT_HANDLE ftHandle, + LPDWORD lpdwEventMask + ); + + FTD2XX_API + BOOL WINAPI FT_W32_SetCommState( + FT_HANDLE ftHandle, + LPFTDCB lpftDcb + ); + + FTD2XX_API + BOOL WINAPI FT_W32_SetCommTimeouts( + FT_HANDLE ftHandle, + FTTIMEOUTS *pTimeouts + ); + + FTD2XX_API + BOOL WINAPI FT_W32_SetupComm( + FT_HANDLE ftHandle, + DWORD dwReadBufferSize, + DWORD dwWriteBufferSize + ); + + FTD2XX_API + BOOL WINAPI FT_W32_WaitCommEvent( + FT_HANDLE ftHandle, + PULONG pulEvent, + LPOVERLAPPED lpOverlapped + ); + + + // + // Device information + // + + typedef struct _ft_device_list_info_node { + ULONG Flags; + ULONG Type; + ULONG ID; + DWORD LocId; + char SerialNumber[16]; + char Description[64]; + FT_HANDLE ftHandle; + } FT_DEVICE_LIST_INFO_NODE; + + // Device information flags + enum { + FT_FLAGS_OPENED = 1, + FT_FLAGS_HISPEED = 2 + }; + + + FTD2XX_API + FT_STATUS WINAPI FT_CreateDeviceInfoList( + LPDWORD lpdwNumDevs + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetDeviceInfoList( + FT_DEVICE_LIST_INFO_NODE *pDest, + LPDWORD lpdwNumDevs + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetDeviceInfoDetail( + DWORD dwIndex, + LPDWORD lpdwFlags, + LPDWORD lpdwType, + LPDWORD lpdwID, + LPDWORD lpdwLocId, + LPVOID lpSerialNumber, + LPVOID lpDescription, + FT_HANDLE *pftHandle + ); + + + // + // Version information + // + + FTD2XX_API + FT_STATUS WINAPI FT_GetDriverVersion( + FT_HANDLE ftHandle, + LPDWORD lpdwVersion + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetLibraryVersion( + LPDWORD lpdwVersion + ); + + + FTD2XX_API + FT_STATUS WINAPI FT_Rescan( + void + ); + + FTD2XX_API + FT_STATUS WINAPI FT_Reload( + WORD wVid, + WORD wPid + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetComPortNumber( + FT_HANDLE ftHandle, + LPLONG lpdwComPortNumber + ); + + + // + // FT232H additional EEPROM functions + // + + FTD2XX_API + FT_STATUS WINAPI FT_EE_ReadConfig( + FT_HANDLE ftHandle, + UCHAR ucAddress, + PUCHAR pucValue + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EE_WriteConfig( + FT_HANDLE ftHandle, + UCHAR ucAddress, + UCHAR ucValue + ); + + FTD2XX_API + FT_STATUS WINAPI FT_EE_ReadECC( + FT_HANDLE ftHandle, + UCHAR ucOption, + LPWORD lpwValue + ); + + FTD2XX_API + FT_STATUS WINAPI FT_GetQueueStatusEx( + FT_HANDLE ftHandle, + DWORD *dwRxBytes + ); + + +#ifdef __cplusplus +} +#endif + + +#endif /* FTD2XX_H */ + diff --git a/build/windows/dist/drivers/FTDI USB Drivers/ftdibus.cat b/build/windows/dist/drivers/FTDI USB Drivers/ftdibus.cat old mode 100755 new mode 100644 index 05035ff55..0a7c72c8e Binary files a/build/windows/dist/drivers/FTDI USB Drivers/ftdibus.cat and b/build/windows/dist/drivers/FTDI USB Drivers/ftdibus.cat differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/ftdibus.inf b/build/windows/dist/drivers/FTDI USB Drivers/ftdibus.inf new file mode 100644 index 000000000..8c3d16c2d --- /dev/null +++ b/build/windows/dist/drivers/FTDI USB Drivers/ftdibus.inf @@ -0,0 +1,153 @@ +; FTDIBUS.INF +; +; Copyright © 2000-2011 Future Technology Devices International Limited +; +; USB serial converter driver installation file for Windows 2000, XP, Server 2003, Vista, Server 2008, +; Windows 7 and Server 2008 R2 (x86 and x64). +; +; +; THIS SOFTWARE IS PROVIDED BY FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED ``AS IS'' AND ANY EXPRESS +; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED +; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +; THE POSSIBILITY OF SUCH DAMAGE. + +; FTDI DRIVERS MAY BE USED ONLY IN CONJUNCTION WITH PRODUCTS BASED ON FTDI PARTS. + +; FTDI DRIVERS MAY BE DISTRIBUTED IN ANY FORM AS LONG AS LICENSE INFORMATION IS NOT MODIFIED. + +; IF A CUSTOM VENDOR ID AND/OR PRODUCT ID OR DESCRIPTION STRING ARE USED, IT IS THE RESPONSIBILITY OF +; THE PRODUCT MANUFACTURER TO MAINTAIN ANY CHANGES AND SUBSEQUENT WHQL RE-CERTIFICATION AS A RESULT OF +; MAKING THESE CHANGES. +; + + +[Version] +Signature="$Windows NT$" +DriverPackageType=PlugAndPlay +DriverPackageDisplayName=%DESC% +Class=USB +ClassGUID={36fc9e60-c465-11cf-8056-444553540000} +Provider=%FTDI% +CatalogFile=ftdibus.cat +DriverVer=03/18/2011,2.08.14 + +[SourceDisksNames] +1=%DriversDisk%,,, + +[SourceDisksFiles] +ftdibus.sys = 1,i386 +ftbusui.dll = 1,i386 +ftd2xx.dll = 1,i386 +FTLang.Dll = 1,i386 + +[SourceDisksFiles.amd64] +ftdibus.sys = 1,amd64 +ftbusui.dll = 1,amd64 +ftd2xx64.dll = 1,amd64 +ftd2xx.dll = 1,i386 +FTLang.Dll = 1,amd64 + +[DestinationDirs] +FtdiBus.NT.Copy = 10,system32\drivers +FtdiBus.NT.Copy2 = 10,system32 +FtdiBus.NTamd64.Copy = 10,system32\drivers +FtdiBus.NTamd64.Copy2 = 10,system32 +FtdiBus.NTamd64.Copy3 = 10,syswow64 + + +[Manufacturer] +%Ftdi%=FtdiHw,NTamd64 + +[FtdiHw] +%USB\VID_0403&PID_6001.DeviceDesc%=FtdiBus.NT,USB\VID_0403&PID_6001 +%USB\VID_0403&PID_6010&MI_00.DeviceDesc%=FtdiBus.NT,USB\VID_0403&PID_6010&MI_00 +%USB\VID_0403&PID_6010&MI_01.DeviceDesc%=FtdiBus.NT,USB\VID_0403&PID_6010&MI_01 +%USB\VID_0403&PID_6011&MI_00.DeviceDesc%=FtdiBus.NT,USB\VID_0403&PID_6011&MI_00 +%USB\VID_0403&PID_6011&MI_01.DeviceDesc%=FtdiBus.NT,USB\VID_0403&PID_6011&MI_01 +%USB\VID_0403&PID_6011&MI_02.DeviceDesc%=FtdiBus.NT,USB\VID_0403&PID_6011&MI_02 +%USB\VID_0403&PID_6011&MI_03.DeviceDesc%=FtdiBus.NT,USB\VID_0403&PID_6011&MI_03 +%USB\VID_0403&PID_6014.DeviceDesc%=FtdiBus.NT,USB\VID_0403&PID_6014 + +[FtdiHw.NTamd64] +%USB\VID_0403&PID_6001.DeviceDesc%=FtdiBus.NTamd64,USB\VID_0403&PID_6001 +%USB\VID_0403&PID_6010&MI_00.DeviceDesc%=FtdiBus.NTamd64,USB\VID_0403&PID_6010&MI_00 +%USB\VID_0403&PID_6010&MI_01.DeviceDesc%=FtdiBus.NTamd64,USB\VID_0403&PID_6010&MI_01 +%USB\VID_0403&PID_6011&MI_00.DeviceDesc%=FtdiBus.NTamd64,USB\VID_0403&PID_6011&MI_00 +%USB\VID_0403&PID_6011&MI_01.DeviceDesc%=FtdiBus.NTamd64,USB\VID_0403&PID_6011&MI_01 +%USB\VID_0403&PID_6011&MI_02.DeviceDesc%=FtdiBus.NTamd64,USB\VID_0403&PID_6011&MI_02 +%USB\VID_0403&PID_6011&MI_03.DeviceDesc%=FtdiBus.NTamd64,USB\VID_0403&PID_6011&MI_03 +%USB\VID_0403&PID_6014.DeviceDesc%=FtdiBus.NTamd64,USB\VID_0403&PID_6014 + +[ControlFlags] +ExcludeFromSelect=* + +[FtdiBus.NT] +CopyFiles=FtdiBus.NT.Copy,FtdiBus.NT.Copy2 +AddReg=FtdiBus.NT.AddReg + +[FtdiBus.NTamd64] +CopyFiles=FtdiBus.NTamd64.Copy,FtdiBus.NTamd64.Copy2,FtdiBus.NTamd64.Copy3 +AddReg=FtdiBus.NT.AddReg + +[FtdiBus.NT.Services] +AddService = FTDIBUS, 0x00000002, FtdiBus.NT.AddService + +[FtdiBus.NTamd64.Services] +AddService = FTDIBUS, 0x00000002, FtdiBus.NT.AddService + +[FtdiBus.NT.AddService] +DisplayName = %SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %10%\system32\drivers\ftdibus.sys +LoadOrderGroup = Base +AddReg = FtdiBus.NT.AddService.AddReg + +[FtdiBus.NT.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,ftdibus.sys +HKR,,EnumPropPages32,,"ftbusui.dll,FTBUSUIPropPageProvider" + +[FtdiBus.NT.AddService.AddReg] +;HKR,Parameters,"LocIds",1,31,00,00,00,32,00,00,00,00 +;HKR,Parameters,"RetryResetCount",0x10001,50 + + +[FtdiBus.NT.Copy] +ftdibus.sys + +[FtdiBus.NT.Copy2] +ftbusui.dll +ftd2xx.dll +FTLang.dll + +[FtdiBus.NTamd64.Copy] +ftdibus.sys + +[FtdiBus.NTamd64.Copy2] +ftbusui.dll +ftd2xx.dll,ftd2xx64.dll +FTLang.dll + +[FtdiBus.NTamd64.Copy3] +ftd2xx.dll + +[Strings] +Ftdi="FTDI" +DESC="CDM Driver Package - Bus/D2XX Driver" +DriversDisk="FTDI USB Drivers Disk" +USB\VID_0403&PID_6001.DeviceDesc="USB Serial Converter" +USB\VID_0403&PID_6010&MI_00.DeviceDesc="USB Serial Converter A" +USB\VID_0403&PID_6010&MI_01.DeviceDesc="USB Serial Converter B" +USB\VID_0403&PID_6011&MI_00.DeviceDesc="USB Serial Converter A" +USB\VID_0403&PID_6011&MI_01.DeviceDesc="USB Serial Converter B" +USB\VID_0403&PID_6011&MI_02.DeviceDesc="USB Serial Converter C" +USB\VID_0403&PID_6011&MI_03.DeviceDesc="USB Serial Converter D" +USB\VID_0403&PID_6014.DeviceDesc="USB Serial Converter" +SvcDesc="USB Serial Converter Driver" +ClassName="USB" diff --git a/build/windows/dist/drivers/FTDI USB Drivers/ftdiport.cat b/build/windows/dist/drivers/FTDI USB Drivers/ftdiport.cat old mode 100755 new mode 100644 index c84595b07..53e5d4781 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/ftdiport.cat and b/build/windows/dist/drivers/FTDI USB Drivers/ftdiport.cat differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/ftdiport.inf b/build/windows/dist/drivers/FTDI USB Drivers/ftdiport.inf new file mode 100644 index 000000000..4283d722b --- /dev/null +++ b/build/windows/dist/drivers/FTDI USB Drivers/ftdiport.inf @@ -0,0 +1,164 @@ +; FTDIPORT.INF +; +; Copyright © 2000-2011 Future Technology Devices International Limited +; +; USB serial port driver installation file for Windows 2000, XP, Server 2003, Vista, Server 2008, +; Windows 7 and Server 2008 R2 (x86 and x64). +; +; +; THIS SOFTWARE IS PROVIDED BY FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED ``AS IS'' AND ANY EXPRESS +; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED +; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +; THE POSSIBILITY OF SUCH DAMAGE. + +; FTDI DRIVERS MAY BE USED ONLY IN CONJUNCTION WITH PRODUCTS BASED ON FTDI PARTS. + +; FTDI DRIVERS MAY BE DISTRIBUTED IN ANY FORM AS LONG AS LICENSE INFORMATION IS NOT MODIFIED. + +; IF A CUSTOM VENDOR ID AND/OR PRODUCT ID OR DESCRIPTION STRING ARE USED, IT IS THE RESPONSIBILITY OF +; THE PRODUCT MANUFACTURER TO MAINTAIN ANY CHANGES AND SUBSEQUENT WHQL RE-CERTIFICATION AS A RESULT OF +; MAKING THESE CHANGES. +; + + +[Version] +Signature="$Windows NT$" +DriverPackageType=PlugAndPlay +DriverPackageDisplayName=%DESC% +Class=Ports +ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318} +Provider=%FTDI% +CatalogFile=ftdiport.cat +DriverVer=03/18/2011,2.08.14 + +[SourceDisksNames] +1=%DriversDisk%,,, + +[SourceDisksFiles] +ftser2k.sys=1,i386 +ftserui2.dll=1,i386 +ftcserco.dll = 1,i386 + +[SourceDisksFiles.amd64] +ftser2k.sys=1,amd64 +ftserui2.dll=1,amd64 +ftcserco.dll = 1,amd64 + +[DestinationDirs] +FtdiPort.NT.Copy=10,system32\drivers +FtdiPort.NT.CopyUI=10,system32 +FtdiPort.NT.CopyCoInst=10,system32 + +[ControlFlags] +ExcludeFromSelect=* + +[Manufacturer] +%FTDI%=FtdiHw,NTamd64 + +[FtdiHw] +%VID_0403&PID_6001.DeviceDesc%=FtdiPort.NT,FTDIBUS\COMPORT&VID_0403&PID_6001 +%VID_0403&PID_6010.DeviceDesc%=FtdiPort.NT,FTDIBUS\COMPORT&VID_0403&PID_6010 +%VID_0403&PID_6011.DeviceDesc%=FtdiPort.NT,FTDIBUS\COMPORT&VID_0403&PID_6011 +%VID_0403&PID_6014.DeviceDesc%=FtdiPort.NT,FTDIBUS\COMPORT&VID_0403&PID_6014 + +[FtdiHw.NTamd64] +%VID_0403&PID_6001.DeviceDesc%=FtdiPort.NTamd64,FTDIBUS\COMPORT&VID_0403&PID_6001 +%VID_0403&PID_6010.DeviceDesc%=FtdiPort.NTamd64,FTDIBUS\COMPORT&VID_0403&PID_6010 +%VID_0403&PID_6011.DeviceDesc%=FtdiPort.NTamd64,FTDIBUS\COMPORT&VID_0403&PID_6011 +%VID_0403&PID_6014.DeviceDesc%=FtdiPort.NTamd64,FTDIBUS\COMPORT&VID_0403&PID_6014 + +[FtdiPort.NT.AddService] +DisplayName = %SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %10%\system32\drivers\ftser2k.sys +LoadOrderGroup = Base + + +; -------------- Serenum Driver install section +[SerEnum_AddService] +DisplayName = %SerEnum.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\serenum.sys +LoadOrderGroup = PNP Filter + +[FtdiPort.NT.AddReg] +HKR,,EnumPropPages32,,"ftserui2.dll,SerialPortPropPageProvider" + +[FtdiPort.NT.Copy] +ftser2k.sys + +[FtdiPort.NT.CopyUI] +ftserui2.dll + +[FtdiPort.NT.CopyCoInst] +ftcserco.dll + +[FtdiPort.NT] +CopyFiles=FtdiPort.NT.Copy,FtdiPort.NT.CopyUI +AddReg=FtdiPort.NT.AddReg + +[FtdiPort.NTamd64] +CopyFiles=FtdiPort.NT.Copy,FtdiPort.NT.CopyUI +AddReg=FtdiPort.NT.AddReg + +[FtdiPort.NT.HW] +AddReg=FtdiPort.NT.HW.AddReg + +[FtdiPort.NTamd64.HW] +AddReg=FtdiPort.NT.HW.AddReg + + +[FtdiPort.NT.Services] +AddService = FTSER2K, 0x00000002, FtdiPort.NT.AddService +AddService = Serenum,,SerEnum_AddService +DelService = FTSERIAL + +[FtdiPort.NTamd64.Services] +AddService = FTSER2K, 0x00000002, FtdiPort.NT.AddService +AddService = Serenum,,SerEnum_AddService +DelService = FTSERIAL + + +[FtdiPort.NT.HW.AddReg] +HKR,,"UpperFilters",0x00010000,"serenum" +HKR,,"ConfigData",1,11,00,3F,3F,10,27,00,00,88,13,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,4E,C0,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00 +HKR,,"MinReadTimeout",0x00010001,0 +HKR,,"MinWriteTimeout",0x00010001,0 +HKR,,"LatencyTimer",0x00010001,16 + + +[FtdiPort.NT.CoInstallers] +AddReg=FtdiPort.NT.CoInstallers.AddReg +CopyFiles=FtdiPort.NT.CopyCoInst + +[FtdiPort.NTamd64.CoInstallers] +AddReg=FtdiPort.NT.CoInstallers.AddReg +CopyFiles=FtdiPort.NT.CopyCoInst + +[FtdiPort.NT.CoInstallers.AddReg] +HKR,,CoInstallers32,0x00010000,"ftcserco.Dll,FTCSERCoInstaller" + + +;---------------------------------------------------------------; + +[Strings] +FTDI="FTDI" +DESC="CDM Driver Package - VCP Driver" +DriversDisk="FTDI USB Drivers Disk" +PortsClassName = "Ports (COM & LPT)" +VID_0403&PID_6001.DeviceDesc="USB Serial Port" +VID_0403&PID_6010.DeviceDesc="USB Serial Port" +VID_0403&PID_6011.DeviceDesc="USB Serial Port" +VID_0403&PID_6014.DeviceDesc="USB Serial Port" +SvcDesc="USB Serial Port Driver" +SerEnum.SvcDesc="Serenum Filter Driver" + + diff --git a/build/windows/dist/drivers/FTDI USB Drivers/ftser2k.sys b/build/windows/dist/drivers/FTDI USB Drivers/ftser2k.sys deleted file mode 100755 index a7b47e4f2..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/ftser2k.sys and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/ftserui2.dll b/build/windows/dist/drivers/FTDI USB Drivers/ftserui2.dll deleted file mode 100755 index eb97f1336..000000000 Binary files a/build/windows/dist/drivers/FTDI USB Drivers/ftserui2.dll and /dev/null differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/i386/ftbusui.dll b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftbusui.dll new file mode 100644 index 000000000..14e5812eb Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftbusui.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/i386/ftcserco.dll b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftcserco.dll new file mode 100644 index 000000000..ebb705268 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftcserco.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/i386/ftd2xx.dll b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftd2xx.dll new file mode 100644 index 000000000..3b8c0abdb Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftd2xx.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/i386/ftd2xx.lib b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftd2xx.lib new file mode 100644 index 000000000..bccb53be9 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftd2xx.lib differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/i386/ftdibus.sys b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftdibus.sys new file mode 100644 index 000000000..40af396a0 Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftdibus.sys differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/i386/ftlang.dll b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftlang.dll new file mode 100644 index 000000000..6b663a7eb Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftlang.dll differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/i386/ftser2k.sys b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftser2k.sys new file mode 100644 index 000000000..85b02d35f Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftser2k.sys differ diff --git a/build/windows/dist/drivers/FTDI USB Drivers/i386/ftserui2.dll b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftserui2.dll new file mode 100644 index 000000000..35bc3932a Binary files /dev/null and b/build/windows/dist/drivers/FTDI USB Drivers/i386/ftserui2.dll differ 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 0ae40d3b6..7adac6233 100644 --- a/hardware/arduino/boards.txt +++ b/hardware/arduino/boards.txt @@ -14,10 +14,11 @@ uno.bootloader.lock_bits=0x0F uno.build.mcu=atmega328p uno.build.f_cpu=16000000L uno.build.core=arduino +uno.build.variant=standard ############################################################## -atmega328.name=Arduino Duemilanove or Nano w/ ATmega328 +atmega328.name=Arduino Duemilanove w/ ATmega328 atmega328.upload.protocol=stk500 atmega328.upload.maximum_size=30720 @@ -34,10 +35,11 @@ atmega328.bootloader.lock_bits=0x0F atmega328.build.mcu=atmega328p atmega328.build.f_cpu=16000000L atmega328.build.core=arduino +atmega328.build.variant=standard ############################################################## -diecimila.name=Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +diecimila.name=Arduino Diecimila or Duemilanove w/ ATmega168 diecimila.upload.protocol=stk500 diecimila.upload.maximum_size=14336 @@ -54,6 +56,49 @@ diecimila.bootloader.lock_bits=0x0F diecimila.build.mcu=atmega168 diecimila.build.f_cpu=16000000L diecimila.build.core=arduino +diecimila.build.variant=standard + +############################################################## + +nano328.name=Arduino Nano w/ ATmega328 + +nano328.upload.protocol=stk500 +nano328.upload.maximum_size=30720 +nano328.upload.speed=57600 + +nano328.bootloader.low_fuses=0xFF +nano328.bootloader.high_fuses=0xDA +nano328.bootloader.extended_fuses=0x05 +nano328.bootloader.path=atmega +nano328.bootloader.file=ATmegaBOOT_168_atmega328.hex +nano328.bootloader.unlock_bits=0x3F +nano328.bootloader.lock_bits=0x0F + +nano328.build.mcu=atmega328p +nano328.build.f_cpu=16000000L +nano328.build.core=arduino +nano328.build.variant=eightanaloginputs + +############################################################## + +nano.name=Arduino Nano w/ ATmega168 + +nano.upload.protocol=stk500 +nano.upload.maximum_size=14336 +nano.upload.speed=19200 + +nano.bootloader.low_fuses=0xff +nano.bootloader.high_fuses=0xdd +nano.bootloader.extended_fuses=0x00 +nano.bootloader.path=atmega +nano.bootloader.file=ATmegaBOOT_168_diecimila.hex +nano.bootloader.unlock_bits=0x3F +nano.bootloader.lock_bits=0x0F + +nano.build.mcu=atmega168 +nano.build.f_cpu=16000000L +nano.build.core=arduino +nano.build.variant=eightanaloginputs ############################################################## @@ -74,6 +119,7 @@ mega2560.bootloader.lock_bits=0x0F mega2560.build.mcu=atmega2560 mega2560.build.f_cpu=16000000L mega2560.build.core=arduino +mega2560.build.variant=mega ############################################################## @@ -94,6 +140,7 @@ mega.bootloader.lock_bits=0x0F mega.build.mcu=atmega1280 mega.build.f_cpu=16000000L mega.build.core=arduino +mega.build.variant=mega ############################################################## @@ -114,6 +161,7 @@ mini.bootloader.lock_bits=0x0F mini.build.mcu=atmega168 mini.build.f_cpu=16000000L mini.build.core=arduino +mini.build.variant=eightanaloginputs ############################################################## @@ -133,7 +181,8 @@ fio.bootloader.lock_bits=0x0F fio.build.mcu=atmega328p fio.build.f_cpu=8000000L -fio.build.core=arduino:arduino +fio.build.core=arduino +fio.build.variant=eightanaloginputs ############################################################## @@ -155,6 +204,7 @@ bt328.bootloader.lock_bits=0x0F bt328.build.mcu=atmega328p bt328.build.f_cpu=16000000L bt328.build.core=arduino +bt328.build.variant=eightanaloginputs ############################################################## @@ -176,6 +226,7 @@ bt.bootloader.lock_bits=0x0F bt.build.mcu=atmega168 bt.build.f_cpu=16000000L bt.build.core=arduino +bt.build.variant=eightanaloginputs ############################################################## @@ -196,6 +247,7 @@ lilypad328.bootloader.lock_bits=0x0F lilypad328.build.mcu=atmega328p lilypad328.build.f_cpu=8000000L lilypad328.build.core=arduino +lilypad328.build.variant=standard ############################################################## @@ -216,6 +268,7 @@ lilypad.bootloader.lock_bits=0x0F lilypad.build.mcu=atmega168 lilypad.build.f_cpu=8000000L lilypad.build.core=arduino +lilypad.build.variant=standard ############################################################## @@ -236,6 +289,7 @@ pro5v328.bootloader.lock_bits=0x0F pro5v328.build.mcu=atmega328p pro5v328.build.f_cpu=16000000L pro5v328.build.core=arduino +pro5v328.build.variant=standard ############################################################## @@ -256,6 +310,7 @@ pro5v.bootloader.lock_bits=0x0F pro5v.build.mcu=atmega168 pro5v.build.f_cpu=16000000L pro5v.build.core=arduino +pro5v.build.variant=standard ############################################################## @@ -276,6 +331,7 @@ pro328.bootloader.lock_bits=0x0F pro328.build.mcu=atmega328p pro328.build.f_cpu=8000000L pro328.build.core=arduino +pro328.build.variant=standard ############################################################## @@ -296,6 +352,7 @@ pro.bootloader.lock_bits=0x0F pro.build.mcu=atmega168 pro.build.f_cpu=8000000L pro.build.core=arduino +pro.build.variant=standard ############################################################## @@ -316,6 +373,7 @@ atmega168.bootloader.lock_bits=0x0F atmega168.build.mcu=atmega168 atmega168.build.f_cpu=16000000L atmega168.build.core=arduino +atmega168.build.variant=standard ############################################################## @@ -335,4 +393,4 @@ atmega8.bootloader.lock_bits=0x0F atmega8.build.mcu=atmega8 atmega8.build.f_cpu=16000000L atmega8.build.core=arduino - +atmega8.build.variant=standard diff --git a/hardware/arduino/bootloaders/optiboot/optiboot.c b/hardware/arduino/bootloaders/optiboot/optiboot.c index af92995ac..c7d817a61 100644 --- a/hardware/arduino/bootloaders/optiboot/optiboot.c +++ b/hardware/arduino/bootloaders/optiboot/optiboot.c @@ -213,7 +213,7 @@ int main(void) { // If not, uncomment the following instructions: // cli(); // SP=RAMEND; // This is done by hardware reset - // asm volatile ("clr __zero_reg__"); + asm volatile ("clr __zero_reg__"); uint8_t ch; diff --git a/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex b/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex index b1c85674a..e8aa31c4b 100644 --- a/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex +++ b/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex @@ -1,33 +1,33 @@ -:107E000085E08093810082E08093C00088E18093C8 -:107E1000C10086E08093C20080E18093C40084B7F3 -:107E200014BE81FFD0D08DE0C8D0259A86E020E333 -:107E30003CEF91E0309385002093840096BBB09B8B -:107E4000FECF1D9AA8958150A9F7DD24D394A5E013 -:107E5000EA2EF1E1FF2EA4D0813421F481E0BED0DE -:107E600083E024C0823411F484E103C0853419F422 -:107E700085E0B4D08AC08535A1F492D0082F10E0F7 -:107E800010930102009300028BD090E0982F882776 -:107E9000802B912B880F991F9093010280930002F1 -:107EA00073C0863529F484E099D080E071D06DC02C -:107EB000843609F043C07CD0E0910002F0910102C9 -:107EC00083E080935700E895C0E0D1E069D08993C2 -:107ED000809102028150809302028823B9F778D002 -:107EE00007B600FCFDCF4091000250910102A0E0D6 -:107EF000B1E02C9130E011968C91119790E0982F81 -:107F00008827822B932B1296FA010C01D0925700EE -:107F1000E89511244E5F5F4FF1E0A038BF0749F7A5 -:107F2000E0910002F0910102E0925700E89507B657 -:107F300000FCFDCFF0925700E89527C08437B9F4D4 -:107F400037D046D0E0910002F09101023196F093D3 -:107F50000102E09300023197E4918E2F19D08091B5 -:107F60000202815080930202882361F70EC0853798 -:107F700039F42ED08EE10CD085E90AD08FE096CF6F -:107F8000813511F488E019D023D080E101D063CF8E -:107F9000982F8091C00085FFFCCF9093C600089574 -:107FA000A8958091C00087FFFCCF8091C6000895FE -:107FB000F7DFF6DF80930202F3CFE0E6F0E098E12E -:107FC00090838083089580E0F8DFEE27FF270994EF -:107FD000E7DF803209F0F7DF84E1DACF1F93182F53 -:0C7FE000DFDF1150E9F7F4DF1F91089576 +:107E0000112485E08093810082E08093C00088E1A6 +:107E10008093C10086E08093C20080E18093C4001B +:107E200084B714BE81FFD0D08DE0C8D0259A86E0FB +:107E300020E33CEF91E0309385002093840096BBD3 +:107E4000B09BFECF1D9AA8958150A9F7DD24D3944D +:107E5000A5E0EA2EF1E1FF2EA4D0813421F481E0E7 +:107E6000BED083E024C0823411F484E103C08534A1 +:107E700019F485E0B4D08AC08535A1F492D0082FDA +:107E800010E010930102009300028BD090E0982F35 +:107E90008827802B912B880F991F90930102809344 +:107EA000000273C0863529F484E099D080E071D057 +:107EB0006DC0843609F043C07CD0E0910002F0919F +:107EC000010283E080935700E895C0E0D1E069D0DB +:107ED0008993809102028150809302028823B9F72E +:107EE00078D007B600FCFDCF40910002509101020E +:107EF000A0E0B1E02C9130E011968C91119790E0C8 +:107F0000982F8827822B932B1296FA010C01D0927E +:107F10005700E89511244E5F5F4FF1E0A038BF078E +:107F200049F7E0910002F0910102E0925700E895D4 +:107F300007B600FCFDCFF0925700E89527C08437C4 +:107F4000B9F437D046D0E0910002F09101023196A9 +:107F5000F0930102E09300023197E4918E2F19D043 +:107F600080910202815080930202882361F70EC043 +:107F7000853739F42ED08EE10CD085E90AD08FE018 +:107F800096CF813511F488E019D023D080E101D05B +:107F900063CF982F8091C00085FFFCCF9093C600DF +:107FA0000895A8958091C00087FFFCCF8091C600FE +:107FB0000895F7DFF6DF80930202F3CFE0E6F0E00A +:107FC00098E190838083089580E0F8DFEE27FF2713 +:107FD0000994E7DF803209F0F7DF84E1DACF1F93FD +:0E7FE000182FDFDF1150E9F7F4DF1F9108952D :0400000300007E007B :00000001FF diff --git a/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.lst b/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.lst index 888871d40..dd879dcd1 100644 --- a/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.lst +++ b/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.lst @@ -3,25 +3,25 @@ optiboot_atmega328.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .text 000001ec 00007e00 00007e00 00000054 2**1 + 0 .text 000001ee 00007e00 00007e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .debug_aranges 00000028 00000000 00000000 00000240 2**0 + 1 .debug_aranges 00000028 00000000 00000000 00000242 2**0 CONTENTS, READONLY, DEBUGGING - 2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0 + 2 .debug_pubnames 0000006a 00000000 00000000 0000026a 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_info 00000269 00000000 00000000 000002d2 2**0 + 3 .debug_info 00000269 00000000 00000000 000002d4 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0 + 4 .debug_abbrev 00000196 00000000 00000000 0000053d 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_line 000003d3 00000000 00000000 000006d1 2**0 + 5 .debug_line 000003db 00000000 00000000 000006d3 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2 + 6 .debug_frame 00000090 00000000 00000000 00000ab0 2**2 CONTENTS, READONLY, DEBUGGING - 7 .debug_str 00000135 00000000 00000000 00000b34 2**0 + 7 .debug_str 00000124 00000000 00000000 00000b40 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0 + 8 .debug_loc 000001d1 00000000 00000000 00000c64 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0 + 9 .debug_ranges 00000068 00000000 00000000 00000e35 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -33,488 +33,492 @@ Disassembly of section .text: #endif /* main program starts here */ int main(void) { - 7e00: 85 e0 ldi r24, 0x05 ; 5 - 7e02: 80 93 81 00 sts 0x0081, r24 + 7e00: 11 24 eor r1, r1 + + uint8_t ch; + #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 + 7e02: 85 e0 ldi r24, 0x05 ; 5 + 7e04: 80 93 81 00 sts 0x0081, r24 #endif #ifndef SOFT_UART UCSR0A = _BV(U2X0); //Double speed mode USART0 - 7e06: 82 e0 ldi r24, 0x02 ; 2 - 7e08: 80 93 c0 00 sts 0x00C0, r24 + 7e08: 82 e0 ldi r24, 0x02 ; 2 + 7e0a: 80 93 c0 00 sts 0x00C0, r24 UCSR0B = _BV(RXEN0) | _BV(TXEN0); - 7e0c: 88 e1 ldi r24, 0x18 ; 24 - 7e0e: 80 93 c1 00 sts 0x00C1, r24 + 7e0e: 88 e1 ldi r24, 0x18 ; 24 + 7e10: 80 93 c1 00 sts 0x00C1, r24 UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); - 7e12: 86 e0 ldi r24, 0x06 ; 6 - 7e14: 80 93 c2 00 sts 0x00C2, r24 + 7e14: 86 e0 ldi r24, 0x06 ; 6 + 7e16: 80 93 c2 00 sts 0x00C2, r24 UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); - 7e18: 80 e1 ldi r24, 0x10 ; 16 - 7e1a: 80 93 c4 00 sts 0x00C4, r24 + 7e1a: 80 e1 ldi r24, 0x10 ; 16 + 7e1c: 80 93 c4 00 sts 0x00C4, r24 #endif // Adaboot no-wait mod ch = MCUSR; - 7e1e: 84 b7 in r24, 0x34 ; 52 + 7e20: 84 b7 in r24, 0x34 ; 52 MCUSR = 0; - 7e20: 14 be out 0x34, r1 ; 52 + 7e22: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); - 7e22: 81 ff sbrs r24, 1 - 7e24: d0 d0 rcall .+416 ; 0x7fc6 + 7e24: 81 ff sbrs r24, 1 + 7e26: d0 d0 rcall .+416 ; 0x7fc8 // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_500MS); - 7e26: 8d e0 ldi r24, 0x0D ; 13 - 7e28: c8 d0 rcall .+400 ; 0x7fba + 7e28: 8d e0 ldi r24, 0x0D ; 13 + 7e2a: c8 d0 rcall .+400 ; 0x7fbc /* Set LED pin as output */ LED_DDR |= _BV(LED); - 7e2a: 25 9a sbi 0x04, 5 ; 4 - 7e2c: 86 e0 ldi r24, 0x06 ; 6 + 7e2c: 25 9a sbi 0x04, 5 ; 4 + 7e2e: 86 e0 ldi r24, 0x06 ; 6 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 7e2e: 20 e3 ldi r18, 0x30 ; 48 - 7e30: 3c ef ldi r19, 0xFC ; 252 + 7e30: 20 e3 ldi r18, 0x30 ; 48 + 7e32: 3c ef ldi r19, 0xFC ; 252 TIFR1 = _BV(TOV1); - 7e32: 91 e0 ldi r25, 0x01 ; 1 + 7e34: 91 e0 ldi r25, 0x01 ; 1 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 7e34: 30 93 85 00 sts 0x0085, r19 - 7e38: 20 93 84 00 sts 0x0084, r18 + 7e36: 30 93 85 00 sts 0x0085, r19 + 7e3a: 20 93 84 00 sts 0x0084, r18 TIFR1 = _BV(TOV1); - 7e3c: 96 bb out 0x16, r25 ; 22 + 7e3e: 96 bb out 0x16, r25 ; 22 while(!(TIFR1 & _BV(TOV1))); - 7e3e: b0 9b sbis 0x16, 0 ; 22 - 7e40: fe cf rjmp .-4 ; 0x7e3e + 7e40: b0 9b sbis 0x16, 0 ; 22 + 7e42: fe cf rjmp .-4 ; 0x7e40 LED_PIN |= _BV(LED); - 7e42: 1d 9a sbi 0x03, 5 ; 3 + 7e44: 1d 9a sbi 0x03, 5 ; 3 return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 7e44: a8 95 wdr + 7e46: a8 95 wdr TCNT1 = -(F_CPU/(1024*16)); TIFR1 = _BV(TOV1); while(!(TIFR1 & _BV(TOV1))); LED_PIN |= _BV(LED); watchdogReset(); } while (--count); - 7e46: 81 50 subi r24, 0x01 ; 1 - 7e48: a9 f7 brne .-22 ; 0x7e34 + 7e48: 81 50 subi r24, 0x01 ; 1 + 7e4a: a9 f7 brne .-22 ; 0x7e36 /* get character from UART */ ch = getch(); if(ch == STK_GET_PARAMETER) { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); - 7e4a: dd 24 eor r13, r13 - 7e4c: d3 94 inc r13 + 7e4c: dd 24 eor r13, r13 + 7e4e: d3 94 inc r13 boot_page_fill((uint16_t)(void*)addrPtr,a); addrPtr += 2; } while (--ch); // Write from programming buffer boot_page_write((uint16_t)(void*)address); - 7e4e: a5 e0 ldi r26, 0x05 ; 5 - 7e50: ea 2e mov r14, r26 + 7e50: a5 e0 ldi r26, 0x05 ; 5 + 7e52: ea 2e mov r14, r26 boot_spm_busy_wait(); #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 7e52: f1 e1 ldi r31, 0x11 ; 17 - 7e54: ff 2e mov r15, r31 + 7e54: f1 e1 ldi r31, 0x11 ; 17 + 7e56: ff 2e mov r15, r31 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 7e56: a4 d0 rcall .+328 ; 0x7fa0 + 7e58: a4 d0 rcall .+328 ; 0x7fa2 if(ch == STK_GET_PARAMETER) { - 7e58: 81 34 cpi r24, 0x41 ; 65 - 7e5a: 21 f4 brne .+8 ; 0x7e64 + 7e5a: 81 34 cpi r24, 0x41 ; 65 + 7e5c: 21 f4 brne .+8 ; 0x7e66 // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); - 7e5c: 81 e0 ldi r24, 0x01 ; 1 - 7e5e: be d0 rcall .+380 ; 0x7fdc + 7e5e: 81 e0 ldi r24, 0x01 ; 1 + 7e60: be d0 rcall .+380 ; 0x7fde putch(0x03); - 7e60: 83 e0 ldi r24, 0x03 ; 3 - 7e62: 24 c0 rjmp .+72 ; 0x7eac + 7e62: 83 e0 ldi r24, 0x03 ; 3 + 7e64: 24 c0 rjmp .+72 ; 0x7eae } else if(ch == STK_SET_DEVICE) { - 7e64: 82 34 cpi r24, 0x42 ; 66 - 7e66: 11 f4 brne .+4 ; 0x7e6c + 7e66: 82 34 cpi r24, 0x42 ; 66 + 7e68: 11 f4 brne .+4 ; 0x7e6e // SET DEVICE is ignored getNch(20); - 7e68: 84 e1 ldi r24, 0x14 ; 20 - 7e6a: 03 c0 rjmp .+6 ; 0x7e72 + 7e6a: 84 e1 ldi r24, 0x14 ; 20 + 7e6c: 03 c0 rjmp .+6 ; 0x7e74 } else if(ch == STK_SET_DEVICE_EXT) { - 7e6c: 85 34 cpi r24, 0x45 ; 69 - 7e6e: 19 f4 brne .+6 ; 0x7e76 + 7e6e: 85 34 cpi r24, 0x45 ; 69 + 7e70: 19 f4 brne .+6 ; 0x7e78 // SET DEVICE EXT is ignored getNch(5); - 7e70: 85 e0 ldi r24, 0x05 ; 5 - 7e72: b4 d0 rcall .+360 ; 0x7fdc - 7e74: 8a c0 rjmp .+276 ; 0x7f8a + 7e72: 85 e0 ldi r24, 0x05 ; 5 + 7e74: b4 d0 rcall .+360 ; 0x7fde + 7e76: 8a c0 rjmp .+276 ; 0x7f8c } else if(ch == STK_LOAD_ADDRESS) { - 7e76: 85 35 cpi r24, 0x55 ; 85 - 7e78: a1 f4 brne .+40 ; 0x7ea2 + 7e78: 85 35 cpi r24, 0x55 ; 85 + 7e7a: a1 f4 brne .+40 ; 0x7ea4 // LOAD ADDRESS address = getch(); - 7e7a: 92 d0 rcall .+292 ; 0x7fa0 - 7e7c: 08 2f mov r16, r24 - 7e7e: 10 e0 ldi r17, 0x00 ; 0 - 7e80: 10 93 01 02 sts 0x0201, r17 - 7e84: 00 93 00 02 sts 0x0200, r16 + 7e7c: 92 d0 rcall .+292 ; 0x7fa2 + 7e7e: 08 2f mov r16, r24 + 7e80: 10 e0 ldi r17, 0x00 ; 0 + 7e82: 10 93 01 02 sts 0x0201, r17 + 7e86: 00 93 00 02 sts 0x0200, r16 address = (address & 0xff) | (getch() << 8); - 7e88: 8b d0 rcall .+278 ; 0x7fa0 - 7e8a: 90 e0 ldi r25, 0x00 ; 0 - 7e8c: 98 2f mov r25, r24 - 7e8e: 88 27 eor r24, r24 - 7e90: 80 2b or r24, r16 - 7e92: 91 2b or r25, r17 + 7e8a: 8b d0 rcall .+278 ; 0x7fa2 + 7e8c: 90 e0 ldi r25, 0x00 ; 0 + 7e8e: 98 2f mov r25, r24 + 7e90: 88 27 eor r24, r24 + 7e92: 80 2b or r24, r16 + 7e94: 91 2b or r25, r17 address += address; // Convert from word address to byte address - 7e94: 88 0f add r24, r24 - 7e96: 99 1f adc r25, r25 - 7e98: 90 93 01 02 sts 0x0201, r25 - 7e9c: 80 93 00 02 sts 0x0200, r24 - 7ea0: 73 c0 rjmp .+230 ; 0x7f88 + 7e96: 88 0f add r24, r24 + 7e98: 99 1f adc r25, r25 + 7e9a: 90 93 01 02 sts 0x0201, r25 + 7e9e: 80 93 00 02 sts 0x0200, r24 + 7ea2: 73 c0 rjmp .+230 ; 0x7f8a verifySpace(); } else if(ch == STK_UNIVERSAL) { - 7ea2: 86 35 cpi r24, 0x56 ; 86 - 7ea4: 29 f4 brne .+10 ; 0x7eb0 + 7ea4: 86 35 cpi r24, 0x56 ; 86 + 7ea6: 29 f4 brne .+10 ; 0x7eb2 // UNIVERSAL command is ignored getNch(4); - 7ea6: 84 e0 ldi r24, 0x04 ; 4 - 7ea8: 99 d0 rcall .+306 ; 0x7fdc + 7ea8: 84 e0 ldi r24, 0x04 ; 4 + 7eaa: 99 d0 rcall .+306 ; 0x7fde putch(0x00); - 7eaa: 80 e0 ldi r24, 0x00 ; 0 - 7eac: 71 d0 rcall .+226 ; 0x7f90 - 7eae: 6d c0 rjmp .+218 ; 0x7f8a + 7eac: 80 e0 ldi r24, 0x00 ; 0 + 7eae: 71 d0 rcall .+226 ; 0x7f92 + 7eb0: 6d c0 rjmp .+218 ; 0x7f8c } /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { - 7eb0: 84 36 cpi r24, 0x64 ; 100 - 7eb2: 09 f0 breq .+2 ; 0x7eb6 - 7eb4: 43 c0 rjmp .+134 ; 0x7f3c + 7eb2: 84 36 cpi r24, 0x64 ; 100 + 7eb4: 09 f0 breq .+2 ; 0x7eb8 + 7eb6: 43 c0 rjmp .+134 ; 0x7f3e // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; getLen(); - 7eb6: 7c d0 rcall .+248 ; 0x7fb0 + 7eb8: 7c d0 rcall .+248 ; 0x7fb2 // Immediately start page erase - this will 4.5ms boot_page_erase((uint16_t)(void*)address); - 7eb8: e0 91 00 02 lds r30, 0x0200 - 7ebc: f0 91 01 02 lds r31, 0x0201 - 7ec0: 83 e0 ldi r24, 0x03 ; 3 - 7ec2: 80 93 57 00 sts 0x0057, r24 - 7ec6: e8 95 spm - 7ec8: c0 e0 ldi r28, 0x00 ; 0 - 7eca: d1 e0 ldi r29, 0x01 ; 1 + 7eba: e0 91 00 02 lds r30, 0x0200 + 7ebe: f0 91 01 02 lds r31, 0x0201 + 7ec2: 83 e0 ldi r24, 0x03 ; 3 + 7ec4: 80 93 57 00 sts 0x0057, r24 + 7ec8: e8 95 spm + 7eca: c0 e0 ldi r28, 0x00 ; 0 + 7ecc: d1 e0 ldi r29, 0x01 ; 1 // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); - 7ecc: 69 d0 rcall .+210 ; 0x7fa0 - 7ece: 89 93 st Y+, r24 + 7ece: 69 d0 rcall .+210 ; 0x7fa2 + 7ed0: 89 93 st Y+, r24 while (--length); - 7ed0: 80 91 02 02 lds r24, 0x0202 - 7ed4: 81 50 subi r24, 0x01 ; 1 - 7ed6: 80 93 02 02 sts 0x0202, r24 - 7eda: 88 23 and r24, r24 - 7edc: b9 f7 brne .-18 ; 0x7ecc + 7ed2: 80 91 02 02 lds r24, 0x0202 + 7ed6: 81 50 subi r24, 0x01 ; 1 + 7ed8: 80 93 02 02 sts 0x0202, r24 + 7edc: 88 23 and r24, r24 + 7ede: b9 f7 brne .-18 ; 0x7ece // Read command terminator, start reply verifySpace(); - 7ede: 78 d0 rcall .+240 ; 0x7fd0 + 7ee0: 78 d0 rcall .+240 ; 0x7fd2 // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - 7ee0: 07 b6 in r0, 0x37 ; 55 - 7ee2: 00 fc sbrc r0, 0 - 7ee4: fd cf rjmp .-6 ; 0x7ee0 + 7ee2: 07 b6 in r0, 0x37 ; 55 + 7ee4: 00 fc sbrc r0, 0 + 7ee6: fd cf rjmp .-6 ; 0x7ee2 } #endif // Copy buffer into programming buffer bufPtr = buff; addrPtr = (uint16_t)(void*)address; - 7ee6: 40 91 00 02 lds r20, 0x0200 - 7eea: 50 91 01 02 lds r21, 0x0201 - 7eee: a0 e0 ldi r26, 0x00 ; 0 - 7ef0: b1 e0 ldi r27, 0x01 ; 1 + 7ee8: 40 91 00 02 lds r20, 0x0200 + 7eec: 50 91 01 02 lds r21, 0x0201 + 7ef0: a0 e0 ldi r26, 0x00 ; 0 + 7ef2: b1 e0 ldi r27, 0x01 ; 1 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 7ef2: 2c 91 ld r18, X - 7ef4: 30 e0 ldi r19, 0x00 ; 0 + 7ef4: 2c 91 ld r18, X + 7ef6: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 7ef6: 11 96 adiw r26, 0x01 ; 1 - 7ef8: 8c 91 ld r24, X - 7efa: 11 97 sbiw r26, 0x01 ; 1 - 7efc: 90 e0 ldi r25, 0x00 ; 0 - 7efe: 98 2f mov r25, r24 - 7f00: 88 27 eor r24, r24 - 7f02: 82 2b or r24, r18 - 7f04: 93 2b or r25, r19 + 7ef8: 11 96 adiw r26, 0x01 ; 1 + 7efa: 8c 91 ld r24, X + 7efc: 11 97 sbiw r26, 0x01 ; 1 + 7efe: 90 e0 ldi r25, 0x00 ; 0 + 7f00: 98 2f mov r25, r24 + 7f02: 88 27 eor r24, r24 + 7f04: 82 2b or r24, r18 + 7f06: 93 2b or r25, r19 #ifdef VIRTUAL_BOOT_PARTITION #define rstVect (*(uint16_t*)(0x204)) #define wdtVect (*(uint16_t*)(0x206)) #endif /* main program starts here */ int main(void) { - 7f06: 12 96 adiw r26, 0x02 ; 2 + 7f08: 12 96 adiw r26, 0x02 ; 2 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; a |= (*bufPtr++) << 8; boot_page_fill((uint16_t)(void*)addrPtr,a); - 7f08: fa 01 movw r30, r20 - 7f0a: 0c 01 movw r0, r24 - 7f0c: d0 92 57 00 sts 0x0057, r13 - 7f10: e8 95 spm - 7f12: 11 24 eor r1, r1 + 7f0a: fa 01 movw r30, r20 + 7f0c: 0c 01 movw r0, r24 + 7f0e: d0 92 57 00 sts 0x0057, r13 + 7f12: e8 95 spm + 7f14: 11 24 eor r1, r1 addrPtr += 2; - 7f14: 4e 5f subi r20, 0xFE ; 254 - 7f16: 5f 4f sbci r21, 0xFF ; 255 + 7f16: 4e 5f subi r20, 0xFE ; 254 + 7f18: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 7f18: f1 e0 ldi r31, 0x01 ; 1 - 7f1a: a0 38 cpi r26, 0x80 ; 128 - 7f1c: bf 07 cpc r27, r31 - 7f1e: 49 f7 brne .-46 ; 0x7ef2 + 7f1a: f1 e0 ldi r31, 0x01 ; 1 + 7f1c: a0 38 cpi r26, 0x80 ; 128 + 7f1e: bf 07 cpc r27, r31 + 7f20: 49 f7 brne .-46 ; 0x7ef4 // Write from programming buffer boot_page_write((uint16_t)(void*)address); - 7f20: e0 91 00 02 lds r30, 0x0200 - 7f24: f0 91 01 02 lds r31, 0x0201 - 7f28: e0 92 57 00 sts 0x0057, r14 - 7f2c: e8 95 spm + 7f22: e0 91 00 02 lds r30, 0x0200 + 7f26: f0 91 01 02 lds r31, 0x0201 + 7f2a: e0 92 57 00 sts 0x0057, r14 + 7f2e: e8 95 spm boot_spm_busy_wait(); - 7f2e: 07 b6 in r0, 0x37 ; 55 - 7f30: 00 fc sbrc r0, 0 - 7f32: fd cf rjmp .-6 ; 0x7f2e + 7f30: 07 b6 in r0, 0x37 ; 55 + 7f32: 00 fc sbrc r0, 0 + 7f34: fd cf rjmp .-6 ; 0x7f30 #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 7f34: f0 92 57 00 sts 0x0057, r15 - 7f38: e8 95 spm - 7f3a: 27 c0 rjmp .+78 ; 0x7f8a + 7f36: f0 92 57 00 sts 0x0057, r15 + 7f3a: e8 95 spm + 7f3c: 27 c0 rjmp .+78 ; 0x7f8c #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 7f3c: 84 37 cpi r24, 0x74 ; 116 - 7f3e: b9 f4 brne .+46 ; 0x7f6e + 7f3e: 84 37 cpi r24, 0x74 ; 116 + 7f40: b9 f4 brne .+46 ; 0x7f70 // READ PAGE - we only read flash getLen(); - 7f40: 37 d0 rcall .+110 ; 0x7fb0 + 7f42: 37 d0 rcall .+110 ; 0x7fb2 verifySpace(); - 7f42: 46 d0 rcall .+140 ; 0x7fd0 + 7f44: 46 d0 rcall .+140 ; 0x7fd2 else ch = pgm_read_byte_near(address); address++; putch(ch); } while (--length); #else do putch(pgm_read_byte_near(address++)); - 7f44: e0 91 00 02 lds r30, 0x0200 - 7f48: f0 91 01 02 lds r31, 0x0201 - 7f4c: 31 96 adiw r30, 0x01 ; 1 - 7f4e: f0 93 01 02 sts 0x0201, r31 - 7f52: e0 93 00 02 sts 0x0200, r30 - 7f56: 31 97 sbiw r30, 0x01 ; 1 - 7f58: e4 91 lpm r30, Z+ - 7f5a: 8e 2f mov r24, r30 - 7f5c: 19 d0 rcall .+50 ; 0x7f90 + 7f46: e0 91 00 02 lds r30, 0x0200 + 7f4a: f0 91 01 02 lds r31, 0x0201 + 7f4e: 31 96 adiw r30, 0x01 ; 1 + 7f50: f0 93 01 02 sts 0x0201, r31 + 7f54: e0 93 00 02 sts 0x0200, r30 + 7f58: 31 97 sbiw r30, 0x01 ; 1 + 7f5a: e4 91 lpm r30, Z+ + 7f5c: 8e 2f mov r24, r30 + 7f5e: 19 d0 rcall .+50 ; 0x7f92 while (--length); - 7f5e: 80 91 02 02 lds r24, 0x0202 - 7f62: 81 50 subi r24, 0x01 ; 1 - 7f64: 80 93 02 02 sts 0x0202, r24 - 7f68: 88 23 and r24, r24 - 7f6a: 61 f7 brne .-40 ; 0x7f44 - 7f6c: 0e c0 rjmp .+28 ; 0x7f8a + 7f60: 80 91 02 02 lds r24, 0x0202 + 7f64: 81 50 subi r24, 0x01 ; 1 + 7f66: 80 93 02 02 sts 0x0202, r24 + 7f6a: 88 23 and r24, r24 + 7f6c: 61 f7 brne .-40 ; 0x7f46 + 7f6e: 0e c0 rjmp .+28 ; 0x7f8c #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 7f6e: 85 37 cpi r24, 0x75 ; 117 - 7f70: 39 f4 brne .+14 ; 0x7f80 + 7f70: 85 37 cpi r24, 0x75 ; 117 + 7f72: 39 f4 brne .+14 ; 0x7f82 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 7f72: 2e d0 rcall .+92 ; 0x7fd0 + 7f74: 2e d0 rcall .+92 ; 0x7fd2 putch(SIGNATURE_0); - 7f74: 8e e1 ldi r24, 0x1E ; 30 - 7f76: 0c d0 rcall .+24 ; 0x7f90 + 7f76: 8e e1 ldi r24, 0x1E ; 30 + 7f78: 0c d0 rcall .+24 ; 0x7f92 putch(SIGNATURE_1); - 7f78: 85 e9 ldi r24, 0x95 ; 149 - 7f7a: 0a d0 rcall .+20 ; 0x7f90 + 7f7a: 85 e9 ldi r24, 0x95 ; 149 + 7f7c: 0a d0 rcall .+20 ; 0x7f92 putch(SIGNATURE_2); - 7f7c: 8f e0 ldi r24, 0x0F ; 15 - 7f7e: 96 cf rjmp .-212 ; 0x7eac + 7f7e: 8f e0 ldi r24, 0x0F ; 15 + 7f80: 96 cf rjmp .-212 ; 0x7eae } else if (ch == 'Q') { - 7f80: 81 35 cpi r24, 0x51 ; 81 - 7f82: 11 f4 brne .+4 ; 0x7f88 + 7f82: 81 35 cpi r24, 0x51 ; 81 + 7f84: 11 f4 brne .+4 ; 0x7f8a // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 7f84: 88 e0 ldi r24, 0x08 ; 8 - 7f86: 19 d0 rcall .+50 ; 0x7fba + 7f86: 88 e0 ldi r24, 0x08 ; 8 + 7f88: 19 d0 rcall .+50 ; 0x7fbc verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 7f88: 23 d0 rcall .+70 ; 0x7fd0 + 7f8a: 23 d0 rcall .+70 ; 0x7fd2 } putch(STK_OK); - 7f8a: 80 e1 ldi r24, 0x10 ; 16 - 7f8c: 01 d0 rcall .+2 ; 0x7f90 - 7f8e: 63 cf rjmp .-314 ; 0x7e56 + 7f8c: 80 e1 ldi r24, 0x10 ; 16 + 7f8e: 01 d0 rcall .+2 ; 0x7f92 + 7f90: 63 cf rjmp .-314 ; 0x7e58 -00007f90 : +00007f92 : } } void putch(char ch) { - 7f90: 98 2f mov r25, r24 + 7f92: 98 2f mov r25, r24 #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); - 7f92: 80 91 c0 00 lds r24, 0x00C0 - 7f96: 85 ff sbrs r24, 5 - 7f98: fc cf rjmp .-8 ; 0x7f92 + 7f94: 80 91 c0 00 lds r24, 0x00C0 + 7f98: 85 ff sbrs r24, 5 + 7f9a: fc cf rjmp .-8 ; 0x7f94 UDR0 = ch; - 7f9a: 90 93 c6 00 sts 0x00C6, r25 + 7f9c: 90 93 c6 00 sts 0x00C6, r25 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 7f9e: 08 95 ret + 7fa0: 08 95 ret -00007fa0 : +00007fa2 : return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 7fa0: a8 95 wdr + 7fa2: a8 95 wdr [uartBit] "I" (UART_RX_BIT) : "r25" ); #else while(!(UCSR0A & _BV(RXC0))); - 7fa2: 80 91 c0 00 lds r24, 0x00C0 - 7fa6: 87 ff sbrs r24, 7 - 7fa8: fc cf rjmp .-8 ; 0x7fa2 + 7fa4: 80 91 c0 00 lds r24, 0x00C0 + 7fa8: 87 ff sbrs r24, 7 + 7faa: fc cf rjmp .-8 ; 0x7fa4 ch = UDR0; - 7faa: 80 91 c6 00 lds r24, 0x00C6 + 7fac: 80 91 c6 00 lds r24, 0x00C6 #ifdef LED_DATA_FLASH LED_PIN |= _BV(LED); #endif return ch; } - 7fae: 08 95 ret + 7fb0: 08 95 ret -00007fb0 : +00007fb2 : } while (--count); } #endif uint8_t getLen() { getch(); - 7fb0: f7 df rcall .-18 ; 0x7fa0 + 7fb2: f7 df rcall .-18 ; 0x7fa2 length = getch(); - 7fb2: f6 df rcall .-20 ; 0x7fa0 - 7fb4: 80 93 02 02 sts 0x0202, r24 + 7fb4: f6 df rcall .-20 ; 0x7fa2 + 7fb6: 80 93 02 02 sts 0x0202, r24 return getch(); } - 7fb8: f3 cf rjmp .-26 ; 0x7fa0 + 7fba: f3 cf rjmp .-26 ; 0x7fa2 -00007fba : +00007fbc : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 7fba: e0 e6 ldi r30, 0x60 ; 96 - 7fbc: f0 e0 ldi r31, 0x00 ; 0 - 7fbe: 98 e1 ldi r25, 0x18 ; 24 - 7fc0: 90 83 st Z, r25 + 7fbc: e0 e6 ldi r30, 0x60 ; 96 + 7fbe: f0 e0 ldi r31, 0x00 ; 0 + 7fc0: 98 e1 ldi r25, 0x18 ; 24 + 7fc2: 90 83 st Z, r25 WDTCSR = x; - 7fc2: 80 83 st Z, r24 + 7fc4: 80 83 st Z, r24 } - 7fc4: 08 95 ret + 7fc6: 08 95 ret -00007fc6 : +00007fc8 : void appStart() { watchdogConfig(WATCHDOG_OFF); - 7fc6: 80 e0 ldi r24, 0x00 ; 0 - 7fc8: f8 df rcall .-16 ; 0x7fba + 7fc8: 80 e0 ldi r24, 0x00 ; 0 + 7fca: f8 df rcall .-16 ; 0x7fbc __asm__ __volatile__ ( - 7fca: ee 27 eor r30, r30 - 7fcc: ff 27 eor r31, r31 - 7fce: 09 94 ijmp + 7fcc: ee 27 eor r30, r30 + 7fce: ff 27 eor r31, r31 + 7fd0: 09 94 ijmp -00007fd0 : +00007fd2 : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) appStart(); - 7fd0: e7 df rcall .-50 ; 0x7fa0 - 7fd2: 80 32 cpi r24, 0x20 ; 32 - 7fd4: 09 f0 breq .+2 ; 0x7fd8 - 7fd6: f7 df rcall .-18 ; 0x7fc6 + 7fd2: e7 df rcall .-50 ; 0x7fa2 + 7fd4: 80 32 cpi r24, 0x20 ; 32 + 7fd6: 09 f0 breq .+2 ; 0x7fda + 7fd8: f7 df rcall .-18 ; 0x7fc8 putch(STK_INSYNC); - 7fd8: 84 e1 ldi r24, 0x14 ; 20 + 7fda: 84 e1 ldi r24, 0x14 ; 20 } - 7fda: da cf rjmp .-76 ; 0x7f90 + 7fdc: da cf rjmp .-76 ; 0x7f92 ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 7fdc: 1f 93 push r17 - 7fde: 18 2f mov r17, r24 + 7fde: 1f 93 push r17 + 7fe0: 18 2f mov r17, r24 -00007fe0 : +00007fe2 : do getch(); while (--count); - 7fe0: df df rcall .-66 ; 0x7fa0 - 7fe2: 11 50 subi r17, 0x01 ; 1 - 7fe4: e9 f7 brne .-6 ; 0x7fe0 + 7fe2: df df rcall .-66 ; 0x7fa2 + 7fe4: 11 50 subi r17, 0x01 ; 1 + 7fe6: e9 f7 brne .-6 ; 0x7fe2 verifySpace(); - 7fe6: f4 df rcall .-24 ; 0x7fd0 + 7fe8: f4 df rcall .-24 ; 0x7fd2 } - 7fe8: 1f 91 pop r17 - 7fea: 08 95 ret + 7fea: 1f 91 pop r17 + 7fec: 08 95 ret diff --git a/hardware/arduino/cores/arduino/Arduino.h b/hardware/arduino/cores/arduino/Arduino.h new file mode 100755 index 000000000..ebdbe9a2f --- /dev/null +++ b/hardware/arduino/cores/arduino/Arduino.h @@ -0,0 +1,205 @@ +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include + +#include +#include +#include + +#include "binary.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +#define HIGH 0x1 +#define LOW 0x0 + +#define INPUT 0x0 +#define OUTPUT 0x1 + +#define true 0x1 +#define false 0x0 + +#define PI 3.1415926535897932384626433832795 +#define HALF_PI 1.5707963267948966192313216916398 +#define TWO_PI 6.283185307179586476925286766559 +#define DEG_TO_RAD 0.017453292519943295769236907684886 +#define RAD_TO_DEG 57.295779513082320876798154814105 + +#define SERIAL 0x0 +#define DISPLAY 0x1 + +#define LSBFIRST 0 +#define MSBFIRST 1 + +#define CHANGE 1 +#define FALLING 2 +#define RISING 3 + +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define INTERNAL1V1 2 +#define INTERNAL2V56 3 +#else +#define INTERNAL 3 +#endif +#define DEFAULT 1 +#define EXTERNAL 0 + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif + +#define min(a,b) ((a)<(b)?(a):(b)) +#define max(a,b) ((a)>(b)?(a):(b)) +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() sei() +#define noInterrupts() cli() + +#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) ) +#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L ) + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + + +typedef unsigned int word; + +#define bit(b) (1UL << (b)) + +typedef uint8_t boolean; +typedef uint8_t byte; + +void init(void); + +void pinMode(uint8_t, uint8_t); +void digitalWrite(uint8_t, uint8_t); +int digitalRead(uint8_t); +int analogRead(uint8_t); +void analogReference(uint8_t mode); +void analogWrite(uint8_t, int); + +unsigned long millis(void); +unsigned long micros(void); +void delay(unsigned long); +void delayMicroseconds(unsigned int us); +unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); + +void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); +uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); + +void attachInterrupt(uint8_t, void (*)(void), int mode); +void detachInterrupt(uint8_t); + +void setup(void); +void loop(void); + +// Get the bit location within the hardware port of the given virtual pin. +// This comes from the pins_*.c file for the active board configuration. + +#define analogInPinToBit(P) (P) + +// On the ATmega1280, the addresses of some of the port registers are +// greater than 255, so we can't store them in uint8_t's. +extern const uint16_t PROGMEM port_to_mode_PGM[]; +extern const uint16_t PROGMEM port_to_input_PGM[]; +extern const uint16_t PROGMEM port_to_output_PGM[]; + +extern const uint8_t PROGMEM digital_pin_to_port_PGM[]; +// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[]; +extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[]; +extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; + +// Get the bit location within the hardware port of the given virtual pin. +// This comes from the pins_*.c file for the active board configuration. +// +// These perform slightly better as macros compared to inline functions +// +#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) ) +#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) ) +#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) ) +#define analogInPinToBit(P) (P) +#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) ) +#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) ) +#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) ) + +#define NOT_A_PIN 0 +#define NOT_A_PORT 0 + +#define PA 1 +#define PB 2 +#define PC 3 +#define PD 4 +#define PE 5 +#define PF 6 +#define PG 7 +#define PH 8 +#define PJ 10 +#define PK 11 +#define PL 12 + +#define NOT_ON_TIMER 0 +#define TIMER0A 1 +#define TIMER0B 2 +#define TIMER1A 3 +#define TIMER1B 4 +#define TIMER2 5 +#define TIMER2A 6 +#define TIMER2B 7 + +#define TIMER3A 8 +#define TIMER3B 9 +#define TIMER3C 10 +#define TIMER4A 11 +#define TIMER4B 12 +#define TIMER4C 13 +#define TIMER5A 14 +#define TIMER5B 15 +#define TIMER5C 16 + +#ifdef __cplusplus +} // extern "C" +#endif + +#ifdef __cplusplus +#include "WCharacter.h" +#include "WString.h" +#include "HardwareSerial.h" + +uint16_t makeWord(uint16_t w); +uint16_t makeWord(byte h, byte l); + +#define word(...) makeWord(__VA_ARGS__) + +unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); + +void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); +void noTone(uint8_t _pin); + +// WMath prototypes +long random(long); +long random(long, long); +void randomSeed(unsigned int); +long map(long, long, long, long, long); + +#endif + +#include "pins_arduino.h" + +#endif \ No newline at end of file diff --git a/hardware/arduino/cores/arduino/HardwareSerial.cpp b/hardware/arduino/cores/arduino/HardwareSerial.cpp index 4397efb7e..d6be2181c 100644 --- a/hardware/arduino/cores/arduino/HardwareSerial.cpp +++ b/hardware/arduino/cores/arduino/HardwareSerial.cpp @@ -24,7 +24,7 @@ #include #include #include -#include "wiring.h" +#include "Arduino.h" #include "wiring_private.h" // this next line disables the entire HardwareSerial.cpp, @@ -34,149 +34,223 @@ #include "HardwareSerial.h" // Define constants and variables for buffering incoming serial data. We're -// using a ring buffer (I think), in which rx_buffer_head is the index of the -// location to which to write the next incoming character and rx_buffer_tail -// is the index of the location from which to read. +// using a ring buffer (I think), in which head is the index of the location +// to which to write the next incoming character and tail is the index of the +// location from which to read. #if (RAMEND < 1000) - #define RX_BUFFER_SIZE 32 + #define SERIAL_BUFFER_SIZE 16 #else - #define RX_BUFFER_SIZE 128 + #define SERIAL_BUFFER_SIZE 64 #endif struct ring_buffer { - unsigned char buffer[RX_BUFFER_SIZE]; - int head; - int tail; + unsigned char buffer[SERIAL_BUFFER_SIZE]; + volatile int head; + volatile int tail; }; #if defined(UBRRH) || defined(UBRR0H) ring_buffer rx_buffer = { { 0 }, 0, 0 }; + ring_buffer tx_buffer = { { 0 }, 0, 0 }; #endif #if defined(UBRR1H) ring_buffer rx_buffer1 = { { 0 }, 0, 0 }; + ring_buffer tx_buffer1 = { { 0 }, 0, 0 }; #endif #if defined(UBRR2H) ring_buffer rx_buffer2 = { { 0 }, 0, 0 }; + ring_buffer tx_buffer2 = { { 0 }, 0, 0 }; #endif #if defined(UBRR3H) ring_buffer rx_buffer3 = { { 0 }, 0, 0 }; + ring_buffer tx_buffer3 = { { 0 }, 0, 0 }; #endif -inline void store_char(unsigned char c, ring_buffer *rx_buffer) +inline void store_char(unsigned char c, ring_buffer *buffer) { - int i = (unsigned int)(rx_buffer->head + 1) % RX_BUFFER_SIZE; + int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE; // if we should be storing the received character into the location // just before the tail (meaning that the head would advance to the // current location of the tail), we're about to overflow the buffer // and so we don't write the character or advance the head. - if (i != rx_buffer->tail) { - rx_buffer->buffer[rx_buffer->head] = c; - rx_buffer->head = i; + if (i != buffer->tail) { + buffer->buffer[buffer->head] = c; + buffer->head = i; } } +#if !defined(USART_RX_vect) && !defined(SIG_USART0_RECV) && \ + !defined(SIG_UART0_RECV) && !defined(USART0_RX_vect) && \ + !defined(SIG_UART_RECV) + #error Don't know what the Data Received vector is called for the first UART +#else + void serialEvent() __attribute__((weak)); + void serialEvent() {} #if defined(USART_RX_vect) SIGNAL(USART_RX_vect) - { - #if defined(UDR0) - unsigned char c = UDR0; - #elif defined(UDR) - unsigned char c = UDR; // atmega8535 - #else - #error UDR not defined - #endif - store_char(c, &rx_buffer); - } -#elif defined(SIG_USART0_RECV) && defined(UDR0) +#elif defined(SIG_USART0_RECV) SIGNAL(SIG_USART0_RECV) - { - unsigned char c = UDR0; - store_char(c, &rx_buffer); - } -#elif defined(SIG_UART0_RECV) && defined(UDR0) +#elif defined(SIG_UART0_RECV) SIGNAL(SIG_UART0_RECV) - { - unsigned char c = UDR0; - store_char(c, &rx_buffer); - } -//#elif defined(SIG_USART_RECV) #elif defined(USART0_RX_vect) - // fixed by Mark Sproul this is on the 644/644p - //SIGNAL(SIG_USART_RECV) SIGNAL(USART0_RX_vect) +#elif defined(SIG_UART_RECV) + SIGNAL(SIG_UART_RECV) +#endif { #if defined(UDR0) unsigned char c = UDR0; #elif defined(UDR) - unsigned char c = UDR; // atmega8, atmega32 + unsigned char c = UDR; #else #error UDR not defined #endif store_char(c, &rx_buffer); + serialEvent(); } -#elif defined(SIG_UART_RECV) - // this is for atmega8 - SIGNAL(SIG_UART_RECV) - { - #if defined(UDR0) - unsigned char c = UDR0; // atmega645 - #elif defined(UDR) - unsigned char c = UDR; // atmega8 - #endif - store_char(c, &rx_buffer); - } -#elif defined(USBCON) - #warning No interrupt handler for usart 0 - #warning Serial(0) is on USB interface -#else - #error No interrupt handler for usart 0 #endif -//#if defined(SIG_USART1_RECV) #if defined(USART1_RX_vect) - //SIGNAL(SIG_USART1_RECV) + void serialEvent1() __attribute__((weak)); + void serialEvent1() {} SIGNAL(USART1_RX_vect) { unsigned char c = UDR1; store_char(c, &rx_buffer1); + serialEvent1(); } #elif defined(SIG_USART1_RECV) #error SIG_USART1_RECV #endif #if defined(USART2_RX_vect) && defined(UDR2) + void serialEvent2() __attribute__((weak)); + void serialEvent2() {} SIGNAL(USART2_RX_vect) { unsigned char c = UDR2; store_char(c, &rx_buffer2); + serialEvent2(); } #elif defined(SIG_USART2_RECV) #error SIG_USART2_RECV #endif #if defined(USART3_RX_vect) && defined(UDR3) + void serialEvent3() __attribute__((weak)); + void serialEvent3() {} SIGNAL(USART3_RX_vect) { unsigned char c = UDR3; store_char(c, &rx_buffer3); + serialEvent3(); } #elif defined(SIG_USART3_RECV) #error SIG_USART3_RECV #endif +#if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect) + #error Don't know what the Data Register Empty vector is called for the first UART +#else +#if defined(UART0_UDRE_vect) +ISR(UART0_UDRE_vect) +#elif defined(UART_UDRE_vect) +ISR(UART_UDRE_vect) +#elif defined(USART0_UDRE_vect) +ISR(USART0_UDRE_vect) +#elif defined(USART_UDRE_vect) +ISR(USART_UDRE_vect) +#endif +{ + if (tx_buffer.head == tx_buffer.tail) { + // Buffer empty, so disable interrupts +#if defined(UCSR0B) + cbi(UCSR0B, UDRIE0); +#else + cbi(UCSRB, UDRIE); +#endif + } + else { + // There is more data in the output buffer. Send the next byte + unsigned char c = tx_buffer.buffer[tx_buffer.tail]; + tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE; + + #if defined(UDR0) + UDR0 = c; + #elif defined(UDR) + UDR = c; + #else + #error UDR not defined + #endif + } +} +#endif + +#ifdef USART1_UDRE_vect +ISR(USART1_UDRE_vect) +{ + if (tx_buffer1.head == tx_buffer1.tail) { + // Buffer empty, so disable interrupts + cbi(UCSR1B, UDRIE1); + } + else { + // There is more data in the output buffer. Send the next byte + unsigned char c = tx_buffer1.buffer[tx_buffer1.tail]; + tx_buffer1.tail = (tx_buffer1.tail + 1) % SERIAL_BUFFER_SIZE; + + UDR1 = c; + } +} +#endif + +#ifdef USART2_UDRE_vect +ISR(USART2_UDRE_vect) +{ + if (tx_buffer2.head == tx_buffer2.tail) { + // Buffer empty, so disable interrupts + cbi(UCSR2B, UDRIE2); + } + else { + // There is more data in the output buffer. Send the next byte + unsigned char c = tx_buffer2.buffer[tx_buffer2.tail]; + tx_buffer2.tail = (tx_buffer2.tail + 1) % SERIAL_BUFFER_SIZE; + + UDR2 = c; + } +} +#endif + +#ifdef USART3_UDRE_vect +ISR(USART3_UDRE_vect) +{ + if (tx_buffer3.head == tx_buffer3.tail) { + // Buffer empty, so disable interrupts + cbi(UCSR3B, UDRIE3); + } + else { + // There is more data in the output buffer. Send the next byte + unsigned char c = tx_buffer3.buffer[tx_buffer3.tail]; + tx_buffer3.tail = (tx_buffer3.tail + 1) % SERIAL_BUFFER_SIZE; + + UDR3 = c; + } +} +#endif + // Constructors //////////////////////////////////////////////////////////////// -HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, +HardwareSerial::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) { _rx_buffer = rx_buffer; + _tx_buffer = tx_buffer; _ubrrh = ubrrh; _ubrrl = ubrrl; _ucsra = ucsra; @@ -185,13 +259,13 @@ HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, _rxen = rxen; _txen = txen; _rxcie = rxcie; - _udre = udre; + _udrie = udrie; _u2x = u2x; } // Public Methods ////////////////////////////////////////////////////////////// -void HardwareSerial::begin(long baud) +void HardwareSerial::begin(unsigned long baud) { uint16_t baud_setting; bool use_u2x = true; @@ -204,6 +278,8 @@ void HardwareSerial::begin(long baud) use_u2x = false; } #endif + +try_again: if (use_u2x) { *_ucsra = 1 << _u2x; @@ -212,6 +288,12 @@ void HardwareSerial::begin(long baud) *_ucsra = 0; baud_setting = (F_CPU / 8 / baud - 1) / 2; } + + if ((baud_setting > 4095) && use_u2x) + { + use_u2x = false; + goto try_again; + } // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register) *_ubrrh = baud_setting >> 8; @@ -220,18 +302,27 @@ void HardwareSerial::begin(long baud) sbi(*_ucsrb, _rxen); sbi(*_ucsrb, _txen); sbi(*_ucsrb, _rxcie); + cbi(*_ucsrb, _udrie); } void HardwareSerial::end() { + // wait for transmission of outgoing data + while (_tx_buffer->head != _tx_buffer->tail) + ; + cbi(*_ucsrb, _rxen); cbi(*_ucsrb, _txen); cbi(*_ucsrb, _rxcie); + cbi(*_ucsrb, _udrie); + + // clear any received data + _rx_buffer->head = _rx_buffer->tail; } int HardwareSerial::available(void) { - return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE; + return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE; } int HardwareSerial::peek(void) @@ -250,39 +341,41 @@ int HardwareSerial::read(void) return -1; } else { unsigned char c = _rx_buffer->buffer[_rx_buffer->tail]; - _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % RX_BUFFER_SIZE; + _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE; return c; } } void HardwareSerial::flush() { - // don't reverse this or there may be problems if the RX interrupt - // occurs after reading the value of rx_buffer_head but before writing - // the value to rx_buffer_tail; the previous value of rx_buffer_head - // may be written to rx_buffer_tail, making it appear as if the buffer - // don't reverse this or there may be problems if the RX interrupt - // occurs after reading the value of rx_buffer_head but before writing - // the value to rx_buffer_tail; the previous value of rx_buffer_head - // may be written to rx_buffer_tail, making it appear as if the buffer - // were full, not empty. - _rx_buffer->head = _rx_buffer->tail; + while (_tx_buffer->head != _tx_buffer->tail) + ; } -void HardwareSerial::write(uint8_t c) +size_t HardwareSerial::write(uint8_t c) { - while (!((*_ucsra) & (1 << _udre))) + int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE; + + // If the output buffer is full, there's nothing for it other than to + // wait for the interrupt handler to empty it a bit + // ???: return 0 here instead? + while (i == _tx_buffer->tail) ; - - *_udr = c; + + _tx_buffer->buffer[_tx_buffer->head] = c; + _tx_buffer->head = i; + + sbi(*_ucsrb, _udrie); + + return 1; } // Preinstantiate Objects ////////////////////////////////////////////////////// #if defined(UBRRH) && defined(UBRRL) - HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X); + HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X); #elif defined(UBRR0H) && defined(UBRR0L) - HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0); + HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0); #elif defined(USBCON) #warning no serial port defined (port 0) #else @@ -290,13 +383,13 @@ void HardwareSerial::write(uint8_t c) #endif #if defined(UBRR1H) - HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1); + HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1); #endif #if defined(UBRR2H) - HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2); + HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2); #endif #if defined(UBRR3H) - HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3); + HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3); #endif #endif // whole file diff --git a/hardware/arduino/cores/arduino/HardwareSerial.h b/hardware/arduino/cores/arduino/HardwareSerial.h index 3efa775f8..1895f08f6 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,21 +41,21 @@ 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); - void begin(long); + 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 }; diff --git a/hardware/arduino/cores/arduino/IPAddress.cpp b/hardware/arduino/cores/arduino/IPAddress.cpp index 408d518a0..fe3deb77a 100644 --- a/hardware/arduino/cores/arduino/IPAddress.cpp +++ b/hardware/arduino/cores/arduino/IPAddress.cpp @@ -1,5 +1,5 @@ -#include +#include #include IPAddress::IPAddress() @@ -42,3 +42,15 @@ bool IPAddress::operator==(const uint8_t* addr) return memcmp(addr, _address, sizeof(_address)) == 0; } +size_t IPAddress::printTo(Print& p) const +{ + size_t n = 0; + for (int i =0; i < 3; i++) + { + n += p.print(_address[i], DEC); + n += p.print('.'); + } + n += p.print(_address[3], DEC); + return n; +} + diff --git a/hardware/arduino/cores/arduino/IPAddress.h b/hardware/arduino/cores/arduino/IPAddress.h index 487e420bd..2585aec0e 100644 --- a/hardware/arduino/cores/arduino/IPAddress.h +++ b/hardware/arduino/cores/arduino/IPAddress.h @@ -26,9 +26,11 @@ #ifndef IPAddress_h #define IPAddress_h +#include + // A class to make it easier to handle and pass around IP addresses -class IPAddress { +class IPAddress : public Printable { private: uint8_t _address[4]; // IPv4 address // Access the raw byte array containing the address. Because this returns a pointer @@ -58,6 +60,8 @@ public: IPAddress& operator=(const uint8_t *address); IPAddress& operator=(uint32_t address); + virtual size_t printTo(Print& p) const; + friend class EthernetClass; friend class UDP; friend class Client; diff --git a/hardware/arduino/cores/arduino/Print.cpp b/hardware/arduino/cores/arduino/Print.cpp index 4ee556dd8..8190d4fb4 100755 --- a/hardware/arduino/cores/arduino/Print.cpp +++ b/hardware/arduino/cores/arduino/Print.cpp @@ -23,173 +23,223 @@ #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 char *str) { - while (*str) - write(*str++); + size_t n = 0; + while (*str) { + n += write(*str++); + } + return n; } /* default implementation: may be overridden */ -void Print::write(const uint8_t *buffer, size_t size) +size_t Print::write(const uint8_t *buffer, size_t size) { - while (size--) - write(*buffer++); -} - -void Print::print(const String &s) -{ - for (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 (int 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 +253,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/Print.h b/hardware/arduino/cores/arduino/Print.h index b092ae51d..fce302e72 100755 --- a/hardware/arduino/cores/arduino/Print.h +++ b/hardware/arduino/cores/arduino/Print.h @@ -24,43 +24,55 @@ #include // for size_t #include "WString.h" +#include "Printable.h" #define DEC 10 #define HEX 16 #define OCT 8 #define BIN 2 -#define BYTE 0 class Print { private: - void printNumber(unsigned long, uint8_t); - void printFloat(double, uint8_t); + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printFloat(double, uint8_t); + protected: + void setWriteError(int err = 1) { write_error = err; } public: - virtual void write(uint8_t) = 0; - virtual void write(const char *str); - virtual void write(const uint8_t *buffer, size_t size); + Print() : write_error(0) {} + + int writeError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + virtual size_t write(const char *str); + virtual size_t write(const uint8_t *buffer, size_t size); - void print(const String &); - void print(const char[]); - void print(char, int = BYTE); - void print(unsigned char, int = BYTE); - void print(int, int = DEC); - void print(unsigned int, int = DEC); - void print(long, int = DEC); - void print(unsigned long, int = DEC); - void print(double, int = 2); + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); - void println(const String &s); - void println(const char[]); - void println(char, int = BYTE); - void println(unsigned char, int = BYTE); - void println(int, int = DEC); - void println(unsigned int, int = DEC); - void println(long, int = DEC); - void println(unsigned long, int = DEC); - void println(double, int = 2); - void println(void); + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); }; #endif diff --git a/libraries/Sprite/Sprite.h b/hardware/arduino/cores/arduino/Printable.h similarity index 52% rename from libraries/Sprite/Sprite.h rename to hardware/arduino/cores/arduino/Printable.h index bdcfdb82f..d03c9af62 100644 --- a/libraries/Sprite/Sprite.h +++ b/hardware/arduino/cores/arduino/Printable.h @@ -1,6 +1,6 @@ /* - Sprite.cpp - 2D sprite buffers library for Arduino & Wiring - Copyright (c) 2006 David A. Mellis. All right reserved. + Printable.h - Interface class that allows printing of complex types + Copyright (c) 2011 Adrian McEwen. 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 @@ -17,32 +17,24 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef Sprite_h -#define Sprite_h +#ifndef Printable_h +#define Printable_h -#include +#include -#include "binary.h" +class Print; -class Sprite +/** The Printable class provides a way for new classes to allow themselves to be printed. + By deriving from Printable and implementing the printTo method, it will then be possible + for users to print out instances of this class by passing them into the usual + Print::print and Print::println methods. +*/ + +class Printable { - private: - uint8_t _width; - uint8_t _height; - uint8_t _depth; - uint8_t _ppb; - uint8_t _bpr; - uint8_t _mask; - uint8_t *_buffer; - - void init(uint8_t width, uint8_t height); - public: - Sprite(uint8_t width, uint8_t height); - Sprite(uint8_t width, uint8_t height, uint8_t row, ...); - uint8_t width() const; - uint8_t height() const; - void write(uint8_t x, uint8_t y, uint8_t value); - uint8_t read(uint8_t x, uint8_t y) const; + public: + virtual size_t printTo(Print& p) const = 0; }; #endif + diff --git a/hardware/arduino/cores/arduino/Stream.cpp b/hardware/arduino/cores/arduino/Stream.cpp new file mode 100644 index 000000000..d267bf0cb --- /dev/null +++ b/hardware/arduino/cores/arduino/Stream.cpp @@ -0,0 +1,233 @@ +/* + Stream.cpp - adds parsing methods to Stream class + Copyright (c) 2008 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 + + Created July 2011 + parsing functions based on TextFinder library by Michael Margolis + */ + +#include "Arduino.h" +#include "Stream.h" + +#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait +#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field + +// private method to read stream with timeout +int Stream::timedRead() +{ + //Serial.println(_timeout); + this->_startMillis = millis(); + while(millis() - this->_startMillis < this->_timeout) + { + if (this->available() > 0) { + return this->read(); + } + } + return -1; // -1 indicates timeout +} + +// returns the next digit in the stream or -1 if timeout +// discards non-numeric characters +int Stream::getNextDigit() +{ + int c; + do{ + c = timedRead(); + if( c < 0) + return c; // timeout + } + while( c != '-' && (c < '0' || c > '9') ) ; + +return c; +} + +// Public Methods +////////////////////////////////////////////////////////////// + +void Stream::setTimeout( long timeout) // sets the maximum number of milliseconds to wait +{ + this->_timeout = timeout; +} + + // find returns true if the target string is found +bool Stream::find(char *target) +{ + return findUntil(target, NULL); +} + +// reads data from the stream until the target string of given length is found +// returns true if target string is found, false if timed out +bool Stream::find(char *target, size_t length) +{ + return findUntil(target, length, NULL, 0); +} + +// as find but search ends if the terminator string is found +bool Stream::findUntil(char *target, char *terminator) +{ + return findUntil(target, strlen(target), terminator, strlen(terminator)); +} + +// reads data from the stream until the target string of the given length is found +// search terminated if the terminator string is found +// returns true if target string is found, false if terminated or timed out +bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen) +{ + size_t index = 0; // maximum target string length is 64k bytes! + size_t termIndex = 0; + int c; + + if( *target == 0) + return true; // return true if target is a null string + while( (c = timedRead()) > 0){ + if( c == target[index]){ + //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); + if(++index >= targetLen){ // return true if all chars in the target match + return true; + } + } + else{ + index = 0; // reset index if any char does not match + } + if(termLen > 0 && c == terminator[termIndex]){ + if(++termIndex >= termLen) + return false; // return false if terminate string found before target string + } + else + termIndex = 0; + } + return false; +} + + +// returns the first valid (long) integer value from the current position. +// initial characters that are not digits (or the minus sign) are skipped +// function is terminated by the first character that is not a digit. +long Stream::parseInt() +{ + return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) +} + +// as above but a given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +long Stream::parseInt(char skipChar) +{ + boolean isNegative = false; + long value = 0; + int c; + + c = getNextDigit(); + // ignore non numeric leading characters + if(c < 0) + return 0; // zero returned if timeout + + do{ + if(c == skipChar) + ; // ignore this charactor + else if(c == '-') + isNegative = true; + else if(c >= '0' && c <= '9') // is c a digit? + value = value * 10 + c - '0'; + c = timedRead(); + } + while( (c >= '0' && c <= '9') || c == skipChar ); + + if(isNegative) + value = -value; + return value; +} + + +// as parseInt but returns a floating point value +float Stream::parseFloat() +{ + parseFloat(NO_SKIP_CHAR); +} + +// as above but the given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +float Stream::parseFloat(char skipChar){ + boolean isNegative = false; + boolean isFraction = false; + long value = 0; + float fValue; + char c; + float fraction = 1.0; + + c = getNextDigit(); + // ignore non numeric leading characters + if(c < 0) + return 0; // zero returned if timeout + + do{ + if(c == skipChar) + ; // ignore + else if(c == '-') + isNegative = true; + else if (c == '.') + isFraction = true; + else if(c >= '0' && c <= '9') { // is c a digit? + value = value * 10 + c - '0'; + if(isFraction) + fraction *= 0.1; + } + c = timedRead(); + } + while( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); + + if(isNegative) + value = -value; + if(isFraction) + return value * fraction; + else + return value; +} + +// read characters from stream into buffer +// terminates if length characters have been read, null is detected or timeout (see setTimeout) +// returns the number of characters placed in the buffer (0 means no valid data found) +int Stream::readBytes( char *buffer, size_t length) +{ + return readBytesUntil( 0, buffer, length); +} + + +// as readBytes with terminator character +// terminates if length characters have been read, timeout, or if the terminator character detected +// returns the number of characters placed in the buffer (0 means no valid data found) + +int Stream::readBytesUntil( char terminator, char *buffer, size_t length) +{ + int index = 0; + *buffer = 0; + while(index < length-1 ){ + int c = timedRead(); + if( c <= 0 ){ + return 0; // timeout returns 0 ! + } + else if( c == terminator){ + buffer[index] = 0; // terminate the string + return index; // data got successfully + } + else{ + buffer[index++] = (char)c; + } + } + buffer[index] = 0; + return index; // here if buffer is full before detecting the terminator +} + diff --git a/hardware/arduino/cores/arduino/Stream.h b/hardware/arduino/cores/arduino/Stream.h index 93d8275dc..1633f15d5 100644 --- a/hardware/arduino/cores/arduino/Stream.h +++ b/hardware/arduino/cores/arduino/Stream.h @@ -15,6 +15,8 @@ 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 + + parsing functions based on TextFinder library by Michael Margolis */ #ifndef Stream_h @@ -23,13 +25,69 @@ #include #include "Print.h" +// compatability macros for testing +/* +#define getInt() parseInt() +#define getInt(skipChar) parseInt(skipchar) +#define getFloat() parseFloat() +#define getFloat(skipChar) parseFloat(skipChar) +#define getString( pre_string, post_string, buffer, length) +readBytesBetween( pre_string, terminator, buffer, length) +*/ + class Stream : public Print { + private: + long _timeout; // number of milliseconds to wait for the next char before aborting timed read + long _startMillis; // used for timeout measurement + int timedRead(); // private method to read stream with timeout + int getNextDigit(); // returns the next numeric digit in the stream or -1 if timeout + public: virtual int available() = 0; virtual int read() = 0; virtual int peek() = 0; virtual void flush() = 0; + + Stream() {_timeout=1000;} + +// parsing methods + + void setTimeout(long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second + + bool find(char *target); // reads data from the stream until the target string is found + // returns true if target string is found, false if timed out (see setTimeout) + + bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found + // returns true if target string is found, false if timed out + + bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found + + bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found + + + long parseInt(); // returns the first valid (long) integer value from the current position. + // initial characters that are not digits (or the minus sign) are skipped + // integer is terminated by the first character that is not a digit. + + long parseInt(char skipChar); // as above but the given skipChar is ignored + // as above but the given skipChar is ignored + // this allows format characters (typically commas) in values to be ignored + + float parseFloat(); // float version of parseInt + + float parseFloat(char skipChar); // as above but the given skipChar is ignored + + int readBytes( char *buffer, size_t length); // read chars from stream into buffer + // terminates if length characters have been read or timeout (see setTimeout) + // returns the number of characters placed in the buffer (0 means no valid data found) + + int readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character + // terminates if length characters have been read, timeout, or if the terminator character detected + // returns the number of characters placed in the buffer (0 means no valid data found) + + // Arduino String functions to be added here + }; #endif diff --git a/hardware/arduino/cores/arduino/Tone.cpp b/hardware/arduino/cores/arduino/Tone.cpp index c3910e7a6..20eed3f48 100755 --- a/hardware/arduino/cores/arduino/Tone.cpp +++ b/hardware/arduino/cores/arduino/Tone.cpp @@ -33,7 +33,7 @@ Version Modified By Date Comments #include #include -#include "wiring.h" +#include "Arduino.h" #include "pins_arduino.h" #if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) diff --git a/hardware/arduino/cores/arduino/WConstants.h b/hardware/arduino/cores/arduino/WConstants.h deleted file mode 100644 index 3e19ac44a..000000000 --- a/hardware/arduino/cores/arduino/WConstants.h +++ /dev/null @@ -1 +0,0 @@ -#include "wiring.h" diff --git a/hardware/arduino/cores/arduino/WInterrupts.c b/hardware/arduino/cores/arduino/WInterrupts.c index 3b3e0c9ec..75c713b89 100755 --- a/hardware/arduino/cores/arduino/WInterrupts.c +++ b/hardware/arduino/cores/arduino/WInterrupts.c @@ -30,7 +30,6 @@ #include #include -#include "WConstants.h" #include "wiring_private.h" volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS]; diff --git a/hardware/arduino/cores/arduino/WProgram.h b/hardware/arduino/cores/arduino/WProgram.h deleted file mode 100755 index f73e760bb..000000000 --- a/hardware/arduino/cores/arduino/WProgram.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef WProgram_h -#define WProgram_h - -#include -#include -#include - -#include - -#include "wiring.h" - -#ifdef __cplusplus -#include "WCharacter.h" -#include "WString.h" -#include "HardwareSerial.h" - -uint16_t makeWord(uint16_t w); -uint16_t makeWord(byte h, byte l); - -#define word(...) makeWord(__VA_ARGS__) - -unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); - -void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); -void noTone(uint8_t _pin); - -// WMath prototypes -long random(long); -long random(long, long); -void randomSeed(unsigned int); -long map(long, long, long, long, long); - -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -const static uint8_t A0 = 54; -const static uint8_t A1 = 55; -const static uint8_t A2 = 56; -const static uint8_t A3 = 57; -const static uint8_t A4 = 58; -const static uint8_t A5 = 59; -const static uint8_t A6 = 60; -const static uint8_t A7 = 61; -const static uint8_t A8 = 62; -const static uint8_t A9 = 63; -const static uint8_t A10 = 64; -const static uint8_t A11 = 65; -const static uint8_t A12 = 66; -const static uint8_t A13 = 67; -const static uint8_t A14 = 68; -const static uint8_t A15 = 69; -#else -const static uint8_t A0 = 14; -const static uint8_t A1 = 15; -const static uint8_t A2 = 16; -const static uint8_t A3 = 17; -const static uint8_t A4 = 18; -const static uint8_t A5 = 19; -const static uint8_t A6 = 20; -const static uint8_t A7 = 21; -#endif - -#endif - -#endif \ No newline at end of file diff --git a/hardware/arduino/cores/arduino/WString.cpp b/hardware/arduino/cores/arduino/WString.cpp index db5a441dc..f90cef01e 100644 --- a/hardware/arduino/cores/arduino/WString.cpp +++ b/hardware/arduino/cores/arduino/WString.cpp @@ -1,6 +1,8 @@ /* WString.cpp - String library for Wiring & Arduino + ...mostly rewritten by Paul Stoffregen... Copyright (c) 2009-10 Hernando Barragan. All rights 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,427 +19,627 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include "WProgram.h" #include "WString.h" -String::String( const char *value ) +/*********************************************/ +/* Constructors */ +/*********************************************/ + +String::String(const char *cstr) { - if ( value == NULL ) - value = ""; - getBuffer( _length = strlen( value ) ); - if ( _buffer != NULL ) - strcpy( _buffer, value ); + init(); + if (cstr) copy(cstr, strlen(cstr)); } -String::String( const String &value ) +String::String(const String &value) { - getBuffer( _length = value._length ); - if ( _buffer != NULL ) - strcpy( _buffer, value._buffer ); + init(); + *this = value; } -String::String( const char value ) +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +String::String(String &&rval) { - _length = 1; - getBuffer(1); - if ( _buffer != NULL ) { - _buffer[0] = value; - _buffer[1] = 0; - } + init(); + move(rval); +} +String::String(StringSumHelper &&rval) +{ + init(); + move(rval); +} +#endif + +String::String(char c) +{ + init(); + char buf[2]; + buf[0] = c; + buf[1] = 0; + *this = buf; } -String::String( const unsigned char value ) +String::String(unsigned char value, unsigned char base) { - _length = 1; - getBuffer(1); - if ( _buffer != NULL) { - _buffer[0] = value; - _buffer[1] = 0; - } + init(); + char buf[9]; + utoa(value, buf, base); + *this = buf; } -String::String( const int value, const int base ) +String::String(int value, unsigned char base) { - char buf[33]; - itoa((signed long)value, buf, base); - getBuffer( _length = strlen(buf) ); - if ( _buffer != NULL ) - strcpy( _buffer, buf ); + init(); + char buf[18]; + itoa(value, buf, base); + *this = buf; } -String::String( const unsigned int value, const int base ) +String::String(unsigned int value, unsigned char base) { - char buf[33]; - ultoa((unsigned long)value, buf, base); - getBuffer( _length = strlen(buf) ); - if ( _buffer != NULL ) - strcpy( _buffer, buf ); + init(); + char buf[17]; + utoa(value, buf, base); + *this = buf; } -String::String( const long value, const int base ) +String::String(long value, unsigned char base) { - char buf[33]; - ltoa(value, buf, base); - getBuffer( _length = strlen(buf) ); - if ( _buffer != NULL ) - strcpy( _buffer, buf ); + init(); + char buf[34]; + ltoa(value, buf, base); + *this = buf; } -String::String( const unsigned long value, const int base ) +String::String(unsigned long value, unsigned char base) { - char buf[33]; - ultoa(value, buf, 10); - getBuffer( _length = strlen(buf) ); - if ( _buffer != NULL ) - strcpy( _buffer, buf ); + init(); + char buf[33]; + ultoa(value, buf, base); + *this = buf; } -char String::charAt( unsigned int loc ) const +String::~String() { - return operator[]( loc ); + free(buffer); } -void String::setCharAt( unsigned int loc, const char aChar ) +/*********************************************/ +/* Memory Management */ +/*********************************************/ + +inline void String::init(void) { - if(_buffer == NULL) return; - if(_length > loc) { - _buffer[loc] = aChar; - } + buffer = NULL; + capacity = 0; + len = 0; + flags = 0; } -int String::compareTo( const String &s2 ) const +void String::invalidate(void) { - return strcmp( _buffer, s2._buffer ); + if (buffer) free(buffer); + buffer = NULL; + capacity = len = 0; } -const String & String::concat( const String &s2 ) +unsigned char String::reserve(unsigned int size) { - return (*this) += s2; + if (buffer && capacity >= size) return 1; + if (changeBuffer(size)) { + if (len == 0) buffer[0] = 0; + return 1; + } + return 0; } -const String & String::operator=( const String &rhs ) +unsigned char String::changeBuffer(unsigned int maxStrLen) { - if ( this == &rhs ) - return *this; - - if ( rhs._length > _length ) - { - free(_buffer); - getBuffer( rhs._length ); - } - - if ( _buffer != NULL ) { - _length = rhs._length; - strcpy( _buffer, rhs._buffer ); - } - return *this; + char *newbuffer = (char *)realloc(buffer, maxStrLen + 1); + if (newbuffer) { + buffer = newbuffer; + capacity = maxStrLen; + return 1; + } + return 0; } -//const String & String::operator+=( const char aChar ) -//{ -// if ( _length == _capacity ) -// doubleBuffer(); -// -// _buffer[ _length++ ] = aChar; -// _buffer[ _length ] = '\0'; -// return *this; -//} +/*********************************************/ +/* Copy and Move */ +/*********************************************/ -const String & String::operator+=( const String &other ) +String & String::copy(const char *cstr, unsigned int length) { - _length += other._length; - if ( _length > _capacity ) - { - char *temp = (char *)realloc(_buffer, _length + 1); - if ( temp != NULL ) { - _buffer = temp; - _capacity = _length; - } else { - _length -= other._length; - return *this; - } - } - strcat( _buffer, other._buffer ); - return *this; + if (!reserve(length)) { + invalidate(); + return *this; + } + len = length; + strcpy(buffer, cstr); + return *this; } - -int String::operator==( const String &rhs ) const +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +void String::move(String &rhs) { - return ( _length == rhs._length && strcmp( _buffer, rhs._buffer ) == 0 ); + if (buffer) { + if (capacity >= rhs.len) { + strcpy(buffer, rhs.buffer); + len = rhs.len; + rhs.len = 0; + return; + } else { + free(buffer); + } + } + buffer = rhs.buffer; + capacity = rhs.capacity; + len = rhs.len; + rhs.buffer = NULL; + rhs.capacity = 0; + rhs.len = 0; +} +#endif + +String & String::operator = (const String &rhs) +{ + if (this == &rhs) return *this; + + if (rhs.buffer) copy(rhs.buffer, rhs.len); + else invalidate(); + + return *this; } -int String::operator!=( const String &rhs ) const +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +String & String::operator = (String &&rval) { - return ( _length != rhs.length() || strcmp( _buffer, rhs._buffer ) != 0 ); + if (this != &rval) move(rval); + return *this; } -int String::operator<( const String &rhs ) const +String & String::operator = (StringSumHelper &&rval) { - return strcmp( _buffer, rhs._buffer ) < 0; + if (this != &rval) move(rval); + return *this; +} +#endif + +String & String::operator = (const char *cstr) +{ + if (cstr) copy(cstr, strlen(cstr)); + else invalidate(); + + return *this; } -int String::operator>( const String &rhs ) const +/*********************************************/ +/* concat */ +/*********************************************/ + +unsigned char String::concat(const String &s) { - return strcmp( _buffer, rhs._buffer ) > 0; + return concat(s.buffer, s.len); } -int String::operator<=( const String &rhs ) const +unsigned char String::concat(const char *cstr, unsigned int length) { - return strcmp( _buffer, rhs._buffer ) <= 0; + unsigned int newlen = len + length; + if (!cstr) return 0; + if (length == 0) return 1; + if (!reserve(newlen)) return 0; + strcpy(buffer + len, cstr); + len = newlen; + return 1; } -int String::operator>=( const String & rhs ) const +unsigned char String::concat(const char *cstr) { - return strcmp( _buffer, rhs._buffer ) >= 0; + if (!cstr) return 0; + return concat(cstr, strlen(cstr)); } -char & String::operator[]( unsigned int index ) +unsigned char String::concat(char c) { - static char dummy_writable_char; - if (index >= _length || !_buffer) { - dummy_writable_char = 0; - return dummy_writable_char; - } - return _buffer[ index ]; + char buf[2]; + buf[0] = c; + buf[1] = 0; + return concat(buf, 1); +} + +unsigned char String::concat(unsigned char num) +{ + char buf[4]; + itoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(int num) +{ + char buf[7]; + itoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(unsigned int num) +{ + char buf[6]; + utoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(long num) +{ + char buf[12]; + ltoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(unsigned long num) +{ + char buf[11]; + ultoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +/*********************************************/ +/* Concatenate */ +/*********************************************/ + +StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(rhs.buffer, rhs.len)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr) +{ + StringSumHelper &a = const_cast(lhs); + if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, char c) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(c)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, int num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, long num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +/*********************************************/ +/* Comparison */ +/*********************************************/ + +int String::compareTo(const String &s) const +{ + if (!buffer || !s.buffer) { + if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer; + if (buffer && len > 0) return *(unsigned char *)buffer; + return 0; + } + return strcmp(buffer, s.buffer); +} + +unsigned char String::equals(const String &s2) const +{ + return (len == s2.len && compareTo(s2) == 0); +} + +unsigned char String::equals(const char *cstr) const +{ + if (len == 0) return (cstr == NULL || *cstr == 0); + if (cstr == NULL) return buffer[0] == 0; + return strcmp(buffer, cstr) == 0; +} + +unsigned char String::operator<(const String &rhs) const +{ + return compareTo(rhs) < 0; +} + +unsigned char String::operator>(const String &rhs) const +{ + return compareTo(rhs) > 0; +} + +unsigned char String::operator<=(const String &rhs) const +{ + return compareTo(rhs) <= 0; +} + +unsigned char String::operator>=(const String &rhs) const +{ + return compareTo(rhs) >= 0; +} + +unsigned char String::equalsIgnoreCase( const String &s2 ) const +{ + if (this == &s2) return 1; + if (len != s2.len) return 0; + if (len == 0) return 1; + const char *p1 = buffer; + const char *p2 = s2.buffer; + while (*p1) { + if (tolower(*p1++) != tolower(*p2++)) return 0; + } + return 1; +} + +unsigned char String::startsWith( const String &s2 ) const +{ + if (len < s2.len) return 0; + return startsWith(s2, 0); +} + +unsigned char String::startsWith( const String &s2, unsigned int offset ) const +{ + if (offset > len - s2.len || !buffer || !s2.buffer) return 0; + return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0; +} + +unsigned char String::endsWith( const String &s2 ) const +{ + if ( len < s2.len || !buffer || !s2.buffer) return 0; + return strcmp(&buffer[len - s2.len], s2.buffer) == 0; +} + +/*********************************************/ +/* Character Access */ +/*********************************************/ + +char String::charAt(unsigned int loc) const +{ + return operator[](loc); +} + +void String::setCharAt(unsigned int loc, char c) +{ + if (loc < len) buffer[loc] = c; +} + +char & String::operator[](unsigned int index) +{ + static char dummy_writable_char; + if (index >= len || !buffer) { + dummy_writable_char = 0; + return dummy_writable_char; + } + return buffer[index]; } char String::operator[]( unsigned int index ) const { - // need to check for valid index, to do later - return _buffer[ index ]; + if (index >= len || !buffer) return 0; + return buffer[index]; } -boolean String::endsWith( const String &s2 ) const +void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const { - if ( _length < s2._length ) - return 0; - - return strcmp( &_buffer[ _length - s2._length], s2._buffer ) == 0; + if (!bufsize || !buf) return; + if (index >= len) { + buf[0] = 0; + return; + } + unsigned int n = bufsize - 1; + if (n > len - index) n = len - index; + strncpy((char *)buf, buffer + index, n); + buf[n] = 0; } -boolean String::equals( const String &s2 ) const +/*********************************************/ +/* Search */ +/*********************************************/ + +int String::indexOf(char c) const { - return ( _length == s2._length && strcmp( _buffer,s2._buffer ) == 0 ); -} - -boolean String::equalsIgnoreCase( const String &s2 ) const -{ - if ( this == &s2 ) - return true; //1; - else if ( _length != s2._length ) - return false; //0; - - return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0; -} - -String String::replace( char findChar, char replaceChar ) -{ - if ( _buffer == NULL ) return *this; - String theReturn = _buffer; - char* temp = theReturn._buffer; - while( (temp = strchr( temp, findChar )) != 0 ) - *temp = replaceChar; - - return theReturn; -} - -String String::replace( const String& match, const String& replace ) -{ - if ( _buffer == NULL ) return *this; - String temp = _buffer, newString; - - int loc; - while ( (loc = temp.indexOf( match )) != -1 ) - { - newString += temp.substring( 0, loc ); - newString += replace; - temp = temp.substring( loc + match._length ); - } - newString += temp; - return newString; -} - -int String::indexOf( char temp ) const -{ - return indexOf( temp, 0 ); + return indexOf(c, 0); } int String::indexOf( char ch, unsigned int fromIndex ) const { - if ( fromIndex >= _length ) - return -1; - - const char* temp = strchr( &_buffer[fromIndex], ch ); - if ( temp == NULL ) - return -1; - - return temp - _buffer; + if (fromIndex >= len) return -1; + const char* temp = strchr(buffer + fromIndex, ch); + if (temp == NULL) return -1; + return temp - buffer; } -int String::indexOf( const String &s2 ) const +int String::indexOf(const String &s2) const { - return indexOf( s2, 0 ); + return indexOf(s2, 0); } -int String::indexOf( const String &s2, unsigned int fromIndex ) const +int String::indexOf(const String &s2, unsigned int fromIndex) const { - if ( fromIndex >= _length ) - return -1; - - const char *theFind = strstr( &_buffer[ fromIndex ], s2._buffer ); - - if ( theFind == NULL ) - return -1; - - return theFind - _buffer; // pointer subtraction + if (fromIndex >= len) return -1; + const char *found = strstr(buffer + fromIndex, s2.buffer); + if (found == NULL) return -1; + return found - buffer; } int String::lastIndexOf( char theChar ) const { - return lastIndexOf( theChar, _length - 1 ); + return lastIndexOf(theChar, len - 1); } -int String::lastIndexOf( char ch, unsigned int fromIndex ) const +int String::lastIndexOf(char ch, int fromIndex) const { - if ( fromIndex >= _length ) - return -1; - - char tempchar = _buffer[fromIndex + 1]; - _buffer[fromIndex + 1] = '\0'; - char* temp = strrchr( _buffer, ch ); - _buffer[fromIndex + 1] = tempchar; - - if ( temp == NULL ) - return -1; - - return temp - _buffer; + if (fromIndex >= len || fromIndex < 0) return -1; + char tempchar = buffer[fromIndex + 1]; + buffer[fromIndex + 1] = '\0'; + char* temp = strrchr( buffer, ch ); + buffer[fromIndex + 1] = tempchar; + if (temp == NULL) return -1; + return temp - buffer; } -int String::lastIndexOf( const String &s2 ) const +int String::lastIndexOf(const String &s2) const { - return lastIndexOf( s2, _length - s2._length ); + return lastIndexOf(s2, len - s2.len); } -int String::lastIndexOf( const String &s2, unsigned int fromIndex ) const +int String::lastIndexOf(const String &s2, int fromIndex) const { - // check for empty strings - if ( s2._length == 0 || s2._length - 1 > fromIndex || fromIndex >= _length ) - return -1; - - // matching first character - char temp = s2[ 0 ]; - - for ( int i = fromIndex; i >= 0; i-- ) - { - if ( _buffer[ i ] == temp && (*this).substring( i, i + s2._length ).equals( s2 ) ) - return i; - } - return -1; -} - -boolean String::startsWith( const String &s2 ) const -{ - if ( _length < s2._length ) - return 0; - - return startsWith( s2, 0 ); -} - -boolean String::startsWith( const String &s2, unsigned int offset ) const -{ - if ( offset > _length - s2._length ) - return 0; - - return strncmp( &_buffer[offset], s2._buffer, s2._length ) == 0; + if (s2.len == 0 || len == 0 || s2.len > len || fromIndex < 0) return -1; + if (fromIndex >= len) fromIndex = len - 1; + int found = -1; + for (char *p = buffer; p <= buffer + fromIndex; p++) { + p = strstr(p, s2.buffer); + if (!p) break; + if (p - buffer <= fromIndex) found = p - buffer; + } + return found; } String String::substring( unsigned int left ) const { - return substring( left, _length ); + return substring(left, len); } -String String::substring( unsigned int left, unsigned int right ) const +String String::substring(unsigned int left, unsigned int right) const { - if ( left > right ) - { - int temp = right; - right = left; - left = temp; - } - - if ( right > _length ) - { - right = _length; - } - - char temp = _buffer[ right ]; // save the replaced character - _buffer[ right ] = '\0'; - String outPut = ( _buffer + left ); // pointer arithmetic - _buffer[ right ] = temp; //restore character - return outPut; + if (left > right) { + unsigned int temp = right; + right = left; + left = temp; + } + String out; + if (left > len) return out; + if (right > len) right = len; + char temp = buffer[right]; // save the replaced character + buffer[right] = '\0'; + out = buffer + left; // pointer arithmetic + buffer[right] = temp; //restore character + return out; } -String String::toLowerCase() const +/*********************************************/ +/* Modification */ +/*********************************************/ + +void String::replace(char find, char replace) { - String temp = _buffer; - - for ( unsigned int i = 0; i < _length; i++ ) - temp._buffer[ i ] = (char)tolower( temp._buffer[ i ] ); - return temp; + if (!buffer) return; + for (char *p = buffer; *p; p++) { + if (*p == find) *p = replace; + } } -String String::toUpperCase() const +void String::replace(const String& find, const String& replace) { - String temp = _buffer; - - for ( unsigned int i = 0; i < _length; i++ ) - temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] ); - return temp; + if (len == 0 || find.len == 0) return; + int diff = replace.len - find.len; + char *readFrom = buffer; + char *foundAt; + if (diff == 0) { + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + memcpy(foundAt, replace.buffer, replace.len); + readFrom = foundAt + replace.len; + } + } else if (diff < 0) { + char *writeTo = buffer; + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + unsigned int n = foundAt - readFrom; + memcpy(writeTo, readFrom, n); + writeTo += n; + memcpy(writeTo, replace.buffer, replace.len); + writeTo += replace.len; + readFrom = foundAt + find.len; + len += diff; + } + strcpy(writeTo, readFrom); + } else { + unsigned int size = len; // compute size needed for result + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + readFrom = foundAt + find.len; + size += diff; + } + if (size == len) return; + if (size > capacity && !changeBuffer(size)) return; // XXX: tell user! + int index = len - 1; + while ((index = lastIndexOf(find, index)) >= 0) { + readFrom = buffer + index + find.len; + memmove(readFrom + diff, readFrom, len - (readFrom - buffer)); + len += diff; + buffer[len] = 0; + memcpy(buffer + index, replace.buffer, replace.len); + index--; + } + } } -String String::trim() const +void String::toLowerCase(void) { - if ( _buffer == NULL ) return *this; - String temp = _buffer; - unsigned int i,j; - - for ( i = 0; i < _length; i++ ) - { - if ( !isspace(_buffer[i]) ) - break; - } - - for ( j = temp._length - 1; j > i; j-- ) - { - if ( !isspace(_buffer[j]) ) - break; - } - - return temp.substring( i, j + 1); + if (!buffer) return; + for (char *p = buffer; *p; p++) { + *p = tolower(*p); + } } -void String::getBytes(unsigned char *buf, unsigned int bufsize) +void String::toUpperCase(void) { - if (!bufsize || !buf) return; - unsigned int len = bufsize - 1; - if (len > _length) len = _length; - strncpy((char *)buf, _buffer, len); - buf[len] = 0; + if (!buffer) return; + for (char *p = buffer; *p; p++) { + *p = toupper(*p); + } } -void String::toCharArray(char *buf, unsigned int bufsize) +void String::trim(void) { - if (!bufsize || !buf) return; - unsigned int len = bufsize - 1; - if (len > _length) len = _length; - strncpy(buf, _buffer, len); - buf[len] = 0; + if (!buffer || len == 0) return; + char *begin = buffer; + while (isspace(*begin)) begin++; + char *end = buffer + len - 1; + while (isspace(*end) && end >= begin) end--; + len = end + 1 - begin; + if (begin > buffer) memcpy(buffer, begin, len); + buffer[len] = 0; +} + +/*********************************************/ +/* Parsing / Conversion */ +/*********************************************/ + +long String::toInt(void) const +{ + if (buffer) return atol(buffer); + return 0; } -long String::toInt() { - return atol(_buffer); -} diff --git a/hardware/arduino/cores/arduino/WString.h b/hardware/arduino/cores/arduino/WString.h index cadddb947..a601aca93 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; - 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, int fromIndex ) const; + int lastIndexOf( const String &str ) const; + int lastIndexOf( const String &str, 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/hardware/arduino/cores/arduino/main.cpp b/hardware/arduino/cores/arduino/main.cpp index cc6e81d90..3c46f1e7a 100755 --- a/hardware/arduino/cores/arduino/main.cpp +++ b/hardware/arduino/cores/arduino/main.cpp @@ -1,4 +1,5 @@ -#include +#define ARDUINO_MAIN +#include int main(void) { diff --git a/hardware/arduino/cores/arduino/new.cpp b/hardware/arduino/cores/arduino/new.cpp new file mode 100644 index 000000000..0f6d4220e --- /dev/null +++ b/hardware/arduino/cores/arduino/new.cpp @@ -0,0 +1,18 @@ +#include + +void * operator new(size_t size) +{ + return malloc(size); +} + +void operator delete(void * ptr) +{ + free(ptr); +} + +int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);}; +void __cxa_guard_release (__guard *g) {*(char *)g = 1;}; +void __cxa_guard_abort (__guard *) {}; + +void __cxa_pure_virtual(void) {}; + diff --git a/hardware/arduino/cores/arduino/new.h b/hardware/arduino/cores/arduino/new.h new file mode 100644 index 000000000..cd940ce8b --- /dev/null +++ b/hardware/arduino/cores/arduino/new.h @@ -0,0 +1,22 @@ +/* Header to define new/delete operators as they aren't provided by avr-gcc by default + Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453 + */ + +#ifndef NEW_H +#define NEW_H + +#include + +void * operator new(size_t size); +void operator delete(void * ptr); + +__extension__ typedef int __guard __attribute__((mode (__DI__))); + +extern "C" int __cxa_guard_acquire(__guard *); +extern "C" void __cxa_guard_release (__guard *); +extern "C" void __cxa_guard_abort (__guard *); + +extern "C" void __cxa_pure_virtual(void); + +#endif + diff --git a/hardware/arduino/cores/arduino/pins_arduino.h b/hardware/arduino/cores/arduino/pins_arduino.h deleted file mode 100644 index bc931c597..000000000 --- a/hardware/arduino/cores/arduino/pins_arduino.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - pins_arduino.h - Pin definition functions for Arduino - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2007 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ -*/ - -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include - -#define NOT_A_PIN 0 -#define NOT_A_PORT 0 - -#define NOT_ON_TIMER 0 -#define TIMER0A 1 -#define TIMER0B 2 -#define TIMER1A 3 -#define TIMER1B 4 -#define TIMER2 5 -#define TIMER2A 6 -#define TIMER2B 7 - -#define TIMER3A 8 -#define TIMER3B 9 -#define TIMER3C 10 -#define TIMER4A 11 -#define TIMER4B 12 -#define TIMER4C 13 -#define TIMER5A 14 -#define TIMER5B 15 -#define TIMER5C 16 - -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -const static uint8_t SS = 53; -const static uint8_t MOSI = 51; -const static uint8_t MISO = 50; -const static uint8_t SCK = 52; -#else -const static uint8_t SS = 10; -const static uint8_t MOSI = 11; -const static uint8_t MISO = 12; -const static uint8_t SCK = 13; -#endif - -// On the ATmega1280, the addresses of some of the port registers are -// greater than 255, so we can't store them in uint8_t's. -extern const uint16_t PROGMEM port_to_mode_PGM[]; -extern const uint16_t PROGMEM port_to_input_PGM[]; -extern const uint16_t PROGMEM port_to_output_PGM[]; - -extern const uint8_t PROGMEM digital_pin_to_port_PGM[]; -// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[]; -extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[]; -extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; - -// Get the bit location within the hardware port of the given virtual pin. -// This comes from the pins_*.c file for the active board configuration. -// -// These perform slightly better as macros compared to inline functions -// -#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) ) -#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) ) -#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) ) -#define analogInPinToBit(P) (P) -#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) ) -#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) ) -#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) ) - -#endif diff --git a/hardware/arduino/cores/arduino/wiring.c b/hardware/arduino/cores/arduino/wiring.c index b90d07e59..ce4cad63c 100755 --- a/hardware/arduino/cores/arduino/wiring.c +++ b/hardware/arduino/cores/arduino/wiring.c @@ -212,10 +212,10 @@ void init() // note, however, that fast pwm mode can achieve a frequency of up // 8 MHz (with a 16 MHz clock) at 50% duty cycle +#if defined(TCCR1B) && defined(CS11) && defined(CS10) TCCR1B = 0; // set timer 1 prescale factor to 64 -#if defined(TCCR1B) && defined(CS11) && defined(CS10) sbi(TCCR1B, CS11); sbi(TCCR1B, CS10); #elif defined(TCCR1) && defined(CS11) && defined(CS10) diff --git a/hardware/arduino/cores/arduino/wiring.h b/hardware/arduino/cores/arduino/wiring.h deleted file mode 100755 index e29959b86..000000000 --- a/hardware/arduino/cores/arduino/wiring.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - wiring.h - Partial implementation of the Wiring API for the ATmega8. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id$ -*/ - -#ifndef Wiring_h -#define Wiring_h - -#include -#include -#include "binary.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -#define HIGH 0x1 -#define LOW 0x0 - -#define INPUT 0x0 -#define OUTPUT 0x1 - -#define true 0x1 -#define false 0x0 - -#define PI 3.1415926535897932384626433832795 -#define HALF_PI 1.5707963267948966192313216916398 -#define TWO_PI 6.283185307179586476925286766559 -#define DEG_TO_RAD 0.017453292519943295769236907684886 -#define RAD_TO_DEG 57.295779513082320876798154814105 - -#define SERIAL 0x0 -#define DISPLAY 0x1 - -#define LSBFIRST 0 -#define MSBFIRST 1 - -#define CHANGE 1 -#define FALLING 2 -#define RISING 3 - -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define INTERNAL1V1 2 -#define INTERNAL2V56 3 -#else -#define INTERNAL 3 -#endif -#define DEFAULT 1 -#define EXTERNAL 0 - -// undefine stdlib's abs if encountered -#ifdef abs -#undef abs -#endif - -#define min(a,b) ((a)<(b)?(a):(b)) -#define max(a,b) ((a)>(b)?(a):(b)) -#define abs(x) ((x)>0?(x):-(x)) -#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) -#define radians(deg) ((deg)*DEG_TO_RAD) -#define degrees(rad) ((rad)*RAD_TO_DEG) -#define sq(x) ((x)*(x)) - -#define interrupts() sei() -#define noInterrupts() cli() - -#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) -#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) ) -#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L ) - -#define lowByte(w) ((uint8_t) ((w) & 0xff)) -#define highByte(w) ((uint8_t) ((w) >> 8)) - -#define bitRead(value, bit) (((value) >> (bit)) & 0x01) -#define bitSet(value, bit) ((value) |= (1UL << (bit))) -#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) -#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) - - -typedef unsigned int word; - -#define bit(b) (1UL << (b)) - -typedef uint8_t boolean; -typedef uint8_t byte; - -void init(void); - -void pinMode(uint8_t, uint8_t); -void digitalWrite(uint8_t, uint8_t); -int digitalRead(uint8_t); -int analogRead(uint8_t); -void analogReference(uint8_t mode); -void analogWrite(uint8_t, int); - -unsigned long millis(void); -unsigned long micros(void); -void delay(unsigned long); -void delayMicroseconds(unsigned int us); -unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); - -void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); -uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); - -void attachInterrupt(uint8_t, void (*)(void), int mode); -void detachInterrupt(uint8_t); - -void setup(void); -void loop(void); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif diff --git a/hardware/arduino/cores/arduino/wiring_digital.c b/hardware/arduino/cores/arduino/wiring_digital.c index 0949da42d..dd1b94979 100755 --- a/hardware/arduino/cores/arduino/wiring_digital.c +++ b/hardware/arduino/cores/arduino/wiring_digital.c @@ -136,17 +136,16 @@ void digitalWrite(uint8_t pin, uint8_t val) out = portOutputRegister(port); + uint8_t oldSREG = SREG; + cli(); + if (val == LOW) { - uint8_t oldSREG = SREG; - cli(); *out &= ~bit; - SREG = oldSREG; } else { - uint8_t oldSREG = SREG; - cli(); *out |= bit; - SREG = oldSREG; } + + SREG = oldSREG; } int digitalRead(uint8_t pin) diff --git a/hardware/arduino/cores/arduino/wiring_private.h b/hardware/arduino/cores/arduino/wiring_private.h index 11f6f00f2..74c0d06a2 100755 --- a/hardware/arduino/cores/arduino/wiring_private.h +++ b/hardware/arduino/cores/arduino/wiring_private.h @@ -31,7 +31,7 @@ #include #include -#include "wiring.h" +#include "Arduino.h" #ifdef __cplusplus extern "C"{ diff --git a/hardware/arduino/variants/eightanaloginputs/pins_arduino.h b/hardware/arduino/variants/eightanaloginputs/pins_arduino.h new file mode 100644 index 000000000..52b37efc4 --- /dev/null +++ b/hardware/arduino/variants/eightanaloginputs/pins_arduino.h @@ -0,0 +1,27 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +#include "../standard/pins_arduino.h" +#undef NUM_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 8 diff --git a/hardware/arduino/cores/arduino/pins_arduino.c b/hardware/arduino/variants/mega/pins_arduino.h old mode 100755 new mode 100644 similarity index 71% rename from hardware/arduino/cores/arduino/pins_arduino.c rename to hardware/arduino/variants/mega/pins_arduino.h index 0c816e94d..237173adc --- a/hardware/arduino/cores/arduino/pins_arduino.c +++ b/hardware/arduino/variants/mega/pins_arduino.h @@ -1,8 +1,8 @@ /* - pins_arduino.c - pin definitions for the Arduino board - Part of Arduino / Wiring Lite + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ - Copyright (c) 2005 David A. Mellis + Copyright (c) 2007 David A. Mellis This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -19,112 +19,118 @@ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - $Id$ + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ */ -#include -#include "wiring_private.h" -#include "pins_arduino.h" +#ifndef Pins_Arduino_h +#define Pins_Arduino_h -// On the Arduino board, digital pins are also used -// for the analog output (software PWM). Analog input -// pins are a separate set. +#include -// ATMEL ATMEGA8 & 168 / ARDUINO -// -// +-\/-+ -// PC6 1| |28 PC5 (AI 5) -// (D 0) PD0 2| |27 PC4 (AI 4) -// (D 1) PD1 3| |26 PC3 (AI 3) -// (D 2) PD2 4| |25 PC2 (AI 2) -// PWM+ (D 3) PD3 5| |24 PC1 (AI 1) -// (D 4) PD4 6| |23 PC0 (AI 0) -// VCC 7| |22 GND -// GND 8| |21 AREF -// PB6 9| |20 AVCC -// PB7 10| |19 PB5 (D 13) -// PWM+ (D 5) PD5 11| |18 PB4 (D 12) -// PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM -// (D 7) PD7 13| |16 PB2 (D 10) PWM -// (D 8) PB0 14| |15 PB1 (D 9) PWM -// +----+ -// -// (PWM+ indicates the additional PWM pins on the ATmega168.) +#define NUM_DIGITAL_PINS 70 +#define NUM_ANALOG_INPUTS 16 +#define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1) +#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46)) -// ATMEL ATMEGA1280 / ARDUINO -// -// 0-7 PE0-PE7 works -// 8-13 PB0-PB5 works -// 14-21 PA0-PA7 works -// 22-29 PH0-PH7 works -// 30-35 PG5-PG0 works -// 36-43 PC7-PC0 works -// 44-51 PJ7-PJ0 works -// 52-59 PL7-PL0 works -// 60-67 PD7-PD0 works -// A0-A7 PF0-PF7 -// A8-A15 PK0-PK7 +const static uint8_t SS = 53; +const static uint8_t MOSI = 51; +const static uint8_t MISO = 50; +const static uint8_t SCK = 52; -#define PA 1 -#define PB 2 -#define PC 3 -#define PD 4 -#define PE 5 -#define PF 6 -#define PG 7 -#define PH 8 -#define PJ 10 -#define PK 11 -#define PL 12 +const static uint8_t SDA = 20; +const static uint8_t SCL = 21; +const static uint8_t LED = 13; +const static uint8_t A0 = 54; +const static uint8_t A1 = 55; +const static uint8_t A2 = 56; +const static uint8_t A3 = 57; +const static uint8_t A4 = 58; +const static uint8_t A5 = 59; +const static uint8_t A6 = 60; +const static uint8_t A7 = 61; +const static uint8_t A8 = 62; +const static uint8_t A9 = 63; +const static uint8_t A10 = 64; +const static uint8_t A11 = 65; +const static uint8_t A12 = 66; +const static uint8_t A13 = 67; +const static uint8_t A14 = 68; +const static uint8_t A15 = 69; + +// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins) +// Only pins available for RECEIVE (TRANSMIT can be on any pin): +// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me) +// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 + +#define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \ + (((p) >= 50) && ((p) <= 53)) || \ + (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) ) + +#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \ + ( (((p) >= 62) && ((p) <= 69)) ? 2 : \ + 0 ) ) + +#define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \ + ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \ + ((uint8_t *)0) ) ) + +#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \ + ( ((p) == 50) ? 3 : \ + ( ((p) == 51) ? 2 : \ + ( ((p) == 52) ? 1 : \ + ( ((p) == 53) ? 0 : \ + ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \ + 0 ) ) ) ) ) ) + +#ifdef ARDUINO_MAIN -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) const uint16_t PROGMEM port_to_mode_PGM[] = { NOT_A_PORT, - &DDRA, - &DDRB, - &DDRC, - &DDRD, - &DDRE, - &DDRF, - &DDRG, - &DDRH, + (uint16_t) &DDRA, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, + (uint16_t) &DDRE, + (uint16_t) &DDRF, + (uint16_t) &DDRG, + (uint16_t) &DDRH, NOT_A_PORT, - &DDRJ, - &DDRK, - &DDRL, + (uint16_t) &DDRJ, + (uint16_t) &DDRK, + (uint16_t) &DDRL, }; const uint16_t PROGMEM port_to_output_PGM[] = { NOT_A_PORT, - &PORTA, - &PORTB, - &PORTC, - &PORTD, - &PORTE, - &PORTF, - &PORTG, - &PORTH, + (uint16_t) &PORTA, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, + (uint16_t) &PORTE, + (uint16_t) &PORTF, + (uint16_t) &PORTG, + (uint16_t) &PORTH, NOT_A_PORT, - &PORTJ, - &PORTK, - &PORTL, + (uint16_t) &PORTJ, + (uint16_t) &PORTK, + (uint16_t) &PORTL, }; const uint16_t PROGMEM port_to_input_PGM[] = { NOT_A_PIN, - &PINA, - &PINB, - &PINC, - &PIND, - &PINE, - &PINF, - &PING, - &PINH, + (uint16_t) &PINA, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &PIND, + (uint16_t) &PINE, + (uint16_t) &PINF, + (uint16_t) &PING, + (uint16_t) &PINH, NOT_A_PIN, - &PINJ, - &PINK, - &PINL, + (uint16_t) &PINJ, + (uint16_t) &PINK, + (uint16_t) &PINL, }; const uint8_t PROGMEM digital_pin_to_port_PGM[] = { @@ -351,115 +357,7 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { NOT_ON_TIMER , // PK 6 ** 68 ** A14 NOT_ON_TIMER , // PK 7 ** 69 ** A15 }; -#else -// these arrays map port names (e.g. port B) to the -// appropriate addresses for various functions (e.g. reading -// and writing) -const uint16_t PROGMEM port_to_mode_PGM[] = { - NOT_A_PORT, - NOT_A_PORT, - &DDRB, - &DDRC, - &DDRD, -}; -const uint16_t PROGMEM port_to_output_PGM[] = { - NOT_A_PORT, - NOT_A_PORT, - &PORTB, - &PORTC, - &PORTD, -}; - -const uint16_t PROGMEM port_to_input_PGM[] = { - NOT_A_PORT, - NOT_A_PORT, - &PINB, - &PINC, - &PIND, -}; - -const uint8_t PROGMEM digital_pin_to_port_PGM[] = { - PD, /* 0 */ - PD, - PD, - PD, - PD, - PD, - PD, - PD, - PB, /* 8 */ - PB, - PB, - PB, - PB, - PB, - PC, /* 14 */ - PC, - PC, - PC, - PC, - PC, -}; - -const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { - _BV(0), /* 0, port D */ - _BV(1), - _BV(2), - _BV(3), - _BV(4), - _BV(5), - _BV(6), - _BV(7), - _BV(0), /* 8, port B */ - _BV(1), - _BV(2), - _BV(3), - _BV(4), - _BV(5), - _BV(0), /* 14, port C */ - _BV(1), - _BV(2), - _BV(3), - _BV(4), - _BV(5), -}; - -const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { - NOT_ON_TIMER, /* 0 - port D */ - NOT_ON_TIMER, - NOT_ON_TIMER, - // on the ATmega168, digital pin 3 has hardware pwm -#if defined(__AVR_ATmega8__) - NOT_ON_TIMER, -#else - TIMER2B, -#endif - NOT_ON_TIMER, - // on the ATmega168, digital pins 5 and 6 have hardware pwm -#if defined(__AVR_ATmega8__) - NOT_ON_TIMER, - NOT_ON_TIMER, -#else - TIMER0B, - TIMER0A, -#endif - NOT_ON_TIMER, - NOT_ON_TIMER, /* 8 - port B */ - TIMER1A, - TIMER1B, -#if defined(__AVR_ATmega8__) - TIMER2, -#else - TIMER2A, -#endif - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, /* 14 - port C */ - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, -}; #endif + +#endif \ No newline at end of file diff --git a/hardware/arduino/variants/standard/pins_arduino.h b/hardware/arduino/variants/standard/pins_arduino.h new file mode 100644 index 000000000..3999d1fcd --- /dev/null +++ b/hardware/arduino/variants/standard/pins_arduino.h @@ -0,0 +1,218 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define NUM_DIGITAL_PINS 20 +#define NUM_ANALOG_INPUTS 6 +#define analogInputToDigitalPin(p) ((p < 6) ? (p) + 14 : -1) + +#if defined(__AVR_ATmega8__) +#define digitalPinHasPWM(p) ((p) == 9 || (p) == 10 || (p) == 11) +#else +#define digitalPinHasPWM(p) ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11) +#endif + +const static uint8_t SS = 10; +const static uint8_t MOSI = 11; +const static uint8_t MISO = 12; +const static uint8_t SCK = 13; + +const static uint8_t SDA = 18; +const static uint8_t SCL = 19; +const static uint8_t LED = 13; + +const static uint8_t A0 = 14; +const static uint8_t A1 = 15; +const static uint8_t A2 = 16; +const static uint8_t A3 = 17; +const static uint8_t A4 = 18; +const static uint8_t A5 = 19; +const static uint8_t A6 = 20; +const static uint8_t A7 = 21; + +#define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0)) +#define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1)) +#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0)))) +#define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14))) + +#ifdef ARDUINO_MAIN + +// On the Arduino board, digital pins are also used +// for the analog output (software PWM). Analog input +// pins are a separate set. + +// ATMEL ATMEGA8 & 168 / ARDUINO +// +// +-\/-+ +// PC6 1| |28 PC5 (AI 5) +// (D 0) PD0 2| |27 PC4 (AI 4) +// (D 1) PD1 3| |26 PC3 (AI 3) +// (D 2) PD2 4| |25 PC2 (AI 2) +// PWM+ (D 3) PD3 5| |24 PC1 (AI 1) +// (D 4) PD4 6| |23 PC0 (AI 0) +// VCC 7| |22 GND +// GND 8| |21 AREF +// PB6 9| |20 AVCC +// PB7 10| |19 PB5 (D 13) +// PWM+ (D 5) PD5 11| |18 PB4 (D 12) +// PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM +// (D 7) PD7 13| |16 PB2 (D 10) PWM +// (D 8) PB0 14| |15 PB1 (D 9) PWM +// +----+ +// +// (PWM+ indicates the additional PWM pins on the ATmega168.) + +// ATMEL ATMEGA1280 / ARDUINO +// +// 0-7 PE0-PE7 works +// 8-13 PB0-PB5 works +// 14-21 PA0-PA7 works +// 22-29 PH0-PH7 works +// 30-35 PG5-PG0 works +// 36-43 PC7-PC0 works +// 44-51 PJ7-PJ0 works +// 52-59 PL7-PL0 works +// 60-67 PD7-PD0 works +// A0-A7 PF0-PF7 +// A8-A15 PK0-PK7 + + +// these arrays map port names (e.g. port B) to the +// appropriate addresses for various functions (e.g. reading +// and writing) +const uint16_t PROGMEM port_to_mode_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, +}; + +const uint16_t PROGMEM port_to_input_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &PIND, +}; + +const uint8_t PROGMEM digital_pin_to_port_PGM[] = { + PD, /* 0 */ + PD, + PD, + PD, + PD, + PD, + PD, + PD, + PB, /* 8 */ + PB, + PB, + PB, + PB, + PB, + PC, /* 14 */ + PC, + PC, + PC, + PC, + PC, +}; + +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { + _BV(0), /* 0, port D */ + _BV(1), + _BV(2), + _BV(3), + _BV(4), + _BV(5), + _BV(6), + _BV(7), + _BV(0), /* 8, port B */ + _BV(1), + _BV(2), + _BV(3), + _BV(4), + _BV(5), + _BV(0), /* 14, port C */ + _BV(1), + _BV(2), + _BV(3), + _BV(4), + _BV(5), +}; + +const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { + NOT_ON_TIMER, /* 0 - port D */ + NOT_ON_TIMER, + NOT_ON_TIMER, + // on the ATmega168, digital pin 3 has hardware pwm +#if defined(__AVR_ATmega8__) + NOT_ON_TIMER, +#else + TIMER2B, +#endif + NOT_ON_TIMER, + // on the ATmega168, digital pins 5 and 6 have hardware pwm +#if defined(__AVR_ATmega8__) + NOT_ON_TIMER, + NOT_ON_TIMER, +#else + TIMER0B, + TIMER0A, +#endif + NOT_ON_TIMER, + NOT_ON_TIMER, /* 8 - port B */ + TIMER1A, + TIMER1B, +#if defined(__AVR_ATmega8__) + TIMER2, +#else + TIMER2A, +#endif + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, /* 14 - port C */ + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, +}; + +#endif + +#endif \ No newline at end of file diff --git a/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp b/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp index 845e2efef..86a275ab7 100644 --- a/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp +++ b/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp @@ -26,7 +26,7 @@ #include "ArduinoTestSuite.h" -#include "WProgram.h" +#include "Arduino.h" #include "HardwareSerial.h" #include "pins_arduino.h" diff --git a/libraries/ArduinoTestSuite/ArduinoTestSuite.h b/libraries/ArduinoTestSuite/ArduinoTestSuite.h index 9501d67a2..af810e1eb 100644 --- a/libraries/ArduinoTestSuite/ArduinoTestSuite.h +++ b/libraries/ArduinoTestSuite/ArduinoTestSuite.h @@ -7,8 +7,8 @@ #include #endif -#ifndef WProgram_h - #include "WProgram.h" +#ifndef Arduino_h + #include "Arduino.h" #endif #ifndef HardwareSerial_h #include "HardwareSerial.h" diff --git a/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde b/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde index d58e8bac6..3196923f5 100644 --- a/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde +++ b/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde @@ -7,7 +7,6 @@ //* Oct 16, 2010 Test of Arduino Constants //************************************************************************ -#include "WProgram.h" #include "HardwareSerial.h" #include diff --git a/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde b/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde index 8ac9fd202..c3235d273 100644 --- a/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde +++ b/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde @@ -1 +1 @@ -//************************************************************************ //* Arduino Test Suite //* ATS_ToneTest //* //* Copyright (c) 2010 Mark Sproul 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 //************************************************************************ //* Aug 31, 2010 Started on TestArduino //* Oct 28, 2010 Started on Delay //************************************************************************ #include "WProgram.h" #include "HardwareSerial.h" #include //************************************************************************ void setup() { short ii; short testNum; int startMemoryUsage; unsigned long startMillis; unsigned long endMillis; unsigned long deltaMillis; unsigned long errMillis; boolean passed; char testNameString[80]; startMemoryUsage = ATS_GetFreeMemory(); ATS_begin("Arduino", "DelayTest"); testNum = 1; //* we start at 2 because 0/1 are RXD/TXD for (ii=0; ii<1000; ii+= 15) { startMillis = millis(); delay(ii); endMillis = millis(); deltaMillis = endMillis - startMillis; if (deltaMillis >= ii) { errMillis = deltaMillis - ii; } else { errMillis = ii - deltaMillis; } if (errMillis <= 1) { passed = true; } else { passed = false; } sprintf(testNameString, "DelayTest.%02d (delay= %4d actual delay=%ld err=%ld)", testNum, ii, deltaMillis, errMillis); ATS_PrintTestStatus(testNameString, passed); testNum++; } ATS_ReportMemoryUsage(startMemoryUsage); ATS_end(); } //************************************************************************ void loop() { } \ No newline at end of file +//************************************************************************ //* Arduino Test Suite //* ATS_ToneTest //* //* Copyright (c) 2010 Mark Sproul 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 //************************************************************************ //* Aug 31, 2010 Started on TestArduino //* Oct 28, 2010 Started on Delay //************************************************************************ #include "HardwareSerial.h" #include //************************************************************************ void setup() { short ii; short testNum; int startMemoryUsage; unsigned long startMillis; unsigned long endMillis; unsigned long deltaMillis; unsigned long errMillis; boolean passed; char testNameString[80]; startMemoryUsage = ATS_GetFreeMemory(); ATS_begin("Arduino", "DelayTest"); testNum = 1; //* we start at 2 because 0/1 are RXD/TXD for (ii=0; ii<1000; ii+= 15) { startMillis = millis(); delay(ii); endMillis = millis(); deltaMillis = endMillis - startMillis; if (deltaMillis >= ii) { errMillis = deltaMillis - ii; } else { errMillis = ii - deltaMillis; } if (errMillis <= 1) { passed = true; } else { passed = false; } sprintf(testNameString, "DelayTest.%02d (delay= %4d actual delay=%ld err=%ld)", testNum, ii, deltaMillis, errMillis); ATS_PrintTestStatus(testNameString, passed); testNum++; } ATS_ReportMemoryUsage(startMemoryUsage); ATS_end(); } //************************************************************************ void loop() { } \ No newline at end of file diff --git a/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde b/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde index 502248a23..3c219bc13 100644 --- a/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde +++ b/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde @@ -8,7 +8,6 @@ //* Oct 18, 2010 Added memory testing //************************************************************************ -#include "WProgram.h" #include "HardwareSerial.h" #include "pins_arduino.h" #include diff --git a/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde b/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde index 33fc81680..e7fc4fa08 100644 --- a/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde +++ b/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde @@ -7,7 +7,6 @@ //* Oct 16, 2010 Started on String Test //************************************************************************ -#include "WProgram.h" #include "HardwareSerial.h" #include diff --git a/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde b/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde index 71a6bea19..000976104 100644 --- a/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde +++ b/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde @@ -7,7 +7,6 @@ //* Oct 16, 2010 Started on String Test //************************************************************************ -#include "WProgram.h" #include "HardwareSerial.h" #include diff --git a/libraries/ArduinoTestSuite/examples/ATS_StringTest/ATS_StringTest.pde b/libraries/ArduinoTestSuite/examples/ATS_StringTest/ATS_StringTest.pde index 27a9d26c7..a1c2944df 100644 --- a/libraries/ArduinoTestSuite/examples/ATS_StringTest/ATS_StringTest.pde +++ b/libraries/ArduinoTestSuite/examples/ATS_StringTest/ATS_StringTest.pde @@ -7,7 +7,6 @@ //* Oct 16, 2010 Started on String Test //************************************************************************ -#include "WProgram.h" #include "HardwareSerial.h" #include diff --git a/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.pde b/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.pde new file mode 100644 index 000000000..3c35627ba --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.pde @@ -0,0 +1,61 @@ +#include + +void Test_Equal(char *testString, char *expected, const String &actual) +{ + char buf[100]; actual.toCharArray(buf, 100); + boolean b = (strcmp(buf, expected) == 0); + ATS_PrintTestStatus(testString, b); + if (!b) { + Serial.print("expected '"); + Serial.print(expected); + Serial.print("', actual '"); + Serial.print(actual); + Serial.println("'"); + } +} + +void setup() +{ + ATS_begin("Arduino", "String Addition Test"); + + String stringOne = String("string"); + String stringTwo = String("other"); + String stringThree = stringOne + stringTwo; + + Test_Equal("Add strings", "stringother", stringThree); + Test_Equal("Adding strings doesn't change them", "string", stringOne); + Test_Equal("Adding strings doesn't change them", "other", stringTwo); + Test_Equal("Add strings", "stringotherstringstringstringother", stringOne + stringTwo + stringOne + stringOne + stringOne + stringTwo); + Test_Equal("Add string to integer", "string12345", stringOne + 12345); + Test_Equal("Add string to negative integer", "string-12345", stringOne + -12345); + Test_Equal("Add integer to string", "123string", 123 + stringOne); + Test_Equal("Add string to integers", "string123456789", stringOne + 123 + 456 + 789); + Test_Equal("Add integer to string", "123string456789", 123 + stringOne + 456 + 789); + Test_Equal("Add string to long", "string123456789", stringOne + 123456789L); + Test_Equal("Add string to negative long", "string-123456789", stringOne + -123456789L); + Test_Equal("Add string to unsigned long", "string123456789", stringOne + 123456789UL); + Test_Equal("Add string to byte", "string123", stringOne + byte(123)); + Test_Equal("Add char", "stringA", stringOne + 'A'); + Test_Equal("Add char", "Astring", 'A' + stringOne); + Test_Equal("Add \"string\"", "stringabc", stringOne + "abc"); + Test_Equal("Add \"string\"", "abcstring", "abc" + stringOne); + Test_Equal("Add multiple \"string\"", "stringabcdef", stringOne + "abc" + "def"); + Test_Equal("Add multiple \"string\"", "abcstringdef", "abc" + stringOne + "def"); + Test_Equal("Add \"string\" and int", "bc", "abc" + 1); + + ATS_end(); +} + +void loop() {} + + + + + + + + + + + + diff --git a/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde b/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde index 8bec6be2a..b244081e5 100644 --- a/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde +++ b/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde @@ -26,7 +26,6 @@ -#include "WProgram.h" #include "HardwareSerial.h" #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) diff --git a/libraries/ArduinoTestSuite/examples/ATS_Write_Print/ATS_Write_Print.ino b/libraries/ArduinoTestSuite/examples/ATS_Write_Print/ATS_Write_Print.ino new file mode 100644 index 000000000..d7e47f179 --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_Write_Print/ATS_Write_Print.ino @@ -0,0 +1,61 @@ +#include + +void Test_Equal(long actual, long expected) +{ + char buf[100]; + boolean b = expected == actual; + ATS_PrintTestStatus("", b); + if (!b) { + Serial.print("expected '"); + Serial.print(expected); + Serial.print("', actual '"); + Serial.print(actual); + Serial.println("'"); + } +} + +void setup() +{ + byte buf[5] = { 65, 66, 67, 0, 69 }; + ATS_begin("Arduino", "Write & Print Return Values Test"); + + Test_Equal(Serial.write('a'), 1); + Test_Equal(Serial.write(byte(0)), 1); + Test_Equal(Serial.write("abc"), 3); + Test_Equal(Serial.write(""), 0); + Test_Equal(Serial.write(buf, 5), 5); + Test_Equal(Serial.print(0), 1); + Test_Equal(Serial.print(""), 0); + Test_Equal(Serial.print("abc"), 3); + Test_Equal(Serial.print(0), 1); + Test_Equal(Serial.print(1), 1); + Test_Equal(Serial.print(11), 2); + Test_Equal(Serial.print(12345), 5); + Test_Equal(Serial.print(-1), 2); + Test_Equal(Serial.print(-123), 4); + Test_Equal(Serial.println(), 2); + Test_Equal(Serial.println(""), 2); + Test_Equal(Serial.println("abc"), 5); + Test_Equal(Serial.println(0), 3); + Test_Equal(Serial.println(1), 3); + Test_Equal(Serial.println(11), 4); + Test_Equal(Serial.println(12345), 7); + Test_Equal(Serial.println(-1), 4); + Test_Equal(Serial.println(-123), 6); + + ATS_end(); +} + +void loop() {} + + + + + + + + + + + + diff --git a/libraries/EEPROM/EEPROM.cpp b/libraries/EEPROM/EEPROM.cpp index 3a361e7f5..dfa1deb56 100755 --- a/libraries/EEPROM/EEPROM.cpp +++ b/libraries/EEPROM/EEPROM.cpp @@ -22,7 +22,7 @@ ******************************************************************************/ #include -#include "WConstants.h" +#include "Arduino.h" #include "EEPROM.h" /****************************************************************************** diff --git a/libraries/Ethernet/Client.cpp b/libraries/Ethernet/Client.cpp index 8a525ca7e..3c1c2503b 100644 --- a/libraries/Ethernet/Client.cpp +++ b/libraries/Ethernet/Client.cpp @@ -5,7 +5,7 @@ extern "C" { #include "string.h" } -#include "WProgram.h" +#include "Arduino.h" #include "Ethernet.h" #include "Client.h" @@ -70,19 +70,24 @@ int Client::connect(IPAddress ip, uint16_t port) { return 1; } -void Client::write(uint8_t b) { - if (_sock != MAX_SOCK_NUM) - send(_sock, &b, 1); +size_t Client::write(uint8_t b) { + return write(&b, 1); } -void Client::write(const char *str) { - if (_sock != MAX_SOCK_NUM) - send(_sock, (const uint8_t *)str, strlen(str)); +size_t Client::write(const char *str) { + return write((const uint8_t *) str, strlen(str)); } -void Client::write(const uint8_t *buf, size_t size) { - if (_sock != MAX_SOCK_NUM) - send(_sock, buf, size); +size_t Client::write(const uint8_t *buf, size_t size) { + if (_sock == MAX_SOCK_NUM) { + setWriteError(); + return 0; + } + if (!send(_sock, buf, size)) { + setWriteError(); + return 0; + } + return size; } int Client::available() { @@ -156,18 +161,8 @@ uint8_t Client::status() { return W5100.readSnSR(_sock); } -// the next three functions are a hack so we can compare the client returned -// by Server::available() to null, or use it as the condition in an -// if-statement. this lets us stay compatible with the Processing network -// library. - -uint8_t Client::operator==(int p) { - return _sock == MAX_SOCK_NUM; -} - -uint8_t Client::operator!=(int p) { - return _sock != MAX_SOCK_NUM; -} +// the next function allows us to use the client returned by +// Server::available() as the condition in an if-statement. Client::operator bool() { return _sock != MAX_SOCK_NUM; diff --git a/libraries/Ethernet/Client.h b/libraries/Ethernet/Client.h index a4d1589ff..1d360063a 100644 --- a/libraries/Ethernet/Client.h +++ b/libraries/Ethernet/Client.h @@ -1,6 +1,6 @@ #ifndef client_h #define client_h -#include "WProgram.h" +#include "Arduino.h" #include "Print.h" #include "NetClient.h" #include "IPAddress.h" @@ -14,9 +14,9 @@ public: uint8_t status(); virtual int connect(IPAddress ip, uint16_t port); virtual int connect(const char *host, uint16_t port); - virtual void write(uint8_t); - virtual void write(const char *str); - virtual void write(const uint8_t *buf, size_t size); + virtual size_t write(uint8_t); + virtual size_t write(const char *str); + virtual size_t write(const uint8_t *buf, size_t size); virtual int available(); virtual int read(); virtual int read(uint8_t *buf, size_t size); diff --git a/libraries/Ethernet/Dhcp.cpp b/libraries/Ethernet/Dhcp.cpp index 8264b435b..29db89098 100755 --- a/libraries/Ethernet/Dhcp.cpp +++ b/libraries/Ethernet/Dhcp.cpp @@ -6,7 +6,7 @@ #include #include #include "Dhcp.h" -#include "wiring.h" +#include "Arduino.h" #include "util.h" int DhcpClass::beginWithDHCP(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) @@ -271,11 +271,19 @@ uint8_t DhcpClass::parseDHCPResponse(unsigned long responseTimeout, uint32_t& tr case routersOnSubnet : opt_len = _dhcpUdpSocket.read(); _dhcpUdpSocket.read(_dhcpGatewayIp, 4); + for (int i = 0; i < opt_len-4; i++) + { + _dhcpUdpSocket.read(); + } break; case dns : opt_len = _dhcpUdpSocket.read(); _dhcpUdpSocket.read(_dhcpDnsServerIp, 4); + for (int i = 0; i < opt_len-4; i++) + { + _dhcpUdpSocket.read(); + } break; case dhcpServerIdentifier : diff --git a/libraries/Ethernet/Dns.cpp b/libraries/Ethernet/Dns.cpp index 3a31e35a4..a049c7633 100644 --- a/libraries/Ethernet/Dns.cpp +++ b/libraries/Ethernet/Dns.cpp @@ -9,7 +9,7 @@ #include "Dns.h" #include //#include -#include "wiring.h" +#include "Arduino.h" #define SOCKET_NONE 255 diff --git a/libraries/Ethernet/Ethernet.cpp b/libraries/Ethernet/Ethernet.cpp index 937f5b4f9..c298f3d17 100644 --- a/libraries/Ethernet/Ethernet.cpp +++ b/libraries/Ethernet/Ethernet.cpp @@ -33,27 +33,37 @@ int EthernetClass::begin(uint8_t *mac_address) } void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip) +{ + // Assume the DNS server will be the machine on the same network as the local IP + // but with last octet being '1' + IPAddress dns_server = local_ip; + dns_server[3] = 1; + begin(mac_address, local_ip, dns_server); +} + +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server) { // Assume the gateway will be the machine on the same network as the local IP // but with last octet being '1' IPAddress gateway = local_ip; gateway[3] = 1; - begin(mac_address, local_ip, gateway); + begin(mac_address, local_ip, dns_server, gateway); } -void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress gateway) +void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway) { IPAddress subnet(255, 255, 255, 0); - begin(mac_address, local_ip, gateway, subnet); + begin(mac_address, local_ip, dns_server, gateway, subnet); } -void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress gateway, IPAddress subnet) +void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) { W5100.init(); W5100.setMACAddress(mac); W5100.setIPAddress(local_ip._address); W5100.setGatewayIp(gateway._address); W5100.setSubnetMask(subnet._address); + _dnsServerAddress = dns_server; } IPAddress EthernetClass::localIP() diff --git a/libraries/Ethernet/Ethernet.h b/libraries/Ethernet/Ethernet.h index fdf0b7f39..b4d223fba 100644 --- a/libraries/Ethernet/Ethernet.h +++ b/libraries/Ethernet/Ethernet.h @@ -20,8 +20,9 @@ public: // Returns 0 if the DHCP configuration failed, and 1 if it succeeded int begin(uint8_t *mac_address); void begin(uint8_t *mac_address, IPAddress local_ip); - void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress gateway); - void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress gateway, IPAddress subnet); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway); + void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); IPAddress localIP(); IPAddress subnetMask(); diff --git a/libraries/Ethernet/Server.cpp b/libraries/Ethernet/Server.cpp index 4271741b9..1ac75d507 100644 --- a/libraries/Ethernet/Server.cpp +++ b/libraries/Ethernet/Server.cpp @@ -67,18 +67,20 @@ Client Server::available() return Client(MAX_SOCK_NUM); } -void Server::write(uint8_t b) +size_t Server::write(uint8_t b) { write(&b, 1); } -void Server::write(const char *str) +size_t Server::write(const char *str) { write((const uint8_t *)str, strlen(str)); } -void Server::write(const uint8_t *buffer, size_t size) +size_t Server::write(const uint8_t *buffer, size_t size) { + size_t n = 0; + accept(); for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { @@ -86,7 +88,9 @@ void Server::write(const uint8_t *buffer, size_t size) if (EthernetClass::_server_port[sock] == _port && client.status() == SnSR::ESTABLISHED) { - client.write(buffer, size); + n += client.write(buffer, size); } } + + return n; } diff --git a/libraries/Ethernet/Server.h b/libraries/Ethernet/Server.h index 4c3bd1b54..0febe4fee 100644 --- a/libraries/Ethernet/Server.h +++ b/libraries/Ethernet/Server.h @@ -14,9 +14,9 @@ public: Server(uint16_t); Client available(); virtual void begin(); - virtual void write(uint8_t); - virtual void write(const char *str); - virtual void write(const uint8_t *buf, size_t size); + virtual size_t write(uint8_t); + virtual size_t write(const char *str); + virtual size_t write(const uint8_t *buf, size_t size); }; #endif diff --git a/libraries/Ethernet/Udp.cpp b/libraries/Ethernet/Udp.cpp index aed5d983b..a1244ffb9 100644 --- a/libraries/Ethernet/Udp.cpp +++ b/libraries/Ethernet/Udp.cpp @@ -102,21 +102,22 @@ int UDP::endPacket() return sendUDP(_sock); } -void UDP::write(uint8_t byte) +size_t UDP::write(uint8_t byte) { - write(&byte, 1); + return write(&byte, 1); } -void UDP::write(const char *str) +size_t UDP::write(const char *str) { size_t len = strlen(str); - write((const uint8_t *)str, len); + return write((const uint8_t *)str, len); } -void UDP::write(const uint8_t *buffer, size_t size) +size_t UDP::write(const uint8_t *buffer, size_t size) { uint16_t bytes_written = bufferData(_sock, _offset, buffer, size); _offset += bytes_written; + return bytes_written; } int UDP::parsePacket() diff --git a/libraries/Ethernet/Udp.h b/libraries/Ethernet/Udp.h index 99df53f15..59238c1ae 100644 --- a/libraries/Ethernet/Udp.h +++ b/libraries/Ethernet/Udp.h @@ -67,11 +67,11 @@ public: // Returns 1 if the packet was sent successfully, 0 if there was an error int endPacket(); // Write a single byte into the packet - virtual void write(uint8_t); + virtual size_t write(uint8_t); // Write a string of characters into the packet - virtual void write(const char *str); + virtual size_t write(const char *str); // Write size bytes from buffer into the packet - virtual void write(const uint8_t *buffer, size_t size); + virtual size_t write(const uint8_t *buffer, size_t size); // Start processing the next available incoming packet // Returns the size of the packet in bytes, or 0 if no packets are available diff --git a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino new file mode 100644 index 000000000..8701568c0 --- /dev/null +++ b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino @@ -0,0 +1,54 @@ +/* + DHCP-based IP printer + + This sketch uses the DHCP extensions to the Ethernet library + to get an IP address via DHCP and print the address obtained. + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 12 April 2011 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address for your controller below. +// Newer Ethernet shields have a MAC address printed on a sticker on the shield +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 80 is default for HTTP): +Client client; + +void setup() { + // start the serial library: + Serial.begin(9600); + // start the Ethernet connection: + Serial.println("Trying to get an IP address using DHCP");z + if (Ethernet.begin(mac) == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // no point in carrying on, so do nothing forevermore: + while(true); + } + // print your local IP address: + Serial.print("My IP address: "); + IPAddress myIPAddress = Ethernet.localIP(); + for (byte thisByte = 0; thisByte < 4; thisByte++) { + // print the value of each byte of the IP address: + Serial.print(myIPAddress[thisByte], DEC); + Serial.print("."); + } + Serial.println(); +} + +void loop() { + +} + + diff --git a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.pde b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.pde new file mode 100644 index 000000000..50a557dcc --- /dev/null +++ b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.pde @@ -0,0 +1,53 @@ +/* + DHCP-based IP printer + + This sketch uses the DHCP extensions to the Ethernet library + to get an IP address via DHCP and print the address obtained. + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 12 April 2011 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address for your controller below. +// Newer Ethernet shields have a MAC address printed on a sticker on the shield +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 80 is default for HTTP): +Client client; + +void setup() { + // start the serial library: + 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(;;) + ; + } + // print your local IP address: + Serial.print("My IP address: "); + for (byte thisByte = 0; thisByte < 4; thisByte++) { + // print the value of each byte of the IP address: + Serial.print(Ethernet.localIP()[thisByte], DEC); + Serial.print("."); + } + Serial.println(); +} + +void loop() { + +} + + diff --git a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino new file mode 100644 index 000000000..c3e581387 --- /dev/null +++ b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino @@ -0,0 +1,80 @@ +/* + DHCP Chat Server + + A simple server that distributes any incoming messages to all + connected clients. To use telnet to your device's IP address and type. + You can see the client's input in the serial monitor as well. + Using an Arduino Wiznet Ethernet shield. + + THis version attempts to get an IP address using DHCP + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 21 May 2011 + by Tom Igoe + Based on ChatServer example by David A. Mellis + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network. +// gateway and subnet are optional: +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; +IPAddress ip(192,168,1, 177); +IPAddress gateway(192,168,1, 1); +IPAddress subnet(255, 255, 0, 0); + +// telnet defaults to port 23 +Server server(23); +boolean gotAMessage = false; // whether or not you got a message from the client yet + +void setup() { + // open the serial port + Serial.begin(9600); + // start the Ethernet connection: + Serial.println("Trying to get an IP address using DHCP"); + if (Ethernet.begin(mac) == 0) { + Serial.println("Failed to configure Ethernet using DHCP"); + // initialize the ethernet device not using DHCP: + Ethernet.begin(mac, ip, gateway, subnet); + } + // print your local IP address: + Serial.print("My IP address: "); + ip = Ethernet.localIP(); + for (byte thisByte = 0; thisByte < 4; thisByte++) { + // print the value of each byte of the IP address: + Serial.print(ip[thisByte], DEC); + Serial.print("."); + } + Serial.println(); + // start listening for clients + server.begin(); + +} + +void loop() { + // wait for a new client: + Client client = server.available(); + + // when the client sends the first byte, say hello: + if (client) { + if (!gotAMessage) { + Serial.println("We have a new client"); + client.println("Hello, client!"); + gotAMessage = true; + } + + // read the bytes incoming from the client: + char thisChar = client.read(); + // echo the bytes back to the client: + server.write(thisChar); + // echo the bytes to the server as well: + Serial.print(thisChar); + } +} + diff --git a/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.pde b/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.pde new file mode 100644 index 000000000..7bec73a83 --- /dev/null +++ b/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.pde @@ -0,0 +1,76 @@ +/* + DNS and DHCP-based Web client + + This sketch connects to a website (http://www.google.com) + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 18 Dec 2009 + by David A. Mellis + modified 12 April 2011 + by Tom Igoe, based on work by Adrian McEwen + + */ + +#include +#include + +// Enter a MAC address for your controller below. +// Newer Ethernet shields have a MAC address printed on a sticker on the shield +byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; +char serverName[] = "www.google.com"; + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 80 is default for HTTP): +Client client; + +void setup() { + // start the serial library: + 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: + while(true); + } + // give the Ethernet shield a second to initialize: + delay(1000); + Serial.println("connecting..."); + + // if you get a connection, report back via serial: + + if (client.connect(serverName, 80)) { + Serial.println("connected"); + // Make a HTTP request: + client.println("GET /search?q=arduino HTTP/1.0"); + client.println(); + } + else { + // kf you didn't get a connection to the server: + Serial.println("connection failed"); + } +} + +void loop() +{ + // if there are incoming bytes available + // from the server, read them and print them: + if (client.available()) { + char c = client.read(); + Serial.print(c); + } + + // if the server's disconnected, stop the client: + if (!client.connected()) { + Serial.println(); + Serial.println("disconnecting."); + client.stop(); + + // do nothing forevermore: + while(true); + } +} + diff --git a/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino new file mode 100644 index 000000000..399e76bc3 --- /dev/null +++ b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino @@ -0,0 +1,124 @@ +/* + Twitter Client with Strings + + This sketch connects to Twitter using an Ethernet shield. It parses the XML + returned, and looks for this is a tweet + + You can use the Arduino Ethernet shield, or the Adafruit Ethernet shield, + either one will work, as long as it's got a Wiznet Ethernet module on board. + + This example uses the DHCP routines in the Ethernet library which is part of the + Arduino core from version 1.0 beta 1 + + This example uses the String library, which is part of the Arduino core from + version 0019. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 21 May 2011 + by Tom Igoe + + This code is in the public domain. + + */ +#include +#include + + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { + 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 }; +IPAddress ip(192,168,1,20); + +// initialize the library instance: +Client client; + +const int requestInterval = 60000; // delay between requests + +char serverName[] = "api.twitter.com"; // twitter URL + +boolean requested; // whether you've made a request since connecting +long lastAttemptTime = 0; // last time you connected to the server, in milliseconds + +String currentLine = ""; // string to hold the text from server +String tweet = ""; // string to hold the tweet +boolean readingTweet = false; // if you're currently reading the tweet + +void setup() { + // reserve space for the strings: + currentLine.reserve(256); + tweet.reserve(150); + +// initialize serial: + Serial.begin(9600); + // attempt a DHCP connection: + if (!Ethernet.begin(mac)) { + // if DHCP fails, start with a hard-coded address: + Ethernet.begin(mac, ip); + } + // connect to Twitter: + connectToServer(); +} + + + +void loop() +{ + if (client.connected()) { + if (client.available()) { + // read incoming bytes: + char inChar = client.read(); + + // add incoming byte to end of line: + currentLine += inChar; + + // if you get a newline, clear the line: + if (inChar == '\n') { + currentLine = ""; + } + // if the current line ends with , it will + // be followed by the tweet: + if ( currentLine.endsWith("")) { + // tweet is beginning. Clear the tweet string: + readingTweet = true; + tweet = ""; + } + // if you're currently reading the bytes of a tweet, + // add them to the tweet String: + if (readingTweet) { + if (inChar != '<') { + tweet += inChar; + } + else { + // if you got a "<" character, + // you've reached the end of the tweet: + readingTweet = false; + Serial.println(tweet); + // close the connection to the server: + client.stop(); + } + } + } + } + else if (millis() - lastAttemptTime > requestInterval) { + // if you're not connected, and two minutes have passed since + // your last connection, then attempt to connect again: + connectToServer(); + } +} + +void connectToServer() { + // attempt to connect, and wait a millisecond: + Serial.println("connecting to server..."); + if (client.connect(serverName, 80)) { + Serial.println("making HTTP request..."); + // make HTTP GET request to twitter: + client.println("GET /1/statuses/user_timeline.xml?screen_name=arduino&count=1 HTTP/1.1"); + client.println("HOST: api.twitter.com"); + client.println(); + } + // note the time of this connect attempt: + lastAttemptTime = millis(); +} diff --git a/libraries/Ethernet/utility/w5100.h b/libraries/Ethernet/utility/w5100.h index 9872c7ccb..35d23ed41 100755 --- a/libraries/Ethernet/utility/w5100.h +++ b/libraries/Ethernet/utility/w5100.h @@ -324,6 +324,10 @@ private: inline static void initSS() { DDRB |= _BV(4); }; inline static void setSS() { PORTB &= ~_BV(4); }; inline static void resetSS() { PORTB |= _BV(4); }; +#elif defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__) + inline static void initSS() { DDRB |= _BV(0); }; + inline static void setSS() { PORTB &= ~_BV(0); }; + inline static void resetSS() { PORTB |= _BV(0); }; #else inline static void initSS() { DDRB |= _BV(2); }; inline static void setSS() { PORTB &= ~_BV(2); }; diff --git a/libraries/Firmata/Boards.h b/libraries/Firmata/Boards.h index 203645447..f71632095 100644 --- a/libraries/Firmata/Boards.h +++ b/libraries/Firmata/Boards.h @@ -3,7 +3,7 @@ #ifndef Firmata_Boards_h #define Firmata_Boards_h -#include // for digitalRead, digitalWrite, etc +#include // for digitalRead, digitalWrite, etc // Normally Servo.h must be included before Firmata.h (which then includes // this file). If Servo.h wasn't included, this allows the code to still diff --git a/libraries/Firmata/Firmata.cpp b/libraries/Firmata/Firmata.cpp index ffaff4d75..e30deae6c 100644 --- a/libraries/Firmata/Firmata.cpp +++ b/libraries/Firmata/Firmata.cpp @@ -14,7 +14,7 @@ //* Includes //****************************************************************************** -#include "WProgram.h" +#include "Arduino.h" #include "HardwareSerial.h" #include "Firmata.h" diff --git a/libraries/Firmata/Firmata.h b/libraries/Firmata/Firmata.h index 9e8dda075..86535d934 100644 --- a/libraries/Firmata/Firmata.h +++ b/libraries/Firmata/Firmata.h @@ -13,7 +13,7 @@ #ifndef Firmata_h #define Firmata_h -#include +#include #include @@ -66,8 +66,8 @@ #define SYSEX_SAMPLING_INTERVAL 0x7A // same as SAMPLING_INTERVAL // pin modes -//#define INPUT 0x00 // defined in wiring.h -//#define OUTPUT 0x01 // defined in wiring.h +//#define INPUT 0x00 // defined in Arduino.h +//#define OUTPUT 0x01 // defined in Arduino.h #define ANALOG 0x02 // analog pin in analogInput mode #define PWM 0x03 // digital pin in PWM output mode #define SERVO 0x04 // digital pin in Servo output mode diff --git a/libraries/Firmata/examples/EchoString/EchoString.pde b/libraries/Firmata/examples/EchoString/EchoString.pde index 6559ae1c6..e5c4e6fe5 100644 --- a/libraries/Firmata/examples/EchoString/EchoString.pde +++ b/libraries/Firmata/examples/EchoString/EchoString.pde @@ -14,12 +14,12 @@ void stringCallback(char *myString) void sysexCallback(byte command, byte argc, byte*argv) { - Serial.print(START_SYSEX, BYTE); - Serial.print(command, BYTE); + Serial.write(START_SYSEX); + Serial.write(command); for(byte i=0; i #include #include -#include "WProgram.h" +#include "Arduino.h" // When the display powers up, it is configured as follows: // @@ -258,8 +258,9 @@ inline void LiquidCrystal::command(uint8_t value) { send(value, LOW); } -inline void LiquidCrystal::write(uint8_t value) { +inline size_t LiquidCrystal::write(uint8_t value) { send(value, HIGH); + return 1; // assume sucess } /************ low level data pushing commands **********/ diff --git a/libraries/LiquidCrystal/LiquidCrystal.h b/libraries/LiquidCrystal/LiquidCrystal.h index f66ec1b4c..f4352f341 100755 --- a/libraries/LiquidCrystal/LiquidCrystal.h +++ b/libraries/LiquidCrystal/LiquidCrystal.h @@ -79,7 +79,7 @@ public: void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - virtual void write(uint8_t); + virtual size_t write(uint8_t); void command(uint8_t); private: void send(uint8_t, uint8_t); diff --git a/libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.pde b/libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.pde new file mode 100644 index 000000000..d3ce47924 --- /dev/null +++ b/libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.pde @@ -0,0 +1,138 @@ +/* + LiquidCrystal Library - Custom Characters + + Demonstrates how to add custom characters on an LCD display. + The LiquidCrystal library works with all LCD displays that are + compatible with the Hitachi HD44780 driver. There are many of + them out there, and you can usually tell them by the 16-pin interface. + + This sketch prints "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/LiquidCrystal/examples/TextDirection/TextDirection.pde b/libraries/LiquidCrystal/examples/TextDirection/TextDirection.pde index 30e4ac587..51bab1fb5 100644 --- a/libraries/LiquidCrystal/examples/TextDirection/TextDirection.pde +++ b/libraries/LiquidCrystal/examples/TextDirection/TextDirection.pde @@ -71,7 +71,7 @@ void loop() { thisChar = 'a'; } // print the character - lcd.print(thisChar, BYTE); + lcd.write(thisChar); // wait a second: delay(1000); // increment the letter: diff --git a/libraries/LiquidCrystal/examples/setCursor/setCursor.pde b/libraries/LiquidCrystal/examples/setCursor/setCursor.pde index 279f3ecca..3c4edf3c4 100644 --- a/libraries/LiquidCrystal/examples/setCursor/setCursor.pde +++ b/libraries/LiquidCrystal/examples/setCursor/setCursor.pde @@ -61,7 +61,7 @@ void loop() { // set the cursor position: lcd.setCursor(thisRow,thisCol); // print the letter: - lcd.print(thisLetter, BYTE); + lcd.write(thisLetter); delay(200); } } diff --git a/libraries/Matrix/Matrix.cpp b/libraries/Matrix/Matrix.cpp deleted file mode 100755 index 2eb3e25ea..000000000 --- a/libraries/Matrix/Matrix.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - Matrix.cpp - Max7219 LED Matrix library for Arduino & Wiring - Copyright (c) 2006 Nicholas Zambetti. 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 -*/ - -// TODO: Support segment displays in api? -// TODO: Support varying vendor layouts? - -/****************************************************************************** - * Includes - ******************************************************************************/ - -extern "C" { - // AVR LibC Includes - #include - #include - - // Wiring Core Includes - #undef abs - #include "WConstants.h" - - // Wiring Core Prototypes - //void pinMode(uint8_t, uint8_t); - //void digitalWrite(int, uint8_t); -} - -#include "Sprite.h" -#include "Matrix.h" - -/****************************************************************************** - * Definitions - ******************************************************************************/ - -// Matrix registers -#define REG_NOOP 0x00 -#define REG_DIGIT0 0x01 -#define REG_DIGIT1 0x02 -#define REG_DIGIT2 0x03 -#define REG_DIGIT3 0x04 -#define REG_DIGIT4 0x05 -#define REG_DIGIT5 0x06 -#define REG_DIGIT6 0x07 -#define REG_DIGIT7 0x08 -#define REG_DECODEMODE 0x09 -#define REG_INTENSITY 0x0A -#define REG_SCANLIMIT 0x0B -#define REG_SHUTDOWN 0x0C -#define REG_DISPLAYTEST 0x0F - -/****************************************************************************** - * Constructors - ******************************************************************************/ - -Matrix::Matrix(uint8_t data, uint8_t clock, uint8_t load, uint8_t screens /* = 1 */) -{ - // record pins for sw spi - _pinData = data; - _pinClock = clock; - _pinLoad = load; - - // set ddr for sw spi pins - pinMode(_pinClock, OUTPUT); - pinMode(_pinData, OUTPUT); - pinMode(_pinLoad, OUTPUT); - - // allocate screenbuffers - _screens = screens; - _buffer = (uint8_t*)calloc(_screens, 64); - _maximumX = (_screens * 8); - - // initialize registers - clear(); // clear display - setScanLimit(0x07); // use all rows/digits - setBrightness(0x0F); // maximum brightness - setRegister(REG_SHUTDOWN, 0x01); // normal operation - setRegister(REG_DECODEMODE, 0x00); // pixels not integers - setRegister(REG_DISPLAYTEST, 0x00); // not in test mode -} - -/****************************************************************************** - * MAX7219 SPI - ******************************************************************************/ - -// sends a single byte by sw spi (no latching) -void Matrix::putByte(uint8_t data) -{ - uint8_t i = 8; - uint8_t mask; - while(i > 0) { - mask = 0x01 << (i - 1); // get bitmask - digitalWrite(_pinClock, LOW); // tick - if (data & mask){ // choose bit - digitalWrite(_pinData, HIGH); // set 1 - }else{ - digitalWrite(_pinData, LOW); // set 0 - } - digitalWrite(_pinClock, HIGH); // tock - --i; // move to lesser bit - } -} - -// sets register to a byte value for all screens -void Matrix::setRegister(uint8_t reg, uint8_t data) -{ - digitalWrite(_pinLoad, LOW); // begin - for(uint8_t i = 0; i < _screens; ++i){ - putByte(reg); // specify register - putByte(data); // send data - } - digitalWrite(_pinLoad, HIGH); // latch in data - digitalWrite(_pinLoad, LOW); // end -} - -// syncs row of display with buffer -void Matrix::syncRow(uint8_t row) -{ - if (!_buffer) return; - - // uint8_t's can't be negative, so don't test for negative row - if (row >= 8) return; - digitalWrite(_pinLoad, LOW); // begin - for(uint8_t i = 0; i < _screens; ++i){ - putByte(8 - row); // specify register - putByte(_buffer[row + (8 * i)]); // send data - } - digitalWrite(_pinLoad, HIGH); // latch in data - digitalWrite(_pinLoad, LOW); // end -} - -/****************************************************************************** - * MAX7219 Configuration - ******************************************************************************/ - -// sets how many digits are displayed -void Matrix::setScanLimit(uint8_t value) -{ - setRegister(REG_SCANLIMIT, value & 0x07); -} - -// sets brightness of the display -void Matrix::setBrightness(uint8_t value) -{ - setRegister(REG_INTENSITY, value & 0x0F); -} - -/****************************************************************************** - * Helper Functions - ******************************************************************************/ - -void Matrix::buffer(uint8_t x, uint8_t y, uint8_t value) -{ - if (!_buffer) return; - - // uint8_t's can't be negative, so don't test for negative x and y. - if (x >= _maximumX || y >= 8) return; - - uint8_t offset = x; // record x - x %= 8; // make x relative to a single matrix - offset -= x; // calculate buffer offset - - // wrap shift relative x for nexus module layout - if (x == 0){ - x = 8; - } - --x; - - // record value in buffer - if(value){ - _buffer[y + offset] |= 0x01 << x; - }else{ - _buffer[y + offset] &= ~(0x01 << x); - } -} - -/****************************************************************************** - * User API - ******************************************************************************/ - -// buffers and writes to screen -void Matrix::write(uint8_t x, uint8_t y, uint8_t value) -{ - buffer(x, y, value); - - // update affected row - syncRow(y); -} - -void Matrix::write(uint8_t x, uint8_t y, Sprite sprite) -{ - for (uint8_t i = 0; i < sprite.height(); i++){ - for (uint8_t j = 0; j < sprite.width(); j++) - buffer(x + j, y + i, sprite.read(j, i)); - - syncRow(y + i); - } -} - -// clears screens and buffers -void Matrix::clear(void) -{ - if (!_buffer) return; - - // clear buffer - for(uint8_t i = 0; i < 8; ++i){ - for(uint8_t j = 0; j < _screens; ++j){ - _buffer[i + (8 * j)] = 0x00; - } - } - - // clear registers - for(uint8_t i = 0; i < 8; ++i){ - syncRow(i); - } -} - diff --git a/libraries/Matrix/Matrix.h b/libraries/Matrix/Matrix.h deleted file mode 100755 index 7c6be91fb..000000000 --- a/libraries/Matrix/Matrix.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Matrix.h - Max7219 LED Matrix library for Arduino & Wiring - Copyright (c) 2006 Nicholas Zambetti. 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 -*/ - -#ifndef Matrix_h -#define Matrix_h - -#include - -class Sprite; - -class Matrix -{ - private: - uint8_t _pinData; - uint8_t _pinClock; - uint8_t _pinLoad; - - uint8_t* _buffer; - uint8_t _screens; - uint8_t _maximumX; - - void putByte(uint8_t); - void setRegister(uint8_t, uint8_t); - void syncRow(uint8_t); - - void setScanLimit(uint8_t); - - void buffer(uint8_t, uint8_t, uint8_t); - public: - Matrix(uint8_t, uint8_t, uint8_t, uint8_t = 1); - void setBrightness(uint8_t); - void write(uint8_t, uint8_t, uint8_t); - void write(uint8_t, uint8_t, Sprite); - void clear(void); -}; - -#endif - diff --git a/libraries/Matrix/examples/hello_matrix/hello_matrix.pde b/libraries/Matrix/examples/hello_matrix/hello_matrix.pde deleted file mode 100644 index 127917f0c..000000000 --- a/libraries/Matrix/examples/hello_matrix/hello_matrix.pde +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -// Hello Matrix -// by Nicholas Zambetti - -// Demonstrates the use of the Matrix library -// For MAX7219 LED Matrix Controllers -// Blinks welcoming face on screen - -// Created 13 February 2006 - -/* create a new Matrix instance - pin 0: data (din) - pin 1: load (load) - pin 2: clock (clk) -*/ -Matrix myMatrix = Matrix(0, 2, 1); - -void setup() -{ -} - -void loop() -{ - myMatrix.clear(); // clear display - - delay(1000); - - // turn some pixels on - myMatrix.write(1, 5, HIGH); - myMatrix.write(2, 2, HIGH); - myMatrix.write(2, 6, HIGH); - myMatrix.write(3, 6, HIGH); - myMatrix.write(4, 6, HIGH); - myMatrix.write(5, 2, HIGH); - myMatrix.write(5, 6, HIGH); - myMatrix.write(6, 5, HIGH); - - delay(1000); -} - diff --git a/libraries/Matrix/examples/sprite_animation/sprite_animation.pde b/libraries/Matrix/examples/sprite_animation/sprite_animation.pde deleted file mode 100644 index bf7c6f578..000000000 --- a/libraries/Matrix/examples/sprite_animation/sprite_animation.pde +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include - -// Sprite Animation -// by Nicholas Zambetti - -// Demonstrates the use of the Matrix & Sprite libraries -// Displays animated waveform graphic on screen - -// Created 29 March 2006 - -/* create a new Matrix instance - pin 0: data (din) - pin 1: load (load) - pin 2: clock (clk) -*/ -Matrix myMatrix = Matrix(0, 2, 1); - -/* create a new Sprite instance - 8 pixels wide, 4 pixels tall -*/ -Sprite wave = Sprite( - 8, 4, - B00011000, - B00100100, - B01000010, - B10000001 -); - -void setup() -{ -} - -int x = 0; - -void loop() -{ - myMatrix.write(x, 2, wave); // place sprite on screen - myMatrix.write(x - 8, 2, wave); // place sprite again, elsewhere on screen - delay(75); // wait a little bit - myMatrix.clear(); // clear the screen for next animation frame - if(x == 8) // if reached end of animation sequence - { - x = 0; // start from beginning - } - x++; // advance x coordinate to the right -} - diff --git a/libraries/Matrix/keywords.txt b/libraries/Matrix/keywords.txt deleted file mode 100644 index b784f874e..000000000 --- a/libraries/Matrix/keywords.txt +++ /dev/null @@ -1,22 +0,0 @@ -####################################### -# Syntax Coloring Map For Matrix -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -Matrix KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -setBrightness KEYWORD2 -write KEYWORD2 -clear KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - diff --git a/libraries/SD/File.cpp b/libraries/SD/File.cpp index ded622c85..ffd09471f 100644 --- a/libraries/SD/File.cpp +++ b/libraries/SD/File.cpp @@ -14,52 +14,138 @@ #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, 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 char *str) { + return write((const uint8_t *) str, strlen(str)); +} + +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->writeError()) { + setWriteError(); + return 0; + } + return t; } int File::peek() { - char 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() { + if (! _file) return 0; return size() - position(); } 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/README.txt b/libraries/SD/README.txt index 863e878c0..495ea4c79 100644 --- a/libraries/SD/README.txt +++ b/libraries/SD/README.txt @@ -9,3 +9,5 @@ License: GNU General Public License V3 (C) Copyright 2010 SparkFun Electronics +Now better than ever with optimization, multiple file support, directory handling, etc - ladyada! + diff --git a/libraries/SD/SD.cpp b/libraries/SD/SD.cpp index aca7468dd..64dc40b98 100644 --- a/libraries/SD/SD.cpp +++ b/libraries/SD/SD.cpp @@ -275,10 +275,10 @@ boolean callback_makeDirPath(SdFile& parentDir, char *filePathComponent, } + /* boolean callback_openPath(SdFile& parentDir, char *filePathComponent, boolean isLastComponent, void *object) { - /* Callback used to open a file specified by a filepath that may specify one or more directories above it. @@ -293,7 +293,6 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent, Returns false once the file has been opened--to prevent the traversal from descending further. (This may be unnecessary.) - */ if (isLastComponent) { SDClass *p_SD = static_cast(object); p_SD->file.open(parentDir, filePathComponent, p_SD->fileOpenMode); @@ -305,6 +304,8 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent, } return true; } + */ + boolean callback_remove(SdFile& parentDir, char *filePathComponent, @@ -345,6 +346,64 @@ boolean SDClass::begin(uint8_t csPin) { } + +// this little helper is used to traverse paths +SdFile SDClass::getParentDir(char *filepath, int *index) { + // get parent directory + SdFile d1 = root; // start with the mostparent, root! + SdFile d2; + + // we'll use the pointers to swap between the two objects + SdFile *parent = &d1; + SdFile *subdir = &d2; + + char *origpath = filepath; + + while (strchr(filepath, '/')) { + + // get rid of leading /'s + if (filepath[0] == '/') { + filepath++; + continue; + } + + if (! strchr(filepath, '/')) { + // it was in the root directory, so leave now + break; + } + + // extract just the name of the next subdirectory + uint8_t idx = strchr(filepath, '/') - filepath; + if (idx > 12) + idx = 12; // dont let them specify long names + char subdirname[13]; + strncpy(subdirname, filepath, idx); + subdirname[idx] = 0; + + // close the subdir (we reuse them) if open + subdir->close(); + if (! subdir->open(parent, subdirname, O_READ)) { + // failed to open one of the subdirectories + return SdFile(); + } + // move forward to the next subdirectory + filepath += idx; + + // we reuse the objects, close it. + parent->close(); + + // swap the pointers + SdFile *t = parent; + parent = subdir; + subdir = t; + } + + *index = (int)(filepath - origpath); + // parent is now the parent diretory of the file! + return *parent; +} + + File SDClass::open(char *filepath, uint8_t mode) { /* @@ -369,6 +428,72 @@ File SDClass::open(char *filepath, uint8_t mode) { */ + int pathidx; + + // do the interative search + SdFile parentdir = getParentDir(filepath, &pathidx); + // no more subdirs! + + filepath += pathidx; + + if (! filepath[0]) { + // it was the directory itself! + return File(parentdir, "/"); + } + + // Open the file itself + SdFile file; + + // failed to open a subdir! + if (!parentdir.isOpen()) + return File(); + + // there is a special case for the Root directory since its a static dir + if (parentdir.isRoot()) { + if ( ! file.open(SD.root, filepath, mode)) { + // failed to open the file :( + return File(); + } + // dont close the root! + } else { + if ( ! file.open(parentdir, filepath, mode)) { + return File(); + } + // close the parent + parentdir.close(); + } + + if (mode & (O_APPEND | O_WRITE)) + file.seekSet(file.fileSize()); + return File(file, filepath); +} + + +/* +File SDClass::open(char *filepath, uint8_t mode) { + // + + Open the supplied file path for reading or writing. + + The file content can be accessed via the `file` property of + the `SDClass` object--this property is currently + a standard `SdFile` object from `sdfatlib`. + + Defaults to read only. + + If `write` is true, default action (when `append` is true) is to + append data to the end of the file. + + If `append` is false then the file will be truncated first. + + If the file does not exist and it is opened for writing the file + will be created. + + An attempt to open a file for reading that does not exist is an + error. + + // + // TODO: Allow for read&write? (Possibly not, as it requires seek.) fileOpenMode = mode; @@ -377,6 +502,7 @@ File SDClass::open(char *filepath, uint8_t mode) { return File(); } +*/ //boolean SDClass::close() { @@ -436,4 +562,55 @@ boolean SDClass::remove(char *filepath) { return walkPath(filepath, root, callback_remove); } -SDClass SD; \ No newline at end of file + +// allows you to recurse into a directory +File File::openNextFile(uint8_t mode) { + dir_t p; + + //Serial.print("\t\treading dir..."); + while (_file->readDir(&p) > 0) { + + // done if past last used entry + if (p.name[0] == DIR_NAME_FREE) { + //Serial.println("end"); + return File(); + } + + // skip deleted entry and entries for . and .. + if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.') { + //Serial.println("dots"); + continue; + } + + // only list subdirectories and files + if (!DIR_IS_FILE_OR_SUBDIR(&p)) { + //Serial.println("notafile"); + continue; + } + + // print file name with possible blank fill + SdFile f; + char name[13]; + _file->dirName(p, name); + //Serial.print("try to open file "); + //Serial.println(name); + + if (f.open(_file, name, mode)) { + //Serial.println("OK!"); + return File(f, name); + } else { + //Serial.println("ugh"); + return File(); + } + } + + //Serial.println("nothing"); + return File(); +} + +void File::rewindDirectory(void) { + if (isDirectory()) + _file->rewind(); +} + +SDClass SD; diff --git a/libraries/SD/SD.h b/libraries/SD/SD.h index 2c5c323a8..cd123edc6 100644 --- a/libraries/SD/SD.h +++ b/libraries/SD/SD.h @@ -15,28 +15,41 @@ #ifndef __SD_H__ #define __SD_H__ -#include +#include #include #include #define FILE_READ O_READ -#define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_SYNC) +#define FILE_WRITE (O_READ | O_WRITE | O_CREAT) class File : public Stream { + private: + char _name[13]; // our name + SdFile *_file; // underlying file pointer + public: - virtual void write(uint8_t); - virtual void write(const char *str); - virtual void write(const uint8_t *buf, size_t size); + File(SdFile f, char *name); // wraps an underlying SdFile + File(void); // 'empty' constructor + ~File(void); // destructor + virtual size_t write(uint8_t); + virtual size_t write(const char *str); + virtual size_t write(const uint8_t *buf, size_t size); virtual int read(); virtual int peek(); virtual int available(); virtual void flush(); + int read(void *buf, uint16_t nbyte); boolean seek(uint32_t pos); uint32_t position(); uint32_t size(); void close(); operator bool(); + char * name(); + + boolean isDirectory(void); + File openNextFile(uint8_t mode = O_RDONLY); + void rewindDirectory(void); }; class SDClass { @@ -47,6 +60,8 @@ private: SdVolume volume; SdFile root; + // my quick&dirty iterator, should be replaced + SdFile getParentDir(char *filepath, int *indx); public: // This needs to be called to set up the connection to the SD card // before other methods are used. @@ -70,7 +85,6 @@ public: boolean rmdir(char *filepath); private: - SdFile file; // This is used to determine the mode used to open a file // it's here because it's the easiest place to pass the diff --git a/libraries/SD/examples/CardInfo/CardInfo.pde b/libraries/SD/examples/CardInfo/CardInfo.pde new file mode 100644 index 000000000..7abfd33e4 --- /dev/null +++ b/libraries/SD/examples/CardInfo/CardInfo.pde @@ -0,0 +1,111 @@ +/* + 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/SD/examples/listfiles/listfiles.pde b/libraries/SD/examples/listfiles/listfiles.pde new file mode 100644 index 000000000..b2435a2c6 --- /dev/null +++ b/libraries/SD/examples/listfiles/listfiles.pde @@ -0,0 +1,77 @@ +/* + SD card basic file example + + This example shows how to create and destroy an SD card file + The circuit: + * SD card attached to SPI bus as follows: + ** MOSI - pin 11 + ** MISO - pin 12 + ** CLK - pin 13 + ** CS - pin 4 + + created Nov 2010 + by David A. Mellis + updated 2 Dec 2010 + by Tom Igoe + + This example code is in the public domain. + + */ +#include + +File root; + +void setup() +{ + Serial.begin(9600); + Serial.print("Initializing 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); + + if (!SD.begin(10)) { + Serial.println("initialization failed!"); + return; + } + Serial.println("initialization done."); + + root = SD.open("/"); + + printDirectory(root, 0); + + Serial.println("done!"); +} + +void loop() +{ + // nothing happens after setup finishes. +} + +void printDirectory(File dir, int numTabs) { + while(true) { + + File entry = dir.openNextFile(); + if (! entry) { + // no more files + //Serial.println("**nomorefiles**"); + break; + } + for (uint8_t i=0; i. */ -#include +#include #include "Sd2Card.h" //------------------------------------------------------------------------------ #ifndef SOFTWARE_SPI diff --git a/libraries/SD/utility/SdFat.h b/libraries/SD/utility/SdFat.h index 048fa711e..344326f98 100644 --- a/libraries/SD/utility/SdFat.h +++ b/libraries/SD/utility/SdFat.h @@ -141,7 +141,7 @@ class SdFile : public Print { * Set writeError to false before calling print() and/or write() and check * for true after calls to print() and/or write(). */ - bool writeError; + //bool writeError; /** * Cancel unbuffered reads for this file. * See setUnbufferedRead() @@ -283,9 +283,9 @@ class SdFile : public Print { } /** \return SdVolume that contains this file. */ SdVolume* volume(void) const {return vol_;} - void write(uint8_t b); - int16_t write(const void* buf, uint16_t nbyte); - void write(const char* str); + size_t write(uint8_t b); + size_t write(const void* buf, uint16_t nbyte); + size_t write(const char* str); void write_P(PGM_P str); void writeln_P(PGM_P str); //------------------------------------------------------------------------------ diff --git a/libraries/SD/utility/SdFatUtil.h b/libraries/SD/utility/SdFatUtil.h index 8bf90483d..c626bfeb9 100644 --- a/libraries/SD/utility/SdFatUtil.h +++ b/libraries/SD/utility/SdFatUtil.h @@ -23,7 +23,7 @@ * \file * Useful utility functions. */ -#include +#include #include /** Store and print a string in flash memory.*/ #define PgmPrint(x) SerialPrint_P(PSTR(x)) diff --git a/libraries/SD/utility/SdFile.cpp b/libraries/SD/utility/SdFile.cpp index 3eb58f48a..47974e206 100644 --- a/libraries/SD/utility/SdFile.cpp +++ b/libraries/SD/utility/SdFile.cpp @@ -19,7 +19,7 @@ */ #include #include -#include +#include //------------------------------------------------------------------------------ // callback function for date/time void (*SdFile::dateTime_)(uint16_t* date, uint16_t* time) = NULL; @@ -1121,7 +1121,7 @@ uint8_t SdFile::truncate(uint32_t length) { * for a read-only file, device is full, a corrupt file system or an I/O error. * */ -int16_t SdFile::write(const void* buf, uint16_t nbyte) { +size_t SdFile::write(const void* buf, uint16_t nbyte) { // convert void* to uint8_t* - must be before goto statements const uint8_t* src = reinterpret_cast(buf); @@ -1210,8 +1210,9 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) { writeErrorReturn: // return for write error - writeError = true; - return -1; + //writeError = true; + setWriteError(); + return 0; } //------------------------------------------------------------------------------ /** @@ -1219,8 +1220,8 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) { * * Use SdFile::writeError to check for errors. */ -void SdFile::write(uint8_t b) { - write(&b, 1); +size_t SdFile::write(uint8_t b) { + return write(&b, 1); } //------------------------------------------------------------------------------ /** @@ -1228,8 +1229,8 @@ void SdFile::write(uint8_t b) { * * Use SdFile::writeError to check for errors. */ -void SdFile::write(const char* str) { - write(str, strlen(str)); +size_t SdFile::write(const char* str) { + return write(str, strlen(str)); } //------------------------------------------------------------------------------ /** diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h index 9d7c3c709..79c89d4d6 100644 --- a/libraries/SPI/SPI.h +++ b/libraries/SPI/SPI.h @@ -12,7 +12,7 @@ #define _SPI_H_INCLUDED #include -#include +#include #include #define SPI_CLOCK_DIV4 0x00 diff --git a/libraries/Servo/Servo.cpp b/libraries/Servo/Servo.cpp index 44e5aa5aa..acac29a86 100755 --- a/libraries/Servo/Servo.cpp +++ b/libraries/Servo/Servo.cpp @@ -43,7 +43,7 @@ */ #include -#include +#include #include "Servo.h" 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(); + + // 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/examples/TwoPortRXExample/TwoPortRXExample.pde b/libraries/SoftwareSerial/examples/TwoPortRXExample/TwoPortRXExample.pde new file mode 100755 index 000000000..1db4536de --- /dev/null +++ b/libraries/SoftwareSerial/examples/TwoPortRXExample/TwoPortRXExample.pde @@ -0,0 +1,50 @@ +#include + +SoftwareSerial ss(2, 3); +SoftwareSerial ss2(4, 5); + +/* This sample shows how to correctly process received data + on two different "soft" serial ports. Here we listen on + the first port (ss) until we receive a '?' character. Then + we begin listening on the other soft port. +*/ + +void setup() +{ + // Start the HW serial port + Serial.begin(57600); + + // Start each soft serial port + ss.begin(4800); + ss2.begin(4800); + + // By default, the most recently "begun" port is listening. + // We want to listen on ss, so let's explicitly select it. + ss.listen(); + + // Simply wait for a ? character to come down the pipe + Serial.println("Data from the first port: "); + char c = 0; + do + if (ss.available()) + { + c = (char)ss.read(); + Serial.print(c); + } + while (c != '?'); + + // Now listen on the second port + ss2.listen(); + + Serial.println("Data from the second port: "); +} + +void loop() +{ + if (ss2.available()) + { + char c = (char)ss2.read(); + Serial.print(c); + } +} + diff --git a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino new file mode 100644 index 000000000..e870c6fc1 --- /dev/null +++ b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino @@ -0,0 +1,78 @@ +/* + Software serial multple serial test + + Receives from the two software serial ports, + sends to the hardware serial port. + + In order to listen on a software port, you call port.listen(). + When using two software serial ports, you have to switch ports + by listen()ing on each one in turn. Pick a logical time to switch + ports, like the end of an expected transmission, or when the + buffer is empty. This example switches ports when there is nothing + more to read from a port + + The circuit: + Two devices which communicate serially are needed. + * First serial device's TX attached to digital pin 2, RX to pin 3 + * Second serial device's TX attached to digital pin 4, RX to pin 5 + + created 18 Apr. 2011 + by Tom Igoe + based on Mikal Hart's twoPortRXExample + + This example code is in the public domain. + + */ + +#include +// software serial #1: TX = digital pin 2, RX = digital pin 3 +SoftwareSerial portOne(2, 3); + +// software serial #2: TX = digital pin 4, RX = digital pin 5 +SoftwareSerial portTwo(4, 5); + +void setup() +{ + // Start the hardware serial port + Serial.begin(9600); + + // Start each software serial port + portOne.begin(9600); + portTwo.begin(9600); +} + +void loop() +{ + // By default, the last intialized port is listening. + // when you want to listen on a port, explicitly select it: + portOne.listen(); + Serial.println("Data from port one:"); + // while there is data coming in, read it + // and send to the hardware serial port: + while (portOne.available() > 0) { + char inByte = portOne.read(); + Serial.write(inByte); + } + + // blank line to separate data from the two ports: + Serial.println(); + + // Now listen on the second port + portTwo.listen(); + // while there is data coming in, read it + // and send to the hardware serial port: + Serial.println("Data from port two:"); + while (portTwo.available() > 0) { + char inByte = portTwo.read(); + Serial.write(inByte); + } + + // blank line to separate data from the two ports: + Serial.println(); +} + + + + + + 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) ####################################### diff --git a/libraries/Sprite/Sprite.cpp b/libraries/Sprite/Sprite.cpp deleted file mode 100644 index 605587610..000000000 --- a/libraries/Sprite/Sprite.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - Sprite.cpp - 2D sprite buffer library for Arduino & Wiring - 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 -*/ - -#include -#include -//#include - -#include "Sprite.h" - -void Sprite::init(uint8_t width, uint8_t height) -{ - _width = width >= 8 ? 8 : width; - _height = height >= 8 ? 8 : height; - - // for now, do nothing if this allocation fails. methods that require it - // should silently fail if _buffer is null. - _buffer = (uint8_t *) calloc(_height, 1); -} - -Sprite::Sprite(uint8_t width, uint8_t height) -{ - init(width, height); -} - -Sprite::Sprite(uint8_t width, uint8_t height, uint8_t row, ...) -{ - init(width, height); - - if (!_buffer) return; - - va_list ap; - va_start(ap, row); - - int y = 0; - - for (y = 0; ; y++) { - for (int x = 0; x < width && x < 8; x++) - write(x, y, (row >> (width - x - 1)) & 0x01); - - if (y == height - 1) - break; - - row = va_arg(ap, int); // using '...' promotes uint8_t to int - } - - va_end(ap); -} - -uint8_t Sprite::width() const -{ - return _width; -} - -uint8_t Sprite::height() const -{ - return _height; -} - -void Sprite::write(uint8_t x, uint8_t y, uint8_t value) -{ - if (!_buffer) return; - - // uint8_t's can't be negative, so don't test for negative x and y. - if (x >= _width || y >= _height) return; - - // we need to bitwise-or the value of the other pixels in the byte with - // the new value, masked and shifted into the proper bits. - _buffer[y] = (_buffer[y] & ~(0x01 << x)) | ((value & 0x01) << x); -} - -uint8_t Sprite::read(uint8_t x, uint8_t y) const -{ - if (!_buffer) return 0; - - // uint8_t's can't be negative, so don't test for negative x and y. - if (x >= _width || y >= _height) return 0; - - return (_buffer[y] >> x) & 0x01; -} diff --git a/libraries/Sprite/binary.h b/libraries/Sprite/binary.h deleted file mode 100644 index af1498033..000000000 --- a/libraries/Sprite/binary.h +++ /dev/null @@ -1,515 +0,0 @@ -#ifndef Binary_h -#define Binary_h - -#define B0 0 -#define B00 0 -#define B000 0 -#define B0000 0 -#define B00000 0 -#define B000000 0 -#define B0000000 0 -#define B00000000 0 -#define B1 1 -#define B01 1 -#define B001 1 -#define B0001 1 -#define B00001 1 -#define B000001 1 -#define B0000001 1 -#define B00000001 1 -#define B10 2 -#define B010 2 -#define B0010 2 -#define B00010 2 -#define B000010 2 -#define B0000010 2 -#define B00000010 2 -#define B11 3 -#define B011 3 -#define B0011 3 -#define B00011 3 -#define B000011 3 -#define B0000011 3 -#define B00000011 3 -#define B100 4 -#define B0100 4 -#define B00100 4 -#define B000100 4 -#define B0000100 4 -#define B00000100 4 -#define B101 5 -#define B0101 5 -#define B00101 5 -#define B000101 5 -#define B0000101 5 -#define B00000101 5 -#define B110 6 -#define B0110 6 -#define B00110 6 -#define B000110 6 -#define B0000110 6 -#define B00000110 6 -#define B111 7 -#define B0111 7 -#define B00111 7 -#define B000111 7 -#define B0000111 7 -#define B00000111 7 -#define B1000 8 -#define B01000 8 -#define B001000 8 -#define B0001000 8 -#define B00001000 8 -#define B1001 9 -#define B01001 9 -#define B001001 9 -#define B0001001 9 -#define B00001001 9 -#define B1010 10 -#define B01010 10 -#define B001010 10 -#define B0001010 10 -#define B00001010 10 -#define B1011 11 -#define B01011 11 -#define B001011 11 -#define B0001011 11 -#define B00001011 11 -#define B1100 12 -#define B01100 12 -#define B001100 12 -#define B0001100 12 -#define B00001100 12 -#define B1101 13 -#define B01101 13 -#define B001101 13 -#define B0001101 13 -#define B00001101 13 -#define B1110 14 -#define B01110 14 -#define B001110 14 -#define B0001110 14 -#define B00001110 14 -#define B1111 15 -#define B01111 15 -#define B001111 15 -#define B0001111 15 -#define B00001111 15 -#define B10000 16 -#define B010000 16 -#define B0010000 16 -#define B00010000 16 -#define B10001 17 -#define B010001 17 -#define B0010001 17 -#define B00010001 17 -#define B10010 18 -#define B010010 18 -#define B0010010 18 -#define B00010010 18 -#define B10011 19 -#define B010011 19 -#define B0010011 19 -#define B00010011 19 -#define B10100 20 -#define B010100 20 -#define B0010100 20 -#define B00010100 20 -#define B10101 21 -#define B010101 21 -#define B0010101 21 -#define B00010101 21 -#define B10110 22 -#define B010110 22 -#define B0010110 22 -#define B00010110 22 -#define B10111 23 -#define B010111 23 -#define B0010111 23 -#define B00010111 23 -#define B11000 24 -#define B011000 24 -#define B0011000 24 -#define B00011000 24 -#define B11001 25 -#define B011001 25 -#define B0011001 25 -#define B00011001 25 -#define B11010 26 -#define B011010 26 -#define B0011010 26 -#define B00011010 26 -#define B11011 27 -#define B011011 27 -#define B0011011 27 -#define B00011011 27 -#define B11100 28 -#define B011100 28 -#define B0011100 28 -#define B00011100 28 -#define B11101 29 -#define B011101 29 -#define B0011101 29 -#define B00011101 29 -#define B11110 30 -#define B011110 30 -#define B0011110 30 -#define B00011110 30 -#define B11111 31 -#define B011111 31 -#define B0011111 31 -#define B00011111 31 -#define B100000 32 -#define B0100000 32 -#define B00100000 32 -#define B100001 33 -#define B0100001 33 -#define B00100001 33 -#define B100010 34 -#define B0100010 34 -#define B00100010 34 -#define B100011 35 -#define B0100011 35 -#define B00100011 35 -#define B100100 36 -#define B0100100 36 -#define B00100100 36 -#define B100101 37 -#define B0100101 37 -#define B00100101 37 -#define B100110 38 -#define B0100110 38 -#define B00100110 38 -#define B100111 39 -#define B0100111 39 -#define B00100111 39 -#define B101000 40 -#define B0101000 40 -#define B00101000 40 -#define B101001 41 -#define B0101001 41 -#define B00101001 41 -#define B101010 42 -#define B0101010 42 -#define B00101010 42 -#define B101011 43 -#define B0101011 43 -#define B00101011 43 -#define B101100 44 -#define B0101100 44 -#define B00101100 44 -#define B101101 45 -#define B0101101 45 -#define B00101101 45 -#define B101110 46 -#define B0101110 46 -#define B00101110 46 -#define B101111 47 -#define B0101111 47 -#define B00101111 47 -#define B110000 48 -#define B0110000 48 -#define B00110000 48 -#define B110001 49 -#define B0110001 49 -#define B00110001 49 -#define B110010 50 -#define B0110010 50 -#define B00110010 50 -#define B110011 51 -#define B0110011 51 -#define B00110011 51 -#define B110100 52 -#define B0110100 52 -#define B00110100 52 -#define B110101 53 -#define B0110101 53 -#define B00110101 53 -#define B110110 54 -#define B0110110 54 -#define B00110110 54 -#define B110111 55 -#define B0110111 55 -#define B00110111 55 -#define B111000 56 -#define B0111000 56 -#define B00111000 56 -#define B111001 57 -#define B0111001 57 -#define B00111001 57 -#define B111010 58 -#define B0111010 58 -#define B00111010 58 -#define B111011 59 -#define B0111011 59 -#define B00111011 59 -#define B111100 60 -#define B0111100 60 -#define B00111100 60 -#define B111101 61 -#define B0111101 61 -#define B00111101 61 -#define B111110 62 -#define B0111110 62 -#define B00111110 62 -#define B111111 63 -#define B0111111 63 -#define B00111111 63 -#define B1000000 64 -#define B01000000 64 -#define B1000001 65 -#define B01000001 65 -#define B1000010 66 -#define B01000010 66 -#define B1000011 67 -#define B01000011 67 -#define B1000100 68 -#define B01000100 68 -#define B1000101 69 -#define B01000101 69 -#define B1000110 70 -#define B01000110 70 -#define B1000111 71 -#define B01000111 71 -#define B1001000 72 -#define B01001000 72 -#define B1001001 73 -#define B01001001 73 -#define B1001010 74 -#define B01001010 74 -#define B1001011 75 -#define B01001011 75 -#define B1001100 76 -#define B01001100 76 -#define B1001101 77 -#define B01001101 77 -#define B1001110 78 -#define B01001110 78 -#define B1001111 79 -#define B01001111 79 -#define B1010000 80 -#define B01010000 80 -#define B1010001 81 -#define B01010001 81 -#define B1010010 82 -#define B01010010 82 -#define B1010011 83 -#define B01010011 83 -#define B1010100 84 -#define B01010100 84 -#define B1010101 85 -#define B01010101 85 -#define B1010110 86 -#define B01010110 86 -#define B1010111 87 -#define B01010111 87 -#define B1011000 88 -#define B01011000 88 -#define B1011001 89 -#define B01011001 89 -#define B1011010 90 -#define B01011010 90 -#define B1011011 91 -#define B01011011 91 -#define B1011100 92 -#define B01011100 92 -#define B1011101 93 -#define B01011101 93 -#define B1011110 94 -#define B01011110 94 -#define B1011111 95 -#define B01011111 95 -#define B1100000 96 -#define B01100000 96 -#define B1100001 97 -#define B01100001 97 -#define B1100010 98 -#define B01100010 98 -#define B1100011 99 -#define B01100011 99 -#define B1100100 100 -#define B01100100 100 -#define B1100101 101 -#define B01100101 101 -#define B1100110 102 -#define B01100110 102 -#define B1100111 103 -#define B01100111 103 -#define B1101000 104 -#define B01101000 104 -#define B1101001 105 -#define B01101001 105 -#define B1101010 106 -#define B01101010 106 -#define B1101011 107 -#define B01101011 107 -#define B1101100 108 -#define B01101100 108 -#define B1101101 109 -#define B01101101 109 -#define B1101110 110 -#define B01101110 110 -#define B1101111 111 -#define B01101111 111 -#define B1110000 112 -#define B01110000 112 -#define B1110001 113 -#define B01110001 113 -#define B1110010 114 -#define B01110010 114 -#define B1110011 115 -#define B01110011 115 -#define B1110100 116 -#define B01110100 116 -#define B1110101 117 -#define B01110101 117 -#define B1110110 118 -#define B01110110 118 -#define B1110111 119 -#define B01110111 119 -#define B1111000 120 -#define B01111000 120 -#define B1111001 121 -#define B01111001 121 -#define B1111010 122 -#define B01111010 122 -#define B1111011 123 -#define B01111011 123 -#define B1111100 124 -#define B01111100 124 -#define B1111101 125 -#define B01111101 125 -#define B1111110 126 -#define B01111110 126 -#define B1111111 127 -#define B01111111 127 -#define B10000000 128 -#define B10000001 129 -#define B10000010 130 -#define B10000011 131 -#define B10000100 132 -#define B10000101 133 -#define B10000110 134 -#define B10000111 135 -#define B10001000 136 -#define B10001001 137 -#define B10001010 138 -#define B10001011 139 -#define B10001100 140 -#define B10001101 141 -#define B10001110 142 -#define B10001111 143 -#define B10010000 144 -#define B10010001 145 -#define B10010010 146 -#define B10010011 147 -#define B10010100 148 -#define B10010101 149 -#define B10010110 150 -#define B10010111 151 -#define B10011000 152 -#define B10011001 153 -#define B10011010 154 -#define B10011011 155 -#define B10011100 156 -#define B10011101 157 -#define B10011110 158 -#define B10011111 159 -#define B10100000 160 -#define B10100001 161 -#define B10100010 162 -#define B10100011 163 -#define B10100100 164 -#define B10100101 165 -#define B10100110 166 -#define B10100111 167 -#define B10101000 168 -#define B10101001 169 -#define B10101010 170 -#define B10101011 171 -#define B10101100 172 -#define B10101101 173 -#define B10101110 174 -#define B10101111 175 -#define B10110000 176 -#define B10110001 177 -#define B10110010 178 -#define B10110011 179 -#define B10110100 180 -#define B10110101 181 -#define B10110110 182 -#define B10110111 183 -#define B10111000 184 -#define B10111001 185 -#define B10111010 186 -#define B10111011 187 -#define B10111100 188 -#define B10111101 189 -#define B10111110 190 -#define B10111111 191 -#define B11000000 192 -#define B11000001 193 -#define B11000010 194 -#define B11000011 195 -#define B11000100 196 -#define B11000101 197 -#define B11000110 198 -#define B11000111 199 -#define B11001000 200 -#define B11001001 201 -#define B11001010 202 -#define B11001011 203 -#define B11001100 204 -#define B11001101 205 -#define B11001110 206 -#define B11001111 207 -#define B11010000 208 -#define B11010001 209 -#define B11010010 210 -#define B11010011 211 -#define B11010100 212 -#define B11010101 213 -#define B11010110 214 -#define B11010111 215 -#define B11011000 216 -#define B11011001 217 -#define B11011010 218 -#define B11011011 219 -#define B11011100 220 -#define B11011101 221 -#define B11011110 222 -#define B11011111 223 -#define B11100000 224 -#define B11100001 225 -#define B11100010 226 -#define B11100011 227 -#define B11100100 228 -#define B11100101 229 -#define B11100110 230 -#define B11100111 231 -#define B11101000 232 -#define B11101001 233 -#define B11101010 234 -#define B11101011 235 -#define B11101100 236 -#define B11101101 237 -#define B11101110 238 -#define B11101111 239 -#define B11110000 240 -#define B11110001 241 -#define B11110010 242 -#define B11110011 243 -#define B11110100 244 -#define B11110101 245 -#define B11110110 246 -#define B11110111 247 -#define B11111000 248 -#define B11111001 249 -#define B11111010 250 -#define B11111011 251 -#define B11111100 252 -#define B11111101 253 -#define B11111110 254 -#define B11111111 255 - -#endif diff --git a/libraries/Sprite/keywords.txt b/libraries/Sprite/keywords.txt deleted file mode 100644 index 73cd8d9dc..000000000 --- a/libraries/Sprite/keywords.txt +++ /dev/null @@ -1,534 +0,0 @@ -####################################### -# Syntax Coloring Map For Sprite -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -Sprite KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -width KEYWORD2 -height KEYWORD2 -write KEYWORD2 -read KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - -B0 LITERAL1 -B00 LITERAL1 -B000 LITERAL1 -B0000 LITERAL1 -B00000 LITERAL1 -B000000 LITERAL1 -B0000000 LITERAL1 -B00000000 LITERAL1 -B1 LITERAL1 -B01 LITERAL1 -B001 LITERAL1 -B0001 LITERAL1 -B00001 LITERAL1 -B000001 LITERAL1 -B0000001 LITERAL1 -B00000001 LITERAL1 -B10 LITERAL1 -B010 LITERAL1 -B0010 LITERAL1 -B00010 LITERAL1 -B000010 LITERAL1 -B0000010 LITERAL1 -B00000010 LITERAL1 -B11 LITERAL1 -B011 LITERAL1 -B0011 LITERAL1 -B00011 LITERAL1 -B000011 LITERAL1 -B0000011 LITERAL1 -B00000011 LITERAL1 -B100 LITERAL1 -B0100 LITERAL1 -B00100 LITERAL1 -B000100 LITERAL1 -B0000100 LITERAL1 -B00000100 LITERAL1 -B101 LITERAL1 -B0101 LITERAL1 -B00101 LITERAL1 -B000101 LITERAL1 -B0000101 LITERAL1 -B00000101 LITERAL1 -B110 LITERAL1 -B0110 LITERAL1 -B00110 LITERAL1 -B000110 LITERAL1 -B0000110 LITERAL1 -B00000110 LITERAL1 -B111 LITERAL1 -B0111 LITERAL1 -B00111 LITERAL1 -B000111 LITERAL1 -B0000111 LITERAL1 -B00000111 LITERAL1 -B1000 LITERAL1 -B01000 LITERAL1 -B001000 LITERAL1 -B0001000 LITERAL1 -B00001000 LITERAL1 -B1001 LITERAL1 -B01001 LITERAL1 -B001001 LITERAL1 -B0001001 LITERAL1 -B00001001 LITERAL1 -B1010 LITERAL1 -B01010 LITERAL1 -B001010 LITERAL1 -B0001010 LITERAL1 -B00001010 LITERAL1 -B1011 LITERAL1 -B01011 LITERAL1 -B001011 LITERAL1 -B0001011 LITERAL1 -B00001011 LITERAL1 -B1100 LITERAL1 -B01100 LITERAL1 -B001100 LITERAL1 -B0001100 LITERAL1 -B00001100 LITERAL1 -B1101 LITERAL1 -B01101 LITERAL1 -B001101 LITERAL1 -B0001101 LITERAL1 -B00001101 LITERAL1 -B1110 LITERAL1 -B01110 LITERAL1 -B001110 LITERAL1 -B0001110 LITERAL1 -B00001110 LITERAL1 -B1111 LITERAL1 -B01111 LITERAL1 -B001111 LITERAL1 -B0001111 LITERAL1 -B00001111 LITERAL1 -B10000 LITERAL1 -B010000 LITERAL1 -B0010000 LITERAL1 -B00010000 LITERAL1 -B10001 LITERAL1 -B010001 LITERAL1 -B0010001 LITERAL1 -B00010001 LITERAL1 -B10010 LITERAL1 -B010010 LITERAL1 -B0010010 LITERAL1 -B00010010 LITERAL1 -B10011 LITERAL1 -B010011 LITERAL1 -B0010011 LITERAL1 -B00010011 LITERAL1 -B10100 LITERAL1 -B010100 LITERAL1 -B0010100 LITERAL1 -B00010100 LITERAL1 -B10101 LITERAL1 -B010101 LITERAL1 -B0010101 LITERAL1 -B00010101 LITERAL1 -B10110 LITERAL1 -B010110 LITERAL1 -B0010110 LITERAL1 -B00010110 LITERAL1 -B10111 LITERAL1 -B010111 LITERAL1 -B0010111 LITERAL1 -B00010111 LITERAL1 -B11000 LITERAL1 -B011000 LITERAL1 -B0011000 LITERAL1 -B00011000 LITERAL1 -B11001 LITERAL1 -B011001 LITERAL1 -B0011001 LITERAL1 -B00011001 LITERAL1 -B11010 LITERAL1 -B011010 LITERAL1 -B0011010 LITERAL1 -B00011010 LITERAL1 -B11011 LITERAL1 -B011011 LITERAL1 -B0011011 LITERAL1 -B00011011 LITERAL1 -B11100 LITERAL1 -B011100 LITERAL1 -B0011100 LITERAL1 -B00011100 LITERAL1 -B11101 LITERAL1 -B011101 LITERAL1 -B0011101 LITERAL1 -B00011101 LITERAL1 -B11110 LITERAL1 -B011110 LITERAL1 -B0011110 LITERAL1 -B00011110 LITERAL1 -B11111 LITERAL1 -B011111 LITERAL1 -B0011111 LITERAL1 -B00011111 LITERAL1 -B100000 LITERAL1 -B0100000 LITERAL1 -B00100000 LITERAL1 -B100001 LITERAL1 -B0100001 LITERAL1 -B00100001 LITERAL1 -B100010 LITERAL1 -B0100010 LITERAL1 -B00100010 LITERAL1 -B100011 LITERAL1 -B0100011 LITERAL1 -B00100011 LITERAL1 -B100100 LITERAL1 -B0100100 LITERAL1 -B00100100 LITERAL1 -B100101 LITERAL1 -B0100101 LITERAL1 -B00100101 LITERAL1 -B100110 LITERAL1 -B0100110 LITERAL1 -B00100110 LITERAL1 -B100111 LITERAL1 -B0100111 LITERAL1 -B00100111 LITERAL1 -B101000 LITERAL1 -B0101000 LITERAL1 -B00101000 LITERAL1 -B101001 LITERAL1 -B0101001 LITERAL1 -B00101001 LITERAL1 -B101010 LITERAL1 -B0101010 LITERAL1 -B00101010 LITERAL1 -B101011 LITERAL1 -B0101011 LITERAL1 -B00101011 LITERAL1 -B101100 LITERAL1 -B0101100 LITERAL1 -B00101100 LITERAL1 -B101101 LITERAL1 -B0101101 LITERAL1 -B00101101 LITERAL1 -B101110 LITERAL1 -B0101110 LITERAL1 -B00101110 LITERAL1 -B101111 LITERAL1 -B0101111 LITERAL1 -B00101111 LITERAL1 -B110000 LITERAL1 -B0110000 LITERAL1 -B00110000 LITERAL1 -B110001 LITERAL1 -B0110001 LITERAL1 -B00110001 LITERAL1 -B110010 LITERAL1 -B0110010 LITERAL1 -B00110010 LITERAL1 -B110011 LITERAL1 -B0110011 LITERAL1 -B00110011 LITERAL1 -B110100 LITERAL1 -B0110100 LITERAL1 -B00110100 LITERAL1 -B110101 LITERAL1 -B0110101 LITERAL1 -B00110101 LITERAL1 -B110110 LITERAL1 -B0110110 LITERAL1 -B00110110 LITERAL1 -B110111 LITERAL1 -B0110111 LITERAL1 -B00110111 LITERAL1 -B111000 LITERAL1 -B0111000 LITERAL1 -B00111000 LITERAL1 -B111001 LITERAL1 -B0111001 LITERAL1 -B00111001 LITERAL1 -B111010 LITERAL1 -B0111010 LITERAL1 -B00111010 LITERAL1 -B111011 LITERAL1 -B0111011 LITERAL1 -B00111011 LITERAL1 -B111100 LITERAL1 -B0111100 LITERAL1 -B00111100 LITERAL1 -B111101 LITERAL1 -B0111101 LITERAL1 -B00111101 LITERAL1 -B111110 LITERAL1 -B0111110 LITERAL1 -B00111110 LITERAL1 -B111111 LITERAL1 -B0111111 LITERAL1 -B00111111 LITERAL1 -B1000000 LITERAL1 -B01000000 LITERAL1 -B1000001 LITERAL1 -B01000001 LITERAL1 -B1000010 LITERAL1 -B01000010 LITERAL1 -B1000011 LITERAL1 -B01000011 LITERAL1 -B1000100 LITERAL1 -B01000100 LITERAL1 -B1000101 LITERAL1 -B01000101 LITERAL1 -B1000110 LITERAL1 -B01000110 LITERAL1 -B1000111 LITERAL1 -B01000111 LITERAL1 -B1001000 LITERAL1 -B01001000 LITERAL1 -B1001001 LITERAL1 -B01001001 LITERAL1 -B1001010 LITERAL1 -B01001010 LITERAL1 -B1001011 LITERAL1 -B01001011 LITERAL1 -B1001100 LITERAL1 -B01001100 LITERAL1 -B1001101 LITERAL1 -B01001101 LITERAL1 -B1001110 LITERAL1 -B01001110 LITERAL1 -B1001111 LITERAL1 -B01001111 LITERAL1 -B1010000 LITERAL1 -B01010000 LITERAL1 -B1010001 LITERAL1 -B01010001 LITERAL1 -B1010010 LITERAL1 -B01010010 LITERAL1 -B1010011 LITERAL1 -B01010011 LITERAL1 -B1010100 LITERAL1 -B01010100 LITERAL1 -B1010101 LITERAL1 -B01010101 LITERAL1 -B1010110 LITERAL1 -B01010110 LITERAL1 -B1010111 LITERAL1 -B01010111 LITERAL1 -B1011000 LITERAL1 -B01011000 LITERAL1 -B1011001 LITERAL1 -B01011001 LITERAL1 -B1011010 LITERAL1 -B01011010 LITERAL1 -B1011011 LITERAL1 -B01011011 LITERAL1 -B1011100 LITERAL1 -B01011100 LITERAL1 -B1011101 LITERAL1 -B01011101 LITERAL1 -B1011110 LITERAL1 -B01011110 LITERAL1 -B1011111 LITERAL1 -B01011111 LITERAL1 -B1100000 LITERAL1 -B01100000 LITERAL1 -B1100001 LITERAL1 -B01100001 LITERAL1 -B1100010 LITERAL1 -B01100010 LITERAL1 -B1100011 LITERAL1 -B01100011 LITERAL1 -B1100100 LITERAL1 -B01100100 LITERAL1 -B1100101 LITERAL1 -B01100101 LITERAL1 -B1100110 LITERAL1 -B01100110 LITERAL1 -B1100111 LITERAL1 -B01100111 LITERAL1 -B1101000 LITERAL1 -B01101000 LITERAL1 -B1101001 LITERAL1 -B01101001 LITERAL1 -B1101010 LITERAL1 -B01101010 LITERAL1 -B1101011 LITERAL1 -B01101011 LITERAL1 -B1101100 LITERAL1 -B01101100 LITERAL1 -B1101101 LITERAL1 -B01101101 LITERAL1 -B1101110 LITERAL1 -B01101110 LITERAL1 -B1101111 LITERAL1 -B01101111 LITERAL1 -B1110000 LITERAL1 -B01110000 LITERAL1 -B1110001 LITERAL1 -B01110001 LITERAL1 -B1110010 LITERAL1 -B01110010 LITERAL1 -B1110011 LITERAL1 -B01110011 LITERAL1 -B1110100 LITERAL1 -B01110100 LITERAL1 -B1110101 LITERAL1 -B01110101 LITERAL1 -B1110110 LITERAL1 -B01110110 LITERAL1 -B1110111 LITERAL1 -B01110111 LITERAL1 -B1111000 LITERAL1 -B01111000 LITERAL1 -B1111001 LITERAL1 -B01111001 LITERAL1 -B1111010 LITERAL1 -B01111010 LITERAL1 -B1111011 LITERAL1 -B01111011 LITERAL1 -B1111100 LITERAL1 -B01111100 LITERAL1 -B1111101 LITERAL1 -B01111101 LITERAL1 -B1111110 LITERAL1 -B01111110 LITERAL1 -B1111111 LITERAL1 -B01111111 LITERAL1 -B10000000 LITERAL1 -B10000001 LITERAL1 -B10000010 LITERAL1 -B10000011 LITERAL1 -B10000100 LITERAL1 -B10000101 LITERAL1 -B10000110 LITERAL1 -B10000111 LITERAL1 -B10001000 LITERAL1 -B10001001 LITERAL1 -B10001010 LITERAL1 -B10001011 LITERAL1 -B10001100 LITERAL1 -B10001101 LITERAL1 -B10001110 LITERAL1 -B10001111 LITERAL1 -B10010000 LITERAL1 -B10010001 LITERAL1 -B10010010 LITERAL1 -B10010011 LITERAL1 -B10010100 LITERAL1 -B10010101 LITERAL1 -B10010110 LITERAL1 -B10010111 LITERAL1 -B10011000 LITERAL1 -B10011001 LITERAL1 -B10011010 LITERAL1 -B10011011 LITERAL1 -B10011100 LITERAL1 -B10011101 LITERAL1 -B10011110 LITERAL1 -B10011111 LITERAL1 -B10100000 LITERAL1 -B10100001 LITERAL1 -B10100010 LITERAL1 -B10100011 LITERAL1 -B10100100 LITERAL1 -B10100101 LITERAL1 -B10100110 LITERAL1 -B10100111 LITERAL1 -B10101000 LITERAL1 -B10101001 LITERAL1 -B10101010 LITERAL1 -B10101011 LITERAL1 -B10101100 LITERAL1 -B10101101 LITERAL1 -B10101110 LITERAL1 -B10101111 LITERAL1 -B10110000 LITERAL1 -B10110001 LITERAL1 -B10110010 LITERAL1 -B10110011 LITERAL1 -B10110100 LITERAL1 -B10110101 LITERAL1 -B10110110 LITERAL1 -B10110111 LITERAL1 -B10111000 LITERAL1 -B10111001 LITERAL1 -B10111010 LITERAL1 -B10111011 LITERAL1 -B10111100 LITERAL1 -B10111101 LITERAL1 -B10111110 LITERAL1 -B10111111 LITERAL1 -B11000000 LITERAL1 -B11000001 LITERAL1 -B11000010 LITERAL1 -B11000011 LITERAL1 -B11000100 LITERAL1 -B11000101 LITERAL1 -B11000110 LITERAL1 -B11000111 LITERAL1 -B11001000 LITERAL1 -B11001001 LITERAL1 -B11001010 LITERAL1 -B11001011 LITERAL1 -B11001100 LITERAL1 -B11001101 LITERAL1 -B11001110 LITERAL1 -B11001111 LITERAL1 -B11010000 LITERAL1 -B11010001 LITERAL1 -B11010010 LITERAL1 -B11010011 LITERAL1 -B11010100 LITERAL1 -B11010101 LITERAL1 -B11010110 LITERAL1 -B11010111 LITERAL1 -B11011000 LITERAL1 -B11011001 LITERAL1 -B11011010 LITERAL1 -B11011011 LITERAL1 -B11011100 LITERAL1 -B11011101 LITERAL1 -B11011110 LITERAL1 -B11011111 LITERAL1 -B11100000 LITERAL1 -B11100001 LITERAL1 -B11100010 LITERAL1 -B11100011 LITERAL1 -B11100100 LITERAL1 -B11100101 LITERAL1 -B11100110 LITERAL1 -B11100111 LITERAL1 -B11101000 LITERAL1 -B11101001 LITERAL1 -B11101010 LITERAL1 -B11101011 LITERAL1 -B11101100 LITERAL1 -B11101101 LITERAL1 -B11101110 LITERAL1 -B11101111 LITERAL1 -B11110000 LITERAL1 -B11110001 LITERAL1 -B11110010 LITERAL1 -B11110011 LITERAL1 -B11110100 LITERAL1 -B11110101 LITERAL1 -B11110110 LITERAL1 -B11110111 LITERAL1 -B11111000 LITERAL1 -B11111001 LITERAL1 -B11111010 LITERAL1 -B11111011 LITERAL1 -B11111100 LITERAL1 -B11111101 LITERAL1 -B11111110 LITERAL1 -B11111111 LITERAL1 - diff --git a/libraries/Stepper/Stepper.cpp b/libraries/Stepper/Stepper.cpp index d5c16a3b4..5d6b5e536 100644 --- a/libraries/Stepper/Stepper.cpp +++ b/libraries/Stepper/Stepper.cpp @@ -45,7 +45,7 @@ http://www.arduino.cc/en/Tutorial/Stepper */ -#include "WProgram.h" +#include "Arduino.h" #include "Stepper.h" /* diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index 849439bf7..211d9c7ef 100755 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -124,13 +124,14 @@ uint8_t TwoWire::endTransmission(void) // must be called in: // slave tx event callback // or after beginTransmission(address) -void TwoWire::send(uint8_t data) +size_t TwoWire::write(uint8_t data) { if(transmitting){ // in master transmitter mode // don't bother if buffer is full if(txBufferLength >= BUFFER_LENGTH){ - return; + setWriteError(); + return 0; } // put byte in tx buffer txBuffer[txBufferIndex] = data; @@ -142,45 +143,39 @@ void TwoWire::send(uint8_t data) // reply to master twi_transmit(&data, 1); } + return 1; } // must be called in: // slave tx event callback // or after beginTransmission(address) -void TwoWire::send(uint8_t* data, uint8_t quantity) +size_t TwoWire::write(const uint8_t *data, size_t quantity) { if(transmitting){ // in master transmitter mode - for(uint8_t i = 0; i < quantity; ++i){ - send(data[i]); + for(size_t i = 0; i < quantity; ++i){ + write(data[i]); } }else{ // in slave send mode // reply to master twi_transmit(data, quantity); } + return quantity; } // must be called in: // slave tx event callback // or after beginTransmission(address) -void TwoWire::send(char* data) +size_t TwoWire::write(const char *data) { - send((uint8_t*)data, strlen(data)); -} - -// must be called in: -// slave tx event callback -// or after beginTransmission(address) -void TwoWire::send(int data) -{ - send((uint8_t)data); + return write((uint8_t*)data, strlen(data)); } // must be called in: // slave rx event callback // or after requestFrom(address, numBytes) -uint8_t TwoWire::available(void) +int TwoWire::available(void) { return rxBufferLength - rxBufferIndex; } @@ -188,11 +183,9 @@ uint8_t TwoWire::available(void) // must be called in: // slave rx event callback // or after requestFrom(address, numBytes) -uint8_t TwoWire::receive(void) +int TwoWire::read(void) { - // default to returning null char - // for people using with char strings - uint8_t value = '\0'; + int value = -1; // get each successive byte on each call if(rxBufferIndex < rxBufferLength){ @@ -203,6 +196,25 @@ uint8_t TwoWire::receive(void) return value; } +// must be called in: +// slave rx event callback +// or after requestFrom(address, numBytes) +int TwoWire::peek(void) +{ + int value = -1; + + if(rxBufferIndex < rxBufferLength){ + value = rxBuffer[rxBufferIndex]; + } + + return value; +} + +void TwoWire::flush(void) +{ + // XXX: to be implemented. +} + // behind the scenes function that is called when data is received void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes) { diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h index a6c29c493..7f6ea67ad 100755 --- a/libraries/Wire/Wire.h +++ b/libraries/Wire/Wire.h @@ -21,10 +21,11 @@ #define TwoWire_h #include +#include "Stream.h" #define BUFFER_LENGTH 32 -class TwoWire +class TwoWire : public Stream { private: static uint8_t rxBuffer[]; @@ -51,12 +52,13 @@ class TwoWire uint8_t endTransmission(void); uint8_t requestFrom(uint8_t, uint8_t); uint8_t requestFrom(int, int); - void send(uint8_t); - void send(uint8_t*, uint8_t); - void send(int); - void send(char*); - uint8_t available(void); - uint8_t receive(void); + virtual size_t write(uint8_t); + virtual size_t write(const char *); + virtual size_t write(const uint8_t *, size_t); + virtual int available(void); + virtual int read(void); + virtual int peek(void); + virtual void flush(void); void onReceive( void (*)(int) ); void onRequest( void (*)(void) ); }; diff --git a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde index 4bb4b83e8..9c41c18f1 100755 --- a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde +++ b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde @@ -26,8 +26,8 @@ void loop() Wire.beginTransmission(112); // transmit to device #112 (0x70) // the address specified in the datasheet is 224 (0xE0) // but i2c adressing uses the high 7 bits so it's 112 - Wire.send(0x00); // sets register pointer to the command register (0x00) - Wire.send(0x50); // command sensor to measure in "inches" (0x50) + Wire.write(byte(0x00)); // sets register pointer to the command register (0x00) + Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50) // use 0x51 for centimeters // use 0x52 for ping microseconds Wire.endTransmission(); // stop transmitting @@ -37,7 +37,7 @@ void loop() // step 3: instruct sensor to return a particular echo reading Wire.beginTransmission(112); // transmit to device #112 - Wire.send(0x02); // sets register pointer to echo #1 register (0x02) + Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02) Wire.endTransmission(); // stop transmitting // step 4: request reading from sensor @@ -46,9 +46,9 @@ void loop() // step 5: receive reading from sensor if(2 <= Wire.available()) // if two bytes were received { - reading = Wire.receive(); // receive high byte (overwrites previous reading) + reading = Wire.read(); // receive high byte (overwrites previous reading) reading = reading << 8; // shift high byte to be high 8 bits - reading |= Wire.receive(); // receive low byte as lower 8 bits + reading |= Wire.read(); // receive low byte as lower 8 bits Serial.println(reading); // print the reading } @@ -64,23 +64,23 @@ void loop() void changeAddress(byte oldAddress, byte newAddress) { Wire.beginTransmission(oldAddress); - Wire.send(0x00); - Wire.send(0xA0); + Wire.write(byte(0x00)); + Wire.write(byte(0xA0)); Wire.endTransmission(); Wire.beginTransmission(oldAddress); - Wire.send(0x00); - Wire.send(0xAA); + Wire.write(byte(0x00)); + Wire.write(byte(0xAA)); Wire.endTransmission(); Wire.beginTransmission(oldAddress); - Wire.send(0x00); - Wire.send(0xA5); + Wire.write(byte(0x00)); + Wire.write(byte(0xA5)); Wire.endTransmission(); Wire.beginTransmission(oldAddress); - Wire.send(0x00); - Wire.send(newAddress); + Wire.write(byte(0x00)); + Wire.write(newAddress); Wire.endTransmission(); } diff --git a/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde b/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde index 00a15cc3e..38da1c543 100644 --- a/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde +++ b/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde @@ -25,8 +25,8 @@ void loop() { Wire.beginTransmission(44); // transmit to device #44 (0x2c) // device address is specified in datasheet - Wire.send(0x00); // sends instruction byte - Wire.send(val); // sends potentiometer value byte + Wire.write(byte(0x00)); // sends instruction byte + Wire.write(val); // sends potentiometer value byte Wire.endTransmission(); // stop transmitting val++; // increment value diff --git a/libraries/Wire/examples/master_reader/master_reader.pde b/libraries/Wire/examples/master_reader/master_reader.pde index 4e0ffbaca..4124d7d6b 100644 --- a/libraries/Wire/examples/master_reader/master_reader.pde +++ b/libraries/Wire/examples/master_reader/master_reader.pde @@ -24,7 +24,7 @@ void loop() while(Wire.available()) // slave may send less than requested { - char c = Wire.receive(); // receive a byte as character + char c = Wire.read(); // receive a byte as character Serial.print(c); // print the character } diff --git a/libraries/Wire/examples/master_writer/master_writer.pde b/libraries/Wire/examples/master_writer/master_writer.pde index 5278787ec..ccaa0361b 100644 --- a/libraries/Wire/examples/master_writer/master_writer.pde +++ b/libraries/Wire/examples/master_writer/master_writer.pde @@ -22,8 +22,8 @@ byte x = 0; void loop() { Wire.beginTransmission(4); // transmit to device #4 - Wire.send("x is "); // sends five bytes - Wire.send(x); // sends one byte + Wire.write("x is "); // sends five bytes + Wire.write(x); // sends one byte Wire.endTransmission(); // stop transmitting x++; diff --git a/libraries/Wire/examples/slave_receiver/slave_receiver.pde b/libraries/Wire/examples/slave_receiver/slave_receiver.pde index 3e85f3dff..60dd4bdde 100644 --- a/libraries/Wire/examples/slave_receiver/slave_receiver.pde +++ b/libraries/Wire/examples/slave_receiver/slave_receiver.pde @@ -30,9 +30,9 @@ void receiveEvent(int howMany) { while(1 < Wire.available()) // loop through all but the last { - char c = Wire.receive(); // receive byte as a character + char c = Wire.read(); // receive byte as a character Serial.print(c); // print the character } - int x = Wire.receive(); // receive byte as an integer + int x = Wire.read(); // receive byte as an integer Serial.println(x); // print the integer } diff --git a/libraries/Wire/examples/slave_sender/slave_sender.pde b/libraries/Wire/examples/slave_sender/slave_sender.pde index e19f0e7be..d3b238af9 100644 --- a/libraries/Wire/examples/slave_sender/slave_sender.pde +++ b/libraries/Wire/examples/slave_sender/slave_sender.pde @@ -27,6 +27,6 @@ void loop() // this function is registered as an event, see setup() void requestEvent() { - Wire.send("hello "); // respond with message of 6 bytes + Wire.write("hello "); // respond with message of 6 bytes // as expected by master } diff --git a/libraries/Wire/utility/twi.c b/libraries/Wire/utility/twi.c index 236878c4a..cef8373a8 100644 --- a/libraries/Wire/utility/twi.c +++ b/libraries/Wire/utility/twi.c @@ -79,7 +79,7 @@ void twi_init(void) // initialize twi prescaler and bit rate cbi(TWSR, TWPS0); cbi(TWSR, TWPS1); - TWBR = ((CPU_FREQ / TWI_FREQ) - 16) / 2; + TWBR = ((F_CPU / TWI_FREQ) - 16) / 2; /* twi bit rate formula from atmega128 manual pg 204 SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR)) @@ -232,7 +232,7 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait * 2 not slave transmitter * 0 ok */ -uint8_t twi_transmit(uint8_t* data, uint8_t length) +uint8_t twi_transmit(const uint8_t* data, uint8_t length) { uint8_t i; diff --git a/libraries/Wire/utility/twi.h b/libraries/Wire/utility/twi.h index 1258d8d38..831b9282a 100755 --- a/libraries/Wire/utility/twi.h +++ b/libraries/Wire/utility/twi.h @@ -24,10 +24,6 @@ //#define ATMEGA8 - #ifndef CPU_FREQ - #define CPU_FREQ 16000000L - #endif - #ifndef TWI_FREQ #define TWI_FREQ 100000L #endif @@ -46,7 +42,7 @@ void twi_setAddress(uint8_t); uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t); uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t); - uint8_t twi_transmit(uint8_t*, uint8_t); + uint8_t twi_transmit(const uint8_t*, uint8_t); void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) ); void twi_attachSlaveTxEvent( void (*)(void) ); void twi_reply(uint8_t); diff --git a/todo.txt b/todo.txt index 46f473935..ea97bf2f0 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,4 @@ -0022 arduino +0100 arduino Fix Linux make.sh, etc. scripts Test on Linux.