Skip to content

Commit b722028

Browse files
committed
Updating to Firmata r82 (e.g. including I2C in StandardFirmata).
http://code.google.com/p/arduino/issues/detail?id=633
1 parent 5ba38fa commit b722028

File tree

11 files changed

+377
-49
lines changed

11 files changed

+377
-49
lines changed

libraries/Firmata/Boards.h

+14-10
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ writePort(port, value, bitmask): Write an 8 bit port.
124124
* Board Specific Configuration
125125
*============================================================================*/
126126

127+
#ifndef digitalPinHasPWM
128+
#define digitalPinHasPWM(p) IS_PIN_DIGITAL(p)
129+
#endif
130+
127131
// Arduino Duemilanove, Diecimila, and NG
128132
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
129133
#if defined(NUM_ANALOG_INPUTS) && NUM_ANALOG_INPUTS == 6
@@ -136,7 +140,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
136140
#define VERSION_BLINK_PIN 13
137141
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19)
138142
#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
139-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
143+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
140144
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS)
141145
#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19)
142146
#define PIN_TO_DIGITAL(p) (p)
@@ -151,7 +155,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
151155
#define VERSION_BLINK_PIN WLED
152156
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
153157
#define IS_PIN_ANALOG(p) ((p) >= FIRST_ANALOG_PIN && (p) < (FIRST_ANALOG_PIN+TOTAL_ANALOG_PINS))
154-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
158+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
155159
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
156160
#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL)
157161
#define PIN_TO_DIGITAL(p) (p)
@@ -167,7 +171,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
167171
#define VERSION_BLINK_PIN 13
168172
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19)
169173
#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) <= 19)
170-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
174+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
171175
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS)
172176
#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19)
173177
#define PIN_TO_DIGITAL(p) (p)
@@ -178,13 +182,13 @@ writePort(port, value, bitmask): Write an 8 bit port.
178182

179183

180184
// Arduino Mega
181-
#elif defined(__AVR_ATmega1280__)
185+
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
182186
#define TOTAL_ANALOG_PINS 16
183187
#define TOTAL_PINS 70 // 54 digital + 16 analog
184188
#define VERSION_BLINK_PIN 13
185189
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS)
186190
#define IS_PIN_ANALOG(p) ((p) >= 54 && (p) < TOTAL_PINS)
187-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
191+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
188192
#define IS_PIN_SERVO(p) ((p) >= 2 && (p) - 2 < MAX_SERVOS)
189193
#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21)
190194
#define PIN_TO_DIGITAL(p) (p)
@@ -200,7 +204,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
200204
#define VERSION_BLINK_PIN 6
201205
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
202206
#define IS_PIN_ANALOG(p) (0)
203-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
207+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
204208
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
205209
#define IS_PIN_I2C(p) (0)
206210
#define PIN_TO_DIGITAL(p) (p)
@@ -216,7 +220,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
216220
#define VERSION_BLINK_PIN 11
217221
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
218222
#define IS_PIN_ANALOG(p) ((p) >= 11 && (p) <= 22)
219-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
223+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
220224
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
221225
#define IS_PIN_I2C(p) ((p) == 5 || (p) == 6)
222226
#define PIN_TO_DIGITAL(p) (p)
@@ -232,7 +236,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
232236
#define VERSION_BLINK_PIN 6
233237
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS)
234238
#define IS_PIN_ANALOG(p) ((p) >= 38 && (p) < TOTAL_PINS)
235-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
239+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
236240
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
237241
#define IS_PIN_I2C(p) ((p) == 0 || (p) == 1)
238242
#define PIN_TO_DIGITAL(p) (p)
@@ -248,7 +252,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
248252
#define VERSION_BLINK_PIN 0
249253
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS)
250254
#define IS_PIN_ANALOG(p) ((p) >= 24 && (p) < TOTAL_PINS)
251-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
255+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
252256
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
253257
#define IS_PIN_I2C(p) ((p) == 16 || (p) == 17)
254258
#define PIN_TO_DIGITAL(p) (p)
@@ -264,7 +268,7 @@ writePort(port, value, bitmask): Write an 8 bit port.
264268
#define VERSION_BLINK_PIN 13
265269
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS)
266270
#define IS_PIN_ANALOG(p) ((p) >= 36 && (p) < TOTAL_PINS)
267-
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
271+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
268272
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
269273
#define IS_PIN_I2C(p) ((p) == 4 || (p) == 5)
270274
#define PIN_TO_DIGITAL(p) (p)

libraries/Firmata/Firmata.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ void FirmataClass::begin(long speed)
6868
Serial.begin(speed);
6969
FirmataSerial = Serial;
7070
blinkVersion();
71-
delay(300);
7271
printVersion();
7372
printFirmwareVersion();
7473
}
@@ -92,11 +91,10 @@ void FirmataClass::blinkVersion(void)
9291
{
9392
// flash the pin with the protocol version
9493
pinMode(VERSION_BLINK_PIN,OUTPUT);
95-
pin13strobe(FIRMATA_MAJOR_VERSION, 200, 400);
96-
delay(300);
97-
pin13strobe(2,1,4); // separator, a quick burst
98-
delay(300);
99-
pin13strobe(FIRMATA_MINOR_VERSION, 200, 400);
94+
pin13strobe(FIRMATA_MAJOR_VERSION, 40, 210);
95+
delay(250);
96+
pin13strobe(FIRMATA_MINOR_VERSION, 40, 210);
97+
delay(125);
10098
}
10199

102100
void FirmataClass::printFirmwareVersion(void)

libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.ino

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please clink on the following link
7+
* to open the download page in your default browser.
8+
*
9+
* http://firmata.org/wiki/Download
10+
*/
11+
112
/*
213
* This firmware reads all inputs and sends them as fast as it can. It was
314
* inspired by the ease-of-use of the Arduino2Max program.

libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.ino

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please clink on the following link
7+
* to open the download page in your default browser.
8+
*
9+
* http://firmata.org/wiki/Download
10+
*/
11+
112
/* This firmware supports as many analog ports as possible, all analog inputs,
213
* four PWM outputs, and two with servo support.
314
*

libraries/Firmata/examples/EchoString/EchoString.ino

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please clink on the following link
7+
* to open the download page in your default browser.
8+
*
9+
* http://firmata.org/wiki/Download
10+
*/
11+
112
/* This sketch accepts strings and raw sysex messages and echos them back.
213
*
314
* This example code is in the public domain.

libraries/Firmata/examples/I2CFirmata/I2CFirmata.ino

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please clink on the following link
7+
* to open the download page in your default browser.
8+
*
9+
* http://firmata.org/wiki/Download
10+
*/
11+
112
/*
213
Copyright (C) 2009 Jeff Hoefs. All rights reserved.
314
Copyright (C) 2009 Shigeru Kobayashi. All rights reserved.

libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.ino

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please clink on the following link
7+
* to open the download page in your default browser.
8+
*
9+
* http://firmata.org/wiki/Download
10+
*/
11+
112
/*
213
Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved.
314

libraries/Firmata/examples/ServoFirmata/ServoFirmata.ino

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please clink on the following link
7+
* to open the download page in your default browser.
8+
*
9+
* http://firmata.org/wiki/Download
10+
*/
11+
112
/* This firmware supports as many servos as possible using the Servo library
213
* included in Arduino 0017
314
*

libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.ino

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please clink on the following link
7+
* to open the download page in your default browser.
8+
*
9+
* http://firmata.org/wiki/Download
10+
*/
11+
112
/* Supports as many analog inputs and analog PWM outputs as possible.
213
*
314
* This example code is in the public domain.

libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.ino

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Firmata is a generic protocol for communicating with microcontrollers
3+
* from software on a host computer. It is intended to work with
4+
* any host computer software package.
5+
*
6+
* To download a host software package, please clink on the following link
7+
* to open the download page in your default browser.
8+
*
9+
* http://firmata.org/wiki/Download
10+
*/
11+
112
/* Supports as many digital inputs and outputs as possible.
213
*
314
* This example code is in the public domain.

0 commit comments

Comments
 (0)