diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 2e3d7b346..2326dbc80 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1722,6 +1722,10 @@ public class Base { * Give this Frame a Processing icon. */ static public void setIcon(Frame frame) { + // don't use the low-res icon on Mac OS X; the window should + // already have the right icon from the .app file. + if (Base.isMacOS()) return; + Image image = Toolkit.getDefaultToolkit().createImage(PApplet.ICON_IMAGE); frame.setIconImage(image); } diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index 3c1548fbd..72fb7bafd 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -17,6 +17,7 @@ import javax.swing.event.*; import javax.swing.text.*; import javax.swing.undo.*; import javax.swing.*; + import java.awt.datatransfer.*; import java.awt.event.*; import java.awt.*; @@ -2025,7 +2026,19 @@ public class JEditTextArea extends JComponent select(getMarkPosition(),xyToOffset(evt.getX(),evt.getY())); } - public void mouseMoved(MouseEvent evt) {} + final Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR); + final Cursor handCursor = new Cursor(Cursor.HAND_CURSOR); + + public void mouseMoved(MouseEvent evt) { + int line = yToLine(evt.getY()); + int offset = xToOffset(line, evt.getX()); + boolean wantHandCursor = checkClickedURL(getLineText(line), offset) != null; + JComponent src = (JComponent) evt.getSource(); + if (wantHandCursor) + src.setCursor(handCursor); + else + src.setCursor(normalCursor); + } } class FocusHandler implements FocusListener diff --git a/build/build.xml b/build/build.xml index d6e00e2bd..c87c96179 100644 --- a/build/build.xml +++ b/build/build.xml @@ -228,9 +228,7 @@ - - - + diff --git a/build/shared/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.pde b/build/shared/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.ino similarity index 86% rename from build/shared/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.pde rename to build/shared/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.ino index 97243f325..2ba6fa73b 100644 --- a/build/shared/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.pde +++ b/build/shared/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.ino @@ -11,5 +11,5 @@ void setup() { void loop() { int sensorValue = analogRead(A0); - Serial.println(sensorValue, DEC); + Serial.println(sensorValue); } diff --git a/build/shared/examples/1.Basics/BareMinimum/BareMinimum.pde b/build/shared/examples/1.Basics/BareMinimum/BareMinimum.ino similarity index 100% rename from build/shared/examples/1.Basics/BareMinimum/BareMinimum.pde rename to build/shared/examples/1.Basics/BareMinimum/BareMinimum.ino diff --git a/build/shared/examples/1.Basics/Blink/Blink.pde b/build/shared/examples/1.Basics/Blink/Blink.ino similarity index 100% rename from build/shared/examples/1.Basics/Blink/Blink.pde rename to build/shared/examples/1.Basics/Blink/Blink.ino diff --git a/build/shared/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.pde b/build/shared/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.ino similarity index 88% rename from build/shared/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.pde rename to build/shared/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.ino index 7651a8fae..68e4dc966 100644 --- a/build/shared/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.pde +++ b/build/shared/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.ino @@ -12,7 +12,7 @@ void setup() { void loop() { int sensorValue = digitalRead(2); - Serial.println(sensorValue, DEC); + Serial.println(sensorValue); } diff --git a/build/shared/examples/1.Basics/Fade/Fade.pde b/build/shared/examples/1.Basics/Fade/Fade.ino similarity index 100% rename from build/shared/examples/1.Basics/Fade/Fade.pde rename to build/shared/examples/1.Basics/Fade/Fade.ino diff --git a/build/shared/examples/2.Digital/BlinkWithoutDelay/BlinkWithoutDelay.pde b/build/shared/examples/2.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino similarity index 100% rename from build/shared/examples/2.Digital/BlinkWithoutDelay/BlinkWithoutDelay.pde rename to build/shared/examples/2.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino diff --git a/build/shared/examples/2.Digital/Button/Button.pde b/build/shared/examples/2.Digital/Button/Button.ino similarity index 98% rename from build/shared/examples/2.Digital/Button/Button.pde rename to build/shared/examples/2.Digital/Button/Button.ino index a56ea14eb..e019fca31 100644 --- a/build/shared/examples/2.Digital/Button/Button.pde +++ b/build/shared/examples/2.Digital/Button/Button.ino @@ -16,7 +16,7 @@ created 2005 by DojoDave - modified 28 Oct 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/2.Digital/Debounce/Debounce.pde b/build/shared/examples/2.Digital/Debounce/Debounce.ino similarity index 99% rename from build/shared/examples/2.Digital/Debounce/Debounce.pde rename to build/shared/examples/2.Digital/Debounce/Debounce.ino index 6f184eccc..89416b269 100644 --- a/build/shared/examples/2.Digital/Debounce/Debounce.pde +++ b/build/shared/examples/2.Digital/Debounce/Debounce.ino @@ -17,7 +17,7 @@ created 21 November 2006 by David A. Mellis - modified 3 Jul 2009 + modified 30 Aug 2011 by Limor Fried This example code is in the public domain. diff --git a/build/shared/examples/2.Digital/StateChangeDetection/StateChangeDetection.pde b/build/shared/examples/2.Digital/StateChangeDetection/StateChangeDetection.ino similarity index 97% rename from build/shared/examples/2.Digital/StateChangeDetection/StateChangeDetection.pde rename to build/shared/examples/2.Digital/StateChangeDetection/StateChangeDetection.ino index 33f997c6b..30bb3c405 100644 --- a/build/shared/examples/2.Digital/StateChangeDetection/StateChangeDetection.pde +++ b/build/shared/examples/2.Digital/StateChangeDetection/StateChangeDetection.ino @@ -16,7 +16,7 @@ most Arduino boards) created 27 Sep 2005 - modified 14 Oct 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. @@ -57,7 +57,7 @@ void loop() { buttonPushCounter++; Serial.println("on"); Serial.print("number of button pushes: "); - Serial.println(buttonPushCounter, DEC); + Serial.println(buttonPushCounter); } else { // if the current state is LOW then the button diff --git a/build/shared/examples/2.Digital/toneKeyboard/toneKeyboard.pde b/build/shared/examples/2.Digital/toneKeyboard/toneKeyboard.ino similarity index 97% rename from build/shared/examples/2.Digital/toneKeyboard/toneKeyboard.pde rename to build/shared/examples/2.Digital/toneKeyboard/toneKeyboard.ino index b1a5364a7..9decdd752 100644 --- a/build/shared/examples/2.Digital/toneKeyboard/toneKeyboard.pde +++ b/build/shared/examples/2.Digital/toneKeyboard/toneKeyboard.ino @@ -9,7 +9,7 @@ * 8-ohm speaker on digital pin 8 created 21 Jan 2010 - Modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/2.Digital/toneMelody/toneMelody.pde b/build/shared/examples/2.Digital/toneMelody/toneMelody.ino similarity index 98% rename from build/shared/examples/2.Digital/toneMelody/toneMelody.pde rename to build/shared/examples/2.Digital/toneMelody/toneMelody.ino index debcebd6b..8593ab770 100644 --- a/build/shared/examples/2.Digital/toneMelody/toneMelody.pde +++ b/build/shared/examples/2.Digital/toneMelody/toneMelody.ino @@ -7,7 +7,7 @@ * 8-ohm speaker on digital pin 8 created 21 Jan 2010 - modified 14 Oct 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/2.Digital/toneMultiple/toneMultiple.pde b/build/shared/examples/2.Digital/toneMultiple/toneMultiple.ino similarity index 100% rename from build/shared/examples/2.Digital/toneMultiple/toneMultiple.pde rename to build/shared/examples/2.Digital/toneMultiple/toneMultiple.ino diff --git a/build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.pde b/build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.ino similarity index 97% rename from build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.pde rename to build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.ino index bcc4b6327..beb28b2bd 100644 --- a/build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.pde +++ b/build/shared/examples/2.Digital/tonePitchFollower/tonePitchFollower.ino @@ -9,7 +9,7 @@ * 4.7K resistor on analog 0 to ground created 21 Jan 2010 - Modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.pde b/build/shared/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.ino similarity index 98% rename from build/shared/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.pde rename to build/shared/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.ino index 57c14219d..e142f690e 100644 --- a/build/shared/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.pde +++ b/build/shared/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.ino @@ -12,7 +12,7 @@ * LED connected from digital pin 9 to ground created 29 Dec. 2008 - Modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/3.Analog/AnalogInput/AnalogInput.pde b/build/shared/examples/3.Analog/AnalogInput/AnalogInput.ino similarity index 98% rename from build/shared/examples/3.Analog/AnalogInput/AnalogInput.pde rename to build/shared/examples/3.Analog/AnalogInput/AnalogInput.ino index 18a005524..5d685883b 100644 --- a/build/shared/examples/3.Analog/AnalogInput/AnalogInput.pde +++ b/build/shared/examples/3.Analog/AnalogInput/AnalogInput.ino @@ -18,7 +18,7 @@ Created by David Cuartielles - Modified 4 Sep 2010 + modified 30 Aug 2011 By Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/3.Analog/AnalogWriteMega/AnalogWriteMega.pde b/build/shared/examples/3.Analog/AnalogWriteMega/AnalogWriteMega.ino similarity index 100% rename from build/shared/examples/3.Analog/AnalogWriteMega/AnalogWriteMega.pde rename to build/shared/examples/3.Analog/AnalogWriteMega/AnalogWriteMega.ino diff --git a/build/shared/examples/3.Analog/Calibration/Calibration.pde b/build/shared/examples/3.Analog/Calibration/Calibration.ino similarity index 98% rename from build/shared/examples/3.Analog/Calibration/Calibration.pde rename to build/shared/examples/3.Analog/Calibration/Calibration.ino index c5734df4e..c3f88fdf0 100644 --- a/build/shared/examples/3.Analog/Calibration/Calibration.pde +++ b/build/shared/examples/3.Analog/Calibration/Calibration.ino @@ -17,7 +17,7 @@ created 29 Oct 2008 By David A Mellis - Modified 4 Sep 2010 + modified 30 Aug 2011 By Tom Igoe http://arduino.cc/en/Tutorial/Calibration diff --git a/build/shared/examples/3.Analog/Fading/Fading.pde b/build/shared/examples/3.Analog/Fading/Fading.ino similarity index 97% rename from build/shared/examples/3.Analog/Fading/Fading.pde rename to build/shared/examples/3.Analog/Fading/Fading.ino index 46959ad26..858d3616c 100644 --- a/build/shared/examples/3.Analog/Fading/Fading.pde +++ b/build/shared/examples/3.Analog/Fading/Fading.ino @@ -8,7 +8,7 @@ Created 1 Nov 2008 By David A. Mellis - Modified 17 June 2009 + modified 30 Aug 2011 By Tom Igoe http://arduino.cc/en/Tutorial/Fading diff --git a/build/shared/examples/3.Analog/Smoothing/Smoothing.pde b/build/shared/examples/3.Analog/Smoothing/Smoothing.ino similarity index 94% rename from build/shared/examples/3.Analog/Smoothing/Smoothing.pde rename to build/shared/examples/3.Analog/Smoothing/Smoothing.ino index 5de30e8d7..e33a0dd16 100644 --- a/build/shared/examples/3.Analog/Smoothing/Smoothing.pde +++ b/build/shared/examples/3.Analog/Smoothing/Smoothing.ino @@ -10,6 +10,7 @@ * Analog sensor (potentiometer will do) attached to analog input 0 Created 22 April 2007 + modified 30 Aug 2011 By David A. Mellis http://www.arduino.cc/en/Tutorial/Smoothing @@ -59,8 +60,8 @@ void loop() { // calculate the average: average = total / numReadings; - // send it to the computer (as ASCII digits) - Serial.println(average, DEC); + // send it to the computer as ASCII digits + Serial.println(average); } diff --git a/build/shared/examples/4.Communication/ASCIITable/ASCIITable.pde b/build/shared/examples/4.Communication/ASCIITable/ASCIITable.ino similarity index 98% rename from build/shared/examples/4.Communication/ASCIITable/ASCIITable.pde rename to build/shared/examples/4.Communication/ASCIITable/ASCIITable.ino index c92b0d023..5a111027d 100644 --- a/build/shared/examples/4.Communication/ASCIITable/ASCIITable.pde +++ b/build/shared/examples/4.Communication/ASCIITable/ASCIITable.ino @@ -11,7 +11,7 @@ created 2006 by Nicholas Zambetti - modified 18 Jan 2009 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/4.Communication/Dimmer/Dimmer.pde b/build/shared/examples/4.Communication/Dimmer/Dimmer.ino similarity index 99% rename from build/shared/examples/4.Communication/Dimmer/Dimmer.pde rename to build/shared/examples/4.Communication/Dimmer/Dimmer.ino index 2985ddaee..78849c2c9 100644 --- a/build/shared/examples/4.Communication/Dimmer/Dimmer.pde +++ b/build/shared/examples/4.Communication/Dimmer/Dimmer.ino @@ -12,7 +12,7 @@ created 2006 by David A. Mellis - modified 14 Apr 2009 + modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. diff --git a/build/shared/examples/4.Communication/Graph/Graph.pde b/build/shared/examples/4.Communication/Graph/Graph.ino similarity index 99% rename from build/shared/examples/4.Communication/Graph/Graph.pde rename to build/shared/examples/4.Communication/Graph/Graph.ino index 03e868b9b..92256ab00 100644 --- a/build/shared/examples/4.Communication/Graph/Graph.pde +++ b/build/shared/examples/4.Communication/Graph/Graph.ino @@ -18,7 +18,7 @@ created 2006 by David A. Mellis - modified 14 Apr 2009 + modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. diff --git a/build/shared/examples/4.Communication/MIDI/Midi.pde b/build/shared/examples/4.Communication/MIDI/Midi.ino similarity index 98% rename from build/shared/examples/4.Communication/MIDI/Midi.pde rename to build/shared/examples/4.Communication/MIDI/Midi.ino index cdeaeea11..a10548673 100644 --- a/build/shared/examples/4.Communication/MIDI/Midi.pde +++ b/build/shared/examples/4.Communication/MIDI/Midi.ino @@ -13,7 +13,7 @@ Attach a MIDI cable to the jack, then to a MIDI synth, and play music. created 13 Jun 2006 - modified 2 Jul 2009 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde b/build/shared/examples/4.Communication/MultiSerialMega/MultiSerialMega.ino similarity index 100% rename from build/shared/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde rename to build/shared/examples/4.Communication/MultiSerialMega/MultiSerialMega.ino diff --git a/build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde b/build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.ino similarity index 99% rename from build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde rename to build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.ino index 8c1f780d3..7ac8231a6 100644 --- a/build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde +++ b/build/shared/examples/4.Communication/PhysicalPixel/PhysicalPixel.ino @@ -15,7 +15,7 @@ created 2006 by David A. Mellis - modified 14 Apr 2009 + modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. @@ -59,7 +59,7 @@ void loop() { // created 2003-4 // based on examples by Casey Reas and Hernando Barragan - // modified 18 Jan 2009 + // modified 30 Aug 2011 // by Tom Igoe // This example code is in the public domain. diff --git a/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde b/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.ino similarity index 99% rename from build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde rename to build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.ino index 3a6e01300..e15031e8b 100644 --- a/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde +++ b/build/shared/examples/4.Communication/SerialCallResponse/SerialCallResponse.ino @@ -15,7 +15,7 @@ Created 26 Sept. 2005 by Tom Igoe - Modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. diff --git a/build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde b/build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino similarity index 97% rename from build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde rename to build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino index 76a6ffe2b..acf400051 100644 --- a/build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde +++ b/build/shared/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.ino @@ -19,7 +19,7 @@ Created 26 Sept. 2005 by Tom Igoe - Modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. @@ -52,15 +52,15 @@ void loop() // delay 10ms to let the ADC recover: delay(10); // read second analog input, divide by 4 to make the range 0-255: - secondSensor = analogRead(1)/4; + secondSensor = analogRead(A1)/4; // read switch, map it to 0 or 255L thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: - Serial.print(firstSensor, DEC); + Serial.print(firstSensor); Serial.print(","); - Serial.print(secondSensor, DEC); + Serial.print(secondSensor); Serial.print(","); - Serial.println(thirdSensor, DEC); + Serial.println(thirdSensor); } } diff --git a/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino b/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino index 458c43dad..11de7adfb 100644 --- a/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino +++ b/build/shared/examples/4.Communication/SerialEvent/SerialEvent.ino @@ -38,20 +38,23 @@ void loop() { } /* - 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: + SerialEvent occurs whenever a new data comes in the + hardware serial RX. This routine is run between each + time loop() runs, so using delay inside loop can delay + response. Multiple bytes of data may be available. */ 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; - } + while (Serial.available()) { + // 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.ino similarity index 99% rename from build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde rename to build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.ino index e931262a9..39e4b5761 100644 --- a/build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde +++ b/build/shared/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.ino @@ -10,7 +10,7 @@ created 2 Dec 2006 by David A. Mellis - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. diff --git a/build/shared/examples/5.Control/Arrays/Arrays.pde b/build/shared/examples/5.Control/Arrays/Arrays.ino similarity index 98% rename from build/shared/examples/5.Control/Arrays/Arrays.pde rename to build/shared/examples/5.Control/Arrays/Arrays.ino index cf83ccfb2..f5154770c 100644 --- a/build/shared/examples/5.Control/Arrays/Arrays.pde +++ b/build/shared/examples/5.Control/Arrays/Arrays.ino @@ -13,7 +13,7 @@ created 2006 by David A. Mellis - modified 5 Jul 2009 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/5.Control/ForLoopIteration/ForLoopIteration.pde b/build/shared/examples/5.Control/ForLoopIteration/ForLoopIteration.ino similarity index 97% rename from build/shared/examples/5.Control/ForLoopIteration/ForLoopIteration.pde rename to build/shared/examples/5.Control/ForLoopIteration/ForLoopIteration.ino index ec60ec9a0..d9ce32b8f 100644 --- a/build/shared/examples/5.Control/ForLoopIteration/ForLoopIteration.pde +++ b/build/shared/examples/5.Control/ForLoopIteration/ForLoopIteration.ino @@ -9,7 +9,7 @@ created 2006 by David A. Mellis - modified 5 Jul 2009 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/5.Control/IfStatementConditional/IfStatementConditional.pde b/build/shared/examples/5.Control/IfStatementConditional/IfStatementConditional.ino similarity index 96% rename from build/shared/examples/5.Control/IfStatementConditional/IfStatementConditional.pde rename to build/shared/examples/5.Control/IfStatementConditional/IfStatementConditional.ino index 5bc0dff3b..8346f2cbb 100644 --- a/build/shared/examples/5.Control/IfStatementConditional/IfStatementConditional.pde +++ b/build/shared/examples/5.Control/IfStatementConditional/IfStatementConditional.ino @@ -16,7 +16,7 @@ connected to pin 13, so you don't need any extra components for this example. created 17 Jan 2009 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. @@ -50,7 +50,7 @@ void loop() { } // print the analog value: - Serial.println(analogValue, DEC); + Serial.println(analogValue); } diff --git a/build/shared/examples/5.Control/WhileStatementConditional/WhileStatementConditional.pde b/build/shared/examples/5.Control/WhileStatementConditional/WhileStatementConditional.ino similarity index 99% rename from build/shared/examples/5.Control/WhileStatementConditional/WhileStatementConditional.pde rename to build/shared/examples/5.Control/WhileStatementConditional/WhileStatementConditional.ino index 69c6fc83b..9cffeef22 100644 --- a/build/shared/examples/5.Control/WhileStatementConditional/WhileStatementConditional.pde +++ b/build/shared/examples/5.Control/WhileStatementConditional/WhileStatementConditional.ino @@ -17,7 +17,7 @@ * 10K resistor attached from pin 2 to ground created 17 Jan 2009 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/5.Control/switchCase/switchCase.pde b/build/shared/examples/5.Control/switchCase/switchCase.ino similarity index 98% rename from build/shared/examples/5.Control/switchCase/switchCase.pde rename to build/shared/examples/5.Control/switchCase/switchCase.ino index 1b76e5fb6..87eb3f340 100644 --- a/build/shared/examples/5.Control/switchCase/switchCase.pde +++ b/build/shared/examples/5.Control/switchCase/switchCase.ino @@ -14,7 +14,7 @@ * 10K resistor from analog in 0 to ground created 1 Jul 2009 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/5.Control/switchCase2/switchCase2.pde b/build/shared/examples/5.Control/switchCase2/switchCase2.ino similarity index 100% rename from build/shared/examples/5.Control/switchCase2/switchCase2.pde rename to build/shared/examples/5.Control/switchCase2/switchCase2.ino diff --git a/build/shared/examples/6.Sensors/ADXL3xx/ADXL3xx.pde b/build/shared/examples/6.Sensors/ADXL3xx/ADXL3xx.ino similarity index 98% rename from build/shared/examples/6.Sensors/ADXL3xx/ADXL3xx.pde rename to build/shared/examples/6.Sensors/ADXL3xx/ADXL3xx.ino index 58ea129d2..a55cc016a 100644 --- a/build/shared/examples/6.Sensors/ADXL3xx/ADXL3xx.pde +++ b/build/shared/examples/6.Sensors/ADXL3xx/ADXL3xx.ino @@ -19,7 +19,7 @@ created 2 Jul 2008 by David A. Mellis - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/6.Sensors/Knock/Knock.pde b/build/shared/examples/6.Sensors/Knock/Knock.ino similarity index 98% rename from build/shared/examples/6.Sensors/Knock/Knock.pde rename to build/shared/examples/6.Sensors/Knock/Knock.ino index 985f032b9..6f8c2c55a 100644 --- a/build/shared/examples/6.Sensors/Knock/Knock.pde +++ b/build/shared/examples/6.Sensors/Knock/Knock.ino @@ -14,7 +14,7 @@ created 25 Mar 2007 by David Cuartielles - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/6.Sensors/Memsic2125/Memsic2125.pde b/build/shared/examples/6.Sensors/Memsic2125/Memsic2125.ino similarity index 98% rename from build/shared/examples/6.Sensors/Memsic2125/Memsic2125.pde rename to build/shared/examples/6.Sensors/Memsic2125/Memsic2125.ino index cf5e81c33..974ccb52f 100644 --- a/build/shared/examples/6.Sensors/Memsic2125/Memsic2125.pde +++ b/build/shared/examples/6.Sensors/Memsic2125/Memsic2125.ino @@ -16,7 +16,7 @@ created 6 Nov 2008 by David A. Mellis - modified 30 Jun 2009 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/6.Sensors/Ping/Ping.pde b/build/shared/examples/6.Sensors/Ping/Ping.ino similarity index 99% rename from build/shared/examples/6.Sensors/Ping/Ping.pde rename to build/shared/examples/6.Sensors/Ping/Ping.ino index 70bab93a7..5de46d603 100644 --- a/build/shared/examples/6.Sensors/Ping/Ping.pde +++ b/build/shared/examples/6.Sensors/Ping/Ping.ino @@ -15,7 +15,7 @@ created 3 Nov 2008 by David A. Mellis - modified 30 Jun 2009 + modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. diff --git a/build/shared/examples/7.Display/RowColumnScanning/RowColumnScanning.pde b/build/shared/examples/7.Display/RowColumnScanning/RowColumnScanning.ino similarity index 99% rename from build/shared/examples/7.Display/RowColumnScanning/RowColumnScanning.pde rename to build/shared/examples/7.Display/RowColumnScanning/RowColumnScanning.ino index bcda4c78d..6be347295 100644 --- a/build/shared/examples/7.Display/RowColumnScanning/RowColumnScanning.pde +++ b/build/shared/examples/7.Display/RowColumnScanning/RowColumnScanning.ino @@ -4,7 +4,7 @@ This example controls an 8x8 LED matrix using two analog inputs created 27 May 2009 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe This example works for the Lumex LDM-24488NI Matrix. See diff --git a/build/shared/examples/7.Display/barGraph/barGraph.pde b/build/shared/examples/7.Display/barGraph/barGraph.ino similarity index 100% rename from build/shared/examples/7.Display/barGraph/barGraph.pde rename to build/shared/examples/7.Display/barGraph/barGraph.ino diff --git a/build/shared/examples/8.Strings/CharacterAnalysis/CharacterAnalysis.pde b/build/shared/examples/8.Strings/CharacterAnalysis/CharacterAnalysis.ino similarity index 100% rename from build/shared/examples/8.Strings/CharacterAnalysis/CharacterAnalysis.pde rename to build/shared/examples/8.Strings/CharacterAnalysis/CharacterAnalysis.ino diff --git a/build/shared/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.pde b/build/shared/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.ino similarity index 98% rename from build/shared/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.pde rename to build/shared/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.ino index fe631b9c7..88938e864 100644 --- a/build/shared/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.pde +++ b/build/shared/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.ino @@ -5,7 +5,7 @@ You can also add several different data types to string, as shown here: created 27 July 2010 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe http://arduino.cc/en/Tutorial/StringAdditionOperator diff --git a/build/shared/examples/8.Strings/StringAppendOperator/StringAppendOperator.pde b/build/shared/examples/8.Strings/StringAppendOperator/StringAppendOperator.ino similarity index 98% rename from build/shared/examples/8.Strings/StringAppendOperator/StringAppendOperator.pde rename to build/shared/examples/8.Strings/StringAppendOperator/StringAppendOperator.ino index 680738142..cb902ca6b 100644 --- a/build/shared/examples/8.Strings/StringAppendOperator/StringAppendOperator.pde +++ b/build/shared/examples/8.Strings/StringAppendOperator/StringAppendOperator.ino @@ -4,7 +4,7 @@ Examples of how to append different data types to strings created 27 July 2010 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe http://arduino.cc/en/Tutorial/StringAppendOperator diff --git a/build/shared/examples/8.Strings/StringCaseChanges/StringCaseChanges.pde b/build/shared/examples/8.Strings/StringCaseChanges/StringCaseChanges.ino similarity index 100% rename from build/shared/examples/8.Strings/StringCaseChanges/StringCaseChanges.pde rename to build/shared/examples/8.Strings/StringCaseChanges/StringCaseChanges.ino diff --git a/build/shared/examples/8.Strings/StringCharacters/StringCharacters.pde b/build/shared/examples/8.Strings/StringCharacters/StringCharacters.ino similarity index 100% rename from build/shared/examples/8.Strings/StringCharacters/StringCharacters.pde rename to build/shared/examples/8.Strings/StringCharacters/StringCharacters.ino diff --git a/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde b/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.ino similarity index 99% rename from build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde rename to build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.ino index 3122b0bee..53c7492e5 100644 --- a/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde +++ b/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.ino @@ -4,7 +4,7 @@ Examples of how to compare strings using the comparison operators created 27 July 2010 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe http://arduino.cc/en/Tutorial/StringComparisonOperators diff --git a/build/shared/examples/8.Strings/StringConstructors/StringConstructors.pde b/build/shared/examples/8.Strings/StringConstructors/StringConstructors.ino similarity index 98% rename from build/shared/examples/8.Strings/StringConstructors/StringConstructors.pde rename to build/shared/examples/8.Strings/StringConstructors/StringConstructors.ino index 94ae2dc7a..ee7e8701c 100644 --- a/build/shared/examples/8.Strings/StringConstructors/StringConstructors.pde +++ b/build/shared/examples/8.Strings/StringConstructors/StringConstructors.ino @@ -4,7 +4,7 @@ Examples of how to create strings from other data types created 27 July 2010 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe http://arduino.cc/en/Tutorial/StringConstructors diff --git a/build/shared/examples/8.Strings/StringIndexOf/StringIndexOf.pde b/build/shared/examples/8.Strings/StringIndexOf/StringIndexOf.ino similarity index 100% rename from build/shared/examples/8.Strings/StringIndexOf/StringIndexOf.pde rename to build/shared/examples/8.Strings/StringIndexOf/StringIndexOf.ino diff --git a/build/shared/examples/8.Strings/StringLength/StringLength.pde b/build/shared/examples/8.Strings/StringLength/StringLength.ino similarity index 100% rename from build/shared/examples/8.Strings/StringLength/StringLength.pde rename to build/shared/examples/8.Strings/StringLength/StringLength.ino diff --git a/build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.pde b/build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.ino similarity index 100% rename from build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.pde rename to build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.ino diff --git a/build/shared/examples/8.Strings/StringReplace/StringReplace.pde b/build/shared/examples/8.Strings/StringReplace/StringReplace.ino similarity index 100% rename from build/shared/examples/8.Strings/StringReplace/StringReplace.pde rename to build/shared/examples/8.Strings/StringReplace/StringReplace.ino diff --git a/build/shared/examples/8.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.pde b/build/shared/examples/8.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino similarity index 98% rename from build/shared/examples/8.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.pde rename to build/shared/examples/8.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino index b18b67684..429ec60d9 100644 --- a/build/shared/examples/8.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.pde +++ b/build/shared/examples/8.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino @@ -4,7 +4,7 @@ Examples of how to use startsWith() and endsWith() in a String created 27 July 2010 - modified 4 Sep 2010 + modified 30 Aug 2011 by Tom Igoe http://arduino.cc/en/Tutorial/StringStartsWithEndsWith diff --git a/build/shared/examples/8.Strings/StringSubstring/StringSubstring.pde b/build/shared/examples/8.Strings/StringSubstring/StringSubstring.ino similarity index 100% rename from build/shared/examples/8.Strings/StringSubstring/StringSubstring.pde rename to build/shared/examples/8.Strings/StringSubstring/StringSubstring.ino diff --git a/build/shared/examples/8.Strings/StringToInt/StringToInt.pde b/build/shared/examples/8.Strings/StringToInt/StringToInt.ino similarity index 100% rename from build/shared/examples/8.Strings/StringToInt/StringToInt.pde rename to build/shared/examples/8.Strings/StringToInt/StringToInt.ino diff --git a/build/shared/examples/8.Strings/StringToIntRGB/StringToIntRGB.pde b/build/shared/examples/8.Strings/StringToIntRGB/StringToIntRGB.ino similarity index 100% rename from build/shared/examples/8.Strings/StringToIntRGB/StringToIntRGB.pde rename to build/shared/examples/8.Strings/StringToIntRGB/StringToIntRGB.ino diff --git a/build/shared/examples/ArduinoISP/ArduinoISP.pde b/build/shared/examples/ArduinoISP/ArduinoISP.ino similarity index 100% rename from build/shared/examples/ArduinoISP/ArduinoISP.pde rename to build/shared/examples/ArduinoISP/ArduinoISP.ino diff --git a/hardware/arduino/boards.txt b/hardware/arduino/boards.txt index 1b2037f15..fb2a1cd70 100644 --- a/hardware/arduino/boards.txt +++ b/hardware/arduino/boards.txt @@ -102,7 +102,7 @@ nano.build.variant=eightanaloginputs ############################################################## -mega2560.name=Arduino Mega 2560 +mega2560.name=Arduino Mega 2560 or Mega ADK mega2560.upload.protocol=stk500v2 mega2560.upload.maximum_size=258048 @@ -165,6 +165,27 @@ mini.build.variant=eightanaloginputs ############################################################## +ethernet.name=Arduino Ethernet + +ethernet.upload.protocol=stk500 +ethernet.upload.maximum_size=32256 +ethernet.upload.speed=115200 + +ethernet.bootloader.low_fuses=0xff +ethernet.bootloader.high_fuses=0xde +ethernet.bootloader.extended_fuses=0x05 +ethernet.bootloader.path=optiboot +ethernet.bootloader.file=optiboot_atmega328.hex +ethernet.bootloader.unlock_bits=0x3F +ethernet.bootloader.lock_bits=0x0F + +ethernet.build.variant=standard +ethernet.build.mcu=atmega328p +ethernet.build.f_cpu=16000000L +ethernet.build.core=arduino + +############################################################## + fio.name=Arduino Fio fio.upload.protocol=arduino diff --git a/hardware/arduino/cores/arduino/Client.h b/hardware/arduino/cores/arduino/Client.h new file mode 100644 index 000000000..ed9e9b48c --- /dev/null +++ b/hardware/arduino/cores/arduino/Client.h @@ -0,0 +1,27 @@ +#ifndef client_h +#define client_h +#include "Print.h" +#include "Stream.h" +#include "IPAddress.h" + +class Client : public Stream { + +public: + virtual int connect(IPAddress ip, uint16_t port) =0; + virtual int connect(const char *host, uint16_t port) =0; + virtual size_t write(uint8_t) =0; + virtual size_t write(const char *str) =0; + virtual size_t write(const uint8_t *buf, size_t size) =0; + virtual int available() = 0; + virtual int read() = 0; + virtual int read(uint8_t *buf, size_t size) = 0; + virtual int peek() = 0; + virtual void flush() = 0; + virtual void stop() = 0; + virtual uint8_t connected() = 0; + virtual operator bool() = 0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/hardware/arduino/cores/arduino/HardwareSerial.cpp b/hardware/arduino/cores/arduino/HardwareSerial.cpp index d6be2181c..3ed8d07b5 100644 --- a/hardware/arduino/cores/arduino/HardwareSerial.cpp +++ b/hardware/arduino/cores/arduino/HardwareSerial.cpp @@ -88,6 +88,8 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #else void serialEvent() __attribute__((weak)); void serialEvent() {} + volatile static unsigned char serialEvent_flag = 0; + #define serialEvent_implemented #if defined(USART_RX_vect) SIGNAL(USART_RX_vect) #elif defined(SIG_USART0_RECV) @@ -108,18 +110,20 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #error UDR not defined #endif store_char(c, &rx_buffer); - serialEvent(); + serialEvent_flag = 1; } #endif #if defined(USART1_RX_vect) void serialEvent1() __attribute__((weak)); void serialEvent1() {} + volatile static unsigned char serialEvent1_flag = 0; + #define serialEvent1_implemented SIGNAL(USART1_RX_vect) { unsigned char c = UDR1; store_char(c, &rx_buffer1); - serialEvent1(); + serialEvent1_flag = 1; } #elif defined(SIG_USART1_RECV) #error SIG_USART1_RECV @@ -128,11 +132,13 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #if defined(USART2_RX_vect) && defined(UDR2) void serialEvent2() __attribute__((weak)); void serialEvent2() {} + volatile static unsigned char serialEvent2_flag = 0; + #define serialEvent2_implemented SIGNAL(USART2_RX_vect) { unsigned char c = UDR2; store_char(c, &rx_buffer2); - serialEvent2(); + serialEvent2_flag = 1; } #elif defined(SIG_USART2_RECV) #error SIG_USART2_RECV @@ -141,16 +147,55 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #if defined(USART3_RX_vect) && defined(UDR3) void serialEvent3() __attribute__((weak)); void serialEvent3() {} + volatile static unsigned char serialEvent3_flag = 0; + #define serialEvent3_implemented SIGNAL(USART3_RX_vect) { unsigned char c = UDR3; store_char(c, &rx_buffer3); - serialEvent3(); + serialEvent3_flag = 1; } #elif defined(SIG_USART3_RECV) #error SIG_USART3_RECV #endif +void serialEventRun(void) +{ + unsigned char flag, oldSREG; +#ifdef serialEvent_implemented + oldSREG = SREG; + noInterrupts(); + flag = serialEvent_flag; + serialEvent_flag = 0; + SREG = oldSREG; + if (flag) serialEvent(); +#endif +#ifdef serialEvent1_implemented + oldSREG = SREG; + noInterrupts(); + flag = serialEvent1_flag; + serialEvent1_flag = 0; + SREG = oldSREG; + if (flag) serialEvent1(); +#endif +#ifdef serialEvent2_implemented + oldSREG = SREG; + noInterrupts(); + flag = serialEvent2_flag; + serialEvent2_flag = 0; + SREG = oldSREG; + if (flag) serialEvent2(); +#endif +#ifdef serialEvent3_implemented + oldSREG = SREG; + noInterrupts(); + flag = serialEvent3_flag; + serialEvent3_flag = 0; + SREG = oldSREG; + if (flag) serialEvent3(); +#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 diff --git a/hardware/arduino/cores/arduino/HardwareSerial.h b/hardware/arduino/cores/arduino/HardwareSerial.h index 1895f08f6..cbb0e5eae 100644 --- a/hardware/arduino/cores/arduino/HardwareSerial.h +++ b/hardware/arduino/cores/arduino/HardwareSerial.h @@ -74,4 +74,6 @@ class HardwareSerial : public Stream extern HardwareSerial Serial3; #endif +extern void serialEventRun(void); + #endif diff --git a/libraries/Ethernet/IPAddress.cpp b/hardware/arduino/cores/arduino/IPAddress.cpp similarity index 100% rename from libraries/Ethernet/IPAddress.cpp rename to hardware/arduino/cores/arduino/IPAddress.cpp diff --git a/libraries/Ethernet/IPAddress.h b/hardware/arduino/cores/arduino/IPAddress.h similarity index 100% rename from libraries/Ethernet/IPAddress.h rename to hardware/arduino/cores/arduino/IPAddress.h diff --git a/hardware/arduino/cores/arduino/Print.h b/hardware/arduino/cores/arduino/Print.h index fce302e72..8530b0358 100755 --- a/hardware/arduino/cores/arduino/Print.h +++ b/hardware/arduino/cores/arduino/Print.h @@ -42,7 +42,7 @@ class Print public: Print() : write_error(0) {} - int writeError() { return write_error; } + int getWriteError() { return write_error; } void clearWriteError() { setWriteError(0); } virtual size_t write(uint8_t) = 0; diff --git a/hardware/arduino/cores/arduino/Printable.h b/hardware/arduino/cores/arduino/Printable.h index e22e87ea2..d03c9af62 100644 --- a/hardware/arduino/cores/arduino/Printable.h +++ b/hardware/arduino/cores/arduino/Printable.h @@ -20,6 +20,8 @@ #ifndef Printable_h #define Printable_h +#include + class Print; /** The Printable class provides a way for new classes to allow themselves to be printed. @@ -27,6 +29,7 @@ class Print; for users to print out instances of this class by passing them into the usual Print::print and Print::println methods. */ + class Printable { public: diff --git a/hardware/arduino/cores/arduino/Server.h b/hardware/arduino/cores/arduino/Server.h new file mode 100644 index 000000000..edab726be --- /dev/null +++ b/hardware/arduino/cores/arduino/Server.h @@ -0,0 +1,9 @@ +#ifndef server_h +#define server_h + +class Server { +public: + virtual void begin() =0; +}; + +#endif diff --git a/hardware/arduino/cores/arduino/Udp.h b/hardware/arduino/cores/arduino/Udp.h new file mode 100644 index 000000000..1fb9cd3cf --- /dev/null +++ b/hardware/arduino/cores/arduino/Udp.h @@ -0,0 +1,90 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write a string of characters into the packet + virtual size_t write(const char *str) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/hardware/arduino/cores/arduino/main.cpp b/hardware/arduino/cores/arduino/main.cpp index 3c46f1e7a..1c2ea9a3c 100755 --- a/hardware/arduino/cores/arduino/main.cpp +++ b/hardware/arduino/cores/arduino/main.cpp @@ -7,8 +7,10 @@ int main(void) setup(); - for (;;) + for (;;) { loop(); + serialEventRun(); + } return 0; } 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/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp b/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp deleted file mode 100644 index 86a275ab7..000000000 --- a/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp +++ /dev/null @@ -1,715 +0,0 @@ -//************************************************************************ -//* Arduino Test Suite -//* (C) 2010 by Mark Sproul -//* Open source as per standard Arduino code -//* -//* 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. -//************************************************************************ -//* Aug 31, 2010 Started on TestArduino -//* Oct 18, 2010 Added memory testing -//************************************************************************ - -#include -#include -#include - - - -#include "ArduinoTestSuite.h" - - -#include "Arduino.h" -#include "HardwareSerial.h" -#include "pins_arduino.h" - - -#include "avr_cpunames.h" - -#if defined(USART3_RX_vect) - #define SERIAL_PORT_COUNT 4 -#elif defined(USART1_RX_vect) - #define SERIAL_PORT_COUNT 2 -#else - #define SERIAL_PORT_COUNT 1 -#endif - - - - -//************************************************************************ -enum -{ - ATS_Manufacturer = 1, - ATS_CPU, - ATS_GCC_version, - ATS_LIBC_version, - ATS_CompiledDate, - ATS_TestSuiteName, - ATS_FreeMemory, - - -}; -unsigned long gTestStartTime; -short gTagIndent; -int gYotalErrors; -int gTestCount; - - - -prog_char gTextMsg_Manufacturer[] PROGMEM = "MANUFACTURER"; -prog_char gTextMsg_CPUname[] PROGMEM = "CPU-NAME"; -prog_char gTextMsg_GCC_VERSION[] PROGMEM = "GCC-Version"; -prog_char gTextMsg_AVR_LIBC[] PROGMEM = "AVR-LibC-Ver"; -prog_char gTextMsg_COMPILED_DATE[] PROGMEM = "Compiled-date"; -prog_char gTextMsg_TEST_SUITE_NAME[] PROGMEM = "Test-Suite-Name"; -prog_char gTextMsg_memoryUsage[] PROGMEM = "Free-memory"; -prog_char gTextMsg_dotdotdot[] PROGMEM = "... "; -prog_char gTextMsg_ok[] PROGMEM = "ok"; -prog_char gTextMsg_FAIL[] PROGMEM = "FAIL"; -prog_char gTextMsg_spaceEqual[] PROGMEM = " = "; -prog_char gTextMsg_info[] PROGMEM = "info."; -prog_char gTextMsg_dashLine[] PROGMEM = "--------------------------"; -prog_char gTextMsg_DigitalRW[] PROGMEM = "DigitalReadWrite_"; -prog_char gTextMsg_PWMoutput[] PROGMEM = "PWMoutput_"; -prog_char gTextMsg_AnalogInput[] PROGMEM = "AnalogInput_"; - -//************************************************************************ -void Serial_print_P(prog_char *flashMemStr) -{ -char theChar; -int ii; - - ii = 0; -#if (FLASHEND > 0x10000) - while (theChar = pgm_read_byte_far(flashMemStr + ii++)) -#else - while (theChar = pgm_read_byte_near(flashMemStr + ii++)) -#endif - { - Serial.print(theChar); - } -} - -//************************************************************************ -void Serial_println_P(prog_char *flashMemStr) -{ - Serial_print_P(flashMemStr); - Serial.println(); -} - -//************************************************************************ -//* this is for internal use only, not made pubic to the API -static void ATS_PrintProperty( int propertyTagNum, - char *propertyName, - char *propertyValue) -{ -char lineBuffer[64]; - - strcpy_P(lineBuffer, gTextMsg_info); - switch(propertyTagNum) - { - case 0: - strcat(lineBuffer, propertyName); - break; - - case ATS_Manufacturer: - strcat_P(lineBuffer, gTextMsg_Manufacturer); - break; - - case ATS_CPU: - strcat_P(lineBuffer, gTextMsg_CPUname); - break; - - case ATS_GCC_version: - strcat_P(lineBuffer, gTextMsg_GCC_VERSION); - break; - - case ATS_LIBC_version: - strcat_P(lineBuffer, gTextMsg_AVR_LIBC); - break; - - case ATS_CompiledDate: - strcat_P(lineBuffer, gTextMsg_COMPILED_DATE); - break; - - case ATS_TestSuiteName: - strcat_P(lineBuffer, gTextMsg_TEST_SUITE_NAME); - break; - - case ATS_FreeMemory: - strcat_P(lineBuffer, gTextMsg_memoryUsage); - break; - } - - while (strlen(lineBuffer) < 20) - { - strcat(lineBuffer, " "); - } - - strcat_P(lineBuffer, gTextMsg_spaceEqual); - if (propertyValue != 0) - { - strcat(lineBuffer, propertyValue); - } - Serial.println(lineBuffer); - -} - - - - -//************************************************************************ -void ATS_begin(char *manufName, char *testSuiteName) -{ -int freeMemory; -char memoryMsg[48]; - - gYotalErrors = 0; - gTestCount = 0; - - Serial.begin(9600); - delay(1000); - - gTestStartTime = millis(); - - Serial.println(); - Serial.println(); - Serial.println(); - - ATS_PrintProperty(ATS_Manufacturer, 0, manufName); - ATS_PrintProperty(ATS_CPU, 0, _AVR_CPU_NAME_); - ATS_PrintProperty(ATS_GCC_version, 0, __VERSION__); - ATS_PrintProperty(ATS_LIBC_version, 0, __AVR_LIBC_VERSION_STRING__); - ATS_PrintProperty(ATS_CompiledDate, 0, __DATE__); - ATS_PrintProperty(ATS_TestSuiteName, 0, testSuiteName); - - freeMemory = ATS_GetFreeMemory(); - sprintf(memoryMsg, "%d bytes", freeMemory); - ATS_PrintProperty(ATS_FreeMemory, 0, memoryMsg); - - randomSeed(analogRead(0)); - -} - -//************************************************************************ -void ATS_end() -{ -long seconds; -long milliSecs; - - - Serial_println_P(gTextMsg_dashLine); - - // Ran 4 tests in 0.000s - Serial.print("Ran "); - Serial.print(gTestCount); - Serial.print(" tests in "); - - seconds = millis() / 1000; - milliSecs = millis() % 1000; - Serial.print(seconds); - Serial.print('.'); - Serial.print(milliSecs); - Serial.print('s'); - Serial.println(); - Serial.println(); - - if (gYotalErrors == 0) - { - Serial.print("OK"); - } - else - { - Serial.print("FAILED (failures="); - Serial.print(gYotalErrors); - Serial.print(")"); - } - Serial.println(); - - //* send control D to terminate (End Of File) - Serial.write(0x04); -} - - - -//************************************************************************ -void ATS_PrintTestStatus(char *testString, boolean passed) -{ -int sLen; - - Serial.print(testString); - sLen = strlen(testString); - while (sLen < 60) - { - Serial.print(' '); - sLen++; - } - Serial_print_P(gTextMsg_dotdotdot); - if (passed) - { - Serial_print_P(gTextMsg_ok); - } - else - { - Serial_print_P(gTextMsg_FAIL); - gYotalErrors++; - } - Serial.println(); - - gTestCount++; -} - - - -//************************************************************************ -//* returns true if no errors, false if there is an error -int ATS_Test_DigitalPinWithHelper(uint8_t digitalPinToTest, uint8_t helperpin) -{ -boolean passedOK; -int pinValue; -char testName[64]; -char numString[32]; - - strcpy_P(testName, gTextMsg_DigitalRW); - sprintf(numString, "%02d", digitalPinToTest); - strcat(testName, numString); - - passedOK = true; - - //* test senario 1 - pinMode(digitalPinToTest, OUTPUT); - pinMode(helperpin, INPUT); - - digitalWrite(digitalPinToTest, HIGH); - pinValue = digitalRead(helperpin); - if (pinValue != HIGH) - { - passedOK = false; - } - - digitalWrite(digitalPinToTest, LOW); - pinValue = digitalRead(helperpin); - if (pinValue != LOW) - { - passedOK = false; - } - - - //* now reverse the input/output - pinMode(digitalPinToTest, INPUT); - pinMode(helperpin, OUTPUT); - - digitalWrite(helperpin, HIGH); - pinValue = digitalRead(digitalPinToTest); - if (pinValue != HIGH) - { - passedOK = false; - } - - digitalWrite(helperpin, LOW); - pinValue = digitalRead(digitalPinToTest); - if (pinValue != LOW) - { - passedOK = false; - } - - - if (! passedOK) - { - sprintf(numString, " (helper pin=%02d)", helperpin); - strcat(testName, numString); - } - ATS_PrintTestStatus(testName, passedOK); - return(passedOK); -} - -//************************************************************************ -boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest) -{ -boolean passedOK; -uint8_t helperpin; - - if ((digitalPinToTest % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = digitalPinToTest + 1; - } - else - { - //* if its ODD - helperpin = digitalPinToTest - 1; - } - passedOK = ATS_Test_DigitalPinWithHelper(digitalPinToTest, helperpin); - return(passedOK); -} - - - -//************************************************************************ -//* returns true if no errors, false if there is an error -int ATS_TestTimer( uint8_t timerPinNumber, - uint8_t inputPin, - char *statusString, - char *errorString) -{ -boolean passedOK; -unsigned long loopCounter; -unsigned long lowCount; -unsigned long highCount; -unsigned long startTime; -int percentLow; -int percentHigh; -int pinValue; -char numString[48]; -int pwmValue; - - pwmValue = 128; - loopCounter = 0; - lowCount = 0; - highCount = 0; - passedOK = true; - - startTime = millis(); - pinMode(inputPin, INPUT); - analogWrite(timerPinNumber, pwmValue); - while ((millis() - startTime) < 500) - { - pinValue = digitalRead(inputPin); - if (pinValue == HIGH) - { - highCount++; - } - else - { - lowCount++; - } - } - analogWrite(timerPinNumber, 0); - - //* the difference should be about 50% - percentLow = lowCount / ((lowCount + highCount) / 100); - percentHigh = highCount / ((lowCount + highCount) / 100); - if ((percentLow > 45) && (percentLow < 55)) - { - passedOK = true; - } - else - { - passedOK = false; - strcat(errorString, " PWM ERROR"); - } - sprintf(numString, " (PWM=%02d %d%% LOW %d%% HIGH)", pwmValue, percentLow, percentHigh); - strcat(statusString, numString); - - return(passedOK); -} - - -//************************************************************************ -//* returns true if no errors, false if there is an error -boolean ATS_Test_PWMPinWithHelper(uint8_t pwmPinToTest, uint8_t helperpin) -{ -boolean passedOK; -char testName[64]; -char errorString[48]; -char numString[8]; -uint8_t timerNumber; - - - - strcpy_P(testName, gTextMsg_PWMoutput); - sprintf(numString, "%02d", pwmPinToTest); - strcat(testName, numString); - - passedOK = true; - errorString[0] = 0; - - - //* is pin1 a timer? - timerNumber = digitalPinToTimer(pwmPinToTest); - if (timerNumber != NOT_ON_TIMER) - { - passedOK = ATS_TestTimer(pwmPinToTest, helperpin, testName, errorString); - } - else - { - //* we should not get here - passedOK = false; - } - - ATS_PrintTestStatus(testName, passedOK); - - - return(passedOK); -} - -//************************************************************************ -boolean ATS_Test_PWM_Pin(uint8_t pwmPinToTest) -{ -boolean passedOK; -uint8_t helperpin; - - if ((pwmPinToTest % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = pwmPinToTest + 1; - } - else - { - //* if its ODD - helperpin = pwmPinToTest - 1; - } - passedOK = ATS_Test_PWMPinWithHelper(pwmPinToTest, helperpin); - return(passedOK); -} - - -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) - #define kAnalogPinOffset 54 -#else - #define kAnalogPinOffset 14 -#endif - - -//************************************************************************ -boolean ATS_Test_AnalogInputWithHelper(uint8_t analogPintoTest, uint8_t helperPin) -{ -boolean passedOK; -char testName[64]; -char infoString[48]; -int analogValueHigh; -int analogValueLow; - - - //* first we have to set the ANALOG pin to INPUT - pinMode(analogPintoTest + kAnalogPinOffset, INPUT); - - passedOK = true; - - strcpy_P(testName, gTextMsg_AnalogInput); - sprintf(infoString, "%02d", analogPintoTest); - strcat(testName, infoString); - - - pinMode(helperPin, OUTPUT); - - digitalWrite(helperPin, LOW); - analogValueLow = analogRead(analogPintoTest); - if (analogValueLow > 100) - { - passedOK = false; - } - - - digitalWrite(helperPin, HIGH); - analogValueHigh = analogRead(analogPintoTest); - if (analogValueHigh < 1000) - { - passedOK = false; - } - - - sprintf(infoString, " (Low=%4d High=%4d helper pin=%d)", analogValueLow, analogValueHigh, helperPin); - strcat(testName, infoString); - - ATS_PrintTestStatus(testName, passedOK); - - return(passedOK); -} - - -//************************************************************************ -boolean ATS_Test_AnalogInput(uint8_t analogPinToTest) -{ -boolean passedOK; -uint8_t helperpin; - - if ((analogPinToTest % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = kAnalogPinOffset + analogPinToTest + 1; - } - else - { - //* if its ODD - helperpin = kAnalogPinOffset + analogPinToTest - 1; - } - passedOK = ATS_Test_AnalogInputWithHelper(analogPinToTest, helperpin); - return(passedOK); -} - - -#define kSerialTestBaudRate 9600 -#define kSerialTestDelay 3 - - -#if (SERIAL_PORT_COUNT > 1) && !defined(__AVR_ATmega32U4__) -//************************************************************************ -//* retunrs 0 if no errors, 1 if an error occured -short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName) -{ -char xmitChar; -char rcvChar; -short ii; -short serialErrCt; -short timeOutLoopCtr; - - - serialErrCt = 1; - if (theSerialPort != 0) - { - serialErrCt = 0; - theSerialPort->begin(kSerialTestBaudRate); - - for (ii=0; ii<150; ii++) - { - xmitChar = ii; - theSerialPort->print(xmitChar); - - timeOutLoopCtr = 0; - //* wait for data to come back or timeout - while (!theSerialPort->available() && (timeOutLoopCtr < kSerialTestDelay)) - { - delay(1); - timeOutLoopCtr++; - } - - if (theSerialPort->available()) - { - //* get the char - rcvChar = theSerialPort->read(); - if (rcvChar != xmitChar) - { - serialErrCt = 1; - } - } - else - { - serialErrCt = 1; - } - } - theSerialPort->end(); - - if (serialErrCt == 0) - { - ATS_PrintTestStatus(serialPortName, PASSED); - } - else - { - ATS_PrintTestStatus(serialPortName, FAILED); - } - } - - return(serialErrCt); -} -#endif - - -//************************************************************************ -boolean ATS_Test_EEPROM(void) -{ -boolean passedOK; -uint8_t dataByte; -uint8_t dataByteRead; -uint16_t dataWord; -uint16_t dataWordRead; -uint32_t dataLongWord; -uint32_t dataLongWordRead; -int addressPtr; -char reportString[48]; - - passedOK = true; - //* test BYTE read/write - addressPtr = random(E2END); - dataByte = 0x5A; - eeprom_write_byte((uint8_t *)addressPtr, dataByte); - dataByteRead = eeprom_read_byte((uint8_t *)addressPtr); - - sprintf(reportString, "EEPROM_byte_rw (addr= 0x%04X)", addressPtr); - if (dataByteRead == dataByte) - { - ATS_PrintTestStatus(reportString, PASSED); - } - else - { - ATS_PrintTestStatus(reportString, FAILED); - passedOK = false; - } - - - //* test WORD read/write - addressPtr = random(E2END); - dataWord = 0xA55A; - eeprom_write_word((uint16_t *)addressPtr, dataWord); - dataWordRead = eeprom_read_word((uint16_t *)addressPtr); - - sprintf(reportString, "EEPROM_word_rw (addr= 0x%04X)", addressPtr); - if (dataWordRead == dataWord) - { - ATS_PrintTestStatus(reportString, PASSED); - } - else - { - ATS_PrintTestStatus(reportString, FAILED); - passedOK = false; - } - - - //* test Long WORD read/write - addressPtr = random(E2END); - dataLongWord = 0x5AA5A55A; - eeprom_write_dword((uint32_t *)addressPtr, dataLongWord); - dataLongWordRead = eeprom_read_dword((uint32_t *)addressPtr); - - sprintf(reportString, "EEPROM_dword_rw (addr= 0x%04X)", addressPtr); - if (dataLongWordRead == dataLongWord) - { - ATS_PrintTestStatus(reportString, PASSED); - } - else - { - ATS_PrintTestStatus(reportString, FAILED); - passedOK = false; - } - - - return(passedOK); -} - - - -//************************************************************************ -extern unsigned int __data_start; -extern unsigned int __data_end; -extern unsigned int __bss_start; -extern unsigned int __bss_end; -extern unsigned int __heap_start; -extern void *__brkval; - - - -//************************************************************************ -int ATS_GetFreeMemory() -{ -int free_memory; - - if((int)__brkval == 0) - { - free_memory = ((int)&free_memory) - ((int)&__bss_end); - } - else - { - free_memory = ((int)&free_memory) - ((int)__brkval); - } - return free_memory; -} - - diff --git a/libraries/ArduinoTestSuite/ArduinoTestSuite.h b/libraries/ArduinoTestSuite/ArduinoTestSuite.h deleted file mode 100644 index af810e1eb..000000000 --- a/libraries/ArduinoTestSuite/ArduinoTestSuite.h +++ /dev/null @@ -1,74 +0,0 @@ -//************************************************************************ -//************************************************************************ -//* Aug 31, 2010 Started on TestArduino -//************************************************************************ - -#ifndef _AVR_IO_H_ - #include -#endif - -#ifndef Arduino_h - #include "Arduino.h" -#endif -#ifndef HardwareSerial_h - #include "HardwareSerial.h" -#endif - - -#if defined(USART3_RX_vect) - #define SERIAL_PORT_COUNT 4 -#elif defined(USART1_RX_vect) - #define SERIAL_PORT_COUNT 2 -#else - #define SERIAL_PORT_COUNT 1 -#endif - - -void ATS_begin(char *manufName, char *testSuiteName); -void ATS_end(); - -void ATS_PrintTestStatus(char *testString, boolean passed); -boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest); -boolean ATS_Test_PWM_Pin(uint8_t digitalPinToTest); -boolean ATS_Test_AnalogInput(uint8_t analogPintoTest); -boolean ATS_Test_EEPROM(void); - -short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName); - - -int ATS_GetFreeMemory(); - -//************************************************************************ -//* this has to be an inline function because calling subroutines affects free memory -inline void ATS_ReportMemoryUsage(int _memoryUsageAtStart) -{ -int freeMemoryAtEnd; -int lostMemory; -boolean memoryOK; -char memoryUsage[48]; - - freeMemoryAtEnd = ATS_GetFreeMemory(); - lostMemory = _memoryUsageAtStart - freeMemoryAtEnd; - if (lostMemory == 0) - { - strcpy(memoryUsage, "Memory Usage"); - memoryOK = true; - } - else - { - sprintf(memoryUsage, "Memory Usage (lost %d bytes)", lostMemory); - memoryOK = false; - } - ATS_PrintTestStatus(memoryUsage, memoryOK); -} - - - -extern unsigned long gTestStartTime; -extern int gYotalErrors; -extern int gTestCount; - - -#define PASSED true -#define FAILED false - diff --git a/libraries/ArduinoTestSuite/avr_cpunames.h b/libraries/ArduinoTestSuite/avr_cpunames.h deleted file mode 100644 index 80832164c..000000000 --- a/libraries/ArduinoTestSuite/avr_cpunames.h +++ /dev/null @@ -1,186 +0,0 @@ -//************************************************************************************************** -//* -//* Atmel AVR CPU name strings -//* -//************************************************************************************************** -//* Sep 19, 2010 Started on avr_cpunames.h -//************************************************************************************************** - -//#include "avr_cpunames.h" - -//************************************************************************************************** - - -#if defined (__AVR_AT94K__) - #define _AVR_CPU_NAME_ "AT94k" -#elif defined (__AVR_AT43USB320__) -#elif defined (__AVR_AT43USB355__) -#elif defined (__AVR_AT76C711__) -#elif defined (__AVR_AT86RF401__) -#elif defined (__AVR_AT90PWM1__) -#elif defined (__AVR_AT90PWM2__) -#elif defined (__AVR_AT90PWM2B__) -#elif defined (__AVR_AT90PWM3__) -#elif defined (__AVR_AT90PWM3B__) -#elif defined (__AVR_AT90PWM216__) -#elif defined (__AVR_AT90PWM316__) -#elif defined (__AVR_ATmega32C1__) -#elif defined (__AVR_ATmega32M1__) -#elif defined (__AVR_ATmega32U4__) - #define _AVR_CPU_NAME_ "ATmega32U4" -#elif defined (__AVR_ATmega32U6__) - #define _AVR_CPU_NAME_ "ATmega32U6" -#elif defined (__AVR_ATmega128__) - #define _AVR_CPU_NAME_ "Atmega128" -#elif defined (__AVR_ATmega1280__) - #define _AVR_CPU_NAME_ "ATmega1280" -#elif defined (__AVR_ATmega1281__) - #define _AVR_CPU_NAME_ "ATmega1281" -#elif defined (__AVR_ATmega1284P__) - #define _AVR_CPU_NAME_ "ATmega1284" -#elif defined (__AVR_ATmega2560__) - #define _AVR_CPU_NAME_ "ATmega2560" -#elif defined (__AVR_ATmega2561__) - #define _AVR_CPU_NAME_ "ATmega2561" -#elif defined (__AVR_AT90CAN32__) - #define _AVR_CPU_NAME_ "AT90CAN32" -#elif defined (__AVR_AT90CAN64__) - #define _AVR_CPU_NAME_ "AT90CAN64" -#elif defined (__AVR_AT90CAN128__) - #define _AVR_CPU_NAME_ "AT90CAN128" -#elif defined (__AVR_AT90USB82__) - #define _AVR_CPU_NAME_ "AT90USB82" -#elif defined (__AVR_AT90USB162__) - #define _AVR_CPU_NAME_ "AT90USB162" -#elif defined (__AVR_AT90USB646__) - #define _AVR_CPU_NAME_ "AT90USB646" -#elif defined (__AVR_AT90USB647__) - #define _AVR_CPU_NAME_ "AT90USB647" -#elif defined (__AVR_AT90USB1286__) - #define _AVR_CPU_NAME_ "AT90USB1286" -#elif defined (__AVR_AT90USB1287__) - #define _AVR_CPU_NAME_ "AT90USB1287" -#elif defined (__AVR_ATmega64__) - #define _AVR_CPU_NAME_ "ATmega64" -#elif defined (__AVR_ATmega640__) - #define _AVR_CPU_NAME_ "ATmega640" -#elif defined (__AVR_ATmega644__) - #define _AVR_CPU_NAME_ "ATmega644" -#elif defined (__AVR_ATmega644P__) - #define _AVR_CPU_NAME_ "ATmega644P" -#elif defined (__AVR_ATmega645__) - #define _AVR_CPU_NAME_ "ATmega645" -#elif defined (__AVR_ATmega6450__) - #define _AVR_CPU_NAME_ "ATmega6450" -#elif defined (__AVR_ATmega649__) - #define _AVR_CPU_NAME_ "ATmega649" -#elif defined (__AVR_ATmega6490__) - #define _AVR_CPU_NAME_ "ATmega6490" -#elif defined (__AVR_ATmega103__) - #define _AVR_CPU_NAME_ "ATmega103" -#elif defined (__AVR_ATmega32__) - #define _AVR_CPU_NAME_ "Atmega32" -#elif defined (__AVR_ATmega323__) - #define _AVR_CPU_NAME_ "ATmega323" -#elif defined (__AVR_ATmega324P__) - #define _AVR_CPU_NAME_ "ATmega324P" -#elif defined (__AVR_ATmega325__) - #define _AVR_CPU_NAME_ "ATmega325" -#elif defined (__AVR_ATmega325P__) - #define _AVR_CPU_NAME_ "ATmega325P" -#elif defined (__AVR_ATmega3250__) - #define _AVR_CPU_NAME_ "ATmega3250" -#elif defined (__AVR_ATmega3250P__) - #define _AVR_CPU_NAME_ "ATmega3250P" -#elif defined (__AVR_ATmega328P__) - #define _AVR_CPU_NAME_ "ATmega328P" -#elif defined (__AVR_ATmega329__) - #define _AVR_CPU_NAME_ "ATmega329" -#elif defined (__AVR_ATmega329P__) - #define _AVR_CPU_NAME_ "ATmega329P" -#elif defined (__AVR_ATmega3290__) - #define _AVR_CPU_NAME_ "ATmega3290" -#elif defined (__AVR_ATmega3290P__) - #define _AVR_CPU_NAME_ "ATmega3290P" -#elif defined (__AVR_ATmega32HVB__) - #define _AVR_CPU_NAME_ "ATmega32HVB" -#elif defined (__AVR_ATmega406__) - #define _AVR_CPU_NAME_ "ATmega406" -#elif defined (__AVR_ATmega16__) - #define _AVR_CPU_NAME_ "Atmega16" -#elif defined (__AVR_ATmega161__) - #define _AVR_CPU_NAME_ "ATmega161" -#elif defined (__AVR_ATmega162__) - #define _AVR_CPU_NAME_ "ATmega162" -#elif defined (__AVR_ATmega163__) - #define _AVR_CPU_NAME_ "ATmega163" -#elif defined (__AVR_ATmega164P__) - #define _AVR_CPU_NAME_ "ATmega164P" -#elif defined (__AVR_ATmega165__) - #define _AVR_CPU_NAME_ "ATmega165" -#elif defined (__AVR_ATmega165P__) - #define _AVR_CPU_NAME_ "ATmega165P" -#elif defined (__AVR_ATmega168__) - #define _AVR_CPU_NAME_ "ATmega168" -#elif defined (__AVR_ATmega168P__) - #define _AVR_CPU_NAME_ "ATmega168P" -#elif defined (__AVR_ATmega169__) - #define _AVR_CPU_NAME_ "Atmega169" -#elif defined (__AVR_ATmega169P__) - #define _AVR_CPU_NAME_ "ATmega169P" -#elif defined (__AVR_ATmega8HVA__) - #define _AVR_CPU_NAME_ "ATmega8HVA" -#elif defined (__AVR_ATmega16HVA__) - #define _AVR_CPU_NAME_ "ATmega16HVA" -#elif defined (__AVR_ATmega8__) - #define _AVR_CPU_NAME_ "ATmega8" -#elif defined (__AVR_ATmega48__) - #define _AVR_CPU_NAME_ "ATmega48" -#elif defined (__AVR_ATmega48P__) - #define _AVR_CPU_NAME_ "ATmega48P" -#elif defined (__AVR_ATmega88__) - #define _AVR_CPU_NAME_ "ATmega88" -#elif defined (__AVR_ATmega88P__) - #define _AVR_CPU_NAME_ "ATmega88P" -#elif defined (__AVR_ATmega8515__) - #define _AVR_CPU_NAME_ "ATmega8515" -#elif defined (__AVR_ATmega8535__) - #define _AVR_CPU_NAME_ "ATmega8535" -#elif defined (__AVR_AT90S8535__) -#elif defined (__AVR_AT90C8534__) -#elif defined (__AVR_AT90S8515__) -#elif defined (__AVR_AT90S4434__) -#elif defined (__AVR_AT90S4433__) -#elif defined (__AVR_AT90S4414__) -#elif defined (__AVR_ATtiny22__) -#elif defined (__AVR_ATtiny26__) -#elif defined (__AVR_AT90S2343__) -#elif defined (__AVR_AT90S2333__) -#elif defined (__AVR_AT90S2323__) -#elif defined (__AVR_AT90S2313__) -#elif defined (__AVR_ATtiny2313__) - #define _AVR_CPU_NAME_ "ATtiny2313" -#elif defined (__AVR_ATtiny13__) -#elif defined (__AVR_ATtiny13A__) -#elif defined (__AVR_ATtiny25__) -#elif defined (__AVR_ATtiny45__) -#elif defined (__AVR_ATtiny85__) -#elif defined (__AVR_ATtiny24__) -#elif defined (__AVR_ATtiny44__) -#elif defined (__AVR_ATtiny84__) -#elif defined (__AVR_ATtiny261__) -#elif defined (__AVR_ATtiny461__) -#elif defined (__AVR_ATtiny861__) -#elif defined (__AVR_ATtiny43U__) -#elif defined (__AVR_ATtiny48__) -#elif defined (__AVR_ATtiny88__) -#elif defined (__AVR_ATtiny167__) - -#else - #error cpu not defined -#endif - - -#if !defined (_AVR_CPU_NAME_) -// #define _AVR_CPU_NAME_ "UNKNOWN" -#endif diff --git a/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde b/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde deleted file mode 100644 index 3196923f5..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde +++ /dev/null @@ -1,75 +0,0 @@ -//************************************************************************ -//* Arduino Test of Arduino Constants -//* (C) 2010 by Rick Anderson -//* Open source as per standard Arduino code -//* -//************************************************************************ -//* Oct 16, 2010 Test of Arduino Constants -//************************************************************************ - -#include "HardwareSerial.h" -#include - -//************************************************************************ -void setup() -{ - int startMemoryUsage; - - //Start memory usage must be site prior to ATS_begin - startMemoryUsage = ATS_GetFreeMemory(); - ATS_begin("Arduino", "Test of Arduino Constants"); - /* - * Test Run Start - */ - - - //test true constant - ATS_PrintTestStatus("1. Test of true constant", true == 1); - - //test false consts - ATS_PrintTestStatus( "2. Test of false constant", false == 0); - - //Test of HIGH == 1 - ATS_PrintTestStatus( "3. Test of HIGH == 1", HIGH == 1); - - //Test of LOW == 0 - ATS_PrintTestStatus( "4. Test of LOW == 0", LOW == 0); - - //Test of INPUT == 1 - ATS_PrintTestStatus( "5. Test of INPUT == 1", HIGH == 1); - - //Test of OUTPUT == 0 - ATS_PrintTestStatus( "6. Test of OUTPUT == 0", LOW == 0); - - //test decimal - ATS_PrintTestStatus( "7. Test of decimal constant", 101 == ((1 * pow(10,2)) + (0 * pow(10,1)) + 1)); - - //test binary - ATS_PrintTestStatus( "8. Test of binary constant", B101 == 5); - - //test octal - ATS_PrintTestStatus( "9. Test of octal constant", 0101 == 65); - - //test hexadecimal - ATS_PrintTestStatus( "7. Test of hexadecimal constant", (0x101 == 257)); - - /* - * Test Run End - */ - ATS_ReportMemoryUsage(startMemoryUsage); - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde b/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde deleted file mode 100644 index c3235d273..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde +++ /dev/null @@ -1 +0,0 @@ -//************************************************************************ //* 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 deleted file mode 100644 index 3c219bc13..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde +++ /dev/null @@ -1,93 +0,0 @@ -//************************************************************************ -//* Arduino Test Suite -//* (C) 2010 by Mark Sproul -//* Open source as per standard Arduino code -//* -//************************************************************************ -//* Aug 31, 2010 Started on TestArduino -//* Oct 18, 2010 Added memory testing -//************************************************************************ - -#include "HardwareSerial.h" -#include "pins_arduino.h" -#include -#include "avr_cpunames.h" - - -#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) -#define kBoard_PinCount 20 -#define kBoard_AnalogCount 6 -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -#define kBoard_PinCount 70 -#define kBoard_AnalogCount 16 -#endif - - - - -//************************************************************************ -void setup() -{ - short ii; - uint8_t timerNumber; - int startMemoryUsage; - - startMemoryUsage = ATS_GetFreeMemory(); - - ATS_begin("Arduino", "general"); - - //* test digital pins - //* we start at 2 because 0/1 are RXD/TXD - for (ii=2; ii 1) - ATS_TestSerialLoopback(&Serial1, "Serial1"); -#endif -#if (SERIAL_PORT_COUNT > 2) - ATS_TestSerialLoopback(&Serial2, "Serial2"); -#endif -#if (SERIAL_PORT_COUNT > 3) - ATS_TestSerialLoopback(&Serial3, "Serial3"); -#endif - - ATS_Test_EEPROM(); - - - ATS_ReportMemoryUsage(startMemoryUsage); - - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.pde b/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.pde deleted file mode 100644 index fefd6b07d..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.pde +++ /dev/null @@ -1,106 +0,0 @@ -// Tests writing to and reading from a file, in particular the -// the Stream implementation (e.g. read() and peek()). - -#include -#include - -void setup() -{ - int startMemoryUsage = ATS_GetFreeMemory(); - boolean b; - File f; - - ATS_begin("Arduino", "SD Test"); - - ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); - if (!b) goto done; - - SD.remove("test.txt"); - - f = SD.open("test.txt", FILE_WRITE); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - f.print("abc"); - f.print("de"); - f.close(); - - f = SD.open("test.txt", FILE_WRITE); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - f.print("fgh"); - f.close(); - - f = SD.open("test.txt"); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("read()", f.read() == 'a'); - ATS_PrintTestStatus("peek()", f.peek() == 'b'); - ATS_PrintTestStatus("read()", f.read() == 'b'); - ATS_PrintTestStatus("read()", f.read() == 'c'); - ATS_PrintTestStatus("peek()", f.peek() == 'd'); - ATS_PrintTestStatus("peek()", f.peek() == 'd'); - ATS_PrintTestStatus("peek()", f.peek() == 'd'); - ATS_PrintTestStatus("peek()", f.peek() == 'd'); - ATS_PrintTestStatus("read()", f.read() == 'd'); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("read()", f.read() == 'e'); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("peek()", f.peek() == 'f'); - ATS_PrintTestStatus("read()", f.read() == 'f'); - ATS_PrintTestStatus("peek()", f.peek() == 'g'); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("peek()", f.peek() == 'g'); - ATS_PrintTestStatus("read()", f.read() == 'g'); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("available()", f.available() != 0); - ATS_PrintTestStatus("peek()", f.peek() == 'h'); - ATS_PrintTestStatus("read()", f.read() == 'h'); - ATS_PrintTestStatus("available()", f.available() == 0); - ATS_PrintTestStatus("peek()", f.peek() == -1); - ATS_PrintTestStatus("read()", f.read() == -1); - ATS_PrintTestStatus("peek()", f.peek() == -1); - ATS_PrintTestStatus("read()", f.read() == -1); - - f.close(); - - SD.remove("test2.txt"); - - f = SD.open("test2.txt", FILE_WRITE); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - f.print("ABC"); - f.close(); - - f = SD.open("test.txt"); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("peek()", f.peek() == 'a'); - - f.close(); - - f = SD.open("test2.txt"); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("peek()", f.peek() == 'A'); - ATS_PrintTestStatus("read()", f.read() == 'A'); - - f.close(); - -done: - ATS_ReportMemoryUsage(startMemoryUsage); - ATS_end(); - -} - -void loop() {} - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.pde b/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.pde deleted file mode 100644 index c3804f4de..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.pde +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include - -void setup() -{ - int startMemoryUsage = ATS_GetFreeMemory(); - boolean b; - File f; - - ATS_begin("Arduino", "SD Files Test"); - - ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); - if (!b) goto done; - - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); - ATS_PrintTestStatus("SD.open()", f = SD.open("asdf.txt", FILE_WRITE)); f.close(); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf.txt")); - ATS_PrintTestStatus("SD.exists()", SD.exists("/asdf.txt")); - ATS_PrintTestStatus("SD.remove()", SD.remove("asdf.txt")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); - - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); - ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("/asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("asdf")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); - - ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("x/y/z")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/z")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/z/")); - ATS_PrintTestStatus("SD.exists()", SD.exists("/x/y/z/")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("x/y/z")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x/y")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("x/y/")); - ATS_PrintTestStatus("SD.exists()", SD.exists("x")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("/x")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); - - ATS_PrintTestStatus("!SD.open()", !(f = SD.open("asdf/asdf.txt", FILE_WRITE))); f.close(); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf/asdf.txt")); - ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); - ATS_PrintTestStatus("SD.open()", f = SD.open("asdf/asdf.txt", FILE_WRITE)); f.close(); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/asdf.txt")); - ATS_PrintTestStatus("!SD.rmdir()", !SD.rmdir("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/asdf.txt")); - ATS_PrintTestStatus("SD.remove()", SD.remove("asdf/asdf.txt")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf/asdf.txt")); - ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); - ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("asdf")); - ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); - -done: - ATS_ReportMemoryUsage(startMemoryUsage); - ATS_end(); - -} - -void loop() {} - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.pde b/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.pde deleted file mode 100644 index 5b0916ca7..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.pde +++ /dev/null @@ -1,109 +0,0 @@ -// Tests writing to and reading from a file, in particular the -// the Stream implementation (e.g. read() and peek()). - -#include -#include - -void setup() -{ - int startMemoryUsage = ATS_GetFreeMemory(); - boolean b; - File f; - - ATS_begin("Arduino", "SD Test"); - - ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); - if (!b) goto done; - - SD.remove("test.txt"); - - f = SD.open("test.txt", FILE_WRITE); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("initial position", f.position() == 0); - ATS_PrintTestStatus("initial size", f.size() == 0); - - f.print("0123456789"); - - ATS_PrintTestStatus("position after writing", f.position() == 10); - ATS_PrintTestStatus("size after writing", f.size() == 10); - - f.seek(0); - - ATS_PrintTestStatus("size after seek", f.size() == 10); - ATS_PrintTestStatus("position after seek", f.position() == 0); - - f.seek(7); - - ATS_PrintTestStatus("position after seek", f.position() == 7); - ATS_PrintTestStatus("reading after seek", f.read() == '7'); - ATS_PrintTestStatus("position after reading after seeking", f.position() == 8); - ATS_PrintTestStatus("reading after reading after seeking", f.read() == '8'); - - f.seek(3); - - ATS_PrintTestStatus("position after seeking", f.position() == 3); - ATS_PrintTestStatus("peeking after seeking", f.peek() == '3'); - ATS_PrintTestStatus("position after peeking after seeking", f.position() == 3); - ATS_PrintTestStatus("peeking after peeking after seeking", f.peek() == '3'); - ATS_PrintTestStatus("position after peeking after seeking", f.position() == 3); - ATS_PrintTestStatus("peeking after peeking after seeking", f.read() == '3'); - ATS_PrintTestStatus("position after peeking after seeking", f.position() == 4); - - f.seek(1); - - ATS_PrintTestStatus("position after seeking", f.position() == 1); - ATS_PrintTestStatus("peeking after seeking", f.peek() == '1'); - - f.seek(4); - - ATS_PrintTestStatus("position after seeking", f.position() == 4); - ATS_PrintTestStatus("peeking after seeking", f.peek() == '4'); - - f.seek(7); - - ATS_PrintTestStatus("position()", f.position() == 7); - ATS_PrintTestStatus("read()", f.read() == '7'); - - f.seek(0); - f.peek(); - f.print("AB"); - - ATS_PrintTestStatus("position()", f.position() == 2); - ATS_PrintTestStatus("size()", f.size() == 10); - ATS_PrintTestStatus("read()", f.read() == '2'); - - f.seek(0); - - ATS_PrintTestStatus("read()", f.read() == 'A'); - ATS_PrintTestStatus("read()", f.read() == 'B'); - ATS_PrintTestStatus("read()", f.read() == '2'); - - f.close(); - - f = SD.open("test.txt"); - ATS_PrintTestStatus("SD.open()", f); - if (!f) goto done; - - ATS_PrintTestStatus("position()", f.position() == 0); - ATS_PrintTestStatus("size()", f.size() == 10); - ATS_PrintTestStatus("peek()", f.peek() == 'A'); - ATS_PrintTestStatus("read()", f.read() == 'A'); - - f.seek(4); - - ATS_PrintTestStatus("position()", f.position() == 4); - ATS_PrintTestStatus("size()", f.size() == 10); - ATS_PrintTestStatus("peek()", f.peek() == '4'); - ATS_PrintTestStatus("read()", f.read() == '4'); - - f.close(); - -done: - ATS_ReportMemoryUsage(startMemoryUsage); - ATS_end(); - -} - -void loop() {} diff --git a/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde b/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde deleted file mode 100644 index e7fc4fa08..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde +++ /dev/null @@ -1,51 +0,0 @@ -//************************************************************************ -//* Arduino Test Example Skeleton -//* (C) 2010 by Rick Anderson -//* Open source as per standard Arduino code -//* -//************************************************************************ -//* Oct 16, 2010 Started on String Test -//************************************************************************ - -#include "HardwareSerial.h" -#include - -//************************************************************************ -void setup() -{ - int startMemoryUsage; - - //startMemoryUsage must be set directly before ATS_begin - startMemoryUsage = ATS_GetFreeMemory(); - ATS_begin("Arduino", "Skeleton Test"); - /* - * Test Run Start - * Test one passes because result is set to true - * Test two fails becuase result is set to false - * You can test memory for any set of tests by using the ATS_ReportMemoryUsage test - * There is also a way to print current memeory for debugging - */ - ATS_PrintTestStatus("1. Test of true test status", true); - - ATS_PrintTestStatus("2. Test of false test status, this will fail.", false); - - ATS_ReportMemoryUsage(startMemoryUsage); - /* - * Test Run End - */ - - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde b/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde deleted file mode 100644 index 000976104..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde +++ /dev/null @@ -1,101 +0,0 @@ -//************************************************************************ -//* Arduino Test Example Skeleton -//* (C) 2010 by Rick Anderson -//* Open source as per standard Arduino code -//* -//************************************************************************ -//* Oct 16, 2010 Started on String Test -//************************************************************************ - -#include "HardwareSerial.h" -#include - -//************************************************************************ -void setup() -{ - char testName[64]; - int startMemoryUsage; - /* - * Create variable for the tests. - */ - - - String stringOne; - int firstClosingBracket; - int firstOpeningBracket; - int secondOpeningBracket; - int secondClosingBracket; - int bodyTag; - int firstListItem; - int secondListItem; - int lastOpeningBracket; - int lastListItem; - int lastParagraph; - int secondLastGraf; - - /*; - * initiate the test run - */ - startMemoryUsage = ATS_GetFreeMemory(); - ATS_begin("Arduino", "String Memory Test"); - // indexOf() returns the position (i.e. index) of a particular character - // in a string. For example, if you were parsing HTML tags, you could use it: - stringOne = ""; - firstClosingBracket = stringOne.indexOf('>'); - Serial.println("The index of > in the string " + stringOne + " is " + firstClosingBracket); - - stringOne = ""; - secondOpeningBracket = firstClosingBracket + 1; - secondClosingBracket = stringOne.indexOf('>', secondOpeningBracket ); - Serial.println("The index of the second > in the string " + stringOne + " is " + secondClosingBracket); - - // you can also use indexOf() to search for Strings: - stringOne = ""; - bodyTag = stringOne.indexOf(""); - Serial.println("The index of the body tag in the string " + stringOne + " is " + bodyTag); - - stringOne = "
  • item
  • item
  • item
"; - firstListItem = stringOne.indexOf("
  • "); - secondListItem = stringOne.indexOf("item", firstListItem + 1 ); - Serial.println("The index of the second list item in the string " + stringOne + " is " + secondClosingBracket); - - // lastIndexOf() gives you the last occurrence of a character or string: - lastOpeningBracket = stringOne.lastIndexOf('<'); - Serial.println("The index of the last < in the string " + stringOne + " is " + lastOpeningBracket); - - lastListItem = stringOne.lastIndexOf("
  • "); - Serial.println("The index of the last list item in the string " + stringOne + " is " + lastListItem); - - - // lastIndexOf() can also search for a string: - stringOne = "

    Lorem ipsum dolor sit amet

    Ipsem

    Quod

    "; - lastParagraph = stringOne.lastIndexOf(" Started on String Test -//************************************************************************ - -#include "HardwareSerial.h" -#include - -//************************************************************************ -void setup() -{ - - int startMemoryUsage; - - ATS_begin("Arduino", "Test of String Library"); - - /* - * Test Variable Setup - * Best practive set all your test variables prior to teseting. - * This is required for Memory tests. - */ - - String stringOne = String("stringThree = "); - String stringTwo = String("this string"); - String stringThree = String (); - char charResult[100]; - - - - /* - * Run the tests - */ - - // adding a constant integer to a string: - stringThree = stringOne + 123; - //strcpy(charResult, "\0"); - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("1. Adding a constant integer to a string:", strcmp(charResult,"stringThree = 123" ) == 0); - - // adding a constant long interger to a string: - stringThree = stringOne + 123456789; - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("2. Adding a constant long interger to a string", strcmp(charResult,"stringThree = 123456789" ) == 0); - - - // adding a constant character to a string: - stringThree = stringOne + 'A'; - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("3. Adding a constant character to a string", strcmp(charResult,"stringThree = A" ) == 0); - - - // adding a constant string to a string: - stringThree = stringOne + "abc"; - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("4. Adding a constant string variable to a string", strcmp(charResult,"stringThree = abc" ) == 0); - - //"5. Adding a constant long interger to a string" - stringThree = stringOne + stringTwo; - stringThree.toCharArray(charResult, sizeof(charResult)); - - ATS_PrintTestStatus("5. Adding a constant long interger to a string", strcmp(charResult,"stringThree = this string" ) == 0); - - - /* - * setup up String Comparison Operater Tests - */ - - stringOne = String("this"); - stringTwo = String("that"); - - // two strings equal: - ATS_PrintTestStatus("6. Two strings equal",stringOne == "this"); - - // two strings not equal: - ATS_PrintTestStatus("7. Two strings not equal",stringOne != stringTwo); - - // two strings not equal (case sensitivity matters): - stringOne = "This"; - stringTwo = "this"; - ATS_PrintTestStatus("8. Two strings not equal [case sensitivity matters]", stringOne != stringTwo); - - // you can also use equals() to see if two strings are the same: - stringOne = "this"; - stringTwo = "this"; - ATS_PrintTestStatus("9. Equals() method equals", stringOne.equals(stringTwo)); - - - // you can also use not equals() to see if two strings are not the same: - stringOne = String("This"); - stringTwo = String("this"); - ATS_PrintTestStatus("10. Not equals() method equals", !stringOne.equals(stringTwo)); - - // or perhaps you want to ignore case: - ATS_PrintTestStatus("11. EqualsIgnoreCase() method equals", stringOne.equalsIgnoreCase(stringTwo)); - - // a numeric string compared to the number it represents: - stringOne = "1"; - int numberOne = 1; - ATS_PrintTestStatus("12. A numeric string compared to the number it represents", stringOne == numberOne); - - // two numeric strings compared: - stringOne = "2"; - stringTwo = "1"; - ATS_PrintTestStatus("13. Two numeric strings compared",stringOne >= stringTwo); - - - // comparison operators can be used to compare strings for alphabetic sorting too: - -/* - stringOne = String("Brown"); - ATS_PrintTestStatus("14. comparison operator < can be used to compare strings for alphabetic sorting ",stringOne < "Charles"); - ATS_PrintTestStatus("15. comparison operator > can be used to compare strings for alphabetic sorting ",stringOne > "Adams"); - ATS_PrintTestStatus("16. comparison operator <= can be used to compare strings for alphabetic sorting ",stringOne <= "Browne"); - ATS_PrintTestStatus("17. comparison operator >= can be used to compare strings for alphabetic sorting ",stringOne >= "Brow"); - */ - - - // the compareTo() operator also allows you to compare strings - stringOne = "Cucumber"; - stringTwo = "Cucuracha"; - - ATS_PrintTestStatus("18. The compareTo() operator also allows you to compare strings", stringOne.compareTo(stringTwo) < 0); - - // compareTo() String with numnber > String with number: - stringOne = "Sensor: 50"; - stringTwo= "Sensor: 150"; - ATS_PrintTestStatus("19. The compareTo() String with integers", stringOne.compareTo(stringTwo) < 0); - - -// compareTo() String with numnber > String with number append integer, matches example code: - stringOne = "Sensor: "; - stringTwo= "Sensor: "; - stringOne += 50; - stringTwo += 150; - ATS_PrintTestStatus("20. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); - - - /* - * setup up String Append Operation Tests - */ - // Serious awful problem here - stringOne = String("Sensor "); - stringTwo = String("value"); - - stringOne += stringTwo; - ATS_PrintTestStatus("21. Adding string to string += ", stringOne.equals("Sensor value")); - - ATS_PrintTestStatus("22. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); - /* - * Test complete - */ - - ATS_end(); - -} - - -//************************************************************************ -void loop() -{ - - -} - - - - - - - - - - - - diff --git a/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.pde b/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.pde deleted file mode 100644 index 3c35627ba..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_String_Addition/ATS_String_Addition.pde +++ /dev/null @@ -1,61 +0,0 @@ -#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 deleted file mode 100644 index b244081e5..000000000 --- a/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde +++ /dev/null @@ -1,249 +0,0 @@ -//************************************************************************ -//* 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 23, 2010 Started on ToneTest -//************************************************************************ - - - - - -#include "HardwareSerial.h" - -#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) - #define kBoard_PinCount 20 - #define kBoard_AnalogCount 6 -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) - #define kBoard_PinCount 70 - #define kBoard_AnalogCount 16 -#endif - -#include - -//************************************************************************ -void TestTonePin(uint8_t toneOutputPinNumber) -{ -uint8_t helperpin; -unsigned long startMilliSecs; -unsigned long highCount, lowCount; -int previousState; -int currentState; -char testNameString[80]; -long outputFreq; -long measuredFreq; -boolean passed; -long percentError; -long deltaFreq; - - if ((toneOutputPinNumber % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = toneOutputPinNumber + 1; - } - else - { - //* if its ODD - helperpin = toneOutputPinNumber - 1; - } - - //* dont set the mode of the OUTPUT pin, the tone command does that - - pinMode(helperpin, INPUT); - - previousState = digitalRead(helperpin); - startMilliSecs = millis(); - highCount = 0; - lowCount = 0; - measuredFreq = 0; - //* we are going to watch for one second - outputFreq = random(200, 2000); - - tone(toneOutputPinNumber, outputFreq); - while ((millis() - startMilliSecs) < 1000) - { - currentState = digitalRead(helperpin); - if (currentState == HIGH) - { - highCount++; - } - else - { - lowCount++; - } - //* check to see if it changed state - if ((currentState == HIGH) && (previousState == LOW)) - { - measuredFreq++; - } - - previousState = currentState; - } - noTone(toneOutputPinNumber); - - deltaFreq = abs(measuredFreq - outputFreq); - - percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); - - sprintf(testNameString, "ToneTest.%02d (out freq= %4ld measured freq= %4ld err= %ld%%)", toneOutputPinNumber, outputFreq, measuredFreq, percentError); - if (percentError < 5) - { - passed = true; - } - else - { - passed = false; - } - - ATS_PrintTestStatus(testNameString, passed); -} - - -//************************************************************************ -//* this test to make sure the duration option works -void TestToneDuration(uint8_t toneOutputPinNumber) -{ -uint8_t helperpin; -unsigned long startMilliSecs; -unsigned long highCount, lowCount; -int previousState; -int currentState; -char testNameString[80]; -long outputFreq; -long measuredFreq; -boolean passed; -long percentError; -long deltaFreq; -long durationTime; - - if ((toneOutputPinNumber % 2) == 0) - { - //* if its EVEN, add 1 - helperpin = toneOutputPinNumber + 1; - } - else - { - //* if its ODD - helperpin = toneOutputPinNumber - 1; - } - - //* dont set the mode of the OUTPUT pin, the tone command does that - - pinMode(helperpin, INPUT); - - previousState = digitalRead(helperpin); - startMilliSecs = millis(); - highCount = 0; - lowCount = 0; - measuredFreq = 0; - durationTime = 0; - //* we are going to watch for one second - outputFreq = random(500, 2000); - - tone(toneOutputPinNumber, outputFreq, 1000); - while ((millis() - startMilliSecs) < 2000) - { - currentState = digitalRead(helperpin); - if (currentState == HIGH) - { - highCount++; - } - else - { - lowCount++; - } - //* count the freq - if ((currentState == HIGH) && (previousState == LOW)) - { - measuredFreq++; - } - - //* check to see if it changed state - if (currentState != previousState) - { - durationTime = millis() - startMilliSecs; - } - - previousState = currentState; - } - - deltaFreq = abs(measuredFreq - outputFreq); - - percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); - - sprintf(testNameString, "ToneTesDurationt.%02d (durationTime =%4ld/1000 freq err= %ld%%)", toneOutputPinNumber, durationTime, percentError); - if ((durationTime > 990) && (durationTime < 1010) && (percentError < 5)) - { - passed = true; - } - else - { - passed = false; - } - noTone(toneOutputPinNumber); - - ATS_PrintTestStatus(testNameString, passed); -} - - - -//************************************************************************ -void setup() -{ -short ii; -uint8_t timerNumber; -int startMemoryUsage; - - startMemoryUsage = ATS_GetFreeMemory(); - - ATS_begin("Arduino", "ToneTest"); - - - //* we start at 2 because 0/1 are RXD/TXD - for (ii=2; ii - -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/examples/eeprom_clear/eeprom_clear.pde b/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino similarity index 100% rename from libraries/EEPROM/examples/eeprom_clear/eeprom_clear.pde rename to libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino diff --git a/libraries/EEPROM/examples/eeprom_read/eeprom_read.pde b/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino similarity index 100% rename from libraries/EEPROM/examples/eeprom_read/eeprom_read.pde rename to libraries/EEPROM/examples/eeprom_read/eeprom_read.ino diff --git a/libraries/EEPROM/examples/eeprom_write/eeprom_write.pde b/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino similarity index 100% rename from libraries/EEPROM/examples/eeprom_write/eeprom_write.pde rename to libraries/EEPROM/examples/eeprom_write/eeprom_write.ino diff --git a/libraries/Ethernet/Dhcp.cpp b/libraries/Ethernet/Dhcp.cpp index c20d2e61d..29db89098 100755 --- a/libraries/Ethernet/Dhcp.cpp +++ b/libraries/Ethernet/Dhcp.cpp @@ -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/Dhcp.h b/libraries/Ethernet/Dhcp.h index c0034940c..f87719959 100755 --- a/libraries/Ethernet/Dhcp.h +++ b/libraries/Ethernet/Dhcp.h @@ -4,7 +4,7 @@ #ifndef Dhcp_h #define Dhcp_h -#include "Udp.h" +#include "EthernetUdp.h" /* DHCP state machine. */ #define STATE_DHCP_START 0 @@ -139,7 +139,7 @@ private: uint8_t _dhcpGatewayIp[4]; uint8_t _dhcpDhcpServerIp[4]; uint8_t _dhcpDnsServerIp[4]; - UDP _dhcpUdpSocket; + EthernetUDP _dhcpUdpSocket; void presend_DHCP(); void send_DHCP_MESSAGE(uint8_t, uint16_t); diff --git a/libraries/Ethernet/Dns.cpp b/libraries/Ethernet/Dns.cpp index a049c7633..86fd0177a 100644 --- a/libraries/Ethernet/Dns.cpp +++ b/libraries/Ethernet/Dns.cpp @@ -3,7 +3,7 @@ // Released under Apache License, version 2.0 #include "w5100.h" -#include "Udp.h" +#include "EthernetUdp.h" #include "util.h" #include "Dns.h" diff --git a/libraries/Ethernet/Dns.h b/libraries/Ethernet/Dns.h index 9582351f2..d4f49769b 100644 --- a/libraries/Ethernet/Dns.h +++ b/libraries/Ethernet/Dns.h @@ -5,7 +5,7 @@ #ifndef DNSClient_h #define DNSClient_h -#include +#include class DNSClient { @@ -35,7 +35,7 @@ protected: IPAddress iDNSServer; uint16_t iRequestId; - UDP iUdp; + EthernetUDP iUdp; }; #endif 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..c916ddae5 100644 --- a/libraries/Ethernet/Ethernet.h +++ b/libraries/Ethernet/Ethernet.h @@ -4,8 +4,8 @@ #include //#include "w5100.h" #include "IPAddress.h" -#include "Client.h" -#include "Server.h" +#include "EthernetClient.h" +#include "EthernetServer.h" #define MAX_SOCK_NUM 4 @@ -20,16 +20,17 @@ 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(); IPAddress gatewayIP(); IPAddress dnsServerIP(); - friend class Client; - friend class Server; + friend class EthernetClient; + friend class EthernetServer; }; extern EthernetClass Ethernet; diff --git a/libraries/Ethernet/Client.cpp b/libraries/Ethernet/EthernetClient.cpp similarity index 73% rename from libraries/Ethernet/Client.cpp rename to libraries/Ethernet/EthernetClient.cpp index 3c1c2503b..42c2c6cc1 100644 --- a/libraries/Ethernet/Client.cpp +++ b/libraries/Ethernet/EthernetClient.cpp @@ -8,19 +8,19 @@ extern "C" { #include "Arduino.h" #include "Ethernet.h" -#include "Client.h" -#include "Server.h" +#include "EthernetClient.h" +#include "EthernetServer.h" #include "Dns.h" -uint16_t Client::_srcport = 1024; +uint16_t EthernetClient::_srcport = 1024; -Client::Client() : _sock(MAX_SOCK_NUM) { +EthernetClient::EthernetClient() : _sock(MAX_SOCK_NUM) { } -Client::Client(uint8_t sock) : _sock(sock) { +EthernetClient::EthernetClient(uint8_t sock) : _sock(sock) { } -int Client::connect(const char* host, uint16_t port) { +int EthernetClient::connect(const char* host, uint16_t port) { // Look up the host first int ret = 0; DNSClient dns; @@ -35,7 +35,7 @@ int Client::connect(const char* host, uint16_t port) { } } -int Client::connect(IPAddress ip, uint16_t port) { +int EthernetClient::connect(IPAddress ip, uint16_t port) { if (_sock != MAX_SOCK_NUM) return 0; @@ -54,7 +54,7 @@ int Client::connect(IPAddress ip, uint16_t port) { if (_srcport == 0) _srcport = 1024; socket(_sock, SnMR::TCP, _srcport, 0); - if (!::connect(_sock, ip.raw_address(), port)) { + if (!::connect(_sock, rawIPAddress(ip), port)) { _sock = MAX_SOCK_NUM; return 0; } @@ -70,15 +70,15 @@ int Client::connect(IPAddress ip, uint16_t port) { return 1; } -size_t Client::write(uint8_t b) { +size_t EthernetClient::write(uint8_t b) { return write(&b, 1); } -size_t Client::write(const char *str) { +size_t EthernetClient::write(const char *str) { return write((const uint8_t *) str, strlen(str)); } -size_t Client::write(const uint8_t *buf, size_t size) { +size_t EthernetClient::write(const uint8_t *buf, size_t size) { if (_sock == MAX_SOCK_NUM) { setWriteError(); return 0; @@ -90,13 +90,13 @@ size_t Client::write(const uint8_t *buf, size_t size) { return size; } -int Client::available() { +int EthernetClient::available() { if (_sock != MAX_SOCK_NUM) return W5100.getRXReceivedSize(_sock); return 0; } -int Client::read() { +int EthernetClient::read() { uint8_t b; if ( recv(_sock, &b, 1) > 0 ) { @@ -110,11 +110,11 @@ int Client::read() { } } -int Client::read(uint8_t *buf, size_t size) { +int EthernetClient::read(uint8_t *buf, size_t size) { return recv(_sock, buf, size); } -int Client::peek() { +int EthernetClient::peek() { uint8_t b; // Unlike recv, peek doesn't check to see if there's any data available, so we must if (!available()) @@ -123,12 +123,12 @@ int Client::peek() { return b; } -void Client::flush() { +void EthernetClient::flush() { while (available()) read(); } -void Client::stop() { +void EthernetClient::stop() { if (_sock == MAX_SOCK_NUM) return; @@ -148,7 +148,7 @@ void Client::stop() { _sock = MAX_SOCK_NUM; } -uint8_t Client::connected() { +uint8_t EthernetClient::connected() { if (_sock == MAX_SOCK_NUM) return 0; uint8_t s = status(); @@ -156,14 +156,14 @@ uint8_t Client::connected() { (s == SnSR::CLOSE_WAIT && !available())); } -uint8_t Client::status() { +uint8_t EthernetClient::status() { if (_sock == MAX_SOCK_NUM) return SnSR::CLOSED; return W5100.readSnSR(_sock); } // the next function allows us to use the client returned by -// Server::available() as the condition in an if-statement. +// EthernetServer::available() as the condition in an if-statement. -Client::operator bool() { +EthernetClient::operator bool() { return _sock != MAX_SOCK_NUM; } diff --git a/libraries/Ethernet/Client.h b/libraries/Ethernet/EthernetClient.h similarity index 50% rename from libraries/Ethernet/Client.h rename to libraries/Ethernet/EthernetClient.h index a8dd6fa42..f68a3b4d9 100644 --- a/libraries/Ethernet/Client.h +++ b/libraries/Ethernet/EthernetClient.h @@ -1,17 +1,19 @@ -#ifndef client_h -#define client_h +#ifndef ethernetclient_h +#define ethernetclient_h #include "Arduino.h" #include "Print.h" +#include "Client.h" +#include "IPAddress.h" -class Client : public Stream { +class EthernetClient : public Client { public: - Client(); - Client(uint8_t sock); + EthernetClient(); + EthernetClient(uint8_t sock); uint8_t status(); - int connect(IPAddress ip, uint16_t port); - int connect(const char *host, uint16_t port); + virtual int connect(IPAddress ip, uint16_t port); + virtual int connect(const char *host, uint16_t port); virtual size_t write(uint8_t); virtual size_t write(const char *str); virtual size_t write(const uint8_t *buf, size_t size); @@ -20,11 +22,11 @@ public: virtual int read(uint8_t *buf, size_t size); virtual int peek(); virtual void flush(); - void stop(); - uint8_t connected(); - operator bool(); + virtual void stop(); + virtual uint8_t connected(); + virtual operator bool(); - friend class Server; + friend class EthernetServer; private: static uint16_t _srcport; diff --git a/libraries/Ethernet/Server.cpp b/libraries/Ethernet/EthernetServer.cpp similarity index 72% rename from libraries/Ethernet/Server.cpp rename to libraries/Ethernet/EthernetServer.cpp index 1ac75d507..9ae86f39e 100644 --- a/libraries/Ethernet/Server.cpp +++ b/libraries/Ethernet/EthernetServer.cpp @@ -5,18 +5,18 @@ extern "C" { } #include "Ethernet.h" -#include "Client.h" -#include "Server.h" +#include "EthernetClient.h" +#include "EthernetServer.h" -Server::Server(uint16_t port) +EthernetServer::EthernetServer(uint16_t port) { _port = port; } -void Server::begin() +void EthernetServer::begin() { for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { - Client client(sock); + EthernetClient client(sock); if (client.status() == SnSR::CLOSED) { socket(sock, SnMR::TCP, _port, 0); listen(sock); @@ -26,12 +26,12 @@ void Server::begin() } } -void Server::accept() +void EthernetServer::accept() { int listening = 0; for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { - Client client(sock); + EthernetClient client(sock); if (EthernetClass::_server_port[sock] == _port) { if (client.status() == SnSR::LISTEN) { @@ -48,12 +48,12 @@ void Server::accept() } } -Client Server::available() +EthernetClient EthernetServer::available() { accept(); for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { - Client client(sock); + EthernetClient client(sock); if (EthernetClass::_server_port[sock] == _port && (client.status() == SnSR::ESTABLISHED || client.status() == SnSR::CLOSE_WAIT)) { @@ -64,27 +64,27 @@ Client Server::available() } } - return Client(MAX_SOCK_NUM); + return EthernetClient(MAX_SOCK_NUM); } -size_t Server::write(uint8_t b) +size_t EthernetServer::write(uint8_t b) { write(&b, 1); } -size_t Server::write(const char *str) +size_t EthernetServer::write(const char *str) { write((const uint8_t *)str, strlen(str)); } -size_t Server::write(const uint8_t *buffer, size_t size) +size_t EthernetServer::write(const uint8_t *buffer, size_t size) { size_t n = 0; accept(); for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { - Client client(sock); + EthernetClient client(sock); if (EthernetClass::_server_port[sock] == _port && client.status() == SnSR::ESTABLISHED) { diff --git a/libraries/Ethernet/EthernetServer.h b/libraries/Ethernet/EthernetServer.h new file mode 100644 index 000000000..ced5ed649 --- /dev/null +++ b/libraries/Ethernet/EthernetServer.h @@ -0,0 +1,22 @@ +#ifndef ethernetserver_h +#define ethernetserver_h + +#include "Server.h" + +class EthernetClient; + +class EthernetServer : +public Server { +private: + uint16_t _port; + void accept(); +public: + EthernetServer(uint16_t); + EthernetClient available(); + virtual void begin(); + 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/EthernetUdp.cpp similarity index 83% rename from libraries/Ethernet/Udp.cpp rename to libraries/Ethernet/EthernetUdp.cpp index a1244ffb9..9ca650986 100644 --- a/libraries/Ethernet/Udp.cpp +++ b/libraries/Ethernet/EthernetUdp.cpp @@ -33,10 +33,10 @@ #include "Dns.h" /* Constructor */ -UDP::UDP() : _sock(MAX_SOCK_NUM) {} +EthernetUDP::EthernetUDP() : _sock(MAX_SOCK_NUM) {} -/* Start UDP socket, listening at local port PORT */ -uint8_t UDP::begin(uint16_t port) { +/* Start EthernetUDP socket, listening at local port PORT */ +uint8_t EthernetUDP::begin(uint16_t port) { if (_sock != MAX_SOCK_NUM) return 0; @@ -59,12 +59,12 @@ uint8_t UDP::begin(uint16_t port) { /* Is data available in rx buffer? Returns 0 if no, number of available bytes if yes. * returned value includes 8 byte UDP header!*/ -int UDP::available() { +int EthernetUDP::available() { return W5100.getRXReceivedSize(_sock); } -/* Release any resources being used by this UDP instance */ -void UDP::stop() +/* Release any resources being used by this EthernetUDP instance */ +void EthernetUDP::stop() { if (_sock == MAX_SOCK_NUM) return; @@ -75,7 +75,7 @@ void UDP::stop() _sock = MAX_SOCK_NUM; } -int UDP::beginPacket(const char *host, uint16_t port) +int EthernetUDP::beginPacket(const char *host, uint16_t port) { // Look up the host first int ret = 0; @@ -91,36 +91,36 @@ int UDP::beginPacket(const char *host, uint16_t port) } } -int UDP::beginPacket(IPAddress ip, uint16_t port) +int EthernetUDP::beginPacket(IPAddress ip, uint16_t port) { _offset = 0; - return startUDP(_sock, ip.raw_address(), port); + return startUDP(_sock, rawIPAddress(ip), port); } -int UDP::endPacket() +int EthernetUDP::endPacket() { return sendUDP(_sock); } -size_t UDP::write(uint8_t byte) +size_t EthernetUDP::write(uint8_t byte) { return write(&byte, 1); } -size_t UDP::write(const char *str) +size_t EthernetUDP::write(const char *str) { size_t len = strlen(str); return write((const uint8_t *)str, len); } -size_t UDP::write(const uint8_t *buffer, size_t size) +size_t EthernetUDP::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() +int EthernetUDP::parsePacket() { if (available() > 0) { @@ -143,7 +143,7 @@ int UDP::parsePacket() return 0; } -int UDP::read() +int EthernetUDP::read() { uint8_t byte; if (recv(_sock, &byte, 1) > 0) @@ -155,7 +155,7 @@ int UDP::read() return -1; } -int UDP::read(unsigned char* buffer, size_t len) +int EthernetUDP::read(unsigned char* buffer, size_t len) { /* In the readPacket that copes with truncating packets, the buffer was filled with this code. Not sure why it loops round reading out a byte @@ -169,7 +169,7 @@ int UDP::read(unsigned char* buffer, size_t len) return recv(_sock, buffer, len); } -int UDP::peek() +int EthernetUDP::peek() { uint8_t b; // Unlike recv, peek doesn't check to see if there's any data available, so we must @@ -179,7 +179,7 @@ int UDP::peek() return b; } -void UDP::flush() +void EthernetUDP::flush() { while (available()) { diff --git a/libraries/Ethernet/Udp.h b/libraries/Ethernet/EthernetUdp.h similarity index 87% rename from libraries/Ethernet/Udp.h rename to libraries/Ethernet/EthernetUdp.h index 59238c1ae..64e30275f 100644 --- a/libraries/Ethernet/Udp.h +++ b/libraries/Ethernet/EthernetUdp.h @@ -34,15 +34,14 @@ * bjoern@cs.stanford.edu 12/30/2008 */ -#ifndef udp_h -#define udp_h +#ifndef ethernetudp_h +#define ethernetudp_h -#include -#include +#include #define UDP_TX_PACKET_MAX_SIZE 24 -class UDP : public Stream { +class EthernetUDP : public UDP { private: uint8_t _sock; // socket ID for Wiz5100 uint16_t _port; // local port to listen on @@ -51,21 +50,21 @@ private: uint16_t _offset; // offset into the packet being sent public: - UDP(); // Constructor - uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use - void stop(); // Finish with the UDP socket + EthernetUDP(); // Constructor + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket // Sending UDP packets // Start building up a packet to send to the remote host specific in ip and port // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port - int beginPacket(IPAddress ip, uint16_t port); + virtual int beginPacket(IPAddress ip, uint16_t port); // Start building up a packet to send to the remote host specific in host and port // Returns 1 if successful, 0 if there was a problem resolving the hostname or port - int beginPacket(const char *host, uint16_t port); + virtual int beginPacket(const char *host, uint16_t port); // Finish off this packet and send it // Returns 1 if the packet was sent successfully, 0 if there was an error - int endPacket(); + virtual int endPacket(); // Write a single byte into the packet virtual size_t write(uint8_t); // Write a string of characters into the packet @@ -75,7 +74,7 @@ public: // Start processing the next available incoming packet // Returns the size of the packet in bytes, or 0 if no packets are available - int parsePacket(); + virtual int parsePacket(); // Number of bytes remaining in the current packet virtual int available(); // Read a single byte from the current packet @@ -91,9 +90,9 @@ public: virtual void flush(); // Finish reading the current packet // Return the IP address of the host who sent the current incoming packet - IPAddress remoteIP() { return _remoteIP; }; + virtual IPAddress remoteIP() { return _remoteIP; }; // Return the port of the host who sent the current incoming packet - uint16_t remotePort() { return _remotePort; }; + virtual uint16_t remotePort() { return _remotePort; }; }; #endif diff --git a/libraries/Ethernet/Server.h b/libraries/Ethernet/Server.h deleted file mode 100644 index fa4a56d88..000000000 --- a/libraries/Ethernet/Server.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef server_h -#define server_h - -#include "Print.h" - -class Client; - -class Server : -public Print { -private: - uint16_t _port; - void accept(); -public: - Server(uint16_t); - Client available(); - void begin(); - 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/examples/BarometricPressureWebServer/BarometricPressureWebServer.pde b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino similarity index 97% rename from libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.pde rename to libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino index 3f43d96db..bfbcb6d4a 100644 --- a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.pde +++ b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino @@ -39,7 +39,7 @@ IPAddress subnet(255, 255, 255, 0); // Initialize the Ethernet server library // with the IP address and port you want to use // (port 80 is default for HTTP): -Server server(80); +EthernetServer server(80); //Sensor's memory register addresses: @@ -96,7 +96,7 @@ void loop() { } // listen for incoming Ethernet connections: - listenForClients(); + listenForEthernetClients(); } @@ -124,9 +124,9 @@ void getData() { Serial.println(" Pa"); } -void listenForClients() { +void listenForEthernetClients() { // listen for incoming clients - Client client = server.available(); + EthernetClient client = server.available(); if (client) { Serial.println("Got a client"); // an http request ends with a blank line diff --git a/libraries/Ethernet/examples/ChatServer/ChatServer.pde b/libraries/Ethernet/examples/ChatServer/ChatServer.ino similarity index 95% rename from libraries/Ethernet/examples/ChatServer/ChatServer.pde rename to libraries/Ethernet/examples/ChatServer/ChatServer.ino index 8267a5dd4..9f819fd5a 100644 --- a/libraries/Ethernet/examples/ChatServer/ChatServer.pde +++ b/libraries/Ethernet/examples/ChatServer/ChatServer.ino @@ -29,7 +29,7 @@ IPAddress gateway(192,168,1, 1); IPAddress subnet(255, 255, 0, 0); // telnet defaults to port 23 -Server server(23); +EthernetServer server(23); boolean gotAMessage = false; // whether or not you got a message from the client yet void setup() { @@ -43,7 +43,7 @@ void setup() { void loop() { // wait for a new client: - Client client = server.available(); + EthernetClient client = server.available(); // when the client sends the first byte, say hello: if (client) { diff --git a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino index 8701568c0..630dd1711 100644 --- a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino +++ b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino @@ -24,24 +24,23 @@ byte mac[] = { // 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; +EthernetClient 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); + for(;;) + ; } // 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(Ethernet.localIP()[thisByte], DEC); Serial.print("."); } Serial.println(); diff --git a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.pde b/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.pde deleted file mode 100644 index 50a557dcc..000000000 --- a/libraries/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.pde +++ /dev/null @@ -1,53 +0,0 @@ -/* - 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 index c3e581387..50820542c 100644 --- a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino +++ b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino @@ -30,7 +30,7 @@ IPAddress gateway(192,168,1, 1); IPAddress subnet(255, 255, 0, 0); // telnet defaults to port 23 -Server server(23); +EthernetServer server(23); boolean gotAMessage = false; // whether or not you got a message from the client yet void setup() { @@ -59,7 +59,7 @@ void setup() { void loop() { // wait for a new client: - Client client = server.available(); + EthernetClient client = server.available(); // when the client sends the first byte, say hello: if (client) { diff --git a/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.pde b/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino similarity index 98% rename from libraries/Ethernet/examples/DnsWebClient/DnsWebClient.pde rename to libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino index 7bec73a83..5c7a53a65 100644 --- a/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.pde +++ b/libraries/Ethernet/examples/DnsWebClient/DnsWebClient.ino @@ -25,7 +25,7 @@ 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; +EthernetClient client; void setup() { // start the serial library: diff --git a/libraries/Ethernet/examples/PachubeClient/PachubeClient.pde b/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino similarity index 99% rename from libraries/Ethernet/examples/PachubeClient/PachubeClient.pde rename to libraries/Ethernet/examples/PachubeClient/PachubeClient.ino index af9bf1f05..e626113b0 100644 --- a/libraries/Ethernet/examples/PachubeClient/PachubeClient.pde +++ b/libraries/Ethernet/examples/PachubeClient/PachubeClient.ino @@ -29,7 +29,7 @@ byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // initialize the library instance: -Client client; +EthernetClient client; long lastConnectionTime = 0; // last time you connected to the server, in milliseconds boolean lastConnected = false; // state of the connection last time through the main loop diff --git a/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.pde b/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino similarity index 99% rename from libraries/Ethernet/examples/PachubeClientString/PachubeClientString.pde rename to libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino index e6dbf09ea..4b97c4175 100644 --- a/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.pde +++ b/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.ino @@ -30,7 +30,7 @@ byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // initialize the library instance: -Client client; +EthernetClient client; long lastConnectionTime = 0; // last time you connected to the server, in milliseconds boolean lastConnected = false; // state of the connection last time through the main loop diff --git a/libraries/Ethernet/examples/TelnetClient/TelnetClient.pde b/libraries/Ethernet/examples/TelnetClient/TelnetClient.ino similarity index 98% rename from libraries/Ethernet/examples/TelnetClient/TelnetClient.pde rename to libraries/Ethernet/examples/TelnetClient/TelnetClient.ino index 7502d218d..5cf1ad875 100644 --- a/libraries/Ethernet/examples/TelnetClient/TelnetClient.pde +++ b/libraries/Ethernet/examples/TelnetClient/TelnetClient.ino @@ -33,7 +33,7 @@ IPAddress server(1,1,1,1); // with the IP address and port of the server // that you want to connect to (port 23 is default for telnet; // if you're using Processing's ChatServer, use port 10002): -Client client; +EthernetClient client; void setup() { // start the Ethernet connection: diff --git a/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino index 399e76bc3..f113e17b9 100644 --- a/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino +++ b/libraries/Ethernet/examples/TwitterClient/TwitterClient.ino @@ -33,7 +33,7 @@ byte mac[] = { IPAddress ip(192,168,1,20); // initialize the library instance: -Client client; +EthernetClient client; const int requestInterval = 60000; // delay between requests diff --git a/libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.pde b/libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.ino similarity index 94% rename from libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.pde rename to libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.ino index 081d69114..4d4045cac 100644 --- a/libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.pde +++ b/libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.ino @@ -15,7 +15,7 @@ #include // needed for Arduino versions later than 0018 #include -#include // UDP library from: bjoern@cs.stanford.edu 12/30/2008 +#include // UDP library from: bjoern@cs.stanford.edu 12/30/2008 // Enter a MAC address and IP address for your controller below. @@ -30,8 +30,8 @@ unsigned int localPort = 8888; // local port to listen on char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet, char ReplyBuffer[] = "acknowledged"; // a string to send back -// A UDP instance to let us send and receive packets over UDP -UDP Udp; +// An EthernetUDP instance to let us send and receive packets over UDP +EthernetUDP Udp; void setup() { // start the Ethernet and UDP: diff --git a/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.pde b/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino similarity index 99% rename from libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.pde rename to libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino index 7c2d3ea9e..b4e24b8ce 100644 --- a/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.pde +++ b/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino @@ -18,7 +18,7 @@ #include #include -#include +#include // Enter a MAC address for your controller below. // Newer Ethernet shields have a MAC address printed on a sticker on the shield @@ -34,7 +34,7 @@ const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets // A UDP instance to let us send and receive packets over UDP -UDP Udp; +EthernetUDP Udp; void setup() { diff --git a/libraries/Ethernet/examples/WebClient/WebClient.pde b/libraries/Ethernet/examples/WebClient/WebClient.ino similarity index 98% rename from libraries/Ethernet/examples/WebClient/WebClient.pde rename to libraries/Ethernet/examples/WebClient/WebClient.ino index 646c3aadd..18068541f 100644 --- a/libraries/Ethernet/examples/WebClient/WebClient.pde +++ b/libraries/Ethernet/examples/WebClient/WebClient.ino @@ -23,7 +23,7 @@ IPAddress server(173,194,33,104); // Google // 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; +EthernetClient client; void setup() { // start the serial library: diff --git a/libraries/Ethernet/examples/WebServer/WebServer.pde b/libraries/Ethernet/examples/WebServer/WebServer.ino similarity index 96% rename from libraries/Ethernet/examples/WebServer/WebServer.pde rename to libraries/Ethernet/examples/WebServer/WebServer.ino index c69a56a40..6837f8320 100644 --- a/libraries/Ethernet/examples/WebServer/WebServer.pde +++ b/libraries/Ethernet/examples/WebServer/WebServer.ino @@ -1,5 +1,5 @@ /* - Web Server + Web Server A simple web server that shows the value of the analog input pins. using an Arduino Wiznet Ethernet shield. @@ -26,7 +26,7 @@ IPAddress ip(192,168,1, 177); // Initialize the Ethernet server library // with the IP address and port you want to use // (port 80 is default for HTTP): -Server server(80); +EthernetServer server(80); void setup() { @@ -38,7 +38,7 @@ void setup() void loop() { // listen for incoming clients - Client client = server.available(); + EthernetClient client = server.available(); if (client) { // an http request ends with a blank line boolean currentLineIsBlank = true; diff --git a/libraries/Ethernet/keywords.txt b/libraries/Ethernet/keywords.txt index 7fdcedf09..6b37cbe05 100644 --- a/libraries/Ethernet/keywords.txt +++ b/libraries/Ethernet/keywords.txt @@ -7,8 +7,8 @@ ####################################### Ethernet KEYWORD1 -Client KEYWORD1 -Server KEYWORD1 +EthernetClient KEYWORD1 +EthernetServer KEYWORD1 IPAddress KEYWORD1 ####################################### 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 f71632095..52f61873f 100644 --- a/libraries/Firmata/Boards.h +++ b/libraries/Firmata/Boards.h @@ -3,7 +3,13 @@ #ifndef Firmata_Boards_h #define Firmata_Boards_h -#include // for digitalRead, digitalWrite, etc +#include + +#if defined(ARDUINO) && ARDUINO >= 100 +#include "Arduino.h" // for digitalRead, digitalWrite, etc +#else +#include "WProgram.h" +#endif // Normally Servo.h must be included before Firmata.h (which then includes // this file). If Servo.h wasn't included, this allows the code to still @@ -120,40 +126,59 @@ writePort(port, value, bitmask): Write an 8 bit port. // Arduino Duemilanove, Diecimila, and NG #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#if defined(NUM_ANALOG_INPUTS) && NUM_ANALOG_INPUTS == 6 +#define TOTAL_ANALOG_PINS 6 +#define TOTAL_PINS 20 // 14 digital + 6 analog +#else #define TOTAL_ANALOG_PINS 8 -#define TOTAL_PINS 24 // 14 digital + 2 unused + 8 analog +#define TOTAL_PINS 22 // 14 digital + 8 analog +#endif #define VERSION_BLINK_PIN 13 -#define IS_PIN_DIGITAL(p) (((p) >= 2 && (p) <= 13) || ((p) >= 16 && (p) <= 21)) -#define IS_PIN_ANALOG(p) ((p) >= 16 && (p) <= 23) +#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19) +#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) -#define IS_PIN_SERVO(p) ((p) >= 2 && (p) <= 13 && (p) - 2 < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) -#define PIN_TO_DIGITAL(p) (((p) < 16) ? (p) : (p) - 2) -#define PIN_TO_ANALOG(p) ((p) - 16) +#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS) +#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - 14) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) #define PIN_TO_SERVO(p) ((p) - 2) #define ARDUINO_PINOUT_OPTIMIZE 1 +// Wiring (and board) +#elif defined(WIRING) +#define VERSION_BLINK_PIN WLED +#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) +#define IS_PIN_ANALOG(p) ((p) >= FIRST_ANALOG_PIN && (p) < (FIRST_ANALOG_PIN+TOTAL_ANALOG_PINS)) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) +#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - FIRST_ANALOG_PIN) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) (p) + + // old Arduinos #elif defined(__AVR_ATmega8__) #define TOTAL_ANALOG_PINS 6 -#define TOTAL_PINS 22 // 14 digital + 2 unused + 6 analog +#define TOTAL_PINS 20 // 14 digital + 6 analog #define VERSION_BLINK_PIN 13 -#define IS_PIN_DIGITAL(p) (((p) >= 2 && (p) <= 13) || ((p) >= 16 && (p) <= 21)) -#define IS_PIN_ANALOG(p) ((p) >= 16 && (p) <= 21) +#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19) +#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) <= 19) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) -#define IS_PIN_SERVO(p) ((p) >= 2 && (p) <= 13 && (p) - 2 < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) -#define PIN_TO_DIGITAL(p) (((p) < 16) ? (p) : (p) - 2) -#define PIN_TO_ANALOG(p) ((p) - 16) +#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS) +#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - 14) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) #define PIN_TO_SERVO(p) ((p) - 2) #define ARDUINO_PINOUT_OPTIMIZE 1 // Arduino Mega -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#elif defined(__AVR_ATmega1280__) #define TOTAL_ANALOG_PINS 16 #define TOTAL_PINS 70 // 54 digital + 16 analog #define VERSION_BLINK_PIN 13 @@ -161,21 +186,13 @@ writePort(port, value, bitmask): Write an 8 bit port. #define IS_PIN_ANALOG(p) ((p) >= 54 && (p) < TOTAL_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 2 && (p) - 2 < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 54) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) #define PIN_TO_SERVO(p) ((p) - 2) -// Wiring -#elif defined(__AVR_ATmega128__) -#define TOTAL_ANALOG_PINS 8 -#define TOTAL_PINS 51 -#define VERSION_BLINK_PIN 48 -// TODO: hardware abstraction for wiring board - - // Teensy 1.0 #elif defined(__AVR_AT90USB162__) #define TOTAL_ANALOG_PINS 0 @@ -201,7 +218,7 @@ writePort(port, value, bitmask): Write an 8 bit port. #define IS_PIN_ANALOG(p) ((p) >= 11 && (p) <= 22) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 5 || (p) == 6) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) (((p)<22)?21-(p):11) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -217,7 +234,7 @@ writePort(port, value, bitmask): Write an 8 bit port. #define IS_PIN_ANALOG(p) ((p) >= 38 && (p) < TOTAL_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 0 || (p) == 1) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 38) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -233,7 +250,7 @@ writePort(port, value, bitmask): Write an 8 bit port. #define IS_PIN_ANALOG(p) ((p) >= 24 && (p) < TOTAL_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 16 || (p) == 17) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 24) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -249,7 +266,7 @@ writePort(port, value, bitmask): Write an 8 bit port. #define IS_PIN_ANALOG(p) ((p) >= 36 && (p) < TOTAL_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 4 || (p) == 5) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 36) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -270,9 +287,9 @@ static inline unsigned char readPort(byte, byte) __attribute__((always_inline, u static inline unsigned char readPort(byte port, byte bitmask) { #if defined(ARDUINO_PINOUT_OPTIMIZE) - if (port == 0) return PIND & B11111100 & bitmask; // ignore Rx/Tx 0/1 - if (port == 1) return PINB & B00111111 & bitmask; // pins 8-13 (14,15 are disabled for the crystal) - if (port == 2) return PINC & bitmask; + if (port == 0) return (PIND & 0xFC) & bitmask; // ignore Rx/Tx 0/1 + if (port == 1) return ((PINB & 0x3F) | ((PINC & 0x03) << 6)) & bitmask; + if (port == 2) return ((PINC & 0x3C) >> 2) & bitmask; return 0; #else unsigned char out=0, pin=port*8; @@ -297,17 +314,27 @@ static inline unsigned char writePort(byte port, byte value, byte bitmask) { #if defined(ARDUINO_PINOUT_OPTIMIZE) if (port == 0) { - bitmask = bitmask & 0xFC; // Tx & Rx pins + bitmask = bitmask & 0xFC; // do not touch Tx & Rx pins + byte valD = value & bitmask; + byte maskD = ~bitmask; cli(); - PORTD = (PORTD & ~bitmask) | (bitmask & value); + PORTD = (PORTD & maskD) | valD; sei(); } else if (port == 1) { + byte valB = (value & bitmask) & 0x3F; + byte valC = (value & bitmask) >> 6; + byte maskB = ~(bitmask & 0x3F); + byte maskC = ~((bitmask & 0xC0) >> 6); cli(); - PORTB = (PORTB & ~bitmask) | (bitmask & value); + PORTB = (PORTB & maskB) | valB; + PORTC = (PORTC & maskC) | valC; sei(); } else if (port == 2) { + bitmask = bitmask & 0x0F; + byte valC = (value & bitmask) << 2; + byte maskC = ~(bitmask << 2); cli(); - PORTC = (PORTC & ~bitmask) | (bitmask & value); + PORTC = (PORTC & maskC) | valC; sei(); } #else diff --git a/libraries/Firmata/Firmata.cpp b/libraries/Firmata/Firmata.cpp index e30deae6c..0d68a5744 100644 --- a/libraries/Firmata/Firmata.cpp +++ b/libraries/Firmata/Firmata.cpp @@ -14,9 +14,8 @@ //* Includes //****************************************************************************** -#include "Arduino.h" -#include "HardwareSerial.h" #include "Firmata.h" +#include "HardwareSerial.h" extern "C" { #include @@ -27,27 +26,27 @@ extern "C" { //* Support Functions //****************************************************************************** -void sendValueAsTwo7bitBytes(int value) +void FirmataClass::sendValueAsTwo7bitBytes(int value) { - Serial.print(value & B01111111, BYTE); // LSB - Serial.print(value >> 7 & B01111111, BYTE); // MSB + FirmataSerial.write(value & B01111111); // LSB + FirmataSerial.write(value >> 7 & B01111111); // MSB } -void startSysex(void) +void FirmataClass::startSysex(void) { - Serial.print(START_SYSEX, BYTE); + FirmataSerial.write(START_SYSEX); } -void endSysex(void) +void FirmataClass::endSysex(void) { - Serial.print(END_SYSEX, BYTE); + FirmataSerial.write(END_SYSEX); } //****************************************************************************** //* Constructors //****************************************************************************** -FirmataClass::FirmataClass(void) +FirmataClass::FirmataClass(Stream &s) : FirmataSerial(s) { firmwareVersionCount = 0; systemReset(); @@ -66,22 +65,27 @@ void FirmataClass::begin(void) /* begin method for overriding default serial bitrate */ void FirmataClass::begin(long speed) { -#if defined(__AVR_ATmega128__) // Wiring - Serial.begin((uint32_t)speed); -#else Serial.begin(speed); -#endif + FirmataSerial = Serial; blinkVersion(); delay(300); printVersion(); printFirmwareVersion(); } +void FirmataClass::begin(Stream &s) +{ + FirmataSerial = s; + systemReset(); + printVersion(); + printFirmwareVersion(); +} + // output the protocol version message to the serial port void FirmataClass::printVersion(void) { - Serial.print(REPORT_VERSION, BYTE); - Serial.print(FIRMATA_MAJOR_VERSION, BYTE); - Serial.print(FIRMATA_MINOR_VERSION, BYTE); + FirmataSerial.write(REPORT_VERSION); + FirmataSerial.write(FIRMATA_MAJOR_VERSION); + FirmataSerial.write(FIRMATA_MINOR_VERSION); } void FirmataClass::blinkVersion(void) @@ -101,9 +105,9 @@ void FirmataClass::printFirmwareVersion(void) if(firmwareVersionCount) { // make sure that the name has been set before reporting startSysex(); - Serial.print(REPORT_FIRMWARE, BYTE); - Serial.print(firmwareVersionVector[0]); // major version number - Serial.print(firmwareVersionVector[1]); // minor version number + FirmataSerial.write(REPORT_FIRMWARE); + FirmataSerial.write(firmwareVersionVector[0]); // major version number + FirmataSerial.write(firmwareVersionVector[1]); // minor version number for(i=2; i> 7, BYTE); // Tx bits 7-13 + FirmataSerial.write(DIGITAL_MESSAGE | (portNumber & 0xF)); + FirmataSerial.write((byte)portData % 128); // Tx bits 0-6 + FirmataSerial.write(portData >> 7); // Tx bits 7-13 } @@ -308,7 +312,7 @@ void FirmataClass::sendSysex(byte command, byte bytec, byte* bytev) { byte i; startSysex(); - Serial.print(command, BYTE); + FirmataSerial.write(command); for(i=0; i -#include - +#include "Boards.h" /* Hardware Abstraction Layer + Wiring/Arduino */ /* Version numbers for the protocol. The protocol is still changing, so these * version numbers are important. This number can be queried so that host * software can test whether it will be compatible with the currently * installed firmware. */ #define FIRMATA_MAJOR_VERSION 2 // for non-compatible changes -#define FIRMATA_MINOR_VERSION 2 // for backwards compatible changes +#define FIRMATA_MINOR_VERSION 3 // for backwards compatible changes +#define FIRMATA_BUGFIX_VERSION 1 // for bugfix releases #define MAX_DATA_BYTES 32 // max number of data bytes in non-Sysex messages @@ -66,8 +65,8 @@ #define SYSEX_SAMPLING_INTERVAL 0x7A // same as SAMPLING_INTERVAL // pin modes -//#define INPUT 0x00 // defined in Arduino.h -//#define OUTPUT 0x01 // defined in Arduino.h +//#define INPUT 0x00 // defined in wiring.h +//#define OUTPUT 0x01 // defined in wiring.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 @@ -88,10 +87,11 @@ extern "C" { class FirmataClass { public: - FirmataClass(); + FirmataClass(Stream &s); /* Arduino constructors */ void begin(); void begin(long); + void begin(Stream &s); /* querying functions */ void printVersion(void); void blinkVersion(void); @@ -116,6 +116,7 @@ public: void detach(byte command); private: + Stream &FirmataSerial; /* firmware name and version */ byte firmwareVersionCount; byte *firmwareVersionVector; @@ -141,6 +142,9 @@ private: void processSysexMessage(void); void systemReset(void); void pin13strobe(int count, int onInterval, int offInterval); + void sendValueAsTwo7bitBytes(int value); + void startSysex(void); + void endSysex(void); }; extern FirmataClass Firmata; @@ -155,8 +159,5 @@ extern FirmataClass Firmata; */ #define setFirmwareVersion(x, y) setFirmwareNameAndVersion(__FILE__, x, y) -/* Hardware Abstraction Layer */ -#include "Boards.h" - #endif /* Firmata_h */ diff --git a/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde b/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.ino similarity index 98% rename from libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde rename to libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.ino index 5bca72a83..775594938 100644 --- a/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde +++ b/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.ino @@ -56,7 +56,7 @@ void loop() byte i; for (i=0; i -# -# - Write prototypes for all your functions (or define them before you -# call them). A prototype declares the types of parameters a -# function will take and what type of value it will return. This -# means that you can have a call to a function before the definition -# of the function. A function prototype looks like the first line of -# the function, with a semi-colon at the end. For example: -# int digitalRead(int pin); -# -# Instructions for using the makefile: -# -# 1. Copy this file into the folder with your sketch. -# -# 2. Below, modify the line containing "TARGET" to refer to the name of -# of your program's file without an extension (e.g. TARGET = foo). -# -# 3. Modify the line containg "ARDUINO" to point the directory that -# contains the Arduino core (for normal Arduino installations, this -# is the hardware/cores/arduino sub-directory). -# -# 4. Modify the line containing "PORT" to refer to the filename -# representing the USB or serial connection to your Arduino board -# (e.g. PORT = /dev/tty.USB0). If the exact name of this file -# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*). -# -# 5. At the command line, change to the directory containing your -# program's file and the makefile. -# -# 6. Type "make" and press enter to compile/verify your program. -# -# 7. Type "make upload", reset your Arduino board, and press enter to -# upload your program to the Arduino board. -# -# $Id: Makefile,v 1.7 2007/04/13 05:28:23 eighthave Exp $ - -PORT = /dev/tty.usbserial-* -TARGET := $(shell pwd | sed 's|.*/\(.*\)|\1|') -ARDUINO = /Applications/arduino -ARDUINO_SRC = $(ARDUINO)/hardware/cores/arduino -ARDUINO_LIB_SRC = $(ARDUINO)/hardware/libraries -INCLUDE = -I$(ARDUINO_SRC) -I$(ARDUINO)/hardware/tools/avr/avr/include \ - -I$(ARDUINO_LIB_SRC)/EEPROM \ - -I$(ARDUINO_LIB_SRC)/Firmata \ - -I$(ARDUINO_LIB_SRC)/Servo \ - -I$(ARDUINO_LIB_SRC) -SRC = $(wildcard $(ARDUINO_SRC)/*.c) -CXXSRC = applet/$(TARGET).cpp $(ARDUINO_SRC)/HardwareSerial.cpp \ - $(ARDUINO_LIB_SRC)/EEPROM/EEPROM.cpp \ - $(ARDUINO_LIB_SRC)/Firmata/Firmata.cpp \ - $(ARDUINO_LIB_SRC)/Servo/Servo.cpp \ - $(ARDUINO_SRC)/WMath.cpp -HEADERS = $(wildcard $(ARDUINO_SRC)/*.h) $(wildcard $(ARDUINO_LIB_SRC)/*/*.h) - -MCU = atmega168 -#MCU = atmega8 -F_CPU = 16000000 -FORMAT = ihex -UPLOAD_RATE = 19200 - -# Name of this Makefile (used for "make depend"). -MAKEFILE = Makefile - -# Debugging format. -# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. -# AVR (extended) COFF requires stabs, plus an avr-objcopy run. -DEBUG = stabs - -OPT = s - -# Place -D or -U options here -CDEFS = -DF_CPU=$(F_CPU) -CXXDEFS = -DF_CPU=$(F_CPU) - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 -CDEBUG = -g$(DEBUG) -CWARN = -Wall -Wstrict-prototypes -CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -#CEXTRA = -Wa,-adhlns=$(<:.c=.lst) - -CFLAGS = $(CDEBUG) $(CDEFS) $(INCLUDE) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) -CXXFLAGS = $(CDEFS) $(INCLUDE) -O$(OPT) -#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs -LDFLAGS = - - -# Programming support using avrdude. Settings and variables. -AVRDUDE_PROGRAMMER = stk500 -AVRDUDE_PORT = $(PORT) -AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex -AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ - -b $(UPLOAD_RATE) -q -V - -# Program settings -CC = avr-gcc -CXX = avr-g++ -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -MV = mv -f - -# Define all object files. -OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) - -# Define all listing files. -LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) -ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - -# Default target. -all: build - -build: applet/$(TARGET).hex - -eep: applet/$(TARGET).eep -lss: applet/$(TARGET).lss -sym: applet/$(TARGET).sym - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT=$(OBJCOPY) --debugging \ ---change-section-address .data-0x800000 \ ---change-section-address .bss-0x800000 \ ---change-section-address .noinit-0x800000 \ ---change-section-address .eeprom-0x810000 - - -coff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -extcoff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -.SUFFIXES: .elf .hex .eep .lss .sym .pde - -.elf.hex: - $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ - -.elf.eep: - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ - -# Create extended listing file from ELF output file. -.elf.lss: - $(OBJDUMP) -h -S $< > $@ - -# Create a symbol table from ELF output file. -.elf.sym: - $(NM) -n $< > $@ - - -# Compile: create object files from C++ source files. -.cpp.o: $(HEADERS) - $(CXX) -c $(ALL_CXXFLAGS) $< -o $@ - -# Compile: create object files from C source files. -.c.o: $(HEADERS) - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -.c.s: - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -.S.o: - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - - -applet/$(TARGET).cpp: $(TARGET).pde - test -d applet || mkdir applet - echo '#include "WProgram.h"' > applet/$(TARGET).cpp - echo '#include "avr/interrupt.h"' >> applet/$(TARGET).cpp - sed -n 's|^\(void .*)\).*|\1;|p' $(TARGET).pde | grep -v 'setup()' | \ - grep -v 'loop()' >> applet/$(TARGET).cpp - cat $(TARGET).pde >> applet/$(TARGET).cpp - cat $(ARDUINO_SRC)/main.cxx >> applet/$(TARGET).cpp - -# Link: create ELF output file from object files. -applet/$(TARGET).elf: applet/$(TARGET).cpp $(OBJ) - $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) - -pd_close_serial: - echo 'close;' | /Applications/Pd-extended.app/Contents/Resources/bin/pdsend 34567 || true - -# Program the device. -upload: applet/$(TARGET).hex - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) - - -pd_test: build pd_close_serial upload - -# Target: clean project. -clean: - $(REMOVE) -- applet/$(TARGET).hex applet/$(TARGET).eep \ - applet/$(TARGET).cof applet/$(TARGET).elf $(TARGET).map \ - applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp \ - $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) - rmdir -- applet - -depend: - if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ - then \ - sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ - $(MAKEFILE).$$$$ && \ - $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ - fi - echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ - >> $(MAKEFILE); \ - $(CC) -M -mmcu=$(MCU) $(CDEFS) $(INCLUDE) $(SRC) $(ASRC) >> $(MAKEFILE) - -.PHONY: all build eep lss sym coff extcoff clean depend pd_close_serial pd_test - -# for emacs -etags: - make etags_`uname -s` - etags *.pde \ - $(ARDUINO_SRC)/*.[ch] \ - $(ARDUINO_SRC)/*.cpp \ - $(ARDUINO_LIB_SRC)/*/*.[ch] \ - $(ARDUINO_LIB_SRC)/*/*.cpp \ - $(ARDUINO)/hardware/tools/avr/avr/include/avr/*.[ch] \ - $(ARDUINO)/hardware/tools/avr/avr/include/*.[ch] - -etags_Darwin: -# etags -a - -etags_Linux: -# etags -a /usr/include/*.h linux/input.h /usr/include/sys/*.h - -etags_MINGW: -# etags -a /usr/include/*.h /usr/include/sys/*.h - - - diff --git a/libraries/Firmata/examples/EchoString/EchoString.pde b/libraries/Firmata/examples/EchoString/EchoString.ino similarity index 78% rename from libraries/Firmata/examples/EchoString/EchoString.pde rename to libraries/Firmata/examples/EchoString/EchoString.ino index e5c4e6fe5..e708ec210 100644 --- a/libraries/Firmata/examples/EchoString/EchoString.pde +++ b/libraries/Firmata/examples/EchoString/EchoString.ino @@ -14,12 +14,7 @@ void stringCallback(char *myString) void sysexCallback(byte command, byte argc, byte*argv) { - Serial.write(START_SYSEX); - Serial.write(command); - for(byte i=0; i -# -# - Write prototypes for all your functions (or define them before you -# call them). A prototype declares the types of parameters a -# function will take and what type of value it will return. This -# means that you can have a call to a function before the definition -# of the function. A function prototype looks like the first line of -# the function, with a semi-colon at the end. For example: -# int digitalRead(int pin); -# -# Instructions for using the makefile: -# -# 1. Copy this file into the folder with your sketch. -# -# 2. Below, modify the line containing "TARGET" to refer to the name of -# of your program's file without an extension (e.g. TARGET = foo). -# -# 3. Modify the line containg "ARDUINO" to point the directory that -# contains the Arduino core (for normal Arduino installations, this -# is the hardware/cores/arduino sub-directory). -# -# 4. Modify the line containing "PORT" to refer to the filename -# representing the USB or serial connection to your Arduino board -# (e.g. PORT = /dev/tty.USB0). If the exact name of this file -# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*). -# -# 5. At the command line, change to the directory containing your -# program's file and the makefile. -# -# 6. Type "make" and press enter to compile/verify your program. -# -# 7. Type "make upload", reset your Arduino board, and press enter to -# upload your program to the Arduino board. -# -# $Id: Makefile,v 1.7 2007/04/13 05:28:23 eighthave Exp $ - -PORT = /dev/tty.usbserial-* -TARGET := $(shell pwd | sed 's|.*/\(.*\)|\1|') -ARDUINO = /Applications/arduino -ARDUINO_SRC = $(ARDUINO)/hardware/cores/arduino -ARDUINO_LIB_SRC = $(ARDUINO)/hardware/libraries -INCLUDE = -I$(ARDUINO_SRC) -I$(ARDUINO)/hardware/tools/avr/avr/include \ - -I$(ARDUINO_LIB_SRC)/EEPROM \ - -I$(ARDUINO_LIB_SRC)/Firmata \ - -I$(ARDUINO_LIB_SRC)/Servo \ - -I$(ARDUINO_LIB_SRC) -SRC = $(wildcard $(ARDUINO_SRC)/*.c) -CXXSRC = applet/$(TARGET).cpp $(ARDUINO_SRC)/HardwareSerial.cpp \ - $(ARDUINO_LIB_SRC)/EEPROM/EEPROM.cpp \ - $(ARDUINO_LIB_SRC)/Firmata/Firmata.cpp \ - $(ARDUINO_LIB_SRC)/Servo/Servo.cpp \ - $(ARDUINO_SRC)/WMath.cpp -HEADERS = $(wildcard $(ARDUINO_SRC)/*.h) $(wildcard $(ARDUINO_LIB_SRC)/*/*.h) - -MCU = atmega168 -#MCU = atmega8 -F_CPU = 16000000 -FORMAT = ihex -UPLOAD_RATE = 19200 - -# Name of this Makefile (used for "make depend"). -MAKEFILE = Makefile - -# Debugging format. -# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. -# AVR (extended) COFF requires stabs, plus an avr-objcopy run. -DEBUG = stabs - -OPT = s - -# Place -D or -U options here -CDEFS = -DF_CPU=$(F_CPU) -CXXDEFS = -DF_CPU=$(F_CPU) - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 -CDEBUG = -g$(DEBUG) -CWARN = -Wall -Wstrict-prototypes -CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -#CEXTRA = -Wa,-adhlns=$(<:.c=.lst) - -CFLAGS = $(CDEBUG) $(CDEFS) $(INCLUDE) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) -CXXFLAGS = $(CDEFS) $(INCLUDE) -O$(OPT) -#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs -LDFLAGS = - - -# Programming support using avrdude. Settings and variables. -AVRDUDE_PROGRAMMER = stk500 -AVRDUDE_PORT = $(PORT) -AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex -AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ - -b $(UPLOAD_RATE) -q -V - -# Program settings -CC = avr-gcc -CXX = avr-g++ -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -MV = mv -f - -# Define all object files. -OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) - -# Define all listing files. -LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) -ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - -# Default target. -all: build - -build: applet/$(TARGET).hex - -eep: applet/$(TARGET).eep -lss: applet/$(TARGET).lss -sym: applet/$(TARGET).sym - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT=$(OBJCOPY) --debugging \ ---change-section-address .data-0x800000 \ ---change-section-address .bss-0x800000 \ ---change-section-address .noinit-0x800000 \ ---change-section-address .eeprom-0x810000 - - -coff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -extcoff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -.SUFFIXES: .elf .hex .eep .lss .sym .pde - -.elf.hex: - $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ - -.elf.eep: - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ - -# Create extended listing file from ELF output file. -.elf.lss: - $(OBJDUMP) -h -S $< > $@ - -# Create a symbol table from ELF output file. -.elf.sym: - $(NM) -n $< > $@ - - -# Compile: create object files from C++ source files. -.cpp.o: $(HEADERS) - $(CXX) -c $(ALL_CXXFLAGS) $< -o $@ - -# Compile: create object files from C source files. -.c.o: $(HEADERS) - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -.c.s: - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -.S.o: - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - - -applet/$(TARGET).cpp: $(TARGET).pde - test -d applet || mkdir applet - echo '#include "WProgram.h"' > applet/$(TARGET).cpp - echo '#include "avr/interrupt.h"' >> applet/$(TARGET).cpp - sed -n 's|^\(void .*)\).*|\1;|p' $(TARGET).pde | grep -v 'setup()' | \ - grep -v 'loop()' >> applet/$(TARGET).cpp - cat $(TARGET).pde >> applet/$(TARGET).cpp - cat $(ARDUINO_SRC)/main.cxx >> applet/$(TARGET).cpp - -# Link: create ELF output file from object files. -applet/$(TARGET).elf: applet/$(TARGET).cpp $(OBJ) - $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) - -pd_close_serial: - echo 'close;' | /Applications/Pd-extended.app/Contents/Resources/bin/pdsend 34567 || true - -# Program the device. -upload: applet/$(TARGET).hex - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) - - -pd_test: build pd_close_serial upload - -# Target: clean project. -clean: - $(REMOVE) -- applet/$(TARGET).hex applet/$(TARGET).eep \ - applet/$(TARGET).cof applet/$(TARGET).elf $(TARGET).map \ - applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp \ - $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) - rmdir -- applet - -depend: - if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ - then \ - sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ - $(MAKEFILE).$$$$ && \ - $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ - fi - echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ - >> $(MAKEFILE); \ - $(CC) -M -mmcu=$(MCU) $(CDEFS) $(INCLUDE) $(SRC) $(ASRC) >> $(MAKEFILE) - -.PHONY: all build eep lss sym coff extcoff clean depend pd_close_serial pd_test - -# for emacs -etags: - make etags_`uname -s` - etags *.pde \ - $(ARDUINO_SRC)/*.[ch] \ - $(ARDUINO_SRC)/*.cpp \ - $(ARDUINO_LIB_SRC)/*/*.[ch] \ - $(ARDUINO_LIB_SRC)/*/*.cpp \ - $(ARDUINO)/hardware/tools/avr/avr/include/avr/*.[ch] \ - $(ARDUINO)/hardware/tools/avr/avr/include/*.[ch] - -etags_Darwin: -# etags -a - -etags_Linux: -# etags -a /usr/include/*.h linux/input.h /usr/include/sys/*.h - -etags_MINGW: -# etags -a /usr/include/*.h /usr/include/sys/*.h - - - diff --git a/libraries/Firmata/examples/I2CFirmata/I2CFirmata.pde b/libraries/Firmata/examples/I2CFirmata/I2CFirmata.ino similarity index 98% rename from libraries/Firmata/examples/I2CFirmata/I2CFirmata.pde rename to libraries/Firmata/examples/I2CFirmata/I2CFirmata.ino index 11202e9b2..f2c931b95 100644 --- a/libraries/Firmata/examples/I2CFirmata/I2CFirmata.pde +++ b/libraries/Firmata/examples/I2CFirmata/I2CFirmata.ino @@ -48,7 +48,7 @@ void readAndReportData(byte address, int theRegister, byte numBytes) { if (theRegister != REGISTER_NOT_SPECIFIED) { Wire.beginTransmission(address); - Wire.send((byte)theRegister); + Wire.write((byte)theRegister); Wire.endTransmission(); delayMicroseconds(i2cReadDelayTime); // delay is necessary for some devices such as WiiNunchuck } @@ -63,7 +63,7 @@ void readAndReportData(byte address, int theRegister, byte numBytes) i2cRxData[0] = address; i2cRxData[1] = theRegister; for (int i = 0; i < numBytes; i++) { - i2cRxData[2 + i] = Wire.receive(); + i2cRxData[2 + i] = Wire.read(); } // send slave address, register and received bytes Firmata.sendSysex(I2C_REPLY, numBytes + 2, i2cRxData); @@ -95,7 +95,7 @@ void sysexCallback(byte command, byte argc, byte *argv) Wire.beginTransmission(slaveAddress); for (byte i = 2; i < argc; i += 2) { data = argv[i] + (argv[i + 1] << 7); - Wire.send(data); + Wire.write(data); } Wire.endTransmission(); delayMicroseconds(70); // TODO is this needed? diff --git a/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde b/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.ino similarity index 100% rename from libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde rename to libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.ino diff --git a/libraries/Firmata/examples/ServoFirmata/Makefile b/libraries/Firmata/examples/ServoFirmata/Makefile deleted file mode 100644 index e968c0a3d..000000000 --- a/libraries/Firmata/examples/ServoFirmata/Makefile +++ /dev/null @@ -1,263 +0,0 @@ -# Arduino makefile -# -# This makefile allows you to build sketches from the command line -# without the Arduino environment (or Java). -# -# The Arduino environment does preliminary processing on a sketch before -# compiling it. If you're using this makefile instead, you'll need to do -# a few things differently: -# -# - Give your program's file a .cpp extension (e.g. foo.cpp). -# -# - Put this line at top of your code: #include -# -# - Write prototypes for all your functions (or define them before you -# call them). A prototype declares the types of parameters a -# function will take and what type of value it will return. This -# means that you can have a call to a function before the definition -# of the function. A function prototype looks like the first line of -# the function, with a semi-colon at the end. For example: -# int digitalRead(int pin); -# -# Instructions for using the makefile: -# -# 1. Copy this file into the folder with your sketch. -# -# 2. Below, modify the line containing "TARGET" to refer to the name of -# of your program's file without an extension (e.g. TARGET = foo). -# -# 3. Modify the line containg "ARDUINO" to point the directory that -# contains the Arduino core (for normal Arduino installations, this -# is the hardware/cores/arduino sub-directory). -# -# 4. Modify the line containing "PORT" to refer to the filename -# representing the USB or serial connection to your Arduino board -# (e.g. PORT = /dev/tty.USB0). If the exact name of this file -# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*). -# -# 5. At the command line, change to the directory containing your -# program's file and the makefile. -# -# 6. Type "make" and press enter to compile/verify your program. -# -# 7. Type "make upload", reset your Arduino board, and press enter to -# upload your program to the Arduino board. -# -# $Id: Makefile,v 1.7 2007/04/13 05:28:23 eighthave Exp $ - -PORT = /dev/tty.usbserial-* -TARGET := $(shell pwd | sed 's|.*/\(.*\)|\1|') -ARDUINO = /Applications/arduino -ARDUINO_SRC = $(ARDUINO)/hardware/cores/arduino -ARDUINO_LIB_SRC = $(ARDUINO)/hardware/libraries -INCLUDE = -I$(ARDUINO_SRC) -I$(ARDUINO)/hardware/tools/avr/avr/include \ - -I$(ARDUINO_LIB_SRC)/EEPROM \ - -I$(ARDUINO_LIB_SRC)/Firmata \ - -I$(ARDUINO_LIB_SRC)/Servo \ - -I$(ARDUINO_LIB_SRC) -SRC = $(wildcard $(ARDUINO_SRC)/*.c) -CXXSRC = applet/$(TARGET).cpp $(ARDUINO_SRC)/HardwareSerial.cpp \ - $(ARDUINO_LIB_SRC)/EEPROM/EEPROM.cpp \ - $(ARDUINO_LIB_SRC)/Firmata/Firmata.cpp \ - $(ARDUINO_LIB_SRC)/Servo/Servo.cpp \ - $(ARDUINO_SRC)/WMath.cpp -HEADERS = $(wildcard $(ARDUINO_SRC)/*.h) $(wildcard $(ARDUINO_LIB_SRC)/*/*.h) - -MCU = atmega168 -#MCU = atmega8 -F_CPU = 16000000 -FORMAT = ihex -UPLOAD_RATE = 19200 - -# Name of this Makefile (used for "make depend"). -MAKEFILE = Makefile - -# Debugging format. -# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. -# AVR (extended) COFF requires stabs, plus an avr-objcopy run. -DEBUG = stabs - -OPT = s - -# Place -D or -U options here -CDEFS = -DF_CPU=$(F_CPU) -CXXDEFS = -DF_CPU=$(F_CPU) - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 -CDEBUG = -g$(DEBUG) -CWARN = -Wall -Wstrict-prototypes -CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -#CEXTRA = -Wa,-adhlns=$(<:.c=.lst) - -CFLAGS = $(CDEBUG) $(CDEFS) $(INCLUDE) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) -CXXFLAGS = $(CDEFS) $(INCLUDE) -O$(OPT) -#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs -LDFLAGS = - - -# Programming support using avrdude. Settings and variables. -AVRDUDE_PROGRAMMER = stk500 -AVRDUDE_PORT = $(PORT) -AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex -AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ - -b $(UPLOAD_RATE) -q -V - -# Program settings -CC = avr-gcc -CXX = avr-g++ -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -MV = mv -f - -# Define all object files. -OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) - -# Define all listing files. -LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) -ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - -# Default target. -all: build - -build: applet/$(TARGET).hex - -eep: applet/$(TARGET).eep -lss: applet/$(TARGET).lss -sym: applet/$(TARGET).sym - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT=$(OBJCOPY) --debugging \ ---change-section-address .data-0x800000 \ ---change-section-address .bss-0x800000 \ ---change-section-address .noinit-0x800000 \ ---change-section-address .eeprom-0x810000 - - -coff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -extcoff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -.SUFFIXES: .elf .hex .eep .lss .sym .pde - -.elf.hex: - $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ - -.elf.eep: - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ - -# Create extended listing file from ELF output file. -.elf.lss: - $(OBJDUMP) -h -S $< > $@ - -# Create a symbol table from ELF output file. -.elf.sym: - $(NM) -n $< > $@ - - -# Compile: create object files from C++ source files. -.cpp.o: $(HEADERS) - $(CXX) -c $(ALL_CXXFLAGS) $< -o $@ - -# Compile: create object files from C source files. -.c.o: $(HEADERS) - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -.c.s: - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -.S.o: - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - - -applet/$(TARGET).cpp: $(TARGET).pde - test -d applet || mkdir applet - echo '#include "WProgram.h"' > applet/$(TARGET).cpp - echo '#include "avr/interrupt.h"' >> applet/$(TARGET).cpp - sed -n 's|^\(void .*)\).*|\1;|p' $(TARGET).pde | grep -v 'setup()' | \ - grep -v 'loop()' >> applet/$(TARGET).cpp - cat $(TARGET).pde >> applet/$(TARGET).cpp - cat $(ARDUINO_SRC)/main.cxx >> applet/$(TARGET).cpp - -# Link: create ELF output file from object files. -applet/$(TARGET).elf: applet/$(TARGET).cpp $(OBJ) - $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) - -pd_close_serial: - echo 'close;' | /Applications/Pd-extended.app/Contents/Resources/bin/pdsend 34567 || true - -# Program the device. -upload: applet/$(TARGET).hex - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) - - -pd_test: build pd_close_serial upload - -# Target: clean project. -clean: - $(REMOVE) -- applet/$(TARGET).hex applet/$(TARGET).eep \ - applet/$(TARGET).cof applet/$(TARGET).elf $(TARGET).map \ - applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp \ - $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) - rmdir -- applet - -depend: - if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ - then \ - sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ - $(MAKEFILE).$$$$ && \ - $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ - fi - echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ - >> $(MAKEFILE); \ - $(CC) -M -mmcu=$(MCU) $(CDEFS) $(INCLUDE) $(SRC) $(ASRC) >> $(MAKEFILE) - -.PHONY: all build eep lss sym coff extcoff clean depend pd_close_serial pd_test - -# for emacs -etags: - make etags_`uname -s` - etags *.pde \ - $(ARDUINO_SRC)/*.[ch] \ - $(ARDUINO_SRC)/*.cpp \ - $(ARDUINO_LIB_SRC)/*/*.[ch] \ - $(ARDUINO_LIB_SRC)/*/*.cpp \ - $(ARDUINO)/hardware/tools/avr/avr/include/avr/*.[ch] \ - $(ARDUINO)/hardware/tools/avr/avr/include/*.[ch] - -etags_Darwin: -# etags -a - -etags_Linux: -# etags -a /usr/include/*.h linux/input.h /usr/include/sys/*.h - -etags_MINGW: -# etags -a /usr/include/*.h /usr/include/sys/*.h - - - diff --git a/libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde b/libraries/Firmata/examples/ServoFirmata/ServoFirmata.ino similarity index 100% rename from libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde rename to libraries/Firmata/examples/ServoFirmata/ServoFirmata.ino diff --git a/libraries/Firmata/examples/SimpleAnalogFirmata/Makefile b/libraries/Firmata/examples/SimpleAnalogFirmata/Makefile deleted file mode 100644 index e968c0a3d..000000000 --- a/libraries/Firmata/examples/SimpleAnalogFirmata/Makefile +++ /dev/null @@ -1,263 +0,0 @@ -# Arduino makefile -# -# This makefile allows you to build sketches from the command line -# without the Arduino environment (or Java). -# -# The Arduino environment does preliminary processing on a sketch before -# compiling it. If you're using this makefile instead, you'll need to do -# a few things differently: -# -# - Give your program's file a .cpp extension (e.g. foo.cpp). -# -# - Put this line at top of your code: #include -# -# - Write prototypes for all your functions (or define them before you -# call them). A prototype declares the types of parameters a -# function will take and what type of value it will return. This -# means that you can have a call to a function before the definition -# of the function. A function prototype looks like the first line of -# the function, with a semi-colon at the end. For example: -# int digitalRead(int pin); -# -# Instructions for using the makefile: -# -# 1. Copy this file into the folder with your sketch. -# -# 2. Below, modify the line containing "TARGET" to refer to the name of -# of your program's file without an extension (e.g. TARGET = foo). -# -# 3. Modify the line containg "ARDUINO" to point the directory that -# contains the Arduino core (for normal Arduino installations, this -# is the hardware/cores/arduino sub-directory). -# -# 4. Modify the line containing "PORT" to refer to the filename -# representing the USB or serial connection to your Arduino board -# (e.g. PORT = /dev/tty.USB0). If the exact name of this file -# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*). -# -# 5. At the command line, change to the directory containing your -# program's file and the makefile. -# -# 6. Type "make" and press enter to compile/verify your program. -# -# 7. Type "make upload", reset your Arduino board, and press enter to -# upload your program to the Arduino board. -# -# $Id: Makefile,v 1.7 2007/04/13 05:28:23 eighthave Exp $ - -PORT = /dev/tty.usbserial-* -TARGET := $(shell pwd | sed 's|.*/\(.*\)|\1|') -ARDUINO = /Applications/arduino -ARDUINO_SRC = $(ARDUINO)/hardware/cores/arduino -ARDUINO_LIB_SRC = $(ARDUINO)/hardware/libraries -INCLUDE = -I$(ARDUINO_SRC) -I$(ARDUINO)/hardware/tools/avr/avr/include \ - -I$(ARDUINO_LIB_SRC)/EEPROM \ - -I$(ARDUINO_LIB_SRC)/Firmata \ - -I$(ARDUINO_LIB_SRC)/Servo \ - -I$(ARDUINO_LIB_SRC) -SRC = $(wildcard $(ARDUINO_SRC)/*.c) -CXXSRC = applet/$(TARGET).cpp $(ARDUINO_SRC)/HardwareSerial.cpp \ - $(ARDUINO_LIB_SRC)/EEPROM/EEPROM.cpp \ - $(ARDUINO_LIB_SRC)/Firmata/Firmata.cpp \ - $(ARDUINO_LIB_SRC)/Servo/Servo.cpp \ - $(ARDUINO_SRC)/WMath.cpp -HEADERS = $(wildcard $(ARDUINO_SRC)/*.h) $(wildcard $(ARDUINO_LIB_SRC)/*/*.h) - -MCU = atmega168 -#MCU = atmega8 -F_CPU = 16000000 -FORMAT = ihex -UPLOAD_RATE = 19200 - -# Name of this Makefile (used for "make depend"). -MAKEFILE = Makefile - -# Debugging format. -# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. -# AVR (extended) COFF requires stabs, plus an avr-objcopy run. -DEBUG = stabs - -OPT = s - -# Place -D or -U options here -CDEFS = -DF_CPU=$(F_CPU) -CXXDEFS = -DF_CPU=$(F_CPU) - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 -CDEBUG = -g$(DEBUG) -CWARN = -Wall -Wstrict-prototypes -CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -#CEXTRA = -Wa,-adhlns=$(<:.c=.lst) - -CFLAGS = $(CDEBUG) $(CDEFS) $(INCLUDE) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) -CXXFLAGS = $(CDEFS) $(INCLUDE) -O$(OPT) -#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs -LDFLAGS = - - -# Programming support using avrdude. Settings and variables. -AVRDUDE_PROGRAMMER = stk500 -AVRDUDE_PORT = $(PORT) -AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex -AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ - -b $(UPLOAD_RATE) -q -V - -# Program settings -CC = avr-gcc -CXX = avr-g++ -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -MV = mv -f - -# Define all object files. -OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) - -# Define all listing files. -LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) -ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - -# Default target. -all: build - -build: applet/$(TARGET).hex - -eep: applet/$(TARGET).eep -lss: applet/$(TARGET).lss -sym: applet/$(TARGET).sym - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT=$(OBJCOPY) --debugging \ ---change-section-address .data-0x800000 \ ---change-section-address .bss-0x800000 \ ---change-section-address .noinit-0x800000 \ ---change-section-address .eeprom-0x810000 - - -coff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -extcoff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -.SUFFIXES: .elf .hex .eep .lss .sym .pde - -.elf.hex: - $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ - -.elf.eep: - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ - -# Create extended listing file from ELF output file. -.elf.lss: - $(OBJDUMP) -h -S $< > $@ - -# Create a symbol table from ELF output file. -.elf.sym: - $(NM) -n $< > $@ - - -# Compile: create object files from C++ source files. -.cpp.o: $(HEADERS) - $(CXX) -c $(ALL_CXXFLAGS) $< -o $@ - -# Compile: create object files from C source files. -.c.o: $(HEADERS) - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -.c.s: - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -.S.o: - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - - -applet/$(TARGET).cpp: $(TARGET).pde - test -d applet || mkdir applet - echo '#include "WProgram.h"' > applet/$(TARGET).cpp - echo '#include "avr/interrupt.h"' >> applet/$(TARGET).cpp - sed -n 's|^\(void .*)\).*|\1;|p' $(TARGET).pde | grep -v 'setup()' | \ - grep -v 'loop()' >> applet/$(TARGET).cpp - cat $(TARGET).pde >> applet/$(TARGET).cpp - cat $(ARDUINO_SRC)/main.cxx >> applet/$(TARGET).cpp - -# Link: create ELF output file from object files. -applet/$(TARGET).elf: applet/$(TARGET).cpp $(OBJ) - $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) - -pd_close_serial: - echo 'close;' | /Applications/Pd-extended.app/Contents/Resources/bin/pdsend 34567 || true - -# Program the device. -upload: applet/$(TARGET).hex - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) - - -pd_test: build pd_close_serial upload - -# Target: clean project. -clean: - $(REMOVE) -- applet/$(TARGET).hex applet/$(TARGET).eep \ - applet/$(TARGET).cof applet/$(TARGET).elf $(TARGET).map \ - applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp \ - $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) - rmdir -- applet - -depend: - if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ - then \ - sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ - $(MAKEFILE).$$$$ && \ - $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ - fi - echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ - >> $(MAKEFILE); \ - $(CC) -M -mmcu=$(MCU) $(CDEFS) $(INCLUDE) $(SRC) $(ASRC) >> $(MAKEFILE) - -.PHONY: all build eep lss sym coff extcoff clean depend pd_close_serial pd_test - -# for emacs -etags: - make etags_`uname -s` - etags *.pde \ - $(ARDUINO_SRC)/*.[ch] \ - $(ARDUINO_SRC)/*.cpp \ - $(ARDUINO_LIB_SRC)/*/*.[ch] \ - $(ARDUINO_LIB_SRC)/*/*.cpp \ - $(ARDUINO)/hardware/tools/avr/avr/include/avr/*.[ch] \ - $(ARDUINO)/hardware/tools/avr/avr/include/*.[ch] - -etags_Darwin: -# etags -a - -etags_Linux: -# etags -a /usr/include/*.h linux/input.h /usr/include/sys/*.h - -etags_MINGW: -# etags -a /usr/include/*.h /usr/include/sys/*.h - - - diff --git a/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde b/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.ino similarity index 100% rename from libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde rename to libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.ino diff --git a/libraries/Firmata/examples/SimpleDigitalFirmata/Makefile b/libraries/Firmata/examples/SimpleDigitalFirmata/Makefile deleted file mode 100644 index e968c0a3d..000000000 --- a/libraries/Firmata/examples/SimpleDigitalFirmata/Makefile +++ /dev/null @@ -1,263 +0,0 @@ -# Arduino makefile -# -# This makefile allows you to build sketches from the command line -# without the Arduino environment (or Java). -# -# The Arduino environment does preliminary processing on a sketch before -# compiling it. If you're using this makefile instead, you'll need to do -# a few things differently: -# -# - Give your program's file a .cpp extension (e.g. foo.cpp). -# -# - Put this line at top of your code: #include -# -# - Write prototypes for all your functions (or define them before you -# call them). A prototype declares the types of parameters a -# function will take and what type of value it will return. This -# means that you can have a call to a function before the definition -# of the function. A function prototype looks like the first line of -# the function, with a semi-colon at the end. For example: -# int digitalRead(int pin); -# -# Instructions for using the makefile: -# -# 1. Copy this file into the folder with your sketch. -# -# 2. Below, modify the line containing "TARGET" to refer to the name of -# of your program's file without an extension (e.g. TARGET = foo). -# -# 3. Modify the line containg "ARDUINO" to point the directory that -# contains the Arduino core (for normal Arduino installations, this -# is the hardware/cores/arduino sub-directory). -# -# 4. Modify the line containing "PORT" to refer to the filename -# representing the USB or serial connection to your Arduino board -# (e.g. PORT = /dev/tty.USB0). If the exact name of this file -# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*). -# -# 5. At the command line, change to the directory containing your -# program's file and the makefile. -# -# 6. Type "make" and press enter to compile/verify your program. -# -# 7. Type "make upload", reset your Arduino board, and press enter to -# upload your program to the Arduino board. -# -# $Id: Makefile,v 1.7 2007/04/13 05:28:23 eighthave Exp $ - -PORT = /dev/tty.usbserial-* -TARGET := $(shell pwd | sed 's|.*/\(.*\)|\1|') -ARDUINO = /Applications/arduino -ARDUINO_SRC = $(ARDUINO)/hardware/cores/arduino -ARDUINO_LIB_SRC = $(ARDUINO)/hardware/libraries -INCLUDE = -I$(ARDUINO_SRC) -I$(ARDUINO)/hardware/tools/avr/avr/include \ - -I$(ARDUINO_LIB_SRC)/EEPROM \ - -I$(ARDUINO_LIB_SRC)/Firmata \ - -I$(ARDUINO_LIB_SRC)/Servo \ - -I$(ARDUINO_LIB_SRC) -SRC = $(wildcard $(ARDUINO_SRC)/*.c) -CXXSRC = applet/$(TARGET).cpp $(ARDUINO_SRC)/HardwareSerial.cpp \ - $(ARDUINO_LIB_SRC)/EEPROM/EEPROM.cpp \ - $(ARDUINO_LIB_SRC)/Firmata/Firmata.cpp \ - $(ARDUINO_LIB_SRC)/Servo/Servo.cpp \ - $(ARDUINO_SRC)/WMath.cpp -HEADERS = $(wildcard $(ARDUINO_SRC)/*.h) $(wildcard $(ARDUINO_LIB_SRC)/*/*.h) - -MCU = atmega168 -#MCU = atmega8 -F_CPU = 16000000 -FORMAT = ihex -UPLOAD_RATE = 19200 - -# Name of this Makefile (used for "make depend"). -MAKEFILE = Makefile - -# Debugging format. -# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. -# AVR (extended) COFF requires stabs, plus an avr-objcopy run. -DEBUG = stabs - -OPT = s - -# Place -D or -U options here -CDEFS = -DF_CPU=$(F_CPU) -CXXDEFS = -DF_CPU=$(F_CPU) - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 -CDEBUG = -g$(DEBUG) -CWARN = -Wall -Wstrict-prototypes -CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -#CEXTRA = -Wa,-adhlns=$(<:.c=.lst) - -CFLAGS = $(CDEBUG) $(CDEFS) $(INCLUDE) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) -CXXFLAGS = $(CDEFS) $(INCLUDE) -O$(OPT) -#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs -LDFLAGS = - - -# Programming support using avrdude. Settings and variables. -AVRDUDE_PROGRAMMER = stk500 -AVRDUDE_PORT = $(PORT) -AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex -AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ - -b $(UPLOAD_RATE) -q -V - -# Program settings -CC = avr-gcc -CXX = avr-g++ -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -MV = mv -f - -# Define all object files. -OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) - -# Define all listing files. -LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) -ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - -# Default target. -all: build - -build: applet/$(TARGET).hex - -eep: applet/$(TARGET).eep -lss: applet/$(TARGET).lss -sym: applet/$(TARGET).sym - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT=$(OBJCOPY) --debugging \ ---change-section-address .data-0x800000 \ ---change-section-address .bss-0x800000 \ ---change-section-address .noinit-0x800000 \ ---change-section-address .eeprom-0x810000 - - -coff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -extcoff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -.SUFFIXES: .elf .hex .eep .lss .sym .pde - -.elf.hex: - $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ - -.elf.eep: - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ - -# Create extended listing file from ELF output file. -.elf.lss: - $(OBJDUMP) -h -S $< > $@ - -# Create a symbol table from ELF output file. -.elf.sym: - $(NM) -n $< > $@ - - -# Compile: create object files from C++ source files. -.cpp.o: $(HEADERS) - $(CXX) -c $(ALL_CXXFLAGS) $< -o $@ - -# Compile: create object files from C source files. -.c.o: $(HEADERS) - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -.c.s: - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -.S.o: - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - - -applet/$(TARGET).cpp: $(TARGET).pde - test -d applet || mkdir applet - echo '#include "WProgram.h"' > applet/$(TARGET).cpp - echo '#include "avr/interrupt.h"' >> applet/$(TARGET).cpp - sed -n 's|^\(void .*)\).*|\1;|p' $(TARGET).pde | grep -v 'setup()' | \ - grep -v 'loop()' >> applet/$(TARGET).cpp - cat $(TARGET).pde >> applet/$(TARGET).cpp - cat $(ARDUINO_SRC)/main.cxx >> applet/$(TARGET).cpp - -# Link: create ELF output file from object files. -applet/$(TARGET).elf: applet/$(TARGET).cpp $(OBJ) - $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) - -pd_close_serial: - echo 'close;' | /Applications/Pd-extended.app/Contents/Resources/bin/pdsend 34567 || true - -# Program the device. -upload: applet/$(TARGET).hex - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) - - -pd_test: build pd_close_serial upload - -# Target: clean project. -clean: - $(REMOVE) -- applet/$(TARGET).hex applet/$(TARGET).eep \ - applet/$(TARGET).cof applet/$(TARGET).elf $(TARGET).map \ - applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp \ - $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) - rmdir -- applet - -depend: - if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ - then \ - sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ - $(MAKEFILE).$$$$ && \ - $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ - fi - echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ - >> $(MAKEFILE); \ - $(CC) -M -mmcu=$(MCU) $(CDEFS) $(INCLUDE) $(SRC) $(ASRC) >> $(MAKEFILE) - -.PHONY: all build eep lss sym coff extcoff clean depend pd_close_serial pd_test - -# for emacs -etags: - make etags_`uname -s` - etags *.pde \ - $(ARDUINO_SRC)/*.[ch] \ - $(ARDUINO_SRC)/*.cpp \ - $(ARDUINO_LIB_SRC)/*/*.[ch] \ - $(ARDUINO_LIB_SRC)/*/*.cpp \ - $(ARDUINO)/hardware/tools/avr/avr/include/avr/*.[ch] \ - $(ARDUINO)/hardware/tools/avr/avr/include/*.[ch] - -etags_Darwin: -# etags -a - -etags_Linux: -# etags -a /usr/include/*.h linux/input.h /usr/include/sys/*.h - -etags_MINGW: -# etags -a /usr/include/*.h /usr/include/sys/*.h - - - diff --git a/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde b/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.ino similarity index 97% rename from libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde rename to libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.ino index 64b566ee3..bbe42ed8d 100644 --- a/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde +++ b/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.ino @@ -52,7 +52,7 @@ void loop() byte i; for (i=0; i -# -# - Write prototypes for all your functions (or define them before you -# call them). A prototype declares the types of parameters a -# function will take and what type of value it will return. This -# means that you can have a call to a function before the definition -# of the function. A function prototype looks like the first line of -# the function, with a semi-colon at the end. For example: -# int digitalRead(int pin); -# -# Instructions for using the makefile: -# -# 1. Copy this file into the folder with your sketch. -# -# 2. Below, modify the line containing "TARGET" to refer to the name of -# of your program's file without an extension (e.g. TARGET = foo). -# -# 3. Modify the line containg "ARDUINO" to point the directory that -# contains the Arduino core (for normal Arduino installations, this -# is the hardware/cores/arduino sub-directory). -# -# 4. Modify the line containing "PORT" to refer to the filename -# representing the USB or serial connection to your Arduino board -# (e.g. PORT = /dev/tty.USB0). If the exact name of this file -# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*). -# -# 5. At the command line, change to the directory containing your -# program's file and the makefile. -# -# 6. Type "make" and press enter to compile/verify your program. -# -# 7. Type "make upload", reset your Arduino board, and press enter to -# upload your program to the Arduino board. -# -# $Id: Makefile,v 1.7 2007/04/13 05:28:23 eighthave Exp $ - -PORT = /dev/tty.usbserial-* -TARGET := $(shell pwd | sed 's|.*/\(.*\)|\1|') -ARDUINO = /Applications/arduino -ARDUINO_SRC = $(ARDUINO)/hardware/cores/arduino -ARDUINO_LIB_SRC = $(ARDUINO)/hardware/libraries -ARDUINO_TOOLS = $(ARDUINO)/hardware/tools -INCLUDE = -I$(ARDUINO_SRC) -I$(ARDUINO)/hardware/tools/avr/avr/include \ - -I$(ARDUINO_LIB_SRC)/EEPROM \ - -I$(ARDUINO_LIB_SRC)/Firmata \ - -I$(ARDUINO_LIB_SRC)/Matrix \ - -I$(ARDUINO_LIB_SRC)/Servo \ - -I$(ARDUINO_LIB_SRC)/Wire \ - -I$(ARDUINO_LIB_SRC) -SRC = $(wildcard $(ARDUINO_SRC)/*.c) -CXXSRC = applet/$(TARGET).cpp $(ARDUINO_SRC)/HardwareSerial.cpp \ - $(ARDUINO_LIB_SRC)/EEPROM/EEPROM.cpp \ - $(ARDUINO_LIB_SRC)/Firmata/Firmata.cpp \ - $(ARDUINO_LIB_SRC)/Servo/Servo.cpp \ - $(ARDUINO_SRC)/Print.cpp \ - $(ARDUINO_SRC)/WMath.cpp -HEADERS = $(wildcard $(ARDUINO_SRC)/*.h) $(wildcard $(ARDUINO_LIB_SRC)/*/*.h) - -MCU = atmega168 -#MCU = atmega8 -F_CPU = 16000000 -FORMAT = ihex -UPLOAD_RATE = 19200 - -# Name of this Makefile (used for "make depend"). -MAKEFILE = Makefile - -# Debugging format. -# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. -# AVR (extended) COFF requires stabs, plus an avr-objcopy run. -DEBUG = stabs - -OPT = s - -# Place -D or -U options here -CDEFS = -DF_CPU=$(F_CPU) -CXXDEFS = -DF_CPU=$(F_CPU) - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 -CDEBUG = -g$(DEBUG) -CWARN = -Wall -Wstrict-prototypes -CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -#CEXTRA = -Wa,-adhlns=$(<:.c=.lst) - -CFLAGS = $(CDEBUG) $(CDEFS) $(INCLUDE) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) -CXXFLAGS = $(CDEFS) $(INCLUDE) -O$(OPT) -#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs -LDFLAGS = - - -# Programming support using avrdude. Settings and variables. -AVRDUDE_PROGRAMMER = stk500 -AVRDUDE_PORT = $(PORT) -AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex -AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ - -b $(UPLOAD_RATE) -q -V - -# Program settings -ARDUINO_AVR_BIN = $(ARDUINO_TOOLS)/avr/bin -CC = $(ARDUINO_AVR_BIN)/avr-gcc -CXX = $(ARDUINO_AVR_BIN)/avr-g++ -OBJCOPY = $(ARDUINO_AVR_BIN)/avr-objcopy -OBJDUMP = $(ARDUINO_AVR_BIN)/avr-objdump -SIZE = $(ARDUINO_AVR_BIN)/avr-size -NM = $(ARDUINO_AVR_BIN)/avr-nm -#AVRDUDE = $(ARDUINO_AVR_BIN)/avrdude -AVRDUDE = avrdude -REMOVE = rm -f -MV = mv -f - -# Define all object files. -OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) - -# Define all listing files. -LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) -ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - -# Default target. -all: build - -build: applet/$(TARGET).hex - -eep: applet/$(TARGET).eep -lss: applet/$(TARGET).lss -sym: applet/$(TARGET).sym - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT=$(OBJCOPY) --debugging \ ---change-section-address .data-0x800000 \ ---change-section-address .bss-0x800000 \ ---change-section-address .noinit-0x800000 \ ---change-section-address .eeprom-0x810000 - - -coff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -extcoff: applet/$(TARGET).elf - $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf applet/$(TARGET).cof - - -.SUFFIXES: .elf .hex .eep .lss .sym .pde - -.elf.hex: - $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ - -.elf.eep: - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ - -# Create extended listing file from ELF output file. -.elf.lss: - $(OBJDUMP) -h -S $< > $@ - -# Create a symbol table from ELF output file. -.elf.sym: - $(NM) -n $< > $@ - - -# Compile: create object files from C++ source files. -.cpp.o: $(HEADERS) - $(CXX) -c $(ALL_CXXFLAGS) $< -o $@ - -# Compile: create object files from C source files. -.c.o: $(HEADERS) - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -.c.s: - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -.S.o: - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - - -applet/$(TARGET).cpp: $(TARGET).pde - test -d applet || mkdir applet - echo '#include "WProgram.h"' > applet/$(TARGET).cpp - echo '#include "avr/interrupt.h"' >> applet/$(TARGET).cpp - sed -n 's|^\(void .*)\).*|\1;|p' $(TARGET).pde | grep -v 'setup()' | \ - grep -v 'loop()' >> applet/$(TARGET).cpp - cat $(TARGET).pde >> applet/$(TARGET).cpp - cat $(ARDUINO_SRC)/main.cxx >> applet/$(TARGET).cpp - -# Link: create ELF output file from object files. -applet/$(TARGET).elf: applet/$(TARGET).cpp $(OBJ) - $(CC) $(ALL_CFLAGS) $(OBJ) -lm --output $@ $(LDFLAGS) -# $(CC) $(ALL_CFLAGS) $(OBJ) $(ARDUINO_TOOLS)/avr/avr/lib/avr5/crtm168.o --output $@ $(LDFLAGS) - -pd_close_serial: - echo 'close;' | /Applications/Pd-extended.app/Contents/Resources/bin/pdsend 34567 || true - -# Program the device. -upload: applet/$(TARGET).hex - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) - - -pd_test: build pd_close_serial upload - -# Target: clean project. -clean: - $(REMOVE) -- applet/$(TARGET).hex applet/$(TARGET).eep \ - applet/$(TARGET).cof applet/$(TARGET).elf $(TARGET).map \ - applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp \ - $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) - rmdir -- applet - -depend: - if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ - then \ - sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ - $(MAKEFILE).$$$$ && \ - $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ - fi - echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ - >> $(MAKEFILE); \ - $(CC) -M -mmcu=$(MCU) $(CDEFS) $(INCLUDE) $(SRC) $(ASRC) >> $(MAKEFILE) - -.PHONY: all build eep lss sym coff extcoff clean depend pd_close_serial pd_test - -# for emacs -etags: - make etags_`uname -s` - etags *.pde \ - $(ARDUINO_SRC)/*.[ch] \ - $(ARDUINO_SRC)/*.cpp \ - $(ARDUINO_LIB_SRC)/*/*.[ch] \ - $(ARDUINO_LIB_SRC)/*/*.cpp \ - $(ARDUINO)/hardware/tools/avr/avr/include/avr/*.[ch] \ - $(ARDUINO)/hardware/tools/avr/avr/include/*.[ch] - -etags_Darwin: -# etags -a - -etags_Linux: -# etags -a /usr/include/*.h linux/input.h /usr/include/sys/*.h - -etags_MINGW: -# etags -a /usr/include/*.h /usr/include/sys/*.h - - -path: - echo $(PATH) - echo $$PATH - diff --git a/libraries/Firmata/examples/StandardFirmata/StandardFirmata.pde b/libraries/Firmata/examples/StandardFirmata/StandardFirmata.ino similarity index 99% rename from libraries/Firmata/examples/StandardFirmata/StandardFirmata.pde rename to libraries/Firmata/examples/StandardFirmata/StandardFirmata.ino index cd433663f..51f090c31 100644 --- a/libraries/Firmata/examples/StandardFirmata/StandardFirmata.pde +++ b/libraries/Firmata/examples/StandardFirmata/StandardFirmata.ino @@ -323,7 +323,7 @@ void setup() { byte i; - Firmata.setFirmwareVersion(2, 2); + Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION); Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); diff --git a/libraries/Firmata/examples/StandardFirmata_2_2_forUNO_0_3/StandardFirmata_2_2_forUNO_0_3.pde b/libraries/Firmata/examples/StandardFirmata_2_2_forUNO_0_3/StandardFirmata_2_2_forUNO_0_3.pde deleted file mode 100644 index 4cfa6581b..000000000 --- a/libraries/Firmata/examples/StandardFirmata_2_2_forUNO_0_3/StandardFirmata_2_2_forUNO_0_3.pde +++ /dev/null @@ -1,436 +0,0 @@ -/* - This introduces modifications on the normal Firmata made for Arduino so that the LED - blinks until receiving the first command over serial. - - Copyright (C) 2010 David Cuartielles. All rights reserved. - - based at 99.9% on Firmata by HC Steiner according to the following license terms: - - Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - See file LICENSE.txt for further informations on licensing terms. - - formatted using the GNU C formatting and indenting -*/ - -/* - * TODO: use Program Control to load stored profiles from EEPROM - */ - -#include -#include - -/*============================================================================== - * GLOBAL VARIABLES - *============================================================================*/ - -/* has the command arrived? */ -boolean firstCommand = false; -int dataOnSerial = 0; -boolean statusLed = false; - -/* analog inputs */ -int analogInputsToReport = 0; // bitwise array to store pin reporting - -/* digital input ports */ -byte reportPINs[TOTAL_PORTS]; // 1 = report this port, 0 = silence -byte previousPINs[TOTAL_PORTS]; // previous 8 bits sent - -/* pins configuration */ -byte pinConfig[TOTAL_PINS]; // configuration of every pin -byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 = anything else -int pinState[TOTAL_PINS]; // any value that has been written - -/* timer variables */ -unsigned long currentMillis; // store the current value from millis() -unsigned long previousMillis; // for comparison with currentMillis -int samplingInterval = 19; // how often to run the main loop (in ms) -unsigned long toggleMillis; - -Servo servos[MAX_SERVOS]; - -/*============================================================================== - * FUNCTIONS - *============================================================================*/ - -void toggleLed() -{ - if (millis() - toggleMillis > 500) { - statusLed = !statusLed; - digitalWrite(13, statusLed); - toggleMillis = millis(); - } -} - -void outputPort(byte portNumber, byte portValue, byte forceSend) -{ - // pins not configured as INPUT are cleared to zeros - portValue = portValue & portConfigInputs[portNumber]; - // only send if the value is different than previously sent - if(forceSend || previousPINs[portNumber] != portValue) { - Firmata.sendDigitalPort(portNumber, portValue); - previousPINs[portNumber] = portValue; - } -} - -/* ----------------------------------------------------------------------------- - * check all the active digital inputs for change of state, then add any events - * to the Serial output queue using Serial.print() */ -void checkDigitalInputs(void) -{ - /* Using non-looping code allows constants to be given to readPort(). - * The compiler will apply substantial optimizations if the inputs - * to readPort() are compile-time constants. */ - if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0, portConfigInputs[0]), false); - if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1, portConfigInputs[1]), false); - if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2, portConfigInputs[2]), false); - if (TOTAL_PORTS > 3 && reportPINs[3]) outputPort(3, readPort(3, portConfigInputs[3]), false); - if (TOTAL_PORTS > 4 && reportPINs[4]) outputPort(4, readPort(4, portConfigInputs[4]), false); - if (TOTAL_PORTS > 5 && reportPINs[5]) outputPort(5, readPort(5, portConfigInputs[5]), false); - if (TOTAL_PORTS > 6 && reportPINs[6]) outputPort(6, readPort(6, portConfigInputs[6]), false); - if (TOTAL_PORTS > 7 && reportPINs[7]) outputPort(7, readPort(7, portConfigInputs[7]), false); - if (TOTAL_PORTS > 8 && reportPINs[8]) outputPort(8, readPort(8, portConfigInputs[8]), false); - if (TOTAL_PORTS > 9 && reportPINs[9]) outputPort(9, readPort(9, portConfigInputs[9]), false); - if (TOTAL_PORTS > 10 && reportPINs[10]) outputPort(10, readPort(10, portConfigInputs[10]), false); - if (TOTAL_PORTS > 11 && reportPINs[11]) outputPort(11, readPort(11, portConfigInputs[11]), false); - if (TOTAL_PORTS > 12 && reportPINs[12]) outputPort(12, readPort(12, portConfigInputs[12]), false); - if (TOTAL_PORTS > 13 && reportPINs[13]) outputPort(13, readPort(13, portConfigInputs[13]), false); - if (TOTAL_PORTS > 14 && reportPINs[14]) outputPort(14, readPort(14, portConfigInputs[14]), false); - if (TOTAL_PORTS > 15 && reportPINs[15]) outputPort(15, readPort(15, portConfigInputs[15]), false); -} - -// ----------------------------------------------------------------------------- -/* sets the pin mode to the correct state and sets the relevant bits in the - * two bit-arrays that track Digital I/O and PWM status - */ -void setPinModeCallback(byte pin, int mode) -{ - if (IS_PIN_SERVO(pin) && mode != SERVO && servos[PIN_TO_SERVO(pin)].attached()) { - servos[PIN_TO_SERVO(pin)].detach(); - } - if (IS_PIN_ANALOG(pin)) { - reportAnalogCallback(PIN_TO_ANALOG(pin), mode == ANALOG ? 1 : 0); // turn on/off reporting - } - if (IS_PIN_DIGITAL(pin)) { - if (mode == INPUT) { - portConfigInputs[pin/8] |= (1 << (pin & 7)); - } else { - portConfigInputs[pin/8] &= ~(1 << (pin & 7)); - } - } - pinState[pin] = 0; - switch(mode) { - case ANALOG: - if (IS_PIN_ANALOG(pin)) { - if (IS_PIN_DIGITAL(pin)) { - pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver - digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups - } - pinConfig[pin] = ANALOG; - } - break; - case INPUT: - if (IS_PIN_DIGITAL(pin)) { - pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver - digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups - pinConfig[pin] = INPUT; - } - break; - case OUTPUT: - if (IS_PIN_DIGITAL(pin)) { - digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable PWM - pinMode(PIN_TO_DIGITAL(pin), OUTPUT); - pinConfig[pin] = OUTPUT; - } - break; - case PWM: - if (IS_PIN_PWM(pin)) { - pinMode(PIN_TO_PWM(pin), OUTPUT); - analogWrite(PIN_TO_PWM(pin), 0); - pinConfig[pin] = PWM; - } - break; - case SERVO: - if (IS_PIN_SERVO(pin)) { - pinConfig[pin] = SERVO; - if (!servos[PIN_TO_SERVO(pin)].attached()) { - servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin)); - } else { - Firmata.sendString("Servo only on pins from 2 to 13"); - } - } - break; - case I2C: - pinConfig[pin] = mode; - Firmata.sendString("I2C mode not yet supported"); - break; - default: - Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM - } - // TODO: save status to EEPROM here, if changed -} - -void analogWriteCallback(byte pin, int value) -{ - if (pin < TOTAL_PINS) { - switch(pinConfig[pin]) { - case SERVO: - if (IS_PIN_SERVO(pin)) - servos[PIN_TO_SERVO(pin)].write(value); - pinState[pin] = value; - break; - case PWM: - if (IS_PIN_PWM(pin)) - analogWrite(PIN_TO_PWM(pin), value); - pinState[pin] = value; - break; - } - } -} - -void digitalWriteCallback(byte port, int value) -{ - byte pin, lastPin, mask=1, pinWriteMask=0; - - if (port < TOTAL_PORTS) { - // create a mask of the pins on this port that are writable. - lastPin = port*8+8; - if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS; - for (pin=port*8; pin < lastPin; pin++) { - // do not disturb non-digital pins (eg, Rx & Tx) - if (IS_PIN_DIGITAL(pin)) { - // only write to OUTPUT and INPUT (enables pullup) - // do not touch pins in PWM, ANALOG, SERVO or other modes - if (pinConfig[pin] == OUTPUT || pinConfig[pin] == INPUT) { - pinWriteMask |= mask; - pinState[pin] = ((byte)value & mask) ? 1 : 0; - } - } - mask = mask << 1; - } - writePort(port, (byte)value, pinWriteMask); - } -} - - -// ----------------------------------------------------------------------------- -/* sets bits in a bit array (int) to toggle the reporting of the analogIns - */ -//void FirmataClass::setAnalogPinReporting(byte pin, byte state) { -//} -void reportAnalogCallback(byte analogPin, int value) -{ - if (analogPin < TOTAL_ANALOG_PINS) { - if(value == 0) { - analogInputsToReport = analogInputsToReport &~ (1 << analogPin); - } else { - analogInputsToReport = analogInputsToReport | (1 << analogPin); - } - } - // TODO: save status to EEPROM here, if changed -} - -void reportDigitalCallback(byte port, int value) -{ - if (port < TOTAL_PORTS) { - reportPINs[port] = (byte)value; - } - // do not disable analog reporting on these 8 pins, to allow some - // pins used for digital, others analog. Instead, allow both types - // of reporting to be enabled, but check if the pin is configured - // as analog when sampling the analog inputs. Likewise, while - // scanning digital pins, portConfigInputs will mask off values from any - // pins configured as analog -} - -/*============================================================================== - * SYSEX-BASED commands - *============================================================================*/ - -void sysexCallback(byte command, byte argc, byte *argv) -{ - switch(command) { - case SERVO_CONFIG: - if(argc > 4) { - // these vars are here for clarity, they'll optimized away by the compiler - byte pin = argv[0]; - int minPulse = argv[1] + (argv[2] << 7); - int maxPulse = argv[3] + (argv[4] << 7); - - if (IS_PIN_SERVO(pin)) { - // servos are pins from 2 to 13, so offset for array - if (servos[PIN_TO_SERVO(pin)].attached()) - servos[PIN_TO_SERVO(pin)].detach(); - servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse); - setPinModeCallback(pin, SERVO); - } - } - break; - case SAMPLING_INTERVAL: - if (argc > 1) - samplingInterval = argv[0] + (argv[1] << 7); - else - Firmata.sendString("Not enough data"); - break; - case EXTENDED_ANALOG: - if (argc > 1) { - int val = argv[1]; - if (argc > 2) val |= (argv[2] << 7); - if (argc > 3) val |= (argv[3] << 14); - analogWriteCallback(argv[0], val); - } - break; - case CAPABILITY_QUERY: - Serial.write(START_SYSEX); - Serial.write(CAPABILITY_RESPONSE); - for (byte pin=0; pin < TOTAL_PINS; pin++) { - if (IS_PIN_DIGITAL(pin)) { - Serial.write((byte)INPUT); - Serial.write(1); - Serial.write((byte)OUTPUT); - Serial.write(1); - } - if (IS_PIN_ANALOG(pin)) { - Serial.write(ANALOG); - Serial.write(10); - } - if (IS_PIN_PWM(pin)) { - Serial.write(PWM); - Serial.write(8); - } - if (IS_PIN_SERVO(pin)) { - Serial.write(SERVO); - Serial.write(14); - } - Serial.write(127); - } - Serial.write(END_SYSEX); - break; - case PIN_STATE_QUERY: - if (argc > 0) { - byte pin=argv[0]; - Serial.write(START_SYSEX); - Serial.write(PIN_STATE_RESPONSE); - Serial.write(pin); - if (pin < TOTAL_PINS) { - Serial.write((byte)pinConfig[pin]); - Serial.write((byte)pinState[pin] & 0x7F); - if (pinState[pin] & 0xFF80) Serial.write((byte)(pinState[pin] >> 7) & 0x7F); - if (pinState[pin] & 0xC000) Serial.write((byte)(pinState[pin] >> 14) & 0x7F); - } - Serial.write(END_SYSEX); - } - break; - case ANALOG_MAPPING_QUERY: - Serial.write(START_SYSEX); - Serial.write(ANALOG_MAPPING_RESPONSE); - for (byte pin=0; pin < TOTAL_PINS; pin++) { - Serial.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127); - } - Serial.write(END_SYSEX); - break; - } -} - -/*============================================================================== - * SETUP() - *============================================================================*/ -void setup() -{ - byte i; - - Firmata.setFirmwareVersion(2, 2); - - Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); - Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); - Firmata.attach(REPORT_ANALOG, reportAnalogCallback); - Firmata.attach(REPORT_DIGITAL, reportDigitalCallback); - Firmata.attach(SET_PIN_MODE, setPinModeCallback); - Firmata.attach(START_SYSEX, sysexCallback); - - // TODO: load state from EEPROM here - - /* these are initialized to zero by the compiler startup code - for (i=0; i < TOTAL_PORTS; i++) { - reportPINs[i] = false; - portConfigInputs[i] = 0; - previousPINs[i] = 0; - } - */ - for (i=0; i < TOTAL_PINS; i++) { - if (IS_PIN_ANALOG(i)) { - // turns off pullup, configures everything - setPinModeCallback(i, ANALOG); - } else { - // sets the output to 0, configures portConfigInputs - setPinModeCallback(i, OUTPUT); - } - } - // by defult, do not report any analog inputs - analogInputsToReport = 0; - - Firmata.begin(57600); - - /* send digital inputs to set the initial state on the host computer, - * since once in the loop(), this firmware will only send on change */ - for (i=0; i < TOTAL_PORTS; i++) { - outputPort(i, readPort(i, portConfigInputs[i]), true); - } - - /* init the toggleLed counter */ - toggleMillis = millis(); - pinMode(13, OUTPUT); -} - -/*============================================================================== - * LOOP() - *============================================================================*/ -void loop() -{ - byte pin, analogPin; - - /* DIGITALREAD - as fast as possible, check for changes and output them to the - * FTDI buffer using Serial.print() */ - checkDigitalInputs(); - - //XXX: hack Firmata to blink until serial command arrives - dataOnSerial = Firmata.available(); - if (dataOnSerial > 0 && !firstCommand) { - firstCommand = true; - } - //XXX: do the blink if the first command hasn't arrived yet - // configures pin 13 as output and then back as input - if (!firstCommand) { - toggleLed(); - } - - /* SERIALREAD - processing incoming messagse as soon as possible, while still - * checking digital inputs. */ - while(dataOnSerial) { - Firmata.processInput(); - dataOnSerial = Firmata.available(); - } - - /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over - * 60 bytes. use a timer to sending an event character every 4 ms to - * trigger the buffer to dump. */ - - currentMillis = millis(); - if (currentMillis - previousMillis > samplingInterval) { - previousMillis += samplingInterval; - /* ANALOGREAD - do all analogReads() at the configured sampling interval */ - for(pin=0; pin